00001 // ===================================================================== 00032 // ===================================================================== 00033 #ifndef CLDAQ__TRUNMANAGER_HH 00034 #define CLDAQ__TRUNMANAGER_HH 00035 00036 #include "Tglobals.h" 00037 #include "TRun.hh" 00038 #include "TSystemTimer.hh" 00039 #include "TSystemClock.hh" 00040 #include "TEnvironmentVariableTable.hh" 00041 00042 class TUserInterface; 00043 class TCommand; 00044 class TSystemAction; 00045 class TRunAction; 00046 class TEventAction; 00047 class TEventManager; 00048 class TSoftwareRunInformationModule; 00049 class TAnalysisManager; 00050 class TSystemTimer; 00051 class TReadoutBookDefinition; 00052 class TReadoutBook; 00053 class TCrateDefinition; 00054 class TCrate; 00055 00056 00131 class TRunManager 00132 { 00133 00134 protected: 00136 static TRunManager* theRunManager; 00137 00138 protected: 00140 Tstatus_t theStatus; 00141 00143 TRun theRun; 00144 00146 TSystemAction* theSystemAction; 00147 00149 TRunAction* theRunAction; 00150 00152 TEventManager* theEventManager; 00153 00155 TUserInterface* theUserInterface; 00156 00158 Tthread_t theThreadOfEventLoop; 00159 00161 TSoftwareRunInformationModule* theRunInformationModule; 00162 00164 TAnalysisManager* theAnalysisManager; 00165 00167 TSystemTimer theRunTimer; 00168 00170 TSystemClock theRunClock; 00171 00173 TReadoutBookDefinition* theReadoutBookDefinition; 00174 00176 TReadoutBook* theReadoutBook; 00177 00179 TCrateDefinition* theCrateDefinition; 00180 00182 TCrate* theCrate; 00183 00185 TEnvironmentVariableTable theEnvironmentVariableTable; 00186 00188 Tint theEventLimit; 00189 00190 public: 00192 00197 TRunManager( TUserInterface* ui = 0 ); 00198 00200 virtual ~TRunManager(); 00201 00202 public: 00204 TUserInterface* GetUserInterface() const; 00205 00207 const TRun& GetRun() const; 00208 00210 TRun& GetRun(); 00211 00213 Tint GetRunID() const; 00214 00216 Tvoid SetRunID( Tint id ); 00217 00219 TSystemAction* GetSystemAction() const; 00220 00222 TRunAction* GetRunAction() const; 00223 00225 TEventManager* GetEventManager() const; 00226 00228 Tvoid SetUserInterface( TUserInterface* ui ); 00229 00231 Tint SetUserCommand( TCommand* command ); 00232 00234 Tvoid SetRun( const TRun& run ); 00235 00237 Tvoid SetSystemAction( TSystemAction* action ); 00238 00240 Tvoid SetRunAction( TRunAction* action ); 00241 00243 Tvoid SetEventAction( TEventAction* action ); 00244 00246 Tvoid SetEventManager( TEventManager* manager ); 00247 00249 Tstatus_t GetStatus() const; 00250 00252 Tvoid SetStatus( Tstatus_t status ); 00253 00255 Tthread_t GetThreadOfEventLoop() const; 00256 00258 Tvoid SetThreadOfEventLoop( Tthread_t thread ); 00259 00261 TSoftwareRunInformationModule* GetRunInformationModule() const; 00262 00264 TAnalysisManager* GetAnalysisManager() const; 00265 00267 const TSystemTimer& GetRunTimer() const; 00268 00270 TSystemTimer& GetRunTimer(); 00271 00273 Tvoid SetRunTimer( const TSystemTimer& timer ); 00274 00276 const TSystemClock& GetRunClock() const; 00277 00279 TSystemClock& GetRunClock(); 00280 00282 Tvoid SetRunClock( const TSystemClock& clock ); 00283 00285 TReadoutBookDefinition* GetReadoutBookDefinition() const; 00286 00288 TReadoutBook* GetReadoutBook() const; 00289 00291 TCrateDefinition* GetCrateDefinition() const; 00292 00294 TCrate* GetCrate() const; 00295 00297 Tvoid SetReadoutBookDefinition( TReadoutBookDefinition* definition ); 00298 00300 Tvoid SetCrateDefinition( TCrateDefinition* definition ); 00301 00303 const TEnvironmentVariableTable& GetEnvironmentVariableTable() const; 00304 00306 TEnvironmentVariableTable& GetEnvironmentVariableTable(); 00307 00309 Tvoid SetEnvironmentVariableTable( const TEnvironmentVariableTable& table ); 00310 00312 Tint GetEventLimit() const; 00313 00315 Tvoid SetEventLimit( Tint nevents ); 00316 00317 public: 00319 virtual Tvoid SessionStart(); 00320 00322 virtual Tvoid ShowStatus() const; 00323 00325 virtual Tvoid PopupLogo() const; 00326 00328 virtual Tvoid PopdownLogo() const; 00329 00331 virtual Tvoid PrintAuthorInformation( Tostream& tos = Tcout ) const; 00332 00334 virtual Tvoid ShutdownRun(); 00335 00337 virtual Tvoid StartRun(); 00338 00340 virtual Tvoid StartRun( Tint runid ); 00341 00343 virtual Tvoid StopRun(); 00344 00346 virtual Tvoid SuspendRun(); 00347 00349 virtual Tvoid ResumeRun(); 00350 00352 virtual Tvoid SetRunInformationModule( TSoftwareRunInformationModule* module ); 00353 00355 virtual Tvoid SetRunInformationModule( const Tstring& id ); 00356 00358 virtual Tvoid SetRunInformationModule( Tint slot ); 00359 00361 virtual Tvoid SetAnalysisManager( TAnalysisManager* manager ); 00362 00363 public: 00365 static TRunManager* GetRunManager(); 00366 00367 protected: 00369 static Tvoid* doEventLoop( Tvoid* arguments ); 00370 00372 static Tvoid* showLogo( Tvoid* arguments ); 00373 00375 static Tvoid catchAlarmSignal( Tint sigid ); 00376 00377 public: 00379 virtual Tvoid GoEventLoop(); 00380 00382 virtual Tvoid WaitReturnFromEventLoop(); 00383 00384 protected: 00386 virtual TstringList divide( const Tstring& input ) const; 00387 00389 virtual Tvoid installDefaultCommand(); 00390 00391 }; 00392 00393 inline TRunManager* TRunManager::GetRunManager() 00394 { 00395 return theRunManager; 00396 } 00397 00398 inline TUserInterface* TRunManager::GetUserInterface() const 00399 { 00400 return theUserInterface; 00401 } 00402 00403 inline Tvoid TRunManager::SetRun( const TRun& run ) 00404 { 00405 theRun = run; 00406 return; 00407 } 00408 00409 inline const TRun& TRunManager::GetRun() const 00410 { 00411 return theRun; 00412 } 00413 00414 inline TRun& TRunManager::GetRun() 00415 { 00416 return theRun; 00417 } 00418 00419 inline Tint TRunManager::GetRunID() const 00420 { 00421 return theRun.GetRunID(); 00422 } 00423 00424 inline Tvoid TRunManager::SetRunID( Tint id ) 00425 { 00426 theRun.SetRunID( id ); 00427 return; 00428 } 00429 00430 inline TSystemAction* TRunManager::GetSystemAction() const 00431 { 00432 return theSystemAction; 00433 } 00434 00435 inline TRunAction* TRunManager::GetRunAction() const 00436 { 00437 return theRunAction; 00438 } 00439 00440 inline TEventManager* TRunManager::GetEventManager() const 00441 { 00442 return theEventManager; 00443 } 00444 00445 inline Tstatus_t TRunManager::GetStatus() const 00446 { 00447 return theStatus; 00448 } 00449 00450 inline Tvoid TRunManager::SetStatus( Tstatus_t status ) 00451 { 00452 theStatus = status; 00453 return; 00454 } 00455 00456 inline Tthread_t TRunManager::GetThreadOfEventLoop() const 00457 { 00458 return theThreadOfEventLoop; 00459 } 00460 00461 inline Tvoid TRunManager::SetThreadOfEventLoop( Tthread_t thread ) 00462 { 00463 theThreadOfEventLoop = thread; 00464 return; 00465 } 00466 00467 inline TSoftwareRunInformationModule* TRunManager::GetRunInformationModule() const 00468 { 00469 return theRunInformationModule; 00470 } 00471 00472 inline TAnalysisManager* TRunManager::GetAnalysisManager() const 00473 { 00474 return theAnalysisManager; 00475 } 00476 00477 inline const TSystemTimer& TRunManager::GetRunTimer() const 00478 { 00479 return theRunTimer; 00480 } 00481 00482 inline TSystemTimer& TRunManager::GetRunTimer() 00483 { 00484 return theRunTimer; 00485 } 00486 00487 inline TReadoutBookDefinition* TRunManager::GetReadoutBookDefinition() const 00488 { 00489 return theReadoutBookDefinition; 00490 } 00491 00492 inline TReadoutBook* TRunManager::GetReadoutBook() const 00493 { 00494 return theReadoutBook; 00495 } 00496 00497 inline TCrateDefinition* TRunManager::GetCrateDefinition() const 00498 { 00499 return theCrateDefinition; 00500 } 00501 00502 inline TCrate* TRunManager::GetCrate() const 00503 { 00504 return theCrate; 00505 } 00506 00507 inline Tvoid TRunManager::SetRunTimer( const TSystemTimer& timer ) 00508 { 00509 theRunTimer = timer; 00510 return; 00511 } 00512 00513 inline const TEnvironmentVariableTable& TRunManager::GetEnvironmentVariableTable() const 00514 { 00515 return theEnvironmentVariableTable; 00516 } 00517 00518 inline TEnvironmentVariableTable& TRunManager::GetEnvironmentVariableTable() 00519 { 00520 return theEnvironmentVariableTable; 00521 } 00522 00523 inline Tvoid TRunManager::SetEnvironmentVariableTable( const TEnvironmentVariableTable& table ) 00524 { 00525 theEnvironmentVariableTable = table; 00526 return; 00527 } 00528 00529 inline const TSystemClock& TRunManager::GetRunClock() const 00530 { 00531 return theRunClock; 00532 } 00533 00534 inline TSystemClock& TRunManager::GetRunClock() 00535 { 00536 return theRunClock; 00537 } 00538 00539 inline Tvoid TRunManager::SetRunClock( const TSystemClock& clock ) 00540 { 00541 theRunClock = clock; 00542 return; 00543 } 00544 00545 inline Tint TRunManager::GetEventLimit() const 00546 { 00547 return theEventLimit; 00548 } 00549 00550 inline Tvoid TRunManager::SetEventLimit( Tint nevents ) 00551 { 00552 theEventLimit = nevents; 00553 return; 00554 } 00555 00556 #endif