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)) {
810 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<
F32>()));
815 if (this->m_runtime.stack.size <
sizeof(
F64)) {
818 this->m_runtime.stack.push(static_cast<F32>(this->m_runtime.stack.pop<
F64>()));
822 if (this->m_runtime.stack.size <
sizeof(
F64)) {
825 F64 val = this->m_runtime.stack.pop<
F64>();
830 const F64 bound = std::ldexp(1.0, 63);
832 if (std::isnan(val)) {
834 }
else if (val >= bound) {
835 result = std::numeric_limits<I64>::max();
836 }
else if (val < -bound) {
839 result =
static_cast<I64
>(val);
841 this->m_runtime.stack.push(result);
845 if (this->m_runtime.stack.size <
sizeof(I64)) {
848 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<I64>()));
852 if (this->m_runtime.stack.size <
sizeof(
F64)) {
855 F64 val = this->m_runtime.stack.pop<
F64>();
859 const F64 bound = std::ldexp(1.0, 64);
861 if (std::isnan(val) || val < 0.0) {
863 }
else if (val >= bound) {
864 result = std::numeric_limits<U64>::max();
866 result =
static_cast<U64
>(val);
868 this->m_runtime.stack.push(result);
872 if (this->m_runtime.stack.size <
sizeof(U64)) {
875 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<U64>()));
879 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
882 I64 rhs = this->m_runtime.stack.pop<I64>();
883 I64 lhs = this->m_runtime.stack.pop<I64>();
887 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() - rhs) < lhs)) {
895 this->m_runtime.stack.push(static_cast<I64>(lhs + rhs));
899 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
902 I64 rhs = this->m_runtime.stack.pop<I64>();
903 I64 lhs = this->m_runtime.stack.pop<I64>();
908 if ((rhs < 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() + rhs) < lhs)) {
917 this->m_runtime.stack.push(static_cast<I64>(lhs - rhs));
921 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
924 I64 rhs = this->m_runtime.stack.pop<I64>();
925 I64 lhs = this->m_runtime.stack.pop<I64>();
930 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() / rhs) < lhs)) {
934 else if ((rhs < 0) && (lhs < 0) && (lhs < (std::numeric_limits<I64>::max() / rhs))) {
947 this->m_runtime.stack.push(static_cast<I64>(lhs * rhs));
951 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
954 U64 rhs = this->m_runtime.stack.pop<U64>();
955 U64 lhs = this->m_runtime.stack.pop<U64>();
960 this->m_runtime.stack.push(static_cast<U64>(lhs / rhs));
964 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
968 I64 rhs = this->m_runtime.stack.pop<I64>();
969 I64 lhs = this->m_runtime.stack.pop<I64>();
982 I64 quotient = lhs / rhs;
983 if (((lhs % rhs) != 0) && ((lhs < 0) != (rhs < 0))) {
986 this->m_runtime.stack.push(quotient);
990 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
993 U64 rhs = this->m_runtime.stack.pop<U64>();
997 U64 lhs = this->m_runtime.stack.pop<U64>();
998 this->m_runtime.stack.push(static_cast<U64>(lhs % rhs));
1002 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
1005 I64 rhs = this->m_runtime.stack.pop<I64>();
1009 I64 lhs = this->m_runtime.stack.pop<I64>();
1013 this->m_runtime.stack.push(static_cast<I64>(0));
1016 I64 res =
static_cast<I64
>(lhs % rhs);
1021 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
1024 this->m_runtime.stack.push(res);
1028 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1031 F64 rhs = this->m_runtime.stack.pop<
F64>();
1032 F64 lhs = this->m_runtime.stack.pop<
F64>();
1033 this->m_runtime.stack.push(static_cast<F64>(lhs + rhs));
1037 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1040 F64 rhs = this->m_runtime.stack.pop<
F64>();
1041 F64 lhs = this->m_runtime.stack.pop<
F64>();
1042 this->m_runtime.stack.push(static_cast<F64>(lhs - rhs));
1046 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1049 F64 rhs = this->m_runtime.stack.pop<
F64>();
1050 F64 lhs = this->m_runtime.stack.pop<
F64>();
1051 this->m_runtime.stack.push(static_cast<F64>(lhs * rhs));
1055 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1058 F64 rhs = this->m_runtime.stack.pop<
F64>();
1059 F64 lhs = this->m_runtime.stack.pop<
F64>();
1060 this->m_runtime.stack.push(static_cast<F64>(lhs / rhs));
1064 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1067 F64 rhs = this->m_runtime.stack.pop<
F64>();
1068 F64 lhs = this->m_runtime.stack.pop<
F64>();
1069 this->m_runtime.stack.push(static_cast<F64>(pow(lhs, rhs)));
1073 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1076 F64 val = this->m_runtime.stack.pop<
F64>();
1080 this->m_runtime.stack.push(static_cast<F64>(log(val)));
1084 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
1087 F64 rhs = this->m_runtime.stack.pop<
F64>();
1088 F64 lhs = this->m_runtime.stack.pop<
F64>();
1091 F64 res = std::fmod(lhs, rhs);
1095 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
1097 }
else if (res == 0) {
1100 res = std::copysign(0.0, rhs);
1102 this->m_runtime.stack.push(res);
1106 if (this->m_runtime.stack.size <
sizeof(
I8)) {
1109 I8 src = this->m_runtime.stack.pop<
I8>();
1110 this->m_runtime.stack.push(static_cast<I64>(src));
1114 if (this->m_runtime.stack.size <
sizeof(I16)) {
1117 I16 src = this->m_runtime.stack.pop<I16>();
1118 this->m_runtime.stack.push(static_cast<I64>(src));
1122 if (this->m_runtime.stack.size <
sizeof(I32)) {
1125 I32 src = this->m_runtime.stack.pop<I32>();
1126 this->m_runtime.stack.push(static_cast<I64>(src));
1130 if (this->m_runtime.stack.size <
sizeof(
U8)) {
1133 U8 src = this->m_runtime.stack.pop<
U8>();
1134 this->m_runtime.stack.push(static_cast<U64>(src));
1138 if (this->m_runtime.stack.size <
sizeof(U16)) {
1141 U16 src = this->m_runtime.stack.pop<U16>();
1142 this->m_runtime.stack.push(static_cast<U64>(src));
1146 if (this->m_runtime.stack.size <
sizeof(U32)) {
1149 U32 src = this->m_runtime.stack.pop<U32>();
1150 this->m_runtime.stack.push(static_cast<U64>(src));
1154 if (this->m_runtime.stack.size <
sizeof(U64)) {
1157 U64 src = this->m_runtime.stack.pop<U64>();
1158 this->m_runtime.stack.push(static_cast<U8>(src));
1162 if (this->m_runtime.stack.size <
sizeof(U64)) {
1165 U64 src = this->m_runtime.stack.pop<U64>();
1166 this->m_runtime.stack.push(static_cast<U16>(src));
1170 if (this->m_runtime.stack.size <
sizeof(U64)) {
1173 U64 src = this->m_runtime.stack.pop<U64>();
1174 this->m_runtime.stack.push(static_cast<U32>(src));
1178 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1181 F64 val = this->m_runtime.stack.pop<
F64>();
1184 this->m_runtime.stack.push(std::floor(val));
1188 if (this->m_runtime.stack.size <
sizeof(I64)) {
1191 I64 val = this->m_runtime.stack.pop<I64>();
1196 this->m_runtime.stack.push(val < 0 ? -val : val);
1200 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1203 F64 val = this->m_runtime.stack.pop<
F64>();
1206 this->m_runtime.stack.push(std::fabs(val));
1209 Signal FpySequencer::stackOp_directiveHandler(
const FpySequencer_StackOpDirective& directive,
DirectiveError& error) {
1213 static_cast<FwAssertArgType>(directive.get__op()));
1215 switch (directive.get__op()) {
1217 error = this->op_or();
1220 error = this->op_and();
1223 error = this->op_ieq();
1226 error = this->op_ine();
1229 error = this->op_ult();
1232 error = this->op_ule();
1235 error = this->op_ugt();
1238 error = this->op_uge();
1241 error = this->op_slt();
1244 error = this->op_sle();
1247 error = this->op_sgt();
1250 error = this->op_sge();
1253 error = this->op_feq();
1256 error = this->op_fne();
1259 error = this->op_flt();
1262 error = this->op_fle();
1265 error = this->op_fgt();
1268 error = this->op_fge();
1271 error = this->op_not();
1274 error = this->op_fpext();
1277 error = this->op_fptrunc();
1280 error = this->op_fptosi();
1283 error = this->op_fptoui();
1286 error = this->op_sitofp();
1289 error = this->op_uitofp();
1292 error = this->op_add();
1295 error = this->op_sub();
1298 error = this->op_mul();
1301 error = this->op_udiv();
1304 error = this->op_sdiv();
1307 error = this->op_umod();
1310 error = this->op_smod();
1313 error = this->op_fadd();
1316 error = this->op_fsub();
1319 error = this->op_fmul();
1322 error = this->op_fdiv();
1325 error = this->op_fpow();
1328 error = this->op_flog();
1331 error = this->op_fmod();
1334 error = this->op_siext_8_64();
1337 error = this->op_siext_16_64();
1340 error = this->op_siext_32_64();
1343 error = this->op_ziext_8_64();
1346 error = this->op_ziext_16_64();
1349 error = this->op_ziext_32_64();
1352 error = this->op_itrunc_64_8();
1355 error = this->op_itrunc_64_16();
1358 error = this->op_itrunc_64_32();
1361 error = this->op_ffloor();
1364 error = this->op_iabs();
1367 error = this->op_fabs();
1379 Signal FpySequencer::exit_directiveHandler(
const FpySequencer_ExitDirective& directive,
DirectiveError& error) {
1380 if (this->m_runtime.stack.size <
sizeof(I32)) {
1384 I32 errorCode = this->m_runtime.stack.pop<I32>();
1386 if (errorCode == 0) {
1398 Signal FpySequencer::allocate_directiveHandler(
const FpySequencer_AllocateDirective& directive,
DirectiveError& error) {
1403 this->m_runtime.stack.pushZeroes(directive.get_size());
1409 if (this->m_runtime.stack.size < size) {
1417 if (destOffset > newStackSize || size > newStackSize - destOffset) {
1422 this->m_runtime.stack.copy(destOffset, this->m_runtime.stack.size - size, size);
1423 this->m_runtime.stack.size = newStackSize;
1435 if (srcOffset > this->m_runtime.stack.size || size > this->m_runtime.stack.size - srcOffset) {
1440 this->m_runtime.stack.copy(this->m_runtime.stack.size, srcOffset, size);
1441 this->m_runtime.stack.size += size;
1445 Signal FpySequencer::storeRelConstOffset_directiveHandler(
const FpySequencer_StoreRelConstOffsetDirective& directive,
1447 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1452 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1455 Signal FpySequencer::loadRel_directiveHandler(
const FpySequencer_LoadRelDirective& directive,
DirectiveError& error) {
1456 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1461 return this->loadHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1464 Signal FpySequencer::pushVal_directiveHandler(
const FpySequencer_PushValDirective& directive,
DirectiveError& error) {
1470 this->m_runtime.stack.push(const_cast<U8*>(directive.get_val()),
1471 static_cast<Fpy::StackSizeType>(directive.get__valSize()));
1475 Signal FpySequencer::discard_directiveHandler(
const FpySequencer_DiscardDirective& directive,
DirectiveError& error) {
1476 if (this->m_runtime.stack.size < directive.get_size()) {
1481 this->m_runtime.stack.size -= directive.get_size();
1485 Signal FpySequencer::memCmp_directiveHandler(
const FpySequencer_MemCmpDirective& directive,
DirectiveError& error) {
1494 if (this->m_runtime.stack.size < directive.get_size() * 2) {
1500 U64 lhsOffset = this->m_runtime.stack.size - directive.get_size() * 2;
1501 U64 rhsOffset = this->m_runtime.stack.size - directive.get_size();
1506 this->m_runtime.stack.size -= directive.get_size() * 2;
1509 if (memcmp(this->m_runtime.stack.bytes + lhsOffset, this->m_runtime.stack.bytes + rhsOffset,
1510 directive.get_size()) == 0) {
1518 Signal FpySequencer::stackCmd_directiveHandler(
const FpySequencer_StackCmdDirective& directive,
DirectiveError& error) {
1521 if (this->m_runtime.stack.size <
sizeof(
FwOpcodeType) ||
1522 this->m_runtime.stack.size -
sizeof(
FwOpcodeType) < directive.get_argsSize()) {
1531 U64 argBufOffset = this->m_runtime.stack.size - directive.get_argsSize();
1534 this->m_runtime.currentCmdOpcode = opcode;
1537 this->m_runtime.stack.size -= directive.get_argsSize();
1547 if (this->sendCmd(opcode, this->m_runtime.stack.bytes + argBufOffset, directive.get_argsSize()) ==
1559 Signal FpySequencer::pushTime_directiveHandler(
const FpySequencer_PushTimeDirective& directive,
DirectiveError& error) {
1575 this->m_runtime.stack.push(timeEsb.getBuffAddr(),
static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
1579 Signal FpySequencer::setSeed_directiveHandler(
const FpySequencer_SetSeedDirective& directive,
DirectiveError& error) {
1580 if (this->m_runtime.stack.size <
sizeof(U32)) {
1585 U32 seed = this->m_runtime.stack.pop<U32>();
1586 this->m_runtime.rng.seed(seed);
1587 this->m_runtime.rngSeeded =
true;
1591 Signal FpySequencer::pushRand_directiveHandler(
const FpySequencer_PushRandDirective& directive,
DirectiveError& error) {
1597 if (!this->m_runtime.rngSeeded) {
1599 std::seed_seq seedSeq{
static_cast<U32
>(currentTime.
getTimeBase()), static_cast<U32>(currentTime.
getContext()),
1601 this->m_runtime.rng.seed(seedSeq);
1602 this->m_runtime.rngSeeded =
true;
1605 U32 randVal =
static_cast<U32
>(this->m_runtime.rng());
1606 this->m_runtime.stack.push(randVal);
1610 Signal FpySequencer::getField_directiveHandler(
const FpySequencer_GetFieldDirective& directive,
DirectiveError& error) {
1618 if (this->m_runtime.stack.size -
sizeof(
Fpy::StackSizeType) < directive.get_parentSize()) {
1627 if (offset > directive.get_parentSize() || directive.get_memberSize() > directive.get_parentSize() - offset) {
1638 Fpy::StackSizeType parentStartOffset = this->m_runtime.stack.size - directive.get_parentSize();
1641 this->m_runtime.stack.move(parentStartOffset, parentStartOffset + offset, directive.get_memberSize());
1643 this->m_runtime.stack.size -= (directive.get_parentSize() - directive.get_memberSize());
1647 Signal FpySequencer::peek_directiveHandler(
const FpySequencer_PeekDirective& directive,
DirectiveError& error) {
1658 if (offset > this->m_runtime.stack.size) {
1671 if (byteCount > this->m_runtime.stack.size - offset) {
1677 U8* src = this->m_runtime.stack.top() - offset - byteCount;
1678 this->m_runtime.stack.push(src, byteCount);
1682 Signal FpySequencer::storeRel_directiveHandler(
const FpySequencer_StoreRelDirective& directive,
DirectiveError& error) {
1695 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + lvarOffset;
1700 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1703 Signal FpySequencer::call_directiveHandler(
const FpySequencer_CallDirective& directive,
DirectiveError& error) {
1705 if (this->m_runtime.stack.size <
sizeof(U32)) {
1711 U32 target = this->m_runtime.stack.pop<U32>();
1726 U32 returnAddr = this->m_runtime.nextStatementIndex;
1729 this->m_runtime.nextStatementIndex = target;
1732 this->m_runtime.stack.push<U32>(returnAddr);
1735 this->m_runtime.stack.push<
Fpy::StackSizeType>(this->m_runtime.stack.currentFrameStart);
1738 this->m_runtime.stack.currentFrameStart = this->m_runtime.stack.size;
1743 Signal FpySequencer::return_directiveHandler(
const FpySequencer_ReturnDirective& directive,
DirectiveError& error) {
1748 if (this->m_runtime.stack.size < returnValSize) {
1755 const Fpy::StackSizeType returnValOffset = this->m_runtime.stack.size - returnValSize;
1758 if (this->m_runtime.stack.currentFrameStart > this->m_runtime.stack.size) {
1762 this->m_runtime.stack.size = this->m_runtime.stack.currentFrameStart;
1774 U32 returnAddr = this->m_runtime.stack.pop<U32>();
1777 if (savedFramePtr > this->m_runtime.stack.size) {
1781 this->m_runtime.stack.currentFrameStart = savedFramePtr;
1790 this->m_runtime.nextStatementIndex = returnAddr;
1793 if (this->m_runtime.stack.size < callArgsSize) {
1798 this->m_runtime.stack.size -= callArgsSize;
1805 if (returnValSize > 0) {
1808 (void)memmove(this->m_runtime.stack.top(), &this->m_runtime.stack.bytes[returnValOffset], returnValSize);
1809 this->m_runtime.stack.size += returnValSize;
1815 Signal FpySequencer::loadAbs_directiveHandler(
const FpySequencer_LoadAbsDirective& directive,
DirectiveError& error) {
1816 return this->loadHelper(directive.get_globalOffset(), directive.get_size(), error);
1819 Signal FpySequencer::storeAbs_directiveHandler(
const FpySequencer_StoreAbsDirective& directive,
DirectiveError& error) {
1833 return this->storeHelper(globalOffset, size, error);
1836 Signal FpySequencer::storeAbsConstOffset_directiveHandler(
const FpySequencer_StoreAbsConstOffsetDirective& directive,
1838 return this->storeHelper(directive.get_globalOffset(), directive.get_size(), error);
1841 Signal FpySequencer::popEvent_directiveHandler(
const FpySequencer_PopEventDirective& directive,
DirectiveError& error) {
1852 if (this->m_runtime.stack.size < severitySize || this->m_runtime.stack.size - severitySize < messageSize) {
1863 if (messageSize > clampedSize) {
1865 FW_ASSERT(this->m_runtime.stack.size >= excess, static_cast<FwAssertArgType>(this->m_runtime.stack.size),
1866 static_cast<FwAssertArgType>(excess));
1867 this->m_runtime.stack.size -= excess;
1869 this->m_runtime.stack.pop(messageBuf, clampedSize);
1870 messageBuf[clampedSize] =
'\0';
1876 Fw::String messageStr(reinterpret_cast<const char*>(messageBuf));
1909 Signal FpySequencer::popSerializable_directiveHandler(
const FpySequencer_PopSerializableDirective& directive,
1916 const FwIndexType portIndex = directive.get_portIndex();
1919 if (portIndex < 0 || portIndex >= MAX_PORTS) {
1931 if (this->m_runtime.stack.size < directive.get_size()) {
1937 U8* dataPtr = this->m_runtime.stack.top() - directive.get_size();
1953 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 ...