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_setSequenceArguments(
48  SmId smId,
51  this->m_sequenceArgs = value.get_buffer();
52 }
53 
58 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqSucceeded(
59  SmId smId,
61 ) {
62  this->m_tlm.sequencesSucceeded++;
63  this->log_ACTIVITY_HI_SequenceDone(this->m_sequenceFilePath);
64  if (this->isConnected_seqDoneOut_OutputPort(0)) {
65  // report that the sequence succeeded to internal callers
66  this->seqDoneOut_out(0, 0, 0, Fw::CmdResponse::OK);
67  }
68 }
69 
74 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqCancelled(
75  SmId smId,
77 ) {
78  this->m_tlm.sequencesCancelled++;
79  this->log_ACTIVITY_HI_SequenceCancelled(this->m_sequenceFilePath);
80  if (this->isConnected_seqDoneOut_OutputPort(0)) {
81  // report that the sequence failed to internal callers
83  }
84 }
85 
90 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_dispatchStatement(
91  SmId smId,
93 ) {
94  Signal result = this->dispatchStatement();
95  switch (result) {
98  break;
99  }
102  break;
103  }
106  break;
107  }
108  default: {
109  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
110  }
111  }
112 }
113 
118 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setGoalState_RUNNING(
119  SmId smId,
121 ) {
122  this->m_goalState = FpySequencer_GoalState::RUNNING;
123 }
124 
129 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setGoalState_VALID(
130  SmId smId,
132 ) {
133  this->m_goalState = FpySequencer_GoalState::VALID;
134 }
135 
140 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setGoalState_IDLE(
141  SmId smId,
143 ) {
144  this->m_goalState = FpySequencer_GoalState::IDLE;
145 }
146 
151 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_sendCmdResponse_OK(
152  SmId smId,
154 ) {
155  if (this->m_sequenceBlockState == BlockState::BLOCK) {
156  // respond if we were waiting on a response
157  this->cmdResponse_out(this->m_savedOpCode, this->m_savedCmdSeq, Fw::CmdResponse::OK);
158  }
159 }
160 
165 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_sendCmdResponse_EXECUTION_ERROR(
166  SmId smId,
168 ) {
169  if (this->m_sequenceBlockState == BlockState::BLOCK) {
170  // respond if we were waiting on a response
171  this->cmdResponse_out(this->m_savedOpCode, this->m_savedCmdSeq, Fw::CmdResponse::EXECUTION_ERROR);
172  }
173 }
174 
179 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_resetRuntime(
180  SmId smId,
182 ) {
183  // explicitly call dtor
184  this->m_runtime.~Runtime();
185  new (&this->m_runtime) Runtime();
186 }
187 
193 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_validate(
194  SmId smId,
196 ) {
197  Fw::Success result = this->validate();
198  if (result == Fw::Success::FAILURE) {
200  return;
201  }
203 }
204 
208 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_checkShouldWake(
209  SmId smId,
211 ) {
212  Signal result = this->checkShouldWake();
213  switch (result) {
216  break;
217  }
220  break;
221  }
224  break;
225  }
226  default: {
227  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
228  }
229  }
230 }
231 
235 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_checkStatementTimeout(
236  SmId smId,
238 ) {
239  Signal result = this->checkStatementTimeout();
240  switch (result) {
243  break;
244  }
247  break;
248  }
251  break;
252  }
253  default: {
254  FW_ASSERT(0, static_cast<FwAssertArgType>(result));
255  }
256  }
257 }
258 
262 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_incrementSequenceCounter(
263  SmId smId,
265 ) {
266  this->m_sequencesStarted++;
267 }
268 
272 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_pushArgsToStack(
273  SmId smId,
275 ) {
276  const Svc::SeqArgs& args = this->m_sequenceArgs;
277 
278  // Early return if no arguments provided
279  if (args.get_size() == 0) {
280  return;
281  }
282 
283  // Push args buffer to stack. Args are already serialized in big-endian format
284  // by F' serialization system, so no endianness conversion is needed.
285  this->m_runtime.stack.push(args.get_buffer(), static_cast<Fpy::StackSizeType>(args.get_size()));
286 }
287 
291 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearSequenceFile(
292  SmId smId,
294 ) {
295  this->m_sequenceFilePath = "";
296 }
297 
301 void FpySequencer ::Svc_FpySequencer_SequencerStateMachine_action_clearSequenceArguments(
302  SmId smId,
304  this->m_sequenceArgs = {0, 0};
305 }
306 
310 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearBreakpoint(
311  SmId smId,
313 ) {
314  this->m_breakpoint.breakpointInUse = false;
315  this->m_breakpoint.breakpointIndex = 0;
316  this->m_breakpoint.breakOnlyOnceOnBreakpoint = false;
317  this->m_breakpoint.breakBeforeNextLine = false;
318 }
319 
323 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqBroken(
324  SmId smId,
326 ) {
327  this->log_ACTIVITY_HI_SequencePaused(this->m_runtime.nextStatementIndex);
328 }
329 
333 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setBreakpoint(
334  SmId smId,
337 ) {
338  this->m_breakpoint.breakpointInUse = value.get_breakOnBreakpoint();
339  this->m_breakpoint.breakOnlyOnceOnBreakpoint = value.get_breakOnlyOnceOnBreakpoint();
340  this->m_breakpoint.breakpointIndex = value.get_breakpointIndex();
342 }
343 
347 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_setBreakBeforeNextLine(
348  SmId smId,
350 ) {
351  this->m_breakpoint.breakBeforeNextLine = true;
352 }
353 
357 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_clearBreakBeforeNextLine(
358  SmId smId,
360 ) {
361  this->m_breakpoint.breakBeforeNextLine = false;
362 }
363 
367 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqFailed(
368  SmId smId,
370 ) {
371  if (this->isConnected_seqDoneOut_OutputPort(0)) {
372  // report that the sequence failed to internal callers
374  }
375 }
376 
380 void FpySequencer::Svc_FpySequencer_SequencerStateMachine_action_report_seqStarted(
381  SmId smId,
383 ) {
384  if (this->isConnected_seqStartOut_OutputPort(0)) {
385  // report that the sequence started to internal callers
386  // NOTE: Sequence Arguments would be cleared if a VALIDATION command is sent, not a full RUN command.
387  this->seqStartOut_out(0, this->m_sequenceFilePath, this->m_sequenceArgs);
388  }
389 }
390 // ----------------------------------------------------------------------
391 // Functions to implement for internal state machine guards
392 // ----------------------------------------------------------------------
393 
399  SmId smId,
401 ) const {
402  return this->m_goalState == FpySequencer_GoalState::RUNNING;
403 }
404 
410  SmId smId,
412 ) const {
413  // there are really two mechanisms for pausing the execution of the seq
414  // one is the "break on next line flag", and the other is the breakpoint
415  return this->m_breakpoint.breakBeforeNextLine ||
416  (this->m_breakpoint.breakpointInUse &&
417  this->m_breakpoint.breakpointIndex == this->m_runtime.nextStatementIndex);
418 }
419 
424  SmId smId,
426 ) const {
427  return this->m_breakpoint.breakOnlyOnceOnBreakpoint;
428 }
429 } // 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 ...
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.
called in dispatchStatement method when a statement was successfully dispatched
void cmdResponse_out(FwOpcodeType opCode, U32 cmdSeq, Fw::CmdResponse response)
Emit command response.
Type_of_buffer & get_buffer()
Get member buffer.
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.
FwSizeType get_size() const
Get member size.
Representing failure.
Command successfully executed.
void seqDoneOut_out(FwIndexType portNum, FwOpcodeType opCode, U32 cmdSeq, const Fw::CmdResponse &response) const
Invoke output port seqDoneOut.
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.
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.
void sequencer_sendSignal_result_failure()
Send signal result_failure to state machine sequencer.
bool isConnected_seqStartOut_OutputPort(FwIndexType portNum) const
void seqStartOut_out(FwIndexType portNum, const Fw::StringBase &filename, const Svc::SeqArgs &args) const
Invoke output port seqStartOut.
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 isConnected_seqDoneOut_OutputPort(FwIndexType portNum) const
U32 StackSizeType
the type which everything referencing a size or offset on the stack is represented in ...