12#ifndef RTCTK_COMPONENTFRAMEWORK_RTCCOMPONENT_HPP
13#define RTCTK_COMPONENTFRAMEWORK_RTCCOMPONENT_HPP
43 : rtctkif::ExceptionErr(
"Request " + request_id +
" rejected in state " + state_id,
101 Super::InputStage::Start();
120 this->
m_engine.PostEvent(std::make_unique<events::UpdateDone>());
124 this->
m_engine.PostEvent(std::make_unique<events::UpdateError>(std::move(eptr)));
143 if (req ==
nullptr) {
174 engine.
RegisterGuard(
"GuardUpdatingAllowed", [
this](
auto c) {
176 if (req ==
nullptr) {
181 auto act_state = this->
m_engine.GetState();
183 if (act_state.find(s) != std::string::npos) {
188 std::string string_arg = req->GetRequestPayload();
189 JsonPayload json_arg = JsonPayload::parse(string_arg);
193 engine.
RegisterGuard(
"GuardDisablingAllowed", [
this](
auto c) {
194 auto act_state = this->
m_engine.GetState();
196 if (act_state.find(s) != std::string::npos) {
209 JsonPayload json_arg = JsonPayload::parse(string_arg);
231 this->
mm.AddTrans(
"On::Operational" ,
"" ,
"events.ClearAlerts",
"",
"ActionClearAlerts");
233 const std::string update_region =
"On:Update";
235 this->
mm.AddState(
Initial,
"On:Update:Initial", update_region);
236 this->
mm.AddState(
Simple,
"On:Update:Idle", update_region);
237 this->
mm.AddState(
Simple,
"On:Update:Busy", update_region ,
"ActivityUpdating" ,
"ActionUpdatingEntry");
239 this->
mm.AddTrans(
"On:Update:Initial" ,
"On:Update:Idle" );
240 this->
mm.AddTrans(
"On:Update:Idle" ,
"On:Update:Busy" ,
"events.Update",
"GuardUpdatingAllowed");
241 this->
mm.AddTrans(
"On:Update:Busy" ,
"On:Update:Idle" ,
"events.UpdateDone",
"" ,
"ActionUpdatingDone" );
242 this->
mm.AddTrans(
"On:Update:Busy" ,
"On:Update:Idle" ,
"events.UpdateError",
"" ,
"ActionUpdatingFailed" );
244 this->
mm.ModTransGuard(
"On::Operational",
"On::NotOperational::Disabling",
"events.Disable",
"",
"GuardDisablingAllowed");
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition rtcCmdsImpl.hpp:94
ModelManipulator mm
Definition modelBuilderBase.hpp:78
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
RequestAborted()
Definition rtcComponent.hpp:31
static constexpr int32_t ERROR_CODE
Definition rtcComponent.hpp:30
Thrown if the command was accepted but the task to run failed.
Definition rtcComponent.hpp:52
RequestFailed(const std::string &message)
Definition rtcComponent.hpp:58
static constexpr int32_t ERROR_CODE
Definition rtcComponent.hpp:57
Thrown if a command is not allowed in current state or guard.
Definition rtcComponent.hpp:39
RequestRejected(const std::string &request_id, const std::string &state_id)
Definition rtcComponent.hpp:42
static constexpr int32_t ERROR_CODE
Definition rtcComponent.hpp:41
Definition rtcComponent.hpp:79
virtual bool GuardUpdatingAllowed(const JsonPayload &args)
Definition rtcComponent.hpp:85
virtual void ActionClearAlerts()
Definition rtcComponent.hpp:89
virtual void ActivityUpdating(StopToken st, const JsonPayload &args)
Definition rtcComponent.hpp:82
ModelBuilder(StateMachineEngine &engine)
Definition rtcComponent.hpp:229
std::function< void(std::exception_ptr)> m_update_error_handler
Definition rtcComponent.hpp:219
std::list< std::string > m_no_disable_in_states
Definition rtcComponent.hpp:221
std::list< std::string > m_no_update_in_states
Definition rtcComponent.hpp:220
OutputStage(StateMachineEngine &engine, BizLogicIf &bl)
Definition rtcComponent.hpp:113
std::function< void()> m_update_success_handler
Definition rtcComponent.hpp:218
std::shared_ptr< rad::cii::Request< std::string, std::string > > m_tmp_update_request
Definition rtcComponent.hpp:217
Definition stateMachineEngine.hpp:34
void RegisterAction(const std::string &id, ActionMethod action)
Register action.
Definition stateMachineEngine.cpp:85
void RegisterGuard(const std::string &id, GuardMethod guard)
Register guard.
Definition stateMachineEngine.cpp:107
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
Definition stdComponent.hpp:147
Definition stdComponent.hpp:420
Definition stdComponent.hpp:182
StateMachineEngine & m_engine
Definition stdComponent.hpp:410
BizLogicIf & m_logic
Definition stdComponent.hpp:411
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition rtcCmdsImpl.hpp:121
Defines the JSON payload type JsonPayload.
Definition commandReplier.cpp:21
StdComponent RtcComponentSuper
Definition rtcComponent.hpp:65
@ 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
Implementation of MAL commands for layer 'RtcComponent'.
Lifecycle of the 'Standard Component'.
Basic life cycle for RtcComponent.
Definition rtcComponent.hpp:73
RtcComponentSuper Super
Definition rtcComponent.hpp:74
Basic life cycle for StdComponent.
Definition stdComponent.hpp:143