F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FpySequencerStateMachine.cpp
Go to the documentation of this file.
1 #include <new>
3 namespace Svc {
4 
5 // ----------------------------------------------------------------------
6 // Functions to implement for internal state machine actions
7 // ----------------------------------------------------------------------
8 
12 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_signalEntered(
13  SmId smId,
15 ) {
17 }
18 
23 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setSequenceFilePath(
24  SmId smId,
27 ) {
28  this->m_sequenceFilePath = value.get_filePath();
29 }
30 
35 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setSequenceBlockState(
36  SmId smId,
39 ) {
40  this->m_sequenceBlockState = value.get_block();
41 }
42 
47 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqSucceeded(
48  SmId smId,
50 ) {
51  this->m_tlm.sequencesSucceeded++;
52  this->log_ACTIVITY_HI_SequenceDone(this->m_sequenceFilePath);
53  if (this->isConnected_seqDoneOut_OutputPort(0)) {
54  // report that the sequence succeeded to internal callers
55  this->seqDoneOut_out(0, 0, 0, Fw::CmdResponse::OK);
56  }
57 }
58 
63 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqCancelled(
64  SmId smId,
66 ) {
67  this->m_tlm.sequencesCancelled++;
68  this->log_ACTIVITY_HI_SequenceCancelled(this->m_sequenceFilePath);
69  if (this->isConnected_seqDoneOut_OutputPort(0)) {
70  // report that the sequence failed to internal callers
72  }
73 }
74 
79 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_dispatchStatement(
80  SmId smId,
82 ) {
83  Signal result = this->dispatchStatement();
84  switch (result) {
87  break;
88  }
91  break;
92  }
95  break;
96  }
97  default: {
98  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
99  }
100  }
101 }
102 
107 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setGoalState_RUNNING(
108  SmId smId,
110 ) {
111  this->m_goalState = FpySequencer_GoalState::RUNNING;
112 }
113 
118 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setGoalState_VALID(
119  SmId smId,
121 ) {
122  this->m_goalState = FpySequencer_GoalState::VALID;
123 }
124 
129 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setGoalState_IDLE(
130  SmId smId,
132 ) {
133  this->m_goalState = FpySequencer_GoalState::IDLE;
134 }
135 
140 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_sendCmdResponse_OK(
141  SmId smId,
143 ) {
144  if (this->m_sequenceBlockState == FpySequencer_BlockState::BLOCK) {
145  // respond if we were waiting on a response
146  this->cmdResponse_out(this->m_savedOpCode, this->m_savedCmdSeq, Fw::CmdResponse::OK);
147  }
148 }
149 
154 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_sendCmdResponse_EXECUTION_ERROR(
155  SmId smId,
157 ) {
158  if (this->m_sequenceBlockState == FpySequencer_BlockState::BLOCK) {
159  // respond if we were waiting on a response
160  this->cmdResponse_out(this->m_savedOpCode, this->m_savedCmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
161  }
162 }
163 
168 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_resetRuntime(
169  SmId smId,
171 ) {
172  // explicitly call dtor
173  this->m_runtime.~Runtime();
174  new (&this->m_runtime) Runtime();
175 }
176 
182 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_validate(
183  SmId smId,
185 ) {
186  Fw::Success result = this->validate();
187  if (result == Fw::Success::FAILURE) {
189  return;
190  }
192 }
193 
197 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_checkShouldWake(
198  SmId smId,
200 ) {
201  Signal result = this->checkShouldWake();
202  switch (result) {
205  break;
206  }
209  break;
210  }
213  break;
214  }
215  default: {
216  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
217  }
218  }
219 }
220 
224 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_checkStatementTimeout(
225  SmId smId,
227 ) {
228  Signal result = this->checkStatementTimeout();
229  switch (result) {
232  break;
233  }
236  break;
237  }
240  break;
241  }
242  default: {
243  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
244  }
245  }
246 }
247 
251 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_incrementSequenceCounter(
252  SmId smId,
254 ) {
255  this->m_sequencesStarted++;
256 }
257 
261 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearSequenceFile(
262  SmId smId,
264 ) {
265  this->m_sequenceFilePath = "";
266 }
267 
271 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearDebugBreakpoint(
272  SmId smId,
274 ) {
275  this->m_debug.breakOnBreakpoint = false;
276  this->m_debug.breakpointIndex = 0;
277  this->m_debug.breakOnlyOnceOnBreakpoint = false;
278 }
279 
283 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_debugBroken(
284  SmId smId,
286 ) {
287  this->log_ACTIVITY_HI_DebugBroken(this->m_runtime.nextStatementIndex, this->m_debug.breakOnlyOnceOnBreakpoint);
288 }
289 
293 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setDebugBreakpoint(
294  SmId smId,
297 ) {
298  this->m_debug.breakOnBreakpoint = value.get_breakOnBreakpoint();
299  this->m_debug.breakOnlyOnceOnBreakpoint = value.get_breakOnlyOnceOnBreakpoint();
300  this->m_debug.breakpointIndex = value.get_breakpointIndex();
302 }
303 
307 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqFailed(
308  SmId smId,
310 ) {
311  if (this->isConnected_seqDoneOut_OutputPort(0)) {
312  // report that the sequence failed to internal callers
314  }
315 }
316 
320 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqStarted(
321  SmId smId,
323 ) {
324  if (this->isConnected_seqDoneOut_OutputPort(0)) {
325  // report that the sequence started to internal callers
326  this->seqStartOut_out(0, this->m_sequenceFilePath);
327  }
328 }
329 // ----------------------------------------------------------------------
330 // Functions to implement for internal state machine guards
331 // ----------------------------------------------------------------------
332 
338  SmId smId,
340 ) const {
341  return this->m_goalState == FpySequencer_GoalState::RUNNING;
342 }
343 
349  SmId smId,
351 ) const {
352  return this->m_debug.breakOnBreakpoint && this->m_debug.breakpointIndex == this->m_runtime.nextStatementIndex;
353 }
354 
359  SmId smId,
361 ) const {
362  return this->m_debug.breakOnlyOnceOnBreakpoint;
363 }
364 } // namespace Svc
void sequencer_sendSignal_result_dispatchStatement_noMoreStatements()
Send signal result_dispatchStatement_noMoreStatements to state machine sequencer. ...
void sequencer_sendSignal_result_checkShouldWake_keepSleeping()
Send signal result_checkShouldWake_keepSleeping to state machine sequencer.
called in dispatchStatement method when a statement was unable to be sent out
called in dispatchStatement method when there were no more statements in the sequence ...
Svc::FpySequencer_BlockState::T get_block() const
Get member block.
void sequencer_sendSignal_result_dispatchStatement_success()
Send signal result_dispatchStatement_success to state machine sequencer.
bool get_breakOnBreakpoint() const
Get member breakOnBreakpoint.
bool Svc_FpySequencer_SequencerStateMachine_guard_goalStateIs_RUNNING(SmId smId, Svc_FpySequencer_SequencerStateMachine::Signal signal) const override
void sequencer_sendSignal_result_checkShouldWake_wakeup()
Send signal result_checkShouldWake_wakeup to state machine sequencer.
void sequencer_sendSignal_result_success()
Send signal result_success to state machine sequencer.
void sequencer_sendSignal_result_dispatchStatement_failure()
Send signal result_dispatchStatement_failure to state machine sequencer.
void seqStartOut_out(FwIndexType portNum, const Fw::StringBase &filename)
Invoke output port seqStartOut.
called in dispatchStatement method when a statement was successfully dispatched
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
bool get_breakOnlyOnceOnBreakpoint() const
Get member breakOnlyOnceOnBreakpoint.
void sequencer_sendSignal_result_checkStatementTimeout_noTimeout()
Send signal result_checkStatementTimeout_noTimeout to state machine sequencer.
Representing failure.
Command successfully executed.
bool isConnected_seqDoneOut_OutputPort(FwIndexType portNum)
void log_ACTIVITY_HI_DebugBroken(U32 stmtIdx, bool breakOnce) const
Log event DebugBroken.
void sequencer_sendSignal_result_timeOpFailed()
Send signal result_timeOpFailed to state machine sequencer.
void seqDoneOut_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response)
Invoke output port seqDoneOut.
Command had execution error.
void sequencer_sendSignal_result_checkStatementTimeout_statementTimeout()
Send signal result_checkStatementTimeout_statementTimeout to state machine sequencer.
void log_ACTIVITY_HI_SequenceCancelled(const Fw::StringBase &filePath) const
Log event SequenceCancelled.
RateGroupDivider component implementation.
void sequencer_sendSignal_result_failure()
Send signal result_failure to state machine sequencer.
void sequencer_sendSignal_entered()
Send signal entered to state machine sequencer.
void log_ACTIVITY_HI_DebugBreakpointSet(U32 breakpointIdx, bool breakOnce) const
Log event DebugBreakpointSet.
void log_ACTIVITY_HI_SequenceDone(const Fw::StringBase &filePath) const
Log event SequenceDone.
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Success/Failure.
bool Svc_FpySequencer_SequencerStateMachine_guard_shouldDebugBreak(SmId smId, Svc_FpySequencer_SequencerStateMachine::Signal signal) const override
bool Svc_FpySequencer_SequencerStateMachine_guard_debugBreakOnce(SmId smId, Svc_FpySequencer_SequencerStateMachine::Signal signal) const override