SMACC2
sm_respira_1.hpp
Go to the documentation of this file.
1// Copyright 2021 RobosoftAI Inc.
2//
3// Licensed under the Apache License, Version 2.0 (the "License");
4// you may not use this file except in compliance with the License.
5// You may obtain a copy of the License at
6//
7// http://www.apache.org/licenses/LICENSE-2.0
8//
9// Unless required by applicable law or agreed to in writing, software
10// distributed under the License is distributed on an "AS IS" BASIS,
11// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12// See the License for the specific language governing permissions and
13// limitations under the License.
14
15#pragma once
16
17#include <rclcpp/rclcpp.hpp>
18#include <smacc2/smacc.hpp>
19
20// CLIENTS
22#include <ros_timer_client/cl_ros_timer.hpp>
23
24// ORTHOGONALS
29
30using namespace cl_ros_timer;
31using namespace cl_ros_publisher;
32using namespace cl_keyboard;
33using namespace sm_respira_1::cl_subscriber;
34
35//CLIENT BEHAVIORS
39
42
44
45//#include <ros_timer_client/client_behaviors/cb_ros_timer.hpp>
46#include <ros_timer_client/client_behaviors/cb_timer_countdown_once.hpp>
47
48//STATE REACTORS
50
51using namespace smacc2;
52using namespace smacc2::state_reactors;
53using namespace smacc2::default_events;
54
55namespace sm_respira_1
56{
57//SUPERSTATES
58class SsACCycle;
59namespace ac_cycle_inner_states
60{
61class StiACCycleLoop;
65class StiACCycleDwell;
66} // namespace ac_cycle_inner_states
67
68class SsCMVCycle;
69
70namespace cmv_cycle_inner_states
71{
72//FORWARD DECLARATIONS OF ALL INNER STATES
73class StiCMVCycleLoop;
78} // namespace cmv_cycle_inner_states
79
80class SsPCCycle;
81namespace pc_cycle_inner_states
82{
83//FORWARD DECLARATIONS OF ALL INNER STATES
84class StiPCCycleLoop;
88class StiPCCycleDwell;
89} // namespace pc_cycle_inner_states
90
91class SsPSCycle;
92namespace ps_cycle_inner_states
93{
94//FORWARD DECLARATIONS OF ALL INNER STATES
95class StiPSCycleLoop;
99class StiPSCycleDwell;
100} // namespace ps_cycle_inner_states
101
102//STATES
103class StObserve;
104class StLeakyLungStep1;
105class StLeakyLungStep2;
106class StLeakyLungStep3;
110class StSystemShutdown;
111
112//MODE STATES
113class MsRun;
114class MsLeakyLung;
116class MsCalibration;
117class MsShutdown;
118
119struct EvToDeep : sc::event<EvToDeep>
120{
121};
122
123struct EvFail : sc::event<EvFail>
124{
125};
126
127// STATE MACHINE
128struct SmRespira1 : public smacc2::SmaccStateMachineBase<SmRespira1, MsRun>
129{
130 using SmaccStateMachineBase::SmaccStateMachineBase;
131
132 virtual void onInitialize() override
133 {
134 this->createOrthogonal<OrTimer>();
135 this->createOrthogonal<OrUpdatablePublisher>();
136 this->createOrthogonal<OrKeyboard>();
137 this->createOrthogonal<OrSubscriber>();
138 }
139};
140} // namespace sm_respira_1
141
142// MODE STATES
148
149//STATES
158
163
164//ss_ac_cycle
170
171//ss_cmv_cycle
177
178//ss_pc_cycle
184
185//ss_ps_cycle
virtual void onInitialize() override
this function should be implemented by the user to create the orthogonals