F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
FpySequencerRunState.cpp
Go to the documentation of this file.
1 #include <new>
2 #include "Fw/Com/ComPacket.hpp"
3 #include "Fw/Time/Time.hpp"
5 namespace Svc {
6 
7 // returns the index of the current statement
8 U32 FpySequencer::currentStatementIdx() {
9  if (this->m_runtime.nextStatementIndex == 0) {
10  // haven't started executing the sequence yet
11  return 0;
12  }
13  return this->m_runtime.nextStatementIndex - 1;
14 }
15 
16 Signal FpySequencer::dispatchStatement() {
17  // check to make sure no array out of bounds, or if it is out of bounds it's only 1 out of bound
18  // as that indicates eof
19  FW_ASSERT(this->m_runtime.nextStatementIndex <= this->m_sequenceObj.get_header().get_statementCount());
20 
21  if (this->m_runtime.nextStatementIndex == this->m_sequenceObj.get_header().get_statementCount()) {
23  }
24 
25  const Fpy::Statement& nextStatement = this->m_sequenceObj.get_statements()[this->m_runtime.nextStatementIndex];
26  this->m_runtime.nextStatementIndex++;
27  this->m_runtime.currentStatementOpcode = nextStatement.get_opCode();
28  this->m_runtime.currentCmdOpcode = 0; // we haven't deserialized the directive yet, so we don't know if it's a cmd
29 
30  Fw::Success result;
31  DirectiveUnion directiveUnion;
32 
33  result = this->deserializeDirective(nextStatement, directiveUnion);
34 
35  if (!result) {
37  }
38 
39  if (this->m_runtime.currentStatementOpcode == Fpy::DirectiveId::CONST_CMD) {
40  // update the opcode of the cmd we will await
41  this->m_runtime.currentCmdOpcode = directiveUnion.constCmd.get_opCode();
42  }
43 
44  this->dispatchDirective(directiveUnion,
45  Fpy::DirectiveId(static_cast<Fpy::DirectiveId::T>(nextStatement.get_opCode())));
46  this->m_runtime.currentStatementDispatchTime =
47  getTime(); // set dispatch time right after we have successfully dispatched
48 
49  this->m_statementsDispatched++;
50 
52 }
53 
54 // deserializes a directive from bytes into the Fpy type
55 // returns success if able to deserialize, and returns the Fpy type object
56 // as a reference, in a union of all the possible directive type objects
57 Fw::Success FpySequencer::deserializeDirective(const Fpy::Statement& stmt, DirectiveUnion& deserializedDirective) {
58  Fw::SerializeStatus status;
59  // make our own esb so we can deser from stmt without breaking its constness
60  Fw::ExternalSerializeBuffer argBuf(const_cast<U8*>(stmt.get_argBuf().getBuffAddr()), stmt.get_argBuf().getSize());
61  status = argBuf.setBuffLen(stmt.get_argBuf().getSize());
62  FW_ASSERT(status == Fw::FW_SERIALIZE_OK, status);
63 
64  switch (stmt.get_opCode()) {
66  // in order to use a type with non trivial ctor in cpp union, have to manually construct and destruct it
67  new (&deserializedDirective.waitRel) FpySequencer_WaitRelDirective();
68  // wait rel does not need deser
69  if (argBuf.getDeserializeSizeLeft() != 0) {
70  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
72  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
73  return Fw::Success::FAILURE;
74  }
75  return Fw::Success::SUCCESS;
76  }
78  new (&deserializedDirective.waitAbs) FpySequencer_WaitAbsDirective();
79  // wait abs does not need deser
80  if (argBuf.getDeserializeSizeLeft() != 0) {
81  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
83  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
84  return Fw::Success::FAILURE;
85  }
86  return Fw::Success::SUCCESS;
87  }
89  new (&deserializedDirective.gotoDirective) FpySequencer_GotoDirective();
90  status = argBuf.deserializeTo(deserializedDirective.gotoDirective);
91  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
92  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
93  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
94  return Fw::Success::FAILURE;
95  }
96  return Fw::Success::SUCCESS;
97  }
98  case Fpy::DirectiveId::IF: {
99  new (&deserializedDirective.ifDirective) FpySequencer_IfDirective();
100  status = argBuf.deserializeTo(deserializedDirective.ifDirective);
101  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
102  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
103  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
104  return Fw::Success::FAILURE;
105  }
106  return Fw::Success::SUCCESS;
107  }
109  new (&deserializedDirective.noOp) FpySequencer_NoOpDirective();
110  // no op does not need deser
111  if (argBuf.getDeserializeSizeLeft() != 0) {
112  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
114  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
115  return Fw::Success::FAILURE;
116  }
117  return Fw::Success::SUCCESS;
118  }
120  new (&deserializedDirective.pushTlmVal) FpySequencer_PushTlmValDirective();
121  status = argBuf.deserializeTo(deserializedDirective.pushTlmVal);
122  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
123  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
124  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
125  return Fw::Success::FAILURE;
126  }
127  return Fw::Success::SUCCESS;
128  }
130  new (&deserializedDirective.pushTlmValAndTime) FpySequencer_PushTlmValAndTimeDirective();
131  status = argBuf.deserializeTo(deserializedDirective.pushTlmValAndTime);
132  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
133  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
134  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
135  return Fw::Success::FAILURE;
136  }
137  return Fw::Success::SUCCESS;
138  }
140  new (&deserializedDirective.pushPrm) FpySequencer_PushPrmDirective();
141  status = argBuf.deserializeTo(deserializedDirective.pushPrm);
142  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
143  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
144  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
145  return Fw::Success::FAILURE;
146  }
147  return Fw::Success::SUCCESS;
148  }
150  new (&deserializedDirective.constCmd) FpySequencer_ConstCmdDirective();
151 
152  // first deserialize the opcode
153  FwOpcodeType opcode;
154  status = argBuf.deserializeTo(opcode);
155  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) {
156  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
157  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
158  return Fw::Success::FAILURE;
159  }
160 
161  deserializedDirective.constCmd.set_opCode(opcode);
162  // how many bytes are left?
163  FwSizeType cmdArgBufSize = argBuf.getDeserializeSizeLeft();
164 
165  // check to make sure the value will fit in the FpySequencer_ConstCmdDirective::argBuf
166  if (cmdArgBufSize > Fpy::MAX_DIRECTIVE_SIZE) {
167  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
169  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
170  return Fw::Success::FAILURE;
171  }
172 
173  // okay, it will fit. put it in
174  status = argBuf.deserializeTo(deserializedDirective.constCmd.get_argBuf(), cmdArgBufSize,
176 
177  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) {
178  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
179  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
180  return Fw::Success::FAILURE;
181  }
182 
183  // now there should be nothing left, otherwise coding err
184  FW_ASSERT(argBuf.getDeserializeSizeLeft() == 0,
185  static_cast<FwAssertArgType>(argBuf.getDeserializeSizeLeft()));
186 
187  // and set the buf size now that we know it
188  deserializedDirective.constCmd.set__argBufSize(cmdArgBufSize);
189  return Fw::Success::SUCCESS;
190  }
191  // fallthrough on purpose
240  new (&deserializedDirective.stackOp) FpySequencer_StackOpDirective();
241  if (argBuf.getDeserializeSizeLeft() != 0) {
242  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
244  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
245  return Fw::Success::FAILURE;
246  }
247  deserializedDirective.stackOp.set__op(stmt.get_opCode());
248  return Fw::Success::SUCCESS;
249  }
250  case Fpy::DirectiveId::EXIT: {
251  new (&deserializedDirective.exit) FpySequencer_ExitDirective();
252  if (argBuf.getDeserializeSizeLeft() != 0) {
253  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
255  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
256  return Fw::Success::FAILURE;
257  }
258  return Fw::Success::SUCCESS;
259  }
261  new (&deserializedDirective.allocate) FpySequencer_AllocateDirective();
262  status = argBuf.deserializeTo(deserializedDirective.allocate);
263  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
264  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
265  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
266  return Fw::Success::FAILURE;
267  }
268  return Fw::Success::SUCCESS;
269  }
271  new (&deserializedDirective.storeRelConstOffset) FpySequencer_StoreRelConstOffsetDirective();
272  status = argBuf.deserializeTo(deserializedDirective.storeRelConstOffset);
273  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
274  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
275  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
276  return Fw::Success::FAILURE;
277  }
278  return Fw::Success::SUCCESS;
279  }
281  new (&deserializedDirective.loadRel) FpySequencer_LoadRelDirective();
282  status = argBuf.deserializeTo(deserializedDirective.loadRel);
283  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
284  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
285  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
286  return Fw::Success::FAILURE;
287  }
288  return Fw::Success::SUCCESS;
289  }
291  new (&deserializedDirective.pushVal) FpySequencer_PushValDirective();
292 
293  // how many bytes are left?
294  FwSizeType bufSize = argBuf.getDeserializeSizeLeft();
295 
296  // check to make sure the value will fit in the FpySequencer_PushValDirective::val buf
297  if (bufSize > Fpy::MAX_DIRECTIVE_SIZE) {
298  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
300  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
301  return Fw::Success::FAILURE;
302  }
303 
304  // okay, it will fit. put it in
305  status =
306  argBuf.deserializeTo(deserializedDirective.pushVal.get_val(), bufSize, Fw::Serialization::OMIT_LENGTH);
307 
308  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) {
309  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
310  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
311  return Fw::Success::FAILURE;
312  }
313 
314  // now there should be nothing left, otherwise coding err
315  FW_ASSERT(argBuf.getDeserializeSizeLeft() == 0,
316  static_cast<FwAssertArgType>(argBuf.getDeserializeSizeLeft()));
317 
318  // and set the buf size now that we know it
319  deserializedDirective.pushVal.set__valSize(bufSize);
320  return Fw::Success::SUCCESS;
321  }
323  new (&deserializedDirective.discard) FpySequencer_DiscardDirective();
324  status = argBuf.deserializeTo(deserializedDirective.discard);
325  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
326  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
327  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
328  return Fw::Success::FAILURE;
329  }
330  return Fw::Success::SUCCESS;
331  }
333  new (&deserializedDirective.memCmp) FpySequencer_MemCmpDirective();
334  status = argBuf.deserializeTo(deserializedDirective.memCmp);
335  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
336  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
337  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
338  return Fw::Success::FAILURE;
339  }
340  return Fw::Success::SUCCESS;
341  }
343  new (&deserializedDirective.stackCmd) FpySequencer_StackCmdDirective();
344  status = argBuf.deserializeTo(deserializedDirective.stackCmd);
345  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
346  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
347  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
348  return Fw::Success::FAILURE;
349  }
350  return Fw::Success::SUCCESS;
351  }
353  new (&deserializedDirective.pushTime) FpySequencer_PushTimeDirective();
354  if (argBuf.getDeserializeSizeLeft() != 0) {
355  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
357  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
358  return Fw::Success::FAILURE;
359  }
360  return Fw::Success::SUCCESS;
361  }
363  new (&deserializedDirective.setSeed) FpySequencer_SetSeedDirective();
364  if (argBuf.getDeserializeSizeLeft() != 0) {
365  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
367  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
368  return Fw::Success::FAILURE;
369  }
370  return Fw::Success::SUCCESS;
371  }
373  new (&deserializedDirective.pushRand) FpySequencer_PushRandDirective();
374  if (argBuf.getDeserializeSizeLeft() != 0) {
375  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
377  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
378  return Fw::Success::FAILURE;
379  }
380  return Fw::Success::SUCCESS;
381  }
383  new (&deserializedDirective.getField) FpySequencer_GetFieldDirective();
384  status = argBuf.deserializeTo(deserializedDirective.getField);
385  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
386  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
387  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
388  return Fw::Success::FAILURE;
389  }
390  return Fw::Success::SUCCESS;
391  }
392  case Fpy::DirectiveId::PEEK: {
393  new (&deserializedDirective.peek) FpySequencer_PeekDirective();
394  if (argBuf.getDeserializeSizeLeft() != 0) {
395  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
397  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
398  return Fw::Success::FAILURE;
399  }
400  return Fw::Success::SUCCESS;
401  }
403  new (&deserializedDirective.storeRel) FpySequencer_StoreRelDirective();
404  status = argBuf.deserializeTo(deserializedDirective.storeRel);
405  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
406  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
407  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
408  return Fw::Success::FAILURE;
409  }
410  return Fw::Success::SUCCESS;
411  }
412  case Fpy::DirectiveId::CALL: {
413  new (&deserializedDirective.call) FpySequencer_CallDirective();
414  if (argBuf.getDeserializeSizeLeft() != 0) {
415  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
417  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
418  return Fw::Success::FAILURE;
419  }
420  return Fw::Success::SUCCESS;
421  }
423  new (&deserializedDirective.returnDirective) FpySequencer_ReturnDirective();
424  status = argBuf.deserializeTo(deserializedDirective.returnDirective);
425  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
426  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
427  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
428  return Fw::Success::FAILURE;
429  }
430  return Fw::Success::SUCCESS;
431  }
433  new (&deserializedDirective.loadAbs) FpySequencer_LoadAbsDirective();
434  status = argBuf.deserializeTo(deserializedDirective.loadAbs);
435  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
436  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
437  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
438  return Fw::Success::FAILURE;
439  }
440  return Fw::Success::SUCCESS;
441  }
443  new (&deserializedDirective.storeAbs) FpySequencer_StoreAbsDirective();
444  status = argBuf.deserializeTo(deserializedDirective.storeAbs);
445  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
446  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
447  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
448  return Fw::Success::FAILURE;
449  }
450  return Fw::Success::SUCCESS;
451  }
453  new (&deserializedDirective.storeAbsConstOffset) FpySequencer_StoreAbsConstOffsetDirective();
454  status = argBuf.deserializeTo(deserializedDirective.storeAbsConstOffset);
455  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
456  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
457  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
458  return Fw::Success::FAILURE;
459  }
460  return Fw::Success::SUCCESS;
461  }
463  new (&deserializedDirective.popEvent) FpySequencer_PopEventDirective();
464  // pop event has no hardcoded args
465  if (argBuf.getDeserializeSizeLeft() != 0) {
466  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
468  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
469  return Fw::Success::FAILURE;
470  }
471  return Fw::Success::SUCCESS;
472  }
474  new (&deserializedDirective.popSerializable) FpySequencer_PopSerializableDirective();
475  status = argBuf.deserializeTo(deserializedDirective.popSerializable);
476  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
477  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
478  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
479  return Fw::Success::FAILURE;
480  }
481  return Fw::Success::SUCCESS;
482  }
484  // unsure what this opcode is. check compiler version matches sequencer
485  break;
486  }
487  // ommited default case to throw compile error on unhandled directives.
488  }
489  this->log_WARNING_HI_UnknownSequencerDirective(stmt.get_opCode(), this->currentStatementIdx(),
490  this->m_sequenceFilePath);
491  return Fw::Success::FAILURE;
492 }
493 
494 // dispatches a deserialized sequencer directive to the right handler.
495 void FpySequencer::dispatchDirective(const DirectiveUnion& directive, const Fpy::DirectiveId& id) {
496  switch (id) {
498  // coding err
499  FW_ASSERT(false);
500  return;
501  }
503  this->directive_waitRel_internalInterfaceInvoke(directive.waitRel);
504  return;
505  }
507  this->directive_waitAbs_internalInterfaceInvoke(directive.waitAbs);
508  return;
509  }
510  case Fpy::DirectiveId::GOTO: {
511  this->directive_goto_internalInterfaceInvoke(directive.gotoDirective);
512  return;
513  }
514  case Fpy::DirectiveId::IF: {
515  this->directive_if_internalInterfaceInvoke(directive.ifDirective);
516  return;
517  }
519  this->directive_noOp_internalInterfaceInvoke(directive.noOp);
520  return;
521  }
523  this->directive_pushTlmVal_internalInterfaceInvoke(directive.pushTlmVal);
524  return;
525  }
527  this->directive_pushTlmValAndTime_internalInterfaceInvoke(directive.pushTlmValAndTime);
528  return;
529  }
531  this->directive_pushPrm_internalInterfaceInvoke(directive.pushPrm);
532  return;
533  }
535  this->directive_constCmd_internalInterfaceInvoke(directive.constCmd);
536  return;
537  }
538  // fallthrough on purpose
587  this->directive_stackOp_internalInterfaceInvoke(directive.stackOp);
588  return;
589  }
590  case Fpy::DirectiveId::EXIT: {
591  this->directive_exit_internalInterfaceInvoke(directive.exit);
592  return;
593  }
595  this->directive_allocate_internalInterfaceInvoke(directive.allocate);
596  return;
597  }
599  this->directive_storeRelConstOffset_internalInterfaceInvoke(directive.storeRelConstOffset);
600  return;
601  }
603  this->directive_loadRel_internalInterfaceInvoke(directive.loadRel);
604  return;
605  }
607  this->directive_pushVal_internalInterfaceInvoke(directive.pushVal);
608  return;
609  }
611  this->directive_discard_internalInterfaceInvoke(directive.discard);
612  return;
613  }
615  this->directive_memCmp_internalInterfaceInvoke(directive.memCmp);
616  return;
617  }
619  this->directive_stackCmd_internalInterfaceInvoke(directive.stackCmd);
620  return;
621  }
623  this->directive_pushTime_internalInterfaceInvoke(directive.pushTime);
624  return;
625  }
627  this->directive_setSeed_internalInterfaceInvoke(directive.setSeed);
628  return;
629  }
631  this->directive_pushRand_internalInterfaceInvoke(directive.pushRand);
632  return;
633  }
635  this->directive_getField_internalInterfaceInvoke(directive.getField);
636  return;
637  }
638  case Fpy::DirectiveId::PEEK: {
639  this->directive_peek_internalInterfaceInvoke(directive.peek);
640  return;
641  }
643  this->directive_storeRel_internalInterfaceInvoke(directive.storeRel);
644  return;
645  }
646  case Fpy::DirectiveId::CALL: {
647  this->directive_call_internalInterfaceInvoke(directive.call);
648  return;
649  }
651  this->directive_return_internalInterfaceInvoke(directive.returnDirective);
652  return;
653  }
655  this->directive_loadAbs_internalInterfaceInvoke(directive.loadAbs);
656  return;
657  }
659  this->directive_storeAbs_internalInterfaceInvoke(directive.storeAbs);
660  return;
661  }
663  this->directive_storeAbsConstOffset_internalInterfaceInvoke(directive.storeAbsConstOffset);
664  return;
665  }
667  this->directive_popEvent_internalInterfaceInvoke(directive.popEvent);
668  return;
669  }
671  this->directive_popSerializable_internalInterfaceInvoke(directive.popSerializable);
672  return;
673  }
674  }
675  // coding err
676  FW_ASSERT(false, static_cast<FwAssertArgType>(id));
677 }
678 
679 Signal FpySequencer::checkShouldWake() {
680  Fw::Time currentTime = this->getTime();
681 
682  if (currentTime.getTimeBase() != this->m_runtime.wakeupTime.getTimeBase()) {
683  // cannot compare these times.
684  this->log_WARNING_HI_MismatchedTimeBase(currentTime.getTimeBase(), this->m_runtime.wakeupTime.getTimeBase());
685 
687  }
688 
689  // Do not compare time context
690 
691  if (currentTime < this->m_runtime.wakeupTime) {
692  // not time to wake up!
694  }
695 
696  // say we've finished our sleep
698 }
699 
700 // checks whether the currently executing statement timed out
701 Signal FpySequencer::checkStatementTimeout() {
702  Fw::ParamValid valid;
703  F32 timeout = this->paramGet_STATEMENT_TIMEOUT_SECS(valid);
704  if (timeout <= 0 || timeout > static_cast<F32>(std::numeric_limits<U32>::max())) {
705  // no timeout
707  }
708 
709  Fw::Time currentTime = getTime();
710 
711  if (currentTime.getTimeBase() != this->m_runtime.currentStatementDispatchTime.getTimeBase()) {
712  // can't compare time base. must have changed
714  this->m_runtime.currentStatementDispatchTime.getTimeBase());
716  }
717 
718  // Do not compare time context
719 
720  if (this->m_runtime.currentStatementDispatchTime.getSeconds() > currentTime.getSeconds()) {
721  // somehow we've gone back in time... just ignore it and move on. should get fixed
722  // if we wait I guess
724  }
725 
726  if (this->m_runtime.currentStatementDispatchTime.getSeconds() == currentTime.getSeconds() &&
727  this->m_runtime.currentStatementDispatchTime.getUSeconds() > currentTime.getUSeconds()) {
728  // same as above
730  }
731 
732  U64 currentUSeconds = static_cast<U64>(currentTime.getSeconds()) * 1000000 + currentTime.getUSeconds();
733  U64 dispatchUSeconds = static_cast<U64>(this->m_runtime.currentStatementDispatchTime.getSeconds()) * 1000000 +
734  this->m_runtime.currentStatementDispatchTime.getUSeconds();
735 
736  U64 timeoutUSeconds = static_cast<U64>(timeout * 1000000.0f);
737 
738  if (currentUSeconds - dispatchUSeconds < timeoutUSeconds) {
739  // not over timeout
741  }
742 
743  // we timed out
744  if (this->m_runtime.currentStatementOpcode == Fpy::DirectiveId::CONST_CMD ||
745  this->m_runtime.currentStatementOpcode == Fpy::DirectiveId::STACK_CMD) {
746  // if we were executing a command, warn that the cmd timed out with its opcode
747  this->log_WARNING_HI_CommandTimedOut(this->m_runtime.currentCmdOpcode, this->currentStatementIdx(),
748  this->m_sequenceFilePath);
749  } else {
750  this->log_WARNING_HI_DirectiveTimedOut(this->m_runtime.currentStatementOpcode, this->currentStatementIdx(),
751  this->m_sequenceFilePath);
752  }
753 
755 }
756 
757 } // namespace Svc
Serialization/Deserialization operation was successful.
called in dispatchStatement method when a statement was unable to be sent out
void log_WARNING_HI_DirectiveTimedOut(U8 opCode, U32 stmtIdx, const Fw::StringBase &filePath) const
Log event DirectiveTimedOut.
FwIdType FwOpcodeType
The type of a command opcode.
called in dispatchStatement method when there were no more statements in the sequence ...
void directive_pushVal_internalInterfaceInvoke(const Svc::FpySequencer_PushValDirective &directive)
Internal interface base-class function for directive_pushVal.
Representing success.
PlatformSizeType FwSizeType
void directive_popEvent_internalInterfaceInvoke(const Svc::FpySequencer_PopEventDirective &directive)
Internal interface base-class function for directive_popEvent.
void directive_stackOp_internalInterfaceInvoke(const Svc::FpySequencer_StackOpDirective &directive)
Internal interface base-class function for directive_stackOp.
void directive_pushTlmVal_internalInterfaceInvoke(const Svc::FpySequencer_PushTlmValDirective &directive)
Internal interface base-class function for directive_pushTlmVal.
void directive_if_internalInterfaceInvoke(const Svc::FpySequencer_IfDirective &directive)
Internal interface base-class function for directive_if.
TimeBase getTimeBase() const
Definition: Time.cpp:126
Deserialization data had incorrect values (unexpected data types)
void directive_noOp_internalInterfaceInvoke(const Svc::FpySequencer_NoOpDirective &directive)
Internal interface base-class function for directive_noOp.
void directive_allocate_internalInterfaceInvoke(const Svc::FpySequencer_AllocateDirective &directive)
Internal interface base-class function for directive_allocate.
void directive_storeRelConstOffset_internalInterfaceInvoke(const Svc::FpySequencer_StoreRelConstOffsetDirective &directive)
Internal interface base-class function for directive_storeRelConstOffset.
void directive_pushTlmValAndTime_internalInterfaceInvoke(const Svc::FpySequencer_PushTlmValAndTimeDirective &directive)
Internal interface base-class function for directive_pushTlmValAndTime.
void directive_stackCmd_internalInterfaceInvoke(const Svc::FpySequencer_StackCmdDirective &directive)
Internal interface base-class function for directive_stackCmd.
void log_WARNING_HI_DirectiveDeserializeError(U8 opcode, U32 stmtIdx, I32 errorCode, U64 buffLeft, U64 buffLength) const
Log event DirectiveDeserializeError.
SerializeStatus
forward declaration for string
float F32
32-bit floating point
Definition: BasicTypes.h:84
void directive_popSerializable_internalInterfaceInvoke(const Svc::FpySequencer_PopSerializableDirective &directive)
Internal interface base-class function for directive_popSerializable.
void directive_loadAbs_internalInterfaceInvoke(const Svc::FpySequencer_LoadAbsDirective &directive)
Internal interface base-class function for directive_loadAbs.
called in dispatchStatement method when a statement was successfully dispatched
F32 paramGet_STATEMENT_TIMEOUT_SECS(Fw::ParamValid &valid)
void directive_memCmp_internalInterfaceInvoke(const Svc::FpySequencer_MemCmpDirective &directive)
Internal interface base-class function for directive_memCmp.
void directive_pushTime_internalInterfaceInvoke(const Svc::FpySequencer_PushTimeDirective &directive)
Internal interface base-class function for directive_pushTime.
Omit length from serialization.
Data was left in the buffer, but not enough to deserialize.
External serialize buffer with no copy semantics.
U32 getSeconds() const
Definition: Time.cpp:118
Type_of_statements & get_statements()
Get member statements.
void directive_waitAbs_internalInterfaceInvoke(const Svc::FpySequencer_WaitAbsDirective &directive)
Internal interface base-class function for directive_waitAbs.
void directive_peek_internalInterfaceInvoke(const Svc::FpySequencer_PeekDirective &directive)
Internal interface base-class function for directive_peek.
void log_WARNING_HI_CommandTimedOut(FwOpcodeType opCode, U32 stmtIdx, const Fw::StringBase &filePath) const
Log event CommandTimedOut.
Representing failure.
void directive_getField_internalInterfaceInvoke(const Svc::FpySequencer_GetFieldDirective &directive)
Internal interface base-class function for directive_getField.
void directive_discard_internalInterfaceInvoke(const Svc::FpySequencer_DiscardDirective &directive)
Internal interface base-class function for directive_discard.
void directive_pushPrm_internalInterfaceInvoke(const Svc::FpySequencer_PushPrmDirective &directive)
Internal interface base-class function for directive_pushPrm.
void directive_pushRand_internalInterfaceInvoke(const Svc::FpySequencer_PushRandDirective &directive)
Internal interface base-class function for directive_pushRand.
U32 getUSeconds() const
Definition: Time.cpp:122
void directive_setSeed_internalInterfaceInvoke(const Svc::FpySequencer_SetSeedDirective &directive)
Internal interface base-class function for directive_setSeed.
void directive_constCmd_internalInterfaceInvoke(const Svc::FpySequencer_ConstCmdDirective &directive)
Internal interface base-class function for directive_constCmd.
void directive_return_internalInterfaceInvoke(const Svc::FpySequencer_ReturnDirective &directive)
Internal interface base-class function for directive_return.
void log_WARNING_HI_UnknownSequencerDirective(U8 opcode, U32 stmtIdx, const Fw::StringBase &filePath) const
Log event UnknownSequencerDirective.
RateGroupDivider component implementation.
Enum representing parameter validity.
void directive_storeAbs_internalInterfaceInvoke(const Svc::FpySequencer_StoreAbsDirective &directive)
Internal interface base-class function for directive_storeAbs.
void log_WARNING_HI_MismatchedTimeBase(I32 internalTimeBase, I32 otherTimeBase) const
Log event MismatchedTimeBase.
void directive_call_internalInterfaceInvoke(const Svc::FpySequencer_CallDirective &directive)
Internal interface base-class function for directive_call.
void directive_exit_internalInterfaceInvoke(const Svc::FpySequencer_ExitDirective &directive)
Internal interface base-class function for directive_exit.
void directive_storeAbsConstOffset_internalInterfaceInvoke(const Svc::FpySequencer_StoreAbsConstOffsetDirective &directive)
Internal interface base-class function for directive_storeAbsConstOffset.
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
void directive_goto_internalInterfaceInvoke(const Svc::FpySequencer_GotoDirective &directive)
Internal interface base-class function for directive_goto.
void directive_waitRel_internalInterfaceInvoke(const Svc::FpySequencer_WaitRelDirective &directive)
Internal interface base-class function for directive_waitRel.
void directive_storeRel_internalInterfaceInvoke(const Svc::FpySequencer_StoreRelDirective &directive)
Internal interface base-class function for directive_storeRel.
void directive_loadRel_internalInterfaceInvoke(const Svc::FpySequencer_LoadRelDirective &directive)
Internal interface base-class function for directive_loadRel.
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
#define FW_ASSERT(...)
Definition: Assert.hpp:14
Success/Failure.
PlatformAssertArgType FwAssertArgType
The type of arguments to assert functions.
#define U64(C)
Definition: sha.h:181