diff --git a/StarsProj/Arg_Actions_Component/Arg_Actions_Component.cpp b/StarsProj/Arg_Actions_Component/Arg_Actions_Component.cpp new file mode 100644 index 0000000..01e1240 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/Arg_Actions_Component.cpp @@ -0,0 +1,112 @@ +// ====================================================================== +// \title Arg_Actions_Component.cpp +// \author watney +// \brief cpp file for Arg_Actions_Component component implementation class +// ====================================================================== + +#include "Arg_Actions_Component/Arg_Actions_Component.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Arg_Actions_Component ::Arg_Actions_Component(const char* const compName) + : Arg_Actions_ComponentComponentBase(compName), m_g1Value(false), m_g2Value(false), m_evCount(0) {} + +Arg_Actions_Component ::~Arg_Actions_Component() {} + +// ---------------------------------------------------------------------- +// Handler implementations for typed input ports +// ---------------------------------------------------------------------- + +void Arg_Actions_Component ::schedIn_handler(FwIndexType portNum, U32 context) { + // Send EV1 signal with incrementing U16 parameter + // Alternate g1 value to test guard behavior + m_g1Value = !m_g1Value; + argActionsState_sendSignal_EV1(static_cast(m_evCount++)); +} + +void Arg_Actions_Component ::schedIn2_handler(FwIndexType portNum, U32 context) { + // Send EV2 signal to test g2 guard + // Alternate g2 value to test guard behavior + m_g2Value = !m_g2Value; + argActionsState_sendSignal_EV2(); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_a1(SmId smId, + Components_Arg_Actions_FP::Signal signal, + U16 value) { + this->log_ACTIVITY_HI_a1Event(value); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_a2(SmId smId, Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_a2Event(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_foo(SmId smId, Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_fooEvent(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Entry(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s1EntryEvent(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Entry2(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s1Entry2Event(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Exit(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s1ExitEvent(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s1Exit2(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s1Exit2Event(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Entry(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s2EntryEvent(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Entry2(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s2Entry2Event(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Exit(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s2ExitEvent(); +} + +void Arg_Actions_Component ::Components_Arg_Actions_FP_action_s2Exit2(SmId smId, + Components_Arg_Actions_FP::Signal signal) { + this->log_ACTIVITY_HI_s2Exit2Event(); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool Arg_Actions_Component ::Components_Arg_Actions_FP_guard_g1(SmId smId, + Components_Arg_Actions_FP::Signal signal, + U16 value) const { + printf("---- g1 value = %d\n", value); + return m_g1Value; +} + +bool Arg_Actions_Component ::Components_Arg_Actions_FP_guard_g2(SmId smId, + Components_Arg_Actions_FP::Signal signal) const { + return m_g2Value; +} + +} // namespace Components diff --git a/StarsProj/Arg_Actions_Component/Arg_Actions_Component.fpp b/StarsProj/Arg_Actions_Component/Arg_Actions_Component.fpp new file mode 100644 index 0000000..2e65a31 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/Arg_Actions_Component.fpp @@ -0,0 +1,37 @@ +module Components { + include "Arg_Actions_FP_State_Machine.fppi" + + @ Component wrapper for Arg_Actions_FP state machine + active component Arg_Actions_Component { + + state machine instance argActionsState: Arg_Actions_FP + + async input port schedIn: Svc.Sched + async input port schedIn2: Svc.Sched + + event s1EntryEvent() severity activity high id 0 format "s1Entry Event" + event s1Entry2Event() severity activity high id 1 format "s1Entry2 Event" + event s1ExitEvent() severity activity high id 2 format "s1Exit Event" + event s1Exit2Event() severity activity high id 3 format "s1Exit2 Event" + event s2EntryEvent() severity activity high id 4 format "s2Entry Event" + event s2Entry2Event() severity activity high id 5 format "s2Entry2 Event" + event s2ExitEvent() severity activity high id 6 format "s2Exit Event" + event s2Exit2Event() severity activity high id 7 format "s2Exit2 Event" + event a1Event(value: U16) severity activity high id 8 format "a1 action with value {}" + event a2Event() severity activity high id 9 format "a2 Event" + event fooEvent() severity activity high id 10 format "foo Event" + + ############################################################################### + # Standard AC Ports: Required for Channels, Events, Commands, and Parameters # + ############################################################################### + @ Port for requesting the current time + time get port timeCaller + + @ Enables command handling + import Fw.Command + + @ Enables event handling + import Fw.Event + + } +} \ No newline at end of file diff --git a/StarsProj/Arg_Actions_Component/Arg_Actions_Component.hpp b/StarsProj/Arg_Actions_Component/Arg_Actions_Component.hpp new file mode 100644 index 0000000..b100e7c --- /dev/null +++ b/StarsProj/Arg_Actions_Component/Arg_Actions_Component.hpp @@ -0,0 +1,130 @@ +// ====================================================================== +// \title Arg_Actions_Component.hpp +// \author watney +// \brief hpp file for Arg_Actions_Component component implementation class +// ====================================================================== + +#ifndef Components_Arg_Actions_Component_HPP +#define Components_Arg_Actions_Component_HPP + +#include "Arg_Actions_Component/Arg_Actions_ComponentComponentAc.hpp" + +namespace Components { + +class Arg_Actions_Component final : public Arg_Actions_ComponentComponentBase { + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Arg_Actions_Component object + Arg_Actions_Component(const char* const compName //!< The component name + ); + + //! Destroy Arg_Actions_Component object + ~Arg_Actions_Component(); + + private: + // ---------------------------------------------------------------------- + // Handler implementations for typed input ports + // ---------------------------------------------------------------------- + + //! Handler implementation for schedIn + void schedIn_handler(FwIndexType portNum, //!< The port number + U32 context //!< The call order + ) override; + + //! Handler implementation for schedIn2 + void schedIn2_handler(FwIndexType portNum, //!< The port number + U32 context //!< The call order + ) override; + + private: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a1 of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_a1(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal, //!< The signal + U16 value //!< The value + ) override; + + //! Implementation for action a2 of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_a2(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action foo of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_foo(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s1Entry of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s1Entry(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s1Entry2 of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s1Entry2(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s1Exit of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s1Exit(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s1Exit2 of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s1Exit2(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s2Entry of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s2Entry(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s2Entry2 of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s2Entry2(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s2Exit of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s2Exit(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + //! Implementation for action s2Exit2 of state machine Components_Arg_Actions_FP + void Components_Arg_Actions_FP_action_s2Exit2(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) override; + + private: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g1 of state machine Components_Arg_Actions_FP + bool Components_Arg_Actions_FP_guard_g1(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal, //!< The signal + U16 value //!< The value + ) const override; + + //! Implementation for guard g2 of state machine Components_Arg_Actions_FP + bool Components_Arg_Actions_FP_guard_g2(SmId smId, //!< The state machine id + Components_Arg_Actions_FP::Signal signal //!< The signal + ) const override; + private: + // ---------------------------------------------------------------------- + // Member variables for guard state + // ---------------------------------------------------------------------- + bool m_g1Value; + bool m_g2Value; + U32 m_evCount; + +}; + +} // namespace Components + +#endif diff --git a/StarsProj/Arg_Actions_Component/Arg_Actions_FP.plantuml b/StarsProj/Arg_Actions_Component/Arg_Actions_FP.plantuml new file mode 100644 index 0000000..f401fac --- /dev/null +++ b/StarsProj/Arg_Actions_Component/Arg_Actions_FP.plantuml @@ -0,0 +1,20 @@ + +@startuml + +[*] --> S1 + +state S1 { + S1:Entry: s1Entry(); s1Entry2(); foo() + S1:Exit: s1Exit(); s1Exit2(); foo() +} + +state S2 { + S2:Entry: s2Entry(); s2Entry2(); foo() + S2:Exit: s2Exit(); s2Exit2() +} + +S1 --> S2: EV1[g1(U16)] +S1 --> S2: EV2[g2()] +S2 --> S1: EV1/a1(U16); a2(); foo() + +@enduml diff --git a/StarsProj/Arg_Actions_Component/Arg_Actions_FP_State_Machine.fppi b/StarsProj/Arg_Actions_Component/Arg_Actions_FP_State_Machine.fppi new file mode 100644 index 0000000..0a75d23 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/Arg_Actions_FP_State_Machine.fppi @@ -0,0 +1,35 @@ +state machine Arg_Actions_FP { + + action a1: U16 + action a2 + action foo + action s1Entry + action s1Entry2 + action s1Exit + action s1Exit2 + action s2Entry + action s2Entry2 + action s2Exit + action s2Exit2 + + guard g1: U16 + guard g2 + + signal EV1: U16 + signal EV2 + + initial enter S1 + state S1 { + entry do { s1Entry, s1Entry2, foo } + exit do { s1Exit, s1Exit2, foo } + on EV1 if g1 enter S2 + on EV2 if g2 enter S2 + } + + state S2 { + entry do { s2Entry, s2Entry2, foo } + exit do { s2Exit, s2Exit2 } + on EV1 do { a1, a2, foo } enter S1 + } + +} diff --git a/StarsProj/Arg_Actions_Component/CMakeLists.txt b/StarsProj/Arg_Actions_Component/CMakeLists.txt new file mode 100644 index 0000000..2fcdec6 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/CMakeLists.txt @@ -0,0 +1,34 @@ +#### +# F Prime CMakeLists.txt: +# +# SOURCES: list of source files (to be compiled) +# AUTOCODER_INPUTS: list of files to be passed to the autocoders +# DEPENDS: list of libraries that this module depends on +# +# More information in the F´ CMake API documentation: +# https://fprime.jpl.nasa.gov/latest/docs/reference/api/cmake/API/ +# +#### + +# Module names are derived from the path from the nearest project/library/framework +# root when not specifically overridden by the developer, i.e. the module defined by +# `MyProj/Some/Path/CMakeLists.txt` will be named `MyProj_Some_Path`. + +register_fprime_library( + AUTOCODER_INPUTS + "${CMAKE_CURRENT_LIST_DIR}/Arg_Actions_Component.fpp" + SOURCES + "${CMAKE_CURRENT_LIST_DIR}/Arg_Actions_Component.cpp" +# DEPENDS +# MyPackage_MyOtherModule +) + +### Unit Tests ### +register_fprime_ut( + AUTOCODER_INPUTS + "${CMAKE_CURRENT_LIST_DIR}/Arg_Actions_Component.fpp" + SOURCES + "${CMAKE_CURRENT_LIST_DIR}/test/ut/Arg_Actions_ComponentTestMain.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/Arg_Actions_ComponentTester.cpp" + UT_AUTO_HELPERS +) diff --git a/StarsProj/Arg_Actions_Component/autocode.sh b/StarsProj/Arg_Actions_Component/autocode.sh new file mode 100755 index 0000000..d08b7eb --- /dev/null +++ b/StarsProj/Arg_Actions_Component/autocode.sh @@ -0,0 +1,2 @@ +#!/bin/bash +../../autocoder/Stars.py -backend fprime -noImpl -model Arg_Actions_FP.plantuml diff --git a/StarsProj/Arg_Actions_Component/docs/sdd.md b/StarsProj/Arg_Actions_Component/docs/sdd.md new file mode 100644 index 0000000..640b792 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/docs/sdd.md @@ -0,0 +1,21 @@ +# Components::Arg_Actions_Component + +Component wrapper for Arg_Actions_FP state machine + +## Introduction + + + +## Requirements + +| Name | Description | Rationale | Validation | +|---|---|---|---| +| | | | | + +## Design + + + +## Configuration + + diff --git a/StarsProj/Arg_Actions_Component/temp_header_fix.txt b/StarsProj/Arg_Actions_Component/temp_header_fix.txt new file mode 100644 index 0000000..2e47403 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/temp_header_fix.txt @@ -0,0 +1,9 @@ + //! Handler implementation for schedIn + void schedIn_handler(FwIndexType portNum, //!< The port number + U32 context //!< The call order + ) override; + + //! Handler implementation for schedIn2 + void schedIn2_handler(FwIndexType portNum, //!< The port number + U32 context //!< The call order + ) override; diff --git a/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTestMain.cpp b/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTestMain.cpp new file mode 100644 index 0000000..a76df73 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTestMain.cpp @@ -0,0 +1,22 @@ +// ====================================================================== +// \title Arg_Actions_ComponentTestMain.cpp +// \author watney +// \brief cpp file for Arg_Actions_Component component test main function +// ====================================================================== + +#include "Arg_Actions_ComponentTester.hpp" + +TEST(Nominal, testTransitions) { + Components::Arg_Actions_ComponentTester tester; + tester.testTransitions(); +} + +TEST(Nominal, testEV2Transitions) { + Components::Arg_Actions_ComponentTester tester; + tester.testEV2Transitions(); +} + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + return RUN_ALL_TESTS(); +} diff --git a/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTester.cpp b/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTester.cpp new file mode 100644 index 0000000..b03b5aa --- /dev/null +++ b/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTester.cpp @@ -0,0 +1,109 @@ +// ====================================================================== +// \title Arg_Actions_ComponentTester.cpp +// \author watney +// \brief cpp file for Arg_Actions_Component component test harness implementation class +// ====================================================================== + +#include "Arg_Actions_ComponentTester.hpp" + +namespace Components { + +// ---------------------------------------------------------------------- +// Construction and destruction +// ---------------------------------------------------------------------- + +Arg_Actions_ComponentTester ::Arg_Actions_ComponentTester() + : Arg_Actions_ComponentGTestBase("Arg_Actions_ComponentTester", Arg_Actions_ComponentTester::MAX_HISTORY_SIZE), + component("Arg_Actions_Component") { + this->connectPorts(); + this->initComponents(); +} + +Arg_Actions_ComponentTester ::~Arg_Actions_ComponentTester() { + this->component.deinit(); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Arg_Actions_ComponentTester ::testTransitions() { + // Initial state should be S1 after initialization + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S1); + ASSERT_EVENTS_s1EntryEvent_SIZE(1); + + // Send EV1 (g1 toggles to true, guard passes, S1->S2) + invoke_to_schedIn(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S2); + ASSERT_EVENTS_s2EntryEvent_SIZE(1); + + // Send EV1 from S2 (no guard, always transitions S2->S1) + invoke_to_schedIn(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S1); + ASSERT_EVENTS_s1EntryEvent_SIZE(2); + + // Send EV1 again (g1 toggles to true, guard passes, S1->S2) + invoke_to_schedIn(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S2); + ASSERT_EVENTS_s2EntryEvent_SIZE(2); + + // Send EV1 from S2 (transition S2->S1) + invoke_to_schedIn(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S1); + ASSERT_EVENTS_s1EntryEvent_SIZE(3); +} + +void Arg_Actions_ComponentTester ::testEV2Transitions() { + // Initial state should be S1 after initialization + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S1); + clearHistory(); + + // Send EV2 (g2 toggles to true, guard passes, S1->S2) + invoke_to_schedIn2(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S2); + ASSERT_EVENTS_s2EntryEvent_SIZE(1); + + // Send EV1 from S2 to return to S1 (no guard, always transitions S2->S1) + invoke_to_schedIn(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S1); + clearHistory(); + + // Send EV2 with g2=false (should stay in S1) + invoke_to_schedIn2(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S1); + ASSERT_EVENTS_s2EntryEvent_SIZE(0); // Should not have entered S2 + + // Send EV2 with g2=true again (should transition to S2) + invoke_to_schedIn2(0, 0); + dispatchAll(); + ASSERT_EQ(component.argActionsState_getState(), Components::Arg_Actions_FP_State::S2); + ASSERT_EVENTS_s2EntryEvent_SIZE(1); +} + +void Arg_Actions_ComponentTester::dispatchAll() +{ + while (this->component.m_queue.getMessagesAvailable() > 0) + this->component.doDispatch(); +} + +void Arg_Actions_ComponentTester::textLogIn( + FwEventIdType id, //!< The event ID + const Fw::Time& timeTag, //!< The time + const Fw::LogSeverity severity, //!< The severity + const Fw::TextLogString& text //!< The event string +) { + TextLogEntry e = {id, timeTag, severity, text}; + printTextLogHistoryEntry(e, stdout); +} + + +} // namespace Components diff --git a/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTester.hpp b/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTester.hpp new file mode 100644 index 0000000..9ea03d8 --- /dev/null +++ b/StarsProj/Arg_Actions_Component/test/ut/Arg_Actions_ComponentTester.hpp @@ -0,0 +1,83 @@ +// ====================================================================== +// \title Arg_Actions_ComponentTester.hpp +// \author watney +// \brief hpp file for Arg_Actions_Component component test harness implementation class +// ====================================================================== + +#ifndef Components_Arg_Actions_ComponentTester_HPP +#define Components_Arg_Actions_ComponentTester_HPP + +#include "Arg_Actions_Component/Arg_Actions_Component.hpp" +#include "Arg_Actions_Component/Arg_Actions_ComponentGTestBase.hpp" + +namespace Components { + +class Arg_Actions_ComponentTester final : public Arg_Actions_ComponentGTestBase { + public: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + // Maximum size of histories storing events, telemetry, and port outputs + static const FwSizeType MAX_HISTORY_SIZE = 10; + + // Instance ID supplied to the component instance under test + static const FwEnumStoreType TEST_INSTANCE_ID = 0; + + // Queue depth supplied to the component instance under test + static const FwSizeType TEST_INSTANCE_QUEUE_DEPTH = 10; + + public: + // ---------------------------------------------------------------------- + // Construction and destruction + // ---------------------------------------------------------------------- + + //! Construct object Arg_Actions_ComponentTester + Arg_Actions_ComponentTester(); + + //! Destroy object Arg_Actions_ComponentTester + ~Arg_Actions_ComponentTester(); + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test state transitions with EV1 + void testTransitions(); + + //! Test state transitions with EV2 + void testEV2Transitions(); + + private: + // ---------------------------------------------------------------------- + // Helper functions + // ---------------------------------------------------------------------- + + //! Connect ports + void connectPorts(); + + //! Initialize components + void initComponents(); + + void textLogIn( + FwEventIdType id, //!< The event ID + const Fw::Time& timeTag, //!< The time + const Fw::LogSeverity severity, //!< The severity + const Fw::TextLogString& text //!< The event string + ); + + void dispatchAll(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The component under test + Arg_Actions_Component component; +}; + +} // namespace Components + +#endif diff --git a/StarsProj/CMakeLists.txt b/StarsProj/CMakeLists.txt index 4acad66..5f2df77 100644 --- a/StarsProj/CMakeLists.txt +++ b/StarsProj/CMakeLists.txt @@ -16,5 +16,5 @@ fprime_setup_included_code() # This includes project-wide objects -add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Starsproj") add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Simple_Component/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Arg_Actions_Component/") diff --git a/StarsProj/Starsproj/CMakeLists.txt b/StarsProj/Starsproj/CMakeLists.txt deleted file mode 100644 index ba74208..0000000 --- a/StarsProj/Starsproj/CMakeLists.txt +++ /dev/null @@ -1,4 +0,0 @@ -# This CMake file is intended to register project-wide objects. -# This allows for reuse between deployments, or other projects. - -add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/Components") diff --git a/StarsProj/Starsproj/Components/CMakeLists.txt b/StarsProj/Starsproj/Components/CMakeLists.txt deleted file mode 100644 index 5fa1a86..0000000 --- a/StarsProj/Starsproj/Components/CMakeLists.txt +++ /dev/null @@ -1,3 +0,0 @@ -# Include project-wide components here - -# add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/MyComponent") diff --git a/autocoder/fprime_backend/fppcoder.py b/autocoder/fprime_backend/fppcoder.py index 1c2d259..9f51ad2 100644 --- a/autocoder/fprime_backend/fppcoder.py +++ b/autocoder/fprime_backend/fppcoder.py @@ -257,12 +257,12 @@ def getStateMachineMethods(xmiModel: XmiModel): actionSet.add(format_funcs(child.exit, True)) if child.name == "TRANSITION": actionSet.add(format_funcs(child.action, True)) - guardSet.add(format_funcs(child.guard, False)) + guardSet.add(format_funcs(child.guard, True)) signalSet.add((child.event + getActionDataType(child.action))) if child.name == "JUNCTION": actionSet.add(format_funcs(child.ifAction, True)) actionSet.add(format_funcs(child.elseAction, True)) - guardSet.add(format_funcs(child.guard, False)) + guardSet.add(format_funcs(child.guard, True)) if child.name == "INITIAL": actionSet.add(format_funcs(child.action, True)) @@ -312,7 +312,7 @@ def generateCode(xmiModel: XmiModel): fppFile.write("\n") for guard in sorted(guards): - escaped_guard = escape_fpp_keyword(guard) + escaped_guard = escape_fpp_keyword(guard.split(':')[0].strip()) + (f": {guard.split(':', 1)[1].strip()}" if ':' in guard else "") fppFile.write(f" guard {escaped_guard}\n") fppFile.write("\n") diff --git a/models/TestModels/Arg_Actions_FP/Arg_Actions_FP_State_Machine.fppi b/models/TestModels/Arg_Actions_FP/Arg_Actions_FP_State_Machine.fppi new file mode 100644 index 0000000..0a75d23 --- /dev/null +++ b/models/TestModels/Arg_Actions_FP/Arg_Actions_FP_State_Machine.fppi @@ -0,0 +1,35 @@ +state machine Arg_Actions_FP { + + action a1: U16 + action a2 + action foo + action s1Entry + action s1Entry2 + action s1Exit + action s1Exit2 + action s2Entry + action s2Entry2 + action s2Exit + action s2Exit2 + + guard g1: U16 + guard g2 + + signal EV1: U16 + signal EV2 + + initial enter S1 + state S1 { + entry do { s1Entry, s1Entry2, foo } + exit do { s1Exit, s1Exit2, foo } + on EV1 if g1 enter S2 + on EV2 if g2 enter S2 + } + + state S2 { + entry do { s2Entry, s2Entry2, foo } + exit do { s2Exit, s2Exit2 } + on EV1 do { a1, a2, foo } enter S1 + } + +} diff --git a/models/TestModels/golden/Arg_Actions_FP/fprime.fppi b/models/TestModels/golden/Arg_Actions_FP/fprime.fppi index baa1ac5..0a75d23 100644 --- a/models/TestModels/golden/Arg_Actions_FP/fprime.fppi +++ b/models/TestModels/golden/Arg_Actions_FP/fprime.fppi @@ -12,7 +12,7 @@ state machine Arg_Actions_FP { action s2Exit action s2Exit2 - guard g1 + guard g1: U16 guard g2 signal EV1: U16