00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "TRunTimeLimitCommand.hh"
00017 #include "TRunManager.hh"
00018 #include "TUserInterface.hh"
00019
00020 static const Tstring _name = "/run/timelimit";
00021 static const Tstring _desc = "set time limit in second for a run scheduling.\nexample> /run/timelimit 3600 // an hour.";
00022
00023 TRunTimeLimitCommand::TRunTimeLimitCommand( TRunManager* manager )
00024 : TCommand( manager, _name, _desc )
00025 {;}
00026
00027 TRunTimeLimitCommand::~TRunTimeLimitCommand()
00028 {;}
00029
00030 Tvoid TRunTimeLimitCommand::Execute( const TstringList& arguments )
00031 {
00032 static const Tstring head = "TRunTimeLimitCommand::Execute: ";
00033 TUserInterface* ui = theRunManager -> GetUserInterface();
00034
00035 if ( arguments.empty() ) {
00036 TUint rest = alarm( alarm( 0 ) );
00037 if ( rest == 0 ) {
00038 Tcout << "this run is not scheduled by alarm." << Tendl;
00039 } else {
00040 ui -> ExecuteCommand( "/system/date" );
00041 Tcout << "this run is scheduled to stop after " << rest << " seconds." << Tendl;
00042 }
00043 } else if ( arguments.size() == 1 ) {
00044 TUint timesec = strtoul( arguments[ 0 ].c_str(), 0, 0 );
00045 TUint ret = alarm( timesec );
00046 if ( ret != 0 ) {
00047 ui -> ExecuteCommand( "/system/date" );
00048 Tcout << "this run was re-scheduled to stop after " << timesec << " seconds." << Tendl;
00049 Tcout << "last schedule is " << ret << " seconds, was removed." << Tendl;
00050 } else {
00051 Tcout << "this run was scheduled to stop after " << timesec << " seconds." << Tendl;
00052 }
00053 } else {
00054 ShowCommandDetail();
00055 }
00056
00057 return;
00058 }
00059
00060 #ifdef __CLDAQ_ROOT_DLL
00061 ClassImp(TRunTimeLimitCommand)
00062 #endif