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 if (uSeconds >= 1000000) {
316 wakeupTime.
add(seconds, uSeconds);
317 this->m_runtime.wakeupTime = wakeupTime;
322 Signal FpySequencer::waitAbs_directiveHandler(
const FpySequencer_WaitAbsDirective& directive,
DirectiveError& error) {
328 U32 uSeconds = this->m_runtime.stack.pop<U32>();
329 U32 seconds = this->m_runtime.stack.pop<U32>();
333 if (uSeconds >= 1000000) {
338 this->m_runtime.wakeupTime =
Fw::Time(static_cast<TimeBase::T>(base), ctx, seconds, uSeconds);
343 Signal FpySequencer::goto_directiveHandler(
const FpySequencer_GotoDirective& directive,
DirectiveError& error) {
349 m_runtime.nextStatementIndex = directive.get_statementIndex();
354 Signal FpySequencer::if_directiveHandler(
const FpySequencer_IfDirective& directive,
DirectiveError& error) {
355 if (this->m_runtime.stack.size < 1) {
365 if (this->m_runtime.stack.pop<
U8>() != 0) {
371 this->m_runtime.nextStatementIndex = directive.get_falseGotoStmtIndex();
375 Signal FpySequencer::noOp_directiveHandler(
const FpySequencer_NoOpDirective& directive,
DirectiveError& error) {
379 Signal FpySequencer::pushTlmVal_directiveHandler(
const FpySequencer_PushTlmValDirective& directive,
403 Signal FpySequencer::pushTlmValAndTime_directiveHandler(
const FpySequencer_PushTlmValAndTimeDirective& directive,
436 this->m_runtime.stack.push(timeEsb.getBuffAddr(),
static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
440 Signal FpySequencer::pushPrm_directiveHandler(
const FpySequencer_PushPrmDirective& directive,
DirectiveError& error) {
464 Signal FpySequencer::constCmd_directiveHandler(
const FpySequencer_ConstCmdDirective& directive,
DirectiveError& error) {
471 if (this->sendCmd(directive.get_opCode(), directive.get_argBuf(), directive.get__argBufSize()) ==
482 if (this->m_runtime.stack.size <
sizeof(
U8) * 2) {
485 this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<
U8>() | this->m_runtime.stack.pop<
U8>()));
489 if (this->m_runtime.stack.size <
sizeof(
U8) * 2) {
492 this->m_runtime.stack.push(static_cast<U8>(this->m_runtime.stack.pop<
U8>() & this->m_runtime.stack.pop<
U8>()));
496 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
499 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() == this->m_runtime.stack.pop<I64>())
505 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
508 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<I64>() != this->m_runtime.stack.pop<I64>())
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(U64) * 2) {
547 U64 rhs = this->m_runtime.stack.pop<U64>();
548 U64 lhs = this->m_runtime.stack.pop<U64>();
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(I64) * 2) {
587 I64 rhs = this->m_runtime.stack.pop<I64>();
588 I64 lhs = this->m_runtime.stack.pop<I64>();
594 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
597 F64 rhs = this->m_runtime.stack.pop<
F64>();
598 F64 lhs = this->m_runtime.stack.pop<
F64>();
605 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
608 F64 rhs = this->m_runtime.stack.pop<
F64>();
609 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>();
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>();
631 this->m_runtime.stack.push(static_cast<U8>(std::islessequal(lhs, rhs) ? static_cast<U8>(
FW_SERIALIZE_TRUE_VALUE)
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>();
646 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
649 F64 rhs = this->m_runtime.stack.pop<
F64>();
650 F64 lhs = this->m_runtime.stack.pop<
F64>();
651 this->m_runtime.stack.push(static_cast<U8>(std::isgreaterequal(lhs, rhs)
657 if (this->m_runtime.stack.size <
sizeof(
U8)) {
660 this->m_runtime.stack.push(static_cast<U8>((this->m_runtime.stack.pop<
U8>() == 0)
667 if (this->m_runtime.stack.size <
sizeof(
F32)) {
670 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<
F32>()));
675 if (this->m_runtime.stack.size <
sizeof(
F64)) {
678 this->m_runtime.stack.push(static_cast<F32>(this->m_runtime.stack.pop<
F64>()));
682 if (this->m_runtime.stack.size <
sizeof(
F64)) {
685 F64 val = this->m_runtime.stack.pop<
F64>();
690 const F64 bound = std::ldexp(1.0, 63);
692 if (std::isnan(val)) {
694 }
else if (val >= bound) {
695 result = std::numeric_limits<I64>::max();
696 }
else if (val < -bound) {
699 result =
static_cast<I64
>(val);
701 this->m_runtime.stack.push(result);
705 if (this->m_runtime.stack.size <
sizeof(I64)) {
708 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<I64>()));
712 if (this->m_runtime.stack.size <
sizeof(
F64)) {
715 F64 val = this->m_runtime.stack.pop<
F64>();
719 const F64 bound = std::ldexp(1.0, 64);
721 if (std::isnan(val) || val < 0.0) {
723 }
else if (val >= bound) {
724 result = std::numeric_limits<U64>::max();
726 result =
static_cast<U64
>(val);
728 this->m_runtime.stack.push(result);
732 if (this->m_runtime.stack.size <
sizeof(U64)) {
735 this->m_runtime.stack.push(static_cast<F64>(this->m_runtime.stack.pop<U64>()));
739 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
742 I64 rhs = this->m_runtime.stack.pop<I64>();
743 I64 lhs = this->m_runtime.stack.pop<I64>();
747 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() - rhs) < lhs)) {
755 this->m_runtime.stack.push(static_cast<I64>(lhs + rhs));
759 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
762 I64 rhs = this->m_runtime.stack.pop<I64>();
763 I64 lhs = this->m_runtime.stack.pop<I64>();
768 if ((rhs < 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() + rhs) < lhs)) {
777 this->m_runtime.stack.push(static_cast<I64>(lhs - rhs));
781 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
784 I64 rhs = this->m_runtime.stack.pop<I64>();
785 I64 lhs = this->m_runtime.stack.pop<I64>();
790 if ((rhs > 0) && (lhs > 0) && ((std::numeric_limits<I64>::max() / rhs) < lhs)) {
794 else if ((rhs < 0) && (lhs < 0) && (lhs < (std::numeric_limits<I64>::max() / rhs))) {
807 this->m_runtime.stack.push(static_cast<I64>(lhs * rhs));
811 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
814 U64 rhs = this->m_runtime.stack.pop<U64>();
815 U64 lhs = this->m_runtime.stack.pop<U64>();
820 this->m_runtime.stack.push(static_cast<U64>(lhs / rhs));
824 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
828 I64 rhs = this->m_runtime.stack.pop<I64>();
829 I64 lhs = this->m_runtime.stack.pop<I64>();
842 I64 quotient = lhs / rhs;
843 if (((lhs % rhs) != 0) && ((lhs < 0) != (rhs < 0))) {
846 this->m_runtime.stack.push(quotient);
850 if (this->m_runtime.stack.size <
sizeof(U64) * 2) {
853 U64 rhs = this->m_runtime.stack.pop<U64>();
857 U64 lhs = this->m_runtime.stack.pop<U64>();
858 this->m_runtime.stack.push(static_cast<U64>(lhs % rhs));
862 if (this->m_runtime.stack.size <
sizeof(I64) * 2) {
865 I64 rhs = this->m_runtime.stack.pop<I64>();
869 I64 lhs = this->m_runtime.stack.pop<I64>();
873 this->m_runtime.stack.push(static_cast<I64>(0));
876 I64 res =
static_cast<I64
>(lhs % rhs);
881 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
884 this->m_runtime.stack.push(res);
888 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
891 F64 rhs = this->m_runtime.stack.pop<
F64>();
892 F64 lhs = this->m_runtime.stack.pop<
F64>();
893 this->m_runtime.stack.push(static_cast<F64>(lhs + rhs));
897 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
900 F64 rhs = this->m_runtime.stack.pop<
F64>();
901 F64 lhs = this->m_runtime.stack.pop<
F64>();
902 this->m_runtime.stack.push(static_cast<F64>(lhs - rhs));
906 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
909 F64 rhs = this->m_runtime.stack.pop<
F64>();
910 F64 lhs = this->m_runtime.stack.pop<
F64>();
911 this->m_runtime.stack.push(static_cast<F64>(lhs * rhs));
915 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
918 F64 rhs = this->m_runtime.stack.pop<
F64>();
919 F64 lhs = this->m_runtime.stack.pop<
F64>();
920 this->m_runtime.stack.push(static_cast<F64>(lhs / rhs));
924 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
927 F64 rhs = this->m_runtime.stack.pop<
F64>();
928 F64 lhs = this->m_runtime.stack.pop<
F64>();
929 this->m_runtime.stack.push(static_cast<F64>(pow(lhs, rhs)));
933 if (this->m_runtime.stack.size <
sizeof(
F64)) {
936 F64 val = this->m_runtime.stack.pop<
F64>();
940 this->m_runtime.stack.push(static_cast<F64>(log(val)));
944 if (this->m_runtime.stack.size <
sizeof(
F64) * 2) {
947 F64 rhs = this->m_runtime.stack.pop<
F64>();
948 F64 lhs = this->m_runtime.stack.pop<
F64>();
951 F64 res = std::fmod(lhs, rhs);
955 if ((res > 0 && rhs < 0) || (res < 0 && rhs > 0)) {
957 }
else if (res == 0) {
960 res = std::copysign(0.0, rhs);
962 this->m_runtime.stack.push(res);
966 if (this->m_runtime.stack.size <
sizeof(
I8)) {
969 I8 src = this->m_runtime.stack.pop<
I8>();
970 this->m_runtime.stack.push(static_cast<I64>(src));
974 if (this->m_runtime.stack.size <
sizeof(I16)) {
977 I16 src = this->m_runtime.stack.pop<I16>();
978 this->m_runtime.stack.push(static_cast<I64>(src));
982 if (this->m_runtime.stack.size <
sizeof(I32)) {
985 I32 src = this->m_runtime.stack.pop<I32>();
986 this->m_runtime.stack.push(static_cast<I64>(src));
990 if (this->m_runtime.stack.size <
sizeof(
U8)) {
993 U8 src = this->m_runtime.stack.pop<
U8>();
994 this->m_runtime.stack.push(static_cast<U64>(src));
998 if (this->m_runtime.stack.size <
sizeof(U16)) {
1001 U16 src = this->m_runtime.stack.pop<U16>();
1002 this->m_runtime.stack.push(static_cast<U64>(src));
1006 if (this->m_runtime.stack.size <
sizeof(U32)) {
1009 U32 src = this->m_runtime.stack.pop<U32>();
1010 this->m_runtime.stack.push(static_cast<U64>(src));
1014 if (this->m_runtime.stack.size <
sizeof(U64)) {
1017 U64 src = this->m_runtime.stack.pop<U64>();
1018 this->m_runtime.stack.push(static_cast<U8>(src));
1022 if (this->m_runtime.stack.size <
sizeof(U64)) {
1025 U64 src = this->m_runtime.stack.pop<U64>();
1026 this->m_runtime.stack.push(static_cast<U16>(src));
1030 if (this->m_runtime.stack.size <
sizeof(U64)) {
1033 U64 src = this->m_runtime.stack.pop<U64>();
1034 this->m_runtime.stack.push(static_cast<U32>(src));
1038 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1041 F64 val = this->m_runtime.stack.pop<
F64>();
1044 this->m_runtime.stack.push(std::floor(val));
1048 if (this->m_runtime.stack.size <
sizeof(I64)) {
1051 I64 val = this->m_runtime.stack.pop<I64>();
1056 this->m_runtime.stack.push(val < 0 ? -val : val);
1060 if (this->m_runtime.stack.size <
sizeof(
F64)) {
1063 F64 val = this->m_runtime.stack.pop<
F64>();
1066 this->m_runtime.stack.push(std::fabs(val));
1069 Signal FpySequencer::stackOp_directiveHandler(
const FpySequencer_StackOpDirective& directive,
DirectiveError& error) {
1073 static_cast<FwAssertArgType>(directive.get__op()));
1075 switch (directive.get__op()) {
1077 error = this->op_or();
1080 error = this->op_and();
1083 error = this->op_ieq();
1086 error = this->op_ine();
1089 error = this->op_ult();
1092 error = this->op_ule();
1095 error = this->op_ugt();
1098 error = this->op_uge();
1101 error = this->op_slt();
1104 error = this->op_sle();
1107 error = this->op_sgt();
1110 error = this->op_sge();
1113 error = this->op_feq();
1116 error = this->op_fne();
1119 error = this->op_flt();
1122 error = this->op_fle();
1125 error = this->op_fgt();
1128 error = this->op_fge();
1131 error = this->op_not();
1134 error = this->op_fpext();
1137 error = this->op_fptrunc();
1140 error = this->op_fptosi();
1143 error = this->op_fptoui();
1146 error = this->op_sitofp();
1149 error = this->op_uitofp();
1152 error = this->op_add();
1155 error = this->op_sub();
1158 error = this->op_mul();
1161 error = this->op_udiv();
1164 error = this->op_sdiv();
1167 error = this->op_umod();
1170 error = this->op_smod();
1173 error = this->op_fadd();
1176 error = this->op_fsub();
1179 error = this->op_fmul();
1182 error = this->op_fdiv();
1185 error = this->op_fpow();
1188 error = this->op_flog();
1191 error = this->op_fmod();
1194 error = this->op_siext_8_64();
1197 error = this->op_siext_16_64();
1200 error = this->op_siext_32_64();
1203 error = this->op_ziext_8_64();
1206 error = this->op_ziext_16_64();
1209 error = this->op_ziext_32_64();
1212 error = this->op_itrunc_64_8();
1215 error = this->op_itrunc_64_16();
1218 error = this->op_itrunc_64_32();
1221 error = this->op_ffloor();
1224 error = this->op_iabs();
1227 error = this->op_fabs();
1239 Signal FpySequencer::exit_directiveHandler(
const FpySequencer_ExitDirective& directive,
DirectiveError& error) {
1240 if (this->m_runtime.stack.size <
sizeof(I32)) {
1244 I32 errorCode = this->m_runtime.stack.pop<I32>();
1246 if (errorCode == 0) {
1258 Signal FpySequencer::allocate_directiveHandler(
const FpySequencer_AllocateDirective& directive,
DirectiveError& error) {
1263 this->m_runtime.stack.pushZeroes(directive.get_size());
1269 if (this->m_runtime.stack.size < size) {
1277 if (destOffset > newStackSize || size > newStackSize - destOffset) {
1282 this->m_runtime.stack.copy(destOffset, this->m_runtime.stack.size - size, size);
1283 this->m_runtime.stack.size = newStackSize;
1295 if (srcOffset > this->m_runtime.stack.size || size > this->m_runtime.stack.size - srcOffset) {
1300 this->m_runtime.stack.copy(this->m_runtime.stack.size, srcOffset, size);
1301 this->m_runtime.stack.size += size;
1305 Signal FpySequencer::storeRelConstOffset_directiveHandler(
const FpySequencer_StoreRelConstOffsetDirective& directive,
1307 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1312 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1315 Signal FpySequencer::loadRel_directiveHandler(
const FpySequencer_LoadRelDirective& directive,
DirectiveError& error) {
1316 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + directive.get_lvarOffset();
1321 return this->loadHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1324 Signal FpySequencer::pushVal_directiveHandler(
const FpySequencer_PushValDirective& directive,
DirectiveError& error) {
1330 this->m_runtime.stack.push(const_cast<U8*>(directive.get_val()),
1331 static_cast<Fpy::StackSizeType>(directive.get__valSize()));
1335 Signal FpySequencer::discard_directiveHandler(
const FpySequencer_DiscardDirective& directive,
DirectiveError& error) {
1336 if (this->m_runtime.stack.size < directive.get_size()) {
1341 this->m_runtime.stack.size -= directive.get_size();
1345 Signal FpySequencer::memCmp_directiveHandler(
const FpySequencer_MemCmpDirective& directive,
DirectiveError& error) {
1354 if (this->m_runtime.stack.size < directive.get_size() * 2) {
1360 U64 lhsOffset = this->m_runtime.stack.size - directive.get_size() * 2;
1361 U64 rhsOffset = this->m_runtime.stack.size - directive.get_size();
1366 this->m_runtime.stack.size -= directive.get_size() * 2;
1369 if (memcmp(this->m_runtime.stack.bytes + lhsOffset, this->m_runtime.stack.bytes + rhsOffset,
1370 directive.get_size()) == 0) {
1378 Signal FpySequencer::stackCmd_directiveHandler(
const FpySequencer_StackCmdDirective& directive,
DirectiveError& error) {
1381 if (this->m_runtime.stack.size <
sizeof(
FwOpcodeType) ||
1382 this->m_runtime.stack.size -
sizeof(
FwOpcodeType) < directive.get_argsSize()) {
1391 U64 argBufOffset = this->m_runtime.stack.size - directive.get_argsSize();
1394 this->m_runtime.currentCmdOpcode = opcode;
1397 this->m_runtime.stack.size -= directive.get_argsSize();
1407 if (this->sendCmd(opcode, this->m_runtime.stack.bytes + argBufOffset, directive.get_argsSize()) ==
1419 Signal FpySequencer::pushTime_directiveHandler(
const FpySequencer_PushTimeDirective& directive,
DirectiveError& error) {
1435 this->m_runtime.stack.push(timeEsb.getBuffAddr(),
static_cast<Fpy::StackSizeType>(timeEsb.getSize()));
1439 Signal FpySequencer::setSeed_directiveHandler(
const FpySequencer_SetSeedDirective& directive,
DirectiveError& error) {
1440 if (this->m_runtime.stack.size <
sizeof(U32)) {
1445 U32 seed = this->m_runtime.stack.pop<U32>();
1446 this->m_runtime.rng.seed(seed);
1447 this->m_runtime.rngSeeded =
true;
1451 Signal FpySequencer::pushRand_directiveHandler(
const FpySequencer_PushRandDirective& directive,
DirectiveError& error) {
1457 if (!this->m_runtime.rngSeeded) {
1459 std::seed_seq seedSeq{
static_cast<U32
>(currentTime.
getTimeBase()), static_cast<U32>(currentTime.
getContext()),
1461 this->m_runtime.rng.seed(seedSeq);
1462 this->m_runtime.rngSeeded =
true;
1465 U32 randVal =
static_cast<U32
>(this->m_runtime.rng());
1466 this->m_runtime.stack.push(randVal);
1470 Signal FpySequencer::getField_directiveHandler(
const FpySequencer_GetFieldDirective& directive,
DirectiveError& error) {
1478 if (this->m_runtime.stack.size -
sizeof(
Fpy::StackSizeType) < directive.get_parentSize()) {
1487 if (offset > directive.get_parentSize() || directive.get_memberSize() > directive.get_parentSize() - offset) {
1498 Fpy::StackSizeType parentStartOffset = this->m_runtime.stack.size - directive.get_parentSize();
1501 this->m_runtime.stack.move(parentStartOffset, parentStartOffset + offset, directive.get_memberSize());
1503 this->m_runtime.stack.size -= (directive.get_parentSize() - directive.get_memberSize());
1507 Signal FpySequencer::peek_directiveHandler(
const FpySequencer_PeekDirective& directive,
DirectiveError& error) {
1518 if (offset > this->m_runtime.stack.size) {
1531 if (byteCount > this->m_runtime.stack.size - offset) {
1537 U8* src = this->m_runtime.stack.top() - offset - byteCount;
1538 this->m_runtime.stack.push(src, byteCount);
1542 Signal FpySequencer::storeRel_directiveHandler(
const FpySequencer_StoreRelDirective& directive,
DirectiveError& error) {
1555 I64 addr =
static_cast<I64
>(this->m_runtime.stack.currentFrameStart) + lvarOffset;
1560 return this->storeHelper(static_cast<Fpy::StackSizeType>(addr), directive.get_size(), error);
1563 Signal FpySequencer::call_directiveHandler(
const FpySequencer_CallDirective& directive,
DirectiveError& error) {
1565 if (this->m_runtime.stack.size <
sizeof(U32)) {
1571 U32 target = this->m_runtime.stack.pop<U32>();
1586 U32 returnAddr = this->m_runtime.nextStatementIndex;
1589 this->m_runtime.nextStatementIndex = target;
1592 this->m_runtime.stack.push<U32>(returnAddr);
1595 this->m_runtime.stack.push<
Fpy::StackSizeType>(this->m_runtime.stack.currentFrameStart);
1598 this->m_runtime.stack.currentFrameStart = this->m_runtime.stack.size;
1603 Signal FpySequencer::return_directiveHandler(
const FpySequencer_ReturnDirective& directive,
DirectiveError& error) {
1608 if (this->m_runtime.stack.size < returnValSize) {
1615 const Fpy::StackSizeType returnValOffset = this->m_runtime.stack.size - returnValSize;
1618 if (this->m_runtime.stack.currentFrameStart > this->m_runtime.stack.size) {
1622 this->m_runtime.stack.size = this->m_runtime.stack.currentFrameStart;
1634 U32 returnAddr = this->m_runtime.stack.pop<U32>();
1637 if (savedFramePtr > this->m_runtime.stack.size) {
1641 this->m_runtime.stack.currentFrameStart = savedFramePtr;
1650 this->m_runtime.nextStatementIndex = returnAddr;
1653 if (this->m_runtime.stack.size < callArgsSize) {
1658 this->m_runtime.stack.size -= callArgsSize;
1665 if (returnValSize > 0) {
1668 (void)memmove(this->m_runtime.stack.top(), &this->m_runtime.stack.bytes[returnValOffset], returnValSize);
1669 this->m_runtime.stack.size += returnValSize;
1675 Signal FpySequencer::loadAbs_directiveHandler(
const FpySequencer_LoadAbsDirective& directive,
DirectiveError& error) {
1676 return this->loadHelper(directive.get_globalOffset(), directive.get_size(), error);
1679 Signal FpySequencer::storeAbs_directiveHandler(
const FpySequencer_StoreAbsDirective& directive,
DirectiveError& error) {
1693 return this->storeHelper(globalOffset, size, error);
1696 Signal FpySequencer::storeAbsConstOffset_directiveHandler(
const FpySequencer_StoreAbsConstOffsetDirective& directive,
1698 return this->storeHelper(directive.get_globalOffset(), directive.get_size(), error);
1701 Signal FpySequencer::popEvent_directiveHandler(
const FpySequencer_PopEventDirective& directive,
DirectiveError& error) {
1712 if (this->m_runtime.stack.size < severitySize || this->m_runtime.stack.size - severitySize < messageSize) {
1723 if (messageSize > clampedSize) {
1725 FW_ASSERT(this->m_runtime.stack.size >= excess, static_cast<FwAssertArgType>(this->m_runtime.stack.size),
1726 static_cast<FwAssertArgType>(excess));
1727 this->m_runtime.stack.size -= excess;
1729 this->m_runtime.stack.pop(messageBuf, clampedSize);
1730 messageBuf[clampedSize] =
'\0';
1736 Fw::String messageStr(reinterpret_cast<const char*>(messageBuf));
1769 Signal FpySequencer::popSerializable_directiveHandler(
const FpySequencer_PopSerializableDirective& directive,
1776 const FwIndexType portIndex = directive.get_portIndex();
1779 if (portIndex < 0 || portIndex >= MAX_PORTS) {
1791 if (this->m_runtime.stack.size < directive.get_size()) {
1797 U8* dataPtr = this->m_runtime.stack.top() - directive.get_size();
1813 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.
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_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.
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.