32 #define _GLIBCXX_USE_NANOSLEEP 50 EventGeneratorManager>
53 App(
const std::string & sName_):
59 std::vector<option> doGetOptions()
const 61 return {{
"starttime", 1,
nullptr,
's'},
62 {
"nextday", 0,
nullptr,
'n'}};
66 std::string doGetOptString()
const 71 bool doProcessOption(
int iOptOpt,
const char * pzOptArg)
77 unsigned hour, min, sec;
79 if(sscanf(pzOptArg,
"%02u:%02u:%02u", &hour, &min, &sec) == 3)
81 secondsStart_ = std::chrono::seconds{(hour * 3600) + (min * 60) + sec};
85 std::cerr<<
"Error in format of start time " 87 <<
" --starttime HH:MM:SS"<<std::endl;
104 virtual std::vector<std::string> doGetOptionsUsage()
const 108 " -s, --starttime TIME Set the start time HH:MM:SS",
109 " -n, --nextday Set the start time to the next day"};
113 void doStart()
override 115 pManager_ = pDirector_->construct(getUUID());
117 if(secondsStart_ != std::chrono::seconds::zero())
119 std::time_t t = std::time(
nullptr);
122 struct tm *tm_ptr = std::localtime(&t);
125 std::chrono::seconds secondsPassed{tm_ptr->tm_hour * 3600 + tm_ptr->tm_min * 60 + tm_ptr->tm_sec};
131 secondsStart_ += std::chrono::seconds{24 * 60 * 60} - secondsPassed;
135 if(secondsStart_ >= secondsPassed)
137 secondsStart_ -= secondsPassed;
141 throw makeException<StartException>(
"Startime in the past");
146 std::this_thread::sleep_for(secondsStart_);
152 pManager_->postStart();
156 std::chrono::seconds secondsStart_;
EMANE::Application::Emulator< EMANE::Application::NEMBuilder, EMANE::Application::NEMDirector, EMANE::Application::NEMManager > App
DECLARE_APPLICATION(EMANE::Application::App,"emaneeventservice")