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  argBuf.setBuffLen(stmt.get_argBuf().getSize());
62 
63  switch (stmt.get_opCode()) {
65  // in order to use a type with non trivial ctor in cpp union, have to manually construct and destruct it
66  new (&deserializedDirective.waitRel) FpySequencer_WaitRelDirective();
67  // wait rel does not need deser
68  if (argBuf.getDeserializeSizeLeft() != 0) {
69  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
71  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
72  return Fw::Success::FAILURE;
73  }
74  break;
75  }
77  new (&deserializedDirective.waitAbs) FpySequencer_WaitAbsDirective();
78  // wait abs does not need deser
79  if (argBuf.getDeserializeSizeLeft() != 0) {
80  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
82  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
83  return Fw::Success::FAILURE;
84  }
85  break;
86  }
88  new (&deserializedDirective.gotoDirective) FpySequencer_GotoDirective();
89  status = argBuf.deserializeTo(deserializedDirective.gotoDirective);
90  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
91  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
92  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
93  return Fw::Success::FAILURE;
94  }
95  break;
96  }
97  case Fpy::DirectiveId::IF: {
98  new (&deserializedDirective.ifDirective) FpySequencer_IfDirective();
99  status = argBuf.deserializeTo(deserializedDirective.ifDirective);
100  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
101  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
102  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
103  return Fw::Success::FAILURE;
104  }
105  break;
106  }
108  new (&deserializedDirective.noOp) FpySequencer_NoOpDirective();
109  // no op does not need deser
110  if (argBuf.getDeserializeSizeLeft() != 0) {
111  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
113  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
114  return Fw::Success::FAILURE;
115  }
116  break;
117  }
119  new (&deserializedDirective.pushTlmVal) FpySequencer_PushTlmValDirective();
120  status = argBuf.deserializeTo(deserializedDirective.pushTlmVal);
121  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
122  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
123  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
124  return Fw::Success::FAILURE;
125  }
126  break;
127  }
129  new (&deserializedDirective.pushTlmValAndTime) FpySequencer_PushTlmValAndTimeDirective();
130  status = argBuf.deserializeTo(deserializedDirective.pushTlmValAndTime);
131  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
132  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
133  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
134  return Fw::Success::FAILURE;
135  }
136  break;
137  }
139  new (&deserializedDirective.pushPrm) FpySequencer_PushPrmDirective();
140  status = argBuf.deserializeTo(deserializedDirective.pushPrm);
141  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
142  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
143  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
144  return Fw::Success::FAILURE;
145  }
146  break;
147  }
149  new (&deserializedDirective.constCmd) FpySequencer_ConstCmdDirective();
150 
151  // first deserialize the opcode
152  FwOpcodeType opcode;
153  status = argBuf.deserializeTo(opcode);
154  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) {
155  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
156  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
157  return Fw::Success::FAILURE;
158  }
159 
160  deserializedDirective.constCmd.set_opCode(opcode);
161  // how many bytes are left?
162  FwSizeType cmdArgBufSize = argBuf.getDeserializeSizeLeft();
163 
164  // check to make sure the value will fit in the FpySequencer_ConstCmdDirective::argBuf
165  if (cmdArgBufSize > Fpy::MAX_DIRECTIVE_SIZE) {
166  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
168  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
169  return Fw::Success::FAILURE;
170  }
171 
172  // okay, it will fit. put it in
173  status = argBuf.deserializeTo(deserializedDirective.constCmd.get_argBuf(), cmdArgBufSize,
175 
176  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) {
177  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
178  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
179  return Fw::Success::FAILURE;
180  }
181 
182  // now there should be nothing left, otherwise coding err
183  FW_ASSERT(argBuf.getDeserializeSizeLeft() == 0,
184  static_cast<FwAssertArgType>(argBuf.getDeserializeSizeLeft()));
185 
186  // and set the buf size now that we know it
187  deserializedDirective.constCmd.set__argBufSize(cmdArgBufSize);
188  break;
189  }
190  // fallthrough on purpose
239  new (&deserializedDirective.stackOp) FpySequencer_StackOpDirective();
240  if (argBuf.getDeserializeSizeLeft() != 0) {
241  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
243  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
244  return Fw::Success::FAILURE;
245  }
246  deserializedDirective.stackOp.set__op(stmt.get_opCode());
247  break;
248  }
249  case Fpy::DirectiveId::EXIT: {
250  new (&deserializedDirective.exit) FpySequencer_ExitDirective();
251  if (argBuf.getDeserializeSizeLeft() != 0) {
252  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
254  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
255  return Fw::Success::FAILURE;
256  }
257  break;
258  }
260  new (&deserializedDirective.allocate) FpySequencer_AllocateDirective();
261  status = argBuf.deserializeTo(deserializedDirective.allocate);
262  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
263  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
264  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
265  return Fw::Success::FAILURE;
266  }
267  break;
268  }
270  new (&deserializedDirective.storeRelConstOffset) FpySequencer_StoreRelConstOffsetDirective();
271  status = argBuf.deserializeTo(deserializedDirective.storeRelConstOffset);
272  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
273  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
274  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
275  return Fw::Success::FAILURE;
276  }
277  break;
278  }
280  new (&deserializedDirective.loadRel) FpySequencer_LoadRelDirective();
281  status = argBuf.deserializeTo(deserializedDirective.loadRel);
282  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
283  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
284  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
285  return Fw::Success::FAILURE;
286  }
287  break;
288  }
290  new (&deserializedDirective.pushVal) FpySequencer_PushValDirective();
291 
292  // how many bytes are left?
293  FwSizeType bufSize = argBuf.getDeserializeSizeLeft();
294 
295  // check to make sure the value will fit in the FpySequencer_PushValDirective::val buf
296  if (bufSize > Fpy::MAX_DIRECTIVE_SIZE) {
297  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
299  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
300  return Fw::Success::FAILURE;
301  }
302 
303  // okay, it will fit. put it in
304  status =
305  argBuf.deserializeTo(deserializedDirective.pushVal.get_val(), bufSize, Fw::Serialization::OMIT_LENGTH);
306 
307  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK) {
308  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
309  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
310  return Fw::Success::FAILURE;
311  }
312 
313  // now there should be nothing left, otherwise coding err
314  FW_ASSERT(argBuf.getDeserializeSizeLeft() == 0,
315  static_cast<FwAssertArgType>(argBuf.getDeserializeSizeLeft()));
316 
317  // and set the buf size now that we know it
318  deserializedDirective.pushVal.set__valSize(bufSize);
319  break;
320  }
322  new (&deserializedDirective.discard) FpySequencer_DiscardDirective();
323  status = argBuf.deserializeTo(deserializedDirective.discard);
324  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
325  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
326  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
327  return Fw::Success::FAILURE;
328  }
329  break;
330  }
332  new (&deserializedDirective.memCmp) FpySequencer_MemCmpDirective();
333  status = argBuf.deserializeTo(deserializedDirective.memCmp);
334  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
335  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
336  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
337  return Fw::Success::FAILURE;
338  }
339  break;
340  }
342  new (&deserializedDirective.stackCmd) FpySequencer_StackCmdDirective();
343  status = argBuf.deserializeTo(deserializedDirective.stackCmd);
344  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
345  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
346  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
347  return Fw::Success::FAILURE;
348  }
349  break;
350  }
352  new (&deserializedDirective.pushTime) FpySequencer_PushTimeDirective();
353  if (argBuf.getDeserializeSizeLeft() != 0) {
354  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
356  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
357  return Fw::Success::FAILURE;
358  }
359  break;
360  }
362  new (&deserializedDirective.getField) FpySequencer_GetFieldDirective();
363  status = argBuf.deserializeTo(deserializedDirective.getField);
364  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
365  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
366  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
367  return Fw::Success::FAILURE;
368  }
369  break;
370  }
371  case Fpy::DirectiveId::PEEK: {
372  new (&deserializedDirective.peek) FpySequencer_PeekDirective();
373  if (argBuf.getDeserializeSizeLeft() != 0) {
374  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
376  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
377  return Fw::Success::FAILURE;
378  }
379  break;
380  }
382  new (&deserializedDirective.storeRel) FpySequencer_StoreRelDirective();
383  status = argBuf.deserializeTo(deserializedDirective.storeRel);
384  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
385  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
386  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
387  return Fw::Success::FAILURE;
388  }
389  break;
390  }
391  case Fpy::DirectiveId::CALL: {
392  new (&deserializedDirective.call) FpySequencer_CallDirective();
393  if (argBuf.getDeserializeSizeLeft() != 0) {
394  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
396  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
397  return Fw::Success::FAILURE;
398  }
399  break;
400  }
402  new (&deserializedDirective.returnDirective) FpySequencer_ReturnDirective();
403  status = argBuf.deserializeTo(deserializedDirective.returnDirective);
404  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
405  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
406  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
407  return Fw::Success::FAILURE;
408  }
409  break;
410  }
412  new (&deserializedDirective.loadAbs) FpySequencer_LoadAbsDirective();
413  status = argBuf.deserializeTo(deserializedDirective.loadAbs);
414  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
415  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
416  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
417  return Fw::Success::FAILURE;
418  }
419  break;
420  }
422  new (&deserializedDirective.storeAbs) FpySequencer_StoreAbsDirective();
423  status = argBuf.deserializeTo(deserializedDirective.storeAbs);
424  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
425  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
426  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
427  return Fw::Success::FAILURE;
428  }
429  break;
430  }
432  new (&deserializedDirective.storeAbsConstOffset) FpySequencer_StoreAbsConstOffsetDirective();
433  status = argBuf.deserializeTo(deserializedDirective.storeAbsConstOffset);
434  if (status != Fw::SerializeStatus::FW_SERIALIZE_OK || argBuf.getDeserializeSizeLeft() != 0) {
435  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(), status,
436  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
437  return Fw::Success::FAILURE;
438  }
439  break;
440  }
442  new (&deserializedDirective.popEvent) FpySequencer_PopEventDirective();
443  // pop event has no hardcoded args
444  if (argBuf.getDeserializeSizeLeft() != 0) {
445  this->log_WARNING_HI_DirectiveDeserializeError(stmt.get_opCode(), this->currentStatementIdx(),
447  argBuf.getDeserializeSizeLeft(), argBuf.getSize());
448  return Fw::Success::FAILURE;
449  }
450  break;
451  }
452  default: {
453  // unsure what this opcode is. check compiler version matches sequencer
454  this->log_WARNING_HI_UnknownSequencerDirective(stmt.get_opCode(), this->currentStatementIdx(),
455  this->m_sequenceFilePath);
456  return Fw::Success::FAILURE;
457  }
458  }
459  return Fw::Success::SUCCESS;
460 }
461 
462 // dispatches a deserialized sequencer directive to the right handler.
463 void FpySequencer::dispatchDirective(const DirectiveUnion& directive, const Fpy::DirectiveId& id) {
464  switch (id) {
466  // coding err
467  FW_ASSERT(0);
468  return;
469  }
471  this->directive_waitRel_internalInterfaceInvoke(directive.waitRel);
472  return;
473  }
475  this->directive_waitAbs_internalInterfaceInvoke(directive.waitAbs);
476  return;
477  }
478  case Fpy::DirectiveId::GOTO: {
479  this->directive_goto_internalInterfaceInvoke(directive.gotoDirective);
480  return;
481  }
482  case Fpy::DirectiveId::IF: {
483  this->directive_if_internalInterfaceInvoke(directive.ifDirective);
484  return;
485  }
487  this->directive_noOp_internalInterfaceInvoke(directive.noOp);
488  return;
489  }
491  this->directive_pushTlmVal_internalInterfaceInvoke(directive.pushTlmVal);
492  return;
493  }
495  this->directive_pushTlmValAndTime_internalInterfaceInvoke(directive.pushTlmValAndTime);
496  return;
497  }
499  this->directive_pushPrm_internalInterfaceInvoke(directive.pushPrm);
500  return;
501  }
503  this->directive_constCmd_internalInterfaceInvoke(directive.constCmd);
504  return;
505  }
506  // fallthrough on purpose
555  this->directive_stackOp_internalInterfaceInvoke(directive.stackOp);
556  return;
557  }
558  case Fpy::DirectiveId::EXIT: {
559  this->directive_exit_internalInterfaceInvoke(directive.exit);
560  return;
561  }
563  this->directive_allocate_internalInterfaceInvoke(directive.allocate);
564  return;
565  }
567  this->directive_storeRelConstOffset_internalInterfaceInvoke(directive.storeRelConstOffset);
568  return;
569  }
571  this->directive_loadRel_internalInterfaceInvoke(directive.loadRel);
572  return;
573  }
575  this->directive_pushVal_internalInterfaceInvoke(directive.pushVal);
576  return;
577  }
579  this->directive_discard_internalInterfaceInvoke(directive.discard);
580  return;
581  }
583  this->directive_memCmp_internalInterfaceInvoke(directive.memCmp);
584  return;
585  }
587  this->directive_stackCmd_internalInterfaceInvoke(directive.stackCmd);
588  return;
589  }
591  this->directive_pushTime_internalInterfaceInvoke(directive.pushTime);
592  return;
593  }
595  this->directive_getField_internalInterfaceInvoke(directive.getField);
596  return;
597  }
598  case Fpy::DirectiveId::PEEK: {
599  this->directive_peek_internalInterfaceInvoke(directive.peek);
600  return;
601  }
603  this->directive_storeRel_internalInterfaceInvoke(directive.storeRel);
604  return;
605  }
606  case Fpy::DirectiveId::CALL: {
607  this->directive_call_internalInterfaceInvoke(directive.call);
608  return;
609  }
611  this->directive_return_internalInterfaceInvoke(directive.returnDirective);
612  return;
613  }
615  this->directive_loadAbs_internalInterfaceInvoke(directive.loadAbs);
616  return;
617  }
619  this->directive_storeAbs_internalInterfaceInvoke(directive.storeAbs);
620  return;
621  }
623  this->directive_storeAbsConstOffset_internalInterfaceInvoke(directive.storeAbsConstOffset);
624  return;
625  }
627  this->directive_popEvent_internalInterfaceInvoke(directive.popEvent);
628  return;
629  }
630  }
631  // coding err
632  FW_ASSERT(0, static_cast<FwAssertArgType>(id));
633 }
634 
635 Signal FpySequencer::checkShouldWake() {
636  Fw::Time currentTime = this->getTime();
637 
638  if (currentTime.getTimeBase() != this->m_runtime.wakeupTime.getTimeBase()) {
639  // cannot compare these times.
640  this->log_WARNING_HI_MismatchedTimeBase(currentTime.getTimeBase(), this->m_runtime.wakeupTime.getTimeBase());
641 
643  }
644 
645  // Do not compare time context
646 
647  if (currentTime < this->m_runtime.wakeupTime) {
648  // not time to wake up!
650  }
651 
652  // say we've finished our sleep
654 }
655 
656 // checks whether the currently executing statement timed out
657 Signal FpySequencer::checkStatementTimeout() {
658  Fw::ParamValid valid;
659  F32 timeout = this->paramGet_STATEMENT_TIMEOUT_SECS(valid);
660  if (timeout <= 0 || timeout > static_cast<F32>(std::numeric_limits<U32>::max())) {
661  // no timeout
663  }
664 
665  Fw::Time currentTime = getTime();
666 
667  if (currentTime.getTimeBase() != this->m_runtime.currentStatementDispatchTime.getTimeBase()) {
668  // can't compare time base. must have changed
670  this->m_runtime.currentStatementDispatchTime.getTimeBase());
672  }
673 
674  // Do not compare time context
675 
676  if (this->m_runtime.currentStatementDispatchTime.getSeconds() > currentTime.getSeconds()) {
677  // somehow we've gone back in time... just ignore it and move on. should get fixed
678  // if we wait I guess
680  }
681 
682  if (this->m_runtime.currentStatementDispatchTime.getSeconds() == currentTime.getSeconds() &&
683  this->m_runtime.currentStatementDispatchTime.getUSeconds() > currentTime.getUSeconds()) {
684  // same as above
686  }
687 
688  U64 currentUSeconds = currentTime.getSeconds() * 1000000 + currentTime.getUSeconds();
689  U64 dispatchUSeconds = this->m_runtime.currentStatementDispatchTime.getSeconds() * 1000000 +
690  this->m_runtime.currentStatementDispatchTime.getUSeconds();
691 
692  U64 timeoutUSeconds = static_cast<U64>(timeout * 1000000.0f);
693 
694  if (currentUSeconds - dispatchUSeconds < timeoutUSeconds) {
695  // not over timeout
697  }
698 
699  // we timed out
700  if (this->m_runtime.currentStatementOpcode == Fpy::DirectiveId::CONST_CMD ||
701  this->m_runtime.currentStatementOpcode == Fpy::DirectiveId::STACK_CMD) {
702  // if we were executing a command, warn that the cmd timed out with its opcode
703  this->log_WARNING_HI_CommandTimedOut(this->m_runtime.currentCmdOpcode, this->currentStatementIdx(),
704  this->m_sequenceFilePath);
705  } else {
706  this->log_WARNING_HI_DirectiveTimedOut(this->m_runtime.currentStatementOpcode, this->currentStatementIdx(),
707  this->m_sequenceFilePath);
708  }
709 
711 }
712 
713 } // 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:83
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.
U32 getUSeconds() const
Definition: Time.cpp:122
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