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  Fw::ParamValid valid;
176  this->m_runtime.flags[Fpy::FlagId::EXIT_ON_CMD_FAIL] = this->paramGet_FLAG_DEFAULT_EXIT_ON_CMD_FAIL(valid);
177 }
178 
184 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_validate(
185  SmId smId,
187 ) {
188  Fw::Success result = this->validate();
189  if (result == Fw::Success::FAILURE) {
191  return;
192  }
194 }
195 
199 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_checkShouldWake(
200  SmId smId,
202 ) {
203  Signal result = this->checkShouldWake();
204  switch (result) {
207  break;
208  }
211  break;
212  }
215  break;
216  }
217  default: {
218  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
219  }
220  }
221 }
222 
226 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_checkStatementTimeout(
227  SmId smId,
229 ) {
230  Signal result = this->checkStatementTimeout();
231  switch (result) {
234  break;
235  }
238  break;
239  }
242  break;
243  }
244  default: {
245  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
246  }
247  }
248 }
249 
253 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_incrementSequenceCounter(
254  SmId smId,
256 ) {
257  this->m_sequencesStarted++;
258 }
259 
263 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearSequenceFile(
264  SmId smId,
266 ) {
267  this->m_sequenceFilePath = "";
268 }
269 
273 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearBreakpoint(
274  SmId smId,
276 ) {
277  this->m_breakpoint.breakpointInUse = false;
278  this->m_breakpoint.breakpointIndex = 0;
279  this->m_breakpoint.breakOnlyOnceOnBreakpoint = false;
280  this->m_breakpoint.breakBeforeNextLine = false;
281 }
282 
286 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqBroken(
287  SmId smId,
289 ) {
290  this->log_ACTIVITY_HI_SequencePaused(this->m_runtime.nextStatementIndex);
291 }
292 
296 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setBreakpoint(
297  SmId smId,
300 ) {
301  this->m_breakpoint.breakpointInUse = value.get_breakOnBreakpoint();
302  this->m_breakpoint.breakOnlyOnceOnBreakpoint = value.get_breakOnlyOnceOnBreakpoint();
303  this->m_breakpoint.breakpointIndex = value.get_breakpointIndex();
305 }
306 
310 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setBreakBeforeNextLine(
311  SmId smId,
313 ) {
314  this->m_breakpoint.breakBeforeNextLine = true;
315 }
316 
320 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearBreakBeforeNextLine(
321  SmId smId,
323 ) {
324  this->m_breakpoint.breakBeforeNextLine = false;
325 }
326 
330 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqFailed(
331  SmId smId,
333 ) {
334  if (this->isConnected_seqDoneOut_OutputPort(0)) {
335  // report that the sequence failed to internal callers
337  }
338 }
339 
343 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqStarted(
344  SmId smId,
346 ) {
347  if (this->isConnected_seqDoneOut_OutputPort(0)) {
348  // report that the sequence started to internal callers
349  this->seqStartOut_out(0, this->m_sequenceFilePath);
350  }
351 }
352 // ----------------------------------------------------------------------
353 // Functions to implement for internal state machine guards
354 // ----------------------------------------------------------------------
355 
361  SmId smId,
363 ) const {
364  return this->m_goalState == FpySequencer_GoalState::RUNNING;
365 }
366 
372  SmId smId,
374 ) const {
375  // there are really two mechanisms for pausing the execution of the seq
376  // one is the "break on next line flag", and the other is the breakpoint
377  return this->m_breakpoint.breakBeforeNextLine ||
378  (this->m_breakpoint.breakpointInUse &&
379  this->m_breakpoint.breakpointIndex == this->m_runtime.nextStatementIndex);
380 }
381 
386  SmId smId,
388 ) const {
389  return this->m_breakpoint.breakOnlyOnceOnBreakpoint;
390 }
391 } // 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
void log_ACTIVITY_HI_SequencePaused(U32 stmtIdx) const
Log event SequencePaused.
called in dispatchStatement method when there were no more statements in the sequence ...
Svc::FpySequencer_BlockState::T get_block() const
Get member block.
U32 get_breakpointIndex() const
Get member breakpointIndex.
void sequencer_sendSignal_result_dispatchStatement_success()
Send signal result_dispatchStatement_success to state machine sequencer.
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 Svc_FpySequencer_SequencerStateMachine_guard_shouldBreak(SmId smId, Svc_FpySequencer_SequencerStateMachine::Signal signal) const override
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)
if true, the sequence will exit with an error if a command fails
void log_ACTIVITY_HI_BreakpointSet(U32 breakpointIdx, bool breakOnce) const
Log event BreakpointSet.
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.
bool Svc_FpySequencer_SequencerStateMachine_guard_breakOnce(SmId smId, Svc_FpySequencer_SequencerStateMachine::Signal signal) const override
RateGroupDivider component implementation.
Enum representing parameter validity.
void sequencer_sendSignal_result_failure()
Send signal result_failure to state machine sequencer.
void sequencer_sendSignal_entered()
Send signal entered to state machine sequencer.
bool get_breakOnlyOnceOnBreakpoint() const
Get member breakOnlyOnceOnBreakpoint.
void log_ACTIVITY_HI_SequenceDone(const Fw::StringBase &filePath) const
Log event SequenceDone.
bool get_breakOnBreakpoint() const
Get member breakOnBreakpoint.
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Success/Failure.
bool paramGet_FLAG_DEFAULT_EXIT_ON_CMD_FAIL(Fw::ParamValid &valid)