RTC Toolkit 6.0.0
Loading...
Searching...
No Matches
supervisory.hpp
Go to the documentation of this file.
1
11
12#ifndef RTCTK_RTCSUPERVISOR_SUPERVISORY_HPP
13#define RTCTK_RTCSUPERVISOR_SUPERVISORY_HPP
14
19
21
22namespace rtctk::rtcSupervisor {
23
24using namespace rtctk::componentFramework;
25
26namespace detail {
38public:
45 explicit SetModesContext(const rad::cii::Request<std::string, std::string>& request)
46 : m_logger(GetLogger("rtctk")), m_request(request), m_arg() {
47 m_arg = JsonPayload::parse(m_request.GetRequestPayload());
48 }
49 SetModesContext(SetModesContext&&) noexcept = default;
50
54 const JsonPayload& GetArg() const noexcept {
55 return m_arg;
56 }
57
61 void SendReply() noexcept {
62 try {
63 m_request.SetReplyValue(STD_OK_REPLY);
64 } catch (const std::exception& exception) {
65 LOG4CPLUS_ERROR(
66 m_logger, "SetModesContext::SendReply: Failed to send reply: " << exception.what());
67 } catch (...) {
68 LOG4CPLUS_ERROR(
69 m_logger,
70 "SetModesContext::SendReply: Failed to send reply with unknown exception.");
71 }
72 }
73
79 void SendErrorReply(std::exception_ptr eptr) noexcept {
80 try {
81 m_request.SetException(RequestFailed(NestedExceptionPrinter(std::move(eptr)).Str()));
82 } catch (...) {
83 LOG4CPLUS_ERROR(
84 m_logger,
85 "SetModesContext::SendErrorReply: Failed to send reply with unknown exception.");
86 }
87 }
88
89private:
90 log4cplus::Logger& m_logger;
91
93 rad::cii::Request<std::string, std::string> m_request;
97 JsonPayload m_arg;
98};
99
110public:
117 explicit WriteBackContext(const rad::cii::Request<std::string, std::string>& request)
118 : m_logger(GetLogger("rtctk")), m_request(request), m_arg() {
119 m_arg = JsonPayload::parse(m_request.GetRequestPayload());
120 }
121 WriteBackContext(WriteBackContext&&) noexcept = default;
122
126 const JsonPayload& GetArg() const noexcept {
127 return m_arg;
128 }
129
133 void SendReply() noexcept {
134 try {
135 m_request.SetReplyValue(STD_OK_REPLY);
136 } catch (const std::exception& exception) {
137 LOG4CPLUS_ERROR(
138 m_logger,
139 "WriteBackContext::SendReply: Failed to send reply: " << exception.what());
140 } catch (...) {
141 LOG4CPLUS_ERROR(
142 m_logger,
143 "WriteBackContext::SendReply: Failed to send reply with unknown exception.");
144 }
145 }
146
152 void SendErrorReply(std::exception_ptr eptr) noexcept {
153 try {
154 m_request.SetException(RequestFailed(NestedExceptionPrinter(std::move(eptr)).Str()));
155 } catch (...) {
156 LOG4CPLUS_ERROR(
157 m_logger,
158 "WriteBackContext::SendErrorReply: Failed to send reply with unknown exception.");
159 }
160 }
161
165 void SendStopReply() noexcept {
166 try {
167 m_request.SetException(StdIfRequestAborted());
168 } catch (...) {
169 LOG4CPLUS_ERROR(
170 m_logger,
171 "SetModesContext::SendStopReply: Failed to send reply with unknown exception.");
172 }
173 }
174
175private:
176 log4cplus::Logger& m_logger;
177
179 rad::cii::Request<std::string, std::string> m_request;
183 JsonPayload m_arg;
184};
185} // namespace detail
186
211template <typename Super>
213 static_assert(std::is_base_of_v<RtcComponent, Super>, "'Supervisory' requires 'RtcComponent'");
214
220 public:
221 // Due to Doxygen limitations the multi-line @exception_basic command cannot have the '*'
222 // character on each line.
230 virtual std::string ActionGetStatus() {
231 return {};
232 }
233
243 virtual void ActivitySettingModes(StopToken st, const JsonPayload& arg) {
244 }
245
254 virtual bool GuardSettingModesAllowed(const JsonPayload& arg) {
255 return true;
256 }
257
266 virtual void ActionSetDeferredModes(const JsonPayload& arg) {
267 }
268
277 return {};
278 }
279
288 return {};
289 }
290
299 return {};
300 }
301
311 virtual void ActivityWritingBack(StopToken st, const JsonPayload& arg) {
312 }
313
323 virtual bool GuardWritingBackAllowed(const JsonPayload& arg) {
324 return true;
325 }
326
335 virtual void ActivityRecovering(StopToken st) {
336 }
337 };
338
343 public:
345
346 void Start() override {
347 Super::InputStage::Start();
348
349 RecoverCmdsImpl::Register(this->m_replier, this->m_engine);
350 ModeCmdsImpl::Register(this->m_replier, this->m_engine);
351 WriteBackCmdsImpl::Register(this->m_replier, this->m_engine);
352 }
353 };
354
359 public:
361 // Handlers ###################################################################
362
363 engine.RegisterRejectHandler<events::SetModes, RequestRejected>();
364 engine.RegisterRejectHandler<events::SetDeferredModes, RequestRejected>();
365 engine.RegisterRejectHandler<events::GetDeferredModes, RequestRejected>();
366 engine.RegisterRejectHandler<events::GetAvailableModes, RequestRejected>();
367 engine.RegisterRejectHandler<events::GetActiveModes, RequestRejected>();
368 engine.RegisterRejectHandler<events::WriteBack, RequestRejected>();
369 engine.RegisterRejectHandler<events::Recover, RequestRejected>();
370
372 this->m_engine.PostEvent(std::make_unique<events::SetModesDone>());
373 };
374
375 m_setmode_error_handler = [this](std::exception_ptr eptr) {
376 this->m_engine.PostEvent(std::make_unique<events::SetModesError>(std::move(eptr)));
377 };
378
380 this->m_engine.PostEvent(std::make_unique<events::WriteBackDone>());
381 };
382
383 m_writeback_error_handler = [this](std::exception_ptr eptr) {
384 this->m_engine.PostEvent(std::make_unique<events::WriteBackError>(std::move(eptr)));
385 };
386
387 // No Disable in states ###############################################################
388
389 this->m_no_disable_in_states.emplace_back("On:SetModes:Busy");
390
391 // No Update in states ################################################################
392
393 this->m_no_update_in_states.emplace_back("On:SetModes:Busy");
394
395 // No SetModes in states ##############################################################
396
397 this->m_no_setmode_in_states.emplace_back("On:Update:Busy");
398 this->m_no_setmode_in_states.emplace_back("On:WriteBack:Busy");
399 this->m_no_setmode_in_states.emplace_back("On::NotOperational::Starting");
400 this->m_no_setmode_in_states.emplace_back("On::NotOperational::NotReady");
401 this->m_no_setmode_in_states.emplace_back("On::NotOperational::Initialising");
402 this->m_no_setmode_in_states.emplace_back("On::NotOperational::Enabling");
403 this->m_no_setmode_in_states.emplace_back("On::NotOperational::Disabling");
404 this->m_no_setmode_in_states.emplace_back("On::Operational::Error");
405 this->m_no_setmode_in_states.emplace_back("On::Operational::Recovering");
406
407 // No WriteBack in states #############################################################
408
409 this->m_no_writeback_in_states.emplace_back("On::NotOperational::Starting");
410 this->m_no_writeback_in_states.emplace_back("On::NotOperational::NotReady");
411 this->m_no_writeback_in_states.emplace_back("On::NotOperational::Initialising");
412 this->m_no_writeback_in_states.emplace_back("On::NotOperational::Enabling");
413 this->m_no_writeback_in_states.emplace_back("On::NotOperational::Disabling");
414 this->m_no_writeback_in_states.emplace_back("On:SetModes:Busy");
415
416 // Guards #####################################################################
417
418 engine.RegisterGuardStatic<events::SetModes>(
419 "GuardSettingModesAllowed", [this](const events::SetModes& ev) -> bool {
428 auto act_state = this->m_engine.GetState();
429 for (auto& s : m_no_setmode_in_states) {
430 if (act_state.find(s) != std::string::npos) {
431 return false;
432 }
433 }
434 detail::SetModesContext ctx(ev.GetPayload());
435 if (static_cast<BizLogicIf&>(this->m_logic)
436 .GuardSettingModesAllowed(ctx.GetArg())) {
437 // SetModes is allowed so context is stored.
438 // If there's an active context (and correspondingly an active
439 // request being processed something have gone terribly wrong)
440 assert(!m_setmode_ctx);
441 m_setmode_ctx.emplace(std::move(ctx));
442 return true;
443 }
444 return false;
445 });
446
447 engine.RegisterGuardStatic<events::WriteBack>(
448 "GuardWritingBackAllowed", [this](const events::WriteBack& ev) -> bool {
457 auto act_state = this->m_engine.GetState();
458 for (auto& s : m_no_writeback_in_states) {
459 if (act_state.find(s) != std::string::npos) {
460 return false;
461 }
462 }
463 detail::WriteBackContext ctx(ev.GetPayload());
464 if (static_cast<BizLogicIf&>(this->m_logic)
465 .GuardWritingBackAllowed(ctx.GetArg())) {
466 // WriteBack is allowed so context is stored.
467 // If there's an active context (and correspondingly an active
468 // request being processed something have gone terribly wrong)
469 assert(!m_writeback_ctx);
470 m_writeback_ctx.emplace(std::move(ctx));
471 return true;
472 }
473 return false;
474 });
475
476 // Activities #####################################################################
477
478 engine.RegisterActivity(
479 "ActivitySettingModes",
480 [this](StopToken stop_token) {
481 assert(m_setmode_ctx);
482 static_cast<BizLogicIf&>(this->m_logic)
483 .ActivitySettingModes(stop_token, m_setmode_ctx->GetArg());
484 },
487
488 engine.RegisterActivity(
489 "ActivityWritingBack",
490 [this](StopToken stop_token) {
491 assert(m_writeback_ctx);
492 static_cast<BizLogicIf&>(this->m_logic)
493 .ActivityWritingBack(stop_token, m_writeback_ctx->GetArg());
494 },
497
498 engine.RegisterActivity(
499 "ActivityRecovering",
500 [this](StopToken stop_token) {
501 static_cast<BizLogicIf&>(this->m_logic).ActivityRecovering(stop_token);
502 },
503 this->m_success_handler,
504 this->m_error_handler);
505
506 // Actions #####################################################################
507
508 // override default implementation for ActionGetStatus in stdComponent.hpp
509 engine.RegisterAction("ActionGetStatus", [this](auto c) {
511 if (req == nullptr) {
512 // no event or request
513 return;
514 }
515 auto status = static_cast<BizLogicIf&>(this->m_logic).ActionGetStatus();
516 req->SetReplyValue(status);
517 });
518
519 engine.RegisterActionStatic<events::SetDeferredModes>(
520 "ActionSetDeferredModes", [this](const events::SetDeferredModes& ev) {
522 if (req == nullptr) {
523 // no event or request
524 return;
525 }
526 try {
527 auto json_arg = JsonPayload::parse(req->GetRequestPayload());
528 static_cast<BizLogicIf&>(this->m_logic).ActionSetDeferredModes(json_arg);
529 req->SetReplyValue(STD_OK_REPLY);
530 } catch (...) {
531 auto nested =
532 WrapWithNested(RtctkException("ActionSetDeferredModes: failed"));
533 auto eptr = std::make_exception_ptr(nested);
534 req->SetException(
535 RequestFailed(NestedExceptionPrinter(std::move(eptr)).Str()));
536 throw; // to be caught in stateMachineEngine.cpp
537 }
538 });
539
540 engine.RegisterActionStatic<events::GetAvailableModes>(
541 "ActionGetAvailableModes", [this](const events::GetAvailableModes& ev) {
543 if (req == nullptr) {
544 // no event or request
545 return;
546 }
547 try {
548 auto result =
549 static_cast<BizLogicIf&>(this->m_logic).ActionGetAvailableModes();
550 req->SetReplyValue(result.dump());
551 } catch (...) {
552 auto nested =
553 WrapWithNested(RtctkException("ActionGetAvailableModes: failed"));
554 auto eptr = std::make_exception_ptr(nested);
555 req->SetException(
556 RequestFailed(NestedExceptionPrinter(std::move(eptr)).Str()));
557 throw; // to be caught in stateMachineEngine.cpp
558 }
559 });
560
561 engine.RegisterActionStatic<events::GetActiveModes>(
562 "ActionGetActiveModes", [this](const events::GetActiveModes& ev) {
564 if (req == nullptr) {
565 // no event or request
566 return;
567 }
568 try {
569 auto result =
570 static_cast<BizLogicIf&>(this->m_logic).ActionGetActiveModes();
571 req->SetReplyValue(result.dump());
572 } catch (...) {
573 auto nested =
574 WrapWithNested(RtctkException("ActionGetActiveModes: failed"));
575 auto eptr = std::make_exception_ptr(nested);
576 req->SetException(
577 RequestFailed(NestedExceptionPrinter(std::move(eptr)).Str()));
578 throw; // to be caught in stateMachineEngine.cpp
579 }
580 });
581
582 engine.RegisterActionStatic<events::GetDeferredModes>(
583 "ActionGetDeferredModes", [this](const events::GetDeferredModes& ev) {
585 if (req == nullptr) {
586 // no event or request
587 return;
588 }
589 try {
590 auto result =
591 static_cast<BizLogicIf&>(this->m_logic).ActionGetDeferredModes();
592 req->SetReplyValue(result.dump());
593 } catch (...) {
594 auto nested =
595 WrapWithNested(RtctkException("ActionGetDeferredModes: failed"));
596 auto eptr = std::make_exception_ptr(nested);
597 req->SetException(
598 RequestFailed(NestedExceptionPrinter(std::move(eptr)).Str()));
599 throw; // to be caught in stateMachineEngine.cpp
600 }
601 });
602
603 engine.RegisterActionStatic<events::SetModesDone>("ActionSettingModesDone",
604 [this](const events::SetModesDone&) {
605 assert(m_setmode_ctx);
606 m_setmode_ctx->SendReply();
607 m_setmode_ctx.reset();
608 });
609
610 engine.RegisterActionStatic<events::SetModesError>(
611 "ActionSettingModesFailed", [this](const events::SetModesError& ev) {
612 m_setmode_ctx->SendErrorReply(ev.GetPayload());
613 m_setmode_ctx.reset();
614 });
615
616 engine.RegisterActionStatic<events::WriteBackDone>(
617 "ActionWriteBackDone", [this](const events::WriteBackDone&) {
618 assert(m_writeback_ctx);
619 m_writeback_ctx->SendReply();
620 m_writeback_ctx.reset();
621 });
622
623 engine.RegisterActionStatic<events::WriteBackError>(
624 "ActionWriteBackFailed", [this](const events::WriteBackError& ev) {
625 m_writeback_ctx->SendErrorReply(ev.GetPayload());
626 m_writeback_ctx.reset();
627 });
628
629 engine.RegisterActionStatic<events::Stop>(
630 "ActionWriteBackStopped", [this](const events::Stop& ev) {
631 auto req = GetPayloadNothrow<events::Stop>(ev);
632 if (req == nullptr) {
633 // no event or request
634 return;
635 }
636 m_writeback_ctx->SendStopReply();
637 m_writeback_ctx.reset();
638 req->SetReplyValue(STD_OK_REPLY);
639 });
640
641 engine.RegisterAction("ActionRecoveringEntry", [this](auto c) {
642 this->m_tmp_request = GetPayloadNothrow<events::Recover>(c);
643 });
644
645 engine.RegisterAction("ActionRecoveringDone", [this](auto c) {
646 if (this->m_tmp_request) {
647 this->m_tmp_request->SetReplyValue(STD_OK_REPLY);
648 this->m_tmp_request = nullptr;
649 }
650 });
651
652 engine.RegisterAction("ActionRecoveringFailed", [this](auto c) {
653 if (auto eptr = GetPayloadNothrow<events::Error>(c); eptr) {
654 if (this->m_tmp_request) {
655 this->m_tmp_request->SetException(
657 this->m_tmp_request = nullptr;
658 }
659 }
660 });
661 }
662
663 protected:
664 std::optional<detail::SetModesContext> m_setmode_ctx;
665 std::optional<detail::WriteBackContext> m_writeback_ctx;
666 std::function<void()> m_setmode_success_handler;
667 std::function<void(std::exception_ptr)> m_setmode_error_handler;
668 std::function<void()> m_writeback_success_handler;
669 std::function<void(std::exception_ptr)> m_writeback_error_handler;
670 std::list<std::string> m_no_setmode_in_states;
671 std::list<std::string> m_no_writeback_in_states;
672 };
673
678 public:
679 explicit ModelBuilder(StateMachineEngine& engine) : Super::ModelBuilder(engine) {
680 // clang-format off
681 this->mm.AddState(Composite, "On:SetModes", "On");
682 this->mm.AddState(Initial, "On:SetModes:Initial", "On:SetModes");
683 this->mm.AddState(Simple, "On:SetModes:Idle", "On:SetModes");
684 this->mm.AddState(Simple, "On:SetModes:Busy", "On:SetModes", "ActivitySettingModes");
685 this->mm.AddState(Initial, "On::Operational::Initial", "On::Operational");
686 this->mm.AddState(Simple, "On::Operational::Idle", "On::Operational");
687 this->mm.AddState(Simple, "On::Operational::Recovering", "On::Operational", "ActivityRecovering", "ActionRecoveringEntry");
688 this->mm.AddState(Simple, "On::Operational::Error", "On::Operational");
689
690 this->mm.AddTrans("On", "" , events::GetAvailableModes::ID, "", "ActionGetAvailableModes");
691 this->mm.AddTrans("On::NotOperational::NotReady", "" , events::SetDeferredModes::ID, "", "ActionSetDeferredModes");
692 this->mm.AddTrans("On::NotOperational::NotReady", "" , events::GetDeferredModes::ID, "", "ActionGetDeferredModes");
693 this->mm.AddTrans("On::NotOperational::Ready", "" , events::SetDeferredModes::ID, "", "ActionSetDeferredModes");
694 this->mm.AddTrans("On::NotOperational::Ready", "" , events::GetDeferredModes::ID, "", "ActionGetDeferredModes");
695 this->mm.AddTrans("On::NotOperational::Ready", "" , events::GetActiveModes::ID, "", "ActionGetActiveModes");
696 this->mm.AddTrans("On::NotOperational::Enabling", "" , events::GetActiveModes::ID, "", "ActionGetActiveModes");
697 this->mm.AddTrans("On::Operational", "" , events::GetActiveModes::ID, "", "ActionGetActiveModes");
698
699 this->mm.AddTrans("On::Operational::Initial" , "On::Operational::Idle" );
700 this->mm.AddTrans("On::Operational::Idle" , "On::Operational::Recovering" , "events.Recover");
701 this->mm.AddTrans("On::Operational::Error" , "On::Operational::Recovering" , "events.Recover");
702 this->mm.AddTrans("On::Operational::Recovering" , "On::Operational::Idle" , "events.Done", "" ,"ActionRecoveringDone");
703 this->mm.AddTrans("On::Operational::Recovering" , "On::Operational::Error" , "events.Error", "" ,"ActionRecoveringFailed");
704
705 this->mm.AddTrans("On:SetModes:Initial", "On:SetModes:Idle");
706 this->mm.AddTrans("On:SetModes:Idle", "On:SetModes:Busy", events::SetModes::ID, "GuardSettingModesAllowed");
707 this->mm.AddTrans("On:SetModes:Busy", "On:SetModes:Idle", events::SetModesDone::ID, "", "ActionSettingModesDone");
708 this->mm.AddTrans("On:SetModes:Busy", "On:SetModes:Idle", events::SetModesError::ID, "", "ActionSettingModesFailed");
709
710 this->mm.AddState(Composite, "On:WriteBack", "On");
711 this->mm.AddState(Initial, "On:WriteBack:Initial", "On:WriteBack");
712 this->mm.AddState(Simple, "On:WriteBack:Idle", "On:WriteBack");
713 this->mm.AddState(Simple, "On:WriteBack:Busy", "On:WriteBack", "ActivityWritingBack");
714
715 this->mm.AddTrans("On:WriteBack:Initial", "On:WriteBack:Idle");
716 this->mm.AddTrans("On:WriteBack:Idle", "On:WriteBack:Busy", events::WriteBack::ID, "GuardWritingBackAllowed");
717 this->mm.AddTrans("On:WriteBack:Busy", "On:WriteBack:Idle", events::WriteBackDone::ID, "", "ActionWriteBackDone");
718 this->mm.AddTrans("On:WriteBack:Busy", "On:WriteBack:Idle", events::WriteBackError::ID, "", "ActionWriteBackFailed");
719 this->mm.AddTrans("On:WriteBack:Busy", "On:WriteBack:Idle", events::Stop::ID, "", "ActionWriteBackStopped");
720 // clang-format on
721 }
722 };
723};
724
725} // namespace rtctk::rtcSupervisor
726
727#endif
Adapter object intended to be used in contexts without direct access to the output-stream object.
Definition exceptions.hpp:168
std::string Str() const
Convenience function for constructing a std::string from the exception.
Definition exceptions.hpp:186
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition rtcCmdsImpl.hpp:67
Thrown if the command was accepted but the task to run failed.
Definition rtcComponent.hpp:52
Thrown if a command is not allowed in current state or guard.
Definition rtcComponent.hpp:39
The RtctkException class is the base class for all Rtctk exceptions.
Definition exceptions.hpp:220
Definition stateMachineEngine.hpp:34
void RegisterGuardStatic(const std::string &id, std::function< bool(const Event &)> guard)
Register guard for statically known event type.
Definition stateMachineEngine.hpp:125
void RegisterAction(const std::string &id, ActionMethod action)
Register action.
Definition stateMachineEngine.cpp:85
void RegisterRejectHandler(const std::string &id, RejectMethod reject)
Register reject handler.
Definition stateMachineEngine.cpp:128
void RegisterActivity(const std::string &id, ActivityMethod activity, SuccessMethod on_success, FailureMethod on_failure)
Register activity.
Definition stateMachineEngine.cpp:120
void RegisterActionStatic(const std::string &id, std::function< void(const Event &)> action)
Register action for statically known event type.
Definition stateMachineEngine.hpp:92
Thrown if somebody sent a stop or abort command.
Definition stdComponent.hpp:95
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition supervisoryCmdsImpl.hpp:39
Business logic interface for Supervisory mixin.
Definition supervisory.hpp:219
virtual JsonPayload ActionGetActiveModes()
Action is used for mode inspection and executed in the state machine thread.
Definition supervisory.hpp:287
virtual bool GuardSettingModesAllowed(const JsonPayload &arg)
Determines if set mode is possible at this time with the provided argument.
Definition supervisory.hpp:254
virtual void ActivitySettingModes(StopToken st, const JsonPayload &arg)
Activity executed in its own thread that performs the mode setting.
Definition supervisory.hpp:243
virtual JsonPayload ActionGetDeferredModes()
Action is used for mode inspection and executed in the state machine thread.
Definition supervisory.hpp:298
virtual std::string ActionGetStatus()
Action is used for system status inspection and is executed in the state machine thread.
Definition supervisory.hpp:230
virtual bool GuardWritingBackAllowed(const JsonPayload &arg)
Determines if writeback is possible at this time with the provided argument.
Definition supervisory.hpp:323
virtual void ActivityRecovering(StopToken st)
Activity executed in its own thread that performs the error recovery.
Definition supervisory.hpp:335
virtual JsonPayload ActionGetAvailableModes()
Action is used for mode inspection and executed in the state machine thread.
Definition supervisory.hpp:276
virtual void ActionSetDeferredModes(const JsonPayload &arg)
Action is executed in the state machine thread and it performs deferred mode setting.
Definition supervisory.hpp:266
virtual void ActivityWritingBack(StopToken st, const JsonPayload &arg)
Activity executed in its own thread that performs the writeback.
Definition supervisory.hpp:311
void Start() override
Definition supervisory.hpp:346
InputStage(CommandReplier &replier, StateMachineEngine &engine)
Definition stdComponent.hpp:160
ModelBuilder(StateMachineEngine &engine)
Definition supervisory.hpp:679
std::list< std::string > m_no_writeback_in_states
Definition supervisory.hpp:671
std::function< void()> m_writeback_success_handler
Definition supervisory.hpp:668
std::function< void()> m_setmode_success_handler
Definition supervisory.hpp:666
std::function< void(std::exception_ptr)> m_setmode_error_handler
Definition supervisory.hpp:667
std::list< std::string > m_no_setmode_in_states
Definition supervisory.hpp:670
std::function< void(std::exception_ptr)> m_writeback_error_handler
Definition supervisory.hpp:669
OutputStage(StateMachineEngine &engine, BizLogicIf &bl)
Definition supervisory.hpp:360
std::optional< detail::SetModesContext > m_setmode_ctx
Definition supervisory.hpp:664
std::optional< detail::WriteBackContext > m_writeback_ctx
Definition supervisory.hpp:665
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition supervisoryCmdsImpl.hpp:86
Holds context necessary for processing a SetModes request to completion.
Definition supervisory.hpp:37
SetModesContext(const rad::cii::Request< std::string, std::string > &request)
Construct context with provided request.
Definition supervisory.hpp:45
void SendErrorReply(std::exception_ptr eptr) noexcept
Send exceptional reply.
Definition supervisory.hpp:79
SetModesContext(SetModesContext &&) noexcept=default
const JsonPayload & GetArg() const noexcept
Definition supervisory.hpp:54
void SendReply() noexcept
Sends hardcoded string reply.
Definition supervisory.hpp:61
Holds context necessary for processing a WriteBack request to completion.
Definition supervisory.hpp:109
void SendReply() noexcept
Sends hardcoded string reply.
Definition supervisory.hpp:133
const JsonPayload & GetArg() const noexcept
Definition supervisory.hpp:126
WriteBackContext(const rad::cii::Request< std::string, std::string > &request)
Construct context with provided request.
Definition supervisory.hpp:117
void SendStopReply() noexcept
Send stop reply.
Definition supervisory.hpp:165
void SendErrorReply(std::exception_ptr eptr) noexcept
Send exceptional reply.
Definition supervisory.hpp:152
WriteBackContext(WriteBackContext &&) noexcept=default
Provides macros and utilities for exception handling.
auto WrapWithNested(E &&exception) noexcept(std::is_nothrow_constructible_v< detail::UnspecifiedNested< typename std::decay_t< E > >, E && >)
Constructs an unspecified exception that derives from both the provided object and std::nested_except...
Definition exceptions.hpp:96
log4cplus::Logger & GetLogger(const std::string &name="app")
Get handle to a specific logger.
Definition logger.cpp:191
Defines the JSON payload type JsonPayload.
Definition measurable.hpp:25
@ Simple
Definition model.hpp:22
@ Composite
Definition model.hpp:22
@ Initial
Definition model.hpp:22
rad::StopToken StopToken
Definition stopToken.hpp:19
std::shared_ptr< typename EVENT::payload_t > GetPayloadNothrow(scxml4cpp::Context *c)
Definition stateMachineEngine.hpp:255
const std::string STD_OK_REPLY
Definition stdComponent.hpp:85
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:24
Definition alertAggregator.cpp:18
Lifecycle of a basic 'RtcComponent'.
A simple Stop Token.
RtcComponentSuper Super
Definition rtcComponent.hpp:74
Life cycle extension to make RtcComponent Supervisory.
Definition supervisory.hpp:212
Implementation of MAL commands for layer 'Supervisory'.