Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into issue-524
Browse files Browse the repository at this point in the history
  • Loading branch information
bocchino committed Dec 3, 2024
2 parents cd01c06 + a54dc13 commit 61669a7
Show file tree
Hide file tree
Showing 17 changed files with 148 additions and 81 deletions.
18 changes: 4 additions & 14 deletions .github/workflows/native-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,13 @@ jobs:
matrix = {
"run": [
{
"runner": "macos-12",
"tag": "macosx_12_0_universal2"
"runner": "macos-13",
"tag": "macosx_13_0_universal2"
},
{
"runner": "ubuntu-22.04",
"tag": "manylinux2014_x86_64",
"container": "quay.io/pypa/manylinux2014_x86_64"
"tag": "manylinux_2_28_x86_64",
"container": "quay.io/pypa/manylinux_2_28_x86_64"
}
]
}
Expand All @@ -131,16 +131,6 @@ jobs:
container:
image: ${{ matrix.run.container || '' }}
steps:
- name: "Fix environment"
run: |
# https://github.com/actions/checkout/issues/1809
# https://github.blog/changelog/2024-03-07-github-actions-all-actions-will-run-on-node20-instead-of-node16-by-default/
#
# NOTE: actions/checkout et al. @v3 are deprecated - however the manylinux2014_x86_64 Docker image does not have node20
# which prevents from upgrading to @v4. We keep the deprecated versions (@v3) for now for lack of a better solution
echo "ACTIONS_RUNNER_FORCED_INTERNAL_NODE_VERSION=node16" >> $GITHUB_ENV
echo "ACTIONS_RUNNER_FORCE_ACTIONS_NODE_VERSION=node16" >> $GITHUB_ENV
echo "ACTIONS_ALLOW_USE_UNSECURE_NODE_VERSION=true" >> $GITHUB_ENV
- name: "Checkout repository"
uses: actions/checkout@v3
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,8 @@ case class ComponentStateMachines(
def getFunctionMembers: List[CppDoc.Class.Member] = {
List.concat(
getOverflowHooks,
getSignalSendMember
getSignalSendFunctions,
getStateGetterFunctions
)
}

Expand Down Expand Up @@ -131,8 +132,8 @@ case class ComponentStateMachines(
CppDoc.Lines.Hpp
)

private def getSignalSendMember: List[CppDoc.Class.Member] = {
lazy val members = stateMachineInstances.map { smi =>
private def getSignalSendFunctions: List[CppDoc.Class.Member] = {
val members = stateMachineInstances.map { smi =>

val serializeCode =
lines(
Expand Down Expand Up @@ -194,11 +195,31 @@ case class ComponentStateMachines(

addAccessTagAndComment(
"PROTECTED",
"State machine function to push signals to the input queue",
guardedList (hasStateMachineInstances) (members)
"Functions for sending sending state machine signals to the input queue",
members
)
}

private def getStateGetterFunctions: List[CppDoc.Class.Member] = {
val members = stateMachineInstances.map { smi =>

val smiName = smi.getName
val smName = s.writeSymbol(smi.symbol)
val smEnumName = s"$smName::${s.getName(smi.symbol)}_States";
functionClassMember(
Some(s"Get the state of state machine instance $smiName"),
s"${smiName}_getState",
Nil,
CppDoc.Type(smEnumName, Some(smEnumName)),
lines(s"return this->m_stateMachine_$smiName.state;"),
CppDoc.Function.NonSV,
CppDoc.Function.Const
)
}

addAccessTagAndComment("PROTECTED", "State getter functions", members)
}

private def writeStateMachineUpdate: List[Line] =
Line.blank ::
line("// Call the state machine update function") ::
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,8 @@ abstract class TopologyCppWriterUtils(
def getComponentNameAsQualIdent(ci: ComponentInstance): String =
getNameAsQualIdent(getComponentName(ci))

def getShortName(name: Name.Qualified): Name.Qualified = {
val ens = s.a.getEnclosingNames(symbol)
name.shortName(ens)
}

def getNameAsQualIdent(name: Name.Qualified): String =
CppWriter.writeQualifiedName(getShortName(name))
CppWriter.writeQualifiedName(name)

def getSpecifierForPhase (phase: Int) (ci: ComponentInstance):
Option[InitSpecifier] = ci.initSpecifierMap.get(phase)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ namespace M {
}

// ----------------------------------------------------------------------
// State machine function to push signals to the input queue
// Functions for sending sending state machine signals to the input queue
// ----------------------------------------------------------------------

void ActiveStateMachinesComponentBase ::
Expand Down Expand Up @@ -442,6 +442,46 @@ namespace M {
);
}

// ----------------------------------------------------------------------
// State getter functions
// ----------------------------------------------------------------------

M::ActiveStateMachines_S1::ActiveStateMachines_S1_States ActiveStateMachinesComponentBase ::
sm1_getState() const
{
return this->m_stateMachine_sm1.state;
}

M::ActiveStateMachines_S1::ActiveStateMachines_S1_States ActiveStateMachinesComponentBase ::
sm2_getState() const
{
return this->m_stateMachine_sm2.state;
}

M::ActiveStateMachines_S2::ActiveStateMachines_S2_States ActiveStateMachinesComponentBase ::
sm3_getState() const
{
return this->m_stateMachine_sm3.state;
}

M::ActiveStateMachines_S2::ActiveStateMachines_S2_States ActiveStateMachinesComponentBase ::
sm4_getState() const
{
return this->m_stateMachine_sm4.state;
}

M::ActiveStateMachines_S2::ActiveStateMachines_S2_States ActiveStateMachinesComponentBase ::
sm5_getState() const
{
return this->m_stateMachine_sm5.state;
}

M::ActiveStateMachines_S2::ActiveStateMachines_S2_States ActiveStateMachinesComponentBase ::
sm6_getState() const
{
return this->m_stateMachine_sm6.state;
}

// ----------------------------------------------------------------------
// Message dispatch functions
// ----------------------------------------------------------------------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ namespace M {
PROTECTED:

// ----------------------------------------------------------------------
// State machine function to push signals to the input queue
// Functions for sending sending state machine signals to the input queue
// ----------------------------------------------------------------------

//! State machine base-class function for sendSignals
Expand Down Expand Up @@ -131,6 +131,30 @@ namespace M {
const Fw::SmSignalBuffer& data //!< The state machine data
);

PROTECTED:

// ----------------------------------------------------------------------
// State getter functions
// ----------------------------------------------------------------------

//! Get the state of state machine instance sm1
M::ActiveStateMachines_S1::ActiveStateMachines_S1_States sm1_getState() const;

//! Get the state of state machine instance sm2
M::ActiveStateMachines_S1::ActiveStateMachines_S1_States sm2_getState() const;

//! Get the state of state machine instance sm3
M::ActiveStateMachines_S2::ActiveStateMachines_S2_States sm3_getState() const;

//! Get the state of state machine instance sm4
M::ActiveStateMachines_S2::ActiveStateMachines_S2_States sm4_getState() const;

//! Get the state of state machine instance sm5
M::ActiveStateMachines_S2::ActiveStateMachines_S2_States sm5_getState() const;

//! Get the state of state machine instance sm6
M::ActiveStateMachines_S2::ActiveStateMachines_S2_States sm6_getState() const;

PRIVATE:

// ----------------------------------------------------------------------
Expand Down
2 changes: 1 addition & 1 deletion compiler/tools/fpp-to-cpp/test/fprime/generate_cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ cd `dirname $0`
echo "generating framework C++"

fpp_files=`find . -name '*.fpp'`
fpp-to-cpp -p $PWD $fpp_files
../../../../bin/fpp-to-cpp -p $PWD $fpp_files

# Move config files into place
for base in FppConstantsAc ProcTypeEnumAc
Expand Down
34 changes: 15 additions & 19 deletions compiler/tools/fpp-to-cpp/test/top/BasicTopologyAc.ref.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,20 @@
// Component instances
// ----------------------------------------------------------------------

namespace M {

Active active1(FW_OPTIONAL_NAME("active1"));

}

namespace M {
Active active2;

}

namespace M {

Active active3(FW_OPTIONAL_NAME("active3"));
M::Active active3(FW_OPTIONAL_NAME("active3"));

}

namespace M {

Passive passive1(FW_OPTIONAL_NAME("passive1"));
M::Passive passive1(FW_OPTIONAL_NAME("passive1"));

}

Expand All @@ -39,6 +33,8 @@ namespace M {

}

M::Active active1(FW_OPTIONAL_NAME("active1"));

namespace M {


Expand All @@ -60,19 +56,19 @@ namespace M {
// ----------------------------------------------------------------------

void initComponents(const TopologyState& state) {
M::active1.init(QueueSizes::M_active1, InstanceIds::M_active1);
M::active2.initSpecial();
M::active3.init(QueueSizes::M_active3, InstanceIds::M_active3);
M::passive1.init(InstanceIds::M_passive1);
M::passive2.init(InstanceIds::M_passive2);
active1.init(QueueSizes::active1, InstanceIds::active1);
}

void configComponents(const TopologyState& state) {
M::active2.config();
}

void setBaseIds() {
M::active1.setIdBase(BaseIds::M_active1);
active1.setIdBase(BaseIds::active1);
M::active2.setIdBase(BaseIds::M_active2);
M::active3.setIdBase(BaseIds::M_active3);
M::passive1.setIdBase(BaseIds::M_passive1);
Expand All @@ -84,7 +80,7 @@ namespace M {
// C1
M::passive1.set_p_OutputPort(
0,
M::active1.get_p_InputPort(0)
active1.get_p_InputPort(0)
);

// C2
Expand All @@ -107,31 +103,31 @@ namespace M {
}

void startTasks(const TopologyState& state) {
M::active1.start(
static_cast<Os::Task::ParamType>(Priorities::M_active1),
static_cast<Os::Task::ParamType>(StackSizes::M_active1),
static_cast<Os::Task::ParamType>(CPUs::M_active1),
static_cast<Os::Task::ParamType>(TaskIds::M_active1)
);
M::active2.startSpecial();
M::active3.start(
Os::Task::TASK_DEFAULT, // Default priority
Os::Task::TASK_DEFAULT, // Default stack size
Os::Task::TASK_DEFAULT, // Default CPU
static_cast<Os::Task::ParamType>(TaskIds::M_active3)
);
active1.start(
static_cast<Os::Task::ParamType>(Priorities::active1),
static_cast<Os::Task::ParamType>(StackSizes::active1),
static_cast<Os::Task::ParamType>(CPUs::active1),
static_cast<Os::Task::ParamType>(TaskIds::active1)
);
}

void stopTasks(const TopologyState& state) {
M::active1.exit();
M::active2.stopSpecial();
M::active3.exit();
active1.exit();
}

void freeThreads(const TopologyState& state) {
(void) M::active1.ActiveComponentBase::join();
M::active2.freeSpecial();
(void) M::active3.ActiveComponentBase::join();
(void) active1.ActiveComponentBase::join();
}

void tearDownComponents(const TopologyState& state) {
Expand Down
Loading

0 comments on commit 61669a7

Please sign in to comment.