12 #ifndef RTCTK_COMPONENTFRAMEWORK_RUNABLE_HPP
13 #define RTCTK_COMPONENTFRAMEWORK_RUNABLE_HPP
15 #include <Rtctkif.hpp>
21 template <
typename Super>
29 template <
typename Super>
31 static_assert(std::is_base_of_v<RtcComponent, Super>,
"'Runnable' requires 'RtcComponent'");
32 static_assert(not is_base_of_template_v<Loopaware, Super>,
"'Runnable' excludes 'Loopaware'");
44 using Super::InputStage::InputStage;
47 Super::InputStage::Start();
64 this->m_no_disable_in_states.push_back(
"On.Operational.Error");
65 this->m_no_disable_in_states.push_back(
"On.Operational.Recovering");
66 this->m_no_disable_in_states.push_back(
"On.Operational.GoingRunning");
67 this->m_no_disable_in_states.push_back(
"On.Operational.GoingIdle");
68 this->m_no_disable_in_states.push_back(
"On.Operational.Running");
72 this->m_no_update_in_states.push_back(
"On.Operational.GoingRunning");
73 this->m_no_update_in_states.push_back(
"On.Operational.GoingIdle");
74 this->m_no_update_in_states.push_back(
"On.Operational.Error");
75 this->m_no_update_in_states.push_back(
"On.Operational.Recovering");
80 this->m_tmp_request = GetPayloadNothrow<events::Run>(c);
84 if (this->m_tmp_request) {
86 this->m_tmp_request =
nullptr;
93 this->m_tmp_request = GetPayloadNothrow<events::Idle>(c);
97 if (this->m_tmp_request) {
99 this->m_tmp_request =
nullptr;
106 if(
auto eptr = GetPayloadNothrow<events::Error>(c); eptr) {
107 if (this->m_tmp_request) {
108 this->m_tmp_request->SetException(
110 this->m_tmp_request =
nullptr;
118 this->m_tmp_request = GetPayloadNothrow<events::Recover>(c);
122 if (this->m_tmp_request) {
124 this->m_tmp_request =
nullptr;
132 static_cast<BizLogicIf&
>(this->m_logic).ActivityGoingRunning(stop_token);
133 }, this->m_success_handler, this->m_error_handler);
137 static_cast<BizLogicIf&
>(this->m_logic).ActivityGoingIdle(stop_token);
138 }, this->m_success_handler, this->m_error_handler);
142 static_cast<BizLogicIf&
>(this->m_logic).ActivityRunning(stop_token);
143 }, this->m_success_handler, this->m_error_handler);
147 static_cast<BizLogicIf&
>(this->m_logic).ActivityRecovering(stop_token);
148 }, this->m_success_handler, this->m_error_handler);
155 this->RegisterLayer({
"Runnable", {}});
157 const std::string parent_region =
"On.Operational.RegionMain";
159 this->mm.AddState(
Composite, parent_region,
"On.Operational");
161 this->mm.AddState(
Initial,
"On.Operational.Initial", parent_region);
162 this->mm.AddState(
Simple,
"On.Operational.Idle", parent_region);
163 this->mm.AddState(
Simple,
"On.Operational.Error", parent_region ,
"" ,
"ActionErrorEntry");
164 this->mm.AddState(
Simple,
"On.Operational.Running", parent_region ,
"ActivityRunning");
165 this->mm.AddState(
Simple,
"On.Operational.Recovering", parent_region ,
"ActivityRecovering" ,
"ActionRecoveringEntry");
166 this->mm.AddState(
Simple,
"On.Operational.GoingRunning", parent_region ,
"ActivityGoingRunning" ,
"ActionGoingRunningEntry");
167 this->mm.AddState(
Simple,
"On.Operational.GoingIdle", parent_region ,
"ActivityGoingIdle" ,
"ActionGoingIdleEntry");
169 this->mm.AddTrans(
"On.Operational.Initial" ,
"On.Operational.Idle" );
170 this->mm.AddTrans(parent_region ,
"On.Operational.Error" ,
"events.Error");
172 this->mm.AddTrans(
"On.Operational.Error" ,
"On.Operational.Recovering" ,
"events.Recover");
173 this->mm.AddTrans(
"On.Operational.Recovering" ,
"On.Operational.Idle" ,
"events.Done",
"" ,
"ActionRecoveringDone");
175 this->mm.AddTrans(
"On.Operational.Idle" ,
"On.Operational.GoingRunning" ,
"events.Run");
176 this->mm.AddTrans(
"On.Operational.GoingRunning" ,
"On.Operational.Running" ,
"events.Done",
"" ,
"ActionGoingRunningDone");
178 this->mm.AddTrans(
"On.Operational.Running" ,
"On.Operational.GoingIdle" ,
"events.Idle");
179 this->mm.AddTrans(
"On.Operational.GoingIdle" ,
"On.Operational.Idle" ,
"events.Done",
"" ,
"ActionGoingIdleDone");
181 this->mm.AddTrans(
"On.Operational.Running" ,
"On.Operational.GoingIdle" ,
"events.Done");
188 #endif // RTCTK_COMPONENTFRAMEWORK_RUNABLE_HPP