11 void FpySequencer::sendSignal(
Signal signal) {
30 FW_ASSERT(
false, static_cast<FwAssertArgType>(signal));
36 void FpySequencer::handleDirectiveErrorCode(Fpy::DirectiveId
id,
DirectiveError err) {
37 this->m_tlm.lastDirectiveError = err;
39 this->m_tlm.directiveErrorIndex = this->currentStatementIdx();
40 this->m_tlm.directiveErrorId = id;
47 cmdBuf.
serializeFrom(static_cast<FwPacketDescriptorType>(Fw::ComPacketType::FW_PACKET_COMMAND));
70 static_cast<U32
>(((this->m_sequencesStarted & 0xFFFF) << 16) | (this->m_statementsDispatched & 0xFFFF));
80 this->sendSignal(this->waitRel_directiveHandler(directive, error));
87 this->sendSignal(this->waitAbs_directiveHandler(directive, error));
94 this->sendSignal(this->goto_directiveHandler(directive, error));
101 this->sendSignal(this->if_directiveHandler(directive, error));
108 this->sendSignal(this->noOp_directiveHandler(directive, error));
116 this->sendSignal(this->pushTlmVal_directiveHandler(directive, error));
124 this->sendSignal(this->pushTlmValAndTime_directiveHandler(directive, error));
131 this->sendSignal(this->pushPrm_directiveHandler(directive, error));
138 this->sendSignal(this->constCmd_directiveHandler(directive, error));
145 this->sendSignal(this->stackOp_directiveHandler(directive, error));
146 handleDirectiveErrorCode(directive.
get__op(), error);
152 this->sendSignal(this->exit_directiveHandler(directive, error));
159 this->sendSignal(this->allocate_directiveHandler(directive, error));
167 this->sendSignal(this->storeRelConstOffset_directiveHandler(directive, error));
174 this->sendSignal(this->pushVal_directiveHandler(directive, error));
181 this->sendSignal(this->loadRel_directiveHandler(directive, error));
188 this->sendSignal(this->discard_directiveHandler(directive, error));
195 this->sendSignal(this->memCmp_directiveHandler(directive, error));
202 this->sendSignal(this->stackCmd_directiveHandler(directive, error));
209 this->sendSignal(this->pushTime_directiveHandler(directive, error));
216 this->sendSignal(this->setSeed_directiveHandler(directive, error));
223 this->sendSignal(this->pushRand_directiveHandler(directive, error));
230 this->sendSignal(this->getField_directiveHandler(directive, error));
237 this->sendSignal(this->peek_directiveHandler(directive, error));
244 this->sendSignal(this->storeRel_directiveHandler(directive, error));
251 this->sendSignal(this->call_directiveHandler(directive, error));
258 this->sendSignal(this->return_directiveHandler(directive, error));
265 this->sendSignal(this->loadAbs_directiveHandler(directive, error));
272 this->sendSignal(this->storeAbs_directiveHandler(directive, error));
280 this->sendSignal(this->storeAbsConstOffset_directiveHandler(directive, error));
287 this->sendSignal(this->popEvent_directiveHandler(directive, error));
295 this->sendSignal(this->popSerializable_directiveHandler(directive, error));
301 if (this->m_runtime.stack.size < 8) {
308 U32 uSeconds = this->m_runtime.stack.pop<U32>();
309 U32 seconds = this->m_runtime.stack.pop<U32>();
311 wakeupTime.
add(seconds, uSeconds);
312 this->m_runtime.wakeupTime = wakeupTime;
317 Signal FpySequencer::waitAbs_directiveHandler(
const FpySequencer_WaitAbsDirective& directive,
DirectiveError& error) {
323 U32 uSeconds = this->m_runtime.stack.pop<U32>();
324 U32 seconds = this->m_runtime.stack.pop<U32>();
328 this->m_runtime.wakeupTime =
Fw::Time(static_cast<TimeBase::T>(base), ctx, seconds, uSeconds);
333 Signal FpySequencer::goto_directiveHandler(
const FpySequencer_GotoDirective& directive,
DirectiveError& error) {
339 m_runtime.nextStatementIndex = directive.get_statementIndex();
344 Signal FpySequencer::if_directiveHandler(
const FpySequencer_IfDirective& directive,
DirectiveError& error) {
345 if (this->m_runtime.stack.size < 1) {
355 if (this->m_runtime.stack.pop<
U8>() != 0) {
361 this->m_runtime.nextStatementIndex = directive.get_falseGotoStmtIndex();
365 Signal FpySequencer::noOp_directiveHandler(
const FpySequencer_NoOpDirective& directive,
DirectiveError& error) {
369 Signal FpySequencer::pushTlmVal_directiveHandler(
const FpySequencer_PushTlmValDirective& directive,
393 Signal FpySequencer::pushTlmValAndTime_directiveHandler(
const FpySequencer_PushTlmValAndTimeDirective& directive,
426 this->m_runtime.stack.push(timeEsb.getBuffAddr(),
static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
430 Signal FpySequencer::pushPrm_directiveHandler(
const FpySequencer_PushPrmDirective& directive,
DirectiveError& error) {
454 Signal FpySequencer::constCmd_directiveHandler(
const FpySequencer_ConstCmdDirective& directive,
DirectiveError& error) {
461 if (this->sendCmd(directive.get_opCode(), directive.get_argBuf(), directive.get__argBufSize()) ==
472 if (this->m_runtime.stack.size <
sizeof(
U8) * 2) {
475 this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<
U8>() | this->m_runtime.stack.pop<
U8>()));
479 if (this->m_runtime.stack.size <
sizeof(
U8) * 2) {
482 this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<
U8>() & this->m_runtime.stack.pop<
U8>()));
486 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
489 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>())
495 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
498 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>())
504 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
507 U64 rhs = this->m_runtime.stack.pop<U64>();
508 U64 lhs = this->m_runtime.stack.pop<U64>();
514 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
517 U64 rhs = this->m_runtime.stack.pop<U64>();
518 U64 lhs = this->m_runtime.stack.pop<U64>();
524 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
527 U64 rhs = this->m_runtime.stack.pop<U64>();
528 U64 lhs = this->m_runtime.stack.pop<U64>();
534 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
537 U64 rhs = this->m_runtime.stack.pop<U64>();
538 U64 lhs = this->m_runtime.stack.pop<U64>();
544 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
547 I64 rhs = this->m_runtime.stack.pop<I64>();
548 I64 lhs = this->m_runtime.stack.pop<I64>();
554 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
557 I64 rhs = this->m_runtime.stack.pop<I64>();
558 I64 lhs = this->m_runtime.stack.pop<I64>();
564 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
567 I64 rhs = this->m_runtime.stack.pop<I64>();
568 I64 lhs = this->m_runtime.stack.pop<I64>();
574 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
577 I64 rhs = this->m_runtime.stack.pop<I64>();
578 I64 lhs = this->m_runtime.stack.pop<I64>();
584 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
587 F64 rhs = this->m_runtime.stack.pop<
F64>();
588 F64 lhs = this->m_runtime.stack.pop<
F64>();
595 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
598 F64 rhs = this->m_runtime.stack.pop<
F64>();
599 F64 lhs = this->m_runtime.stack.pop<
F64>();
606 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
609 F64 rhs = this->m_runtime.stack.pop<
F64>();
610 F64 lhs = this->m_runtime.stack.pop<
F64>();
616 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
619 F64 rhs = this->m_runtime.stack.pop<
F64>();
620 F64 lhs = this->m_runtime.stack.pop<
F64>();
621 this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs) ? static_cast<U8>(
FW_SERIALIZE_TRUE_VALUE)
626 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
629 F64 rhs = this->m_runtime.stack.pop<
F64>();
630 F64 lhs = this->m_runtime.stack.pop<
F64>();
636 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
639 F64 rhs = this->m_runtime.stack.pop<
F64>();
640 F64 lhs = this->m_runtime.stack.pop<
F64>();
641 this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)
647 if (this->m_runtime.stack.size <
sizeof(
U8)) {
650 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<
U8>() == 0)
657 if (this->m_runtime.stack.size <
sizeof(
F32)) {
660 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<
F32>()));
665 if (this->m_runtime.stack.size <
sizeof(
F64)) {
668 this->m_runtime.stack.push(static_cast<F32>(this->m_runtime.stack.pop<
F64>()));
672 if (this->m_runtime.stack.size <
sizeof(
F64)) {
675 F64 val = this->m_runtime.stack.pop<
F64>();
680 const F64 bound = std::ldexp(1.0, 63);
682 if (std::isnan(val)) {
684 }
else if (val >= bound) {
685 result = std::numeric_limits<I64>::max();
686 }
else if (val < -bound) {
689 result =
static_cast<I64
>(val);
691 this->m_runtime.stack.push(result);
695 if (this->m_runtime.stack.size <
sizeof(I64)) {
698 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<I64>()));
702 if (this->m_runtime.stack.size <
sizeof(
F64)) {
705 F64 val = this->m_runtime.stack.pop<
F64>();
709 const F64 bound = std::ldexp(1.0, 64);
711 if (std::isnan(val) || val < 0.0) {
713 }
else if (val >= bound) {
714 result = std::numeric_limits<U64>::max();
716 result =
static_cast<U64
>(val);
718 this->m_runtime.stack.push(result);
722 if (this->m_runtime.stack.size <
sizeof(U64)) {
725 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<U64>()));
729 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
732 I64 rhs = this->m_runtime.stack.pop<I64>();
733 I64 lhs = this->m_runtime.stack.pop<I64>();
737 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() - rhs) < lhs)) {
745 this->m_runtime.stack.push(static_cast<I64>(lhs + rhs));
749 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
752 I64 rhs = this->m_runtime.stack.pop<I64>();
753 I64 lhs = this->m_runtime.stack.pop<I64>();
758 if ((rhs < 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() + rhs) < lhs)) {
767 this->m_runtime.stack.push(static_cast<I64>(lhs - rhs));
771 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
774 I64 rhs = this->m_runtime.stack.pop<I64>();
775 I64 lhs = this->m_runtime.stack.pop<I64>();
780 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() / rhs) < lhs)) {
784 else if ((rhs < 0) && (lhs < 0) && (lhs < (std::numeric_limits<I64>::max() / rhs))) {
797 this->m_runtime.stack.push(static_cast<I64>(lhs * rhs));
801 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
804 U64 rhs = this->m_runtime.stack.pop<U64>();
805 U64 lhs = this->m_runtime.stack.pop<U64>();
810 this->m_runtime.stack.push(static_cast<U64>(lhs / rhs));
814 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
818 I64 rhs = this->m_runtime.stack.pop<I64>();
819 I64 lhs = this->m_runtime.stack.pop<I64>();
832 I64 quotient = lhs / rhs;
833 if (((lhs % rhs) != 0) && ((lhs < 0) != (rhs < 0))) {
836 this->m_runtime.stack.push(quotient);
840 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
843 U64 rhs = this->m_runtime.stack.pop<U64>();
847 U64 lhs = this->m_runtime.stack.pop<U64>();
848 this->m_runtime.stack.push(static_cast<U64>(lhs % rhs));
852 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
855 I64 rhs = this->m_runtime.stack.pop<I64>();
859 I64 lhs = this->m_runtime.stack.pop<I64>();
863 this->m_runtime.stack.push(static_cast<I64>(0));
866 I64 res =
static_cast<I64
>(lhs % rhs);
871 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
874 this->m_runtime.stack.push(res);
878 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
881 F64 rhs = this->m_runtime.stack.pop<
F64>();
882 F64 lhs = this->m_runtime.stack.pop<
F64>();
883 this->m_runtime.stack.push(static_cast<F64>(lhs + rhs));
887 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
890 F64 rhs = this->m_runtime.stack.pop<
F64>();
891 F64 lhs = this->m_runtime.stack.pop<
F64>();
892 this->m_runtime.stack.push(static_cast<F64>(lhs - rhs));
896 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
899 F64 rhs = this->m_runtime.stack.pop<
F64>();
900 F64 lhs = this->m_runtime.stack.pop<
F64>();
901 this->m_runtime.stack.push(static_cast<F64>(lhs * rhs));
905 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
908 F64 rhs = this->m_runtime.stack.pop<
F64>();
909 F64 lhs = this->m_runtime.stack.pop<
F64>();
910 this->m_runtime.stack.push(static_cast<F64>(lhs / rhs));
914 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
917 F64 rhs = this->m_runtime.stack.pop<
F64>();
918 F64 lhs = this->m_runtime.stack.pop<
F64>();
919 this->m_runtime.stack.push(static_cast<F64>(pow(lhs, rhs)));
923 if (this->m_runtime.stack.size <
sizeof(
F64)) {
926 F64 val = this->m_runtime.stack.pop<
F64>();
930 this->m_runtime.stack.push(static_cast<F64>(log(val)));
934 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
937 F64 rhs = this->m_runtime.stack.pop<
F64>();
938 F64 lhs = this->m_runtime.stack.pop<
F64>();
941 F64 res = std::fmod(lhs, rhs);
945 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
947 }
else if (res == 0) {
950 res = std::copysign(0.0, rhs);
952 this->m_runtime.stack.push(res);
956 if (this->m_runtime.stack.size <
sizeof(
I8)) {
959 I8 src = this->m_runtime.stack.pop<
I8>();
960 this->m_runtime.stack.push(static_cast<I64>(src));
964 if (this->m_runtime.stack.size <
sizeof(I16)) {
967 I16 src = this->m_runtime.stack.pop<I16>();
968 this->m_runtime.stack.push(static_cast<I64>(src));
972 if (this->m_runtime.stack.size <
sizeof(I32)) {
975 I32 src = this->m_runtime.stack.pop<I32>();
976 this->m_runtime.stack.push(static_cast<I64>(src));
980 if (this->m_runtime.stack.size <
sizeof(
U8)) {
983 U8 src = this->m_runtime.stack.pop<
U8>();
984 this->m_runtime.stack.push(static_cast<U64>(src));
988 if (this->m_runtime.stack.size <
sizeof(U16)) {
991 U16 src = this->m_runtime.stack.pop<U16>();
992 this->m_runtime.stack.push(static_cast<U64>(src));
996 if (this->m_runtime.stack.size <
sizeof(U32)) {
999 U32 src = this->m_runtime.stack.pop<U32>();
1000 this->m_runtime.stack.push(static_cast<U64>(src));
1004 if (this->m_runtime.stack.size <
sizeof(U64)) {
1007 U64 src = this->m_runtime.stack.pop<U64>();
1008 this->m_runtime.stack.push(static_cast<U8>(src));
1012 if (this->m_runtime.stack.size <
sizeof(U64)) {
1015 U64 src = this->m_runtime.stack.pop<U64>();
1016 this->m_runtime.stack.push(static_cast<U16>(src));
1020 if (this->m_runtime.stack.size <
sizeof(U64)) {
1023 U64 src = this->m_runtime.stack.pop<U64>();
1024 this->m_runtime.stack.push(static_cast<U32>(src));
1028 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1031 F64 val = this->m_runtime.stack.pop<
F64>();
1034 this->m_runtime.stack.push(std::floor(val));
1038 if (this->m_runtime.stack.size <
sizeof(I64)) {
1041 I64 val = this->m_runtime.stack.pop<I64>();
1046 this->m_runtime.stack.push(val < 0 ? -val : val);
1050 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1053 F64 val = this->m_runtime.stack.pop<
F64>();
1056 this->m_runtime.stack.push(std::fabs(val));
1059 Signal FpySequencer::stackOp_directiveHandler(
const FpySequencer_StackOpDirective& directive,
DirectiveError& error) {
1063 static_cast<FwAssertArgType>(directive.get__op()));
1065 switch (directive.get__op()) {
1067 error = this->op_or();
1070 error = this->op_and();
1073 error = this->op_ieq();
1076 error = this->op_ine();
1079 error = this->op_ult();
1082 error = this->op_ule();
1085 error = this->op_ugt();
1088 error = this->op_uge();
1091 error = this->op_slt();
1094 error = this->op_sle();
1097 error = this->op_sgt();
1100 error = this->op_sge();
1103 error = this->op_feq();
1106 error = this->op_fne();
1109 error = this->op_flt();
1112 error = this->op_fle();
1115 error = this->op_fgt();
1118 error = this->op_fge();
1121 error = this->op_not();
1124 error = this->op_fpext();
1127 error = this->op_fptrunc();
1130 error = this->op_fptosi();
1133 error = this->op_fptoui();
1136 error = this->op_sitofp();
1139 error = this->op_uitofp();
1142 error = this->op_add();
1145 error = this->op_sub();
1148 error = this->op_mul();
1151 error = this->op_udiv();
1154 error = this->op_sdiv();
1157 error = this->op_umod();
1160 error = this->op_smod();
1163 error = this->op_fadd();
1166 error = this->op_fsub();
1169 error = this->op_fmul();
1172 error = this->op_fdiv();
1175 error = this->op_fpow();
1178 error = this->op_flog();
1181 error = this->op_fmod();
1184 error = this->op_siext_8_64();
1187 error = this->op_siext_16_64();
1190 error = this->op_siext_32_64();
1193 error = this->op_ziext_8_64();
1196 error = this->op_ziext_16_64();
1199 error = this->op_ziext_32_64();
1202 error = this->op_itrunc_64_8();
1205 error = this->op_itrunc_64_16();
1208 error = this->op_itrunc_64_32();
1211 error = this->op_ffloor();
1214 error = this->op_iabs();
1217 error = this->op_fabs();
1229 Signal FpySequencer::exit_directiveHandler(
const FpySequencer_ExitDirective& directive,
DirectiveError& error) {
1230 if (this->m_runtime.stack.size <
sizeof(I32)) {
1234 I32 errorCode = this->m_runtime.stack.pop<I32>();
1236 if (errorCode == 0) {
1248 Signal FpySequencer::allocate_directiveHandler(
const FpySequencer_AllocateDirective& directive,
DirectiveError& error) {
1253 this->m_runtime.stack.pushZeroes(directive.get_size());
1259 if (this->m_runtime.stack.size < size) {
1267 if (destOffset > newStackSize || size > newStackSize - destOffset) {
1272 this->m_runtime.stack.copy(destOffset, this->m_runtime.stack.size - size, size);
1273 this->m_runtime.stack.size = newStackSize;
1285 if (srcOffset > this->m_runtime.stack.size || size > this->m_runtime.stack.size - srcOffset) {
1290 this->m_runtime.stack.copy(this->m_runtime.stack.size, srcOffset, size);
1291 this->m_runtime.stack.size += size;
1295 Signal FpySequencer::storeRelConstOffset_directiveHandler(
const FpySequencer_StoreRelConstOffsetDirective& directive,
1297 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1302 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1305 Signal FpySequencer::loadRel_directiveHandler(
const FpySequencer_LoadRelDirective& directive,
DirectiveError& error) {
1306 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1311 return this->loadHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1314 Signal FpySequencer::pushVal_directiveHandler(
const FpySequencer_PushValDirective& directive,
DirectiveError& error) {
1320 this->m_runtime.stack.push(const_cast<U8*>(directive.get_val()),
1321 static_cast<Fpy::StackSizeType>(directive.get__valSize()));
1325 Signal FpySequencer::discard_directiveHandler(
const FpySequencer_DiscardDirective& directive,
DirectiveError& error) {
1326 if (this->m_runtime.stack.size < directive.get_size()) {
1331 this->m_runtime.stack.size -= directive.get_size();
1335 Signal FpySequencer::memCmp_directiveHandler(
const FpySequencer_MemCmpDirective& directive,
DirectiveError& error) {
1344 if (this->m_runtime.stack.size < directive.get_size() * 2) {
1350 U64 lhsOffset = this->m_runtime.stack.size - directive.get_size() * 2;
1351 U64 rhsOffset = this->m_runtime.stack.size - directive.get_size();
1356 this->m_runtime.stack.size -= directive.get_size() * 2;
1359 if (memcmp(this->m_runtime.stack.bytes + lhsOffset, this->m_runtime.stack.bytes + rhsOffset,
1360 directive.get_size()) == 0) {
1368 Signal FpySequencer::stackCmd_directiveHandler(
const FpySequencer_StackCmdDirective& directive,
DirectiveError& error) {
1371 if (this->m_runtime.stack.size <
sizeof(
FwOpcodeType) ||
1372 this->m_runtime.stack.size -
sizeof(
FwOpcodeType) < directive.get_argsSize()) {
1381 U64 argBufOffset = this->m_runtime.stack.size - directive.get_argsSize();
1384 this->m_runtime.currentCmdOpcode = opcode;
1387 this->m_runtime.stack.size -= directive.get_argsSize();
1397 if (this->sendCmd(opcode, this->m_runtime.stack.bytes + argBufOffset, directive.get_argsSize()) ==
1409 Signal FpySequencer::pushTime_directiveHandler(
const FpySequencer_PushTimeDirective& directive,
DirectiveError& error) {
1425 this->m_runtime.stack.push(timeEsb.getBuffAddr(),
static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
1429 Signal FpySequencer::setSeed_directiveHandler(
const FpySequencer_SetSeedDirective& directive,
DirectiveError& error) {
1430 if (this->m_runtime.stack.size <
sizeof(U32)) {
1435 U32 seed = this->m_runtime.stack.pop<U32>();
1436 this->m_runtime.rng.seed(seed);
1437 this->m_runtime.rngSeeded =
true;
1441 Signal FpySequencer::pushRand_directiveHandler(
const FpySequencer_PushRandDirective& directive,
DirectiveError& error) {
1447 if (!this->m_runtime.rngSeeded) {
1449 std::seed_seq seedSeq{
static_cast<U32
>(currentTime.
getTimeBase()), static_cast<U32>(currentTime.
getContext()),
1451 this->m_runtime.rng.seed(seedSeq);
1452 this->m_runtime.rngSeeded =
true;
1455 U32 randVal =
static_cast<U32
>(this->m_runtime.rng());
1456 this->m_runtime.stack.push(randVal);
1460 Signal FpySequencer::getField_directiveHandler(
const FpySequencer_GetFieldDirective& directive,
DirectiveError& error) {
1468 if (this->m_runtime.stack.size -
sizeof(
Fpy::StackSizeType) < directive.get_parentSize()) {
1477 if (offset > directive.get_parentSize() || directive.get_memberSize() > directive.get_parentSize() - offset) {
1488 Fpy::StackSizeType parentStartOffset = this->m_runtime.stack.size - directive.get_parentSize();
1491 this->m_runtime.stack.move(parentStartOffset, parentStartOffset + offset, directive.get_memberSize());
1493 this->m_runtime.stack.size -= (directive.get_parentSize() - directive.get_memberSize());
1497 Signal FpySequencer::peek_directiveHandler(
const FpySequencer_PeekDirective& directive,
DirectiveError& error) {
1508 if (offset > this->m_runtime.stack.size) {
1521 if (byteCount > this->m_runtime.stack.size - offset) {
1527 U8* src = this->m_runtime.stack.top() - offset - byteCount;
1528 this->m_runtime.stack.push(src, byteCount);
1532 Signal FpySequencer::storeRel_directiveHandler(
const FpySequencer_StoreRelDirective& directive,
DirectiveError& error) {
1545 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + lvarOffset;
1550 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1553 Signal FpySequencer::call_directiveHandler(
const FpySequencer_CallDirective& directive,
DirectiveError& error) {
1555 if (this->m_runtime.stack.size <
sizeof(U32)) {
1561 U32 target = this->m_runtime.stack.pop<U32>();
1576 U32 returnAddr = this->m_runtime.nextStatementIndex;
1579 this->m_runtime.nextStatementIndex = target;
1582 this->m_runtime.stack.push<U32>(returnAddr);
1585 this->m_runtime.stack.push<
Fpy::StackSizeType>(this->m_runtime.stack.currentFrameStart);
1588 this->m_runtime.stack.currentFrameStart = this->m_runtime.stack.size;
1593 Signal FpySequencer::return_directiveHandler(
const FpySequencer_ReturnDirective& directive,
DirectiveError& error) {
1598 if (this->m_runtime.stack.size < returnValSize) {
1605 const Fpy::StackSizeType returnValOffset = this->m_runtime.stack.size - returnValSize;
1608 if (this->m_runtime.stack.currentFrameStart > this->m_runtime.stack.size) {
1612 this->m_runtime.stack.size = this->m_runtime.stack.currentFrameStart;
1624 U32 returnAddr = this->m_runtime.stack.pop<U32>();
1627 if (savedFramePtr > this->m_runtime.stack.size) {
1631 this->m_runtime.stack.currentFrameStart = savedFramePtr;
1640 this->m_runtime.nextStatementIndex = returnAddr;
1643 if (this->m_runtime.stack.size < callArgsSize) {
1648 this->m_runtime.stack.size -= callArgsSize;
1655 if (returnValSize > 0) {
1658 (void)memmove(this->m_runtime.stack.top(), &this->m_runtime.stack.bytes[returnValOffset], returnValSize);
1659 this->m_runtime.stack.size += returnValSize;
1665 Signal FpySequencer::loadAbs_directiveHandler(
const FpySequencer_LoadAbsDirective& directive,
DirectiveError& error) {
1666 return this->loadHelper(directive.get_globalOffset(), directive.get_size(), error);
1669 Signal FpySequencer::storeAbs_directiveHandler(
const FpySequencer_StoreAbsDirective& directive,
DirectiveError& error) {
1683 return this->storeHelper(globalOffset, size, error);
1686 Signal FpySequencer::storeAbsConstOffset_directiveHandler(
const FpySequencer_StoreAbsConstOffsetDirective& directive,
1688 return this->storeHelper(directive.get_globalOffset(), directive.get_size(), error);
1691 Signal FpySequencer::popEvent_directiveHandler(
const FpySequencer_PopEventDirective& directive,
DirectiveError& error) {
1702 if (this->m_runtime.stack.size < severitySize || this->m_runtime.stack.size - severitySize < messageSize) {
1713 if (messageSize > clampedSize) {
1715 FW_ASSERT(this->m_runtime.stack.size >= excess, static_cast<FwAssertArgType>(this->m_runtime.stack.size),
1716 static_cast<FwAssertArgType>(excess));
1717 this->m_runtime.stack.size -= excess;
1719 this->m_runtime.stack.pop(messageBuf, clampedSize);
1720 messageBuf[clampedSize] =
'\0';
1726 Fw::String messageStr(reinterpret_cast<const char*>(messageBuf));
1759 Signal FpySequencer::popSerializable_directiveHandler(
const FpySequencer_PopSerializableDirective& directive,
1766 const FwIndexType portIndex = directive.get_portIndex();
1769 if (portIndex < 0 || portIndex >= MAX_PORTS) {
1781 if (this->m_runtime.stack.size < directive.get_size()) {
1787 U8* dataPtr = this->m_runtime.stack.top() - directive.get_size();
1799 this->m_runtime.stack.size -= directive.get_size();
void directive_storeRelConstOffset_internalInterfaceHandler(const Svc::FpySequencer_StoreRelConstOffsetDirective &directive) override
Internal interface handler for directive_storeRelConstOffset.
void cmdOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port cmdOut.
void directive_storeRel_internalInterfaceHandler(const Svc::FpySequencer_StoreRelDirective &directive) override
Internal interface handler for directive_storeRel.
Serialization/Deserialization operation was successful.
void directive_return_internalInterfaceHandler(const Svc::FpySequencer_ReturnDirective &directive) override
Internal interface handler for directive_return.
sets the index of the next directive to execute
void directive_call_internalInterfaceHandler(const Svc::FpySequencer_CallDirective &directive) override
Internal interface handler for directive_call.
bool isConnected_getTlmChan_OutputPort(FwIndexType portNum) const
FwIdType FwOpcodeType
The type of a command opcode.
pushes the next RNG value to the stack
branches based off of the top byte of the stack
void directive_if_internalInterfaceHandler(const Svc::FpySequencer_IfDirective &directive) override
Internal interface handler for directive_if.
void directive_setSeed_internalInterfaceHandler(const Svc::FpySequencer_SetSeedDirective &directive) override
Internal interface handler for directive_setSeed.
PlatformSizeType FwSizeType
stores a value to an absolute address in the stack (for global variables), offset from stack ...
void directive_loadAbs_internalInterfaceHandler(const Svc::FpySequencer_LoadAbsDirective &directive) override
Internal interface handler for directive_loadAbs.
void directive_stackOp_internalInterfaceHandler(const Svc::FpySequencer_StackOpDirective &directive) override
Internal interface handler for directive_stackOp.
called when statement successfully executed. only raised in the RUNNING.AWAITING_CMD_RESPONSE state ...
void directive_getField_internalInterfaceHandler(const Svc::FpySequencer_GetFieldDirective &directive) override
Internal interface handler for directive_getField.
returns from a function call
I32 SignedStackSizeType
signed version of StackSizeType, used for relative offsets that can be negative
Serializable::SizeType getSize() const override
Get current buffer size.
void directive_pushTlmValAndTime_internalInterfaceHandler(const Svc::FpySequencer_PushTlmValAndTimeDirective &directive) override
Internal interface handler for directive_pushTlmValAndTime.
int8_t I8
8-bit signed integer
stores a value to a local variable at a compile-time-known offset relative to the current stack frame...
Fw::SerializeStatus serialOut_out(FwIndexType portNum, Fw::LinearBufferBase &buffer)
Invoke output port serialOut.
void directive_constCmd_internalInterfaceHandler(const Svc::FpySequencer_ConstCmdDirective &directive) override
Internal interface handler for directive_constCmd.
Fw::ParamValid getParam_out(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val) const
Invoke output port getParam.
bool isConnected_prmGet_OutputPort(FwIndexType portNum) const
pop an opcode and arg buf off the stack, send to cmd dispatcher and await response ...
void directive_peek_internalInterfaceHandler(const Svc::FpySequencer_PeekDirective &directive) override
Internal interface handler for directive_peek.
TimeBase getTimeBase() const
void sequencer_sendSignal_stmtResponse_success()
Send signal stmtResponse_success to state machine sequencer.
void directive_loadRel_internalInterfaceHandler(const Svc::FpySequencer_LoadRelDirective &directive) override
Internal interface handler for directive_loadRel.
void directive_memCmp_internalInterfaceHandler(const Svc::FpySequencer_MemCmpDirective &directive) override
Internal interface handler for directive_memCmp.
void directive_pushVal_internalInterfaceHandler(const Svc::FpySequencer_PushValDirective &directive) override
Internal interface handler for directive_pushVal.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
void directive_pushPrm_internalInterfaceHandler(const Svc::FpySequencer_PushPrmDirective &directive) override
Internal interface handler for directive_pushPrm.
REQUIRED: Maximum number of serial ports. This sentinel value MUST be named.
pops bytes off the top of the stack and does nothing with them
void directive_pushTime_internalInterfaceHandler(const Svc::FpySequencer_PushTimeDirective &directive) override
Internal interface handler for directive_pushTime.
void log_DIAGNOSTIC_LogDiagnostic(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogDiagnostic.
void log_COMMAND_LogCommand(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogCommand.
U8 FwTimeContextStoreType
The type used to serialize a time context value.
Software diagnostic events.
void directive_pushRand_internalInterfaceHandler(const Svc::FpySequencer_PushRandDirective &directive) override
Internal interface handler for directive_pushRand.
void log_ACTIVITY_LO_LogActivityLo(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogActivityLo.
SerializeStatus
forward declaration for string
void log_WARNING_HI_SequenceExitedWithError(const Fw::StringBase &filePath, I32 errorCode) const
Log event SequenceExitedWithError.
float F32
32-bit floating point
Fpy::DirectiveErrorCode DirectiveError
void directive_allocate_internalInterfaceHandler(const Svc::FpySequencer_AllocateDirective &directive) override
Internal interface handler for directive_allocate.
executes a cmd with const args
void directive_waitRel_internalInterfaceHandler(const FpySequencer_WaitRelDirective &directive) override
Internal interface handler for directive_waitRel.
void directive_noOp_internalInterfaceHandler(const Svc::FpySequencer_NoOpDirective &directive) override
Internal interface handler for directive_noOp.
loads a value from a local variable at a compile-time-known offset relative to the current stack fram...
void directive_stackCmd_internalInterfaceHandler(const Svc::FpySequencer_StackCmdDirective &directive) override
Internal interface handler for directive_stackCmd.
void log_ACTIVITY_HI_LogActivityHi(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogActivityHi.
void directive_discard_internalInterfaceHandler(const Svc::FpySequencer_DiscardDirective &directive) override
Internal interface handler for directive_discard.
pop two byte arrays off the top of the stack, call memcmp, push 1 if they were equal, 0 otherwise
U8 * getBuffAddr()
Get buffer address for data filling (non-const version)
Svc::Fpy::Header & get_header()
Get member header.
Less important informational events.
pops a severity and message from the stack and emits an F Prime event
An activity related to commanding.
A less serious but recoverable event.
Omit length from serialization.
void directive_exit_internalInterfaceHandler(const Svc::FpySequencer_ExitDirective &directive) override
Internal interface handler for directive_exit.
stores a value to an absolute address in the stack (for global variables), const offset ...
External serialize buffer with no copy semantics.
Svc::Fpy::DirectiveId::T get__op() const
Get member _op.
U8 SerialType
The serial representation type.
void directive_waitAbs_internalInterfaceHandler(const FpySequencer_WaitAbsDirective &directive) override
Internal interface handler for directive_waitAbs.
void log_WARNING_HI_LogWarningHi(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogWarningHi.
void directive_goto_internalInterfaceHandler(const Svc::FpySequencer_GotoDirective &directive) override
Internal interface handler for directive_goto.
peeks at N bytes from the stack, starting from an offset relative to the top of the stack ...
void sequencer_sendSignal_stmtResponse_failure()
Send signal stmtResponse_failure to state machine sequencer.
A serious but recoverable event.
void sequencer_sendSignal_stmtResponse_beginSleep()
Send signal stmtResponse_beginSleep to state machine sequencer.
void directive_popSerializable_internalInterfaceHandler(const Svc::FpySequencer_PopSerializableDirective &directive) override
Internal interface handler for directive_popSerializable.
void directive_storeAbsConstOffset_internalInterfaceHandler(const Svc::FpySequencer_StoreAbsConstOffsetDirective &directive) override
Internal interface handler for directive_storeAbsConstOffset.
sleeps for a relative duration from the current time
uint8_t U8
8-bit unsigned integer
bool isConnected_serialOut_OutputPort(FwIndexType portNum) const
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
void directive_popEvent_internalInterfaceHandler(const Svc::FpySequencer_PopEventDirective &directive) override
Internal interface handler for directive_popEvent.
generic stack operation handler
Important informational events.
static U32 min(const U32 a, const U32 b)
U8 SerialType
The serial representation type.
static Time add(const Time &a, const Time &b)
void sequencer_sendSignal_stmtResponse_keepWaiting()
Send signal stmtResponse_keepWaiting to state machine sequencer.
FwTimeContextStoreType getContext() const
sleeps until an absolute time
called when the statement unsuccessfully executed. only raised in the RUNNING.AWAITING_CMD_RESPONSE s...
loads a value from an absolute address in the stack (for global variables)
PlatformIndexType FwIndexType
pops a U32 from the stack and uses it to seed the RNG used by PushRandDirective
double F64
64-bit floating point (double). Required for compiler-supplied double promotion.
pops serialized data from stack and sends to serial output port
A fatal non-recoverable event.
void log_WARNING_LO_LogWarningLo(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogWarningLo.
pushes a const byte array onto stack
stores a value to a local variable at a runtime-determined offset relative to the current stack frame...
RateGroupDivider component implementation.
Enum representing parameter validity.
void log_FATAL_LogFatal(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogFatal.
void directive_storeAbs_internalInterfaceHandler(const Svc::FpySequencer_StoreAbsDirective &directive) override
Internal interface handler for directive_storeAbs.
pushes a prm buf to the stack
U16 FwTimeBaseStoreType
The type used to serialize a time base value.
pushes the current Fw.Time struct to the stack
pushes some empty bytes to the stack
called when the statement is telling the sequencer to await a later stmt response ...
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
Fw::TlmValid getTlmChan_out(FwIndexType portNum, FwChanIdType id, Fw::Time &timeTag, Fw::TlmBuffer &val) const
Invoke output port getTlmChan.
a statement is telling the sequencer to go to sleep
pushes a tlm buf to the stack
U32 StackSizeType
the type which everything referencing a size or offset on the stack is represented in ...
void directive_pushTlmVal_internalInterfaceHandler(const Svc::FpySequencer_PushTlmValDirective &directive) override
Internal interface handler for directive_pushTlmVal.