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