Skip to content

Commit

Permalink
Revise state machine code gen
Browse files Browse the repository at this point in the history
  • Loading branch information
bocchino committed Sep 4, 2024
1 parent e20c6fd commit a4e863d
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -63,16 +63,19 @@ case class ComponentStateMachines(
Line.blank ::
List.concat(
lines(
s"""|// Deserialize the state machine ID
s"""|// Deserialize the state machine ID to an FwEnumStoreType
|FwEnumStoreType enumStoreSmId = 0;
|Fw::SerializeStatus deserStatus = msg.deserialize(enumStoreSmId);
|FW_ASSERT(
| deserStatus == Fw::FW_SERIALIZE_OK,
| static_cast<FwAssertArgType>(deserStatus)
|);
|// Cast it to the correct type
|SmId stateMachineId = static_cast<SmId>(enumStoreSmId);
|
|// Deserialize the state machine signal
|// Deserialize the state machine signal to an FwEnumStoreType.
|// This value will be cast to the correct type in the
|// switch statement that calls the state machine update function.
|FwEnumStoreType enumStoreSmSignal = 0;
|deserStatus = msg.deserialize(enumStoreSmSignal);
|FW_ASSERT(
Expand Down Expand Up @@ -217,8 +220,7 @@ case class ComponentStateMachines(
}),
Line.blank :: lines(
s"""|default:
| FW_ASSERT(0, static_cast<FwAssertArgType>(stateMachineId));
| break;"""
| return MSG_DISPATCH_ERROR;"""
)
)
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -490,16 +490,19 @@ namespace M {
// Handle state machine signals
case STATEMACHINE_SENDSIGNALS: {

// Deserialize the state machine ID
// Deserialize the state machine ID to an FwEnumStoreType
FwEnumStoreType enumStoreSmId = 0;
Fw::SerializeStatus deserStatus = msg.deserialize(enumStoreSmId);
FW_ASSERT(
deserStatus == Fw::FW_SERIALIZE_OK,
static_cast<FwAssertArgType>(deserStatus)
);
// Cast it to the correct type
SmId stateMachineId = static_cast<SmId>(enumStoreSmId);

// Deserialize the state machine signal
// Deserialize the state machine signal to an FwEnumStoreType.
// This value will be cast to the correct type in the
// switch statement that calls the state machine update function.
FwEnumStoreType enumStoreSmSignal = 0;
deserStatus = msg.deserialize(enumStoreSmSignal);
FW_ASSERT(
Expand Down Expand Up @@ -568,8 +571,7 @@ namespace M {
}

default:
FW_ASSERT(0, static_cast<FwAssertArgType>(stateMachineId));
break;
return MSG_DISPATCH_ERROR;
}

break;
Expand Down

0 comments on commit a4e863d

Please sign in to comment.