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));
82 bool FpySequencer::checkDirectiveExpected(Fpy::DirectiveId directive, U64 sequenceIndex) {
87 if (sequenceIndex != this->m_sequencesStarted) {
101 this->sendSignal(this->waitRel_directiveHandler(directive, error));
112 this->sendSignal(this->waitAbs_directiveHandler(directive, error));
123 this->sendSignal(this->goto_directiveHandler(directive, error));
134 this->sendSignal(this->if_directiveHandler(directive, error));
145 this->sendSignal(this->noOp_directiveHandler(directive, error));
156 this->sendSignal(this->pushTlmVal_directiveHandler(directive, error));
168 this->sendSignal(this->pushTlmValAndTime_directiveHandler(directive, error));
179 this->sendSignal(this->pushPrm_directiveHandler(directive, error));
190 this->sendSignal(this->constCmd_directiveHandler(directive, error));
197 if (!this->checkDirectiveExpected(directive.
get__op(), sequenceIndex)) {
201 this->sendSignal(this->stackOp_directiveHandler(directive, error));
202 handleDirectiveErrorCode(directive.
get__op(), error);
212 this->sendSignal(this->exit_directiveHandler(directive, error));
223 this->sendSignal(this->allocate_directiveHandler(directive, error));
235 this->sendSignal(this->storeRelConstOffset_directiveHandler(directive, error));
246 this->sendSignal(this->pushVal_directiveHandler(directive, error));
257 this->sendSignal(this->loadRel_directiveHandler(directive, error));
268 this->sendSignal(this->discard_directiveHandler(directive, error));
279 this->sendSignal(this->memCmp_directiveHandler(directive, error));
290 this->sendSignal(this->stackCmd_directiveHandler(directive, error));
301 this->sendSignal(this->pushTime_directiveHandler(directive, error));
312 this->sendSignal(this->setSeed_directiveHandler(directive, error));
323 this->sendSignal(this->pushRand_directiveHandler(directive, error));
334 this->sendSignal(this->getField_directiveHandler(directive, error));
345 this->sendSignal(this->peek_directiveHandler(directive, error));
356 this->sendSignal(this->storeRel_directiveHandler(directive, error));
367 this->sendSignal(this->call_directiveHandler(directive, error));
378 this->sendSignal(this->return_directiveHandler(directive, error));
389 this->sendSignal(this->loadAbs_directiveHandler(directive, error));
400 this->sendSignal(this->storeAbs_directiveHandler(directive, error));
412 this->sendSignal(this->storeAbsConstOffset_directiveHandler(directive, error));
423 this->sendSignal(this->popEvent_directiveHandler(directive, error));
435 this->sendSignal(this->popSerializable_directiveHandler(directive, error));
441 if (this->m_runtime.stack.size < 8) {
448 U32 uSeconds = this->m_runtime.stack.pop<U32>();
449 U32 seconds = this->m_runtime.stack.pop<U32>();
451 if (uSeconds >= 1000000) {
456 wakeupTime.
add(seconds, uSeconds);
457 this->m_runtime.wakeupTime = wakeupTime;
462 Signal FpySequencer::waitAbs_directiveHandler(
const FpySequencer_WaitAbsDirective& directive,
DirectiveError& error) {
468 U32 uSeconds = this->m_runtime.stack.pop<U32>();
469 U32 seconds = this->m_runtime.stack.pop<U32>();
473 if (uSeconds >= 1000000) {
478 this->m_runtime.wakeupTime =
Fw::Time(static_cast<TimeBase::T>(base), ctx, seconds, uSeconds);
483 Signal FpySequencer::goto_directiveHandler(
const FpySequencer_GotoDirective& directive,
DirectiveError& error) {
489 m_runtime.nextStatementIndex = directive.get_statementIndex();
494 Signal FpySequencer::if_directiveHandler(
const FpySequencer_IfDirective& directive,
DirectiveError& error) {
495 if (this->m_runtime.stack.size < 1) {
505 if (this->m_runtime.stack.pop<
U8>() != 0) {
511 this->m_runtime.nextStatementIndex = directive.get_falseGotoStmtIndex();
515 Signal FpySequencer::noOp_directiveHandler(
const FpySequencer_NoOpDirective& directive,
DirectiveError& error) {
519 Signal FpySequencer::pushTlmVal_directiveHandler(
const FpySequencer_PushTlmValDirective& directive,
543 Signal FpySequencer::pushTlmValAndTime_directiveHandler(
const FpySequencer_PushTlmValAndTimeDirective& directive,
576 this->m_runtime.stack.push(timeEsb.getBuffAddr(),
static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
580 Signal FpySequencer::pushPrm_directiveHandler(
const FpySequencer_PushPrmDirective& directive,
DirectiveError& error) {
604 Signal FpySequencer::constCmd_directiveHandler(
const FpySequencer_ConstCmdDirective& directive,
DirectiveError& error) {
611 if (this->sendCmd(directive.get_opCode(), directive.get_argBuf(), directive.get__argBufSize()) ==
622 if (this->m_runtime.stack.size <
sizeof(
U8) * 2) {
625 this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<
U8>() | this->m_runtime.stack.pop<
U8>()));
629 if (this->m_runtime.stack.size <
sizeof(
U8) * 2) {
632 this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<
U8>() & this->m_runtime.stack.pop<
U8>()));
636 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
639 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>())
645 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
648 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>())
654 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
657 U64 rhs = this->m_runtime.stack.pop<U64>();
658 U64 lhs = this->m_runtime.stack.pop<U64>();
664 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
667 U64 rhs = this->m_runtime.stack.pop<U64>();
668 U64 lhs = this->m_runtime.stack.pop<U64>();
674 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
677 U64 rhs = this->m_runtime.stack.pop<U64>();
678 U64 lhs = this->m_runtime.stack.pop<U64>();
684 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
687 U64 rhs = this->m_runtime.stack.pop<U64>();
688 U64 lhs = this->m_runtime.stack.pop<U64>();
694 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
697 I64 rhs = this->m_runtime.stack.pop<I64>();
698 I64 lhs = this->m_runtime.stack.pop<I64>();
704 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
707 I64 rhs = this->m_runtime.stack.pop<I64>();
708 I64 lhs = this->m_runtime.stack.pop<I64>();
714 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
717 I64 rhs = this->m_runtime.stack.pop<I64>();
718 I64 lhs = this->m_runtime.stack.pop<I64>();
724 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
727 I64 rhs = this->m_runtime.stack.pop<I64>();
728 I64 lhs = this->m_runtime.stack.pop<I64>();
734 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
737 F64 rhs = this->m_runtime.stack.pop<
F64>();
738 F64 lhs = this->m_runtime.stack.pop<
F64>();
745 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
748 F64 rhs = this->m_runtime.stack.pop<
F64>();
749 F64 lhs = this->m_runtime.stack.pop<
F64>();
756 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
759 F64 rhs = this->m_runtime.stack.pop<
F64>();
760 F64 lhs = this->m_runtime.stack.pop<
F64>();
766 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
769 F64 rhs = this->m_runtime.stack.pop<
F64>();
770 F64 lhs = this->m_runtime.stack.pop<
F64>();
771 this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs) ? static_cast<U8>(
FW_SERIALIZE_TRUE_VALUE)
776 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
779 F64 rhs = this->m_runtime.stack.pop<
F64>();
780 F64 lhs = this->m_runtime.stack.pop<
F64>();
786 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
789 F64 rhs = this->m_runtime.stack.pop<
F64>();
790 F64 lhs = this->m_runtime.stack.pop<
F64>();
791 this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)
797 if (this->m_runtime.stack.size <
sizeof(
U8)) {
800 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<
U8>() == 0)
807 if (this->m_runtime.stack.size <
sizeof(
F32)) {
814 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<
F32>()));
819 if (this->m_runtime.stack.size <
sizeof(
F64)) {
822 this->m_runtime.stack.push(static_cast<F32>(this->m_runtime.stack.pop<
F64>()));
826 if (this->m_runtime.stack.size <
sizeof(
F64)) {
829 F64 val = this->m_runtime.stack.pop<
F64>();
834 const F64 bound = std::ldexp(1.0, 63);
836 if (std::isnan(val)) {
838 }
else if (val >= bound) {
839 result = std::numeric_limits<I64>::max();
840 }
else if (val < -bound) {
843 result =
static_cast<I64
>(val);
845 this->m_runtime.stack.push(result);
849 if (this->m_runtime.stack.size <
sizeof(I64)) {
852 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<I64>()));
856 if (this->m_runtime.stack.size <
sizeof(
F64)) {
859 F64 val = this->m_runtime.stack.pop<
F64>();
863 const F64 bound = std::ldexp(1.0, 64);
865 if (std::isnan(val) || val < 0.0) {
867 }
else if (val >= bound) {
868 result = std::numeric_limits<U64>::max();
870 result =
static_cast<U64
>(val);
872 this->m_runtime.stack.push(result);
876 if (this->m_runtime.stack.size <
sizeof(U64)) {
879 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<U64>()));
883 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
886 I64 rhs = this->m_runtime.stack.pop<I64>();
887 I64 lhs = this->m_runtime.stack.pop<I64>();
891 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() - rhs) < lhs)) {
899 this->m_runtime.stack.push(static_cast<I64>(lhs + rhs));
903 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
906 I64 rhs = this->m_runtime.stack.pop<I64>();
907 I64 lhs = this->m_runtime.stack.pop<I64>();
912 if ((rhs < 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() + rhs) < lhs)) {
921 this->m_runtime.stack.push(static_cast<I64>(lhs - rhs));
925 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
928 I64 rhs = this->m_runtime.stack.pop<I64>();
929 I64 lhs = this->m_runtime.stack.pop<I64>();
934 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() / rhs) < lhs)) {
938 else if ((rhs < 0) && (lhs < 0) && (lhs < (std::numeric_limits<I64>::max() / rhs))) {
951 this->m_runtime.stack.push(static_cast<I64>(lhs * rhs));
955 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
958 U64 rhs = this->m_runtime.stack.pop<U64>();
959 U64 lhs = this->m_runtime.stack.pop<U64>();
964 this->m_runtime.stack.push(static_cast<U64>(lhs / rhs));
968 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
972 I64 rhs = this->m_runtime.stack.pop<I64>();
973 I64 lhs = this->m_runtime.stack.pop<I64>();
986 I64 quotient = lhs / rhs;
987 if (((lhs % rhs) != 0) && ((lhs < 0) != (rhs < 0))) {
990 this->m_runtime.stack.push(quotient);
994 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
997 U64 rhs = this->m_runtime.stack.pop<U64>();
1001 U64 lhs = this->m_runtime.stack.pop<U64>();
1002 this->m_runtime.stack.push(static_cast<U64>(lhs % rhs));
1006 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
1009 I64 rhs = this->m_runtime.stack.pop<I64>();
1013 I64 lhs = this->m_runtime.stack.pop<I64>();
1017 this->m_runtime.stack.push(static_cast<I64>(0));
1020 I64 res =
static_cast<I64
>(lhs % rhs);
1025 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
1028 this->m_runtime.stack.push(res);
1032 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1035 F64 rhs = this->m_runtime.stack.pop<
F64>();
1036 F64 lhs = this->m_runtime.stack.pop<
F64>();
1037 this->m_runtime.stack.push(static_cast<F64>(lhs + rhs));
1041 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1044 F64 rhs = this->m_runtime.stack.pop<
F64>();
1045 F64 lhs = this->m_runtime.stack.pop<
F64>();
1046 this->m_runtime.stack.push(static_cast<F64>(lhs - rhs));
1050 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1053 F64 rhs = this->m_runtime.stack.pop<
F64>();
1054 F64 lhs = this->m_runtime.stack.pop<
F64>();
1055 this->m_runtime.stack.push(static_cast<F64>(lhs * rhs));
1059 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1062 F64 rhs = this->m_runtime.stack.pop<
F64>();
1063 F64 lhs = this->m_runtime.stack.pop<
F64>();
1064 this->m_runtime.stack.push(static_cast<F64>(lhs / rhs));
1068 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1071 F64 rhs = this->m_runtime.stack.pop<
F64>();
1072 F64 lhs = this->m_runtime.stack.pop<
F64>();
1073 this->m_runtime.stack.push(static_cast<F64>(pow(lhs, rhs)));
1077 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1080 F64 val = this->m_runtime.stack.pop<
F64>();
1084 this->m_runtime.stack.push(static_cast<F64>(log(val)));
1088 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1091 F64 rhs = this->m_runtime.stack.pop<
F64>();
1092 F64 lhs = this->m_runtime.stack.pop<
F64>();
1095 F64 res = std::fmod(lhs, rhs);
1099 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
1101 }
else if (res == 0) {
1104 res = std::copysign(0.0, rhs);
1106 this->m_runtime.stack.push(res);
1110 if (this->m_runtime.stack.size <
sizeof(
I8)) {
1117 I8 src = this->m_runtime.stack.pop<
I8>();
1118 this->m_runtime.stack.push(static_cast<I64>(src));
1122 if (this->m_runtime.stack.size <
sizeof(I16)) {
1129 I16 src = this->m_runtime.stack.pop<I16>();
1130 this->m_runtime.stack.push(static_cast<I64>(src));
1134 if (this->m_runtime.stack.size <
sizeof(I32)) {
1141 I32 src = this->m_runtime.stack.pop<I32>();
1142 this->m_runtime.stack.push(static_cast<I64>(src));
1146 if (this->m_runtime.stack.size <
sizeof(
U8)) {
1153 U8 src = this->m_runtime.stack.pop<
U8>();
1154 this->m_runtime.stack.push(static_cast<U64>(src));
1158 if (this->m_runtime.stack.size <
sizeof(U16)) {
1165 U16 src = this->m_runtime.stack.pop<U16>();
1166 this->m_runtime.stack.push(static_cast<U64>(src));
1170 if (this->m_runtime.stack.size <
sizeof(U32)) {
1177 U32 src = this->m_runtime.stack.pop<U32>();
1178 this->m_runtime.stack.push(static_cast<U64>(src));
1182 if (this->m_runtime.stack.size <
sizeof(U64)) {
1185 U64 src = this->m_runtime.stack.pop<U64>();
1186 this->m_runtime.stack.push(static_cast<U8>(src));
1190 if (this->m_runtime.stack.size <
sizeof(U64)) {
1193 U64 src = this->m_runtime.stack.pop<U64>();
1194 this->m_runtime.stack.push(static_cast<U16>(src));
1198 if (this->m_runtime.stack.size <
sizeof(U64)) {
1201 U64 src = this->m_runtime.stack.pop<U64>();
1202 this->m_runtime.stack.push(static_cast<U32>(src));
1206 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1209 F64 val = this->m_runtime.stack.pop<
F64>();
1212 this->m_runtime.stack.push(std::floor(val));
1216 if (this->m_runtime.stack.size <
sizeof(I64)) {
1219 I64 val = this->m_runtime.stack.pop<I64>();
1224 this->m_runtime.stack.push(val < 0 ? -val : val);
1228 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1231 F64 val = this->m_runtime.stack.pop<
F64>();
1234 this->m_runtime.stack.push(std::fabs(val));
1237 Signal FpySequencer::stackOp_directiveHandler(
const FpySequencer_StackOpDirective& directive,
DirectiveError& error) {
1241 static_cast<FwAssertArgType>(directive.get__op()));
1243 switch (directive.get__op()) {
1245 error = this->op_or();
1248 error = this->op_and();
1251 error = this->op_ieq();
1254 error = this->op_ine();
1257 error = this->op_ult();
1260 error = this->op_ule();
1263 error = this->op_ugt();
1266 error = this->op_uge();
1269 error = this->op_slt();
1272 error = this->op_sle();
1275 error = this->op_sgt();
1278 error = this->op_sge();
1281 error = this->op_feq();
1284 error = this->op_fne();
1287 error = this->op_flt();
1290 error = this->op_fle();
1293 error = this->op_fgt();
1296 error = this->op_fge();
1299 error = this->op_not();
1302 error = this->op_fpext();
1305 error = this->op_fptrunc();
1308 error = this->op_fptosi();
1311 error = this->op_fptoui();
1314 error = this->op_sitofp();
1317 error = this->op_uitofp();
1320 error = this->op_add();
1323 error = this->op_sub();
1326 error = this->op_mul();
1329 error = this->op_udiv();
1332 error = this->op_sdiv();
1335 error = this->op_umod();
1338 error = this->op_smod();
1341 error = this->op_fadd();
1344 error = this->op_fsub();
1347 error = this->op_fmul();
1350 error = this->op_fdiv();
1353 error = this->op_fpow();
1356 error = this->op_flog();
1359 error = this->op_fmod();
1362 error = this->op_siext_8_64();
1365 error = this->op_siext_16_64();
1368 error = this->op_siext_32_64();
1371 error = this->op_ziext_8_64();
1374 error = this->op_ziext_16_64();
1377 error = this->op_ziext_32_64();
1380 error = this->op_itrunc_64_8();
1383 error = this->op_itrunc_64_16();
1386 error = this->op_itrunc_64_32();
1389 error = this->op_ffloor();
1392 error = this->op_iabs();
1395 error = this->op_fabs();
1407 Signal FpySequencer::exit_directiveHandler(
const FpySequencer_ExitDirective& directive,
DirectiveError& error) {
1408 if (this->m_runtime.stack.size <
sizeof(I32)) {
1412 I32 errorCode = this->m_runtime.stack.pop<I32>();
1414 if (errorCode == 0) {
1426 Signal FpySequencer::allocate_directiveHandler(
const FpySequencer_AllocateDirective& directive,
DirectiveError& error) {
1431 this->m_runtime.stack.pushZeroes(directive.get_size());
1437 if (this->m_runtime.stack.size < size) {
1445 if (destOffset > newStackSize || size > newStackSize - destOffset) {
1450 this->m_runtime.stack.copy(destOffset, this->m_runtime.stack.size - size, size);
1451 this->m_runtime.stack.size = newStackSize;
1463 if (srcOffset > this->m_runtime.stack.size || size > this->m_runtime.stack.size - srcOffset) {
1468 this->m_runtime.stack.copy(this->m_runtime.stack.size, srcOffset, size);
1469 this->m_runtime.stack.size += size;
1473 Signal FpySequencer::storeRelConstOffset_directiveHandler(
const FpySequencer_StoreRelConstOffsetDirective& directive,
1475 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1480 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1483 Signal FpySequencer::loadRel_directiveHandler(
const FpySequencer_LoadRelDirective& directive,
DirectiveError& error) {
1484 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1489 return this->loadHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1492 Signal FpySequencer::pushVal_directiveHandler(
const FpySequencer_PushValDirective& directive,
DirectiveError& error) {
1498 this->m_runtime.stack.push(const_cast<U8*>(directive.get_val()),
1499 static_cast<Fpy::StackSizeType>(directive.get__valSize()));
1503 Signal FpySequencer::discard_directiveHandler(
const FpySequencer_DiscardDirective& directive,
DirectiveError& error) {
1504 if (this->m_runtime.stack.size < directive.get_size()) {
1509 this->m_runtime.stack.size -= directive.get_size();
1513 Signal FpySequencer::memCmp_directiveHandler(
const FpySequencer_MemCmpDirective& directive,
DirectiveError& error) {
1522 if (this->m_runtime.stack.size < directive.get_size() * 2) {
1528 U64 lhsOffset = this->m_runtime.stack.size - directive.get_size() * 2;
1529 U64 rhsOffset = this->m_runtime.stack.size - directive.get_size();
1534 this->m_runtime.stack.size -= directive.get_size() * 2;
1537 if (memcmp(this->m_runtime.stack.bytes + lhsOffset, this->m_runtime.stack.bytes + rhsOffset,
1538 directive.get_size()) == 0) {
1546 Signal FpySequencer::stackCmd_directiveHandler(
const FpySequencer_StackCmdDirective& directive,
DirectiveError& error) {
1549 if (this->m_runtime.stack.size <
sizeof(
FwOpcodeType) ||
1550 this->m_runtime.stack.size -
sizeof(
FwOpcodeType) < directive.get_argsSize()) {
1559 U64 argBufOffset = this->m_runtime.stack.size - directive.get_argsSize();
1562 this->m_runtime.currentCmdOpcode = opcode;
1565 this->m_runtime.stack.size -= directive.get_argsSize();
1575 if (this->sendCmd(opcode, this->m_runtime.stack.bytes + argBufOffset, directive.get_argsSize()) ==
1587 Signal FpySequencer::pushTime_directiveHandler(
const FpySequencer_PushTimeDirective& directive,
DirectiveError& error) {
1603 this->m_runtime.stack.push(timeEsb.getBuffAddr(),
static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
1607 Signal FpySequencer::setSeed_directiveHandler(
const FpySequencer_SetSeedDirective& directive,
DirectiveError& error) {
1608 if (this->m_runtime.stack.size <
sizeof(U32)) {
1613 U32 seed = this->m_runtime.stack.pop<U32>();
1614 this->m_runtime.rng.seed(seed);
1615 this->m_runtime.rngSeeded =
true;
1619 Signal FpySequencer::pushRand_directiveHandler(
const FpySequencer_PushRandDirective& directive,
DirectiveError& error) {
1625 if (!this->m_runtime.rngSeeded) {
1627 std::seed_seq seedSeq{
static_cast<U32
>(currentTime.
getTimeBase()), static_cast<U32>(currentTime.
getContext()),
1629 this->m_runtime.rng.seed(seedSeq);
1630 this->m_runtime.rngSeeded =
true;
1633 U32 randVal =
static_cast<U32
>(this->m_runtime.rng());
1634 this->m_runtime.stack.push(randVal);
1638 Signal FpySequencer::getField_directiveHandler(
const FpySequencer_GetFieldDirective& directive,
DirectiveError& error) {
1646 if (this->m_runtime.stack.size -
sizeof(
Fpy::StackSizeType) < directive.get_parentSize()) {
1655 if (offset > directive.get_parentSize() || directive.get_memberSize() > directive.get_parentSize() - offset) {
1666 Fpy::StackSizeType parentStartOffset = this->m_runtime.stack.size - directive.get_parentSize();
1669 this->m_runtime.stack.move(parentStartOffset, parentStartOffset + offset, directive.get_memberSize());
1671 this->m_runtime.stack.size -= (directive.get_parentSize() - directive.get_memberSize());
1675 Signal FpySequencer::peek_directiveHandler(
const FpySequencer_PeekDirective& directive,
DirectiveError& error) {
1686 if (offset > this->m_runtime.stack.size) {
1699 if (byteCount > this->m_runtime.stack.size - offset) {
1705 U8* src = this->m_runtime.stack.top() - offset - byteCount;
1706 this->m_runtime.stack.push(src, byteCount);
1710 Signal FpySequencer::storeRel_directiveHandler(
const FpySequencer_StoreRelDirective& directive,
DirectiveError& error) {
1723 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + lvarOffset;
1728 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1731 Signal FpySequencer::call_directiveHandler(
const FpySequencer_CallDirective& directive,
DirectiveError& error) {
1733 if (this->m_runtime.stack.size <
sizeof(U32)) {
1739 U32 target = this->m_runtime.stack.pop<U32>();
1754 U32 returnAddr = this->m_runtime.nextStatementIndex;
1757 this->m_runtime.nextStatementIndex = target;
1760 this->m_runtime.stack.push<U32>(returnAddr);
1763 this->m_runtime.stack.push<
Fpy::StackSizeType>(this->m_runtime.stack.currentFrameStart);
1766 this->m_runtime.stack.currentFrameStart = this->m_runtime.stack.size;
1771 Signal FpySequencer::return_directiveHandler(
const FpySequencer_ReturnDirective& directive,
DirectiveError& error) {
1776 if (this->m_runtime.stack.size < returnValSize) {
1783 const Fpy::StackSizeType returnValOffset = this->m_runtime.stack.size - returnValSize;
1786 if (this->m_runtime.stack.currentFrameStart > this->m_runtime.stack.size) {
1790 this->m_runtime.stack.size = this->m_runtime.stack.currentFrameStart;
1802 U32 returnAddr = this->m_runtime.stack.pop<U32>();
1805 if (savedFramePtr > this->m_runtime.stack.size) {
1809 this->m_runtime.stack.currentFrameStart = savedFramePtr;
1818 this->m_runtime.nextStatementIndex = returnAddr;
1821 if (this->m_runtime.stack.size < callArgsSize) {
1826 this->m_runtime.stack.size -= callArgsSize;
1833 if (returnValSize > 0) {
1836 (void)memmove(this->m_runtime.stack.top(), &this->m_runtime.stack.bytes[returnValOffset], returnValSize);
1837 this->m_runtime.stack.size += returnValSize;
1843 Signal FpySequencer::loadAbs_directiveHandler(
const FpySequencer_LoadAbsDirective& directive,
DirectiveError& error) {
1844 return this->loadHelper(directive.get_globalOffset(), directive.get_size(), error);
1847 Signal FpySequencer::storeAbs_directiveHandler(
const FpySequencer_StoreAbsDirective& directive,
DirectiveError& error) {
1861 return this->storeHelper(globalOffset, size, error);
1864 Signal FpySequencer::storeAbsConstOffset_directiveHandler(
const FpySequencer_StoreAbsConstOffsetDirective& directive,
1866 return this->storeHelper(directive.get_globalOffset(), directive.get_size(), error);
1869 Signal FpySequencer::popEvent_directiveHandler(
const FpySequencer_PopEventDirective& directive,
DirectiveError& error) {
1880 if (this->m_runtime.stack.size < severitySize || this->m_runtime.stack.size - severitySize < messageSize) {
1891 if (messageSize > clampedSize) {
1893 FW_ASSERT(this->m_runtime.stack.size >= excess, static_cast<FwAssertArgType>(this->m_runtime.stack.size),
1894 static_cast<FwAssertArgType>(excess));
1895 this->m_runtime.stack.size -= excess;
1897 this->m_runtime.stack.pop(messageBuf, clampedSize);
1898 messageBuf[clampedSize] =
'\0';
1904 Fw::String messageStr(reinterpret_cast<const char*>(messageBuf));
1937 Signal FpySequencer::popSerializable_directiveHandler(
const FpySequencer_PopSerializableDirective& directive,
1944 const FwIndexType portIndex = directive.get_portIndex();
1947 if (portIndex < 0 || portIndex >= MAX_PORTS) {
1959 if (this->m_runtime.stack.size < directive.get_size()) {
1965 U8* dataPtr = this->m_runtime.stack.top() - directive.get_size();
1981 this->m_runtime.stack.size -= directive.get_size();
void directive_allocate_internalInterfaceHandler(const Svc::FpySequencer_AllocateDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_allocate.
void cmdOut_out(FwIndexType portNum, Fw::ComBuffer &data, U32 context) const
Invoke output port cmdOut.
Serialization/Deserialization operation was successful.
sets the index of the next directive to execute
void directive_stackOp_internalInterfaceHandler(const Svc::FpySequencer_StackOpDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_stackOp.
bool isConnected_getTlmChan_OutputPort(FwIndexType portNum) const
void directive_waitAbs_internalInterfaceHandler(const FpySequencer_WaitAbsDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_waitAbs.
FwIdType FwOpcodeType
The type of a command opcode.
pushes the next RNG value to the stack
void directive_call_internalInterfaceHandler(const Svc::FpySequencer_CallDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_call.
branches based off of the top byte of the stack
bool isConnected_getParam_OutputPort(FwIndexType portNum) const
PlatformSizeType FwSizeType
stores a value to an absolute address in the stack (for global variables), offset from stack ...
void directive_storeRelConstOffset_internalInterfaceHandler(const Svc::FpySequencer_StoreRelConstOffsetDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_storeRelConstOffset.
called when statement successfully executed. only raised in the RUNNING.AWAITING_CMD_RESPONSE state ...
void directive_loadAbs_internalInterfaceHandler(const Svc::FpySequencer_LoadAbsDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_loadAbs.
returns from a function call
void directive_storeAbsConstOffset_internalInterfaceHandler(const Svc::FpySequencer_StoreAbsConstOffsetDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_storeAbsConstOffset.
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_pushVal_internalInterfaceHandler(const Svc::FpySequencer_PushValDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_pushVal.
void directive_noOp_internalInterfaceHandler(const Svc::FpySequencer_NoOpDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_noOp.
int8_t I8
8-bit signed integer
void log_WARNING_LO_DirectiveWhileNotAwaiting(const Svc::Fpy::DirectiveId &directive, I32 state) const
Log event DirectiveWhileNotAwaiting.
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.
Fw::ParamValid getParam_out(FwIndexType portNum, FwPrmIdType id, Fw::ParamBuffer &val) const
Invoke output port getParam.
void directive_loadRel_internalInterfaceHandler(const Svc::FpySequencer_LoadRelDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_loadRel.
pop an opcode and arg buf off the stack, send to cmd dispatcher and await response ...
void log_WARNING_LO_DirectiveFromOldSequence(const Svc::Fpy::DirectiveId &directive, U64 oldSequenceIdx, U64 currentSequenceIdx) const
Log event DirectiveFromOldSequence.
TimeBase getTimeBase() const
void sequencer_sendSignal_stmtResponse_success()
Send signal stmtResponse_success to state machine sequencer.
SerializeStatus serializeFrom(U8 val, Endianness mode=Endianness::BIG) override
Serialize an 8-bit unsigned integer value.
REQUIRED: Maximum number of serial ports. This sentinel value MUST be named.
void directive_pushPrm_internalInterfaceHandler(const Svc::FpySequencer_PushPrmDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_pushPrm.
pops bytes off the top of the stack and does nothing with them
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.
void directive_goto_internalInterfaceHandler(const Svc::FpySequencer_GotoDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_goto.
U8 FwTimeContextStoreType
The type used to serialize a time context value.
Software diagnostic events.
void log_ACTIVITY_LO_LogActivityLo(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogActivityLo.
SerializeStatus
forward declaration for string
Svc_FpySequencer_SequencerStateMachine::State sequencer_getState() const
Get the state of state machine instance sequencer.
void log_WARNING_HI_SequenceExitedWithError(const Fw::StringBase &filePath, I32 errorCode) const
Log event SequenceExitedWithError.
float F32
32-bit floating point
Fpy::DirectiveErrorCode DirectiveError
executes a cmd with const args
loads a value from a local variable at a compile-time-known offset relative to the current stack fram...
void log_ACTIVITY_HI_LogActivityHi(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogActivityHi.
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.
void directive_setSeed_internalInterfaceHandler(const Svc::FpySequencer_SetSeedDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_setSeed.
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_storeRel_internalInterfaceHandler(const Svc::FpySequencer_StoreRelDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_storeRel.
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_storeAbs_internalInterfaceHandler(const Svc::FpySequencer_StoreAbsDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_storeAbs.
void directive_stackCmd_internalInterfaceHandler(const Svc::FpySequencer_StackCmdDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_stackCmd.
void directive_pushRand_internalInterfaceHandler(const Svc::FpySequencer_PushRandDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_pushRand.
void log_WARNING_HI_LogWarningHi(const Fw::StringBase &filePath, const Fw::StringBase &message) const
Log event LogWarningHi.
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 directive_constCmd_internalInterfaceHandler(const Svc::FpySequencer_ConstCmdDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_constCmd.
void directive_return_internalInterfaceHandler(const Svc::FpySequencer_ReturnDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_return.
void sequencer_sendSignal_stmtResponse_beginSleep()
Send signal stmtResponse_beginSleep to state machine sequencer.
void directive_getField_internalInterfaceHandler(const Svc::FpySequencer_GetFieldDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_getField.
sleeps for a relative duration from the current time
void directive_pushTlmValAndTime_internalInterfaceHandler(const Svc::FpySequencer_PushTlmValAndTimeDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_pushTlmValAndTime.
uint8_t U8
8-bit unsigned integer
bool isConnected_serialOut_OutputPort(FwIndexType portNum) const
void directive_pushTlmVal_internalInterfaceHandler(const Svc::FpySequencer_PushTlmValDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_pushTlmVal.
SerializeStatus setBuffLen(Serializable::SizeType length) override
Set buffer length manually.
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.
void directive_if_internalInterfaceHandler(const Svc::FpySequencer_IfDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_if.
FwTimeContextStoreType getContext() const
sleeps until an absolute time
void directive_exit_internalInterfaceHandler(const Svc::FpySequencer_ExitDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_exit.
void directive_popSerializable_internalInterfaceHandler(const Svc::FpySequencer_PopSerializableDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_popSerializable.
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
void directive_waitRel_internalInterfaceHandler(const FpySequencer_WaitRelDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_waitRel.
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 directive_peek_internalInterfaceHandler(const Svc::FpySequencer_PeekDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_peek.
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.
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
void directive_pushTime_internalInterfaceHandler(const Svc::FpySequencer_PushTimeDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_pushTime.
called when the statement is telling the sequencer to await a later stmt response ...
FpySequencer_SequencerStateMachineStateMachineBase::Signal Signal
void directive_popEvent_internalInterfaceHandler(const Svc::FpySequencer_PopEventDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_popEvent.
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
void directive_memCmp_internalInterfaceHandler(const Svc::FpySequencer_MemCmpDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_memCmp.
pushes a tlm buf to the stack
void directive_discard_internalInterfaceHandler(const Svc::FpySequencer_DiscardDirective &directive, U64 sequenceIndex) override
Internal interface handler for directive_discard.
U32 StackSizeType
the type which everything referencing a size or offset on the stack is represented in ...