13 #include <events.rad.hpp>
17 #include <rad/exceptions.hpp>
18 #include <rad/getPayload.hpp>
19 #include <rad/mal/request.hpp>
20 #include <rad/smEvent.hpp>
22 #include <scxml4cpp/Event.h>
23 #include <scxml4cpp/Helper.h>
24 #include <scxml4cpp/State.h>
32 for (
auto* s : states) {
39 if (substate->getId() ==
"Off") {
42 State* state = s->getParent();
46 State* top = state->getParent();
50 if (top->getParent() !=
nullptr) {
54 status = state->getId() +
";" + substate->getId();
62 :
rad::ActionGroup(
"ActionsStd"),
65 m_signal(ios, sm,
rad::UniqueEvent(new Events::CtrlC())),
70 m_signal.Add(SIGTERM);
77 auto req = rad::GetLastEventPayloadNothrow<Events::Exit>(c);
79 LOG4CPLUS_ERROR(
GetLogger(),
"Exit event has no associated request!");
82 req->SetReplyValue(
"OK");
94 auto req = rad::GetLastEventPayloadNothrow<Events::GetState>(c);
96 LOG4CPLUS_ERROR(
GetLogger(),
"Status event has no associated request!");
99 req->SetReplyValue(m_sm.GetStatus());
105 auto req = rad::GetLastEventPayloadNothrow<Events::GetStatus>(c);
106 if (req ==
nullptr) {
107 LOG4CPLUS_ERROR(
GetLogger(),
"Status event has no associated request!");
110 auto status =
MakeStatusString(m_sm.GetActiveStates()).value_or(
"NotOperational;Undefined");
111 req->SetReplyValue(status);
118 auto req = rad::GetLastEventPayloadNothrow<Events::Stop>(c);
119 if (req ==
nullptr) {
120 LOG4CPLUS_ERROR(
GetLogger(),
"Stop event has no associated request!");
123 req->SetReplyValue(
"OK");
129 auto req = rad::GetLastEventPayloadNothrow<Events::Init>(c);
130 if (req ==
nullptr) {
131 LOG4CPLUS_ERROR(
GetLogger(),
"Init event has no associated request!");
134 req->SetReplyValue(
"OK");
140 auto req = rad::GetLastEventPayloadNothrow<Events::Enable>(c);
141 if (req ==
nullptr) {
142 LOG4CPLUS_ERROR(
GetLogger(),
"Enable event has no associated request!");
145 req->SetReplyValue(
"OK");
151 auto req = rad::GetLastEventPayloadNothrow<Events::Disable>(c);
152 if (req ==
nullptr) {
153 LOG4CPLUS_ERROR(
GetLogger(),
"Disable event has no associated request!");
156 req->SetReplyValue(
"OK");
162 auto req = rad::GetLastEventPayloadNothrow<Events::Reset>(c);
163 if (req ==
nullptr) {
164 LOG4CPLUS_ERROR(
GetLogger(),
"Reset event has no associated request!");
167 req->SetReplyValue(
"OK");
173 auto req = rad::GetLastEventPayloadNothrow<Events::SetLogLevel>(c);
174 if (req ==
nullptr) {
175 LOG4CPLUS_ERROR(
GetLogger(),
"SetLogLevel event has no associated request!");
179 auto req_params = req->GetRequestPayload();
180 std::string level = req_params->getLevel();
181 std::string logger_name = req_params->getLogger();
183 log4cplus::LogLevelManager& log_mgr = log4cplus::getLogLevelManager();
185 log4cplus::LogLevel ll = log_mgr.fromString(level);
186 if (ll == log4cplus::NOT_SET_LOG_LEVEL) {
187 req->SetReplyValue(
"ERR unknown logging level: " + level);
191 if (logger_name ==
"" || logger_name ==
LOGGER_NAME) {
194 log4cplus::Logger::getInstance(logger_name).setLogLevel(ll);
196 LOG4CPLUS_DEBUG(
GetLogger(),
"Log level set to " << level <<
" for logger " << logger_name);
198 req->SetReplyValue(
"OK");