13#ifndef RTCTK_COMPONENTFRAMEWORK_RTCCOMPONENT_HPP
14#define RTCTK_COMPONENTFRAMEWORK_RTCCOMPONENT_HPP
44 : rtctkif::ExceptionErr(
"Request " + request_id +
" rejected in state " + state_id,
102 Super::InputStage::Start();
121 this->
m_engine.PostEvent(std::make_unique<events::UpdateDone>());
125 this->
m_engine.PostEvent(std::make_unique<events::UpdateError>(std::move(eptr)));
144 if (req ==
nullptr) {
175 engine.
RegisterGuard(
"GuardUpdatingAllowed", [
this](
auto c) {
177 if (req ==
nullptr) {
182 auto act_state = this->
m_engine.GetState();
184 if (act_state.find(s) != std::string::npos) {
189 std::string string_arg = req->GetRequestPayload();
190 JsonPayload json_arg = JsonPayload::parse(string_arg);
194 engine.
RegisterGuard(
"GuardDisablingAllowed", [
this](
auto c) {
195 auto act_state = this->
m_engine.GetState();
197 if (act_state.find(s) != std::string::npos) {
210 JsonPayload json_arg = JsonPayload::parse(string_arg);
232 this->
mm.AddTrans(
"On::Operational" ,
"" ,
"events.ClearAlerts",
"",
"ActionClearAlerts");
234 const std::string update_region =
"On:Update";
236 this->
mm.AddState(
Initial,
"On:Update:Initial", update_region);
237 this->
mm.AddState(
Simple,
"On:Update:Idle", update_region);
238 this->
mm.AddState(
Simple,
"On:Update:Busy", update_region ,
"ActivityUpdating" ,
"ActionUpdatingEntry");
240 this->
mm.AddTrans(
"On:Update:Initial" ,
"On:Update:Idle" );
241 this->
mm.AddTrans(
"On:Update:Idle" ,
"On:Update:Busy" ,
"events.Update",
"GuardUpdatingAllowed");
242 this->
mm.AddTrans(
"On:Update:Busy" ,
"On:Update:Idle" ,
"events.UpdateDone",
"" ,
"ActionUpdatingDone" );
243 this->
mm.AddTrans(
"On:Update:Busy" ,
"On:Update:Idle" ,
"events.UpdateError",
"" ,
"ActionUpdatingFailed" );
245 this->
mm.ModTransGuard(
"On::Operational",
"On::NotOperational::Disabling",
"events.Disable",
"",
"GuardDisablingAllowed");
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition rtcCmdsImpl.hpp:95
ModelManipulator mm
Definition modelBuilderBase.hpp:79
Adapter object intended to be used in contexts without direct access to the output-stream object.
Definition exceptions.hpp:161
std::string Str() const
Convenience function for constructing a std::string from the exception.
Definition exceptions.hpp:179
RequestAborted()
Definition rtcComponent.hpp:32
static constexpr int32_t ERROR_CODE
Definition rtcComponent.hpp:31
Thrown if the command was accepted but the task to run failed.
Definition rtcComponent.hpp:53
RequestFailed(const std::string &message)
Definition rtcComponent.hpp:59
static constexpr int32_t ERROR_CODE
Definition rtcComponent.hpp:58
Thrown if a command is not allowed in current state or guard.
Definition rtcComponent.hpp:40
RequestRejected(const std::string &request_id, const std::string &state_id)
Definition rtcComponent.hpp:43
static constexpr int32_t ERROR_CODE
Definition rtcComponent.hpp:42
Definition rtcComponent.hpp:80
virtual bool GuardUpdatingAllowed(const JsonPayload &args)
Definition rtcComponent.hpp:86
virtual void ActionClearAlerts()
Definition rtcComponent.hpp:90
virtual void ActivityUpdating(StopToken st, const JsonPayload &args)
Definition rtcComponent.hpp:83
ModelBuilder(StateMachineEngine &engine)
Definition rtcComponent.hpp:230
std::function< void(std::exception_ptr)> m_update_error_handler
Definition rtcComponent.hpp:220
std::list< std::string > m_no_disable_in_states
Definition rtcComponent.hpp:222
std::list< std::string > m_no_update_in_states
Definition rtcComponent.hpp:221
OutputStage(StateMachineEngine &engine, BizLogicIf &bl)
Definition rtcComponent.hpp:114
std::function< void()> m_update_success_handler
Definition rtcComponent.hpp:219
std::shared_ptr< rad::cii::Request< std::string, std::string > > m_tmp_update_request
Definition rtcComponent.hpp:218
Definition stateMachineEngine.hpp:35
void RegisterAction(const std::string &id, ActionMethod action)
Register action.
Definition stateMachineEngine.cpp:86
void RegisterGuard(const std::string &id, GuardMethod guard)
Register guard.
Definition stateMachineEngine.cpp:108
void RegisterRejectHandler(const std::string &id, RejectMethod reject)
Register reject handler.
Definition stateMachineEngine.cpp:129
void RegisterActivity(const std::string &id, ActivityMethod activity, SuccessMethod on_success, FailureMethod on_failure)
Register activity.
Definition stateMachineEngine.cpp:121
Definition stdComponent.hpp:148
Definition stdComponent.hpp:420
Definition stdComponent.hpp:183
StateMachineEngine & m_engine
Definition stdComponent.hpp:410
BizLogicIf & m_logic
Definition stdComponent.hpp:411
static void Register(CommandReplier &replier, StateMachineEngine &engine)
Definition rtcCmdsImpl.hpp:122
Defines the JSON payload type JsonPayload.
Definition commandReplier.cpp:22
StdComponent RtcComponentSuper
Definition rtcComponent.hpp:66
@ Simple
Definition model.hpp:23
@ Composite
Definition model.hpp:23
@ Initial
Definition model.hpp:23
rad::StopToken StopToken
Definition stopToken.hpp:20
std::shared_ptr< typename EVENT::payload_t > GetPayloadNothrow(scxml4cpp::Context *c)
Definition stateMachineEngine.hpp:256
const std::string STD_OK_REPLY
Definition stdComponent.hpp:86
nlohmann::json JsonPayload
Type requirements:
Definition jsonPayload.hpp:25
Implementation of MAL commands for layer 'RtcComponent'.
Lifecycle of the 'Standard Component'.
Basic life cycle for RtcComponent.
Definition rtcComponent.hpp:74
RtcComponentSuper Super
Definition rtcComponent.hpp:75
Basic life cycle for StdComponent.
Definition stdComponent.hpp:144