8 #ifndef SUP_SUBSIM_COMMON_UTILS_IPP_
9 #define SUP_SUBSIM_COMMON_UTILS_IPP_
18 #include <utils/bat/logger.hpp>
19 #include <rad/smAdapter.hpp>
20 #include <rad/mal/request.hpp>
21 #include <rad/activity.hpp>
26 template <
class EVENT_DONE,
class EVENT_ERR>
29 const std::string cmd,
30 rad::ThreadActivity* activity) {
34 auto repl_ok = config.
GetReplyOk(cmd).value_or(
true);
37 LOG4CPLUS_INFO(utils::bat::GetAppLogger(),
"Reply msg: " << msg);
39 LOG4CPLUS_DEBUG(utils::bat::GetAppLogger(),
"Reply delay: " << delay);
41 int increment = int(delay/100);
42 LOG4CPLUS_DEBUG(utils::bat::GetAppLogger(),
"Increment: " << increment);
43 while (total < delay) {
44 if (activity->IsStopRequested()) {
45 sm.PostEvent(rad::UniqueEvent(
new EVENT_ERR(cmd +
" has been stopped !" )));
48 std::this_thread::sleep_for(std::chrono::milliseconds(increment));
50 LOG4CPLUS_DEBUG(utils::bat::GetAppLogger(),
"Total Time: " << total <<
" [ms]");
54 sm.PostEvent(rad::UniqueEvent(
new EVENT_DONE));
56 sm.PostEvent(rad::UniqueEvent(
new EVENT_ERR(msg )));
64 #endif // SUP_SUBSIM_COMMON_UTILS_IPP_