From 02a351c6001816633f60c4b33d1fd1beb19dece9 Mon Sep 17 00:00:00 2001 From: Rob Bocchino Date: Mon, 6 Jan 2025 14:58:54 -0800 Subject: [PATCH] FPP v2.3.0a1 (#3066) * Update requirements to use new fpp version * Removed unneeded files * update FppTest for new autocoder changes * Get unit tests updated and working for fpp state machines phase 1 delivery * Rename Fw/SMTest to Fw/Sm * Update STARS to use FW_ASSERT * Rename SMSignalBuffer to SmSignalBuffer * Fix spelling issues with CI * Update requirements to the FPP alpha release v2.2.0a3 * Fix requirements.txt * Fix requirements.txt * Initialize data in the constructor of SmSignalBuffer * Add constructor list to all the constructors in SmSignalBuffer * Reorganize FppTest directories Move external state machine tests to state_machine/external * Add missing file * Reorganize FppTest/state_machine external --> external_instance * Add state machine test harness * Revise SmGuard * Fix include guard * Add header file for test harness * Revise Basic state machine * Revise Basic test * Add Junction test * Add missing file * Refactor internal state machine tests * Add Nested state machine * Revise Nested test * Revise state machine tests * Fix issues in string utils * Revise FppTest Add signals to state machine tests * Refactor state machine test harness * Revise autocode for Basic test Replace with actual autocode * Update fpp version Fix F Prime to match Switch initial/basic test from checked-in to auto-generated * Revise FppTest Make state machine guards const * Update fpp version Convert initial/Junction test to autocode * Update fpp version Make initial/nested test use autocode * Start to add State/Basic test * Revise FppTest Revise namespaces in state machine tests * Revise SmState::Basic test * Update fpp version Convert SmState/Basic test to use autocoding * Update FppTest * Add SmState/BasicSelf test * Add state/BasicGuard test * Add SmState/BasicU32 test * Revise state machine tests * Refactor state machine tests * Revise FppTest * Revise comments * Refactor state machine tests * Refactor state machine tests * Refactor state machine tests * Refactor state machine tests * Revise state machine tests * Revise state machine tests * Revise state machine tests * Revise state machine tests * Revise fpp tests * Revise state machine tests * Revise state machine tests * Revise state machine tests * Revise state machine tests * Revise state machine tests * Add README files to FPP tests * Start to add StateToState test * Revise StateToState test * Revise StateToState test * Revise StateToState test * Revise StateToState test * Revise StateToState test Remove hand-generated files * Revise StateToState tests * Add BasicInternal test * Update fpp version * Revise state machine tests * Add state-to-junction test * Add Internal state machine test * Add Polymorphism test * Add StateToChild test * Revise README files * Add junction/Basic test * Revise FppTest build * Update fpp version; revise Basic test * Revise junction tests * Add BasicGuardU32 test * Add BasicGuardString test * Add BasicGuardTestAbsType test * Add BasicGuardTestArray test * Add BasicGuardTestEnum test * Add BasicGuardTestStruct test * Add junction/Sequence test * Add junction/SequenceU32 test * Add junction/InputPairU16U32 test * Add JunctionToState.fpp * Add junction/JunctionToState test * Add junction/JunctionToJunction test * Update fpp version * Update fpp version Revise test code to match * Update fpp version * Update fpp version * Fix CMakeLists * Update fpp version * Update fpp version * Refactor sm tests * Refactor sm tests * Refactor sm tests * Update fpp version * Start to add internal_instance tests * Add missing files * Revise state machine tests * Revise state machine tests * Revise sm instance initial tests * Revise sm instance init tests * Revise sm instance initial tests * Revise sm instance initial tests * Add sm instance state tests * Revise sm instance state tests * Revise sm instance state tests * Revise sm instance state tests * Revise sm instance state tests * Revise internal instance state tests * Revise sm instance state tests * Revise sm instance state tests * Revsie BasicGuardTestAbsType * Revise sm instance state tests * Revise BasicGuardTestAbsType * Add BasicGuardTestArray * Add BasicGuardTestEnum * Add BasicGuardTestStruct * Add BasicGuardU32 * Add BasicInternal * Revise BasicInternal * Add BasicSelf * Reformat code * Add BasicString test * Add BasicTestAbsType * Add BasicTestArray * Add BasicTestEnum * Add BasicTestStruct * Add BasicU32 * Remove extraneous file * Remove extraneous files * Revise sm tests * Revise state machine tests * Add Internal test * Add Polymorphism test * Add StateToChild test * Add StateToJunction test * Add StateToSelf test * Add StateToState test * Add junction/Basic * Add BasicU32 test * Add InputPairU16U32 * Add JunctionToJunction * Revise comments * Add JunctionToState * Revise JunctionToState * Revise JunctionToJunction * Add Sequence test * Add Sequence test * Revise SequenceU32 test * Revise state machine tests Add tests for queued components * Revise Basic test Add schedIn handler * Revise junction/Basic test Add schedIn handler * Revise state/Basic test Add schedIn handler * Revise initial/Basic test Add multiple instances of the same state machine * Revise state/Basic test Add multiple instances of the same state machine * Reformat code * Update fpp version * Update fpp; revise FppTest * Refactor internal/initial tests * Revise state machine tests * Revise internal/state tests * Revise state-machine/internal tests Rename junction to choice * Revise state-machine/internal tests * Reformat C++ files * Revise state-machine/internal_instance/initial tests * Revise internal_instance/state tests * Format code * Revise internal_instance/choice tests * Update fpp version * Format code * Update fpp version * Improve const correctness in Fw/Port * Update design * Revise state machines design * Revise state machine design * Revise state machine design * Revise state machine design * Revise state machine design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machine instances design * Revise state machines design * Revise state machines design * Revise state machines design * Update fpp version * Update fpp version; revise code to match * Update fpp version * Revise state machines design * Revise state machines design Add class diagram * Revise state machines design * Revise state machines design * Revise typography Close up spaces in names with embedded variables * Revise state machines design * Revise state machines design * Revise state machines design * Revise state machine unit tests * Revise state machine tests Increase code coverage * Revise state machine tests Increase code coverage * Update fpp version * Update spelling * Remove Design directory This directory no longer exists in fprime/devel * Update mkdocs --------- Co-authored-by: watney Co-authored-by: garthwatney <160269551+garthwatney@users.noreply.github.com> Co-authored-by: M Starch --- .github/actions/spelling/expect.txt | 3 + FppTest/CMakeLists.txt | 16 +- FppTest/state_machine/CMakeLists.txt | 24 +- FppTest/state_machine/README.md | 3 + .../external_instance/CMakeLists.txt | 20 + .../{ => external_instance}/DeviceSm.cpp | 0 .../{ => external_instance}/DeviceSm.fppi | 0 .../{ => external_instance}/DeviceSm.hpp | 0 .../{ => external_instance}/DeviceSm.plantuml | 0 .../external_instance/DeviceSm.png | Bin 0 -> 8772 bytes .../{ => external_instance}/HackSm.cpp | 0 .../{ => external_instance}/HackSm.hpp | 0 .../{ => external_instance}/HackSm.plantuml | 0 .../external_instance/HackSm.png | Bin 0 -> 16903 bytes .../{ => external_instance}/Makefile | 0 .../{ => external_instance}/SMEvents.hpp | 0 .../{ => external_instance}/SmTest.cpp | 2 +- .../{ => external_instance}/SmTest.fpp | 0 .../{ => external_instance}/SmTest.hpp | 2 +- .../test/ut/SmTestTestMain.cpp | 2 +- .../test/ut/SmTestTester.cpp | 2 +- .../test/ut/SmTestTester.hpp | 2 +- FppTest/state_machine/internal/CMakeLists.txt | 4 + FppTest/state_machine/internal/README.md | 4 + .../state_machine/internal/choice/Basic.cpp | 82 ++++ .../state_machine/internal/choice/Basic.fpp | 9 + .../state_machine/internal/choice/Basic.hpp | 69 +++ .../internal/choice/BasicU32.cpp | 87 ++++ .../internal/choice/BasicU32.fpp | 9 + .../internal/choice/BasicU32.hpp | 71 +++ .../internal/choice/CMakeLists.txt | 24 + .../internal/choice/ChoiceToChoice.cpp | 137 ++++++ .../internal/choice/ChoiceToChoice.fpp | 9 + .../internal/choice/ChoiceToChoice.hpp | 88 ++++ .../internal/choice/ChoiceToState.cpp | 102 +++++ .../internal/choice/ChoiceToState.fpp | 9 + .../internal/choice/ChoiceToState.hpp | 83 ++++ .../internal/choice/InputPairU16U32.cpp | 121 +++++ .../internal/choice/InputPairU16U32.fpp | 9 + .../internal/choice/InputPairU16U32.hpp | 70 +++ .../state_machine/internal/choice/README.md | 3 + .../internal/choice/Sequence.cpp | 118 +++++ .../internal/choice/Sequence.fpp | 9 + .../internal/choice/Sequence.hpp | 79 ++++ .../internal/choice/SequenceU32.cpp | 124 +++++ .../internal/choice/SequenceU32.fpp | 9 + .../internal/choice/SequenceU32.hpp | 81 ++++ .../internal/choice/include/Basic.fppi | 38 ++ .../internal/choice/include/BasicU32.fppi | 38 ++ .../choice/include/ChoiceToChoice.fppi | 64 +++ .../choice/include/ChoiceToState.fppi | 61 +++ .../choice/include/InputPairU16U32.fppi | 41 ++ .../internal/choice/include/Sequence.fppi | 49 ++ .../internal/choice/include/SequenceU32.fppi | 49 ++ .../state_machine/internal/choice/main.cpp | 119 +++++ .../internal/harness/CMakeLists.txt | 11 + .../state_machine/internal/harness/Guard.hpp | 73 +++ .../internal/harness/Harness.fpp | 17 + .../internal/harness/Harness.hpp | 24 + .../internal/harness/History.hpp | 81 ++++ .../internal/harness/NoArgGuard.hpp | 72 +++ .../state_machine/internal/harness/Pick.hpp | 88 ++++ .../state_machine/internal/harness/README.md | 3 + .../internal/harness/SignalValueHistory.hpp | 88 ++++ .../internal/harness/TestAbsType.cpp | 38 ++ .../internal/harness/TestAbsType.hpp | 77 ++++ .../state_machine/internal/harness/main.cpp | 7 + .../state_machine/internal/initial/Basic.cpp | 44 ++ .../state_machine/internal/initial/Basic.fpp | 9 + .../state_machine/internal/initial/Basic.hpp | 52 +++ .../internal/initial/CMakeLists.txt | 16 + .../state_machine/internal/initial/Choice.cpp | 72 +++ .../state_machine/internal/initial/Choice.fpp | 9 + .../state_machine/internal/initial/Choice.hpp | 67 +++ .../state_machine/internal/initial/Nested.cpp | 45 ++ .../state_machine/internal/initial/Nested.fpp | 9 + .../state_machine/internal/initial/Nested.hpp | 52 +++ .../state_machine/internal/initial/README.md | 3 + .../internal/initial/include/Basic.fppi | 14 + .../internal/initial/include/Choice.fppi | 25 + .../internal/initial/include/Nested.fppi | 23 + .../state_machine/internal/initial/main.cpp | 40 ++ .../state_machine/internal/state/Basic.cpp | 49 ++ .../state_machine/internal/state/Basic.fpp | 9 + .../state_machine/internal/state/Basic.hpp | 52 +++ .../internal/state/BasicGuard.cpp | 75 +++ .../internal/state/BasicGuard.fpp | 9 + .../internal/state/BasicGuard.hpp | 68 +++ .../internal/state/BasicGuardString.cpp | 77 ++++ .../internal/state/BasicGuardString.fpp | 9 + .../internal/state/BasicGuardString.hpp | 64 +++ .../internal/state/BasicGuardTestAbsType.cpp | 76 ++++ .../internal/state/BasicGuardTestAbsType.fpp | 9 + .../internal/state/BasicGuardTestAbsType.hpp | 64 +++ .../internal/state/BasicGuardTestArray.cpp | 75 +++ .../internal/state/BasicGuardTestArray.fpp | 9 + .../internal/state/BasicGuardTestArray.hpp | 64 +++ .../internal/state/BasicGuardTestEnum.cpp | 75 +++ .../internal/state/BasicGuardTestEnum.fpp | 9 + .../internal/state/BasicGuardTestEnum.hpp | 64 +++ .../internal/state/BasicGuardTestStruct.cpp | 76 ++++ .../internal/state/BasicGuardTestStruct.fpp | 9 + .../internal/state/BasicGuardTestStruct.hpp | 64 +++ .../internal/state/BasicGuardU32.cpp | 75 +++ .../internal/state/BasicGuardU32.fpp | 9 + .../internal/state/BasicGuardU32.hpp | 64 +++ .../internal/state/BasicInternal.cpp | 46 ++ .../internal/state/BasicInternal.fpp | 9 + .../internal/state/BasicInternal.hpp | 52 +++ .../internal/state/BasicSelf.cpp | 49 ++ .../internal/state/BasicSelf.fpp | 9 + .../internal/state/BasicSelf.hpp | 52 +++ .../internal/state/BasicString.cpp | 58 +++ .../internal/state/BasicString.fpp | 9 + .../internal/state/BasicString.hpp | 60 +++ .../internal/state/BasicTestAbsType.cpp | 57 +++ .../internal/state/BasicTestAbsType.fpp | 9 + .../internal/state/BasicTestAbsType.hpp | 60 +++ .../internal/state/BasicTestArray.cpp | 57 +++ .../internal/state/BasicTestArray.fpp | 9 + .../internal/state/BasicTestArray.hpp | 60 +++ .../internal/state/BasicTestEnum.cpp | 57 +++ .../internal/state/BasicTestEnum.fpp | 9 + .../internal/state/BasicTestEnum.hpp | 60 +++ .../internal/state/BasicTestStruct.cpp | 57 +++ .../internal/state/BasicTestStruct.fpp | 9 + .../internal/state/BasicTestStruct.hpp | 60 +++ .../state_machine/internal/state/BasicU32.cpp | 57 +++ .../state_machine/internal/state/BasicU32.fpp | 9 + .../state_machine/internal/state/BasicU32.hpp | 60 +++ .../internal/state/CMakeLists.txt | 54 +++ .../state_machine/internal/state/Internal.cpp | 74 +++ .../state_machine/internal/state/Internal.fpp | 9 + .../state_machine/internal/state/Internal.hpp | 61 +++ .../internal/state/Polymorphism.cpp | 64 +++ .../internal/state/Polymorphism.fpp | 9 + .../internal/state/Polymorphism.hpp | 48 ++ .../state_machine/internal/state/README.md | 3 + .../internal/state/StateToChild.cpp | 118 +++++ .../internal/state/StateToChild.fpp | 9 + .../internal/state/StateToChild.hpp | 81 ++++ .../internal/state/StateToChoice.cpp | 193 ++++++++ .../internal/state/StateToChoice.fpp | 9 + .../internal/state/StateToChoice.hpp | 106 +++++ .../internal/state/StateToSelf.cpp | 134 ++++++ .../internal/state/StateToSelf.fpp | 9 + .../internal/state/StateToSelf.hpp | 89 ++++ .../internal/state/StateToState.cpp | 188 ++++++++ .../internal/state/StateToState.fpp | 9 + .../internal/state/StateToState.hpp | 103 +++++ .../internal/state/include/Basic.fppi | 31 ++ .../internal/state/include/BasicGuard.fppi | 34 ++ .../state/include/BasicGuardString.fppi | 29 ++ .../state/include/BasicGuardTestAbsType.fppi | 26 ++ .../state/include/BasicGuardTestArray.fppi | 26 ++ .../state/include/BasicGuardTestEnum.fppi | 26 ++ .../state/include/BasicGuardTestStruct.fppi | 26 ++ .../internal/state/include/BasicGuardU32.fppi | 26 ++ .../internal/state/include/BasicInternal.fppi | 24 + .../internal/state/include/BasicSelf.fppi | 26 ++ .../internal/state/include/BasicString.fppi | 36 ++ .../state/include/BasicTestAbsType.fppi | 34 ++ .../state/include/BasicTestArray.fppi | 34 ++ .../internal/state/include/BasicTestEnum.fppi | 34 ++ .../state/include/BasicTestStruct.fppi | 34 ++ .../internal/state/include/BasicU32.fppi | 34 ++ .../internal/state/include/Internal.fppi | 38 ++ .../internal/state/include/Polymorphism.fppi | 46 ++ .../internal/state/include/StateToChild.fppi | 64 +++ .../internal/state/include/StateToChoice.fppi | 109 +++++ .../internal/state/include/StateToSelf.fppi | 77 ++++ .../internal/state/include/StateToState.fppi | 108 +++++ FppTest/state_machine/internal/state/main.cpp | 294 ++++++++++++ .../internal_instance/CMakeLists.txt | 3 + .../internal_instance/choice/Basic.cpp | 168 +++++++ .../internal_instance/choice/Basic.fpp | 19 + .../internal_instance/choice/Basic.hpp | 165 +++++++ .../internal_instance/choice/BasicU32.cpp | 107 +++++ .../internal_instance/choice/BasicU32.fpp | 13 + .../internal_instance/choice/BasicU32.hpp | 115 +++++ .../internal_instance/choice/CMakeLists.txt | 24 + .../choice/ChoiceToChoice.cpp | 195 ++++++++ .../choice/ChoiceToChoice.fpp | 13 + .../choice/ChoiceToChoice.hpp | 155 +++++++ .../choice/ChoiceToState.cpp | 124 +++++ .../choice/ChoiceToState.fpp | 13 + .../choice/ChoiceToState.hpp | 133 ++++++ .../choice/InputPairU16U32.cpp | 144 ++++++ .../choice/InputPairU16U32.fpp | 13 + .../choice/InputPairU16U32.hpp | 112 +++++ .../internal_instance/choice/Sequence.cpp | 134 ++++++ .../internal_instance/choice/Sequence.fpp | 13 + .../internal_instance/choice/Sequence.hpp | 126 +++++ .../internal_instance/choice/SequenceU32.cpp | 144 ++++++ .../internal_instance/choice/SequenceU32.fpp | 13 + .../internal_instance/choice/SequenceU32.hpp | 129 ++++++ .../internal_instance/choice/main.cpp | 134 ++++++ .../internal_instance/initial/Basic.cpp | 84 ++++ .../internal_instance/initial/Basic.fpp | 23 + .../internal_instance/initial/Basic.hpp | 115 +++++ .../internal_instance/initial/CMakeLists.txt | 16 + .../internal_instance/initial/Choice.cpp | 116 +++++ .../internal_instance/initial/Choice.fpp | 17 + .../internal_instance/initial/Choice.hpp | 138 ++++++ .../internal_instance/initial/Nested.cpp | 71 +++ .../internal_instance/initial/Nested.fpp | 17 + .../internal_instance/initial/Nested.hpp | 110 +++++ .../internal_instance/initial/main.cpp | 40 ++ .../internal_instance/state/Basic.cpp | 120 +++++ .../internal_instance/state/Basic.fpp | 23 + .../internal_instance/state/Basic.hpp | 115 +++++ .../internal_instance/state/BasicGuard.cpp | 93 ++++ .../internal_instance/state/BasicGuard.fpp | 13 + .../internal_instance/state/BasicGuard.hpp | 113 +++++ .../state/BasicGuardString.cpp | 100 ++++ .../state/BasicGuardString.fpp | 13 + .../state/BasicGuardString.hpp | 106 +++++ .../state/BasicGuardTestAbsType.cpp | 130 ++++++ .../state/BasicGuardTestAbsType.fpp | 13 + .../state/BasicGuardTestAbsType.hpp | 129 ++++++ .../state/BasicGuardTestArray.cpp | 99 ++++ .../state/BasicGuardTestArray.fpp | 13 + .../state/BasicGuardTestArray.hpp | 109 +++++ .../state/BasicGuardTestEnum.cpp | 97 ++++ .../state/BasicGuardTestEnum.fpp | 13 + .../state/BasicGuardTestEnum.hpp | 107 +++++ .../state/BasicGuardTestStruct.cpp | 99 ++++ .../state/BasicGuardTestStruct.fpp | 13 + .../state/BasicGuardTestStruct.hpp | 109 +++++ .../internal_instance/state/BasicGuardU32.cpp | 97 ++++ .../internal_instance/state/BasicGuardU32.fpp | 13 + .../internal_instance/state/BasicGuardU32.hpp | 106 +++++ .../internal_instance/state/BasicInternal.cpp | 55 +++ .../internal_instance/state/BasicInternal.fpp | 13 + .../internal_instance/state/BasicInternal.hpp | 85 ++++ .../internal_instance/state/BasicSelf.cpp | 58 +++ .../internal_instance/state/BasicSelf.fpp | 13 + .../internal_instance/state/BasicSelf.hpp | 85 ++++ .../internal_instance/state/BasicString.cpp | 69 +++ .../internal_instance/state/BasicString.fpp | 13 + .../internal_instance/state/BasicString.hpp | 96 ++++ .../state/BasicTestAbsType.cpp | 69 +++ .../state/BasicTestAbsType.fpp | 13 + .../state/BasicTestAbsType.hpp | 96 ++++ .../state/BasicTestArray.cpp | 68 +++ .../state/BasicTestArray.fpp | 13 + .../state/BasicTestArray.hpp | 96 ++++ .../internal_instance/state/BasicTestEnum.cpp | 68 +++ .../internal_instance/state/BasicTestEnum.fpp | 13 + .../internal_instance/state/BasicTestEnum.hpp | 96 ++++ .../state/BasicTestStruct.cpp | 69 +++ .../state/BasicTestStruct.fpp | 13 + .../state/BasicTestStruct.hpp | 96 ++++ .../internal_instance/state/BasicU32.cpp | 63 +++ .../internal_instance/state/BasicU32.fpp | 13 + .../internal_instance/state/BasicU32.hpp | 95 ++++ .../internal_instance/state/CMakeLists.txt | 54 +++ .../internal_instance/state/Internal.cpp | 89 ++++ .../internal_instance/state/Internal.fpp | 13 + .../internal_instance/state/Internal.hpp | 93 ++++ .../internal_instance/state/Polymorphism.cpp | 69 +++ .../internal_instance/state/Polymorphism.fpp | 13 + .../internal_instance/state/Polymorphism.hpp | 70 +++ .../internal_instance/state/StateToChild.cpp | 137 ++++++ .../internal_instance/state/StateToChild.fpp | 13 + .../internal_instance/state/StateToChild.hpp | 125 +++++ .../internal_instance/state/StateToChoice.cpp | 232 ++++++++++ .../internal_instance/state/StateToChoice.fpp | 13 + .../internal_instance/state/StateToChoice.hpp | 167 +++++++ .../internal_instance/state/StateToSelf.cpp | 155 +++++++ .../internal_instance/state/StateToSelf.fpp | 13 + .../internal_instance/state/StateToSelf.hpp | 138 ++++++ .../internal_instance/state/StateToState.cpp | 217 +++++++++ .../internal_instance/state/StateToState.fpp | 13 + .../internal_instance/state/StateToState.hpp | 158 +++++++ .../internal_instance/state/main.cpp | 299 ++++++++++++ FppTest/utils/Utils.cpp | 2 +- Fw/Port/PortBase.cpp | 4 +- Fw/Port/PortBase.hpp | 4 +- Ref/TypeDemo/TypeDemo.fpp | 6 +- Svc/Health/Health.fpp | 18 +- Svc/PolyIf/PolyIf.fpp | 2 +- Svc/SystemResources/SystemResources.hpp | 2 +- .../user-manual/design/state-machines.md | 429 ++++++++++++++++++ docs/img/sm-impl-class-diagram.png | Bin 0 -> 13144 bytes docs/img/sm-impl-class-diagram.puml | 17 + docs/mkdocs.yml | 1 + requirements.txt | 24 +- 288 files changed, 16413 insertions(+), 62 deletions(-) create mode 100644 FppTest/state_machine/README.md create mode 100644 FppTest/state_machine/external_instance/CMakeLists.txt rename FppTest/state_machine/{ => external_instance}/DeviceSm.cpp (100%) rename FppTest/state_machine/{ => external_instance}/DeviceSm.fppi (100%) rename FppTest/state_machine/{ => external_instance}/DeviceSm.hpp (100%) rename FppTest/state_machine/{ => external_instance}/DeviceSm.plantuml (100%) create mode 100644 FppTest/state_machine/external_instance/DeviceSm.png rename FppTest/state_machine/{ => external_instance}/HackSm.cpp (100%) rename FppTest/state_machine/{ => external_instance}/HackSm.hpp (100%) rename FppTest/state_machine/{ => external_instance}/HackSm.plantuml (100%) create mode 100644 FppTest/state_machine/external_instance/HackSm.png rename FppTest/state_machine/{ => external_instance}/Makefile (100%) rename FppTest/state_machine/{ => external_instance}/SMEvents.hpp (100%) rename FppTest/state_machine/{ => external_instance}/SmTest.cpp (98%) rename FppTest/state_machine/{ => external_instance}/SmTest.fpp (100%) rename FppTest/state_machine/{ => external_instance}/SmTest.hpp (98%) rename FppTest/state_machine/{ => external_instance}/test/ut/SmTestTestMain.cpp (86%) rename FppTest/state_machine/{ => external_instance}/test/ut/SmTestTester.cpp (97%) rename FppTest/state_machine/{ => external_instance}/test/ut/SmTestTester.hpp (97%) create mode 100644 FppTest/state_machine/internal/CMakeLists.txt create mode 100644 FppTest/state_machine/internal/README.md create mode 100644 FppTest/state_machine/internal/choice/Basic.cpp create mode 100644 FppTest/state_machine/internal/choice/Basic.fpp create mode 100644 FppTest/state_machine/internal/choice/Basic.hpp create mode 100644 FppTest/state_machine/internal/choice/BasicU32.cpp create mode 100644 FppTest/state_machine/internal/choice/BasicU32.fpp create mode 100644 FppTest/state_machine/internal/choice/BasicU32.hpp create mode 100644 FppTest/state_machine/internal/choice/CMakeLists.txt create mode 100644 FppTest/state_machine/internal/choice/ChoiceToChoice.cpp create mode 100644 FppTest/state_machine/internal/choice/ChoiceToChoice.fpp create mode 100644 FppTest/state_machine/internal/choice/ChoiceToChoice.hpp create mode 100644 FppTest/state_machine/internal/choice/ChoiceToState.cpp create mode 100644 FppTest/state_machine/internal/choice/ChoiceToState.fpp create mode 100644 FppTest/state_machine/internal/choice/ChoiceToState.hpp create mode 100644 FppTest/state_machine/internal/choice/InputPairU16U32.cpp create mode 100644 FppTest/state_machine/internal/choice/InputPairU16U32.fpp create mode 100644 FppTest/state_machine/internal/choice/InputPairU16U32.hpp create mode 100644 FppTest/state_machine/internal/choice/README.md create mode 100644 FppTest/state_machine/internal/choice/Sequence.cpp create mode 100644 FppTest/state_machine/internal/choice/Sequence.fpp create mode 100644 FppTest/state_machine/internal/choice/Sequence.hpp create mode 100644 FppTest/state_machine/internal/choice/SequenceU32.cpp create mode 100644 FppTest/state_machine/internal/choice/SequenceU32.fpp create mode 100644 FppTest/state_machine/internal/choice/SequenceU32.hpp create mode 100644 FppTest/state_machine/internal/choice/include/Basic.fppi create mode 100644 FppTest/state_machine/internal/choice/include/BasicU32.fppi create mode 100644 FppTest/state_machine/internal/choice/include/ChoiceToChoice.fppi create mode 100644 FppTest/state_machine/internal/choice/include/ChoiceToState.fppi create mode 100644 FppTest/state_machine/internal/choice/include/InputPairU16U32.fppi create mode 100644 FppTest/state_machine/internal/choice/include/Sequence.fppi create mode 100644 FppTest/state_machine/internal/choice/include/SequenceU32.fppi create mode 100644 FppTest/state_machine/internal/choice/main.cpp create mode 100644 FppTest/state_machine/internal/harness/CMakeLists.txt create mode 100644 FppTest/state_machine/internal/harness/Guard.hpp create mode 100644 FppTest/state_machine/internal/harness/Harness.fpp create mode 100644 FppTest/state_machine/internal/harness/Harness.hpp create mode 100644 FppTest/state_machine/internal/harness/History.hpp create mode 100644 FppTest/state_machine/internal/harness/NoArgGuard.hpp create mode 100644 FppTest/state_machine/internal/harness/Pick.hpp create mode 100644 FppTest/state_machine/internal/harness/README.md create mode 100644 FppTest/state_machine/internal/harness/SignalValueHistory.hpp create mode 100644 FppTest/state_machine/internal/harness/TestAbsType.cpp create mode 100644 FppTest/state_machine/internal/harness/TestAbsType.hpp create mode 100644 FppTest/state_machine/internal/harness/main.cpp create mode 100644 FppTest/state_machine/internal/initial/Basic.cpp create mode 100644 FppTest/state_machine/internal/initial/Basic.fpp create mode 100644 FppTest/state_machine/internal/initial/Basic.hpp create mode 100644 FppTest/state_machine/internal/initial/CMakeLists.txt create mode 100644 FppTest/state_machine/internal/initial/Choice.cpp create mode 100644 FppTest/state_machine/internal/initial/Choice.fpp create mode 100644 FppTest/state_machine/internal/initial/Choice.hpp create mode 100644 FppTest/state_machine/internal/initial/Nested.cpp create mode 100644 FppTest/state_machine/internal/initial/Nested.fpp create mode 100644 FppTest/state_machine/internal/initial/Nested.hpp create mode 100644 FppTest/state_machine/internal/initial/README.md create mode 100644 FppTest/state_machine/internal/initial/include/Basic.fppi create mode 100644 FppTest/state_machine/internal/initial/include/Choice.fppi create mode 100644 FppTest/state_machine/internal/initial/include/Nested.fppi create mode 100644 FppTest/state_machine/internal/initial/main.cpp create mode 100644 FppTest/state_machine/internal/state/Basic.cpp create mode 100644 FppTest/state_machine/internal/state/Basic.fpp create mode 100644 FppTest/state_machine/internal/state/Basic.hpp create mode 100644 FppTest/state_machine/internal/state/BasicGuard.cpp create mode 100644 FppTest/state_machine/internal/state/BasicGuard.fpp create mode 100644 FppTest/state_machine/internal/state/BasicGuard.hpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardString.cpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardString.fpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardString.hpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestAbsType.cpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestAbsType.fpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestAbsType.hpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestArray.cpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestArray.fpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestArray.hpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestEnum.cpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestEnum.fpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestEnum.hpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestStruct.cpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestStruct.fpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardTestStruct.hpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardU32.cpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardU32.fpp create mode 100644 FppTest/state_machine/internal/state/BasicGuardU32.hpp create mode 100644 FppTest/state_machine/internal/state/BasicInternal.cpp create mode 100644 FppTest/state_machine/internal/state/BasicInternal.fpp create mode 100644 FppTest/state_machine/internal/state/BasicInternal.hpp create mode 100644 FppTest/state_machine/internal/state/BasicSelf.cpp create mode 100644 FppTest/state_machine/internal/state/BasicSelf.fpp create mode 100644 FppTest/state_machine/internal/state/BasicSelf.hpp create mode 100644 FppTest/state_machine/internal/state/BasicString.cpp create mode 100644 FppTest/state_machine/internal/state/BasicString.fpp create mode 100644 FppTest/state_machine/internal/state/BasicString.hpp create mode 100644 FppTest/state_machine/internal/state/BasicTestAbsType.cpp create mode 100644 FppTest/state_machine/internal/state/BasicTestAbsType.fpp create mode 100644 FppTest/state_machine/internal/state/BasicTestAbsType.hpp create mode 100644 FppTest/state_machine/internal/state/BasicTestArray.cpp create mode 100644 FppTest/state_machine/internal/state/BasicTestArray.fpp create mode 100644 FppTest/state_machine/internal/state/BasicTestArray.hpp create mode 100644 FppTest/state_machine/internal/state/BasicTestEnum.cpp create mode 100644 FppTest/state_machine/internal/state/BasicTestEnum.fpp create mode 100644 FppTest/state_machine/internal/state/BasicTestEnum.hpp create mode 100644 FppTest/state_machine/internal/state/BasicTestStruct.cpp create mode 100644 FppTest/state_machine/internal/state/BasicTestStruct.fpp create mode 100644 FppTest/state_machine/internal/state/BasicTestStruct.hpp create mode 100644 FppTest/state_machine/internal/state/BasicU32.cpp create mode 100644 FppTest/state_machine/internal/state/BasicU32.fpp create mode 100644 FppTest/state_machine/internal/state/BasicU32.hpp create mode 100644 FppTest/state_machine/internal/state/CMakeLists.txt create mode 100644 FppTest/state_machine/internal/state/Internal.cpp create mode 100644 FppTest/state_machine/internal/state/Internal.fpp create mode 100644 FppTest/state_machine/internal/state/Internal.hpp create mode 100644 FppTest/state_machine/internal/state/Polymorphism.cpp create mode 100644 FppTest/state_machine/internal/state/Polymorphism.fpp create mode 100644 FppTest/state_machine/internal/state/Polymorphism.hpp create mode 100644 FppTest/state_machine/internal/state/README.md create mode 100644 FppTest/state_machine/internal/state/StateToChild.cpp create mode 100644 FppTest/state_machine/internal/state/StateToChild.fpp create mode 100644 FppTest/state_machine/internal/state/StateToChild.hpp create mode 100644 FppTest/state_machine/internal/state/StateToChoice.cpp create mode 100644 FppTest/state_machine/internal/state/StateToChoice.fpp create mode 100644 FppTest/state_machine/internal/state/StateToChoice.hpp create mode 100644 FppTest/state_machine/internal/state/StateToSelf.cpp create mode 100644 FppTest/state_machine/internal/state/StateToSelf.fpp create mode 100644 FppTest/state_machine/internal/state/StateToSelf.hpp create mode 100644 FppTest/state_machine/internal/state/StateToState.cpp create mode 100644 FppTest/state_machine/internal/state/StateToState.fpp create mode 100644 FppTest/state_machine/internal/state/StateToState.hpp create mode 100644 FppTest/state_machine/internal/state/include/Basic.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicGuard.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicGuardString.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicGuardTestAbsType.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicGuardTestArray.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicGuardTestEnum.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicGuardTestStruct.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicGuardU32.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicInternal.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicSelf.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicString.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicTestAbsType.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicTestArray.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicTestEnum.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicTestStruct.fppi create mode 100644 FppTest/state_machine/internal/state/include/BasicU32.fppi create mode 100644 FppTest/state_machine/internal/state/include/Internal.fppi create mode 100644 FppTest/state_machine/internal/state/include/Polymorphism.fppi create mode 100644 FppTest/state_machine/internal/state/include/StateToChild.fppi create mode 100644 FppTest/state_machine/internal/state/include/StateToChoice.fppi create mode 100644 FppTest/state_machine/internal/state/include/StateToSelf.fppi create mode 100644 FppTest/state_machine/internal/state/include/StateToState.fppi create mode 100644 FppTest/state_machine/internal/state/main.cpp create mode 100644 FppTest/state_machine/internal_instance/CMakeLists.txt create mode 100644 FppTest/state_machine/internal_instance/choice/Basic.cpp create mode 100644 FppTest/state_machine/internal_instance/choice/Basic.fpp create mode 100644 FppTest/state_machine/internal_instance/choice/Basic.hpp create mode 100644 FppTest/state_machine/internal_instance/choice/BasicU32.cpp create mode 100644 FppTest/state_machine/internal_instance/choice/BasicU32.fpp create mode 100644 FppTest/state_machine/internal_instance/choice/BasicU32.hpp create mode 100644 FppTest/state_machine/internal_instance/choice/CMakeLists.txt create mode 100644 FppTest/state_machine/internal_instance/choice/ChoiceToChoice.cpp create mode 100644 FppTest/state_machine/internal_instance/choice/ChoiceToChoice.fpp create mode 100644 FppTest/state_machine/internal_instance/choice/ChoiceToChoice.hpp create mode 100644 FppTest/state_machine/internal_instance/choice/ChoiceToState.cpp create mode 100644 FppTest/state_machine/internal_instance/choice/ChoiceToState.fpp create mode 100644 FppTest/state_machine/internal_instance/choice/ChoiceToState.hpp create mode 100644 FppTest/state_machine/internal_instance/choice/InputPairU16U32.cpp create mode 100644 FppTest/state_machine/internal_instance/choice/InputPairU16U32.fpp create mode 100644 FppTest/state_machine/internal_instance/choice/InputPairU16U32.hpp create mode 100644 FppTest/state_machine/internal_instance/choice/Sequence.cpp create mode 100644 FppTest/state_machine/internal_instance/choice/Sequence.fpp create mode 100644 FppTest/state_machine/internal_instance/choice/Sequence.hpp create mode 100644 FppTest/state_machine/internal_instance/choice/SequenceU32.cpp create mode 100644 FppTest/state_machine/internal_instance/choice/SequenceU32.fpp create mode 100644 FppTest/state_machine/internal_instance/choice/SequenceU32.hpp create mode 100644 FppTest/state_machine/internal_instance/choice/main.cpp create mode 100644 FppTest/state_machine/internal_instance/initial/Basic.cpp create mode 100644 FppTest/state_machine/internal_instance/initial/Basic.fpp create mode 100644 FppTest/state_machine/internal_instance/initial/Basic.hpp create mode 100644 FppTest/state_machine/internal_instance/initial/CMakeLists.txt create mode 100644 FppTest/state_machine/internal_instance/initial/Choice.cpp create mode 100644 FppTest/state_machine/internal_instance/initial/Choice.fpp create mode 100644 FppTest/state_machine/internal_instance/initial/Choice.hpp create mode 100644 FppTest/state_machine/internal_instance/initial/Nested.cpp create mode 100644 FppTest/state_machine/internal_instance/initial/Nested.fpp create mode 100644 FppTest/state_machine/internal_instance/initial/Nested.hpp create mode 100644 FppTest/state_machine/internal_instance/initial/main.cpp create mode 100644 FppTest/state_machine/internal_instance/state/Basic.cpp create mode 100644 FppTest/state_machine/internal_instance/state/Basic.fpp create mode 100644 FppTest/state_machine/internal_instance/state/Basic.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuard.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuard.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuard.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardString.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardString.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardString.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestArray.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestArray.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestArray.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardU32.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardU32.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicGuardU32.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicInternal.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicInternal.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicInternal.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicSelf.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicSelf.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicSelf.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicString.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicString.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicString.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestAbsType.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestAbsType.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestAbsType.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestArray.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestArray.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestArray.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestEnum.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestEnum.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestEnum.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestStruct.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestStruct.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicTestStruct.hpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicU32.cpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicU32.fpp create mode 100644 FppTest/state_machine/internal_instance/state/BasicU32.hpp create mode 100644 FppTest/state_machine/internal_instance/state/CMakeLists.txt create mode 100644 FppTest/state_machine/internal_instance/state/Internal.cpp create mode 100644 FppTest/state_machine/internal_instance/state/Internal.fpp create mode 100644 FppTest/state_machine/internal_instance/state/Internal.hpp create mode 100644 FppTest/state_machine/internal_instance/state/Polymorphism.cpp create mode 100644 FppTest/state_machine/internal_instance/state/Polymorphism.fpp create mode 100644 FppTest/state_machine/internal_instance/state/Polymorphism.hpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToChild.cpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToChild.fpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToChild.hpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToChoice.cpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToChoice.fpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToChoice.hpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToSelf.cpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToSelf.fpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToSelf.hpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToState.cpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToState.fpp create mode 100644 FppTest/state_machine/internal_instance/state/StateToState.hpp create mode 100644 FppTest/state_machine/internal_instance/state/main.cpp create mode 100644 docs/documentation/user-manual/design/state-machines.md create mode 100644 docs/img/sm-impl-class-diagram.png create mode 100644 docs/img/sm-impl-class-diagram.puml diff --git a/.github/actions/spelling/expect.txt b/.github/actions/spelling/expect.txt index 37ea1b67cf..ee30693556 100644 --- a/.github/actions/spelling/expect.txt +++ b/.github/actions/spelling/expect.txt @@ -42,6 +42,7 @@ argname argtype arinc arpa +ASize ASTRING ATester ATL @@ -103,6 +104,7 @@ carg caselessmatch CBF CBLOCK +CComponent CCSDS ccsparc cdefs @@ -566,6 +568,7 @@ mscfile mseconds mstarch mstat +MState mstring mtype multiarch diff --git a/FppTest/CMakeLists.txt b/FppTest/CMakeLists.txt index 1ae2e7930e..9139c01f80 100644 --- a/FppTest/CMakeLists.txt +++ b/FppTest/CMakeLists.txt @@ -20,14 +20,20 @@ add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/struct/") set(SOURCE_FILES "source.cpp") set(MOD_DEPS ${PROJECT_NAME}/array + ${PROJECT_NAME}/component/active + ${PROJECT_NAME}/component/empty + ${PROJECT_NAME}/component/passive + ${PROJECT_NAME}/component/queued ${PROJECT_NAME}/dp - ${PROJECT_NAME}/state_machine ${PROJECT_NAME}/enum + ${PROJECT_NAME}/state_machine/external_instance + ${PROJECT_NAME}/state_machine/internal/initial + ${PROJECT_NAME}/state_machine/internal/junction + ${PROJECT_NAME}/state_machine/internal/state + ${PROJECT_NAME}/state_machine/internal_instance/initial + ${PROJECT_NAME}/state_machine/internal_instance/junction + ${PROJECT_NAME}/state_machine/internal_instance/state ${PROJECT_NAME}/struct - ${PROJECT_NAME}/component/empty - ${PROJECT_NAME}/component/active - ${PROJECT_NAME}/component/queued - ${PROJECT_NAME}/component/passive ) register_fprime_deployment() diff --git a/FppTest/state_machine/CMakeLists.txt b/FppTest/state_machine/CMakeLists.txt index 6d1e6c1e0f..63c6183139 100644 --- a/FppTest/state_machine/CMakeLists.txt +++ b/FppTest/state_machine/CMakeLists.txt @@ -1,21 +1,3 @@ -set(SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/SmTest.cpp" - "${CMAKE_CURRENT_LIST_DIR}/SmTest.fpp" - "${CMAKE_CURRENT_LIST_DIR}/DeviceSm.cpp" - "${CMAKE_CURRENT_LIST_DIR}/HackSm.cpp" -) -set(MOD_DEPS Fw/Sm) - -register_fprime_module() - -set(UT_SOURCE_FILES - "${CMAKE_CURRENT_LIST_DIR}/SmTest.fpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/SmTestTestMain.cpp" - "${CMAKE_CURRENT_LIST_DIR}/test/ut/SmTestTester.cpp" - "${CMAKE_CURRENT_LIST_DIR}/DeviceSm.cpp" - "${CMAKE_CURRENT_LIST_DIR}/HackSm.cpp" -) - -set(UT_MOD_DEPS STest) -set(UT_AUTO_HELPERS ON) -register_fprime_ut() +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/external_instance/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/internal/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/internal_instance/") diff --git a/FppTest/state_machine/README.md b/FppTest/state_machine/README.md new file mode 100644 index 0000000000..8a2feb0e23 --- /dev/null +++ b/FppTest/state_machine/README.md @@ -0,0 +1,3 @@ +# state_machine + +Tests for FPP state machines. diff --git a/FppTest/state_machine/external_instance/CMakeLists.txt b/FppTest/state_machine/external_instance/CMakeLists.txt new file mode 100644 index 0000000000..28232c430e --- /dev/null +++ b/FppTest/state_machine/external_instance/CMakeLists.txt @@ -0,0 +1,20 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/SmTest.cpp" + "${CMAKE_CURRENT_LIST_DIR}/SmTest.fpp" + "${CMAKE_CURRENT_LIST_DIR}/DeviceSm.cpp" + "${CMAKE_CURRENT_LIST_DIR}/HackSm.cpp" +) +set(MOD_DEPS Fw/Sm) + +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/SmTest.fpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/SmTestTestMain.cpp" + "${CMAKE_CURRENT_LIST_DIR}/test/ut/SmTestTester.cpp" + "${CMAKE_CURRENT_LIST_DIR}/DeviceSm.cpp" + "${CMAKE_CURRENT_LIST_DIR}/HackSm.cpp" +) +set(UT_MOD_DEPS STest) +set(UT_AUTO_HELPERS ON) +register_fprime_ut() diff --git a/FppTest/state_machine/DeviceSm.cpp b/FppTest/state_machine/external_instance/DeviceSm.cpp similarity index 100% rename from FppTest/state_machine/DeviceSm.cpp rename to FppTest/state_machine/external_instance/DeviceSm.cpp diff --git a/FppTest/state_machine/DeviceSm.fppi b/FppTest/state_machine/external_instance/DeviceSm.fppi similarity index 100% rename from FppTest/state_machine/DeviceSm.fppi rename to FppTest/state_machine/external_instance/DeviceSm.fppi diff --git a/FppTest/state_machine/DeviceSm.hpp b/FppTest/state_machine/external_instance/DeviceSm.hpp similarity index 100% rename from FppTest/state_machine/DeviceSm.hpp rename to FppTest/state_machine/external_instance/DeviceSm.hpp diff --git a/FppTest/state_machine/DeviceSm.plantuml b/FppTest/state_machine/external_instance/DeviceSm.plantuml similarity index 100% rename from FppTest/state_machine/DeviceSm.plantuml rename to FppTest/state_machine/external_instance/DeviceSm.plantuml diff --git a/FppTest/state_machine/external_instance/DeviceSm.png b/FppTest/state_machine/external_instance/DeviceSm.png new file mode 100644 index 0000000000000000000000000000000000000000..ccfca2a143cb49120a9eaaf79ed44127f724292a GIT binary patch literal 8772 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 literal 0 HcmV?d00001 diff --git a/FppTest/state_machine/HackSm.cpp b/FppTest/state_machine/external_instance/HackSm.cpp similarity index 100% rename from FppTest/state_machine/HackSm.cpp rename to FppTest/state_machine/external_instance/HackSm.cpp diff --git a/FppTest/state_machine/HackSm.hpp b/FppTest/state_machine/external_instance/HackSm.hpp similarity index 100% rename from FppTest/state_machine/HackSm.hpp rename to FppTest/state_machine/external_instance/HackSm.hpp diff --git a/FppTest/state_machine/HackSm.plantuml b/FppTest/state_machine/external_instance/HackSm.plantuml similarity index 100% rename from FppTest/state_machine/HackSm.plantuml rename to FppTest/state_machine/external_instance/HackSm.plantuml diff --git a/FppTest/state_machine/external_instance/HackSm.png b/FppTest/state_machine/external_instance/HackSm.png new file mode 100644 index 0000000000000000000000000000000000000000..9ec785a6e7e2cc2b4b7a2644ba5d2566d21b42d8 GIT binary patch literal 16903 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 P1I|sAJ2%RdOoRRxLCW|& literal 0 HcmV?d00001 diff --git a/FppTest/state_machine/Makefile b/FppTest/state_machine/external_instance/Makefile similarity index 100% rename from FppTest/state_machine/Makefile rename to FppTest/state_machine/external_instance/Makefile diff --git a/FppTest/state_machine/SMEvents.hpp b/FppTest/state_machine/external_instance/SMEvents.hpp similarity index 100% rename from FppTest/state_machine/SMEvents.hpp rename to FppTest/state_machine/external_instance/SMEvents.hpp diff --git a/FppTest/state_machine/SmTest.cpp b/FppTest/state_machine/external_instance/SmTest.cpp similarity index 98% rename from FppTest/state_machine/SmTest.cpp rename to FppTest/state_machine/external_instance/SmTest.cpp index 776071bf89..1133cee469 100644 --- a/FppTest/state_machine/SmTest.cpp +++ b/FppTest/state_machine/external_instance/SmTest.cpp @@ -6,7 +6,7 @@ #include -#include "FppTest/state_machine/SmTest.hpp" +#include "FppTest/state_machine/external_instance/SmTest.hpp" #include "Fw/Types/Assert.hpp" namespace FppTest { diff --git a/FppTest/state_machine/SmTest.fpp b/FppTest/state_machine/external_instance/SmTest.fpp similarity index 100% rename from FppTest/state_machine/SmTest.fpp rename to FppTest/state_machine/external_instance/SmTest.fpp diff --git a/FppTest/state_machine/SmTest.hpp b/FppTest/state_machine/external_instance/SmTest.hpp similarity index 98% rename from FppTest/state_machine/SmTest.hpp rename to FppTest/state_machine/external_instance/SmTest.hpp index 55f7dec146..d4bc4ec635 100644 --- a/FppTest/state_machine/SmTest.hpp +++ b/FppTest/state_machine/external_instance/SmTest.hpp @@ -9,7 +9,7 @@ #include -#include "FppTest/state_machine/SmTestComponentAc.hpp" +#include "FppTest/state_machine/external_instance/SmTestComponentAc.hpp" #include "Fw/Types/String.hpp" namespace FppTest { diff --git a/FppTest/state_machine/test/ut/SmTestTestMain.cpp b/FppTest/state_machine/external_instance/test/ut/SmTestTestMain.cpp similarity index 86% rename from FppTest/state_machine/test/ut/SmTestTestMain.cpp rename to FppTest/state_machine/external_instance/test/ut/SmTestTestMain.cpp index 769b464f3d..d4b2ee352b 100644 --- a/FppTest/state_machine/test/ut/SmTestTestMain.cpp +++ b/FppTest/state_machine/external_instance/test/ut/SmTestTestMain.cpp @@ -2,7 +2,7 @@ // SmTestTestMain.cpp // ---------------------------------------------------------------------- -#include "FppTest/state_machine/test/ut/SmTestTester.hpp" +#include "FppTest/state_machine/external_instance/test/ut/SmTestTester.hpp" #include "Fw/Test/UnitTest.hpp" #include "STest/Random/Random.hpp" diff --git a/FppTest/state_machine/test/ut/SmTestTester.cpp b/FppTest/state_machine/external_instance/test/ut/SmTestTester.cpp similarity index 97% rename from FppTest/state_machine/test/ut/SmTestTester.cpp rename to FppTest/state_machine/external_instance/test/ut/SmTestTester.cpp index b16b77fa3d..0b6bc0fcd3 100644 --- a/FppTest/state_machine/test/ut/SmTestTester.cpp +++ b/FppTest/state_machine/external_instance/test/ut/SmTestTester.cpp @@ -6,7 +6,7 @@ #include -#include "FppTest/state_machine/test/ut/SmTestTester.hpp" +#include "FppTest/state_machine/external_instance/test/ut/SmTestTester.hpp" #include "Fw/Types/ExternalString.hpp" #include "STest/Pick/Pick.hpp" diff --git a/FppTest/state_machine/test/ut/SmTestTester.hpp b/FppTest/state_machine/external_instance/test/ut/SmTestTester.hpp similarity index 97% rename from FppTest/state_machine/test/ut/SmTestTester.hpp rename to FppTest/state_machine/external_instance/test/ut/SmTestTester.hpp index 66021b5622..cdf1894e5c 100644 --- a/FppTest/state_machine/test/ut/SmTestTester.hpp +++ b/FppTest/state_machine/external_instance/test/ut/SmTestTester.hpp @@ -8,7 +8,7 @@ #define FppTest_SmTest_Tester_HPP #include "SmTestGTestBase.hpp" -#include "FppTest/state_machine/SmTest.hpp" +#include "FppTest/state_machine/external_instance/SmTest.hpp" #include "STest/Pick/Pick.hpp" namespace FppTest { diff --git a/FppTest/state_machine/internal/CMakeLists.txt b/FppTest/state_machine/internal/CMakeLists.txt new file mode 100644 index 0000000000..6d339b9f8e --- /dev/null +++ b/FppTest/state_machine/internal/CMakeLists.txt @@ -0,0 +1,4 @@ +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/choice/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/harness/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/initial/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/state/") diff --git a/FppTest/state_machine/internal/README.md b/FppTest/state_machine/internal/README.md new file mode 100644 index 0000000000..965fa7c40b --- /dev/null +++ b/FppTest/state_machine/internal/README.md @@ -0,0 +1,4 @@ +# state_machine/internal + +Tests for internal FPP state machines, i.e., state machines whose behavior +is expressed in FPP. diff --git a/FppTest/state_machine/internal/choice/Basic.cpp b/FppTest/state_machine/internal/choice/Basic.cpp new file mode 100644 index 0000000000..22c52c3f55 --- /dev/null +++ b/FppTest/state_machine/internal/choice/Basic.cpp @@ -0,0 +1,82 @@ +// ====================================================================== +// +// \title Basic.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a choice (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/choice/Basic.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmChoice { + +Basic::Basic() : BasicStateMachineBase(), m_action_a_history(), m_action_b_history(), m_guard_g() {} + +void Basic::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void Basic::action_b(Signal signal) { + this->m_action_b_history.push(signal); +} + +bool Basic::guard_g(Signal signal) const { + return this->m_guard_g.call(signal); +} + +void Basic::testTrue() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + ASSERT_EQ(this->getState(), State::S2); +} + +void Basic::testFalse() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getItemAt(0), Signal::s); + ASSERT_EQ(this->getState(), State::S3); +} + +} // namespace SmChoice + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/choice/Basic.fpp b/FppTest/state_machine/internal/choice/Basic.fpp new file mode 100644 index 0000000000..6585106087 --- /dev/null +++ b/FppTest/state_machine/internal/choice/Basic.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmChoice { + + include "include/Basic.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/choice/Basic.hpp b/FppTest/state_machine/internal/choice/Basic.hpp new file mode 100644 index 0000000000..9f55f3908f --- /dev/null +++ b/FppTest/state_machine/internal/choice/Basic.hpp @@ -0,0 +1,69 @@ +// ====================================================================== +// +// \title Basic.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a choice (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_Basic_HPP +#define FppTest_State_Basic_HPP + +#include "FppTest/state_machine/internal/choice/BasicStateMachineAc.hpp" +#include "FppTest/state_machine/internal/harness/Harness.hpp" + +namespace FppTest { + +namespace SmChoice { + +//! A basic state machine with a choice +class Basic final : public BasicStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + Basic(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal //!< The signal + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal //!< The signal + ) const final; + + public: + //! Run the test with the true guard + void testTrue(); + + //! Run the test with the false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b of Basic + SmHarness::History m_action_b_history; + + //! The guard g + SmHarness::NoArgGuard m_guard_g; +}; + +} // namespace SmChoice + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/choice/BasicU32.cpp b/FppTest/state_machine/internal/choice/BasicU32.cpp new file mode 100644 index 0000000000..61e8f0b993 --- /dev/null +++ b/FppTest/state_machine/internal/choice/BasicU32.cpp @@ -0,0 +1,87 @@ +// ====================================================================== +// +// \title BasicU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a U32 choice (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/choice/BasicU32.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmChoice { + +BasicU32::BasicU32() : BasicU32StateMachineBase(), m_action_a_history(), m_action_b_history(), m_guard_g() {} + +void BasicU32::action_a(Signal signal, U32 value) { + this->m_action_a_history.push(signal, value); +} + +void BasicU32::action_b(Signal signal) { + this->m_action_b_history.push(signal); +} + +bool BasicU32::guard_g(Signal signal, U32 value) const { + return this->m_guard_g.call(signal, value); +} + +void BasicU32::testTrue() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + this->sendSignal_s(value); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + ASSERT_EQ(this->getState(), State::S2); +} + +void BasicU32::testFalse() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + this->sendSignal_s(value); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getItemAt(0), Signal::s); + ASSERT_EQ(this->getState(), State::S3); +} + +} // namespace SmChoice + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/choice/BasicU32.fpp b/FppTest/state_machine/internal/choice/BasicU32.fpp new file mode 100644 index 0000000000..2d0bcb60ff --- /dev/null +++ b/FppTest/state_machine/internal/choice/BasicU32.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmChoice { + + include "include/BasicU32.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/choice/BasicU32.hpp b/FppTest/state_machine/internal/choice/BasicU32.hpp new file mode 100644 index 0000000000..a64f4cc93a --- /dev/null +++ b/FppTest/state_machine/internal/choice/BasicU32.hpp @@ -0,0 +1,71 @@ +// ====================================================================== +// +// \title BasicU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a U32 choice (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicU32_HPP +#define FppTest_State_BasicU32_HPP + +#include "FppTest/state_machine/internal/choice/BasicU32StateMachineAc.hpp" +#include "FppTest/state_machine/internal/harness/Harness.hpp" + +namespace FppTest { + +namespace SmChoice { + +//! A basic state machine with a U32 choice +class BasicU32 final : public BasicU32StateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicU32(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + U32 value //!< The value + ) final; + + //! Implementation of action b + void action_b(Signal signal //!< The signal + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + U32 value //!< The value + ) const final; + + public: + //! Run the test with the true guard + void testTrue(); + + //! Run the test with the false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The history associated with action b + SmHarness::History m_action_b_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmChoice + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/choice/CMakeLists.txt b/FppTest/state_machine/internal/choice/CMakeLists.txt new file mode 100644 index 0000000000..9db4fea92f --- /dev/null +++ b/FppTest/state_machine/internal/choice/CMakeLists.txt @@ -0,0 +1,24 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToChoice.fpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToState.fpp" + "${CMAKE_CURRENT_LIST_DIR}/InputPairU16U32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Sequence.fpp" + "${CMAKE_CURRENT_LIST_DIR}/SequenceU32.fpp" +) +set(MOD_DEPS FppTest/state_machine/internal/harness) +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToChoice.cpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToState.cpp" + "${CMAKE_CURRENT_LIST_DIR}/InputPairU16U32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Sequence.cpp" + "${CMAKE_CURRENT_LIST_DIR}/SequenceU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/main.cpp" +) +set(UT_MOD_DEPS STest) +register_fprime_ut() diff --git a/FppTest/state_machine/internal/choice/ChoiceToChoice.cpp b/FppTest/state_machine/internal/choice/ChoiceToChoice.cpp new file mode 100644 index 0000000000..b59d072f3a --- /dev/null +++ b/FppTest/state_machine/internal/choice/ChoiceToChoice.cpp @@ -0,0 +1,137 @@ +// ====================================================================== +// +// \title ChoiceToChoice.hpp +// \author R. Bocchino +// \brief Test class for state machine with a choice-to-choice transition (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/choice/ChoiceToChoice.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmChoice { + +ChoiceToChoice::ChoiceToChoice() : ChoiceToChoiceStateMachineBase(), m_actionHistory(), m_guard_g1(), m_guard_g2() {} + +void ChoiceToChoice::action_exitS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void ChoiceToChoice::action_a(Signal signal) { + this->m_actionHistory.push(signal, ActionId::A); +} + +void ChoiceToChoice::action_enterS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S2); +} + +bool ChoiceToChoice::guard_g1(Signal signal) const { + return this->m_guard_g1.call(signal); +} + +bool ChoiceToChoice::guard_g2(Signal signal) const { + return this->m_guard_g2.call(signal); +} + +void ChoiceToChoice::testG1True() { + this->m_actionHistory.clear(); + this->m_guard_g1.reset(); + this->m_guard_g2.reset(); + this->m_guard_g1.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_actionHistory.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + const FwIndexType expectedSize = 3; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::s); + } + const auto& values = this->m_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(this->getState(), State::S2_S3); +} + +void ChoiceToChoice::testG1FalseG2True() { + this->m_actionHistory.clear(); + this->m_guard_g1.reset(); + this->m_guard_g2.reset(); + this->m_guard_g2.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_actionHistory.getSize(), 0); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + const FwIndexType expectedSize = 3; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::s); + } + const auto& values = this->m_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(this->getState(), State::S2_S3); +} + +void ChoiceToChoice::testG1FalseG2False() { + this->m_actionHistory.clear(); + this->m_guard_g1.reset(); + this->m_guard_g2.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_actionHistory.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + const FwIndexType expectedSize = 3; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::s); + } + const auto& values = this->m_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(this->getState(), State::S2_S4); +} + +} // namespace SmChoice + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/choice/ChoiceToChoice.fpp b/FppTest/state_machine/internal/choice/ChoiceToChoice.fpp new file mode 100644 index 0000000000..caf0c72f91 --- /dev/null +++ b/FppTest/state_machine/internal/choice/ChoiceToChoice.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmChoice { + + include "include/ChoiceToChoice.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/choice/ChoiceToChoice.hpp b/FppTest/state_machine/internal/choice/ChoiceToChoice.hpp new file mode 100644 index 0000000000..1d94ff6219 --- /dev/null +++ b/FppTest/state_machine/internal/choice/ChoiceToChoice.hpp @@ -0,0 +1,88 @@ +// ====================================================================== +// +// \title ChoiceToChoice.hpp +// \author R. Bocchino +// \brief Test class for state machine with a choice-to-choice transition (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United Choices Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_Choice_ChoiceToChoice_HPP +#define FppTest_Choice_ChoiceToChoice_HPP + +#include "FppTest/state_machine/internal/choice/ChoiceToChoiceStateMachineAc.hpp" +#include "FppTest/state_machine/internal/harness/Harness.hpp" + +namespace FppTest { + +namespace SmChoice { + +//! A state machine with a choice-to-choice transition +class ChoiceToChoice final : public ChoiceToChoiceStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Action IDs + enum class ActionId { + EXIT_S1, + A, + ENTER_S2, + }; + + public: + //! Constructor + ChoiceToChoice(); + + private: + //! Implementation of action exitS1 + void action_exitS1(Signal signal //!< The signal + ) final; + + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action enterS2 + void action_enterS2(Signal signal //!< The signal + ) final; + + //! Implementation of guard g1 + bool guard_g1(Signal signal //!< The signal + ) const final; + + //! Implementation of guard g2 + bool guard_g2(Signal signal //!< The signal + ) const final; + + public: + //! Run the test with g1 true + void testG1True(); + + //! Run the test with g1 false and g2 true + void testG1FalseG2True(); + + //! Run the test with g1 false and g2 false + void testG1FalseG2False(); + + private: + //! The action history + SmHarness::SignalValueHistory m_actionHistory; + + //! The guard g1 + SmHarness::NoArgGuard m_guard_g1; + + //! The guard g2 + SmHarness::NoArgGuard m_guard_g2; +}; + +} // namespace SmChoice + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/choice/ChoiceToState.cpp b/FppTest/state_machine/internal/choice/ChoiceToState.cpp new file mode 100644 index 0000000000..3000fc8887 --- /dev/null +++ b/FppTest/state_machine/internal/choice/ChoiceToState.cpp @@ -0,0 +1,102 @@ +// ====================================================================== +// +// \title ChoiceToState.hpp +// \author R. Bocchino +// \brief Test class for state machine with a choice-to-state transition (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/choice/ChoiceToState.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmChoice { + +ChoiceToState::ChoiceToState() : ChoiceToStateStateMachineBase(), m_actionHistory(), m_guard_g() {} + +void ChoiceToState::action_exitS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void ChoiceToState::action_a(Signal signal) { + this->m_actionHistory.push(signal, ActionId::A); +} + +bool ChoiceToState::guard_g(Signal signal) const { + return this->m_guard_g.call(signal); +} + +void ChoiceToState::action_enterS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void ChoiceToState::action_enterS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S3); +} + +void ChoiceToState::testTrue() { + this->m_actionHistory.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_actionHistory.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getItemAt(0), Signal::s); + const FwIndexType expectedSize = 5; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::s); + } + const auto& values = this->m_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(values.getItemAt(3), ActionId::A); + ASSERT_EQ(values.getItemAt(4), ActionId::ENTER_S3); + ASSERT_EQ(this->getState(), State::S2_S3); +} + +void ChoiceToState::testFalse() { + this->m_actionHistory.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_actionHistory.getSize(), 0); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getItemAt(0), Signal::s); + const FwIndexType expectedSize = 4; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::s); + } + const auto& values = this->m_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(values.getItemAt(3), ActionId::ENTER_S3); + ASSERT_EQ(this->getState(), State::S2_S3); +} + +} // namespace SmChoice + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/choice/ChoiceToState.fpp b/FppTest/state_machine/internal/choice/ChoiceToState.fpp new file mode 100644 index 0000000000..18f1d349a2 --- /dev/null +++ b/FppTest/state_machine/internal/choice/ChoiceToState.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmChoice { + + include "include/ChoiceToState.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/choice/ChoiceToState.hpp b/FppTest/state_machine/internal/choice/ChoiceToState.hpp new file mode 100644 index 0000000000..38de3c0365 --- /dev/null +++ b/FppTest/state_machine/internal/choice/ChoiceToState.hpp @@ -0,0 +1,83 @@ +// ====================================================================== +// +// \title ChoiceToState.hpp +// \author R. Bocchino +// \brief Test class for state machine with a choice-to-state transition (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_ChoiceToState_HPP +#define FppTest_State_ChoiceToState_HPP + +#include "FppTest/state_machine/internal/choice/ChoiceToStateStateMachineAc.hpp" +#include "FppTest/state_machine/internal/harness/Harness.hpp" + +namespace FppTest { + +namespace SmChoice { + +//! A state machine with a choice-to-state transition +class ChoiceToState final : public ChoiceToStateStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Action IDs + enum class ActionId { + EXIT_S1, + A, + ENTER_S2, + ENTER_S3, + }; + + public: + //! Constructor + ChoiceToState(); + + private: + //! Implementation of action exitS1 + void action_exitS1(Signal signal //!< The signal + ) final; + + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action enterS2 + void action_enterS2(Signal signal //!< The signal + ) final; + + //! Implementation of action enterS3 + void action_enterS3(Signal signal //!< The signal + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal //!< The signal + ) const final; + + public: + //! Run the test with the true guard + void testTrue(); + + //! Run the test with the false guard + void testFalse(); + + private: + //! The action history + SmHarness::SignalValueHistory m_actionHistory; + + //! The guard g + SmHarness::NoArgGuard m_guard_g; +}; + +} // namespace SmChoice + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/choice/InputPairU16U32.cpp b/FppTest/state_machine/internal/choice/InputPairU16U32.cpp new file mode 100644 index 0000000000..d7df76988f --- /dev/null +++ b/FppTest/state_machine/internal/choice/InputPairU16U32.cpp @@ -0,0 +1,121 @@ +// ====================================================================== +// +// \title InputPairU16U32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a U32 choice (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/choice/InputPairU16U32.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmChoice { + +InputPairU16U32::InputPairU16U32() : InputPairU16U32StateMachineBase(), m_action_a_history(), m_guard_g() {} + +void InputPairU16U32::action_a(Signal signal, U32 value) { + this->m_action_a_history.push(signal, value); +} + +bool InputPairU16U32::guard_g(Signal signal, U32 value) const { + return this->m_guard_g.call(signal, value); +} + +void InputPairU16U32::testS1True() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const U16 value = static_cast(STest::Pick::any()); + this->sendSignal_s1(value); + this->sendSignal_s1(value); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s1); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->getState(), State::S2); +} + +void InputPairU16U32::testS1False() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const U16 value = static_cast(STest::Pick::any()); + this->sendSignal_s1(value); + this->sendSignal_s1(value); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s1); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->getState(), State::S3); +} + +void InputPairU16U32::testS2True() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s2(value); + this->sendSignal_s2(value); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s2); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s2); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->getState(), State::S2); +} + +void InputPairU16U32::testS2False() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s2(value); + this->sendSignal_s2(value); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s2); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s2); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->getState(), State::S3); +} + +} // namespace SmChoice + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/choice/InputPairU16U32.fpp b/FppTest/state_machine/internal/choice/InputPairU16U32.fpp new file mode 100644 index 0000000000..0d4d7c26cb --- /dev/null +++ b/FppTest/state_machine/internal/choice/InputPairU16U32.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmChoice { + + include "include/InputPairU16U32.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/choice/InputPairU16U32.hpp b/FppTest/state_machine/internal/choice/InputPairU16U32.hpp new file mode 100644 index 0000000000..81831890f8 --- /dev/null +++ b/FppTest/state_machine/internal/choice/InputPairU16U32.hpp @@ -0,0 +1,70 @@ +// ====================================================================== +// +// \title InputPairU16U32.hpp +// \author R. Bocchino +// \brief Test class for state machine with a pair of choice inputs (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_InputPairU16U32_HPP +#define FppTest_State_InputPairU16U32_HPP + +#include "FppTest/state_machine/internal/choice/InputPairU16U32StateMachineAc.hpp" +#include "FppTest/state_machine/internal/harness/Harness.hpp" + +namespace FppTest { + +namespace SmChoice { + +//! A basic state machine with a pair of choice inputs +class InputPairU16U32 final : public InputPairU16U32StateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + InputPairU16U32(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + U32 value //!< The value + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + U32 value //!< The value + ) const final; + + public: + //! Run the test with signal s1 and true guard + void testS1True(); + + //! Run the test with signal s1 and false guard + void testS1False(); + + //! Run the test with signal s2 and true guard + void testS2True(); + + //! Run the test with signal s2 and false guard + void testS2False(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmChoice + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/choice/README.md b/FppTest/state_machine/internal/choice/README.md new file mode 100644 index 0000000000..56d0dcad4a --- /dev/null +++ b/FppTest/state_machine/internal/choice/README.md @@ -0,0 +1,3 @@ +# state_machine/internal/choice + +Tests for transitions out of choices in FPP internal state machines. diff --git a/FppTest/state_machine/internal/choice/Sequence.cpp b/FppTest/state_machine/internal/choice/Sequence.cpp new file mode 100644 index 0000000000..ef5fda1baa --- /dev/null +++ b/FppTest/state_machine/internal/choice/Sequence.cpp @@ -0,0 +1,118 @@ +// ====================================================================== +// +// \title Sequence.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with choice sequence (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/choice/Sequence.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmChoice { + +Sequence::Sequence() + : SequenceStateMachineBase(), m_action_a_history(), m_action_b_history(), m_guard_g1(), m_guard_g2() {} + +void Sequence::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void Sequence::action_b(Signal signal) { + this->m_action_b_history.push(signal); +} + +bool Sequence::guard_g1(Signal signal) const { + return this->m_guard_g1.call(signal); +} + +bool Sequence::guard_g2(Signal signal) const { + return this->m_guard_g2.call(signal); +} + +void Sequence::testG1True() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g1.reset(); + this->m_guard_g1.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + ASSERT_EQ(this->getState(), State::S2); +} + +void Sequence::testG1FalseG2True() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g1.reset(); + this->m_guard_g2.reset(); + this->m_guard_g2.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + ASSERT_EQ(this->getState(), State::S3); +} + +void Sequence::testG1FalseG2False() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g1.reset(); + this->m_guard_g2.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + this->sendSignal_s(); + this->sendSignal_s(); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getItemAt(0), Signal::s); + ASSERT_EQ(this->getState(), State::S4); +} + +} // namespace SmChoice + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/choice/Sequence.fpp b/FppTest/state_machine/internal/choice/Sequence.fpp new file mode 100644 index 0000000000..93631df7e9 --- /dev/null +++ b/FppTest/state_machine/internal/choice/Sequence.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmChoice { + + include "include/Sequence.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/choice/Sequence.hpp b/FppTest/state_machine/internal/choice/Sequence.hpp new file mode 100644 index 0000000000..1a6ebe815e --- /dev/null +++ b/FppTest/state_machine/internal/choice/Sequence.hpp @@ -0,0 +1,79 @@ +// ====================================================================== +// +// \title Sequence.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a choice sequence (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_Sequence_HPP +#define FppTest_State_Sequence_HPP + +#include "FppTest/state_machine/internal/choice/SequenceStateMachineAc.hpp" +#include "FppTest/state_machine/internal/harness/Harness.hpp" + +namespace FppTest { + +namespace SmChoice { + +//! A basic state machine with a choice sequence +class Sequence final : public SequenceStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + Sequence(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal //!< The signal + ) final; + + //! Implementation of guard g1 + bool guard_g1(Signal signal //!< The signal + ) const final; + + //! Implementation of guard g2 + bool guard_g2(Signal signal //!< The signal + ) const final; + + public: + //! Run the test with g1 true + void testG1True(); + + //! Run the test with g1 true and g2 true + void testG1FalseG2True(); + + //! Run the test with g1 true and g2 false + void testG1FalseG2False(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b + SmHarness::History m_action_b_history; + + //! The guard g1 + SmHarness::NoArgGuard m_guard_g1; + + //! The guard g2 + SmHarness::NoArgGuard m_guard_g2; +}; + +} // namespace SmChoice + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/choice/SequenceU32.cpp b/FppTest/state_machine/internal/choice/SequenceU32.cpp new file mode 100644 index 0000000000..46f7c7d794 --- /dev/null +++ b/FppTest/state_machine/internal/choice/SequenceU32.cpp @@ -0,0 +1,124 @@ +// ====================================================================== +// +// \title SequenceU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a U32 choice (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/choice/SequenceU32.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmChoice { + +SequenceU32::SequenceU32() + : SequenceU32StateMachineBase(), m_action_a_history(), m_action_b_history(), m_guard_g1(), m_guard_g2() {} + +void SequenceU32::action_a(Signal signal, U32 value) { + this->m_action_a_history.push(signal, value); +} + +void SequenceU32::action_b(Signal signal) { + this->m_action_b_history.push(signal); +} + +bool SequenceU32::guard_g1(Signal signal) const { + return this->m_guard_g1.call(signal); +} + +bool SequenceU32::guard_g2(Signal signal, U32 value) const { + return this->m_guard_g2.call(signal, value); +} + +void SequenceU32::testG1True() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g1.reset(); + this->m_guard_g1.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + this->sendSignal_s(value); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + ASSERT_EQ(this->getState(), State::S2); +} + +void SequenceU32::testG1FalseG2True() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g1.reset(); + this->m_guard_g2.reset(); + this->m_guard_g2.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + this->sendSignal_s(value); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + ASSERT_EQ(this->getState(), State::S3); +} + +void SequenceU32::testG1FalseG2False() { + this->m_action_a_history.clear(); + this->m_action_b_history.clear(); + this->m_guard_g1.reset(); + this->m_guard_g2.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + this->sendSignal_s(value); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g1.getCallHistory().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g2.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getItemAt(0), Signal::s); + ASSERT_EQ(this->getState(), State::S4); +} + +} // namespace SmChoice + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/choice/SequenceU32.fpp b/FppTest/state_machine/internal/choice/SequenceU32.fpp new file mode 100644 index 0000000000..c4e7d261d7 --- /dev/null +++ b/FppTest/state_machine/internal/choice/SequenceU32.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmChoice { + + include "include/SequenceU32.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/choice/SequenceU32.hpp b/FppTest/state_machine/internal/choice/SequenceU32.hpp new file mode 100644 index 0000000000..fd05fae887 --- /dev/null +++ b/FppTest/state_machine/internal/choice/SequenceU32.hpp @@ -0,0 +1,81 @@ +// ====================================================================== +// +// \title SequenceU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with a U32 choice sequence (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_SequenceU32_HPP +#define FppTest_State_SequenceU32_HPP + +#include "FppTest/state_machine/internal/choice/SequenceU32StateMachineAc.hpp" +#include "FppTest/state_machine/internal/harness/Harness.hpp" + +namespace FppTest { + +namespace SmChoice { + +//! A basic state machine with a U32 choice sequence +class SequenceU32 final : public SequenceU32StateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + SequenceU32(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + U32 value //!< The value + ) final; + + //! Implementation of action b + void action_b(Signal signal //!< The signal + ) final; + + //! Implementation of guard g1 + bool guard_g1(Signal signal //!< The signal + ) const final; + + //! Implementation of guard g2 + bool guard_g2(Signal signal, //!< The signal + U32 value //!< The value + ) const final; + + public: + //! Run the test with g1 true + void testG1True(); + + //! Run the test with g1 true and g2 true + void testG1FalseG2True(); + + //! Run the test with g1 true and g2 false + void testG1FalseG2False(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The history associated with action b + SmHarness::History m_action_b_history; + + //! The guard g1 + SmHarness::NoArgGuard m_guard_g1; + + //! The guard g2 + SmHarness::Guard m_guard_g2; +}; + +} // namespace SmChoice + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/choice/include/Basic.fppi b/FppTest/state_machine/internal/choice/include/Basic.fppi new file mode 100644 index 0000000000..81e2657d4a --- /dev/null +++ b/FppTest/state_machine/internal/choice/include/Basic.fppi @@ -0,0 +1,38 @@ +@ A basic state machine with a choice +state machine Basic { + + @ Action a + action a + + @ Action b + action b + + @ Signal s + signal s + + @ Guard g + guard g + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ State transition + on s enter C + + } + + @ Choice C + choice C { + if g do { a } enter S2 else do { b } enter S3 + } + + @ State S2 + state S2 + + @ State S3 + state S3 + +} diff --git a/FppTest/state_machine/internal/choice/include/BasicU32.fppi b/FppTest/state_machine/internal/choice/include/BasicU32.fppi new file mode 100644 index 0000000000..50cce92584 --- /dev/null +++ b/FppTest/state_machine/internal/choice/include/BasicU32.fppi @@ -0,0 +1,38 @@ +@ A basic state machine with a U32 choice +state machine BasicU32 { + + @ Action a + action a: U32 + + @ Action b + action b + + @ Signal s + signal s: U32 + + @ Guard g + guard g: U32 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ State transition + on s enter C + + } + + @ Choice C + choice C { + if g do { a } enter S2 else do { b } enter S3 + } + + @ State S2 + state S2 + + @ State S3 + state S3 + +} diff --git a/FppTest/state_machine/internal/choice/include/ChoiceToChoice.fppi b/FppTest/state_machine/internal/choice/include/ChoiceToChoice.fppi new file mode 100644 index 0000000000..c93837a9e8 --- /dev/null +++ b/FppTest/state_machine/internal/choice/include/ChoiceToChoice.fppi @@ -0,0 +1,64 @@ +@ A state machine for testing choice-to-choice transitions +@ with hierarchy +state machine ChoiceToChoice { + + @ Exit S1 + action exitS1 + + @ Action a + action a + + @ Enter S2 + action enterS2 + + @ Signal s + signal s + + @ Guard g1 + guard g1 + + @ Guard g2 + guard g2 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Exit S1 + exit do { exitS1 } + + @ Choice C1 + choice C1 { + if g1 do { a } enter S2 else do { a } enter S2.C2 + } + + @ State transition to C1 + on s enter C1 + + } + + @ State S2 + state S2 { + + @ Enter S2 + entry do { enterS2 } + + @ Initial transition + initial enter S3 + + @ Choice C2 + choice C2 { + if g2 enter S3 else enter S4 + } + + @ State S3 + state S3 + + @ State S4 + state S4 + + } + +} diff --git a/FppTest/state_machine/internal/choice/include/ChoiceToState.fppi b/FppTest/state_machine/internal/choice/include/ChoiceToState.fppi new file mode 100644 index 0000000000..f472c58963 --- /dev/null +++ b/FppTest/state_machine/internal/choice/include/ChoiceToState.fppi @@ -0,0 +1,61 @@ +@ A state machine for testing choice-to-state transitions +@ with hierarchy +state machine ChoiceToState { + + @ Exit S1 + action exitS1 + + @ Action a + action a + + @ Enter S2 + action enterS2 + + @ Enter S3 + action enterS3 + + @ Signal s + signal s + + @ Guard g + guard g + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Exit S1 + exit do { exitS1 } + + @ Choice C + choice C { + if g do { a } enter S2 else do { a } enter S2.S3 + } + + @ State transition to C + on s enter C + + } + + @ State S2 + state S2 { + + @ Enter S2 + entry do { enterS2 } + + @ Initial transition + initial do { a } enter S3 + + @ State S3 + state S3 { + + @ Enter S3 + entry do { enterS3 } + + } + + } + +} diff --git a/FppTest/state_machine/internal/choice/include/InputPairU16U32.fppi b/FppTest/state_machine/internal/choice/include/InputPairU16U32.fppi new file mode 100644 index 0000000000..7b406f4e98 --- /dev/null +++ b/FppTest/state_machine/internal/choice/include/InputPairU16U32.fppi @@ -0,0 +1,41 @@ +@ A state machine with two inputs to a choice +state machine InputPairU16U32 { + + @ Action a + action a: U32 + + @ Signal s1 + signal s1: U16 + + @ Signal s2 + signal s2: U32 + + @ Guard g + guard g: U32 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ State transition on s1 + on s1 enter C + + @ State transition on s2 + on s2 enter C + + } + + @ Choice C + choice C { + if g do { a } enter S2 else do { a } enter S3 + } + + @ State S2 + state S2 + + @ State S3 + state S3 + +} diff --git a/FppTest/state_machine/internal/choice/include/Sequence.fppi b/FppTest/state_machine/internal/choice/include/Sequence.fppi new file mode 100644 index 0000000000..262051cc60 --- /dev/null +++ b/FppTest/state_machine/internal/choice/include/Sequence.fppi @@ -0,0 +1,49 @@ +@ A basic state machine with a choice sequence +state machine Sequence { + + @ Action a + action a + + @ Action b + action b + + @ Signal s + signal s + + @ Guard g1 + guard g1 + + @ Guard g2 + guard g2 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ State transition + on s enter C1 + + } + + @ Choice C1 + choice C1 { + if g1 enter S2 else enter C2 + } + + @ Choice C2 + choice C2 { + if g2 do { a } enter S3 else do { b } enter S4 + } + + @ State S2 + state S2 + + @ State S3 + state S3 + + @ State S4 + state S4 + +} diff --git a/FppTest/state_machine/internal/choice/include/SequenceU32.fppi b/FppTest/state_machine/internal/choice/include/SequenceU32.fppi new file mode 100644 index 0000000000..71a4a63b4f --- /dev/null +++ b/FppTest/state_machine/internal/choice/include/SequenceU32.fppi @@ -0,0 +1,49 @@ +@ A basic state machine with a U32 choice sequence +state machine SequenceU32 { + + @ Action a + action a: U32 + + @ Action b + action b + + @ Signal s + signal s: U32 + + @ Guard g1 + guard g1 + + @ Guard g2 + guard g2: U32 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ State transition + on s enter C1 + + } + + @ Choice C1 + choice C1 { + if g1 enter S2 else enter C2 + } + + @ Choice C2 + choice C2 { + if g2 do { a } enter S3 else do { b } enter S4 + } + + @ State S2 + state S2 + + @ State S3 + state S3 + + @ State S4 + state S4 + +} diff --git a/FppTest/state_machine/internal/choice/main.cpp b/FppTest/state_machine/internal/choice/main.cpp new file mode 100644 index 0000000000..288cba8598 --- /dev/null +++ b/FppTest/state_machine/internal/choice/main.cpp @@ -0,0 +1,119 @@ +// ---------------------------------------------------------------------- +// main.cpp +// ---------------------------------------------------------------------- + +#include + +#include "FppTest/state_machine/internal/choice/Basic.hpp" +#include "FppTest/state_machine/internal/choice/BasicU32.hpp" +#include "FppTest/state_machine/internal/choice/ChoiceToChoice.hpp" +#include "FppTest/state_machine/internal/choice/ChoiceToState.hpp" +#include "FppTest/state_machine/internal/choice/InputPairU16U32.hpp" +#include "FppTest/state_machine/internal/choice/Sequence.hpp" +#include "FppTest/state_machine/internal/choice/SequenceU32.hpp" +#include "STest/STest/Random/Random.hpp" + +TEST(Basic, True) { + FppTest::SmChoice::Basic basic; + basic.testTrue(); +} + +TEST(Basic, False) { + FppTest::SmChoice::Basic basic; + basic.testFalse(); +} + +TEST(BasicU32, True) { + FppTest::SmChoice::BasicU32 basicU32; + basicU32.testTrue(); +} + +TEST(BasicU32, False) { + FppTest::SmChoice::BasicU32 basicU32; + basicU32.testFalse(); +} + +TEST(InputPairU16U32, S1True) { + FppTest::SmChoice::InputPairU16U32 inputPair; + inputPair.testS1True(); +} + +TEST(InputPairU16U32, S1False) { + FppTest::SmChoice::InputPairU16U32 inputPair; + inputPair.testS1False(); +} + +TEST(InputPairU16U32, S2True) { + FppTest::SmChoice::InputPairU16U32 inputPair; + inputPair.testS2True(); +} + +TEST(InputPairU16U32, S2False) { + FppTest::SmChoice::InputPairU16U32 inputPair; + inputPair.testS2False(); +} + +TEST(ChoiceToChoice, G1True) { + FppTest::SmChoice::ChoiceToChoice choiceToChoice; + choiceToChoice.testG1True(); +} + +TEST(ChoiceToChoice, G1FalseG2True) { + FppTest::SmChoice::ChoiceToChoice choiceToChoice; + choiceToChoice.testG1FalseG2True(); +} + +TEST(ChoiceToChoice, G1FalseG2False) { + FppTest::SmChoice::ChoiceToChoice choiceToChoice; + choiceToChoice.testG1FalseG2False(); +} + +TEST(ChoiceToState, True) { + FppTest::SmChoice::ChoiceToState choiceToState; + choiceToState.testTrue(); +} + +TEST(ChoiceToState, False) { + FppTest::SmChoice::ChoiceToState choiceToState; + choiceToState.testFalse(); +} + +TEST(Sequence, G1True) { + FppTest::SmChoice::Sequence sequence; + sequence.testG1True(); +} + +TEST(Sequence, G1FalseG2True) { + FppTest::SmChoice::Sequence sequence; + sequence.testG1FalseG2True(); +} + +TEST(Sequence, G1FalseG2False) { + FppTest::SmChoice::Sequence sequence; + sequence.testG1FalseG2False(); +} + +TEST(SequenceU32, G1True) { + FppTest::SmChoice::SequenceU32 sequenceU32; + sequenceU32.testG1True(); +} + +TEST(SequenceU32, G1FalseG2True) { + FppTest::SmChoice::SequenceU32 sequenceU32; + sequenceU32.testG1FalseG2True(); +} + +TEST(SequenceU32, G1FalseG2False) { + FppTest::SmChoice::SequenceU32 sequenceU32; + sequenceU32.testG1FalseG2False(); +} + +// ---------------------------------------------------------------------- +// Main function +// ---------------------------------------------------------------------- + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + STest::Random::seed(); + return RUN_ALL_TESTS(); +} diff --git a/FppTest/state_machine/internal/harness/CMakeLists.txt b/FppTest/state_machine/internal/harness/CMakeLists.txt new file mode 100644 index 0000000000..74e898a38b --- /dev/null +++ b/FppTest/state_machine/internal/harness/CMakeLists.txt @@ -0,0 +1,11 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Harness.fpp" + "${CMAKE_CURRENT_LIST_DIR}/TestAbsType.cpp" +) +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/main.cpp" +) +set(UT_MOD_DEPS STest) +register_fprime_ut() diff --git a/FppTest/state_machine/internal/harness/Guard.hpp b/FppTest/state_machine/internal/harness/Guard.hpp new file mode 100644 index 0000000000..1395a5f349 --- /dev/null +++ b/FppTest/state_machine/internal/harness/Guard.hpp @@ -0,0 +1,73 @@ +// ====================================================================== +// +// \title Guard.hpp +// \author R. Bocchino +// \brief Template for test implementation of a state machine guard +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_SmHarness_Guard_HPP +#define FppTest_SmHarness_Guard_HPP + +#include +#include "FppTest/state_machine/internal/harness/SignalValueHistory.hpp" + +namespace FppTest { + +namespace SmHarness { + +//! Test implementation of a state machine guard with a value argument +template +class Guard { + public: + //! The call history type + using CallHistory = SignalValueHistory; + + //! Constructor + Guard() {} + + //! Reset the guard to the initial state + void reset() { + this->m_callHistory.clear(); + this->m_returnValue = false; + } + + //! Clear the call history but keep the return value + void clearCallHistory() { this->m_callHistory.clear(); } + + //! Call the guard + bool call(Signal signal, //!< The signal + const T& arg //!< The argument + ) const { + // Use const cast to update the history + const_cast*>(this)->m_callHistory.push(signal, arg); + return this->m_returnValue; + } + + //! Set the return value + void setReturnValue(bool returnValue //!< The return value + ) { + this->m_returnValue = returnValue; + } + + //! Get the call history + const CallHistory& getCallHistory() const { return this->m_callHistory; } + + private: + //! The return value + bool m_returnValue = false; + + //! The call history + CallHistory m_callHistory = {}; +}; + +} // namespace SmHarness + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/harness/Harness.fpp b/FppTest/state_machine/internal/harness/Harness.fpp new file mode 100644 index 0000000000..fbd1ba5801 --- /dev/null +++ b/FppTest/state_machine/internal/harness/Harness.fpp @@ -0,0 +1,17 @@ +module FppTest { + + module SmHarness { + + type TestAbsType + + enum TestEnum { A, B, C } + + array TestArray = [3] U32 + + struct TestStruct { + x: U32 + } + + } + +} diff --git a/FppTest/state_machine/internal/harness/Harness.hpp b/FppTest/state_machine/internal/harness/Harness.hpp new file mode 100644 index 0000000000..89509922af --- /dev/null +++ b/FppTest/state_machine/internal/harness/Harness.hpp @@ -0,0 +1,24 @@ +// ====================================================================== +// +// \title Harness.hpp +// \author R. Bocchino +// \brief Header file for internal state machine test harness +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_SmHarness_HPP +#define FppTest_SmHarness_HPP + +#include "FppTest/state_machine/internal/harness/Guard.hpp" +#include "FppTest/state_machine/internal/harness/History.hpp" +#include "FppTest/state_machine/internal/harness/NoArgGuard.hpp" +#include "FppTest/state_machine/internal/harness/Pick.hpp" +#include "FppTest/state_machine/internal/harness/SignalValueHistory.hpp" +#include "FppTest/state_machine/internal/harness/TestAbsType.hpp" + +#endif diff --git a/FppTest/state_machine/internal/harness/History.hpp b/FppTest/state_machine/internal/harness/History.hpp new file mode 100644 index 0000000000..77cc454d24 --- /dev/null +++ b/FppTest/state_machine/internal/harness/History.hpp @@ -0,0 +1,81 @@ +// ====================================================================== +// +// \title History.hpp +// \author R. Bocchino +// \brief Header for a history of value items +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_SmHarness_History_HPP +#define FppTest_SmHarness_History_HPP + +#include +#include + +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmHarness { + +//! A history of value items +template +class History { + public: + //! Constructor + History() {} + + //! Clear the history + void clear() { this->m_size = 0; } + + //! Check two histories for equality + bool operator==(History& history //!< The other history + ) const { + bool result = (this->m_size == history.m_size); + if (result) { + for (FwSizeType i = 0; i < this->m_size; i++) { + if (this->m_items[i] != history.m_items[i]) { + result = false; + break; + } + } + } + return result; + } + + //! Push an item on the history + void push(const T& item //!< The item + ) { + FW_ASSERT(m_size < size); + this->m_items[m_size] = T(item); + this->m_size++; + } + + //! Get the history size + FwSizeType getSize() const { return this->m_size; } + + //! Get the history item at an index + const T& getItemAt(FwIndexType index //!< The index + ) const { + FW_ASSERT(index < this->m_size); + return this->m_items[index]; + } + + private: + //! The history size + FwSizeType m_size = 0; + + //! The items in the history + std::array m_items = {}; +}; + +} // namespace SmHarness + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/harness/NoArgGuard.hpp b/FppTest/state_machine/internal/harness/NoArgGuard.hpp new file mode 100644 index 0000000000..bf696bd795 --- /dev/null +++ b/FppTest/state_machine/internal/harness/NoArgGuard.hpp @@ -0,0 +1,72 @@ +// ====================================================================== +// +// \title NoArgGuard.hpp +// \author R. Bocchino +// \brief Class for test implementation of a state machine guard +// with no argument value +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_SmHarness_NoArgGuard_HPP +#define FppTest_SmHarness_NoArgGuard_HPP + +#include "FppTest/state_machine/internal/harness/History.hpp" + +namespace FppTest { + +namespace SmHarness { + +//! Test implementation of a state machine guard with no argument value +template +class NoArgGuard { + public: + //! Call history type + using CallHistory = History; + + //! Constructor + NoArgGuard() : m_callHistory() {} + + //! Reset the guard to the initial state + void reset() { + this->m_callHistory.clear(); + this->m_returnValue = false; + } + + //! Clear the call history but keep the return value + void clearCallHistory() { this->m_callHistory.clear(); } + + //! Call the guard + bool call(Signal signal //!< The signal + ) const { + // Use const cast to update the history + const_cast*>(this)->m_callHistory.push(signal); + return this->m_returnValue; + } + + //! Set the return value + void setReturnValue(bool returnValue //!< The return value + ) { + this->m_returnValue = returnValue; + } + + //! Get the call history + const CallHistory& getCallHistory() const { return this->m_callHistory; } + + private: + //! The return value + bool m_returnValue = false; + + //! The call history + CallHistory m_callHistory; +}; + +} // namespace SmHarness + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/harness/Pick.hpp b/FppTest/state_machine/internal/harness/Pick.hpp new file mode 100644 index 0000000000..b42a4d6ca9 --- /dev/null +++ b/FppTest/state_machine/internal/harness/Pick.hpp @@ -0,0 +1,88 @@ +// ====================================================================== +// +// \title Pick.hpp +// \author R. Bocchino +// \brief Header file for picking state machine test values +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_SmHarness_Pick_HPP +#define FppTest_SmHarness_Pick_HPP + +#include +#include + +#include "FppTest/state_machine/internal/harness/TestAbsType.hpp" +#include "FppTest/state_machine/internal/harness/TestArrayArrayAc.hpp" +#include "FppTest/state_machine/internal/harness/TestEnumEnumAc.hpp" +#include "FppTest/state_machine/internal/harness/TestStructSerializableAc.hpp" +#include "Fw/Types/String.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmHarness { + +namespace Pick { + +//! Pick a state machine ID +static inline FwEnumStoreType stateMachineId() { + const U32 upper = FW_MIN(std::numeric_limits::max(), std::numeric_limits::max()); + const U32 id = STest::Pick::lowerUpper(0, upper); + return static_cast(id); +} + +//! Pick a TestAbsType value +static inline TestAbsType testAbsType() { + const U32 data = STest::Pick::any(); + return TestAbsType(data); +} + +//! Pick a TestArray value +static inline TestArray testArray() { + TestArray result; + for (FwIndexType i = 0; i < TestArray::SIZE; i++) { + result[i] = STest::Pick::any(); + } + return result; +} + +//! Pick a TestEnum value +static inline TestEnum testEnum() { + const U32 u32Value = STest::Pick::startLength(0, TestEnum::NUM_CONSTANTS); + const TestEnum::T enumValue = static_cast(u32Value); + return TestEnum(enumValue); +} + +//! Pick a TestStruct value +static inline TestStruct testStruct() { + const U32 x = STest::Pick::any(); + return TestStruct(x); +} + +//! Pick a string value +static inline void string(Fw::StringBase& s, //!< The string value (output) + FwSizeType maxLen = Fw::String::STRING_SIZE //!< The max string length +) { + const U32 size = STest::Pick::lowerUpper(0, maxLen); + s = ""; + for (U32 i = 0; i < size; i++) { + char c = static_cast(STest::Pick::lowerUpper(32, 126)); + Fw::String cString; + cString.format("%c", c); + s += cString; + } +} + +} // namespace Pick + +} // namespace SmHarness + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/harness/README.md b/FppTest/state_machine/internal/harness/README.md new file mode 100644 index 0000000000..a773e3ca24 --- /dev/null +++ b/FppTest/state_machine/internal/harness/README.md @@ -0,0 +1,3 @@ +# state_machine/internal/harness + +Harness code for testing FPP internal state machines. diff --git a/FppTest/state_machine/internal/harness/SignalValueHistory.hpp b/FppTest/state_machine/internal/harness/SignalValueHistory.hpp new file mode 100644 index 0000000000..66deb5fbff --- /dev/null +++ b/FppTest/state_machine/internal/harness/SignalValueHistory.hpp @@ -0,0 +1,88 @@ +// ====================================================================== +// +// \title SignalValueHistory.hpp +// \author R. Bocchino +// \brief Template for a history of calls with signals and values +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_SmHarness_SignalValueHistory_HPP +#define FppTest_SmHarness_SignalValueHistory_HPP + +#include +#include + +#include "FppTest/state_machine/internal/harness/History.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmHarness { + +//! A history with signals and values +template +class SignalValueHistory { + public: + //! The signal history type + using SignalHistory = History; + + //! The value history type + using ValueHistory = History; + + //! Constructor + SignalValueHistory() : m_signals(), m_values() {} + + //! Clear the history + void clear() { + this->m_size = 0; + this->m_signals.clear(); + this->m_values.clear(); + } + + //! Check two histories for equality + bool operator==(SignalValueHistory& history //!< The other history + ) const { + return (this->m_size == history.m_size) && (this->m_signals = history.m_signals) && + (this->m_values = history.m_values); + } + + //! Push an item on the history + void push(Signal signal, //!< The signal + const T& value //!< The value + ) { + FW_ASSERT(this->m_size < size, static_cast(this->m_size)); + this->m_signals.push(signal); + this->m_values.push(value); + this->m_size++; + } + + //! Get the history size + FwSizeType getSize() const { return this->m_size; } + + //! Get the signal history + const SignalHistory& getSignals() const { return this->m_signals; } + + //! Get the value history + const ValueHistory& getValues() const { return this->m_values; } + + private: + //! The size of the history + FwSizeType m_size = 0; + + //! The signal history + SignalHistory m_signals = {}; + + //! The values in the history + ValueHistory m_values = {}; +}; + +} // namespace SmHarness + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/harness/TestAbsType.cpp b/FppTest/state_machine/internal/harness/TestAbsType.cpp new file mode 100644 index 0000000000..845255df76 --- /dev/null +++ b/FppTest/state_machine/internal/harness/TestAbsType.cpp @@ -0,0 +1,38 @@ +// ====================================================================== +// +// \title TestAbsType.cpp +// \author R. Bocchino +// \brief An abstract type for testing (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include "FppTest/state_machine/internal/harness/TestAbsType.hpp" + +namespace FppTest { + +namespace SmHarness { + +#ifdef BUILD_UT +std::ostream& operator<<(std::ostream& os, const TestAbsType& obj) { + Fw::String s; + obj.toString(s); + os << s; + return os; +} +#endif + +#if FW_SERIALIZABLE_TO_STRING +void TestAbsType::toString(Fw::StringBase& sb) const { + static const char* formatString = "TestAbsType(%" PRIu32 ")"; + sb.format(formatString, this->m_data); +} +#endif + +} // namespace SmHarness + +} // namespace FppTest diff --git a/FppTest/state_machine/internal/harness/TestAbsType.hpp b/FppTest/state_machine/internal/harness/TestAbsType.hpp new file mode 100644 index 0000000000..04454d4df0 --- /dev/null +++ b/FppTest/state_machine/internal/harness/TestAbsType.hpp @@ -0,0 +1,77 @@ +// ====================================================================== +// +// \title TestAbsType.hpp +// \author R. Bocchino +// \brief An abstract type for testing +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_SmHarness_TestAbsType_HPP +#define FppTest_SmHarness_TestAbsType_HPP + +#include + +#include "Fw/Types/Serializable.hpp" +#include "Fw/Types/String.hpp" + +namespace FppTest { + +namespace SmHarness { + +//! An abstract type for testing +struct TestAbsType final : public Fw::Serializable { + //! The serialized size + static constexpr FwSizeType SERIALIZED_SIZE = sizeof(U32); + + //! Default-argument constructor + TestAbsType() : m_data(0) {} + + //! Supplied-argument constructor + TestAbsType(U32 data //!< The data + ) + : m_data(data) {} + + //! Comparison operator + bool operator==(const TestAbsType& obj) const { return this->m_data == obj.m_data; } + +#ifdef BUILD_UT + //! Ostream operator + friend std::ostream& operator<<(std::ostream& os, //!< The ostream + const TestAbsType& obj //!< The object + ); +#endif + + //! Serialize function + //! \return Status + Fw::SerializeStatus serialize(Fw::SerializeBufferBase& sbb //!< The serialize buffer base + ) const final { + return sbb.serialize(this->m_data); + } + + //! Deserialize method + //! \return status + Fw::SerializeStatus deserialize(Fw::SerializeBufferBase& sbb //!< The serialize buffer base + ) final { + return sbb.deserialize(this->m_data); + } + +#if FW_SERIALIZABLE_TO_STRING + //! Convert TestAbsType to string + void toString(Fw::StringBase& sb //!< The StringBase object to hold the result + ) const; +#endif + + //! The data + U32 m_data; +}; + +} // namespace SmHarness + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/harness/main.cpp b/FppTest/state_machine/internal/harness/main.cpp new file mode 100644 index 0000000000..69d14304ea --- /dev/null +++ b/FppTest/state_machine/internal/harness/main.cpp @@ -0,0 +1,7 @@ +// Main function so we can do a unit test build in this directory + +#include "Harness.hpp" + +int main(int argc, char** argv) { + return 0; +} diff --git a/FppTest/state_machine/internal/initial/Basic.cpp b/FppTest/state_machine/internal/initial/Basic.cpp new file mode 100644 index 0000000000..173476aca2 --- /dev/null +++ b/FppTest/state_machine/internal/initial/Basic.cpp @@ -0,0 +1,44 @@ +// ====================================================================== +// +// \title Basic.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/initial/Basic.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmInitial { + +Basic::Basic() : BasicStateMachineBase(), m_action_a_history() {} + +void Basic::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void Basic::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + const FwSizeType expectedSize = 3; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::__FPRIME_AC_INITIAL_TRANSITION); + } +} + +} // namespace SmInitial + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/initial/Basic.fpp b/FppTest/state_machine/internal/initial/Basic.fpp new file mode 100644 index 0000000000..983e68dd6a --- /dev/null +++ b/FppTest/state_machine/internal/initial/Basic.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmInitial { + + include "include/Basic.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/initial/Basic.hpp b/FppTest/state_machine/internal/initial/Basic.hpp new file mode 100644 index 0000000000..6c1f6cbab6 --- /dev/null +++ b/FppTest/state_machine/internal/initial/Basic.hpp @@ -0,0 +1,52 @@ +// ====================================================================== +// +// \title Basic.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_Basic_HPP +#define FppTest_Basic_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/initial/BasicStateMachineAc.hpp" + +namespace FppTest { + +namespace SmInitial { + +//! Basic state machine +class Basic final : public BasicStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + Basic(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; +}; + +} // namespace SmInitial + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/initial/CMakeLists.txt b/FppTest/state_machine/internal/initial/CMakeLists.txt new file mode 100644 index 0000000000..56da4fac54 --- /dev/null +++ b/FppTest/state_machine/internal/initial/CMakeLists.txt @@ -0,0 +1,16 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Choice.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Nested.fpp" +) +set(MOD_DEPS FppTest/state_machine/internal/harness) +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Choice.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Nested.cpp" + "${CMAKE_CURRENT_LIST_DIR}/main.cpp" +) +set(UT_MOD_DEPS STest) +register_fprime_ut() diff --git a/FppTest/state_machine/internal/initial/Choice.cpp b/FppTest/state_machine/internal/initial/Choice.cpp new file mode 100644 index 0000000000..53e3973130 --- /dev/null +++ b/FppTest/state_machine/internal/initial/Choice.cpp @@ -0,0 +1,72 @@ +// ====================================================================== +// +// \title Choice.hpp +// \author R. Bocchino +// \brief Test class for choice state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include +#include + +#include "FppTest/state_machine/internal/initial/Choice.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmInitial { + +Choice::Choice() : ChoiceStateMachineBase(), m_action_a_history(), m_guard_g() {} + +void Choice::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +bool Choice::guard_g(Signal signal) const { + return m_guard_g.call(signal); +} + +void Choice::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedActionSize = 5; + const FwSizeType expectedGuardSize = 1; + this->checkActionsAndGuards(expectedActionSize, expectedGuardSize); +} + +void Choice::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->m_state, State::S); + const FwSizeType expectedActionSize = 3; + const FwSizeType expectedGuardSize = 1; + this->checkActionsAndGuards(expectedActionSize, expectedGuardSize); +} + +void Choice::checkActionsAndGuards(FwSizeType expectedActionSize, FwSizeType expectedGuardSize) { + ASSERT_EQ(this->m_action_a_history.getSize(), expectedActionSize); + for (FwSizeType i = 0; i < expectedActionSize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), expectedGuardSize); + for (FwSizeType i = 0; i < expectedGuardSize; i++) { + ASSERT_EQ(this->m_guard_g.getCallHistory().getItemAt(i), Signal::__FPRIME_AC_INITIAL_TRANSITION); + } +} + +} // namespace SmInitial + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/initial/Choice.fpp b/FppTest/state_machine/internal/initial/Choice.fpp new file mode 100644 index 0000000000..78b1b4d2a3 --- /dev/null +++ b/FppTest/state_machine/internal/initial/Choice.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmInitial { + + include "include/Choice.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/initial/Choice.hpp b/FppTest/state_machine/internal/initial/Choice.hpp new file mode 100644 index 0000000000..e25f620dbc --- /dev/null +++ b/FppTest/state_machine/internal/initial/Choice.hpp @@ -0,0 +1,67 @@ +// ====================================================================== +// +// \title Choice.hpp +// \author R. Bocchino +// \brief Test class for choice state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_Choice_HPP +#define FppTest_Choice_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/initial/ChoiceStateMachineAc.hpp" + +namespace FppTest { + +namespace SmInitial { + +//! Choice state machine +class Choice final : public ChoiceStateMachineBase { + public: + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + Choice(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal //!< The signal + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! Helper function for checking actions and guards + void checkActionsAndGuards(FwSizeType expectedActionSize, //!< The expected action size + FwSizeType expectedGuardSize //!< The expected guard size + ); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The guard g + SmHarness::NoArgGuard m_guard_g; +}; + +} // namespace SmInitial + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/initial/Nested.cpp b/FppTest/state_machine/internal/initial/Nested.cpp new file mode 100644 index 0000000000..0a9feb4355 --- /dev/null +++ b/FppTest/state_machine/internal/initial/Nested.cpp @@ -0,0 +1,45 @@ +// ====================================================================== +// +// \title Nested.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include +#include + +#include "FppTest/state_machine/internal/initial/Nested.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmInitial { + +Nested::Nested() : NestedStateMachineBase(), m_action_a_history() {} + +void Nested::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void Nested::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S_T); + const FwSizeType expectedActionSize = 6; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedActionSize); + for (FwSizeType i = 0; i < expectedActionSize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::__FPRIME_AC_INITIAL_TRANSITION); + } +} + +} // namespace SmInitial + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/initial/Nested.fpp b/FppTest/state_machine/internal/initial/Nested.fpp new file mode 100644 index 0000000000..09af965354 --- /dev/null +++ b/FppTest/state_machine/internal/initial/Nested.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmInitial { + + include "include/Nested.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/initial/Nested.hpp b/FppTest/state_machine/internal/initial/Nested.hpp new file mode 100644 index 0000000000..41e830e4e1 --- /dev/null +++ b/FppTest/state_machine/internal/initial/Nested.hpp @@ -0,0 +1,52 @@ +// ====================================================================== +// +// \title Nested.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_Nested_HPP +#define FppTest_Nested_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/initial/NestedStateMachineAc.hpp" + +namespace FppTest { + +namespace SmInitial { + +//! Nested state machine +class Nested final : public NestedStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + Nested(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; +}; + +} // namespace SmInitial + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/initial/README.md b/FppTest/state_machine/internal/initial/README.md new file mode 100644 index 0000000000..f29bdf8539 --- /dev/null +++ b/FppTest/state_machine/internal/initial/README.md @@ -0,0 +1,3 @@ +# state_machine/internal/initial + +Tests for initial transitions in FPP internal state machines. diff --git a/FppTest/state_machine/internal/initial/include/Basic.fppi b/FppTest/state_machine/internal/initial/include/Basic.fppi new file mode 100644 index 0000000000..4bfe5b22f0 --- /dev/null +++ b/FppTest/state_machine/internal/initial/include/Basic.fppi @@ -0,0 +1,14 @@ +@ A basic state machine +state machine Basic { + + @ Action a + action a + + initial do { a } enter S + + @ State S + state S { + entry do { a, a } + } + +} diff --git a/FppTest/state_machine/internal/initial/include/Choice.fppi b/FppTest/state_machine/internal/initial/include/Choice.fppi new file mode 100644 index 0000000000..b82a30ee3e --- /dev/null +++ b/FppTest/state_machine/internal/initial/include/Choice.fppi @@ -0,0 +1,25 @@ +@ A state machine with an initial choice +state machine Choice { + + @ Action a + action a + + @ Guard g + guard g + + initial do { a } enter C + + @ Choice C + choice C { if g do { a } enter S else do { a, a } enter T } + + @ State S + state S { + entry do { a } + } + + @ State T + state T { + entry do { a, a } + } + +} diff --git a/FppTest/state_machine/internal/initial/include/Nested.fppi b/FppTest/state_machine/internal/initial/include/Nested.fppi new file mode 100644 index 0000000000..7628dbc56b --- /dev/null +++ b/FppTest/state_machine/internal/initial/include/Nested.fppi @@ -0,0 +1,23 @@ +@ A state machine with nested initial transitions +state machine Nested { + + @ Action a + action a + + initial do { a } enter S + + @ State S + state S { + + entry do { a, a } + + initial enter T + + @ State S.T + state T { + entry do { a, a, a } + } + + } + +} diff --git a/FppTest/state_machine/internal/initial/main.cpp b/FppTest/state_machine/internal/initial/main.cpp new file mode 100644 index 0000000000..80feb5a1b4 --- /dev/null +++ b/FppTest/state_machine/internal/initial/main.cpp @@ -0,0 +1,40 @@ +// ---------------------------------------------------------------------- +// main.cpp +// ---------------------------------------------------------------------- + +#include + +#include "FppTest/state_machine/internal/initial/Basic.hpp" +#include "FppTest/state_machine/internal/initial/Choice.hpp" +#include "FppTest/state_machine/internal/initial/Nested.hpp" +#include "STest/STest/Random/Random.hpp" + +TEST(Basic, Test) { + FppTest::SmInitial::Basic basic; + basic.test(); +} + +TEST(Choice, False) { + FppTest::SmInitial::Choice choice; + choice.testFalse(); +} + +TEST(Choice, True) { + FppTest::SmInitial::Choice choice; + choice.testTrue(); +} + +TEST(Nested, Test) { + FppTest::SmInitial::Nested nested; + nested.test(); +} + +// ---------------------------------------------------------------------- +// Main function +// ---------------------------------------------------------------------- + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + STest::Random::seed(); + return RUN_ALL_TESTS(); +} diff --git a/FppTest/state_machine/internal/state/Basic.cpp b/FppTest/state_machine/internal/state/Basic.cpp new file mode 100644 index 0000000000..27b94a548e --- /dev/null +++ b/FppTest/state_machine/internal/state/Basic.cpp @@ -0,0 +1,49 @@ +// ====================================================================== +// +// \title Basic.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/Basic.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +Basic::Basic() : BasicStateMachineBase(), m_action_a_history() {} + +void Basic::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void Basic::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + this->sendSignal_s(); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedSize = 6; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/Basic.fpp b/FppTest/state_machine/internal/state/Basic.fpp new file mode 100644 index 0000000000..a17f3af3ec --- /dev/null +++ b/FppTest/state_machine/internal/state/Basic.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/Basic.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/Basic.hpp b/FppTest/state_machine/internal/state/Basic.hpp new file mode 100644 index 0000000000..6776a1e94d --- /dev/null +++ b/FppTest/state_machine/internal/state/Basic.hpp @@ -0,0 +1,52 @@ +// ====================================================================== +// +// \title Basic.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_Basic_HPP +#define FppTest_State_Basic_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine +class Basic final : public BasicStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + Basic(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicGuard.cpp b/FppTest/state_machine/internal/state/BasicGuard.cpp new file mode 100644 index 0000000000..93c124cfb5 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuard.cpp @@ -0,0 +1,75 @@ +// ====================================================================== +// +// \title BasicGuard.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with guard (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicGuard.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicGuard::BasicGuard() : BasicGuardStateMachineBase(), m_action_a_history(), m_guard_g() {} + +void BasicGuard::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +bool BasicGuard::guard_g(Signal signal) const { + return this->m_guard_g.call(signal); +} + +void BasicGuard::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + this->sendSignal_s(); + ASSERT_EQ(this->getState(), State::S); + this->checkActionsAndGuards(0, 1); +} + +void BasicGuard::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + this->sendSignal_s(); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(); + ASSERT_EQ(this->getState(), State::T); + this->checkActionsAndGuards(6, 1); +} + +void BasicGuard::checkActionsAndGuards(FwSizeType expectedActionSize, FwSizeType expectedGuardSize) { + ASSERT_EQ(this->m_action_a_history.getSize(), expectedActionSize); + for (FwSizeType i = 0; i < expectedActionSize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), expectedGuardSize); + for (FwSizeType i = 0; i < expectedGuardSize; i++) { + ASSERT_EQ(this->m_guard_g.getCallHistory().getItemAt(i), Signal::s); + } +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicGuard.fpp b/FppTest/state_machine/internal/state/BasicGuard.fpp new file mode 100644 index 0000000000..e1b4f2fb90 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuard.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicGuard.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicGuard.hpp b/FppTest/state_machine/internal/state/BasicGuard.hpp new file mode 100644 index 0000000000..5e1cc2c915 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuard.hpp @@ -0,0 +1,68 @@ +// ====================================================================== +// +// \title BasicGuard.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with guard (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicGuard_HPP +#define FppTest_State_BasicGuard_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a guard +class BasicGuard final : public BasicGuardStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicGuard(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal //!< The signal + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! Helper function for checking actions and guards + void checkActionsAndGuards(FwSizeType expectedActionSize, //!< The expected action size + FwSizeType expectedGuardSize //!< The expected guard size + ); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The guard g + SmHarness::NoArgGuard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicGuardString.cpp b/FppTest/state_machine/internal/state/BasicGuardString.cpp new file mode 100644 index 0000000000..4e6e5f3a74 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardString.cpp @@ -0,0 +1,77 @@ +// ====================================================================== +// +// \title BasicGuardString.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with string guard (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicGuardString.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicGuardString::BasicGuardString() : BasicGuardStringStateMachineBase(), m_action_a_history(), m_guard_g() {} + +void BasicGuardString::action_a(Signal signal, const Fw::StringBase& value) { + this->m_action_a_history.push(signal, Fw::String(value)); +} + +bool BasicGuardString::guard_g(Signal signal, const Fw::StringBase& value) const { + return this->m_guard_g.call(signal, Fw::String(value)); +} + +void BasicGuardString::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + Fw::String value; + SmHarness::Pick::string(value); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void BasicGuardString::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + Fw::String value; + SmHarness::Pick::string(value); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicGuardString.fpp b/FppTest/state_machine/internal/state/BasicGuardString.fpp new file mode 100644 index 0000000000..66e0c2f3db --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardString.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicGuardString.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicGuardString.hpp b/FppTest/state_machine/internal/state/BasicGuardString.hpp new file mode 100644 index 0000000000..b9f4393929 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardString.hpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// \title BasicGuardString.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with string guard (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicGuardString_HPP +#define FppTest_State_BasicGuardString_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardStringStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a String guard +class BasicGuardString final : public BasicGuardStringStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicGuardString(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + const Fw::StringBase& value //!< The value + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + const Fw::StringBase& value //!< The value + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicGuardTestAbsType.cpp b/FppTest/state_machine/internal/state/BasicGuardTestAbsType.cpp new file mode 100644 index 0000000000..fa19358efd --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestAbsType.cpp @@ -0,0 +1,76 @@ +// ====================================================================== +// +// \title BasicGuardTestAbsType.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestAbsType guard (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicGuardTestAbsType.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicGuardTestAbsType::BasicGuardTestAbsType() + : BasicGuardTestAbsTypeStateMachineBase(), m_action_a_history(), m_guard_g() {} + +void BasicGuardTestAbsType::action_a(Signal signal, const SmHarness::TestAbsType& value) { + this->m_action_a_history.push(signal, value); +} + +bool BasicGuardTestAbsType::guard_g(Signal signal, const SmHarness::TestAbsType& value) const { + return this->m_guard_g.call(signal, value); +} + +void BasicGuardTestAbsType::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + const SmHarness::TestAbsType value = SmHarness::Pick::testAbsType(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void BasicGuardTestAbsType::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestAbsType value = SmHarness::Pick::testAbsType(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicGuardTestAbsType.fpp b/FppTest/state_machine/internal/state/BasicGuardTestAbsType.fpp new file mode 100644 index 0000000000..67ff0a8247 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestAbsType.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicGuardTestAbsType.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicGuardTestAbsType.hpp b/FppTest/state_machine/internal/state/BasicGuardTestAbsType.hpp new file mode 100644 index 0000000000..09b58f05a9 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestAbsType.hpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// \title BasicGuardTestAbsType.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestAbsType guard (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicGuardTestAbsType_HPP +#define FppTest_State_BasicGuardTestAbsType_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestAbsTypeStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a TestAbsType guard +class BasicGuardTestAbsType final : public BasicGuardTestAbsTypeStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicGuardTestAbsType(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + const SmHarness::TestAbsType& value //!< The value + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + const SmHarness::TestAbsType& value //!< The value + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicGuardTestArray.cpp b/FppTest/state_machine/internal/state/BasicGuardTestArray.cpp new file mode 100644 index 0000000000..b5ecca9b83 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestArray.cpp @@ -0,0 +1,75 @@ +// ====================================================================== +// +// \title BasicGuardTestArray.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestArray guard (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicGuardTestArray.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicGuardTestArray::BasicGuardTestArray() : BasicGuardTestArrayStateMachineBase(), m_action_a_history(), m_guard_g() {} + +void BasicGuardTestArray::action_a(Signal signal, const SmHarness::TestArray& value) { + this->m_action_a_history.push(signal, value); +} + +bool BasicGuardTestArray::guard_g(Signal signal, const SmHarness::TestArray& value) const { + return this->m_guard_g.call(signal, value); +} + +void BasicGuardTestArray::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + const SmHarness::TestArray value = SmHarness::Pick::testArray(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void BasicGuardTestArray::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestArray value = SmHarness::Pick::testArray(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicGuardTestArray.fpp b/FppTest/state_machine/internal/state/BasicGuardTestArray.fpp new file mode 100644 index 0000000000..438f3e29df --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestArray.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicGuardTestArray.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicGuardTestArray.hpp b/FppTest/state_machine/internal/state/BasicGuardTestArray.hpp new file mode 100644 index 0000000000..01bda7a2d2 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestArray.hpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// \title BasicGuardTestArray.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestArray guard (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicGuardTestArray_HPP +#define FppTest_State_BasicGuardTestArray_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestArrayStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a TestArray guard +class BasicGuardTestArray final : public BasicGuardTestArrayStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicGuardTestArray(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + const SmHarness::TestArray& value //!< The value + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + const SmHarness::TestArray& value //!< The value + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicGuardTestEnum.cpp b/FppTest/state_machine/internal/state/BasicGuardTestEnum.cpp new file mode 100644 index 0000000000..1e978fca74 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestEnum.cpp @@ -0,0 +1,75 @@ +// ====================================================================== +// +// \title BasicGuardTestEnum.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestEnum guard (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicGuardTestEnum.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicGuardTestEnum::BasicGuardTestEnum() : BasicGuardTestEnumStateMachineBase(), m_action_a_history(), m_guard_g() {} + +void BasicGuardTestEnum::action_a(Signal signal, const SmHarness::TestEnum& value) { + this->m_action_a_history.push(signal, value); +} + +bool BasicGuardTestEnum::guard_g(Signal signal, const SmHarness::TestEnum& value) const { + return this->m_guard_g.call(signal, value); +} + +void BasicGuardTestEnum::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + const SmHarness::TestEnum value = SmHarness::Pick::testEnum(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void BasicGuardTestEnum::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestEnum value = SmHarness::Pick::testEnum(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicGuardTestEnum.fpp b/FppTest/state_machine/internal/state/BasicGuardTestEnum.fpp new file mode 100644 index 0000000000..217f879619 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestEnum.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicGuardTestEnum.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicGuardTestEnum.hpp b/FppTest/state_machine/internal/state/BasicGuardTestEnum.hpp new file mode 100644 index 0000000000..b053afa76e --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestEnum.hpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// \title BasicGuardTestEnum.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestEnum guard (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicGuardTestEnum_HPP +#define FppTest_State_BasicGuardTestEnum_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestEnumStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a TestEnum guard +class BasicGuardTestEnum final : public BasicGuardTestEnumStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicGuardTestEnum(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + const SmHarness::TestEnum& value //!< The value + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + const SmHarness::TestEnum& value //!< The value + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicGuardTestStruct.cpp b/FppTest/state_machine/internal/state/BasicGuardTestStruct.cpp new file mode 100644 index 0000000000..7d041467e7 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestStruct.cpp @@ -0,0 +1,76 @@ +// ====================================================================== +// +// \title BasicGuardTestStruct.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestStruct guard (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicGuardTestStruct.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicGuardTestStruct::BasicGuardTestStruct() + : BasicGuardTestStructStateMachineBase(), m_action_a_history(), m_guard_g() {} + +void BasicGuardTestStruct::action_a(Signal signal, const SmHarness::TestStruct& value) { + this->m_action_a_history.push(signal, value); +} + +bool BasicGuardTestStruct::guard_g(Signal signal, const SmHarness::TestStruct& value) const { + return this->m_guard_g.call(signal, value); +} + +void BasicGuardTestStruct::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + const SmHarness::TestStruct value = SmHarness::Pick::testStruct(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void BasicGuardTestStruct::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestStruct value = SmHarness::Pick::testStruct(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicGuardTestStruct.fpp b/FppTest/state_machine/internal/state/BasicGuardTestStruct.fpp new file mode 100644 index 0000000000..46737f0767 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestStruct.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicGuardTestStruct.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicGuardTestStruct.hpp b/FppTest/state_machine/internal/state/BasicGuardTestStruct.hpp new file mode 100644 index 0000000000..ddc94b571a --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardTestStruct.hpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// \title BasicGuardTestStruct.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestStruct guard (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicGuardTestStruct_HPP +#define FppTest_State_BasicGuardTestStruct_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestStructStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a TestStruct guard +class BasicGuardTestStruct final : public BasicGuardTestStructStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicGuardTestStruct(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + const SmHarness::TestStruct& value //!< The value + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + const SmHarness::TestStruct& value //!< The value + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicGuardU32.cpp b/FppTest/state_machine/internal/state/BasicGuardU32.cpp new file mode 100644 index 0000000000..e03a9b01af --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardU32.cpp @@ -0,0 +1,75 @@ +// ====================================================================== +// +// \title BasicGuardU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with U32 guard (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicGuardU32.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicGuardU32::BasicGuardU32() : BasicGuardU32StateMachineBase(), m_action_a_history(), m_guard_g() {} + +void BasicGuardU32::action_a(Signal signal, U32 value) { + this->m_action_a_history.push(signal, value); +} + +bool BasicGuardU32::guard_g(Signal signal, U32 value) const { + return this->m_guard_g.call(signal, value); +} + +void BasicGuardU32::testFalse() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void BasicGuardU32::testTrue() { + this->m_action_a_history.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_guard_g.getCallHistory().getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicGuardU32.fpp b/FppTest/state_machine/internal/state/BasicGuardU32.fpp new file mode 100644 index 0000000000..e39d7ea411 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardU32.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicGuardU32.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicGuardU32.hpp b/FppTest/state_machine/internal/state/BasicGuardU32.hpp new file mode 100644 index 0000000000..393ba4b73e --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicGuardU32.hpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// \title BasicGuardU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with U32 guard (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicGuardU32_HPP +#define FppTest_State_BasicGuardU32_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardU32StateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a U32 guard +class BasicGuardU32 final : public BasicGuardU32StateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicGuardU32(); + + private: + //! Implementation of action a + void action_a(Signal signal, //!< The signal + U32 value //!< The value + ) final; + + //! Implementation of guard g + bool guard_g(Signal signal, //!< The signal + U32 value //!< The value + ) const; + + public: + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + //! The history associated with action a + SmHarness::SignalValueHistory m_action_a_history; + + //! The guard g + SmHarness::Guard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicInternal.cpp b/FppTest/state_machine/internal/state/BasicInternal.cpp new file mode 100644 index 0000000000..c1f55c9682 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicInternal.cpp @@ -0,0 +1,46 @@ +// ====================================================================== +// +// \title BasicInternal.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicInternal.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicInternal::BasicInternal() : BasicInternalStateMachineBase(), m_action_a_history() {} + +void BasicInternal::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicInternal::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getItemAt(0), Signal::__FPRIME_AC_INITIAL_TRANSITION); + this->m_action_a_history.clear(); + this->sendSignal_s(); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getItemAt(0), Signal::s); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicInternal.fpp b/FppTest/state_machine/internal/state/BasicInternal.fpp new file mode 100644 index 0000000000..638ee0be91 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicInternal.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicInternal.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicInternal.hpp b/FppTest/state_machine/internal/state/BasicInternal.hpp new file mode 100644 index 0000000000..8ffdf3ad8d --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicInternal.hpp @@ -0,0 +1,52 @@ +// ====================================================================== +// +// \title BasicInternal.hpp +// \author R. Bocchino +// \brief Test class for basic state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicInternal_HPP +#define FppTest_State_BasicInternal_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicInternalStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with an internal transition +class BasicInternal final : public BasicInternalStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicInternal(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicSelf.cpp b/FppTest/state_machine/internal/state/BasicSelf.cpp new file mode 100644 index 0000000000..3609adbad8 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicSelf.cpp @@ -0,0 +1,49 @@ +// ====================================================================== +// +// \title BasicSelf.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with self transition (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicSelf.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicSelf::BasicSelf() : BasicSelfStateMachineBase(), m_action_a_history() {} + +void BasicSelf::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicSelf::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getItemAt(0), Signal::__FPRIME_AC_INITIAL_TRANSITION); + this->m_action_a_history.clear(); + this->sendSignal_s(); + ASSERT_EQ(this->getState(), State::S); + const FwSizeType expectedSize = 6; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicSelf.fpp b/FppTest/state_machine/internal/state/BasicSelf.fpp new file mode 100644 index 0000000000..3027bd567e --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicSelf.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicSelf.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicSelf.hpp b/FppTest/state_machine/internal/state/BasicSelf.hpp new file mode 100644 index 0000000000..6bdf8f8542 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicSelf.hpp @@ -0,0 +1,52 @@ +// ====================================================================== +// +// \title BasicSelf.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with self transition (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicSelf_HPP +#define FppTest_State_BasicSelf_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicSelfStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with a self transition +class BasicSelf final : public BasicSelfStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicSelf(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicString.cpp b/FppTest/state_machine/internal/state/BasicString.cpp new file mode 100644 index 0000000000..5f7b0ffb2b --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicString.cpp @@ -0,0 +1,58 @@ +// ====================================================================== +// +// \title BasicString.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with string actions (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicString.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicString::BasicString() : BasicStringStateMachineBase(), m_action_a_history(), m_action_b_history() {} + +void BasicString::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicString::action_b(Signal signal, const Fw::StringBase& value) { + this->m_action_b_history.push(signal, Fw::String(value)); +} + +void BasicString::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + Fw::String value; + SmHarness::Pick::string(value); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicString.fpp b/FppTest/state_machine/internal/state/BasicString.fpp new file mode 100644 index 0000000000..6230b23679 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicString.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicString.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicString.hpp b/FppTest/state_machine/internal/state/BasicString.hpp new file mode 100644 index 0000000000..762b6e057d --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicString.hpp @@ -0,0 +1,60 @@ +// ====================================================================== +// +// \title BasicString.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with string actions (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicString_HPP +#define FppTest_State_BasicString_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicStringStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with string actions +class BasicString final : public BasicStringStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicString(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal, //!< The signal + const Fw::StringBase& value //!< The value + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b + SmHarness::SignalValueHistory m_action_b_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicTestAbsType.cpp b/FppTest/state_machine/internal/state/BasicTestAbsType.cpp new file mode 100644 index 0000000000..974a4b8d11 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestAbsType.cpp @@ -0,0 +1,57 @@ +// ====================================================================== +// +// \title BasicTestAbsType.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestAbsType actions (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicTestAbsType.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicTestAbsType::BasicTestAbsType() : BasicTestAbsTypeStateMachineBase(), m_action_a_history(), m_action_b_history() {} + +void BasicTestAbsType::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicTestAbsType::action_b(Signal signal, const SmHarness::TestAbsType& value) { + this->m_action_b_history.push(signal, value); +} + +void BasicTestAbsType::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestAbsType value = SmHarness::Pick::testAbsType(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicTestAbsType.fpp b/FppTest/state_machine/internal/state/BasicTestAbsType.fpp new file mode 100644 index 0000000000..55853e6e79 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestAbsType.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicTestAbsType.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicTestAbsType.hpp b/FppTest/state_machine/internal/state/BasicTestAbsType.hpp new file mode 100644 index 0000000000..ee4aee59a5 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestAbsType.hpp @@ -0,0 +1,60 @@ +// ====================================================================== +// +// \title BasicTestAbsType.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestAbsType actions (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicTestAbsType_HPP +#define FppTest_State_BasicTestAbsType_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicTestAbsTypeStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with TestAbsType actions +class BasicTestAbsType final : public BasicTestAbsTypeStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicTestAbsType(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal, //!< The signal + const SmHarness::TestAbsType& value //!< The value + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b + SmHarness::SignalValueHistory m_action_b_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicTestArray.cpp b/FppTest/state_machine/internal/state/BasicTestArray.cpp new file mode 100644 index 0000000000..4392c36a77 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestArray.cpp @@ -0,0 +1,57 @@ +// ====================================================================== +// +// \title BasicTestArray.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestArray actions (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicTestArray.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicTestArray::BasicTestArray() : BasicTestArrayStateMachineBase(), m_action_a_history(), m_action_b_history() {} + +void BasicTestArray::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicTestArray::action_b(Signal signal, const SmHarness::TestArray& value) { + this->m_action_b_history.push(signal, value); +} + +void BasicTestArray::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestArray value = SmHarness::Pick::testArray(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicTestArray.fpp b/FppTest/state_machine/internal/state/BasicTestArray.fpp new file mode 100644 index 0000000000..f7e6ad4e82 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestArray.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicTestArray.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicTestArray.hpp b/FppTest/state_machine/internal/state/BasicTestArray.hpp new file mode 100644 index 0000000000..661744ec62 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestArray.hpp @@ -0,0 +1,60 @@ +// ====================================================================== +// +// \title BasicTestArray.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestArray actions (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicTestArray_HPP +#define FppTest_State_BasicTestArray_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicTestArrayStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with TestArray actions +class BasicTestArray final : public BasicTestArrayStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicTestArray(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal, //!< The signal + const SmHarness::TestArray& value //!< The value + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b + SmHarness::SignalValueHistory m_action_b_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicTestEnum.cpp b/FppTest/state_machine/internal/state/BasicTestEnum.cpp new file mode 100644 index 0000000000..130ade4c81 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestEnum.cpp @@ -0,0 +1,57 @@ +// ====================================================================== +// +// \title BasicTestEnum.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestEnum actions (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicTestEnum.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicTestEnum::BasicTestEnum() : BasicTestEnumStateMachineBase(), m_action_a_history(), m_action_b_history() {} + +void BasicTestEnum::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicTestEnum::action_b(Signal signal, const SmHarness::TestEnum& value) { + this->m_action_b_history.push(signal, value); +} + +void BasicTestEnum::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestEnum value = SmHarness::Pick::testEnum(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicTestEnum.fpp b/FppTest/state_machine/internal/state/BasicTestEnum.fpp new file mode 100644 index 0000000000..a80f3524a7 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestEnum.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicTestEnum.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicTestEnum.hpp b/FppTest/state_machine/internal/state/BasicTestEnum.hpp new file mode 100644 index 0000000000..ee81437809 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestEnum.hpp @@ -0,0 +1,60 @@ +// ====================================================================== +// +// \title BasicTestEnum.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestEnum actions (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicTestEnum_HPP +#define FppTest_State_BasicTestEnum_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicTestEnumStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with TestEnum actions +class BasicTestEnum final : public BasicTestEnumStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicTestEnum(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal, //!< The signal + const SmHarness::TestEnum& value //!< The value + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b + SmHarness::SignalValueHistory m_action_b_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicTestStruct.cpp b/FppTest/state_machine/internal/state/BasicTestStruct.cpp new file mode 100644 index 0000000000..47c60b4ce2 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestStruct.cpp @@ -0,0 +1,57 @@ +// ====================================================================== +// +// \title BasicTestStruct.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestStruct actions (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicTestStruct.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicTestStruct::BasicTestStruct() : BasicTestStructStateMachineBase(), m_action_a_history(), m_action_b_history() {} + +void BasicTestStruct::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicTestStruct::action_b(Signal signal, const SmHarness::TestStruct& value) { + this->m_action_b_history.push(signal, value); +} + +void BasicTestStruct::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const SmHarness::TestStruct value = SmHarness::Pick::testStruct(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicTestStruct.fpp b/FppTest/state_machine/internal/state/BasicTestStruct.fpp new file mode 100644 index 0000000000..80e3ecc58c --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestStruct.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicTestStruct.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicTestStruct.hpp b/FppTest/state_machine/internal/state/BasicTestStruct.hpp new file mode 100644 index 0000000000..4f3cc4770d --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicTestStruct.hpp @@ -0,0 +1,60 @@ +// ====================================================================== +// +// \title BasicTestStruct.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with TestStruct actions (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicTestStruct_HPP +#define FppTest_State_BasicTestStruct_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicTestStructStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with TestStruct actions +class BasicTestStruct final : public BasicTestStructStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicTestStruct(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal, //!< The signal + const SmHarness::TestStruct& value //!< The value + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b + SmHarness::SignalValueHistory m_action_b_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/BasicU32.cpp b/FppTest/state_machine/internal/state/BasicU32.cpp new file mode 100644 index 0000000000..089b2bb2cd --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicU32.cpp @@ -0,0 +1,57 @@ +// ====================================================================== +// +// \title BasicU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with U32 actions (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/BasicU32.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +BasicU32::BasicU32() : BasicU32StateMachineBase(), m_action_a_history(), m_action_b_history() {} + +void BasicU32::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void BasicU32::action_b(Signal signal, U32 value) { + this->m_action_b_history.push(signal, value); +} + +void BasicU32::test() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + this->sendSignal_s(value); + ASSERT_EQ(this->getState(), State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_action_a_history.getItemAt(i), Signal::s); + } + ASSERT_EQ(this->m_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_action_b_history.getSignals().getItemAt(0), Signal::s); + ASSERT_EQ(this->m_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/BasicU32.fpp b/FppTest/state_machine/internal/state/BasicU32.fpp new file mode 100644 index 0000000000..6cea2206ac --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicU32.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/BasicU32.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/BasicU32.hpp b/FppTest/state_machine/internal/state/BasicU32.hpp new file mode 100644 index 0000000000..376ea422e5 --- /dev/null +++ b/FppTest/state_machine/internal/state/BasicU32.hpp @@ -0,0 +1,60 @@ +// ====================================================================== +// +// \title BasicU32.hpp +// \author R. Bocchino +// \brief Test class for basic state machine with U32 actions (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_BasicU32_HPP +#define FppTest_State_BasicU32_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/BasicU32StateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A basic state machine with U32 actions +class BasicU32 final : public BasicU32StateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + BasicU32(); + + private: + //! Implementation of action a + void action_a(Signal signal //!< The signal + ) final; + + //! Implementation of action b + void action_b(Signal signal, //!< The signal + U32 value //!< The value + ) final; + + public: + //! Run the test + void test(); + + private: + //! The history associated with action a + SmHarness::History m_action_a_history; + + //! The history associated with action b + SmHarness::SignalValueHistory m_action_b_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/CMakeLists.txt b/FppTest/state_machine/internal/state/CMakeLists.txt new file mode 100644 index 0000000000..18714b3408 --- /dev/null +++ b/FppTest/state_machine/internal/state/CMakeLists.txt @@ -0,0 +1,54 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuard.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardString.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestAbsType.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestArray.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestEnum.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestStruct.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardU32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicInternal.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicSelf.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicString.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestAbsType.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestArray.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestEnum.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestStruct.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Internal.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Polymorphism.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChild.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChoice.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToSelf.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToState.fpp" +) +set(MOD_DEPS FppTest/state_machine/internal/harness) +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuard.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardString.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestAbsType.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestArray.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestEnum.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestStruct.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicInternal.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicSelf.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicString.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestAbsType.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestArray.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestEnum.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestStruct.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Internal.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Polymorphism.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChild.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChoice.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToSelf.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToState.cpp" + "${CMAKE_CURRENT_LIST_DIR}/main.cpp" +) +set(UT_MOD_DEPS STest) +register_fprime_ut() diff --git a/FppTest/state_machine/internal/state/Internal.cpp b/FppTest/state_machine/internal/state/Internal.cpp new file mode 100644 index 0000000000..8a356b4a76 --- /dev/null +++ b/FppTest/state_machine/internal/state/Internal.cpp @@ -0,0 +1,74 @@ +// ====================================================================== +// +// \title Internal.hpp +// \author R. Bocchino +// \brief Test class for internal state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/Internal.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +Internal::Internal() : InternalStateMachineBase(), m_action_a_history() {} + +void Internal::action_a(Signal signal) { + this->m_action_a_history.push(signal); +} + +void Internal::testInit() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1_S2); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void Internal::testS2_internal() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->getState(), State::S1_S2); + this->sendSignal_S1_internal(); + ASSERT_EQ(this->getState(), State::S1_S2); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getItemAt(0), Signal::S1_internal); +} + +void Internal::testS2_to_S3() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->getState(), State::S1_S2); + this->sendSignal_S2_to_S3(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); + ASSERT_EQ(this->m_action_a_history.getSize(), 0); +} + +void Internal::testS3_internal() { + this->m_action_a_history.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); + this->sendSignal_S1_internal(); + ASSERT_EQ(this->getState(), State::S1_S3); + ASSERT_EQ(this->m_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_action_a_history.getItemAt(0), Signal::S1_internal); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/Internal.fpp b/FppTest/state_machine/internal/state/Internal.fpp new file mode 100644 index 0000000000..d26eda1977 --- /dev/null +++ b/FppTest/state_machine/internal/state/Internal.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/Internal.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/Internal.hpp b/FppTest/state_machine/internal/state/Internal.hpp new file mode 100644 index 0000000000..ca352a7764 --- /dev/null +++ b/FppTest/state_machine/internal/state/Internal.hpp @@ -0,0 +1,61 @@ +// ====================================================================== +// +// \title Internal.hpp +// \author R. Bocchino +// \brief Test class for internal state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_Internal_HPP +#define FppTest_State_Internal_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/InternalStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A hierarchical state machine with an internal transition +class Internal final : public InternalStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Constructor + Internal(); + + private: + //! Action a + void action_a(Signal signal //!< The signal + ) final; + + public: + //! Test initial transition + void testInit(); + + //! Test internal transition in S2 + void testS2_internal(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test internal transition in S3 + void testS3_internal(); + + private: + //! The history of action a + SmHarness::History m_action_a_history; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/Polymorphism.cpp b/FppTest/state_machine/internal/state/Polymorphism.cpp new file mode 100644 index 0000000000..bb18f4eaba --- /dev/null +++ b/FppTest/state_machine/internal/state/Polymorphism.cpp @@ -0,0 +1,64 @@ +// ====================================================================== +// +// \title Polymorphism.hpp +// \author R. Bocchino +// \brief Test class for polymorphic state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/Polymorphism.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +Polymorphism::Polymorphism() : PolymorphismStateMachineBase() {} + +void Polymorphism::testInit() { + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1_S2); +} + +void Polymorphism::testS2_poly() { + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->getState(), State::S1_S2); + this->sendSignal_poly(); + this->sendSignal_poly(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S4); +} + +void Polymorphism::testS2_to_S3() { + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->getState(), State::S1_S2); + this->sendSignal_S2_to_S3(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); +} + +void Polymorphism::testS3_poly() { + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); + this->sendSignal_poly(); + this->sendSignal_poly(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S5); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/Polymorphism.fpp b/FppTest/state_machine/internal/state/Polymorphism.fpp new file mode 100644 index 0000000000..400f73cc32 --- /dev/null +++ b/FppTest/state_machine/internal/state/Polymorphism.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/Polymorphism.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/Polymorphism.hpp b/FppTest/state_machine/internal/state/Polymorphism.hpp new file mode 100644 index 0000000000..f3b2dae06d --- /dev/null +++ b/FppTest/state_machine/internal/state/Polymorphism.hpp @@ -0,0 +1,48 @@ +// ====================================================================== +// +// \title Polymorphism.hpp +// \author R. Bocchino +// \brief Test class for polymorphic state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_Polymorphism_HPP +#define FppTest_State_Polymorphism_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/PolymorphismStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A hierarchical state machine with behavioral polymorphism +class Polymorphism final : public PolymorphismStateMachineBase { + public: + //! Constructor + Polymorphism(); + + public: + //! Test initial transition + void testInit(); + + //! Test polymorphic transition in S2 + void testS2_poly(); + + //! Test transition from S2 to S3 + void testS2_to_S3(); + + //! Test polymorphic transition in S3 + void testS3_poly(); +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/README.md b/FppTest/state_machine/internal/state/README.md new file mode 100644 index 0000000000..956ea3c58f --- /dev/null +++ b/FppTest/state_machine/internal/state/README.md @@ -0,0 +1,3 @@ +# state_machine/internal/states + +Tests for transitions out of states in FPP internal state machines. diff --git a/FppTest/state_machine/internal/state/StateToChild.cpp b/FppTest/state_machine/internal/state/StateToChild.cpp new file mode 100644 index 0000000000..0d63772ada --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToChild.cpp @@ -0,0 +1,118 @@ +// ====================================================================== +// +// \title StateToChild.hpp +// \author R. Bocchino +// \brief Test class for state-to-self state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/StateToChild.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +StateToChild::StateToChild() : StateToChildStateMachineBase(), m_actionHistory() {} + +void StateToChild::action_exitS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToChild::action_exitS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToChild::action_a(Signal signal) { + this->m_actionHistory.push(signal, ActionId::A); +} + +void StateToChild::action_enterS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToChild::action_enterS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S3); +} + +void StateToChild::testInit() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1_S2); + ASSERT_EQ(this->m_actionHistory.getSize(), 1); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + ASSERT_EQ(signals.getItemAt(0), Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S2); +} + +void StateToChild::testS2_to_S2() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S2(); + ASSERT_EQ(this->getState(), State::S1_S2); + const FwSizeType expectedSize = 3; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S2); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::A); + ASSERT_EQ(actions.getItemAt(2), ActionId::ENTER_S2); +} + +void StateToChild::testS2_to_S3() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S2_to_S3(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToChild::testS3_to_S2() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + this->m_actionHistory.clear(); + ASSERT_EQ(this->getState(), State::S1_S3); + this->sendSignal_S1_to_S2(); + ASSERT_EQ(this->getState(), State::S1_S2); + const FwSizeType expectedSize = 3; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S2); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::A); + ASSERT_EQ(actions.getItemAt(2), ActionId::ENTER_S2); +} +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/StateToChild.fpp b/FppTest/state_machine/internal/state/StateToChild.fpp new file mode 100644 index 0000000000..72cd8f4aae --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToChild.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/StateToChild.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/StateToChild.hpp b/FppTest/state_machine/internal/state/StateToChild.hpp new file mode 100644 index 0000000000..2d30f961c1 --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToChild.hpp @@ -0,0 +1,81 @@ +// ====================================================================== +// +// \title StateToChild.hpp +// \author R. Bocchino +// \brief Test class for state-to-self state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_StateToChild_HPP +#define FppTest_State_StateToChild_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/StateToChildStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A state machine for testing state-to-child transitions with hierarchy +class StateToChild final : public StateToChildStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Action IDs + enum class ActionId { EXIT_S2, EXIT_S3, A, ENTER_S2, ENTER_S3 }; + + public: + //! Constructor + StateToChild(); + + private: + //! Exit S2 + void action_exitS2(Signal signal //!< The signal + ) final; + + //! Exit S3 + void action_exitS3(Signal signal //!< The signal + ) final; + + //! Action a + void action_a(Signal signal //!< The signal + ) final; + + //! Enter S2 + void action_enterS2(Signal signal //!< The signal + ) final; + + //! Enter S3 + void action_enterS3(Signal signal //!< The signal + ) final; + + public: + //! Test initial transition + void testInit(); + + //! Test transition from S2 to S2 + void testS2_to_S2(); + + //! Test transition from S2 to S3 + void testS2_to_S3(); + + //! Test transition from S3 to S2 + void testS3_to_S2(); + + private: + //! The action history + SmHarness::SignalValueHistory m_actionHistory; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/StateToChoice.cpp b/FppTest/state_machine/internal/state/StateToChoice.cpp new file mode 100644 index 0000000000..8acac30a6d --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToChoice.cpp @@ -0,0 +1,193 @@ +// ====================================================================== +// +// \title StateToChoice.hpp +// \author R. Bocchino +// \brief Test class for state-to-state state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/StateToChoice.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +StateToChoice::StateToChoice() : StateToChoiceStateMachineBase(), m_actionHistory(), m_guard_g() {} + +void StateToChoice::action_exitS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void StateToChoice::action_exitS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToChoice::action_exitS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToChoice::action_a(Signal signal) { + this->m_actionHistory.push(signal, ActionId::A); +} + +void StateToChoice::action_enterS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S1); +} + +void StateToChoice::action_enterS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToChoice::action_enterS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S3); +} + +void StateToChoice::action_enterS4(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S4); +} + +bool StateToChoice::guard_g(Signal signal) const { + return this->m_guard_g.call(signal); +} + +void StateToChoice::testInit() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1_S2); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S2); +} + +void StateToChoice::testS2_to_C() { + this->m_actionHistory.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_C(); + this->sendSignal_S1_to_C(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S4_S5); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_C); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +void StateToChoice::testS2_to_S3() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S2_to_S3(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToChoice::testS2_to_S4() { + this->m_actionHistory.clear(); + this->m_guard_g.reset(); + this->m_guard_g.setReturnValue(true); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S4(); + this->sendSignal_S1_to_S4(); + ASSERT_EQ(this->getState(), State::S4_S5); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +void StateToChoice::testS3_to_C() { + this->m_actionHistory.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_C(); + this->sendSignal_S1_to_C(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S4_S6); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_C); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +void StateToChoice::testS3_to_S4() { + this->m_actionHistory.clear(); + this->m_guard_g.reset(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S4(); + this->sendSignal_S1_to_S4(); + ASSERT_EQ(this->getState(), State::S4_S6); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/StateToChoice.fpp b/FppTest/state_machine/internal/state/StateToChoice.fpp new file mode 100644 index 0000000000..eb578090a6 --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToChoice.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/StateToChoice.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/StateToChoice.hpp b/FppTest/state_machine/internal/state/StateToChoice.hpp new file mode 100644 index 0000000000..3b2bd4d246 --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToChoice.hpp @@ -0,0 +1,106 @@ +// ====================================================================== +// +// \title StateToChoice.hpp +// \author R. Bocchino +// \brief Test class for state-to-choice state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_StateToChoice_HPP +#define FppTest_State_StateToChoice_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/StateToChoiceStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A state machine for testing state-to-choice transitions with hierarchy +class StateToChoice final : public StateToChoiceStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Action IDs + enum class ActionId { EXIT_S1, EXIT_S2, EXIT_S3, A, ENTER_S1, ENTER_S2, ENTER_S3, ENTER_S4 }; + + public: + //! Constructor + StateToChoice(); + + private: + //! Exit S1 + void action_exitS1(Signal signal //!< The signal + ) final; + + //! Exit S2 + void action_exitS2(Signal signal //!< The signal + ) final; + + //! Exit S3 + void action_exitS3(Signal signal //!< The signal + ) final; + + //! Action a + void action_a(Signal signal //!< The signal + ) final; + + //! Enter S1 + void action_enterS1(Signal signal //!< The signal + ) final; + + //! Enter S2 + void action_enterS2(Signal signal //!< The signal + ) final; + + //! Enter S3 + void action_enterS3(Signal signal //!< The signal + ) final; + + //! Enter S4 + void action_enterS4(Signal signal //!< The signal + ) final; + + //! Guard g + bool guard_g(Signal signal //!< The signal + ) const final; + + public: + //! Test initial transition + void testInit(); + + //! Test transition S2 to C + void testS2_to_C(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test transition S2 to S4 + void testS2_to_S4(); + + //! Test transition S3 to C + void testS3_to_C(); + + //! Test transition S3 to S4 + void testS3_to_S4(); + + private: + //! The action history + SmHarness::SignalValueHistory m_actionHistory; + + //! The guard g + SmHarness::NoArgGuard m_guard_g; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/StateToSelf.cpp b/FppTest/state_machine/internal/state/StateToSelf.cpp new file mode 100644 index 0000000000..d459ec0ae3 --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToSelf.cpp @@ -0,0 +1,134 @@ +// ====================================================================== +// +// \title StateToSelf.hpp +// \author R. Bocchino +// \brief Test class for state-to-self state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/StateToSelf.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +StateToSelf::StateToSelf() : StateToSelfStateMachineBase(), m_actionHistory() {} + +void StateToSelf::action_exitS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void StateToSelf::action_exitS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToSelf::action_exitS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToSelf::action_a(Signal signal) { + this->m_actionHistory.push(signal, ActionId::A); +} + +void StateToSelf::action_enterS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S1); +} + +void StateToSelf::action_enterS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToSelf::action_enterS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S3); +} + +void StateToSelf::testInit() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1_S2); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S2); +} + +void StateToSelf::testS2_to_S1() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S1(); + ASSERT_EQ(this->getState(), State::S1_S2); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S1); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S2); +} + +void StateToSelf::testS2_to_S3() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S2_to_S3(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToSelf::testS3_to_S1() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S1(); + ASSERT_EQ(this->getState(), State::S1_S2); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S1); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S2); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/StateToSelf.fpp b/FppTest/state_machine/internal/state/StateToSelf.fpp new file mode 100644 index 0000000000..84030e369b --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToSelf.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/StateToSelf.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/StateToSelf.hpp b/FppTest/state_machine/internal/state/StateToSelf.hpp new file mode 100644 index 0000000000..df61c44480 --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToSelf.hpp @@ -0,0 +1,89 @@ +// ====================================================================== +// +// \title StateToSelf.hpp +// \author R. Bocchino +// \brief Test class for state-to-self state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_StateToSelf_HPP +#define FppTest_State_StateToSelf_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/StateToSelfStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A state machine for testing state-to-self transitions with hierarchy +class StateToSelf final : public StateToSelfStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Action IDs + enum class ActionId { EXIT_S1, EXIT_S2, EXIT_S3, A, ENTER_S1, ENTER_S2, ENTER_S3 }; + + public: + //! Constructor + StateToSelf(); + + private: + //! Exit S1 + void action_exitS1(Signal signal //!< The signal + ) final; + + //! Exit S2 + void action_exitS2(Signal signal //!< The signal + ) final; + + //! Exit S3 + void action_exitS3(Signal signal //!< The signal + ) final; + + //! Action a + void action_a(Signal signal //!< The signal + ) final; + + //! Enter S1 + void action_enterS1(Signal signal //!< The signal + ) final; + + //! Enter S2 + void action_enterS2(Signal signal //!< The signal + ) final; + + //! Enter S3 + void action_enterS3(Signal signal //!< The signal + ) final; + + public: + //! Test initial transition + void testInit(); + + //! Test transition S2 to S1 + void testS2_to_S1(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test transition S3 to S1 + void testS3_to_S1(); + + private: + //! The action history + SmHarness::SignalValueHistory m_actionHistory; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/StateToState.cpp b/FppTest/state_machine/internal/state/StateToState.cpp new file mode 100644 index 0000000000..2b7ec7994a --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToState.cpp @@ -0,0 +1,188 @@ +// ====================================================================== +// +// \title StateToState.hpp +// \author R. Bocchino +// \brief Test class for state-to-state state machine (implementation) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/StateToState.hpp" +#include "STest/STest/Pick/Pick.hpp" + +namespace FppTest { + +namespace SmState { + +StateToState::StateToState() : StateToStateStateMachineBase(), m_actionHistory() {} + +void StateToState::action_exitS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void StateToState::action_exitS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToState::action_exitS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToState::action_a(Signal signal) { + this->m_actionHistory.push(signal, ActionId::A); +} + +void StateToState::action_enterS1(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S1); +} + +void StateToState::action_enterS2(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToState::action_enterS3(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S3); +} + +void StateToState::action_enterS4(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S4); +} + +void StateToState::action_enterS5(Signal signal) { + this->m_actionHistory.push(signal, ActionId::ENTER_S5); +} + +void StateToState::testInit() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + ASSERT_EQ(this->m_id, id); + ASSERT_EQ(this->getState(), State::S1_S2); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S2); +} + +void StateToState::testS2_to_S3() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S2_to_S3(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToState::testS2_to_S4() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S4(); + this->sendSignal_S1_to_S4(); + ASSERT_EQ(this->getState(), State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +void StateToState::testS2_to_S5() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S5(); + this->sendSignal_S1_to_S5(); + ASSERT_EQ(this->getState(), State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S5); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +void StateToState::testS3_to_S4() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S4(); + this->sendSignal_S2_to_S3(); + ASSERT_EQ(this->getState(), State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +void StateToState::testS3_to_S5() { + this->m_actionHistory.clear(); + const FwEnumStoreType id = SmHarness::Pick::stateMachineId(); + this->initBase(id); + this->sendSignal_S2_to_S3(); + this->m_actionHistory.clear(); + this->sendSignal_S1_to_S5(); + ASSERT_EQ(this->getState(), State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_actionHistory.getSignals(); + const auto& actions = this->m_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), Signal::S1_to_S5); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +} // namespace SmState + +} // end namespace FppTest diff --git a/FppTest/state_machine/internal/state/StateToState.fpp b/FppTest/state_machine/internal/state/StateToState.fpp new file mode 100644 index 0000000000..47ceb4e0f2 --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToState.fpp @@ -0,0 +1,9 @@ +module FppTest { + + module SmState { + + include "include/StateToState.fppi" + + } + +} diff --git a/FppTest/state_machine/internal/state/StateToState.hpp b/FppTest/state_machine/internal/state/StateToState.hpp new file mode 100644 index 0000000000..55f6810005 --- /dev/null +++ b/FppTest/state_machine/internal/state/StateToState.hpp @@ -0,0 +1,103 @@ +// ====================================================================== +// +// \title StateToState.hpp +// \author R. Bocchino +// \brief Test class for state-to-state state machine (header) +// +// \copyright +// Copyright 2024, by the California Institute of Technology. +// ALL RIGHTS RESERVED. United States Government Sponsorship +// acknowledged. +// +// ====================================================================== + +#ifndef FppTest_State_StateToState_HPP +#define FppTest_State_StateToState_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal/state/StateToStateStateMachineAc.hpp" + +namespace FppTest { + +namespace SmState { + +//! A state machine for testing state-to-state transitions with hierarchy +class StateToState final : public StateToStateStateMachineBase { + public: + //! The history size + static constexpr FwSizeType historySize = 10; + + public: + //! Action IDs + enum class ActionId { EXIT_S1, EXIT_S2, EXIT_S3, A, ENTER_S1, ENTER_S2, ENTER_S3, ENTER_S4, ENTER_S5 }; + + public: + //! Constructor + StateToState(); + + private: + //! Exit S1 + void action_exitS1(Signal signal //!< The signal + ) final; + + //! Exit S2 + void action_exitS2(Signal signal //!< The signal + ) final; + + //! Exit S3 + void action_exitS3(Signal signal //!< The signal + ) final; + + //! Action a + void action_a(Signal signal //!< The signal + ) final; + + //! Enter S1 + void action_enterS1(Signal signal //!< The signal + ) final; + + //! Enter S2 + void action_enterS2(Signal signal //!< The signal + ) final; + + //! Enter S3 + void action_enterS3(Signal signal //!< The signal + ) final; + + //! Enter S4 + void action_enterS4(Signal signal //!< The signal + ) final; + + //! Enter S5 + void action_enterS5(Signal signal //!< The signal + ) final; + + public: + //! Test initial transition + void testInit(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test transition S2 to S4 + void testS2_to_S4(); + + //! Test transition S2 to S5 + void testS2_to_S5(); + + //! Test transition S3 to S4 + void testS3_to_S4(); + + //! Test transition S3 to S5 + void testS3_to_S5(); + + private: + //! The action history + SmHarness::SignalValueHistory m_actionHistory; +}; + +} // namespace SmState + +} // end namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal/state/include/Basic.fppi b/FppTest/state_machine/internal/state/include/Basic.fppi new file mode 100644 index 0000000000..fbe2cae8c6 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/Basic.fppi @@ -0,0 +1,31 @@ +@ A basic state machine +state machine Basic { + + @ Action a + action a + + @ Signal s + signal s + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s do { a, a } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicGuard.fppi b/FppTest/state_machine/internal/state/include/BasicGuard.fppi new file mode 100644 index 0000000000..a44a7a8a20 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicGuard.fppi @@ -0,0 +1,34 @@ +@ A basic state machine with a guard +state machine BasicGuard { + + @ Action a + action a + + @ Guard g + guard g + + @ Signal s + signal s + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s if g do { a, a } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicGuardString.fppi b/FppTest/state_machine/internal/state/include/BasicGuardString.fppi new file mode 100644 index 0000000000..1cb4c337b0 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicGuardString.fppi @@ -0,0 +1,29 @@ +constant basicGuardStringSize = 80 + +@ A basic state machine with a string guard +state machine BasicGuardString { + + + @ Action a + action a: string + + @ Guard g + guard g: string + + @ Signal s + signal s: string size basicGuardStringSize + + initial enter S + + @ State S + state S { + + @ State transition + on s if g do { a } enter T + + } + + @ State T + state T + +} diff --git a/FppTest/state_machine/internal/state/include/BasicGuardTestAbsType.fppi b/FppTest/state_machine/internal/state/include/BasicGuardTestAbsType.fppi new file mode 100644 index 0000000000..db500d9367 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicGuardTestAbsType.fppi @@ -0,0 +1,26 @@ +@ A basic state machine with a TestAbsType guard +state machine BasicGuardTestAbsType { + + @ Action a + action a: SmHarness.TestAbsType + + @ Guard g + guard g: SmHarness.TestAbsType + + @ Signal s + signal s: SmHarness.TestAbsType + + initial enter S + + @ State S + state S { + + @ State transition + on s if g do { a } enter T + + } + + @ State T + state T + +} diff --git a/FppTest/state_machine/internal/state/include/BasicGuardTestArray.fppi b/FppTest/state_machine/internal/state/include/BasicGuardTestArray.fppi new file mode 100644 index 0000000000..8ca75ff991 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicGuardTestArray.fppi @@ -0,0 +1,26 @@ +@ A basic state machine with a TestArray guard +state machine BasicGuardTestArray { + + @ Action a + action a: SmHarness.TestArray + + @ Guard g + guard g: SmHarness.TestArray + + @ Signal s + signal s: SmHarness.TestArray + + initial enter S + + @ State S + state S { + + @ State transition + on s if g do { a } enter T + + } + + @ State T + state T + +} diff --git a/FppTest/state_machine/internal/state/include/BasicGuardTestEnum.fppi b/FppTest/state_machine/internal/state/include/BasicGuardTestEnum.fppi new file mode 100644 index 0000000000..be0da6b0fb --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicGuardTestEnum.fppi @@ -0,0 +1,26 @@ + @ A basic state machine with a TestEnum guard +state machine BasicGuardTestEnum { + + @ Action a + action a: SmHarness.TestEnum + + @ Guard g + guard g: SmHarness.TestEnum + + @ Signal s + signal s: SmHarness.TestEnum + + initial enter S + + @ State S + state S { + + @ State transition + on s if g do { a } enter T + + } + + @ State T + state T + +} diff --git a/FppTest/state_machine/internal/state/include/BasicGuardTestStruct.fppi b/FppTest/state_machine/internal/state/include/BasicGuardTestStruct.fppi new file mode 100644 index 0000000000..a756781fc5 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicGuardTestStruct.fppi @@ -0,0 +1,26 @@ +@ A basic state machine with a TestStruct guard +state machine BasicGuardTestStruct { + + @ Action a + action a: SmHarness.TestStruct + + @ Guard g + guard g: SmHarness.TestStruct + + @ Signal s + signal s: SmHarness.TestStruct + + initial enter S + + @ State S + state S { + + @ State transition + on s if g do { a } enter T + + } + + @ State T + state T + +} diff --git a/FppTest/state_machine/internal/state/include/BasicGuardU32.fppi b/FppTest/state_machine/internal/state/include/BasicGuardU32.fppi new file mode 100644 index 0000000000..c4ef1f404e --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicGuardU32.fppi @@ -0,0 +1,26 @@ +@ A basic state machine with a U32 guard +state machine BasicGuardU32 { + + @ Action a + action a: U32 + + @ Guard g + guard g: U32 + + @ Signal s + signal s: U32 + + initial enter S + + @ State S + state S { + + @ State transition + on s if g do { a } enter T + + } + + @ State T + state T + +} diff --git a/FppTest/state_machine/internal/state/include/BasicInternal.fppi b/FppTest/state_machine/internal/state/include/BasicInternal.fppi new file mode 100644 index 0000000000..4dbbd44b54 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicInternal.fppi @@ -0,0 +1,24 @@ +@ A basic state machine with an internal transition +state machine BasicInternal { + + @ Action a + action a + + @ Signal s + signal s + + @ Initial transition + initial enter S + + @ State S + state S { + + @ Enter S + entry do { a } + + @ Internal transition + on s do { a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicSelf.fppi b/FppTest/state_machine/internal/state/include/BasicSelf.fppi new file mode 100644 index 0000000000..f341831837 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicSelf.fppi @@ -0,0 +1,26 @@ +@ A basic state machine with a self transition +state machine BasicSelf { + + @ Action a + action a + + @ Signal s + signal s + + initial enter S + + @ State S + state S { + + @ Entry + entry do { a } + + @ Exit + exit do { a, a } + + @ State transition + on s do { a, a, a } enter S + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicString.fppi b/FppTest/state_machine/internal/state/include/BasicString.fppi new file mode 100644 index 0000000000..df2b31dd05 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicString.fppi @@ -0,0 +1,36 @@ +constant basicStringSize = 80 + +@ A basic state machine with string actions +state machine BasicString { + + @ Action a + action a + + @ Action b + action b: string + + @ Signal s + signal s: string + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s do { a, b } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicTestAbsType.fppi b/FppTest/state_machine/internal/state/include/BasicTestAbsType.fppi new file mode 100644 index 0000000000..7b2f6ea4bf --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicTestAbsType.fppi @@ -0,0 +1,34 @@ +@ A basic state machine with TestAbsType actions +state machine BasicTestAbsType { + + @ Action a + action a + + @ Action b + action b: SmHarness.TestAbsType + + @ Signal s + signal s: SmHarness.TestAbsType + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s do { a, b } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicTestArray.fppi b/FppTest/state_machine/internal/state/include/BasicTestArray.fppi new file mode 100644 index 0000000000..34267b90ce --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicTestArray.fppi @@ -0,0 +1,34 @@ +@ A basic state machine with TestArray actions +state machine BasicTestArray { + + @ Action a + action a + + @ Action b + action b: SmHarness.TestArray + + @ Signal s + signal s: SmHarness.TestArray + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s do { a, b } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicTestEnum.fppi b/FppTest/state_machine/internal/state/include/BasicTestEnum.fppi new file mode 100644 index 0000000000..d3f68da496 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicTestEnum.fppi @@ -0,0 +1,34 @@ +@ A basic state machine with TestEnum actions +state machine BasicTestEnum { + + @ Action a + action a + + @ Action b + action b: SmHarness.TestEnum + + @ Signal s + signal s: SmHarness.TestEnum + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s do { a, b } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicTestStruct.fppi b/FppTest/state_machine/internal/state/include/BasicTestStruct.fppi new file mode 100644 index 0000000000..0736551c6d --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicTestStruct.fppi @@ -0,0 +1,34 @@ +@ A basic state machine with TestStruct actions +state machine BasicTestStruct { + + @ Action a + action a + + @ Action b + action b: SmHarness.TestStruct + + @ Signal s + signal s: SmHarness.TestStruct + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s do { a, b } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/BasicU32.fppi b/FppTest/state_machine/internal/state/include/BasicU32.fppi new file mode 100644 index 0000000000..7a2305d3be --- /dev/null +++ b/FppTest/state_machine/internal/state/include/BasicU32.fppi @@ -0,0 +1,34 @@ +@ A basic state machine with U32 actions +state machine BasicU32 { + + @ Action a + action a + + @ Action b + action b: U32 + + @ Signal s + signal s: U32 + + initial enter S + + @ State S + state S { + + @ Exit + exit do { a } + + @ State transition + on s do { a, b } enter T + + } + + @ State T + state T { + + @ Entry + entry do { a, a, a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/Internal.fppi b/FppTest/state_machine/internal/state/include/Internal.fppi new file mode 100644 index 0000000000..811448550e --- /dev/null +++ b/FppTest/state_machine/internal/state/include/Internal.fppi @@ -0,0 +1,38 @@ +@ A hierarchical state machine with an internal transition +state machine Internal { + + @ Action a + action a + + @ Signal for internal transition in S1 + signal S1_internal + + @ Signal for transition from S2 to S3 + signal S2_to_S3 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Initial transition + initial enter S2 + + @ State S2 + state S2 { + + @ Transition from S2 to S3 + on S2_to_S3 enter S3 + + } + + @ State S3 + state S3 + + @ Internal transition + on S1_internal do { a } + + } + +} diff --git a/FppTest/state_machine/internal/state/include/Polymorphism.fppi b/FppTest/state_machine/internal/state/include/Polymorphism.fppi new file mode 100644 index 0000000000..8387f7feed --- /dev/null +++ b/FppTest/state_machine/internal/state/include/Polymorphism.fppi @@ -0,0 +1,46 @@ +@ A hierarchical state machine with behavioral polymorphism +state machine Polymorphism { + + @ Signal for polymorphic transition + signal poly + + @ Signal for transition from S2 to S3 + signal S2_to_S3 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Initial transition + initial enter S2 + + @ Polymorphic state transition + on poly enter S4 + + @ State S2 + state S2 { + + on S2_to_S3 enter S3 + + } + + @ State S3 + state S3 { + + @ Polymorphic state transition + @ This transition overrides the transition in S1 + on poly enter S5 + + } + + } + + @ State S4 + state S4 + + @ State S5 + state S5 + +} diff --git a/FppTest/state_machine/internal/state/include/StateToChild.fppi b/FppTest/state_machine/internal/state/include/StateToChild.fppi new file mode 100644 index 0000000000..7c4c14d369 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/StateToChild.fppi @@ -0,0 +1,64 @@ +@ A state machine for testing state-to-child transitions +state machine StateToChild { + + @ Exit S2 + action exitS2 + + @ Exit S3 + action exitS3 + + @ Action a + action a + + @ Enter S2 + action enterS2 + + @ Enter S3 + action enterS3 + + @ Signal for going from S1 to S2 + signal S1_to_S2 + + @ Signal for going from S2 to S3 + signal S2_to_S3 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Initial transition + initial enter S2 + + @ State S2 + state S2 { + + @ Enter S2 + entry do { enterS2 } + + @ Exit S2 + exit do { exitS2 } + + @ State transition to S3 + on S2_to_S3 enter S3 + + } + + @ State S3 + state S3 { + + @ Enter S3 + entry do { enterS3 } + + @ Exit S3 + exit do { exitS3 } + + } + + @ State transition to S2 + on S1_to_S2 do { a } enter S2 + + } + +} diff --git a/FppTest/state_machine/internal/state/include/StateToChoice.fppi b/FppTest/state_machine/internal/state/include/StateToChoice.fppi new file mode 100644 index 0000000000..c5be6ce87a --- /dev/null +++ b/FppTest/state_machine/internal/state/include/StateToChoice.fppi @@ -0,0 +1,109 @@ +@ A state machine for testing state-to-choice transitions +@ with hierarchy +state machine StateToChoice { + + @ Exit S1 + action exitS1 + + @ Exit S2 + action exitS2 + + @ Exit S3 + action exitS3 + + @ Action a + action a + + @ Enter S1 + action enterS1 + + @ Enter S2 + action enterS2 + + @ Enter S3 + action enterS3 + + @ Enter S4 + action enterS4 + + @ Guard g + guard g + + @ Signal for going from S1 to S4 + signal S1_to_S4 + + @ Signal for going from S1 to C + signal S1_to_C + + @ Signal for going from S2 to S3 + signal S2_to_S3 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Initial transition + initial enter S2 + + @ Enter S1 + entry do { enterS1 } + + @ Exit S1 + exit do { exitS1 } + + @ State S2 + state S2 { + + @ Enter S2 + entry do { enterS2 } + + @ Exit S2 + exit do { exitS2 } + + @ State transition to S3 + on S2_to_S3 enter S3 + + } + + @ State S3 + state S3 { + + @ Enter S3 + entry do { enterS3 } + + @ Exit S3 + exit do { exitS3 } + + } + + @ State transition to S4 + on S1_to_S4 do { a } enter S4 + + @ State transition to C + on S1_to_C do { a } enter S4.C + + } + + @ State S4 + state S4 { + + @ Initial transition + initial enter C + + @ Enter S4 + entry do { enterS4 } + + @ Choice C + choice C { if g enter S5 else enter S6 } + + @ State S5 + state S5 + + @ State S6 + state S6 + + } + +} diff --git a/FppTest/state_machine/internal/state/include/StateToSelf.fppi b/FppTest/state_machine/internal/state/include/StateToSelf.fppi new file mode 100644 index 0000000000..a646c7cec0 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/StateToSelf.fppi @@ -0,0 +1,77 @@ +@ A state machine for testing state-to-self transitions +@ with hierarchy +state machine StateToSelf { + + @ Exit S1 + action exitS1 + + @ Exit S2 + action exitS2 + + @ Exit S3 + action exitS3 + + @ Action a + action a + + @ Enter S1 + action enterS1 + + @ Enter S2 + action enterS2 + + @ Enter S3 + action enterS3 + + @ Signal for going from S1 to S1 + signal S1_to_S1 + + @ Signal for going from S2 to S3 + signal S2_to_S3 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Initial transition + initial enter S2 + + @ Enter S1 + entry do { enterS1 } + + @ Exit S1 + exit do { exitS1 } + + @ State S2 + state S2 { + + @ Enter S2 + entry do { enterS2 } + + @ Exit S2 + exit do { exitS2 } + + @ State transition to S3 + on S2_to_S3 enter S3 + + } + + @ State S3 + state S3 { + + @ Enter S3 + entry do { enterS3 } + + @ Exit S3 + exit do { exitS3 } + + } + + @ State transition to S1 + on S1_to_S1 do { a } enter S1 + + } + +} diff --git a/FppTest/state_machine/internal/state/include/StateToState.fppi b/FppTest/state_machine/internal/state/include/StateToState.fppi new file mode 100644 index 0000000000..d81e9356f7 --- /dev/null +++ b/FppTest/state_machine/internal/state/include/StateToState.fppi @@ -0,0 +1,108 @@ +@ A state machine for testing state-to-state transitions +@ with hierarchy +state machine StateToState { + + @ Exit S1 + action exitS1 + + @ Exit S2 + action exitS2 + + @ Exit S3 + action exitS3 + + @ Action a + action a + + @ Enter S1 + action enterS1 + + @ Enter S2 + action enterS2 + + @ Enter S3 + action enterS3 + + @ Enter S4 + action enterS4 + + @ Enter S5 + action enterS5 + + @ Signal for going from S1 to S4 + signal S1_to_S4 + + @ Signal for going from S1 to S5 + signal S1_to_S5 + + @ Signal for going from S2 to S3 + signal S2_to_S3 + + @ Initial transition + initial enter S1 + + @ State S1 + state S1 { + + @ Initial transition + initial enter S2 + + @ Enter S1 + entry do { enterS1 } + + @ Exit S1 + exit do { exitS1 } + + @ State S2 + state S2 { + + @ Enter S2 + entry do { enterS2 } + + @ Exit S2 + exit do { exitS2 } + + @ State transition to S3 + on S2_to_S3 enter S3 + + } + + @ State S3 + state S3 { + + @ Enter S3 + entry do { enterS3 } + + @ Exit S3 + exit do { exitS3 } + + } + + @ State transition to S4 + on S1_to_S4 do { a } enter S4 + + @ State transition to S5 + on S1_to_S5 do { a } enter S4.S5 + + } + + @ State S4 + state S4 { + + @ Initial transition + initial enter S5 + + @ Enter S4 + entry do { enterS4 } + + @ State S5 + state S5 { + + @ Enter S5 + entry do { enterS5 } + + } + + } + +} diff --git a/FppTest/state_machine/internal/state/main.cpp b/FppTest/state_machine/internal/state/main.cpp new file mode 100644 index 0000000000..50eb94bc13 --- /dev/null +++ b/FppTest/state_machine/internal/state/main.cpp @@ -0,0 +1,294 @@ +// ---------------------------------------------------------------------- +// main.cpp +// ---------------------------------------------------------------------- + +#include + +#include "FppTest/state_machine/internal/state/Basic.hpp" +#include "FppTest/state_machine/internal/state/BasicGuard.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardString.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestAbsType.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestArray.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestEnum.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardTestStruct.hpp" +#include "FppTest/state_machine/internal/state/BasicGuardU32.hpp" +#include "FppTest/state_machine/internal/state/BasicInternal.hpp" +#include "FppTest/state_machine/internal/state/BasicSelf.hpp" +#include "FppTest/state_machine/internal/state/BasicString.hpp" +#include "FppTest/state_machine/internal/state/BasicTestAbsType.hpp" +#include "FppTest/state_machine/internal/state/BasicTestArray.hpp" +#include "FppTest/state_machine/internal/state/BasicTestEnum.hpp" +#include "FppTest/state_machine/internal/state/BasicTestStruct.hpp" +#include "FppTest/state_machine/internal/state/BasicU32.hpp" +#include "FppTest/state_machine/internal/state/Internal.hpp" +#include "FppTest/state_machine/internal/state/Polymorphism.hpp" +#include "FppTest/state_machine/internal/state/StateToChild.hpp" +#include "FppTest/state_machine/internal/state/StateToChoice.hpp" +#include "FppTest/state_machine/internal/state/StateToSelf.hpp" +#include "FppTest/state_machine/internal/state/StateToState.hpp" +#include "STest/STest/Random/Random.hpp" + +TEST(Basic, Test) { + FppTest::SmState::Basic basic; + basic.test(); +} + +TEST(BasicGuard, False) { + FppTest::SmState::BasicGuard basicGuard; + basicGuard.testFalse(); +} + +TEST(BasicGuard, True) { + FppTest::SmState::BasicGuard basicGuard; + basicGuard.testTrue(); +} + +TEST(BasicGuardString, False) { + FppTest::SmState::BasicGuardString basicGuardString; + basicGuardString.testFalse(); +} + +TEST(BasicGuardString, True) { + FppTest::SmState::BasicGuardString basicGuardString; + basicGuardString.testTrue(); +} + +TEST(BasicGuardTestAbsType, False) { + FppTest::SmState::BasicGuardTestAbsType basicGuardTestAbsType; + basicGuardTestAbsType.testFalse(); +} + +TEST(BasicGuardTestAbsType, True) { + FppTest::SmState::BasicGuardTestAbsType basicGuardTestAbsType; + basicGuardTestAbsType.testTrue(); +} + +TEST(BasicGuardTestArray, False) { + FppTest::SmState::BasicGuardTestArray basicGuardTestArray; + basicGuardTestArray.testFalse(); +} + +TEST(BasicGuardTestArray, True) { + FppTest::SmState::BasicGuardTestArray basicGuardTestArray; + basicGuardTestArray.testTrue(); +} + +TEST(BasicGuardTestEnum, False) { + FppTest::SmState::BasicGuardTestEnum basicGuardTestEnum; + basicGuardTestEnum.testFalse(); +} + +TEST(BasicGuardTestEnum, True) { + FppTest::SmState::BasicGuardTestEnum basicGuardTestEnum; + basicGuardTestEnum.testTrue(); +} + +TEST(BasicGuardTestStruct, False) { + FppTest::SmState::BasicGuardTestStruct basicGuardTestStruct; + basicGuardTestStruct.testFalse(); +} + +TEST(BasicGuardTestStruct, True) { + FppTest::SmState::BasicGuardTestStruct basicGuardTestStruct; + basicGuardTestStruct.testTrue(); +} + +TEST(BasicGuardU32, False) { + FppTest::SmState::BasicGuardU32 basicGuardU32; + basicGuardU32.testFalse(); +} + +TEST(BasicGuardU32, True) { + FppTest::SmState::BasicGuardU32 basicGuardU32; + basicGuardU32.testTrue(); +} + +TEST(BasicInternal, Test) { + FppTest::SmState::BasicInternal basicInternal; + basicInternal.test(); +} + +TEST(BasicSelf, Test) { + FppTest::SmState::BasicSelf basicSelf; + basicSelf.test(); +} + +TEST(BasicString, Test) { + FppTest::SmState::BasicString basicString; + basicString.test(); +} + +TEST(BasicTestAbsType, Test) { + FppTest::SmState::BasicTestAbsType basicTestAbsType; + basicTestAbsType.test(); +} + +TEST(BasicTestArray, Test) { + FppTest::SmState::BasicTestArray basicTestArray; + basicTestArray.test(); +} + +TEST(BasicTestEnum, Test) { + FppTest::SmState::BasicTestEnum basicTestEnum; + basicTestEnum.test(); +} + +TEST(BasicTestStruct, Test) { + FppTest::SmState::BasicTestStruct basicTestStruct; + basicTestStruct.test(); +} + +TEST(BasicU32, Test) { + FppTest::SmState::BasicU32 basicU32; + basicU32.test(); +} + +TEST(Internal, Init) { + FppTest::SmState::Internal internal; + internal.testInit(); +} + +TEST(Internal, S2_internal) { + FppTest::SmState::Internal internal; + internal.testS2_internal(); +} + +TEST(Internal, S2_to_S3) { + FppTest::SmState::Internal internal; + internal.testS2_to_S3(); +} + +TEST(Internal, S3_internal) { + FppTest::SmState::Internal internal; + internal.testS3_internal(); +} + +TEST(Polymorphism, Init) { + FppTest::SmState::Polymorphism polymorphism; + polymorphism.testInit(); +} + +TEST(Polymorphism, S2_poly) { + FppTest::SmState::Polymorphism polymorphism; + polymorphism.testS2_poly(); +} + +TEST(Polymorphism, S2_to_S3) { + FppTest::SmState::Polymorphism polymorphism; + polymorphism.testS2_to_S3(); +} + +TEST(Polymorphism, S3_poly) { + FppTest::SmState::Polymorphism polymorphism; + polymorphism.testS3_poly(); +} + +TEST(StateToChild, Init) { + FppTest::SmState::StateToChild stateToChild; + stateToChild.testInit(); +} + +TEST(StateToChild, S2_to_S2) { + FppTest::SmState::StateToChild stateToChild; + stateToChild.testS2_to_S2(); +} + +TEST(StateToChild, S2_to_S3) { + FppTest::SmState::StateToChild stateToChild; + stateToChild.testS2_to_S3(); +} + +TEST(StateToChild, S3_to_S2) { + FppTest::SmState::StateToChild stateToChild; + stateToChild.testS3_to_S2(); +} + +TEST(StateToChoice, Init) { + FppTest::SmState::StateToChoice stateToChoice; + stateToChoice.testInit(); +} + +TEST(StateToChoice, S2_to_C) { + FppTest::SmState::StateToChoice stateToChoice; + stateToChoice.testS2_to_C(); +} + +TEST(StateToChoice, S2_to_S4) { + FppTest::SmState::StateToChoice stateToChoice; + stateToChoice.testS2_to_S4(); +} + +TEST(StateToChoice, S2_to_S3) { + FppTest::SmState::StateToChoice stateToChoice; + stateToChoice.testS2_to_S3(); +} + +TEST(StateToChoice, S3_to_C) { + FppTest::SmState::StateToChoice stateToChoice; + stateToChoice.testS3_to_C(); +} + +TEST(StateToChoice, S3_to_S4) { + FppTest::SmState::StateToChoice stateToChoice; + stateToChoice.testS3_to_S4(); +} + +TEST(StateToSelf, Init) { + FppTest::SmState::StateToSelf stateToSelf; + stateToSelf.testInit(); +} + +TEST(StateToSelf, S2_to_S1) { + FppTest::SmState::StateToSelf stateToSelf; + stateToSelf.testS2_to_S1(); +} + +TEST(StateToSelf, S2_to_S3) { + FppTest::SmState::StateToSelf stateToSelf; + stateToSelf.testS2_to_S3(); +} + +TEST(StateToSelf, S3_to_S1) { + FppTest::SmState::StateToSelf stateToSelf; + stateToSelf.testS3_to_S1(); +} + +TEST(StateToState, Init) { + FppTest::SmState::StateToState stateToState; + stateToState.testInit(); +} + +TEST(StateToState, S2_to_S3) { + FppTest::SmState::StateToState stateToState; + stateToState.testS2_to_S3(); +} + +TEST(StateToState, S2_to_S4) { + FppTest::SmState::StateToState stateToState; + stateToState.testS2_to_S4(); +} + +TEST(StateToState, S2_to_S5) { + FppTest::SmState::StateToState stateToState; + stateToState.testS2_to_S5(); +} + +TEST(StateToState, S3_to_S4) { + FppTest::SmState::StateToState stateToState; + stateToState.testS3_to_S4(); +} + +TEST(StateToState, S3_to_S5) { + FppTest::SmState::StateToState stateToState; + stateToState.testS3_to_S5(); +} + +// ---------------------------------------------------------------------- +// Main function +// ---------------------------------------------------------------------- + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + STest::Random::seed(); + return RUN_ALL_TESTS(); +} diff --git a/FppTest/state_machine/internal_instance/CMakeLists.txt b/FppTest/state_machine/internal_instance/CMakeLists.txt new file mode 100644 index 0000000000..7066a29ac9 --- /dev/null +++ b/FppTest/state_machine/internal_instance/CMakeLists.txt @@ -0,0 +1,3 @@ +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/choice/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/initial/") +add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/state/") diff --git a/FppTest/state_machine/internal_instance/choice/Basic.cpp b/FppTest/state_machine/internal_instance/choice/Basic.cpp new file mode 100644 index 0000000000..9156622bea --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/Basic.cpp @@ -0,0 +1,168 @@ +// ====================================================================== +// \title Basic.cpp +// \author bocchino +// \brief cpp file for Basic component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/choice/Basic.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Basic::Basic(const char* const compName) + : BasicComponentBase(compName), + m_basic_action_a_history(), + m_basic_action_b_history(), + m_basic_guard_g(), + m_smChoiceBasic_action_a_history(), + m_smChoiceBasic_action_b_history(), + m_smChoiceBasic_guard_g() {} + +Basic::~Basic() {} + +// ---------------------------------------------------------------------- +// Handler implementations for typed input ports +// ---------------------------------------------------------------------- + +void Basic::schedIn_handler(FwIndexType portNum, U32 context) { + // Nothing to do +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Basic::FppTest_SmInstanceChoice_Basic_Basic_action_a(SmId smId, + FppTest_SmInstanceChoice_Basic_Basic::Signal signal) { + ASSERT_EQ(smId, SmId::basic); + this->m_basic_action_a_history.push(signal); +} + +void Basic::FppTest_SmInstanceChoice_Basic_Basic_action_b(SmId smId, + FppTest_SmInstanceChoice_Basic_Basic::Signal signal) { + ASSERT_EQ(smId, SmId::basic); + this->m_basic_action_b_history.push(signal); +} + +void Basic::FppTest_SmChoice_Basic_action_a(SmId smId, FppTest_SmChoice_Basic::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceBasic); + this->m_smChoiceBasic_action_a_history.push(signal); +} + +void Basic::FppTest_SmChoice_Basic_action_b(SmId smId, FppTest_SmChoice_Basic::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceBasic); + this->m_smChoiceBasic_action_b_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool Basic::FppTest_SmInstanceChoice_Basic_Basic_guard_g(SmId smId, + FppTest_SmInstanceChoice_Basic_Basic::Signal signal) const { + FW_ASSERT(smId == SmId::basic, static_cast(smId)); + return this->m_basic_guard_g.call(signal); +} + +bool Basic::FppTest_SmChoice_Basic_guard_g(SmId smId, FppTest_SmChoice_Basic::Signal signal) const { + FW_ASSERT(smId == SmId::smChoiceBasic, static_cast(smId)); + return this->m_smChoiceBasic_guard_g.call(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Basic::testBasicTrue() { + this->m_basic_action_a_history.clear(); + this->m_basic_action_b_history.clear(); + this->m_basic_guard_g.reset(); + this->m_basic_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->basic_getState(), Basic_Basic::State::S1); + ASSERT_EQ(this->m_basic_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_basic_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_basic_action_b_history.getSize(), 0); + this->basic_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_basic_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_basic_guard_g.getCallHistory().getItemAt(0), Basic_Basic::Signal::s); + ASSERT_EQ(this->m_basic_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_basic_action_a_history.getItemAt(0), Basic_Basic::Signal::s); + ASSERT_EQ(this->m_basic_action_b_history.getSize(), 0); + ASSERT_EQ(this->basic_getState(), Basic_Basic::State::S2); +} + +void Basic::testBasicFalse() { + this->m_basic_action_a_history.clear(); + this->m_basic_action_b_history.clear(); + this->m_basic_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->basic_getState(), Basic_Basic::State::S1); + ASSERT_EQ(this->m_basic_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_basic_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_basic_action_b_history.getSize(), 0); + this->basic_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_basic_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_basic_guard_g.getCallHistory().getItemAt(0), Basic_Basic::Signal::s); + ASSERT_EQ(this->m_basic_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_basic_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_basic_action_b_history.getItemAt(0), Basic_Basic::Signal::s); + ASSERT_EQ(this->basic_getState(), Basic_Basic::State::S3); +} + +void Basic::testSmChoiceBasicTrue() { + this->m_smChoiceBasic_action_a_history.clear(); + this->m_smChoiceBasic_action_b_history.clear(); + this->m_smChoiceBasic_guard_g.reset(); + this->m_smChoiceBasic_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceBasic_getState(), SmChoice_Basic::State::S1); + ASSERT_EQ(this->m_smChoiceBasic_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasic_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasic_action_b_history.getSize(), 0); + this->smChoiceBasic_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceBasic_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasic_guard_g.getCallHistory().getItemAt(0), SmChoice_Basic::Signal::s); + ASSERT_EQ(this->m_smChoiceBasic_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasic_action_a_history.getItemAt(0), SmChoice_Basic::Signal::s); + ASSERT_EQ(this->m_smChoiceBasic_action_b_history.getSize(), 0); + ASSERT_EQ(this->smChoiceBasic_getState(), SmChoice_Basic::State::S2); +} + +void Basic::testSmChoiceBasicFalse() { + this->m_smChoiceBasic_action_a_history.clear(); + this->m_smChoiceBasic_action_b_history.clear(); + this->m_smChoiceBasic_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceBasic_getState(), SmChoice_Basic::State::S1); + ASSERT_EQ(this->m_smChoiceBasic_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasic_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasic_action_b_history.getSize(), 0); + this->smChoiceBasic_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceBasic_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasic_guard_g.getCallHistory().getItemAt(0), SmChoice_Basic::Signal::s); + ASSERT_EQ(this->m_smChoiceBasic_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasic_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasic_action_b_history.getItemAt(0), SmChoice_Basic::Signal::s); + ASSERT_EQ(this->smChoiceBasic_getState(), SmChoice_Basic::State::S3); +} + +} // namespace SmInstanceChoice + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/choice/Basic.fpp b/FppTest/state_machine/internal_instance/choice/Basic.fpp new file mode 100644 index 0000000000..33954ba5c7 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/Basic.fpp @@ -0,0 +1,19 @@ +module FppTest { + + module SmInstanceChoice { + + queued component Basic { + + sync input port schedIn: Svc.Sched + + include "../../internal/choice/include/Basic.fppi" + + state machine instance basic: Basic + + state machine instance smChoiceBasic: SmChoice.Basic priority 1 assert + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/choice/Basic.hpp b/FppTest/state_machine/internal_instance/choice/Basic.hpp new file mode 100644 index 0000000000..7e4bf2248d --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/Basic.hpp @@ -0,0 +1,165 @@ +// ====================================================================== +// \title Basic.hpp +// \author bocchino +// \brief hpp file for Basic component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceChoice_Basic_HPP +#define FppTest_SmInstanceChoice_Basic_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/choice/BasicComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +class Basic : public BasicComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmInstanceChoice_Basic_Basic + using Basic_Basic = FppTest_SmInstanceChoice_Basic_Basic; + + //! The type FppTest_SmChoice_Basic + using SmChoice_Basic = FppTest_SmChoice_Basic; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Basic object + Basic(const char* const compName //!< The component name + ); + + //! Destroy Basic object + ~Basic(); + + 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; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmInstanceChoice_Basic_Basic + //! + //! Action a + void FppTest_SmInstanceChoice_Basic_Basic_action_a( + SmId smId, //!< The state machine id + FppTest_SmInstanceChoice_Basic_Basic::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmInstanceChoice_Basic_Basic + //! + //! Action b + void FppTest_SmInstanceChoice_Basic_Basic_action_b( + SmId smId, //!< The state machine id + FppTest_SmInstanceChoice_Basic_Basic::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmChoice_Basic + //! + //! Action a + void FppTest_SmChoice_Basic_action_a(SmId smId, //!< The state machine id + FppTest_SmChoice_Basic::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmChoice_Basic + //! + //! Action b + void FppTest_SmChoice_Basic_action_b(SmId smId, //!< The state machine id + FppTest_SmChoice_Basic::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmInstanceChoice_Basic_Basic + //! + //! Guard g + bool FppTest_SmInstanceChoice_Basic_Basic_guard_g( + SmId smId, //!< The state machine id + FppTest_SmInstanceChoice_Basic_Basic::Signal signal //!< The signal + ) const override; + + //! Implementation for guard g of state machine FppTest_SmChoice_Basic + //! + //! Guard g + bool FppTest_SmChoice_Basic_guard_g(SmId smId, //!< The state machine id + FppTest_SmChoice_Basic::Signal signal //!< The signal + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the basic test with the true guard + void testBasicTrue(); + + //! Run the basic test with the false guard + void testBasicFalse(); + + //! Run the smChoiceBasic test with the true guard + void testSmChoiceBasicTrue(); + + //! Run the smChoiceSmChoiceBasic test with the false guard + void testSmChoiceBasicFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of basic + SmHarness::History m_basic_action_a_history; + + //! The history associated with action b of basic + SmHarness::History m_basic_action_b_history; + + //! The guard g of basic + SmHarness::NoArgGuard m_basic_guard_g; + + //! The history associated with action a of smChoiceBasic + SmHarness::History m_smChoiceBasic_action_a_history; + + //! The history associated with action b of smChoiceBasic + SmHarness::History m_smChoiceBasic_action_b_history; + + //! The guard g of smChoiceBasic + SmHarness::NoArgGuard m_smChoiceBasic_guard_g; +}; + +} // namespace SmInstanceChoice + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/choice/BasicU32.cpp b/FppTest/state_machine/internal_instance/choice/BasicU32.cpp new file mode 100644 index 0000000000..8af10ff47a --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/BasicU32.cpp @@ -0,0 +1,107 @@ +// ====================================================================== +// \title BasicU32.cpp +// \author bocchino +// \brief cpp file for BasicU32 component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/choice/BasicU32.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicU32 ::BasicU32(const char* const compName) + : BasicU32ComponentBase(compName), + m_smChoiceBasicU32_action_a_history(), + m_smChoiceBasicU32_action_b_history(), + m_smChoiceBasicU32_guard_g() {} + +BasicU32 ::~BasicU32() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicU32 ::FppTest_SmChoice_BasicU32_action_a(SmId smId, FppTest_SmChoice_BasicU32::Signal signal, U32 value) { + ASSERT_EQ(smId, SmId::smChoiceBasicU32); + this->m_smChoiceBasicU32_action_a_history.push(signal, value); +} + +void BasicU32 ::FppTest_SmChoice_BasicU32_action_b(SmId smId, FppTest_SmChoice_BasicU32::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceBasicU32); + this->m_smChoiceBasicU32_action_b_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicU32 ::FppTest_SmChoice_BasicU32_guard_g(SmId smId, + FppTest_SmChoice_BasicU32::Signal signal, + U32 value) const { + FW_ASSERT(smId == SmId::smChoiceBasicU32, static_cast(smId)); + return this->m_smChoiceBasicU32_guard_g.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicU32::testTrue() { + this->m_smChoiceBasicU32_action_a_history.clear(); + this->m_smChoiceBasicU32_action_b_history.clear(); + this->m_smChoiceBasicU32_guard_g.reset(); + this->m_smChoiceBasicU32_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceBasicU32_getState(), SmChoice_BasicU32::State::S1); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasicU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasicU32_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smChoiceBasicU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmChoice_BasicU32::Signal::s); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceBasicU32_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasicU32_action_a_history.getSignals().getItemAt(0), SmChoice_BasicU32::Signal::s); + ASSERT_EQ(this->m_smChoiceBasicU32_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceBasicU32_action_b_history.getSize(), 0); + ASSERT_EQ(this->smChoiceBasicU32_getState(), SmChoice_BasicU32::State::S2); +} + +void BasicU32::testFalse() { + this->m_smChoiceBasicU32_action_a_history.clear(); + this->m_smChoiceBasicU32_action_b_history.clear(); + this->m_smChoiceBasicU32_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceBasicU32_getState(), SmChoice_BasicU32::State::S1); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasicU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasicU32_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smChoiceBasicU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmChoice_BasicU32::Signal::s); + ASSERT_EQ(this->m_smChoiceBasicU32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceBasicU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceBasicU32_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceBasicU32_action_b_history.getItemAt(0), SmChoice_BasicU32::Signal::s); + ASSERT_EQ(this->smChoiceBasicU32_getState(), SmChoice_BasicU32::State::S3); +} + +} // namespace SmInstanceChoice + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/choice/BasicU32.fpp b/FppTest/state_machine/internal_instance/choice/BasicU32.fpp new file mode 100644 index 0000000000..f000fcf5d6 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/BasicU32.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceChoice { + + active component BasicU32 { + + state machine instance smChoiceBasicU32: SmChoice.BasicU32 priority 2 block + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/choice/BasicU32.hpp b/FppTest/state_machine/internal_instance/choice/BasicU32.hpp new file mode 100644 index 0000000000..5bbe72c1e8 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/BasicU32.hpp @@ -0,0 +1,115 @@ +// ====================================================================== +// \title BasicU32.hpp +// \author bocchino +// \brief hpp file for BasicU32 component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceChoice_BasicU32_HPP +#define FppTest_SmInstanceChoice_BasicU32_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/choice/BasicU32ComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +class BasicU32 : public BasicU32ComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmChoice_BasicU32 + using SmChoice_BasicU32 = FppTest_SmChoice_BasicU32; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicU32 object + BasicU32(const char* const compName //!< The component name + ); + + //! Destroy BasicU32 object + ~BasicU32(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmChoice_BasicU32 + //! + //! Action a + void FppTest_SmChoice_BasicU32_action_a(SmId smId, //!< The state machine id + FppTest_SmChoice_BasicU32::Signal signal, //!< The signal + U32 value //!< The value + ) override; + + //! Implementation for action b of state machine FppTest_SmChoice_BasicU32 + //! + //! Action b + void FppTest_SmChoice_BasicU32_action_b(SmId smId, //!< The state machine id + FppTest_SmChoice_BasicU32::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmChoice_BasicU32 + //! + //! Guard g + bool FppTest_SmChoice_BasicU32_guard_g(SmId smId, //!< The state machine id + FppTest_SmChoice_BasicU32::Signal signal, //!< The signal + U32 value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test with the true guard + void testTrue(); + + //! Run the test with the false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smChoiceBasicU32 + SmHarness::SignalValueHistory m_smChoiceBasicU32_action_a_history; + + //! The history associated with action b of smChoiceBasicU32 + SmHarness::History m_smChoiceBasicU32_action_b_history; + + //! The guard g of smChoiceBasicU32 + SmHarness::Guard m_smChoiceBasicU32_guard_g; +}; + +} // namespace SmInstanceChoice + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/choice/CMakeLists.txt b/FppTest/state_machine/internal_instance/choice/CMakeLists.txt new file mode 100644 index 0000000000..9db4fea92f --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/CMakeLists.txt @@ -0,0 +1,24 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToChoice.fpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToState.fpp" + "${CMAKE_CURRENT_LIST_DIR}/InputPairU16U32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Sequence.fpp" + "${CMAKE_CURRENT_LIST_DIR}/SequenceU32.fpp" +) +set(MOD_DEPS FppTest/state_machine/internal/harness) +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToChoice.cpp" + "${CMAKE_CURRENT_LIST_DIR}/ChoiceToState.cpp" + "${CMAKE_CURRENT_LIST_DIR}/InputPairU16U32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Sequence.cpp" + "${CMAKE_CURRENT_LIST_DIR}/SequenceU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/main.cpp" +) +set(UT_MOD_DEPS STest) +register_fprime_ut() diff --git a/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.cpp b/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.cpp new file mode 100644 index 0000000000..3d1c732a5f --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.cpp @@ -0,0 +1,195 @@ +// ====================================================================== +// \title ChoiceToChoice.cpp +// \author bocchino +// \brief cpp file for ChoiceToChoice component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/choice/ChoiceToChoice.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +ChoiceToChoice ::ChoiceToChoice(const char* const compName) + : ChoiceToChoiceComponentBase(compName), + m_smChoiceChoiceToChoice_actionHistory(), + m_smChoiceChoiceToChoice_guard_g1(), + m_smChoiceChoiceToChoice_guard_g2() {} + +ChoiceToChoice ::~ChoiceToChoice() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void ChoiceToChoice ::FppTest_SmChoice_ChoiceToChoice_action_exitS1(SmId smId, + FppTest_SmChoice_ChoiceToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceChoiceToChoice); + this->m_smChoiceChoiceToChoice_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void ChoiceToChoice ::FppTest_SmChoice_ChoiceToChoice_action_a(SmId smId, + FppTest_SmChoice_ChoiceToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceChoiceToChoice); + this->m_smChoiceChoiceToChoice_actionHistory.push(signal, ActionId::A); +} + +void ChoiceToChoice ::FppTest_SmChoice_ChoiceToChoice_action_enterS2(SmId smId, + FppTest_SmChoice_ChoiceToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceChoiceToChoice); + this->m_smChoiceChoiceToChoice_actionHistory.push(signal, ActionId::ENTER_S2); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool ChoiceToChoice ::FppTest_SmChoice_ChoiceToChoice_guard_g1(SmId smId, + FppTest_SmChoice_ChoiceToChoice::Signal signal) const { + FW_ASSERT(smId == SmId::smChoiceChoiceToChoice, static_cast(smId)); + return this->m_smChoiceChoiceToChoice_guard_g1.call(signal); +} + +bool ChoiceToChoice ::FppTest_SmChoice_ChoiceToChoice_guard_g2(SmId smId, + FppTest_SmChoice_ChoiceToChoice::Signal signal) const { + FW_ASSERT(smId == SmId::smChoiceChoiceToChoice, static_cast(smId)); + return this->m_smChoiceChoiceToChoice_guard_g2.call(signal); +} + +// ---------------------------------------------------------------------- +// Overflow hook implementations for internal state machines +// ---------------------------------------------------------------------- + +void ChoiceToChoice ::smChoiceChoiceToChoice_stateMachineOverflowHook(SmId smId, + FwEnumStoreType signal, + Fw::SerializeBufferBase& buffer) { + this->m_hookCalled = true; + ASSERT_EQ(smId, SmId::smChoiceChoiceToChoice); + ASSERT_EQ(static_cast(signal), SmChoice_ChoiceToChoice::Signal::s); + ASSERT_EQ(buffer.getBuffLeft(), 0); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void ChoiceToChoice::testG1True() { + this->m_smChoiceChoiceToChoice_actionHistory.clear(); + this->m_smChoiceChoiceToChoice_guard_g1.reset(); + this->m_smChoiceChoiceToChoice_guard_g2.reset(); + this->m_smChoiceChoiceToChoice_guard_g1.setReturnValue(true); + this->m_hookCalled = false; + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceChoiceToChoice_getState(), SmChoice_ChoiceToChoice::State::S1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_actionHistory.getSize(), 0); + this->smChoiceChoiceToChoice_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_FALSE(this->m_hookCalled); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getItemAt(0), + SmChoice_ChoiceToChoice::Signal::s); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g2.getCallHistory().getSize(), 0); + const FwIndexType expectedSize = 3; + ASSERT_EQ(this->m_smChoiceChoiceToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smChoiceChoiceToChoice_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmChoice_ChoiceToChoice::Signal::s); + } + const auto& values = this->m_smChoiceChoiceToChoice_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(this->smChoiceChoiceToChoice_getState(), SmChoice_ChoiceToChoice::State::S2_S3); +} + +void ChoiceToChoice::testG1FalseG2True() { + this->m_smChoiceChoiceToChoice_actionHistory.clear(); + this->m_smChoiceChoiceToChoice_guard_g1.reset(); + this->m_smChoiceChoiceToChoice_guard_g2.reset(); + this->m_smChoiceChoiceToChoice_guard_g2.setReturnValue(true); + this->m_hookCalled = false; + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceChoiceToChoice_getState(), SmChoice_ChoiceToChoice::State::S1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_actionHistory.getSize(), 0); + this->smChoiceChoiceToChoice_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_FALSE(this->m_hookCalled); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getItemAt(0), + SmChoice_ChoiceToChoice::Signal::s); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getItemAt(0), + SmChoice_ChoiceToChoice::Signal::s); + const FwIndexType expectedSize = 3; + ASSERT_EQ(this->m_smChoiceChoiceToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smChoiceChoiceToChoice_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmChoice_ChoiceToChoice::Signal::s); + } + const auto& values = this->m_smChoiceChoiceToChoice_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(this->smChoiceChoiceToChoice_getState(), SmChoice_ChoiceToChoice::State::S2_S3); +} + +void ChoiceToChoice::testG1FalseG2False() { + this->m_smChoiceChoiceToChoice_actionHistory.clear(); + this->m_smChoiceChoiceToChoice_guard_g1.reset(); + this->m_smChoiceChoiceToChoice_guard_g2.reset(); + this->m_hookCalled = false; + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceChoiceToChoice_getState(), SmChoice_ChoiceToChoice::State::S1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_actionHistory.getSize(), 0); + this->smChoiceChoiceToChoice_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_FALSE(this->m_hookCalled); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getItemAt(0), + SmChoice_ChoiceToChoice::Signal::s); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceChoiceToChoice_guard_g1.getCallHistory().getItemAt(0), + SmChoice_ChoiceToChoice::Signal::s); + const FwIndexType expectedSize = 3; + ASSERT_EQ(this->m_smChoiceChoiceToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smChoiceChoiceToChoice_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmChoice_ChoiceToChoice::Signal::s); + } + const auto& values = this->m_smChoiceChoiceToChoice_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(this->smChoiceChoiceToChoice_getState(), SmChoice_ChoiceToChoice::State::S2_S4); +} + +void ChoiceToChoice::testOverflow() { + this->m_hookCalled = false; + this->init(queueDepth, instanceId); + for (FwSizeType i = 0; i < queueDepth; i++) { + this->smChoiceChoiceToChoice_sendSignal_s(); + ASSERT_FALSE(this->m_hookCalled); + } + this->smChoiceChoiceToChoice_sendSignal_s(); + ASSERT_TRUE(this->m_hookCalled); +} + +} // namespace SmInstanceChoice + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.fpp b/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.fpp new file mode 100644 index 0000000000..23645ba86a --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceChoice { + + active component ChoiceToChoice { + + state machine instance smChoiceChoiceToChoice: SmChoice.ChoiceToChoice priority 4 hook + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.hpp b/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.hpp new file mode 100644 index 0000000000..1f692aa692 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/ChoiceToChoice.hpp @@ -0,0 +1,155 @@ +// ====================================================================== +// \title ChoiceToChoice.hpp +// \author bocchino +// \brief hpp file for ChoiceToChoice component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceChoice_ChoiceToChoice_HPP +#define FppTest_SmInstanceChoice_ChoiceToChoice_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/choice/ChoiceToChoiceComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +class ChoiceToChoice : public ChoiceToChoiceComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! Action IDs + enum class ActionId { + EXIT_S1, + A, + ENTER_S2, + }; + + //! The type FppTest_SmChoice_ChoiceToChoice + using SmChoice_ChoiceToChoice = FppTest_SmChoice_ChoiceToChoice; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct ChoiceToChoice object + ChoiceToChoice(const char* const compName //!< The component name + ); + + //! Destroy ChoiceToChoice object + ~ChoiceToChoice(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action exitS1 of state machine FppTest_SmChoice_ChoiceToChoice + //! + //! Exit S1 + void FppTest_SmChoice_ChoiceToChoice_action_exitS1(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmChoice_ChoiceToChoice + //! + //! Action a + void FppTest_SmChoice_ChoiceToChoice_action_a(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS2 of state machine FppTest_SmChoice_ChoiceToChoice + //! + //! Enter S2 + void FppTest_SmChoice_ChoiceToChoice_action_enterS2(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToChoice::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g1 of state machine FppTest_SmChoice_ChoiceToChoice + //! + //! Guard g1 + bool FppTest_SmChoice_ChoiceToChoice_guard_g1(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToChoice::Signal signal //!< The signal + ) const override; + + //! Implementation for guard g2 of state machine FppTest_SmChoice_ChoiceToChoice + //! + //! Guard g2 + bool FppTest_SmChoice_ChoiceToChoice_guard_g2(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToChoice::Signal signal //!< The signal + ) const override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Overflow hook implementations for internal state machines + // ---------------------------------------------------------------------- + + //! Overflow hook implementation for smChoiceChoiceToChoice + void smChoiceChoiceToChoice_stateMachineOverflowHook(SmId smId, //!< The state machine ID + FwEnumStoreType signal, //!< The signal + Fw::SerializeBufferBase& buffer //!< The message buffer + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test with g1 true + void testG1True(); + + //! Run the test with g1 false and g2 true + void testG1FalseG2True(); + + //! Run the test with g1 false and g2 false + void testG1FalseG2False(); + + //! Test with queue overflow + void testOverflow(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! Whether the overflow hook was called + bool m_hookCalled = false; + + //! The action history for smChoiceChoiceToChoice + SmHarness::SignalValueHistory + m_smChoiceChoiceToChoice_actionHistory; + + //! The guard g1 for smChoiceChoiceToChoice + SmHarness::NoArgGuard m_smChoiceChoiceToChoice_guard_g1; + + //! The guard g2 for smChoiceChoiceToChoice + SmHarness::NoArgGuard m_smChoiceChoiceToChoice_guard_g2; +}; + +} // namespace SmInstanceChoice + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/choice/ChoiceToState.cpp b/FppTest/state_machine/internal_instance/choice/ChoiceToState.cpp new file mode 100644 index 0000000000..79f0b1286f --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/ChoiceToState.cpp @@ -0,0 +1,124 @@ +// ====================================================================== +// \title ChoiceToState.cpp +// \author bocchino +// \brief cpp file for ChoiceToState component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/choice/ChoiceToState.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +ChoiceToState::ChoiceToState(const char* const compName) + : ChoiceToStateComponentBase(compName), + m_smChoiceChoiceToState_actionHistory(), + m_smChoiceChoiceToState_guard_g() {} + +ChoiceToState::~ChoiceToState() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void ChoiceToState::FppTest_SmChoice_ChoiceToState_action_exitS1(SmId smId, + FppTest_SmChoice_ChoiceToState::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceChoiceToState); + this->m_smChoiceChoiceToState_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void ChoiceToState::FppTest_SmChoice_ChoiceToState_action_a(SmId smId, FppTest_SmChoice_ChoiceToState::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceChoiceToState); + this->m_smChoiceChoiceToState_actionHistory.push(signal, ActionId::A); +} + +void ChoiceToState::FppTest_SmChoice_ChoiceToState_action_enterS2(SmId smId, + FppTest_SmChoice_ChoiceToState::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceChoiceToState); + this->m_smChoiceChoiceToState_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void ChoiceToState::FppTest_SmChoice_ChoiceToState_action_enterS3(SmId smId, + FppTest_SmChoice_ChoiceToState::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceChoiceToState); + this->m_smChoiceChoiceToState_actionHistory.push(signal, ActionId::ENTER_S3); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool ChoiceToState::FppTest_SmChoice_ChoiceToState_guard_g(SmId smId, + FppTest_SmChoice_ChoiceToState::Signal signal) const { + FW_ASSERT(smId == SmId::smChoiceChoiceToState, static_cast(smId)); + return this->m_smChoiceChoiceToState_guard_g.call(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void ChoiceToState::testTrue() { + this->m_smChoiceChoiceToState_actionHistory.clear(); + this->m_smChoiceChoiceToState_guard_g.reset(); + this->m_smChoiceChoiceToState_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceChoiceToState_getState(), SmChoice_ChoiceToState::State::S1); + ASSERT_EQ(this->m_smChoiceChoiceToState_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToState_actionHistory.getSize(), 0); + this->smChoiceChoiceToState_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceChoiceToState_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceChoiceToState_guard_g.getCallHistory().getItemAt(0), SmChoice_ChoiceToState::Signal::s); + const FwIndexType expectedSize = 5; + ASSERT_EQ(this->m_smChoiceChoiceToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smChoiceChoiceToState_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmChoice_ChoiceToState::Signal::s); + } + const auto& values = this->m_smChoiceChoiceToState_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(values.getItemAt(3), ActionId::A); + ASSERT_EQ(values.getItemAt(4), ActionId::ENTER_S3); + ASSERT_EQ(this->smChoiceChoiceToState_getState(), SmChoice_ChoiceToState::State::S2_S3); +} + +void ChoiceToState::testFalse() { + this->m_smChoiceChoiceToState_actionHistory.clear(); + this->m_smChoiceChoiceToState_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceChoiceToState_getState(), SmChoice_ChoiceToState::State::S1); + ASSERT_EQ(this->m_smChoiceChoiceToState_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceChoiceToState_actionHistory.getSize(), 0); + this->smChoiceChoiceToState_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceChoiceToState_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceChoiceToState_guard_g.getCallHistory().getItemAt(0), SmChoice_ChoiceToState::Signal::s); + const FwIndexType expectedSize = 4; + ASSERT_EQ(this->m_smChoiceChoiceToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smChoiceChoiceToState_actionHistory.getSignals(); + for (FwIndexType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmChoice_ChoiceToState::Signal::s); + } + const auto& values = this->m_smChoiceChoiceToState_actionHistory.getValues(); + ASSERT_EQ(values.getItemAt(0), ActionId::EXIT_S1); + ASSERT_EQ(values.getItemAt(1), ActionId::A); + ASSERT_EQ(values.getItemAt(2), ActionId::ENTER_S2); + ASSERT_EQ(values.getItemAt(3), ActionId::ENTER_S3); + ASSERT_EQ(this->smChoiceChoiceToState_getState(), SmChoice_ChoiceToState::State::S2_S3); +} + +} // namespace SmInstanceChoice + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/choice/ChoiceToState.fpp b/FppTest/state_machine/internal_instance/choice/ChoiceToState.fpp new file mode 100644 index 0000000000..2c8137e6e5 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/ChoiceToState.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceChoice { + + active component ChoiceToState { + + state machine instance smChoiceChoiceToState: SmChoice.ChoiceToState + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/choice/ChoiceToState.hpp b/FppTest/state_machine/internal_instance/choice/ChoiceToState.hpp new file mode 100644 index 0000000000..520b6abc23 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/ChoiceToState.hpp @@ -0,0 +1,133 @@ +// ====================================================================== +// \title ChoiceToState.hpp +// \author bocchino +// \brief hpp file for ChoiceToState component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceChoice_ChoiceToState_HPP +#define FppTest_SmInstanceChoice_ChoiceToState_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/choice/ChoiceToStateComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +class ChoiceToState : public ChoiceToStateComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! Action IDs + enum class ActionId { + EXIT_S1, + A, + ENTER_S2, + ENTER_S3, + }; + + //! The type FppTest_SmChoice_ChoiceToState + using SmChoice_ChoiceToState = FppTest_SmChoice_ChoiceToState; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct ChoiceToState object + ChoiceToState(const char* const compName //!< The component name + ); + + //! Destroy ChoiceToState object + ~ChoiceToState(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action exitS1 of state machine FppTest_SmChoice_ChoiceToState + //! + //! Exit S1 + void FppTest_SmChoice_ChoiceToState_action_exitS1(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToState::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmChoice_ChoiceToState + //! + //! Action a + void FppTest_SmChoice_ChoiceToState_action_a(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToState::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS2 of state machine FppTest_SmChoice_ChoiceToState + //! + //! Enter S2 + void FppTest_SmChoice_ChoiceToState_action_enterS2(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToState::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS3 of state machine FppTest_SmChoice_ChoiceToState + //! + //! Enter S3 + void FppTest_SmChoice_ChoiceToState_action_enterS3(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToState::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmChoice_ChoiceToState + //! + //! Guard g + bool FppTest_SmChoice_ChoiceToState_guard_g(SmId smId, //!< The state machine id + FppTest_SmChoice_ChoiceToState::Signal signal //!< The signal + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test with the true guard + void testTrue(); + + //! Run the test with the false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The action history for smChoiceChoiceToState + SmHarness::SignalValueHistory + m_smChoiceChoiceToState_actionHistory; + + //! The guard g for smChoiceChoiceToState + SmHarness::NoArgGuard m_smChoiceChoiceToState_guard_g; +}; + +} // namespace SmInstanceChoice + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/choice/InputPairU16U32.cpp b/FppTest/state_machine/internal_instance/choice/InputPairU16U32.cpp new file mode 100644 index 0000000000..a45b07eb3f --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/InputPairU16U32.cpp @@ -0,0 +1,144 @@ +// ====================================================================== +// \title InputPairU16U32.cpp +// \author bocchino +// \brief cpp file for InputPairU16U32 component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/choice/InputPairU16U32.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +InputPairU16U32 ::InputPairU16U32(const char* const compName) + : InputPairU16U32ComponentBase(compName), + m_smChoiceInputPairU16U32_action_a_history(), + m_smChoiceInputPairU16U32_guard_g() {} + +InputPairU16U32 ::~InputPairU16U32() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void InputPairU16U32 ::FppTest_SmChoice_InputPairU16U32_action_a(SmId smId, + FppTest_SmChoice_InputPairU16U32::Signal signal, + U32 value) { + ASSERT_EQ(smId, SmId::smChoiceInputPairU16U32); + this->m_smChoiceInputPairU16U32_action_a_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool InputPairU16U32 ::FppTest_SmChoice_InputPairU16U32_guard_g(SmId smId, + FppTest_SmChoice_InputPairU16U32::Signal signal, + U32 value) const { + FW_ASSERT(smId == SmId::smChoiceInputPairU16U32, static_cast(smId)); + return this->m_smChoiceInputPairU16U32_guard_g.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void InputPairU16U32::testS1True() { + this->m_smChoiceInputPairU16U32_action_a_history.clear(); + this->m_smChoiceInputPairU16U32_guard_g.reset(); + this->m_smChoiceInputPairU16U32_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 0); + const U16 value = static_cast(STest::Pick::any()); + this->smChoiceInputPairU16U32_sendSignal_s1(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S2); +} + +void InputPairU16U32::testS1False() { + this->m_smChoiceInputPairU16U32_action_a_history.clear(); + this->m_smChoiceInputPairU16U32_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 0); + const U16 value = static_cast(STest::Pick::any()); + this->smChoiceInputPairU16U32_sendSignal_s1(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S3); +} + +void InputPairU16U32::testS2True() { + this->m_smChoiceInputPairU16U32_action_a_history.clear(); + this->m_smChoiceInputPairU16U32_guard_g.reset(); + this->m_smChoiceInputPairU16U32_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smChoiceInputPairU16U32_sendSignal_s2(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s2); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s2); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S2); +} + +void InputPairU16U32::testS2False() { + this->m_smChoiceInputPairU16U32_action_a_history.clear(); + this->m_smChoiceInputPairU16U32_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smChoiceInputPairU16U32_sendSignal_s2(value); + const auto status = this->doDispatch(); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s2); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getSignals().getItemAt(0), + SmChoice_InputPairU16U32::Signal::s2); + ASSERT_EQ(this->m_smChoiceInputPairU16U32_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->smChoiceInputPairU16U32_getState(), SmChoice_InputPairU16U32::State::S3); +} + +} // namespace SmInstanceChoice + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/choice/InputPairU16U32.fpp b/FppTest/state_machine/internal_instance/choice/InputPairU16U32.fpp new file mode 100644 index 0000000000..c082549d57 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/InputPairU16U32.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceChoice { + + active component InputPairU16U32 { + + state machine instance smChoiceInputPairU16U32: SmChoice.InputPairU16U32 priority 3 drop + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/choice/InputPairU16U32.hpp b/FppTest/state_machine/internal_instance/choice/InputPairU16U32.hpp new file mode 100644 index 0000000000..b3dcb89ac9 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/InputPairU16U32.hpp @@ -0,0 +1,112 @@ +// ====================================================================== +// \title InputPairU16U32.hpp +// \author bocchino +// \brief hpp file for InputPairU16U32 component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceChoice_InputPairU16U32_HPP +#define FppTest_SmInstanceChoice_InputPairU16U32_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/choice/InputPairU16U32ComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +class InputPairU16U32 : public InputPairU16U32ComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmChoice_InputPairU16U32 + using SmChoice_InputPairU16U32 = FppTest_SmChoice_InputPairU16U32; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct InputPairU16U32 object + InputPairU16U32(const char* const compName //!< The component name + ); + + //! Destroy InputPairU16U32 object + ~InputPairU16U32(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmChoice_InputPairU16U32 + //! + //! Action a + void FppTest_SmChoice_InputPairU16U32_action_a(SmId smId, //!< The state machine id + FppTest_SmChoice_InputPairU16U32::Signal signal, //!< The signal + U32 value //!< The value + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmChoice_InputPairU16U32 + //! + //! Guard g + bool FppTest_SmChoice_InputPairU16U32_guard_g(SmId smId, //!< The state machine id + FppTest_SmChoice_InputPairU16U32::Signal signal, //!< The signal + U32 value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test with signal s1 and true guard + void testS1True(); + + //! Run the test with signal s1 and false guard + void testS1False(); + + //! Run the test with signal s2 and true guard + void testS2True(); + + //! Run the test with signal s2 and false guard + void testS2False(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smChoiceInputPairU16U32 + SmHarness::SignalValueHistory + m_smChoiceInputPairU16U32_action_a_history; + + //! The guard g of smChoiceInputPairU16U32 + SmHarness::Guard m_smChoiceInputPairU16U32_guard_g; +}; + +} // namespace SmInstanceChoice + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/choice/Sequence.cpp b/FppTest/state_machine/internal_instance/choice/Sequence.cpp new file mode 100644 index 0000000000..457f22f924 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/Sequence.cpp @@ -0,0 +1,134 @@ +// ====================================================================== +// \title Sequence.cpp +// \author bocchino +// \brief cpp file for Sequence component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/choice/Sequence.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Sequence ::Sequence(const char* const compName) + : SequenceComponentBase(compName), + m_smChoiceSequence_action_a_history(), + m_smChoiceSequence_action_b_history(), + m_smChoiceSequence_guard_g1(), + m_smChoiceSequence_guard_g2() {} + +Sequence ::~Sequence() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Sequence ::FppTest_SmChoice_Sequence_action_a(SmId smId, FppTest_SmChoice_Sequence::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceSequence); + this->m_smChoiceSequence_action_a_history.push(signal); +} + +void Sequence ::FppTest_SmChoice_Sequence_action_b(SmId smId, FppTest_SmChoice_Sequence::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceSequence); + this->m_smChoiceSequence_action_b_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool Sequence ::FppTest_SmChoice_Sequence_guard_g1(SmId smId, FppTest_SmChoice_Sequence::Signal signal) const { + FW_ASSERT(smId == SmId::smChoiceSequence, static_cast(smId)); + return this->m_smChoiceSequence_guard_g1.call(signal); +} + +bool Sequence ::FppTest_SmChoice_Sequence_guard_g2(SmId smId, FppTest_SmChoice_Sequence::Signal signal) const { + FW_ASSERT(smId == SmId::smChoiceSequence, static_cast(smId)); + return this->m_smChoiceSequence_guard_g2.call(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Sequence::testG1True() { + this->m_smChoiceSequence_action_a_history.clear(); + this->m_smChoiceSequence_action_b_history.clear(); + this->m_smChoiceSequence_guard_g1.reset(); + this->m_smChoiceSequence_guard_g1.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceSequence_getState(), SmChoice_Sequence::State::S1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_b_history.getSize(), 0); + this->smChoiceSequence_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getItemAt(0), SmChoice_Sequence::Signal::s); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_b_history.getSize(), 0); + ASSERT_EQ(this->smChoiceSequence_getState(), SmChoice_Sequence::State::S2); +} + +void Sequence::testG1FalseG2True() { + this->m_smChoiceSequence_action_a_history.clear(); + this->m_smChoiceSequence_action_b_history.clear(); + this->m_smChoiceSequence_guard_g1.reset(); + this->m_smChoiceSequence_guard_g2.reset(); + this->m_smChoiceSequence_guard_g2.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceSequence_getState(), SmChoice_Sequence::State::S1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_b_history.getSize(), 0); + this->smChoiceSequence_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getItemAt(0), SmChoice_Sequence::Signal::s); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getItemAt(0), SmChoice_Sequence::Signal::s); + ASSERT_EQ(this->m_smChoiceSequence_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequence_action_a_history.getItemAt(0), SmChoice_Sequence::Signal::s); + ASSERT_EQ(this->m_smChoiceSequence_action_b_history.getSize(), 0); + ASSERT_EQ(this->smChoiceSequence_getState(), SmChoice_Sequence::State::S3); +} + +void Sequence::testG1FalseG2False() { + this->m_smChoiceSequence_action_a_history.clear(); + this->m_smChoiceSequence_action_b_history.clear(); + this->m_smChoiceSequence_guard_g1.reset(); + this->m_smChoiceSequence_guard_g2.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceSequence_getState(), SmChoice_Sequence::State::S1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_b_history.getSize(), 0); + this->smChoiceSequence_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g1.getCallHistory().getItemAt(0), SmChoice_Sequence::Signal::s); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequence_guard_g2.getCallHistory().getItemAt(0), SmChoice_Sequence::Signal::s); + ASSERT_EQ(this->m_smChoiceSequence_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequence_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequence_action_b_history.getItemAt(0), SmChoice_Sequence::Signal::s); + ASSERT_EQ(this->smChoiceSequence_getState(), SmChoice_Sequence::State::S4); +} + +} // namespace SmInstanceChoice + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/choice/Sequence.fpp b/FppTest/state_machine/internal_instance/choice/Sequence.fpp new file mode 100644 index 0000000000..79d6aa0a97 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/Sequence.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceChoice { + + active component Sequence { + + state machine instance smChoiceSequence: SmChoice.Sequence + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/choice/Sequence.hpp b/FppTest/state_machine/internal_instance/choice/Sequence.hpp new file mode 100644 index 0000000000..ca09e3f249 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/Sequence.hpp @@ -0,0 +1,126 @@ +// ====================================================================== +// \title Sequence.hpp +// \author bocchino +// \brief hpp file for Sequence component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceChoice_Sequence_HPP +#define FppTest_SmInstanceChoice_Sequence_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/choice/SequenceComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +class Sequence : public SequenceComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmChoice_Sequence + using SmChoice_Sequence = FppTest_SmChoice_Sequence; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Sequence object + Sequence(const char* const compName //!< The component name + ); + + //! Destroy Sequence object + ~Sequence(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmChoice_Sequence + //! + //! Action a + void FppTest_SmChoice_Sequence_action_a(SmId smId, //!< The state machine id + FppTest_SmChoice_Sequence::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmChoice_Sequence + //! + //! Action b + void FppTest_SmChoice_Sequence_action_b(SmId smId, //!< The state machine id + FppTest_SmChoice_Sequence::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g1 of state machine FppTest_SmChoice_Sequence + //! + //! Guard g1 + bool FppTest_SmChoice_Sequence_guard_g1(SmId smId, //!< The state machine id + FppTest_SmChoice_Sequence::Signal signal //!< The signal + ) const override; + + //! Implementation for guard g2 of state machine FppTest_SmChoice_Sequence + //! + //! Guard g2 + bool FppTest_SmChoice_Sequence_guard_g2(SmId smId, //!< The state machine id + FppTest_SmChoice_Sequence::Signal signal //!< The signal + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test with g1 true + void testG1True(); + + //! Run the test with g1 true and g2 true + void testG1FalseG2True(); + + //! Run the test with g1 true and g2 false + void testG1FalseG2False(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smChoiceSequence + SmHarness::History m_smChoiceSequence_action_a_history; + + //! The history associated with action b of smChoiceSequence + SmHarness::History m_smChoiceSequence_action_b_history; + + //! The guard g1 of smChoiceSequence + SmHarness::NoArgGuard m_smChoiceSequence_guard_g1; + + //! The guard g2 of smChoiceSequence + SmHarness::NoArgGuard m_smChoiceSequence_guard_g2; +}; + +} // namespace SmInstanceChoice + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/choice/SequenceU32.cpp b/FppTest/state_machine/internal_instance/choice/SequenceU32.cpp new file mode 100644 index 0000000000..0151436d3d --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/SequenceU32.cpp @@ -0,0 +1,144 @@ +// ====================================================================== +// \title SequenceU32.cpp +// \author bocchino +// \brief cpp file for SequenceU32 component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/choice/SequenceU32.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +SequenceU32::SequenceU32(const char* const compName) + : SequenceU32ComponentBase(compName), + m_smChoiceSequenceU32_action_a_history(), + m_smChoiceSequenceU32_action_b_history(), + m_smChoiceSequenceU32_guard_g1(), + m_smChoiceSequenceU32_guard_g2() {} + +SequenceU32::~SequenceU32() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void SequenceU32::FppTest_SmChoice_SequenceU32_action_a(SmId smId, + FppTest_SmChoice_SequenceU32::Signal signal, + U32 value) { + ASSERT_EQ(smId, SmId::smChoiceSequenceU32); + this->m_smChoiceSequenceU32_action_a_history.push(signal, value); +} + +void SequenceU32::FppTest_SmChoice_SequenceU32_action_b(SmId smId, FppTest_SmChoice_SequenceU32::Signal signal) { + ASSERT_EQ(smId, SmId::smChoiceSequenceU32); + this->m_smChoiceSequenceU32_action_b_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool SequenceU32::FppTest_SmChoice_SequenceU32_guard_g1(SmId smId, FppTest_SmChoice_SequenceU32::Signal signal) const { + FW_ASSERT(smId == SmId::smChoiceSequenceU32, static_cast(smId)); + return this->m_smChoiceSequenceU32_guard_g1.call(signal); +} + +bool SequenceU32::FppTest_SmChoice_SequenceU32_guard_g2(SmId smId, + FppTest_SmChoice_SequenceU32::Signal signal, + U32 value) const { + FW_ASSERT(smId == SmId::smChoiceSequenceU32, static_cast(smId)); + return this->m_smChoiceSequenceU32_guard_g2.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void SequenceU32::testG1True() { + this->m_smChoiceSequenceU32_action_a_history.clear(); + this->m_smChoiceSequenceU32_action_b_history.clear(); + this->m_smChoiceSequenceU32_guard_g1.reset(); + this->m_smChoiceSequenceU32_guard_g1.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceSequenceU32_getState(), SmChoice_SequenceU32::State::S1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smChoiceSequenceU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getItemAt(0), SmChoice_SequenceU32::Signal::s); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_b_history.getSize(), 0); + ASSERT_EQ(this->smChoiceSequenceU32_getState(), SmChoice_SequenceU32::State::S2); +} + +void SequenceU32::testG1FalseG2True() { + this->m_smChoiceSequenceU32_action_a_history.clear(); + this->m_smChoiceSequenceU32_action_b_history.clear(); + this->m_smChoiceSequenceU32_guard_g1.reset(); + this->m_smChoiceSequenceU32_guard_g2.reset(); + this->m_smChoiceSequenceU32_guard_g2.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceSequenceU32_getState(), SmChoice_SequenceU32::State::S1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smChoiceSequenceU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getItemAt(0), SmChoice_SequenceU32::Signal::s); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSignals().getItemAt(0), + SmChoice_SequenceU32::Signal::s); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getSignals().getItemAt(0), SmChoice_SequenceU32::Signal::s); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_b_history.getSize(), 0); + ASSERT_EQ(this->smChoiceSequenceU32_getState(), SmChoice_SequenceU32::State::S3); +} + +void SequenceU32::testG1FalseG2False() { + this->m_smChoiceSequenceU32_action_a_history.clear(); + this->m_smChoiceSequenceU32_action_b_history.clear(); + this->m_smChoiceSequenceU32_guard_g1.reset(); + this->m_smChoiceSequenceU32_guard_g2.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smChoiceSequenceU32_getState(), SmChoice_SequenceU32::State::S1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_b_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smChoiceSequenceU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g1.getCallHistory().getItemAt(0), SmChoice_SequenceU32::Signal::s); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getSignals().getItemAt(0), + SmChoice_SequenceU32::Signal::s); + ASSERT_EQ(this->m_smChoiceSequenceU32_guard_g2.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smChoiceSequenceU32_action_b_history.getItemAt(0), SmChoice_SequenceU32::Signal::s); + ASSERT_EQ(this->smChoiceSequenceU32_getState(), SmChoice_SequenceU32::State::S4); +} + +} // namespace SmInstanceChoice + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/choice/SequenceU32.fpp b/FppTest/state_machine/internal_instance/choice/SequenceU32.fpp new file mode 100644 index 0000000000..9a948983e3 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/SequenceU32.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceChoice { + + active component SequenceU32 { + + state machine instance smChoiceSequenceU32: SmChoice.SequenceU32 + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/choice/SequenceU32.hpp b/FppTest/state_machine/internal_instance/choice/SequenceU32.hpp new file mode 100644 index 0000000000..46c6d0d744 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/SequenceU32.hpp @@ -0,0 +1,129 @@ +// ====================================================================== +// \title SequenceU32.hpp +// \author bocchino +// \brief hpp file for SequenceU32 component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceChoice_SequenceU32_HPP +#define FppTest_SmInstanceChoice_SequenceU32_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/choice/SequenceU32ComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceChoice { + +class SequenceU32 : public SequenceU32ComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmChoice_SequenceU32 + using SmChoice_SequenceU32 = FppTest_SmChoice_SequenceU32; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct SequenceU32 object + SequenceU32(const char* const compName //!< The component name + ); + + //! Destroy SequenceU32 object + ~SequenceU32(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmChoice_SequenceU32 + //! + //! Action a + void FppTest_SmChoice_SequenceU32_action_a(SmId smId, //!< The state machine id + FppTest_SmChoice_SequenceU32::Signal signal, //!< The signal + U32 value //!< The value + ) override; + + //! Implementation for action b of state machine FppTest_SmChoice_SequenceU32 + //! + //! Action b + void FppTest_SmChoice_SequenceU32_action_b(SmId smId, //!< The state machine id + FppTest_SmChoice_SequenceU32::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g1 of state machine FppTest_SmChoice_SequenceU32 + //! + //! Guard g1 + bool FppTest_SmChoice_SequenceU32_guard_g1(SmId smId, //!< The state machine id + FppTest_SmChoice_SequenceU32::Signal signal //!< The signal + ) const override; + + //! Implementation for guard g2 of state machine FppTest_SmChoice_SequenceU32 + //! + //! Guard g2 + bool FppTest_SmChoice_SequenceU32_guard_g2(SmId smId, //!< The state machine id + FppTest_SmChoice_SequenceU32::Signal signal, //!< The signal + U32 value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test with g1 true + void testG1True(); + + //! Run the test with g1 true and g2 true + void testG1FalseG2True(); + + //! Run the test with g1 true and g2 false + void testG1FalseG2False(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smChoiceSequenceU32 + SmHarness::SignalValueHistory + m_smChoiceSequenceU32_action_a_history; + + //! The history associated with action b of smChoiceSequenceU32 + SmHarness::History m_smChoiceSequenceU32_action_b_history; + + //! The guard g1 of smChoiceSequenceU32 + SmHarness::NoArgGuard m_smChoiceSequenceU32_guard_g1; + + //! The guard g2 of smChoiceSequenceU32 + SmHarness::Guard m_smChoiceSequenceU32_guard_g2; +}; + +} // namespace SmInstanceChoice + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/choice/main.cpp b/FppTest/state_machine/internal_instance/choice/main.cpp new file mode 100644 index 0000000000..9957dd0771 --- /dev/null +++ b/FppTest/state_machine/internal_instance/choice/main.cpp @@ -0,0 +1,134 @@ +// ---------------------------------------------------------------------- +// main.cpp +// ---------------------------------------------------------------------- + +#include + +#include "FppTest/state_machine/internal_instance/choice/Basic.hpp" +#include "FppTest/state_machine/internal_instance/choice/BasicU32.hpp" +#include "FppTest/state_machine/internal_instance/choice/ChoiceToChoice.hpp" +#include "FppTest/state_machine/internal_instance/choice/ChoiceToState.hpp" +#include "FppTest/state_machine/internal_instance/choice/InputPairU16U32.hpp" +#include "FppTest/state_machine/internal_instance/choice/Sequence.hpp" +#include "FppTest/state_machine/internal_instance/choice/SequenceU32.hpp" +#include "STest/STest/Random/Random.hpp" + +TEST(Basic, BasicTrue) { + FppTest::SmInstanceChoice::Basic basic("basic"); + basic.testBasicTrue(); +} + +TEST(Basic, BasicFalse) { + FppTest::SmInstanceChoice::Basic basic("basic"); + basic.testBasicFalse(); +} + +TEST(Basic, SmChoiceBasicTrue) { + FppTest::SmInstanceChoice::Basic basic("basic"); + basic.testSmChoiceBasicTrue(); +} + +TEST(Basic, SmChoiceBasicFalse) { + FppTest::SmInstanceChoice::Basic basic("basic"); + basic.testSmChoiceBasicFalse(); +} + +TEST(BasicU32, True) { + FppTest::SmInstanceChoice::BasicU32 basicU32("basicU32"); + basicU32.testTrue(); +} + +TEST(BasicU32, False) { + FppTest::SmInstanceChoice::BasicU32 basicU32("basicU32"); + basicU32.testFalse(); +} + +TEST(InputPairU16U32, S1True) { + FppTest::SmInstanceChoice::InputPairU16U32 inputPair("inputPair"); + inputPair.testS1True(); +} + +TEST(InputPairU16U32, S1False) { + FppTest::SmInstanceChoice::InputPairU16U32 inputPair("inputPair"); + inputPair.testS1False(); +} + +TEST(InputPairU16U32, S2True) { + FppTest::SmInstanceChoice::InputPairU16U32 inputPair("inputPair"); + inputPair.testS2True(); +} + +TEST(InputPairU16U32, S2False) { + FppTest::SmInstanceChoice::InputPairU16U32 inputPair("inputPair"); + inputPair.testS2False(); +} + +TEST(ChoiceToChoice, G1True) { + FppTest::SmInstanceChoice::ChoiceToChoice choiceToChoice("choiceToChoice"); + choiceToChoice.testG1True(); +} + +TEST(ChoiceToChoice, G1FalseG2True) { + FppTest::SmInstanceChoice::ChoiceToChoice choiceToChoice("choiceToChoice"); + choiceToChoice.testG1FalseG2True(); +} + +TEST(ChoiceToChoice, G1FalseG2False) { + FppTest::SmInstanceChoice::ChoiceToChoice choiceToChoice("choiceToChoice"); + choiceToChoice.testG1FalseG2False(); +} + +TEST(ChoiceToChoice, Overflow) { + FppTest::SmInstanceChoice::ChoiceToChoice choiceToChoice("choiceToChoice"); + choiceToChoice.testOverflow(); +} + +TEST(ChoiceToState, True) { + FppTest::SmInstanceChoice::ChoiceToState choiceToState("choiceToState"); + choiceToState.testTrue(); +} + +TEST(ChoiceToState, False) { + FppTest::SmInstanceChoice::ChoiceToState choiceToState("choiceToState"); + choiceToState.testFalse(); +} + +TEST(Sequence, G1True) { + FppTest::SmInstanceChoice::Sequence sequence("sequence"); + sequence.testG1True(); +} + +TEST(Sequence, G1FalseG2True) { + FppTest::SmInstanceChoice::Sequence sequence("sequence"); + sequence.testG1FalseG2True(); +} + +TEST(Sequence, G1FalseG2False) { + FppTest::SmInstanceChoice::Sequence sequence("sequence"); + sequence.testG1FalseG2False(); +} + +TEST(SequenceU32, G1True) { + FppTest::SmInstanceChoice::SequenceU32 sequenceU32("sequenceU32"); + sequenceU32.testG1True(); +} + +TEST(SequenceU32, G1FalseG2True) { + FppTest::SmInstanceChoice::SequenceU32 sequenceU32("sequenceU32"); + sequenceU32.testG1FalseG2True(); +} + +TEST(SequenceU32, G1FalseG2False) { + FppTest::SmInstanceChoice::SequenceU32 sequenceU32("sequenceU32"); + sequenceU32.testG1FalseG2False(); +} + +// ---------------------------------------------------------------------- +// Main function +// ---------------------------------------------------------------------- + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + STest::Random::seed(); + return RUN_ALL_TESTS(); +} diff --git a/FppTest/state_machine/internal_instance/initial/Basic.cpp b/FppTest/state_machine/internal_instance/initial/Basic.cpp new file mode 100644 index 0000000000..f866969cba --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Basic.cpp @@ -0,0 +1,84 @@ +// ====================================================================== +// \title Basic.cpp +// \author bocchino +// \brief cpp file for Basic component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/initial/Basic.hpp" + +namespace FppTest { + +namespace SmInstanceInitial { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Basic::Basic(const char* const compName) + : BasicComponentBase(compName), m_basic1_action_a_history(), m_smInitialBasic1_action_a_history() {} + +Basic::~Basic() {} + +// ---------------------------------------------------------------------- +// Handler implementations for typed input ports +// ---------------------------------------------------------------------- + +void Basic::schedIn_handler(FwIndexType portNum, U32 context) { + // Nothing to do +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Basic::FppTest_SmInitial_Basic_action_a(SmId smId, FppTest_SmInitial_Basic::Signal signal) { + ASSERT_TRUE((smId == SmId::smInitialBasic1) || (smId == SmId::smInitialBasic2)); + if (smId == SmId::smInitialBasic1) { + this->m_smInitialBasic1_action_a_history.push(signal); + } else { + this->m_smInitialBasic2_action_a_history.push(signal); + } +} + +void Basic::FppTest_SmInstanceInitial_Basic_Basic_action_a(SmId smId, + FppTest_SmInstanceInitial_Basic_Basic::Signal signal) { + ASSERT_TRUE((smId == SmId::basic1) || (smId == SmId::basic2)); + if (smId == SmId::basic1) { + this->m_basic1_action_a_history.push(signal); + } else { + this->m_basic2_action_a_history.push(signal); + } +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Basic::test() { + this->m_basic1_action_a_history.clear(); + this->m_smInitialBasic1_action_a_history.clear(); + ASSERT_EQ(this->basic1_getState(), Basic_Basic::State::__FPRIME_AC_UNINITIALIZED); + ASSERT_EQ(this->smInitialBasic1_getState(), SmInitial_Basic::State::__FPRIME_AC_UNINITIALIZED); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->basic1_getState(), Basic_Basic::State::S); + ASSERT_EQ(this->smInitialBasic1_getState(), SmInitial_Basic::State::S); + const FwSizeType expectedSize = 3; + ASSERT_EQ(this->m_basic1_action_a_history.getSize(), expectedSize); + ASSERT_EQ(this->m_basic2_action_a_history.getSize(), expectedSize); + ASSERT_EQ(this->m_smInitialBasic1_action_a_history.getSize(), expectedSize); + ASSERT_EQ(this->m_smInitialBasic2_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_basic1_action_a_history.getItemAt(i), Basic_Basic::Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(this->m_basic2_action_a_history.getItemAt(i), Basic_Basic::Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(this->m_smInitialBasic1_action_a_history.getItemAt(i), + SmInitial_Basic::Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(this->m_smInitialBasic2_action_a_history.getItemAt(i), + SmInitial_Basic::Signal::__FPRIME_AC_INITIAL_TRANSITION); + } +} + +} // namespace SmInstanceInitial + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/initial/Basic.fpp b/FppTest/state_machine/internal_instance/initial/Basic.fpp new file mode 100644 index 0000000000..cb63d523a1 --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Basic.fpp @@ -0,0 +1,23 @@ +module FppTest { + + module SmInstanceInitial { + + queued component Basic { + + sync input port schedIn: Svc.Sched + + include "../../internal/initial/include/Basic.fppi" + + state machine instance basic1: Basic + + state machine instance basic2: Basic + + state machine instance smInitialBasic1: SmInitial.Basic + + state machine instance smInitialBasic2: SmInitial.Basic + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/initial/Basic.hpp b/FppTest/state_machine/internal_instance/initial/Basic.hpp new file mode 100644 index 0000000000..be4627381b --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Basic.hpp @@ -0,0 +1,115 @@ +// ====================================================================== +// \title Basic.hpp +// \author bocchino +// \brief hpp file for Basic component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceInitial_Basic_HPP +#define FppTest_SmInstanceInitial_Basic_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/initial/BasicComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceInitial { + +class Basic : public BasicComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmInstanceInitial_Basic_Basic + using Basic_Basic = FppTest_SmInstanceInitial_Basic_Basic; + + //! The type FppTest_SmInitial_Basic + using SmInitial_Basic = FppTest_SmInitial_Basic; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Basic object + Basic(const char* const compName //!< The component name + ); + + //! Destroy Basic object + ~Basic(); + + 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; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmInitial_Basic + //! + //! Action a + void FppTest_SmInitial_Basic_action_a(SmId smId, //!< The state machine id + FppTest_SmInitial_Basic::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmInstanceInitial_Basic_Basic + //! + //! Action a + void FppTest_SmInstanceInitial_Basic_Basic_action_a( + SmId smId, //!< The state machine id + FppTest_SmInstanceInitial_Basic_Basic::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of basic1 + SmHarness::History m_basic1_action_a_history; + + //! The history associated with action a of basic2 + SmHarness::History m_basic2_action_a_history; + + //! The history associated with action a of smInitialBasic1 + SmHarness::History m_smInitialBasic1_action_a_history; + + //! The history associated with action a of smInitialBasic2 + SmHarness::History m_smInitialBasic2_action_a_history; +}; + +} // namespace SmInstanceInitial + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/initial/CMakeLists.txt b/FppTest/state_machine/internal_instance/initial/CMakeLists.txt new file mode 100644 index 0000000000..56da4fac54 --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/CMakeLists.txt @@ -0,0 +1,16 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Choice.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Nested.fpp" +) +set(MOD_DEPS FppTest/state_machine/internal/harness) +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Choice.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Nested.cpp" + "${CMAKE_CURRENT_LIST_DIR}/main.cpp" +) +set(UT_MOD_DEPS STest) +register_fprime_ut() diff --git a/FppTest/state_machine/internal_instance/initial/Choice.cpp b/FppTest/state_machine/internal_instance/initial/Choice.cpp new file mode 100644 index 0000000000..9e1f5ffb3a --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Choice.cpp @@ -0,0 +1,116 @@ +// ====================================================================== +// \title Choice.cpp +// \author bocchino +// \brief cpp file for Choice component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/initial/Choice.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceInitial { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Choice::Choice(const char* const compName) + : ChoiceComponentBase(compName), + m_choice_action_a_history(), + m_smInitialChoice_action_a_history(), + m_choice_guard_g(), + m_smInitialChoice_guard_g() {} + +Choice::~Choice() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Choice::FppTest_SmInitial_Choice_action_a(SmId smId, FppTest_SmInitial_Choice::Signal signal) { + ASSERT_EQ(smId, SmId::smInitialChoice); + this->m_smInitialChoice_action_a_history.push(signal); +} + +void Choice::FppTest_SmInstanceInitial_Choice_Choice_action_a(SmId smId, + FppTest_SmInstanceInitial_Choice_Choice::Signal signal) { + ASSERT_EQ(smId, SmId::choice); + this->m_choice_action_a_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool Choice ::FppTest_SmInitial_Choice_guard_g(SmId smId, FppTest_SmInitial_Choice::Signal signal) const { + FW_ASSERT(smId == SmId::smInitialChoice, static_cast(smId)); + return m_smInitialChoice_guard_g.call(signal); +} + +bool Choice ::FppTest_SmInstanceInitial_Choice_Choice_guard_g( + SmId smId, + FppTest_SmInstanceInitial_Choice_Choice::Signal signal) const { + FW_ASSERT(smId == SmId::choice, static_cast(smId)); + return m_choice_guard_g.call(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Choice::testFalse() { + this->m_choice_action_a_history.clear(); + this->m_smInitialChoice_action_a_history.clear(); + this->m_choice_guard_g.reset(); + this->m_smInitialChoice_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->choice_getState(), Choice_Choice::State::T); + ASSERT_EQ(this->smInitialChoice_getState(), SmInitial_Choice::State::T); + const FwSizeType expectedActionSize = 5; + const FwSizeType expectedGuardSize = 1; + this->checkActionsAndGuards(expectedActionSize, expectedGuardSize); +} + +void Choice::testTrue() { + this->m_choice_action_a_history.clear(); + this->m_smInitialChoice_action_a_history.clear(); + this->m_choice_guard_g.reset(); + this->m_smInitialChoice_guard_g.reset(); + this->m_choice_guard_g.setReturnValue(true); + this->m_smInitialChoice_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->choice_getState(), Choice_Choice::State::S); + ASSERT_EQ(this->smInitialChoice_getState(), SmInitial_Choice::State::S); + const FwSizeType expectedActionSize = 3; + const FwSizeType expectedGuardSize = 1; + this->checkActionsAndGuards(expectedActionSize, expectedGuardSize); +} + +// ---------------------------------------------------------------------- +// Helper functions +// ---------------------------------------------------------------------- + +void Choice::checkActionsAndGuards(FwSizeType expectedActionSize, FwSizeType expectedGuardSize) { + ASSERT_EQ(this->m_choice_action_a_history.getSize(), expectedActionSize); + ASSERT_EQ(this->m_smInitialChoice_action_a_history.getSize(), expectedActionSize); + for (FwSizeType i = 0; i < expectedActionSize; i++) { + ASSERT_EQ(this->m_choice_action_a_history.getItemAt(i), Choice_Choice::Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(this->m_smInitialChoice_action_a_history.getItemAt(i), + SmInitial_Choice::Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(this->m_choice_guard_g.getCallHistory().getSize(), expectedGuardSize); + ASSERT_EQ(this->m_smInitialChoice_guard_g.getCallHistory().getSize(), expectedGuardSize); + for (FwSizeType i = 0; i < expectedGuardSize; i++) { + ASSERT_EQ(this->m_choice_guard_g.getCallHistory().getItemAt(i), + Choice_Choice::Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(this->m_smInitialChoice_guard_g.getCallHistory().getItemAt(i), + SmInitial_Choice::Signal::__FPRIME_AC_INITIAL_TRANSITION); + } +} + +} // namespace SmInstanceInitial + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/initial/Choice.fpp b/FppTest/state_machine/internal_instance/initial/Choice.fpp new file mode 100644 index 0000000000..1e9888a853 --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Choice.fpp @@ -0,0 +1,17 @@ +module FppTest { + + module SmInstanceInitial { + + active component Choice { + + include "../../internal/initial/include/Choice.fppi" + + state machine instance $choice: Choice priority 1 assert + + state machine instance smInitialChoice: SmInitial.Choice priority 2 block + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/initial/Choice.hpp b/FppTest/state_machine/internal_instance/initial/Choice.hpp new file mode 100644 index 0000000000..ce0d03f864 --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Choice.hpp @@ -0,0 +1,138 @@ +// ====================================================================== +// \title Choice.hpp +// \author bocchino +// \brief hpp file for Choice component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceInitial_Choice_HPP +#define FppTest_SmInstanceInitial_Choice_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/initial/ChoiceComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceInitial { + +class Choice : public ChoiceComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmInstanceInitial_Choice_Choice + using Choice_Choice = FppTest_SmInstanceInitial_Choice_Choice; + + //! The type FppTest_SmInitial_Choice + using SmInitial_Choice = FppTest_SmInitial_Choice; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Choice object + Choice(const char* const compName //!< The component name + ); + + //! Destroy Choice object + ~Choice(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmInitial_Choice + //! + //! Action a + void FppTest_SmInitial_Choice_action_a(SmId smId, //!< The state machine id + FppTest_SmInitial_Choice::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmInstanceInitial_Choice_Choice + //! + //! Action a + void FppTest_SmInstanceInitial_Choice_Choice_action_a( + SmId smId, //!< The state machine id + FppTest_SmInstanceInitial_Choice_Choice::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmInitial_Choice + //! + //! Guard g + bool FppTest_SmInitial_Choice_guard_g(SmId smId, //!< The state machine id + FppTest_SmInitial_Choice::Signal signal //!< The signal + ) const override; + + //! Implementation for guard g of state machine FppTest_SmInstanceInitial_Choice_Choice + //! + //! Guard g + bool FppTest_SmInstanceInitial_Choice_Choice_guard_g( + SmId smId, //!< The state machine id + FppTest_SmInstanceInitial_Choice_Choice::Signal signal //!< The signal + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Helper functions + // ---------------------------------------------------------------------- + + //! Helper function for checking actions and guards + void checkActionsAndGuards(FwSizeType expectedActionSize, //!< The expected action size + FwSizeType expectedGuardSize //!< The expected guard size + ); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of choice + SmHarness::History m_choice_action_a_history; + + //! The history associated with action a of smInitialChoice + SmHarness::History m_smInitialChoice_action_a_history; + + //! The guard g of choice + SmHarness::NoArgGuard m_choice_guard_g; + + //! The guard g of smInitialChoice + SmHarness::NoArgGuard m_smInitialChoice_guard_g; +}; + +} // namespace SmInstanceInitial + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/initial/Nested.cpp b/FppTest/state_machine/internal_instance/initial/Nested.cpp new file mode 100644 index 0000000000..a6ef87174e --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Nested.cpp @@ -0,0 +1,71 @@ +// ====================================================================== +// \title Nested.cpp +// \author bocchino +// \brief cpp file for Nested component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/initial/Nested.hpp" + +namespace FppTest { + +namespace SmInstanceInitial { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Nested::Nested(const char* const compName) + : NestedComponentBase(compName), m_nested_action_a_history(), m_smInitialNested_action_a_history() {} + +Nested::~Nested() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Nested::FppTest_SmInitial_Nested_action_a(SmId smId, FppTest_SmInitial_Nested::Signal signal) { + ASSERT_EQ(smId, SmId::smInitialNested); + this->m_smInitialNested_action_a_history.push(signal); +} + +void Nested::FppTest_SmInstanceInitial_Nested_Nested_action_a(SmId smId, + FppTest_SmInstanceInitial_Nested_Nested::Signal signal) { + ASSERT_EQ(smId, SmId::nested); + this->m_nested_action_a_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Overflow hook implementations for internal state machines +// ---------------------------------------------------------------------- + +void Nested ::smInitialNested_stateMachineOverflowHook(SmId smId, + FwEnumStoreType signal, + Fw::SerializeBufferBase& buffer) { + // Nothing to do +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Nested::test() { + this->m_nested_action_a_history.clear(); + this->m_smInitialNested_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->nested_getState(), Nested_Nested::State::S_T); + ASSERT_EQ(this->smInitialNested_getState(), SmInitial_Nested::State::S_T); + const FwSizeType expectedActionSize = 6; + ASSERT_EQ(this->m_nested_action_a_history.getSize(), expectedActionSize); + ASSERT_EQ(this->m_smInitialNested_action_a_history.getSize(), expectedActionSize); + for (FwSizeType i = 0; i < expectedActionSize; i++) { + ASSERT_EQ(this->m_nested_action_a_history.getItemAt(i), Nested_Nested::Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(this->m_smInitialNested_action_a_history.getItemAt(i), + SmInitial_Nested::Signal::__FPRIME_AC_INITIAL_TRANSITION); + } +} + +} // namespace SmInstanceInitial + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/initial/Nested.fpp b/FppTest/state_machine/internal_instance/initial/Nested.fpp new file mode 100644 index 0000000000..852486f9d2 --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Nested.fpp @@ -0,0 +1,17 @@ +module FppTest { + + module SmInstanceInitial { + + active component Nested { + + include "../../internal/initial/include/Nested.fppi" + + state machine instance nested: Nested priority 3 drop + + state machine instance smInitialNested: SmInitial.Nested priority 4 hook + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/initial/Nested.hpp b/FppTest/state_machine/internal_instance/initial/Nested.hpp new file mode 100644 index 0000000000..31a059a031 --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/Nested.hpp @@ -0,0 +1,110 @@ +// ====================================================================== +// \title Nested.hpp +// \author bocchino +// \brief hpp file for Nested component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceInitial_Nested_HPP +#define FppTest_SmInstanceInitial_Nested_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/initial/NestedComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceInitial { + +class Nested : public NestedComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmInstanceInitial_Nested_Nested + using Nested_Nested = FppTest_SmInstanceInitial_Nested_Nested; + + //! The type FppTest_SmInitial_Nested + using SmInitial_Nested = FppTest_SmInitial_Nested; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Nested object + Nested(const char* const compName //!< The component name + ); + + //! Destroy Nested object + ~Nested(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmInitial_Nested + //! + //! Action a + void FppTest_SmInitial_Nested_action_a(SmId smId, //!< The state machine id + FppTest_SmInitial_Nested::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmInstanceInitial_Nested_Nested + //! + //! Action a + void FppTest_SmInstanceInitial_Nested_Nested_action_a( + SmId smId, //!< The state machine id + FppTest_SmInstanceInitial_Nested_Nested::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Overflow hook implementations for internal state machines + // ---------------------------------------------------------------------- + + //! Overflow hook implementation for smInitialNested + void smInitialNested_stateMachineOverflowHook(SmId smId, //!< The state machine ID + FwEnumStoreType signal, //!< The signal + Fw::SerializeBufferBase& buffer //!< The message buffer + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of nested + SmHarness::History m_nested_action_a_history; + + //! The history associated with action a of smInitialNested + SmHarness::History m_smInitialNested_action_a_history; +}; + +} // namespace SmInstanceInitial + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/initial/main.cpp b/FppTest/state_machine/internal_instance/initial/main.cpp new file mode 100644 index 0000000000..b45ed53e95 --- /dev/null +++ b/FppTest/state_machine/internal_instance/initial/main.cpp @@ -0,0 +1,40 @@ +// ---------------------------------------------------------------------- +// main.cpp +// ---------------------------------------------------------------------- + +#include + +#include "FppTest/state_machine/internal_instance/initial/Basic.hpp" +#include "FppTest/state_machine/internal_instance/initial/Choice.hpp" +#include "FppTest/state_machine/internal_instance/initial/Nested.hpp" +#include "STest/STest/Random/Random.hpp" + +TEST(Basic, Test) { + FppTest::SmInstanceInitial::Basic basic("basic"); + basic.test(); +} + +TEST(Choice, False) { + FppTest::SmInstanceInitial::Choice choice("choice"); + choice.testFalse(); +} + +TEST(Choice, True) { + FppTest::SmInstanceInitial::Choice choice("choice"); + choice.testTrue(); +} + +TEST(Nested, Test) { + FppTest::SmInstanceInitial::Nested nested("nested"); + nested.test(); +} + +// ---------------------------------------------------------------------- +// Main function +// ---------------------------------------------------------------------- + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + STest::Random::seed(); + return RUN_ALL_TESTS(); +} diff --git a/FppTest/state_machine/internal_instance/state/Basic.cpp b/FppTest/state_machine/internal_instance/state/Basic.cpp new file mode 100644 index 0000000000..f6d82fc260 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Basic.cpp @@ -0,0 +1,120 @@ +// ====================================================================== +// \title Basic.cpp +// \author bocchino +// \brief cpp file for Basic component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/Basic.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Basic ::Basic(const char* const compName) + : BasicComponentBase(compName), m_basic1_action_a_history(), m_smStateBasic1_action_a_history() {} + +Basic ::~Basic() {} + +// ---------------------------------------------------------------------- +// Handler implementations for typed input ports +// ---------------------------------------------------------------------- + +void Basic::schedIn_handler(FwIndexType portNum, U32 context) { + // Nothing to do +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Basic ::FppTest_SmInstanceState_Basic_Basic_action_a(SmId smId, + FppTest_SmInstanceState_Basic_Basic::Signal signal) { + ASSERT_TRUE((smId == SmId::basic1) || (smId == SmId::basic2)); + if (smId == SmId::basic1) { + this->m_basic1_action_a_history.push(signal); + } else { + this->m_basic2_action_a_history.push(signal); + } +} + +void Basic ::FppTest_SmState_Basic_action_a(SmId smId, FppTest_SmState_Basic::Signal signal) { + ASSERT_TRUE((smId == SmId::smStateBasic1) || (smId == SmId::smStateBasic2)); + if (smId == SmId::smStateBasic1) { + this->m_smStateBasic1_action_a_history.push(signal); + } else { + this->m_smStateBasic2_action_a_history.push(signal); + } +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Basic::test() { + this->m_basic1_action_a_history.clear(); + this->m_smStateBasic1_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->basic1_getState(), Basic_Basic::State::S); + ASSERT_EQ(this->smStateBasic1_getState(), SmState_Basic::State::S); + ASSERT_EQ(this->m_basic1_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_basic2_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasic1_action_a_history.getSize(), 0); + { + // Send signal s to basic1 + this->basic1_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->basic1_getState(), Basic_Basic::State::T); + const FwSizeType expectedSize = 6; + ASSERT_EQ(this->m_basic1_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_basic1_action_a_history.getItemAt(i), Basic_Basic::Signal::s); + } + } + { + // Send signal s to basic2 + this->basic2_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->basic2_getState(), Basic_Basic::State::T); + const FwSizeType expectedSize = 6; + ASSERT_EQ(this->m_basic2_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_basic2_action_a_history.getItemAt(i), Basic_Basic::Signal::s); + } + } + { + // Send signal s to smStateBasic1 + this->smStateBasic1_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasic1_getState(), SmState_Basic::State::T); + const FwSizeType expectedSize = 6; + ASSERT_EQ(this->m_smStateBasic1_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_smStateBasic1_action_a_history.getItemAt(i), SmState_Basic::Signal::s); + } + } + { + // Send signal s to smStateBasic2 + this->smStateBasic2_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasic2_getState(), SmState_Basic::State::T); + const FwSizeType expectedSize = 6; + ASSERT_EQ(this->m_smStateBasic2_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_smStateBasic2_action_a_history.getItemAt(i), SmState_Basic::Signal::s); + } + } +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/Basic.fpp b/FppTest/state_machine/internal_instance/state/Basic.fpp new file mode 100644 index 0000000000..348d1b9df1 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Basic.fpp @@ -0,0 +1,23 @@ +module FppTest { + + module SmInstanceState { + + queued component Basic { + + sync input port schedIn: Svc.Sched + + include "../../internal/state/include/Basic.fppi" + + state machine instance basic1: Basic + + state machine instance basic2: Basic + + state machine instance smStateBasic1: SmState.Basic priority 1 assert + + state machine instance smStateBasic2: SmState.Basic priority 2 drop + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/Basic.hpp b/FppTest/state_machine/internal_instance/state/Basic.hpp new file mode 100644 index 0000000000..66edc714e4 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Basic.hpp @@ -0,0 +1,115 @@ +// ====================================================================== +// \title Basic.hpp +// \author bocchino +// \brief hpp file for Basic component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_Basic_HPP +#define FppTest_SmInstanceState_Basic_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class Basic : public BasicComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmInstanceState_Basic_Basic + using Basic_Basic = FppTest_SmInstanceState_Basic_Basic; + + //! The type FppTest_SmState_Basic + using SmState_Basic = FppTest_SmState_Basic; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Basic object + Basic(const char* const compName //!< The component name + ); + + //! Destroy Basic object + ~Basic(); + + 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; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmInstanceState_Basic_Basic + //! + //! Action a + void FppTest_SmInstanceState_Basic_Basic_action_a( + SmId smId, //!< The state machine id + FppTest_SmInstanceState_Basic_Basic::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmState_Basic + //! + //! Action a + void FppTest_SmState_Basic_action_a(SmId smId, //!< The state machine id + FppTest_SmState_Basic::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of basic1 + SmHarness::History m_basic1_action_a_history; + + //! The history associated with action a of basic2 + SmHarness::History m_basic2_action_a_history; + + //! The history associated with action a of smStateBasic1 + SmHarness::History m_smStateBasic1_action_a_history; + + //! The history associated with action a of smStateBasic2 + SmHarness::History m_smStateBasic2_action_a_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicGuard.cpp b/FppTest/state_machine/internal_instance/state/BasicGuard.cpp new file mode 100644 index 0000000000..e7a20dec18 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuard.cpp @@ -0,0 +1,93 @@ +// ====================================================================== +// \title BasicGuard.cpp +// \author bocchino +// \brief cpp file for BasicGuard component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicGuard.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicGuard ::BasicGuard(const char* const compName) + : BasicGuardComponentBase(compName), m_smStateBasicGuard_action_a_history(), m_smStateBasicGuard_guard_g() {} + +BasicGuard ::~BasicGuard() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicGuard ::FppTest_SmState_BasicGuard_action_a(SmId smId, FppTest_SmState_BasicGuard::Signal signal) { + ASSERT_EQ(smId, SmId::smStateBasicGuard); + this->m_smStateBasicGuard_action_a_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicGuard ::FppTest_SmState_BasicGuard_guard_g(SmId smId, FppTest_SmState_BasicGuard::Signal signal) const { + FW_ASSERT(smId == SmId::smStateBasicGuard, static_cast(smId)); + return this->m_smStateBasicGuard_guard_g.call(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicGuard::testFalse() { + this->m_smStateBasicGuard_action_a_history.clear(); + this->m_smStateBasicGuard_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuard_getState(), SmState_BasicGuard::State::S); + ASSERT_EQ(this->m_smStateBasicGuard_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuard_guard_g.getCallHistory().getSize(), 0); + this->smStateBasicGuard_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuard_getState(), SmState_BasicGuard::State::S); + this->checkActionsAndGuards(0, 1); +} + +void BasicGuard::testTrue() { + this->m_smStateBasicGuard_action_a_history.clear(); + this->m_smStateBasicGuard_guard_g.reset(); + this->m_smStateBasicGuard_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuard_getState(), SmState_BasicGuard::State::S); + ASSERT_EQ(this->m_smStateBasicGuard_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuard_guard_g.getCallHistory().getSize(), 0); + this->smStateBasicGuard_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuard_getState(), SmState_BasicGuard::State::T); + this->checkActionsAndGuards(6, 1); +} + +// ---------------------------------------------------------------------- +// Helper functions +// ---------------------------------------------------------------------- + +void BasicGuard::checkActionsAndGuards(FwSizeType expectedActionSize, FwSizeType expectedGuardSize) { + ASSERT_EQ(this->m_smStateBasicGuard_action_a_history.getSize(), expectedActionSize); + for (FwSizeType i = 0; i < expectedActionSize; i++) { + ASSERT_EQ(this->m_smStateBasicGuard_action_a_history.getItemAt(i), SmState_BasicGuard::Signal::s); + } + ASSERT_EQ(this->m_smStateBasicGuard_guard_g.getCallHistory().getSize(), expectedGuardSize); + for (FwSizeType i = 0; i < expectedGuardSize; i++) { + ASSERT_EQ(this->m_smStateBasicGuard_guard_g.getCallHistory().getItemAt(i), SmState_BasicGuard::Signal::s); + } +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicGuard.fpp b/FppTest/state_machine/internal_instance/state/BasicGuard.fpp new file mode 100644 index 0000000000..712ce484ae --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuard.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicGuard { + + state machine instance smStateBasicGuard: SmState.BasicGuard priority 2 block + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicGuard.hpp b/FppTest/state_machine/internal_instance/state/BasicGuard.hpp new file mode 100644 index 0000000000..ec02868e3b --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuard.hpp @@ -0,0 +1,113 @@ +// ====================================================================== +// \title BasicGuard.hpp +// \author bocchino +// \brief hpp file for BasicGuard component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicGuard_HPP +#define FppTest_SmInstanceState_BasicGuard_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicGuard : public BasicGuardComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicGuard + using SmState_BasicGuard = FppTest_SmState_BasicGuard; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicGuard object + BasicGuard(const char* const compName //!< The component name + ); + + //! Destroy BasicGuard object + ~BasicGuard(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicGuard + //! + //! Action a + void FppTest_SmState_BasicGuard_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuard::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_BasicGuard + //! + //! Guard g + bool FppTest_SmState_BasicGuard_guard_g(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuard::Signal signal //!< The signal + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Helper functions + // ---------------------------------------------------------------------- + + //! Helper function for checking actions and guards + void checkActionsAndGuards(FwSizeType expectedActionSize, //!< The expected action size + FwSizeType expectedGuardSize //!< The expected guard size + ); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicGuard + SmHarness::History m_smStateBasicGuard_action_a_history; + + //! The guard g of smStateBasicGuard + SmHarness::NoArgGuard m_smStateBasicGuard_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardString.cpp b/FppTest/state_machine/internal_instance/state/BasicGuardString.cpp new file mode 100644 index 0000000000..649d9395e0 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardString.cpp @@ -0,0 +1,100 @@ +// ====================================================================== +// \title BasicGuardString.cpp +// \author bocchino +// \brief cpp file for BasicGuardString component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/FppConstantsAc.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardString.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicGuardString ::BasicGuardString(const char* const compName) + : BasicGuardStringComponentBase(compName), + m_smStateBasicGuardString_action_a_history(), + m_smStateBasicGuardString_guard_g() {} + +BasicGuardString ::~BasicGuardString() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicGuardString ::FppTest_SmState_BasicGuardString_action_a(SmId smId, + FppTest_SmState_BasicGuardString::Signal signal, + const Fw::StringBase& value) { + ASSERT_EQ(smId, SmId::smStateBasicGuardString); + this->m_smStateBasicGuardString_action_a_history.push(signal, Fw::String(value)); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicGuardString ::FppTest_SmState_BasicGuardString_guard_g(SmId smId, + FppTest_SmState_BasicGuardString::Signal signal, + const Fw::StringBase& value) const { + FW_ASSERT(smId == SmId::smStateBasicGuardString, static_cast(smId)); + return this->m_smStateBasicGuardString_guard_g.call(signal, Fw::String(value)); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicGuardString::testFalse() { + this->m_smStateBasicGuardString_action_a_history.clear(); + this->m_smStateBasicGuardString_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardString_getState(), SmState_BasicGuardString::State::S); + ASSERT_EQ(this->m_smStateBasicGuardString_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getSize(), 0); + Fw::String value; + SmHarness::Pick::string(value, SmState::basicGuardStringSize); + this->smStateBasicGuardString_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardString_getState(), SmState_BasicGuardString::State::S); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardString::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardString_action_a_history.getSize(), 0); +} + +void BasicGuardString::testTrue() { + this->m_smStateBasicGuardString_action_a_history.clear(); + this->m_smStateBasicGuardString_guard_g.reset(); + this->m_smStateBasicGuardString_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardString_getState(), SmState_BasicGuardString::State::S); + ASSERT_EQ(this->m_smStateBasicGuardString_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getSize(), 0); + Fw::String value; + SmHarness::Pick::string(value, SmState::basicGuardStringSize); + this->smStateBasicGuardString_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardString_getState(), SmState_BasicGuardString::State::T); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardString::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardString_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardString_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardString_action_a_history.getSignals().getItemAt(0), + SmState_BasicGuardString::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardString_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardString.fpp b/FppTest/state_machine/internal_instance/state/BasicGuardString.fpp new file mode 100644 index 0000000000..127e41d99c --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardString.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicGuardString { + + state machine instance smStateBasicGuardString: SmState.BasicGuardString priority 3 drop + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardString.hpp b/FppTest/state_machine/internal_instance/state/BasicGuardString.hpp new file mode 100644 index 0000000000..ca00def3a1 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardString.hpp @@ -0,0 +1,106 @@ +// ====================================================================== +// \title BasicGuardString.hpp +// \author bocchino +// \brief hpp file for BasicGuardString component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicGuardString_HPP +#define FppTest_SmInstanceState_BasicGuardString_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardStringComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicGuardString : public BasicGuardStringComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicGuardString + using SmState_BasicGuardString = FppTest_SmState_BasicGuardString; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicGuardString object + BasicGuardString(const char* const compName //!< The component name + ); + + //! Destroy BasicGuardString object + ~BasicGuardString(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicGuardString + //! + //! Action a + void FppTest_SmState_BasicGuardString_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardString::Signal signal, //!< The signal + const Fw::StringBase& value //!< The value + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_BasicGuardString + //! + //! Guard g + bool FppTest_SmState_BasicGuardString_guard_g(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardString::Signal signal, //!< The signal + const Fw::StringBase& value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicGuardString + SmHarness::SignalValueHistory + m_smStateBasicGuardString_action_a_history; + + //! The guard g of smStateBasicGuardString + SmHarness::Guard m_smStateBasicGuardString_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.cpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.cpp new file mode 100644 index 0000000000..0f4fcedd61 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.cpp @@ -0,0 +1,130 @@ +// ====================================================================== +// \title BasicGuardTestAbsType.cpp +// \author bocchino +// \brief cpp file for BasicGuardTestAbsType component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicGuardTestAbsType::BasicGuardTestAbsType(const char* const compName) + : BasicGuardTestAbsTypeComponentBase(compName), + m_value(), + m_smStateBasicGuardTestAbsType_action_a_history(), + m_smStateBasicGuardTestAbsType_guard_g() {} + +BasicGuardTestAbsType::~BasicGuardTestAbsType() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicGuardTestAbsType::FppTest_SmState_BasicGuardTestAbsType_action_a( + SmId smId, + FppTest_SmState_BasicGuardTestAbsType::Signal signal, + const SmHarness::TestAbsType& value) { + ASSERT_EQ(smId, SmId::smStateBasicGuardTestAbsType); + this->m_smStateBasicGuardTestAbsType_action_a_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicGuardTestAbsType::FppTest_SmState_BasicGuardTestAbsType_guard_g( + SmId smId, + FppTest_SmState_BasicGuardTestAbsType::Signal signal, + const SmHarness::TestAbsType& value) const { + FW_ASSERT(smId == SmId::smStateBasicGuardTestAbsType, static_cast(smId)); + return this->m_smStateBasicGuardTestAbsType_guard_g.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Overflow hook implementations for internal state machines +// ---------------------------------------------------------------------- + +void BasicGuardTestAbsType::smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId, + FwEnumStoreType signal, + Fw::SerializeBufferBase& buffer) { + this->m_hookCalled = true; + ASSERT_EQ(smId, SmId::smStateBasicGuardTestAbsType); + ASSERT_EQ(static_cast(signal), SmState_BasicGuardTestAbsType::Signal::s); + SmHarness::TestAbsType value; + const auto status = buffer.deserialize(value); + ASSERT_EQ(status, Fw::FW_SERIALIZE_OK); + ASSERT_EQ(buffer.getBuffLeft(), 0); + ASSERT_EQ(value, this->m_value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicGuardTestAbsType::testFalse() { + this->m_smStateBasicGuardTestAbsType_action_a_history.clear(); + this->m_smStateBasicGuardTestAbsType_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestAbsType_getState(), SmState_BasicGuardTestAbsType::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getSize(), 0); + this->m_value = SmHarness::Pick::testAbsType(); + this->smStateBasicGuardTestAbsType_sendSignal_s(this->m_value); + ASSERT_FALSE(this->m_hookCalled); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestAbsType_getState(), SmState_BasicGuardTestAbsType::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestAbsType::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getValues().getItemAt(0), this->m_value); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_action_a_history.getSize(), 0); +} + +void BasicGuardTestAbsType::testTrue() { + this->m_smStateBasicGuardTestAbsType_action_a_history.clear(); + this->m_smStateBasicGuardTestAbsType_guard_g.reset(); + this->m_smStateBasicGuardTestAbsType_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestAbsType_getState(), SmState_BasicGuardTestAbsType::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getSize(), 0); + this->m_value = SmHarness::Pick::testAbsType(); + this->smStateBasicGuardTestAbsType_sendSignal_s(this->m_value); + ASSERT_FALSE(this->m_hookCalled); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestAbsType_getState(), SmState_BasicGuardTestAbsType::State::T); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestAbsType::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_guard_g.getCallHistory().getValues().getItemAt(0), this->m_value); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_action_a_history.getSignals().getItemAt(0), + SmState_BasicGuardTestAbsType::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestAbsType_action_a_history.getValues().getItemAt(0), this->m_value); +} + +void BasicGuardTestAbsType::testOverflow() { + this->init(queueDepth, instanceId); + this->m_value = SmHarness::Pick::testAbsType(); + for (FwSizeType i = 0; i < queueDepth; i++) { + this->smStateBasicGuardTestAbsType_sendSignal_s(this->m_value); + ASSERT_FALSE(this->m_hookCalled); + } + this->smStateBasicGuardTestAbsType_sendSignal_s(this->m_value); + ASSERT_TRUE(this->m_hookCalled); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.fpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.fpp new file mode 100644 index 0000000000..9f48dbfc83 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicGuardTestAbsType { + + state machine instance smStateBasicGuardTestAbsType: SmState.BasicGuardTestAbsType priority 4 hook + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.hpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.hpp new file mode 100644 index 0000000000..7bb9d259bd --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.hpp @@ -0,0 +1,129 @@ +// ====================================================================== +// \title BasicGuardTestAbsType.hpp +// \author bocchino +// \brief hpp file for BasicGuardTestAbsType component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicGuardTestAbsType_HPP +#define FppTest_SmInstanceState_BasicGuardTestAbsType_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestAbsTypeComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicGuardTestAbsType : public BasicGuardTestAbsTypeComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicGuardTestAbsType + using SmState_BasicGuardTestAbsType = FppTest_SmState_BasicGuardTestAbsType; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicGuardTestAbsType object + BasicGuardTestAbsType(const char* const compName //!< The component name + ); + + //! Destroy BasicGuardTestAbsType object + ~BasicGuardTestAbsType(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicGuardTestAbsType + //! + //! Action a + void FppTest_SmState_BasicGuardTestAbsType_action_a( + SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestAbsType::Signal signal, //!< The signal + const SmHarness::TestAbsType& value //!< The value + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_BasicGuardTestAbsType + //! + //! Guard g + bool FppTest_SmState_BasicGuardTestAbsType_guard_g( + SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestAbsType::Signal signal, //!< The signal + const SmHarness::TestAbsType& value //!< The value + ) const override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Overflow hook implementations for internal state machines + // ---------------------------------------------------------------------- + + //! Overflow hook implementation for smStateBasicGuardTestAbsType + void smStateBasicGuardTestAbsType_stateMachineOverflowHook(SmId smId, //!< The state machine ID + FwEnumStoreType signal, //!< The signal + Fw::SerializeBufferBase& buffer //!< The message buffer + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + //! Test with queue overflow + void testOverflow(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The test value + SmHarness::TestAbsType m_value; + + //! Whether the overflow hook was called + bool m_hookCalled = false; + + //! The history associated with action a of smStateBasicGuardTestAbsType + SmHarness::SignalValueHistory + m_smStateBasicGuardTestAbsType_action_a_history; + + //! The guard g of smStateBasicGuardTestAbsType + SmHarness::Guard + m_smStateBasicGuardTestAbsType_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.cpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.cpp new file mode 100644 index 0000000000..38fbf6be2a --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.cpp @@ -0,0 +1,99 @@ +// ====================================================================== +// \title BasicGuardTestArray.cpp +// \author bocchino +// \brief cpp file for BasicGuardTestArray component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestArray.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicGuardTestArray::BasicGuardTestArray(const char* const compName) + : BasicGuardTestArrayComponentBase(compName), + m_smStateBasicGuardTestArray_action_a_history(), + m_smStateBasicGuardTestArray_guard_g() {} + +BasicGuardTestArray::~BasicGuardTestArray() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicGuardTestArray::FppTest_SmState_BasicGuardTestArray_action_a( + SmId smId, + FppTest_SmState_BasicGuardTestArray::Signal signal, + const SmHarness::TestArray& value) { + ASSERT_EQ(smId, SmId::smStateBasicGuardTestArray); + this->m_smStateBasicGuardTestArray_action_a_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicGuardTestArray::FppTest_SmState_BasicGuardTestArray_guard_g( + SmId smId, + FppTest_SmState_BasicGuardTestArray::Signal signal, + const SmHarness::TestArray& value) const { + FW_ASSERT(smId == SmId::smStateBasicGuardTestArray, static_cast(smId)); + return this->m_smStateBasicGuardTestArray_guard_g.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicGuardTestArray::testFalse() { + this->m_smStateBasicGuardTestArray_action_a_history.clear(); + this->m_smStateBasicGuardTestArray_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestArray_getState(), SmState_BasicGuardTestArray::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getSize(), 0); + const auto value = SmHarness::Pick::testArray(); + this->smStateBasicGuardTestArray_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestArray_getState(), SmState_BasicGuardTestArray::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestArray::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_action_a_history.getSize(), 0); +} + +void BasicGuardTestArray::testTrue() { + this->m_smStateBasicGuardTestArray_action_a_history.clear(); + this->m_smStateBasicGuardTestArray_guard_g.reset(); + this->m_smStateBasicGuardTestArray_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestArray_getState(), SmState_BasicGuardTestArray::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getSize(), 0); + const auto value = SmHarness::Pick::testArray(); + this->smStateBasicGuardTestArray_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestArray_getState(), SmState_BasicGuardTestArray::State::T); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestArray::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_action_a_history.getSignals().getItemAt(0), + SmState_BasicGuardTestArray::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestArray_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.fpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.fpp new file mode 100644 index 0000000000..336916dfa3 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicGuardTestArray { + + state machine instance smStateBasicGuardTestArray: SmState.BasicGuardTestArray + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.hpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.hpp new file mode 100644 index 0000000000..bcc8fb5347 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestArray.hpp @@ -0,0 +1,109 @@ +// ====================================================================== +// \title BasicGuardTestArray.hpp +// \author bocchino +// \brief hpp file for BasicGuardTestArray component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicGuardTestArray_HPP +#define FppTest_SmInstanceState_BasicGuardTestArray_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestArrayComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicGuardTestArray : public BasicGuardTestArrayComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicGuardTestArray + using SmState_BasicGuardTestArray = FppTest_SmState_BasicGuardTestArray; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicGuardTestArray object + BasicGuardTestArray(const char* const compName //!< The component name + ); + + //! Destroy BasicGuardTestArray object + ~BasicGuardTestArray(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicGuardTestArray + //! + //! Action a + void FppTest_SmState_BasicGuardTestArray_action_a( + SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestArray::Signal signal, //!< The signal + const SmHarness::TestArray& value //!< The value + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_BasicGuardTestArray + //! + //! Guard g + bool FppTest_SmState_BasicGuardTestArray_guard_g( + SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestArray::Signal signal, //!< The signal + const SmHarness::TestArray& value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicGuardTestArray + SmHarness::SignalValueHistory + m_smStateBasicGuardTestArray_action_a_history; + + //! The guard g of smStateBasicGuardTestArray + SmHarness::Guard + m_smStateBasicGuardTestArray_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.cpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.cpp new file mode 100644 index 0000000000..bb3d775c40 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.cpp @@ -0,0 +1,97 @@ +// ====================================================================== +// \title BasicGuardTestEnum.cpp +// \author bocchino +// \brief cpp file for BasicGuardTestEnum component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicGuardTestEnum::BasicGuardTestEnum(const char* const compName) + : BasicGuardTestEnumComponentBase(compName), + m_smStateBasicGuardTestEnum_action_a_history(), + m_smStateBasicGuardTestEnum_guard_g() {} + +BasicGuardTestEnum::~BasicGuardTestEnum() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicGuardTestEnum::FppTest_SmState_BasicGuardTestEnum_action_a(SmId smId, + FppTest_SmState_BasicGuardTestEnum::Signal signal, + const SmHarness::TestEnum& value) { + ASSERT_EQ(smId, SmId::smStateBasicGuardTestEnum); + this->m_smStateBasicGuardTestEnum_action_a_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicGuardTestEnum::FppTest_SmState_BasicGuardTestEnum_guard_g(SmId smId, + FppTest_SmState_BasicGuardTestEnum::Signal signal, + const SmHarness::TestEnum& value) const { + FW_ASSERT(smId == SmId::smStateBasicGuardTestEnum, static_cast(smId)); + return this->m_smStateBasicGuardTestEnum_guard_g.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicGuardTestEnum::testFalse() { + this->m_smStateBasicGuardTestEnum_action_a_history.clear(); + this->m_smStateBasicGuardTestEnum_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestEnum_getState(), SmState_BasicGuardTestEnum::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getSize(), 0); + const auto value = SmHarness::Pick::testEnum(); + this->smStateBasicGuardTestEnum_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestEnum_getState(), SmState_BasicGuardTestEnum::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestEnum::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_action_a_history.getSize(), 0); +} + +void BasicGuardTestEnum::testTrue() { + this->m_smStateBasicGuardTestEnum_action_a_history.clear(); + this->m_smStateBasicGuardTestEnum_guard_g.reset(); + this->m_smStateBasicGuardTestEnum_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestEnum_getState(), SmState_BasicGuardTestEnum::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getSize(), 0); + const auto value = SmHarness::Pick::testEnum(); + this->smStateBasicGuardTestEnum_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestEnum_getState(), SmState_BasicGuardTestEnum::State::T); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestEnum::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_action_a_history.getSignals().getItemAt(0), + SmState_BasicGuardTestEnum::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestEnum_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.fpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.fpp new file mode 100644 index 0000000000..fb01095da1 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicGuardTestEnum { + + state machine instance smStateBasicGuardTestEnum: SmState.BasicGuardTestEnum + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.hpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.hpp new file mode 100644 index 0000000000..a7534259bb --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.hpp @@ -0,0 +1,107 @@ +// ====================================================================== +// \title BasicGuardTestEnum.hpp +// \author bocchino +// \brief hpp file for BasicGuardTestEnum component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicGuardTestEnum_HPP +#define FppTest_SmInstanceState_BasicGuardTestEnum_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestEnumComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicGuardTestEnum : public BasicGuardTestEnumComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicGuardTestEnum + using SmState_BasicGuardTestEnum = FppTest_SmState_BasicGuardTestEnum; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicGuardTestEnum object + BasicGuardTestEnum(const char* const compName //!< The component name + ); + + //! Destroy BasicGuardTestEnum object + ~BasicGuardTestEnum(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicGuardTestEnum + //! + //! Action a + void FppTest_SmState_BasicGuardTestEnum_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestEnum::Signal signal, //!< The signal + const SmHarness::TestEnum& value //!< The value + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_BasicGuardTestEnum + //! + //! Guard g + bool FppTest_SmState_BasicGuardTestEnum_guard_g(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestEnum::Signal signal, //!< The signal + const SmHarness::TestEnum& value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicGuardTestEnum + SmHarness::SignalValueHistory + m_smStateBasicGuardTestEnum_action_a_history; + + //! The guard g of smStateBasicGuardTestEnum + SmHarness::Guard + m_smStateBasicGuardTestEnum_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.cpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.cpp new file mode 100644 index 0000000000..ef9a1878cd --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.cpp @@ -0,0 +1,99 @@ +// ====================================================================== +// \title BasicGuardTestStruct.cpp +// \author bocchino +// \brief cpp file for BasicGuardTestStruct component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicGuardTestStruct::BasicGuardTestStruct(const char* const compName) + : BasicGuardTestStructComponentBase(compName), + m_smStateBasicGuardTestStruct_action_a_history(), + m_smStateBasicGuardTestStruct_guard_g() {} + +BasicGuardTestStruct::~BasicGuardTestStruct() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicGuardTestStruct::FppTest_SmState_BasicGuardTestStruct_action_a( + SmId smId, + FppTest_SmState_BasicGuardTestStruct::Signal signal, + const SmHarness::TestStruct& value) { + ASSERT_EQ(smId, SmId::smStateBasicGuardTestStruct); + this->m_smStateBasicGuardTestStruct_action_a_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicGuardTestStruct::FppTest_SmState_BasicGuardTestStruct_guard_g( + SmId smId, + FppTest_SmState_BasicGuardTestStruct::Signal signal, + const SmHarness::TestStruct& value) const { + FW_ASSERT(smId == SmId::smStateBasicGuardTestStruct, static_cast(smId)); + return this->m_smStateBasicGuardTestStruct_guard_g.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicGuardTestStruct::testFalse() { + this->m_smStateBasicGuardTestStruct_action_a_history.clear(); + this->m_smStateBasicGuardTestStruct_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestStruct_getState(), SmState_BasicGuardTestStruct::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getSize(), 0); + const auto value = SmHarness::Pick::testStruct(); + this->smStateBasicGuardTestStruct_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestStruct_getState(), SmState_BasicGuardTestStruct::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestStruct::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_action_a_history.getSize(), 0); +} + +void BasicGuardTestStruct::testTrue() { + this->m_smStateBasicGuardTestStruct_action_a_history.clear(); + this->m_smStateBasicGuardTestStruct_guard_g.reset(); + this->m_smStateBasicGuardTestStruct_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardTestStruct_getState(), SmState_BasicGuardTestStruct::State::S); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getSize(), 0); + const auto value = SmHarness::Pick::testStruct(); + this->smStateBasicGuardTestStruct_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardTestStruct_getState(), SmState_BasicGuardTestStruct::State::T); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardTestStruct::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_action_a_history.getSignals().getItemAt(0), + SmState_BasicGuardTestStruct::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardTestStruct_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.fpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.fpp new file mode 100644 index 0000000000..4e5f4b2ca1 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicGuardTestStruct { + + state machine instance smStateBasicGuardTestStruct: SmState.BasicGuardTestStruct + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.hpp b/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.hpp new file mode 100644 index 0000000000..9d2a7b15b0 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.hpp @@ -0,0 +1,109 @@ +// ====================================================================== +// \title BasicGuardTestStruct.hpp +// \author bocchino +// \brief hpp file for BasicGuardTestStruct component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicGuardTestStruct_HPP +#define FppTest_SmInstanceState_BasicGuardTestStruct_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestStructComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicGuardTestStruct : public BasicGuardTestStructComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicGuardTestStruct + using SmState_BasicGuardTestStruct = FppTest_SmState_BasicGuardTestStruct; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicGuardTestStruct object + BasicGuardTestStruct(const char* const compName //!< The component name + ); + + //! Destroy BasicGuardTestStruct object + ~BasicGuardTestStruct(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicGuardTestStruct + //! + //! Action a + void FppTest_SmState_BasicGuardTestStruct_action_a( + SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestStruct::Signal signal, //!< The signal + const SmHarness::TestStruct& value //!< The value + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_BasicGuardTestStruct + //! + //! Guard g + bool FppTest_SmState_BasicGuardTestStruct_guard_g( + SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardTestStruct::Signal signal, //!< The signal + const SmHarness::TestStruct& value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicGuardTestStruct + SmHarness::SignalValueHistory + m_smStateBasicGuardTestStruct_action_a_history; + + //! The guard g of smStateBasicGuardTestStruct + SmHarness::Guard + m_smStateBasicGuardTestStruct_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardU32.cpp b/FppTest/state_machine/internal_instance/state/BasicGuardU32.cpp new file mode 100644 index 0000000000..c51c248c70 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardU32.cpp @@ -0,0 +1,97 @@ +// ====================================================================== +// \title BasicGuardU32.cpp +// \author bocchino +// \brief cpp file for BasicGuardU32 component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicGuardU32.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicGuardU32::BasicGuardU32(const char* const compName) + : BasicGuardU32ComponentBase(compName), + m_smStateBasicGuardU32_action_a_history(), + m_smStateBasicGuardU32_guard_g() {} + +BasicGuardU32::~BasicGuardU32() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicGuardU32::FppTest_SmState_BasicGuardU32_action_a(SmId smId, + FppTest_SmState_BasicGuardU32::Signal signal, + U32 value) { + ASSERT_EQ(smId, SmId::smStateBasicGuardU32); + this->m_smStateBasicGuardU32_action_a_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool BasicGuardU32::FppTest_SmState_BasicGuardU32_guard_g(SmId smId, + FppTest_SmState_BasicGuardU32::Signal signal, + U32 value) const { + FW_ASSERT(smId == SmId::smStateBasicGuardU32, static_cast(smId)); + return this->m_smStateBasicGuardU32_guard_g.call(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicGuardU32::testFalse() { + this->m_smStateBasicGuardU32_action_a_history.clear(); + this->m_smStateBasicGuardU32_guard_g.reset(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardU32_getState(), SmState_BasicGuardU32::State::S); + ASSERT_EQ(this->m_smStateBasicGuardU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getSize(), 0); + const U32 value = STest::Pick::any(); + this->smStateBasicGuardU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardU32_getState(), SmState_BasicGuardU32::State::S); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardU32::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardU32_action_a_history.getSize(), 0); +} + +void BasicGuardU32::testTrue() { + this->m_smStateBasicGuardU32_action_a_history.clear(); + this->m_smStateBasicGuardU32_guard_g.reset(); + this->m_smStateBasicGuardU32_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicGuardU32_getState(), SmState_BasicGuardU32::State::S); + ASSERT_EQ(this->m_smStateBasicGuardU32_action_a_history.getSize(), 0); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getSize(), 0); + const U32 value = STest::Pick::any(); + this->smStateBasicGuardU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicGuardU32_getState(), SmState_BasicGuardU32::State::T); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getSignals().getItemAt(0), + SmState_BasicGuardU32::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardU32_guard_g.getCallHistory().getValues().getItemAt(0), value); + ASSERT_EQ(this->m_smStateBasicGuardU32_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicGuardU32_action_a_history.getSignals().getItemAt(0), + SmState_BasicGuardU32::Signal::s); + ASSERT_EQ(this->m_smStateBasicGuardU32_action_a_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardU32.fpp b/FppTest/state_machine/internal_instance/state/BasicGuardU32.fpp new file mode 100644 index 0000000000..8782258719 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardU32.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicGuardU32 { + + state machine instance smStateBasicGuardU32: SmState.BasicGuardU32 + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicGuardU32.hpp b/FppTest/state_machine/internal_instance/state/BasicGuardU32.hpp new file mode 100644 index 0000000000..2ac3da4be2 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicGuardU32.hpp @@ -0,0 +1,106 @@ +// ====================================================================== +// \title BasicGuardU32.hpp +// \author bocchino +// \brief hpp file for BasicGuardU32 component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicGuardU32_HPP +#define FppTest_SmInstanceState_BasicGuardU32_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardU32ComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicGuardU32 : public BasicGuardU32ComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicGuardU32 + using SmState_BasicGuardU32 = FppTest_SmState_BasicGuardU32; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicGuardU32 object + BasicGuardU32(const char* const compName //!< The component name + ); + + //! Destroy BasicGuardU32 object + ~BasicGuardU32(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicGuardU32 + //! + //! Action a + void FppTest_SmState_BasicGuardU32_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardU32::Signal signal, //!< The signal + U32 value //!< The value + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_BasicGuardU32 + //! + //! Guard g + bool FppTest_SmState_BasicGuardU32_guard_g(SmId smId, //!< The state machine id + FppTest_SmState_BasicGuardU32::Signal signal, //!< The signal + U32 value //!< The value + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test with true guard + void testTrue(); + + //! Test with false guard + void testFalse(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicGuardU32 + SmHarness::SignalValueHistory + m_smStateBasicGuardU32_action_a_history; + + //! The guard g of smStateBasicGuardU32 + SmHarness::Guard m_smStateBasicGuardU32_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicInternal.cpp b/FppTest/state_machine/internal_instance/state/BasicInternal.cpp new file mode 100644 index 0000000000..9fe9b0088c --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicInternal.cpp @@ -0,0 +1,55 @@ +// ====================================================================== +// \title BasicInternal.cpp +// \author bocchino +// \brief cpp file for BasicInternal component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicInternal.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicInternal::BasicInternal(const char* const compName) + : BasicInternalComponentBase(compName), m_smStateBasicInternal_action_a_history() {} + +BasicInternal::~BasicInternal() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicInternal::FppTest_SmState_BasicInternal_action_a(SmId smId, FppTest_SmState_BasicInternal::Signal signal) { + ASSERT_EQ(smId, SmId::smStateBasicInternal); + this->m_smStateBasicInternal_action_a_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicInternal::test() { + this->m_smStateBasicInternal_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicInternal_getState(), SmState_BasicInternal::State::S); + ASSERT_EQ(this->m_smStateBasicInternal_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicInternal_action_a_history.getItemAt(0), + SmState_BasicInternal::Signal::__FPRIME_AC_INITIAL_TRANSITION); + this->m_smStateBasicInternal_action_a_history.clear(); + this->smStateBasicInternal_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicInternal_getState(), SmState_BasicInternal::State::S); + ASSERT_EQ(this->m_smStateBasicInternal_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicInternal_action_a_history.getItemAt(0), SmState_BasicInternal::Signal::s); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicInternal.fpp b/FppTest/state_machine/internal_instance/state/BasicInternal.fpp new file mode 100644 index 0000000000..4a1be360ec --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicInternal.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicInternal { + + state machine instance smStateBasicInternal: SmState.BasicInternal + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicInternal.hpp b/FppTest/state_machine/internal_instance/state/BasicInternal.hpp new file mode 100644 index 0000000000..7e3a871b3b --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicInternal.hpp @@ -0,0 +1,85 @@ +// ====================================================================== +// \title BasicInternal.hpp +// \author bocchino +// \brief hpp file for BasicInternal component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicInternal_HPP +#define FppTest_SmInstanceState_BasicInternal_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicInternalComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicInternal : public BasicInternalComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicInternal + using SmState_BasicInternal = FppTest_SmState_BasicInternal; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicInternal object + BasicInternal(const char* const compName //!< The component name + ); + + //! Destroy BasicInternal object + ~BasicInternal(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicInternal + //! + //! Action a + void FppTest_SmState_BasicInternal_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicInternal::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicInternal + SmHarness::History m_smStateBasicInternal_action_a_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicSelf.cpp b/FppTest/state_machine/internal_instance/state/BasicSelf.cpp new file mode 100644 index 0000000000..25dc3fcee0 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicSelf.cpp @@ -0,0 +1,58 @@ +// ====================================================================== +// \title BasicSelf.cpp +// \author bocchino +// \brief cpp file for BasicSelf component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicSelf.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicSelf::BasicSelf(const char* const compName) + : BasicSelfComponentBase(compName), m_smStateBasicSelf_action_a_history() {} + +BasicSelf::~BasicSelf() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicSelf::FppTest_SmState_BasicSelf_action_a(SmId smId, FppTest_SmState_BasicSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateBasicSelf); + this->m_smStateBasicSelf_action_a_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicSelf::test() { + this->m_smStateBasicSelf_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicSelf_getState(), SmState_BasicSelf::State::S); + ASSERT_EQ(this->m_smStateBasicSelf_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicSelf_action_a_history.getItemAt(0), + SmState_BasicSelf::Signal::__FPRIME_AC_INITIAL_TRANSITION); + this->m_smStateBasicSelf_action_a_history.clear(); + this->smStateBasicSelf_sendSignal_s(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicSelf_getState(), SmState_BasicSelf::State::S); + const FwSizeType expectedSize = 6; + ASSERT_EQ(this->m_smStateBasicSelf_action_a_history.getSize(), expectedSize); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(this->m_smStateBasicSelf_action_a_history.getItemAt(i), SmState_BasicSelf::Signal::s); + } +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicSelf.fpp b/FppTest/state_machine/internal_instance/state/BasicSelf.fpp new file mode 100644 index 0000000000..8855a4e3b5 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicSelf.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicSelf { + + state machine instance smStateBasicSelf: SmState.BasicSelf + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicSelf.hpp b/FppTest/state_machine/internal_instance/state/BasicSelf.hpp new file mode 100644 index 0000000000..f116902cbf --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicSelf.hpp @@ -0,0 +1,85 @@ +// ====================================================================== +// \title BasicSelf.hpp +// \author bocchino +// \brief hpp file for BasicSelf component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicSelf_HPP +#define FppTest_SmInstanceState_BasicSelf_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicSelfComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicSelf : public BasicSelfComponentBase { + private: + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicSelf + using SmState_BasicSelf = FppTest_SmState_BasicSelf; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicSelf object + BasicSelf(const char* const compName //!< The component name + ); + + //! Destroy BasicSelf object + ~BasicSelf(); + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicSelf + //! + //! Action a + void FppTest_SmState_BasicSelf_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicSelf::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicSelf + SmHarness::History m_smStateBasicSelf_action_a_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicString.cpp b/FppTest/state_machine/internal_instance/state/BasicString.cpp new file mode 100644 index 0000000000..f4b738c62c --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicString.cpp @@ -0,0 +1,69 @@ +// ====================================================================== +// \title BasicString.cpp +// \author bocchino +// \brief cpp file for BasicString component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal/state/FppConstantsAc.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicString.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicString ::BasicString(const char* const compName) + : BasicStringComponentBase(compName), + m_smStateBasicString_action_a_history(), + m_smStateBasicString_action_b_history() {} + +BasicString ::~BasicString() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicString ::FppTest_SmState_BasicString_action_a(SmId smId, FppTest_SmState_BasicString::Signal signal) { + this->m_smStateBasicString_action_a_history.push(signal); +} + +void BasicString ::FppTest_SmState_BasicString_action_b(SmId smId, + FppTest_SmState_BasicString::Signal signal, + const Fw::StringBase& value) { + this->m_smStateBasicString_action_b_history.push(signal, Fw::String(value)); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicString::test() { + this->m_smStateBasicString_action_a_history.clear(); + this->m_smStateBasicString_action_b_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicString_getState(), SmState_BasicString::State::S); + ASSERT_EQ(this->m_smStateBasicString_action_a_history.getSize(), 0); + Fw::String value; + SmHarness::Pick::string(value, SmState::basicStringSize); + this->smStateBasicString_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicString_getState(), SmState_BasicString::State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_smStateBasicString_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_smStateBasicString_action_a_history.getItemAt(i), SmState_BasicString::Signal::s); + } + ASSERT_EQ(this->m_smStateBasicString_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicString_action_b_history.getSignals().getItemAt(0), SmState_BasicString::Signal::s); + ASSERT_EQ(this->m_smStateBasicString_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicString.fpp b/FppTest/state_machine/internal_instance/state/BasicString.fpp new file mode 100644 index 0000000000..aa90835949 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicString.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicString { + + state machine instance smStateBasicString: SmState.BasicString + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicString.hpp b/FppTest/state_machine/internal_instance/state/BasicString.hpp new file mode 100644 index 0000000000..fb84220731 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicString.hpp @@ -0,0 +1,96 @@ +// ====================================================================== +// \title BasicString.hpp +// \author bocchino +// \brief hpp file for BasicString component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicString_HPP +#define FppTest_SmInstanceState_BasicString_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicStringComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicString : public BasicStringComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicString object + BasicString(const char* const compName //!< The component name + ); + + //! Destroy BasicString object + ~BasicString(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicString + using SmState_BasicString = FppTest_SmState_BasicString; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicString + //! + //! Action a + void FppTest_SmState_BasicString_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicString::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmState_BasicString + //! + //! Action b + void FppTest_SmState_BasicString_action_b(SmId smId, //!< The state machine id + FppTest_SmState_BasicString::Signal signal, //!< The signal + const Fw::StringBase& value //!< The value + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicString + SmHarness::History m_smStateBasicString_action_a_history; + + //! The history associated with action b of smStateBasicString + SmHarness::SignalValueHistory + m_smStateBasicString_action_b_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicTestAbsType.cpp b/FppTest/state_machine/internal_instance/state/BasicTestAbsType.cpp new file mode 100644 index 0000000000..40f48188f3 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestAbsType.cpp @@ -0,0 +1,69 @@ +// ====================================================================== +// \title BasicTestAbsType.cpp +// \author bocchino +// \brief cpp file for BasicTestAbsType component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicTestAbsType.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicTestAbsType ::BasicTestAbsType(const char* const compName) + : BasicTestAbsTypeComponentBase(compName), + m_smStateBasicTestAbsType_action_a_history(), + m_smStateBasicTestAbsType_action_b_history() {} + +BasicTestAbsType ::~BasicTestAbsType() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicTestAbsType ::FppTest_SmState_BasicTestAbsType_action_a(SmId smId, + FppTest_SmState_BasicTestAbsType::Signal signal) { + this->m_smStateBasicTestAbsType_action_a_history.push(signal); +} + +void BasicTestAbsType ::FppTest_SmState_BasicTestAbsType_action_b(SmId smId, + FppTest_SmState_BasicTestAbsType::Signal signal, + const SmHarness::TestAbsType& value) { + this->m_smStateBasicTestAbsType_action_b_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicTestAbsType::test() { + this->m_smStateBasicTestAbsType_action_a_history.clear(); + this->m_smStateBasicTestAbsType_action_b_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicTestAbsType_getState(), SmState_BasicTestAbsType::State::S); + ASSERT_EQ(this->m_smStateBasicTestAbsType_action_a_history.getSize(), 0); + const SmHarness::TestAbsType value = SmHarness::Pick::testAbsType(); + this->smStateBasicTestAbsType_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicTestAbsType_getState(), SmState_BasicTestAbsType::State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_smStateBasicTestAbsType_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_smStateBasicTestAbsType_action_a_history.getItemAt(i), SmState_BasicTestAbsType::Signal::s); + } + ASSERT_EQ(this->m_smStateBasicTestAbsType_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicTestAbsType_action_b_history.getSignals().getItemAt(0), + SmState_BasicTestAbsType::Signal::s); + ASSERT_EQ(this->m_smStateBasicTestAbsType_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicTestAbsType.fpp b/FppTest/state_machine/internal_instance/state/BasicTestAbsType.fpp new file mode 100644 index 0000000000..98c2764956 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestAbsType.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicTestAbsType { + + state machine instance smStateBasicTestAbsType: SmState.BasicTestAbsType + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicTestAbsType.hpp b/FppTest/state_machine/internal_instance/state/BasicTestAbsType.hpp new file mode 100644 index 0000000000..caf1deccfb --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestAbsType.hpp @@ -0,0 +1,96 @@ +// ====================================================================== +// \title BasicTestAbsType.hpp +// \author bocchino +// \brief hpp file for BasicTestAbsType component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicTestAbsType_HPP +#define FppTest_SmInstanceState_BasicTestAbsType_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestAbsTypeComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicTestAbsType : public BasicTestAbsTypeComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicTestAbsType object + BasicTestAbsType(const char* const compName //!< The component name + ); + + //! Destroy BasicTestAbsType object + ~BasicTestAbsType(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicTestAbsType + using SmState_BasicTestAbsType = FppTest_SmState_BasicTestAbsType; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicTestAbsType + //! + //! Action a + void FppTest_SmState_BasicTestAbsType_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestAbsType::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmState_BasicTestAbsType + //! + //! Action b + void FppTest_SmState_BasicTestAbsType_action_b(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestAbsType::Signal signal, //!< The signal + const SmHarness::TestAbsType& value //!< The value + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicTestAbsType + SmHarness::History m_smStateBasicTestAbsType_action_a_history; + + //! The history associated with action b of smStateBasicTestAbsType + SmHarness::SignalValueHistory + m_smStateBasicTestAbsType_action_b_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicTestArray.cpp b/FppTest/state_machine/internal_instance/state/BasicTestArray.cpp new file mode 100644 index 0000000000..0180f00eb3 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestArray.cpp @@ -0,0 +1,68 @@ +// ====================================================================== +// \title BasicTestArray.cpp +// \author bocchino +// \brief cpp file for BasicTestArray component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicTestArray.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicTestArray::BasicTestArray(const char* const compName) + : BasicTestArrayComponentBase(compName), + m_smStateBasicTestArray_action_a_history(), + m_smStateBasicTestArray_action_b_history() {} + +BasicTestArray::~BasicTestArray() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicTestArray::FppTest_SmState_BasicTestArray_action_a(SmId smId, FppTest_SmState_BasicTestArray::Signal signal) { + this->m_smStateBasicTestArray_action_a_history.push(signal); +} + +void BasicTestArray::FppTest_SmState_BasicTestArray_action_b(SmId smId, + FppTest_SmState_BasicTestArray::Signal signal, + const SmHarness::TestArray& value) { + this->m_smStateBasicTestArray_action_b_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicTestArray::test() { + this->m_smStateBasicTestArray_action_a_history.clear(); + this->m_smStateBasicTestArray_action_b_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicTestArray_getState(), SmState_BasicTestArray::State::S); + ASSERT_EQ(this->m_smStateBasicTestArray_action_a_history.getSize(), 0); + const SmHarness::TestArray value = SmHarness::Pick::testArray(); + this->smStateBasicTestArray_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicTestArray_getState(), SmState_BasicTestArray::State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_smStateBasicTestArray_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_smStateBasicTestArray_action_a_history.getItemAt(i), SmState_BasicTestArray::Signal::s); + } + ASSERT_EQ(this->m_smStateBasicTestArray_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicTestArray_action_b_history.getSignals().getItemAt(0), + SmState_BasicTestArray::Signal::s); + ASSERT_EQ(this->m_smStateBasicTestArray_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicTestArray.fpp b/FppTest/state_machine/internal_instance/state/BasicTestArray.fpp new file mode 100644 index 0000000000..2d73105ec4 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestArray.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicTestArray { + + state machine instance smStateBasicTestArray: SmState.BasicTestArray + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicTestArray.hpp b/FppTest/state_machine/internal_instance/state/BasicTestArray.hpp new file mode 100644 index 0000000000..6d04556a75 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestArray.hpp @@ -0,0 +1,96 @@ +// ====================================================================== +// \title BasicTestArray.hpp +// \author bocchino +// \brief hpp file for BasicTestArray component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicTestArray_HPP +#define FppTest_SmInstanceState_BasicTestArray_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestArrayComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicTestArray : public BasicTestArrayComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicTestArray object + BasicTestArray(const char* const compName //!< The component name + ); + + //! Destroy BasicTestArray object + ~BasicTestArray(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicTestArray + using SmState_BasicTestArray = FppTest_SmState_BasicTestArray; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicTestArray + //! + //! Action a + void FppTest_SmState_BasicTestArray_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestArray::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmState_BasicTestArray + //! + //! Action b + void FppTest_SmState_BasicTestArray_action_b(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestArray::Signal signal, //!< The signal + const SmHarness::TestArray& value //!< The value + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicTestArray + SmHarness::History m_smStateBasicTestArray_action_a_history; + + //! The history associated with action b of smStateBasicTestArray + SmHarness::SignalValueHistory + m_smStateBasicTestArray_action_b_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicTestEnum.cpp b/FppTest/state_machine/internal_instance/state/BasicTestEnum.cpp new file mode 100644 index 0000000000..cdcf5f1fbb --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestEnum.cpp @@ -0,0 +1,68 @@ +// ====================================================================== +// \title BasicTestEnum.cpp +// \author bocchino +// \brief cpp file for BasicTestEnum component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicTestEnum.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicTestEnum::BasicTestEnum(const char* const compName) + : BasicTestEnumComponentBase(compName), + m_smStateBasicTestEnum_action_a_history(), + m_smStateBasicTestEnum_action_b_history() {} + +BasicTestEnum::~BasicTestEnum() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicTestEnum::FppTest_SmState_BasicTestEnum_action_a(SmId smId, FppTest_SmState_BasicTestEnum::Signal signal) { + this->m_smStateBasicTestEnum_action_a_history.push(signal); +} + +void BasicTestEnum::FppTest_SmState_BasicTestEnum_action_b(SmId smId, + FppTest_SmState_BasicTestEnum::Signal signal, + const SmHarness::TestEnum& value) { + this->m_smStateBasicTestEnum_action_b_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicTestEnum::test() { + this->m_smStateBasicTestEnum_action_a_history.clear(); + this->m_smStateBasicTestEnum_action_b_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicTestEnum_getState(), SmState_BasicTestEnum::State::S); + ASSERT_EQ(this->m_smStateBasicTestEnum_action_a_history.getSize(), 0); + const SmHarness::TestEnum value = SmHarness::Pick::testEnum(); + this->smStateBasicTestEnum_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicTestEnum_getState(), SmState_BasicTestEnum::State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_smStateBasicTestEnum_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_smStateBasicTestEnum_action_a_history.getItemAt(i), SmState_BasicTestEnum::Signal::s); + } + ASSERT_EQ(this->m_smStateBasicTestEnum_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicTestEnum_action_b_history.getSignals().getItemAt(0), + SmState_BasicTestEnum::Signal::s); + ASSERT_EQ(this->m_smStateBasicTestEnum_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicTestEnum.fpp b/FppTest/state_machine/internal_instance/state/BasicTestEnum.fpp new file mode 100644 index 0000000000..4906530d4f --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestEnum.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicTestEnum { + + state machine instance smStateBasicTestEnum: SmState.BasicTestEnum + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicTestEnum.hpp b/FppTest/state_machine/internal_instance/state/BasicTestEnum.hpp new file mode 100644 index 0000000000..e494b9fef6 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestEnum.hpp @@ -0,0 +1,96 @@ +// ====================================================================== +// \title BasicTestEnum.hpp +// \author bocchino +// \brief hpp file for BasicTestEnum component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicTestEnum_HPP +#define FppTest_SmInstanceState_BasicTestEnum_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestEnumComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicTestEnum : public BasicTestEnumComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicTestEnum object + BasicTestEnum(const char* const compName //!< The component name + ); + + //! Destroy BasicTestEnum object + ~BasicTestEnum(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicTestEnum + using SmState_BasicTestEnum = FppTest_SmState_BasicTestEnum; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicTestEnum + //! + //! Action a + void FppTest_SmState_BasicTestEnum_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestEnum::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmState_BasicTestEnum + //! + //! Action b + void FppTest_SmState_BasicTestEnum_action_b(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestEnum::Signal signal, //!< The signal + const SmHarness::TestEnum& value //!< The value + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicTestEnum + SmHarness::History m_smStateBasicTestEnum_action_a_history; + + //! The history associated with action b of smStateBasicTestEnum + SmHarness::SignalValueHistory + m_smStateBasicTestEnum_action_b_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicTestStruct.cpp b/FppTest/state_machine/internal_instance/state/BasicTestStruct.cpp new file mode 100644 index 0000000000..91be6c4c49 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestStruct.cpp @@ -0,0 +1,69 @@ +// ====================================================================== +// \title BasicTestStruct.cpp +// \author bocchino +// \brief cpp file for BasicTestStruct component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicTestStruct.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicTestStruct::BasicTestStruct(const char* const compName) + : BasicTestStructComponentBase(compName), + m_smStateBasicTestStruct_action_a_history(), + m_smStateBasicTestStruct_action_b_history() {} + +BasicTestStruct::~BasicTestStruct() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicTestStruct::FppTest_SmState_BasicTestStruct_action_a(SmId smId, + FppTest_SmState_BasicTestStruct::Signal signal) { + this->m_smStateBasicTestStruct_action_a_history.push(signal); +} + +void BasicTestStruct::FppTest_SmState_BasicTestStruct_action_b(SmId smId, + FppTest_SmState_BasicTestStruct::Signal signal, + const SmHarness::TestStruct& value) { + this->m_smStateBasicTestStruct_action_b_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicTestStruct::test() { + this->m_smStateBasicTestStruct_action_a_history.clear(); + this->m_smStateBasicTestStruct_action_b_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicTestStruct_getState(), SmState_BasicTestStruct::State::S); + ASSERT_EQ(this->m_smStateBasicTestStruct_action_a_history.getSize(), 0); + const SmHarness::TestStruct value = SmHarness::Pick::testStruct(); + this->smStateBasicTestStruct_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicTestStruct_getState(), SmState_BasicTestStruct::State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_smStateBasicTestStruct_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_smStateBasicTestStruct_action_a_history.getItemAt(i), SmState_BasicTestStruct::Signal::s); + } + ASSERT_EQ(this->m_smStateBasicTestStruct_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicTestStruct_action_b_history.getSignals().getItemAt(0), + SmState_BasicTestStruct::Signal::s); + ASSERT_EQ(this->m_smStateBasicTestStruct_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicTestStruct.fpp b/FppTest/state_machine/internal_instance/state/BasicTestStruct.fpp new file mode 100644 index 0000000000..50ca829591 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestStruct.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicTestStruct { + + state machine instance smStateBasicTestStruct: SmState.BasicTestStruct + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicTestStruct.hpp b/FppTest/state_machine/internal_instance/state/BasicTestStruct.hpp new file mode 100644 index 0000000000..33758bdbbc --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicTestStruct.hpp @@ -0,0 +1,96 @@ +// ====================================================================== +// \title BasicTestStruct.hpp +// \author bocchino +// \brief hpp file for BasicTestStruct component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicTestStruct_HPP +#define FppTest_SmInstanceState_BasicTestStruct_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestStructComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicTestStruct : public BasicTestStructComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicTestStruct object + BasicTestStruct(const char* const compName //!< The component name + ); + + //! Destroy BasicTestStruct object + ~BasicTestStruct(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicTestStruct + using SmState_BasicTestStruct = FppTest_SmState_BasicTestStruct; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicTestStruct + //! + //! Action a + void FppTest_SmState_BasicTestStruct_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestStruct::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmState_BasicTestStruct + //! + //! Action b + void FppTest_SmState_BasicTestStruct_action_b(SmId smId, //!< The state machine id + FppTest_SmState_BasicTestStruct::Signal signal, //!< The signal + const SmHarness::TestStruct& value //!< The value + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicTestStruct + SmHarness::History m_smStateBasicTestStruct_action_a_history; + + //! The history associated with action b of smStateBasicTestStruct + SmHarness::SignalValueHistory + m_smStateBasicTestStruct_action_b_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/BasicU32.cpp b/FppTest/state_machine/internal_instance/state/BasicU32.cpp new file mode 100644 index 0000000000..345a42da25 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicU32.cpp @@ -0,0 +1,63 @@ +// ====================================================================== +// \title BasicU32.cpp +// \author bocchino +// \brief cpp file for BasicU32 component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/BasicU32.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +BasicU32::BasicU32(const char* const compName) + : BasicU32ComponentBase(compName), m_smStateBasicU32_action_a_history(), m_smStateBasicU32_action_b_history() {} + +BasicU32::~BasicU32() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void BasicU32::FppTest_SmState_BasicU32_action_a(SmId smId, FppTest_SmState_BasicU32::Signal signal) { + this->m_smStateBasicU32_action_a_history.push(signal); +} + +void BasicU32::FppTest_SmState_BasicU32_action_b(SmId smId, FppTest_SmState_BasicU32::Signal signal, U32 value) { + this->m_smStateBasicU32_action_b_history.push(signal, value); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void BasicU32::test() { + this->m_smStateBasicU32_action_a_history.clear(); + this->m_smStateBasicU32_action_b_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateBasicU32_getState(), SmState_BasicU32::State::S); + ASSERT_EQ(this->m_smStateBasicU32_action_a_history.getSize(), 0); + const U32 value = STest::Pick::any(); + this->smStateBasicU32_sendSignal_s(value); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateBasicU32_getState(), SmState_BasicU32::State::T); + const FwSizeType expectedASize = 5; + ASSERT_EQ(this->m_smStateBasicU32_action_a_history.getSize(), expectedASize); + for (FwSizeType i = 0; i < expectedASize; i++) { + ASSERT_EQ(this->m_smStateBasicU32_action_a_history.getItemAt(i), SmState_BasicU32::Signal::s); + } + ASSERT_EQ(this->m_smStateBasicU32_action_b_history.getSize(), 1); + ASSERT_EQ(this->m_smStateBasicU32_action_b_history.getSignals().getItemAt(0), SmState_BasicU32::Signal::s); + ASSERT_EQ(this->m_smStateBasicU32_action_b_history.getValues().getItemAt(0), value); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/BasicU32.fpp b/FppTest/state_machine/internal_instance/state/BasicU32.fpp new file mode 100644 index 0000000000..e31035c3ac --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicU32.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component BasicU32 { + + state machine instance smStateBasicU32: SmState.BasicU32 + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/BasicU32.hpp b/FppTest/state_machine/internal_instance/state/BasicU32.hpp new file mode 100644 index 0000000000..3b4691c86f --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/BasicU32.hpp @@ -0,0 +1,95 @@ +// ====================================================================== +// \title BasicU32.hpp +// \author bocchino +// \brief hpp file for BasicU32 component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_BasicU32_HPP +#define FppTest_SmInstanceState_BasicU32_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicU32ComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class BasicU32 : public BasicU32ComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct BasicU32 object + BasicU32(const char* const compName //!< The component name + ); + + //! Destroy BasicU32 object + ~BasicU32(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_BasicU32 + using SmState_BasicU32 = FppTest_SmState_BasicU32; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_BasicU32 + //! + //! Action a + void FppTest_SmState_BasicU32_action_a(SmId smId, //!< The state machine id + FppTest_SmState_BasicU32::Signal signal //!< The signal + ) override; + + //! Implementation for action b of state machine FppTest_SmState_BasicU32 + //! + //! Action b + void FppTest_SmState_BasicU32_action_b(SmId smId, //!< The state machine id + FppTest_SmState_BasicU32::Signal signal, //!< The signal + U32 value //!< The value + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Run the test + void test(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateBasicU32 + SmHarness::History m_smStateBasicU32_action_a_history; + + //! The history associated with action b of smStateBasicU32 + SmHarness::SignalValueHistory m_smStateBasicU32_action_b_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/CMakeLists.txt b/FppTest/state_machine/internal_instance/state/CMakeLists.txt new file mode 100644 index 0000000000..18714b3408 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/CMakeLists.txt @@ -0,0 +1,54 @@ +set(SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuard.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardString.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestAbsType.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestArray.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestEnum.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestStruct.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardU32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicInternal.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicSelf.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicString.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestAbsType.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestArray.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestEnum.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestStruct.fpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Internal.fpp" + "${CMAKE_CURRENT_LIST_DIR}/Polymorphism.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChild.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChoice.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToSelf.fpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToState.fpp" +) +set(MOD_DEPS FppTest/state_machine/internal/harness) +register_fprime_module() + +set(UT_SOURCE_FILES + "${CMAKE_CURRENT_LIST_DIR}/Basic.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuard.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardString.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestAbsType.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestArray.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestEnum.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardTestStruct.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicGuardU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicInternal.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicSelf.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicString.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestAbsType.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestArray.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestEnum.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicTestStruct.cpp" + "${CMAKE_CURRENT_LIST_DIR}/BasicU32.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Internal.cpp" + "${CMAKE_CURRENT_LIST_DIR}/Polymorphism.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChild.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToChoice.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToSelf.cpp" + "${CMAKE_CURRENT_LIST_DIR}/StateToState.cpp" + "${CMAKE_CURRENT_LIST_DIR}/main.cpp" +) +set(UT_MOD_DEPS STest) +register_fprime_ut() diff --git a/FppTest/state_machine/internal_instance/state/Internal.cpp b/FppTest/state_machine/internal_instance/state/Internal.cpp new file mode 100644 index 0000000000..4a93c3a3e8 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Internal.cpp @@ -0,0 +1,89 @@ +// ====================================================================== +// \title Internal.cpp +// \author bocchino +// \brief cpp file for Internal component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/Internal.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Internal::Internal(const char* const compName) + : InternalComponentBase(compName), m_smStateInternal_action_a_history() {} + +Internal::~Internal() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void Internal::FppTest_SmState_Internal_action_a(SmId smId, FppTest_SmState_Internal::Signal signal) { + ASSERT_EQ(smId, SmId::smStateInternal); + this->m_smStateInternal_action_a_history.push(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Internal::testInit() { + this->m_smStateInternal_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S2); + ASSERT_EQ(this->m_smStateInternal_action_a_history.getSize(), 0); +} + +void Internal::testS2_internal() { + this->m_smStateInternal_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S2); + this->smStateInternal_sendSignal_S1_internal(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S2); + ASSERT_EQ(this->m_smStateInternal_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateInternal_action_a_history.getItemAt(0), SmState_Internal::Signal::S1_internal); +} + +void Internal::testS2_to_S3() { + this->m_smStateInternal_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S2); + this->smStateInternal_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S3); + ASSERT_EQ(this->m_smStateInternal_action_a_history.getSize(), 0); +} + +void Internal::testS3_internal() { + this->m_smStateInternal_action_a_history.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S2); + { + this->smStateInternal_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S3); + } + { + this->smStateInternal_sendSignal_S1_internal(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(smStateInternal_getState(), SmState_Internal::State::S1_S3); + ASSERT_EQ(this->m_smStateInternal_action_a_history.getSize(), 1); + ASSERT_EQ(this->m_smStateInternal_action_a_history.getItemAt(0), SmState_Internal::Signal::S1_internal); + } +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/Internal.fpp b/FppTest/state_machine/internal_instance/state/Internal.fpp new file mode 100644 index 0000000000..54fdfe2638 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Internal.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component Internal { + + state machine instance smStateInternal: SmState.Internal + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/Internal.hpp b/FppTest/state_machine/internal_instance/state/Internal.hpp new file mode 100644 index 0000000000..42bf5af363 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Internal.hpp @@ -0,0 +1,93 @@ +// ====================================================================== +// \title Internal.hpp +// \author bocchino +// \brief hpp file for Internal component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_Internal_HPP +#define FppTest_SmInstanceState_Internal_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/InternalComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class Internal : public InternalComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Internal object + Internal(const char* const compName //!< The component name + ); + + //! Destroy Internal object + ~Internal(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_Internal + using SmState_Internal = FppTest_SmState_Internal; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action a of state machine FppTest_SmState_Internal + //! + //! Action a + void FppTest_SmState_Internal_action_a(SmId smId, //!< The state machine id + FppTest_SmState_Internal::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test initial transition + void testInit(); + + //! Test internal transition in S2 + void testS2_internal(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test internal transition in S3 + void testS3_internal(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The history associated with action a of smStateInternal + SmHarness::History m_smStateInternal_action_a_history; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/Polymorphism.cpp b/FppTest/state_machine/internal_instance/state/Polymorphism.cpp new file mode 100644 index 0000000000..114b04ae47 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Polymorphism.cpp @@ -0,0 +1,69 @@ +// ====================================================================== +// \title Polymorphism.cpp +// \author bocchino +// \brief cpp file for Polymorphism component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/Polymorphism.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +Polymorphism::Polymorphism(const char* const compName) : PolymorphismComponentBase(compName) {} + +Polymorphism::~Polymorphism() {} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void Polymorphism::testInit() { + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S1_S2); +} + +void Polymorphism::testS2_poly() { + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S1_S2); + this->smStatePolymorphism_sendSignal_poly(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S4); +} + +void Polymorphism::testS2_to_S3() { + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S1_S2); + this->smStatePolymorphism_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S1_S3); +} + +void Polymorphism::testS3_poly() { + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S1_S2); + { + this->smStatePolymorphism_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S1_S3); + } + { + this->smStatePolymorphism_sendSignal_poly(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStatePolymorphism_getState(), SmState_Polymorphism::State::S5); + } +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/Polymorphism.fpp b/FppTest/state_machine/internal_instance/state/Polymorphism.fpp new file mode 100644 index 0000000000..1a4f10106f --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Polymorphism.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component Polymorphism { + + state machine instance smStatePolymorphism: SmState.Polymorphism + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/Polymorphism.hpp b/FppTest/state_machine/internal_instance/state/Polymorphism.hpp new file mode 100644 index 0000000000..4b0e23fbd1 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/Polymorphism.hpp @@ -0,0 +1,70 @@ +// ====================================================================== +// \title Polymorphism.hpp +// \author bocchino +// \brief hpp file for Polymorphism component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_Polymorphism_HPP +#define FppTest_SmInstanceState_Polymorphism_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/PolymorphismComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class Polymorphism : public PolymorphismComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct Polymorphism object + Polymorphism(const char* const compName //!< The component name + ); + + //! Destroy Polymorphism object + ~Polymorphism(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_Polymorphism + using SmState_Polymorphism = FppTest_SmState_Polymorphism; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test initial transition + void testInit(); + + //! Test polymorphic transition in S2 + void testS2_poly(); + + //! Test transition from S2 to S3 + void testS2_to_S3(); + + //! Test polymorphic transition in S3 + void testS3_poly(); +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/StateToChild.cpp b/FppTest/state_machine/internal_instance/state/StateToChild.cpp new file mode 100644 index 0000000000..3bfaaa7104 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToChild.cpp @@ -0,0 +1,137 @@ +// ====================================================================== +// \title StateToChild.cpp +// \author bocchino +// \brief cpp file for StateToChild component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/StateToChild.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +StateToChild::StateToChild(const char* const compName) + : StateToChildComponentBase(compName), m_smStateStateToChild_actionHistory() {} + +StateToChild::~StateToChild() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void StateToChild::FppTest_SmState_StateToChild_action_exitS2(SmId smId, FppTest_SmState_StateToChild::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChild); + this->m_smStateStateToChild_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToChild::FppTest_SmState_StateToChild_action_exitS3(SmId smId, FppTest_SmState_StateToChild::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChild); + this->m_smStateStateToChild_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToChild::FppTest_SmState_StateToChild_action_a(SmId smId, FppTest_SmState_StateToChild::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChild); + this->m_smStateStateToChild_actionHistory.push(signal, ActionId::A); +} + +void StateToChild::FppTest_SmState_StateToChild_action_enterS2(SmId smId, FppTest_SmState_StateToChild::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChild); + this->m_smStateStateToChild_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToChild::FppTest_SmState_StateToChild_action_enterS3(SmId smId, FppTest_SmState_StateToChild::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChild); + this->m_smStateStateToChild_actionHistory.push(signal, ActionId::ENTER_S3); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void StateToChild::testInit() { + this->m_smStateStateToChild_actionHistory.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateStateToChild_getState(), SmState_StateToChild::State::S1_S2); + ASSERT_EQ(this->m_smStateStateToChild_actionHistory.getSize(), 1); + const auto& signals = this->m_smStateStateToChild_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChild_actionHistory.getValues(); + ASSERT_EQ(signals.getItemAt(0), SmState_StateToChild::Signal::__FPRIME_AC_INITIAL_TRANSITION); + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S2); +} + +void StateToChild::testS2_to_S2() { + this->m_smStateStateToChild_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToChild_actionHistory.clear(); + this->smStateStateToChild_sendSignal_S1_to_S2(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToChild_getState(), SmState_StateToChild::State::S1_S2); + const FwSizeType expectedSize = 3; + ASSERT_EQ(this->m_smStateStateToChild_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChild_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChild_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChild::Signal::S1_to_S2); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::A); + ASSERT_EQ(actions.getItemAt(2), ActionId::ENTER_S2); +} + +void StateToChild::testS2_to_S3() { + this->m_smStateStateToChild_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToChild_actionHistory.clear(); + this->smStateStateToChild_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToChild_getState(), SmState_StateToChild::State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_smStateStateToChild_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChild_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChild_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChild::Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToChild::testS3_to_S2() { + this->m_smStateStateToChild_actionHistory.clear(); + this->init(queueDepth, instanceId); + { + this->m_smStateStateToChild_actionHistory.clear(); + this->smStateStateToChild_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToChild_getState(), SmState_StateToChild::State::S1_S3); + } + { + this->m_smStateStateToChild_actionHistory.clear(); + this->smStateStateToChild_sendSignal_S1_to_S2(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToChild_getState(), SmState_StateToChild::State::S1_S2); + } + const FwSizeType expectedSize = 3; + ASSERT_EQ(this->m_smStateStateToChild_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChild_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChild_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChild::Signal::S1_to_S2); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::A); + ASSERT_EQ(actions.getItemAt(2), ActionId::ENTER_S2); +} +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/StateToChild.fpp b/FppTest/state_machine/internal_instance/state/StateToChild.fpp new file mode 100644 index 0000000000..dbaa35ec84 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToChild.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component StateToChild { + + state machine instance smStateStateToChild: SmState.StateToChild + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/StateToChild.hpp b/FppTest/state_machine/internal_instance/state/StateToChild.hpp new file mode 100644 index 0000000000..afe1245e1b --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToChild.hpp @@ -0,0 +1,125 @@ +// ====================================================================== +// \title StateToChild.hpp +// \author bocchino +// \brief hpp file for StateToChild component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_StateToChild_HPP +#define FppTest_SmInstanceState_StateToChild_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToChildComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class StateToChild : public StateToChildComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct StateToChild object + StateToChild(const char* const compName //!< The component name + ); + + //! Destroy StateToChild object + ~StateToChild(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_StateToChild + using SmState_StateToChild = FppTest_SmState_StateToChild; + + //! Action IDs + enum class ActionId { EXIT_S2, EXIT_S3, A, ENTER_S2, ENTER_S3 }; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action exitS2 of state machine FppTest_SmState_StateToChild + //! + //! Exit S2 + void FppTest_SmState_StateToChild_action_exitS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToChild::Signal signal //!< The signal + ) override; + + //! Implementation for action exitS3 of state machine FppTest_SmState_StateToChild + //! + //! Exit S3 + void FppTest_SmState_StateToChild_action_exitS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToChild::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmState_StateToChild + //! + //! Action a + void FppTest_SmState_StateToChild_action_a(SmId smId, //!< The state machine id + FppTest_SmState_StateToChild::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS2 of state machine FppTest_SmState_StateToChild + //! + //! Enter S2 + void FppTest_SmState_StateToChild_action_enterS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToChild::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS3 of state machine FppTest_SmState_StateToChild + //! + //! Enter S3 + void FppTest_SmState_StateToChild_action_enterS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToChild::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test initial transition + void testInit(); + + //! Test transition from S2 to S2 + void testS2_to_S2(); + + //! Test transition from S2 to S3 + void testS2_to_S3(); + + //! Test transition from S3 to S2 + void testS3_to_S2(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The action history for smStateStateToChild + SmHarness::SignalValueHistory + m_smStateStateToChild_actionHistory; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/StateToChoice.cpp b/FppTest/state_machine/internal_instance/state/StateToChoice.cpp new file mode 100644 index 0000000000..e7edb8163e --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToChoice.cpp @@ -0,0 +1,232 @@ +// ====================================================================== +// \title StateToChoice.cpp +// \author bocchino +// \brief cpp file for StateToChoice component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/StateToChoice.hpp" +#include "Fw/Types/Assert.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +StateToChoice::StateToChoice(const char* const compName) + : StateToChoiceComponentBase(compName), m_smStateStateToChoice_actionHistory(), m_smStateStateToChoice_guard_g() {} + +StateToChoice::~StateToChoice() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void StateToChoice::FppTest_SmState_StateToChoice_action_exitS1(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void StateToChoice::FppTest_SmState_StateToChoice_action_exitS2(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToChoice::FppTest_SmState_StateToChoice_action_exitS3(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToChoice::FppTest_SmState_StateToChoice_action_a(SmId smId, FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::A); +} + +void StateToChoice::FppTest_SmState_StateToChoice_action_enterS1(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::ENTER_S1); +} + +void StateToChoice::FppTest_SmState_StateToChoice_action_enterS2(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToChoice::FppTest_SmState_StateToChoice_action_enterS3(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::ENTER_S3); +} + +void StateToChoice::FppTest_SmState_StateToChoice_action_enterS4(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToChoice); + this->m_smStateStateToChoice_actionHistory.push(signal, ActionId::ENTER_S4); +} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine guards +// ---------------------------------------------------------------------- + +bool StateToChoice ::FppTest_SmState_StateToChoice_guard_g(SmId smId, + FppTest_SmState_StateToChoice::Signal signal) const { + FW_ASSERT(smId == SmId::smStateStateToChoice, static_cast(smId)); + return this->m_smStateStateToChoice_guard_g.call(signal); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void StateToChoice::testInit() { + this->m_smStateStateToChoice_actionHistory.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateStateToChoice_getState(), SmState_StateToChoice::State::S1_S2); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_smStateStateToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChoice_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChoice_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChoice::Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S2); +} + +void StateToChoice::testS2_to_C() { + this->m_smStateStateToChoice_actionHistory.clear(); + this->m_smStateStateToChoice_guard_g.reset(); + this->m_smStateStateToChoice_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + this->m_smStateStateToChoice_actionHistory.clear(); + this->smStateStateToChoice_sendSignal_S1_to_C(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToChoice_getState(), SmState_StateToChoice::State::S4_S5); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_smStateStateToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChoice_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChoice_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChoice::Signal::S1_to_C); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +void StateToChoice::testS2_to_S3() { + this->m_smStateStateToChoice_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToChoice_actionHistory.clear(); + this->smStateStateToChoice_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToChoice_getState(), SmState_StateToChoice::State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_smStateStateToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChoice_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChoice_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChoice::Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToChoice::testS2_to_S4() { + this->m_smStateStateToChoice_actionHistory.clear(); + this->m_smStateStateToChoice_guard_g.reset(); + this->m_smStateStateToChoice_guard_g.setReturnValue(true); + this->init(queueDepth, instanceId); + this->m_smStateStateToChoice_actionHistory.clear(); + this->smStateStateToChoice_sendSignal_S1_to_S4(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToChoice_getState(), SmState_StateToChoice::State::S4_S5); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_smStateStateToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChoice_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChoice_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChoice::Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +void StateToChoice::testS3_to_C() { + this->m_smStateStateToChoice_actionHistory.clear(); + this->m_smStateStateToChoice_guard_g.reset(); + this->init(queueDepth, instanceId); + { + this->m_smStateStateToChoice_actionHistory.clear(); + this->smStateStateToChoice_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + { + this->m_smStateStateToChoice_actionHistory.clear(); + this->smStateStateToChoice_sendSignal_S1_to_C(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + ASSERT_EQ(this->smStateStateToChoice_getState(), SmState_StateToChoice::State::S4_S6); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_smStateStateToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChoice_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChoice_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChoice::Signal::S1_to_C); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +void StateToChoice::testS3_to_S4() { + this->m_smStateStateToChoice_actionHistory.clear(); + this->m_smStateStateToChoice_guard_g.reset(); + this->init(queueDepth, instanceId); + { + this->m_smStateStateToChoice_actionHistory.clear(); + this->smStateStateToChoice_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + { + this->m_smStateStateToChoice_actionHistory.clear(); + this->smStateStateToChoice_sendSignal_S1_to_S4(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + ASSERT_EQ(this->smStateStateToChoice_getState(), SmState_StateToChoice::State::S4_S6); + const FwSizeType expectedSize = 4; + ASSERT_EQ(this->m_smStateStateToChoice_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToChoice_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToChoice_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToChoice::Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/StateToChoice.fpp b/FppTest/state_machine/internal_instance/state/StateToChoice.fpp new file mode 100644 index 0000000000..9159d2ae0f --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToChoice.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component StateToChoice { + + state machine instance smStateStateToChoice: SmState.StateToChoice + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/StateToChoice.hpp b/FppTest/state_machine/internal_instance/state/StateToChoice.hpp new file mode 100644 index 0000000000..999cbda307 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToChoice.hpp @@ -0,0 +1,167 @@ +// ====================================================================== +// \title StateToChoice.hpp +// \author bocchino +// \brief hpp file for StateToChoice component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_StateToChoice_HPP +#define FppTest_SmInstanceState_StateToChoice_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToChoiceComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class StateToChoice : public StateToChoiceComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct StateToChoice object + StateToChoice(const char* const compName //!< The component name + ); + + //! Destroy StateToChoice object + ~StateToChoice(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_StateToChoice + using SmState_StateToChoice = FppTest_SmState_StateToChoice; + + //! Action IDs + enum class ActionId { EXIT_S1, EXIT_S2, EXIT_S3, A, ENTER_S1, ENTER_S2, ENTER_S3, ENTER_S4 }; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + + //! Implementation for action exitS1 of state machine FppTest_SmState_StateToChoice + //! + //! Exit S1 + void FppTest_SmState_StateToChoice_action_exitS1(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action exitS2 of state machine FppTest_SmState_StateToChoice + //! + //! Exit S2 + void FppTest_SmState_StateToChoice_action_exitS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action exitS3 of state machine FppTest_SmState_StateToChoice + //! + //! Exit S3 + void FppTest_SmState_StateToChoice_action_exitS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmState_StateToChoice + //! + //! Action a + void FppTest_SmState_StateToChoice_action_a(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS1 of state machine FppTest_SmState_StateToChoice + //! + //! Enter S1 + void FppTest_SmState_StateToChoice_action_enterS1(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS2 of state machine FppTest_SmState_StateToChoice + //! + //! Enter S2 + void FppTest_SmState_StateToChoice_action_enterS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS3 of state machine FppTest_SmState_StateToChoice + //! + //! Enter S3 + void FppTest_SmState_StateToChoice_action_enterS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS4 of state machine FppTest_SmState_StateToChoice + //! + //! Enter S4 + void FppTest_SmState_StateToChoice_action_enterS4(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) override; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine guards + // ---------------------------------------------------------------------- + + //! Implementation for guard g of state machine FppTest_SmState_StateToChoice + //! + //! Guard g + bool FppTest_SmState_StateToChoice_guard_g(SmId smId, //!< The state machine id + FppTest_SmState_StateToChoice::Signal signal //!< The signal + ) const override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test initial transition + void testInit(); + + //! Test transition S2 to C + void testS2_to_C(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test transition S2 to S4 + void testS2_to_S4(); + + //! Test transition S3 to C + void testS3_to_C(); + + //! Test transition S3 to S4 + void testS3_to_S4(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The action history for SmStateStateToChoice + SmHarness::SignalValueHistory + m_smStateStateToChoice_actionHistory; + + //! The guard g for SmStateStateToChoice + SmHarness::NoArgGuard m_smStateStateToChoice_guard_g; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/StateToSelf.cpp b/FppTest/state_machine/internal_instance/state/StateToSelf.cpp new file mode 100644 index 0000000000..f74ca1706c --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToSelf.cpp @@ -0,0 +1,155 @@ +// ====================================================================== +// \title StateToSelf.cpp +// \author bocchino +// \brief cpp file for StateToSelf component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/StateToSelf.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +StateToSelf::StateToSelf(const char* const compName) + : StateToSelfComponentBase(compName), m_smStateStateToSelf_actionHistory() {} + +StateToSelf::~StateToSelf() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void StateToSelf::FppTest_SmState_StateToSelf_action_exitS1(SmId smId, FppTest_SmState_StateToSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToSelf); + this->m_smStateStateToSelf_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void StateToSelf::FppTest_SmState_StateToSelf_action_exitS2(SmId smId, FppTest_SmState_StateToSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToSelf); + this->m_smStateStateToSelf_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToSelf::FppTest_SmState_StateToSelf_action_exitS3(SmId smId, FppTest_SmState_StateToSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToSelf); + this->m_smStateStateToSelf_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToSelf::FppTest_SmState_StateToSelf_action_a(SmId smId, FppTest_SmState_StateToSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToSelf); + this->m_smStateStateToSelf_actionHistory.push(signal, ActionId::A); +} + +void StateToSelf::FppTest_SmState_StateToSelf_action_enterS1(SmId smId, FppTest_SmState_StateToSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToSelf); + this->m_smStateStateToSelf_actionHistory.push(signal, ActionId::ENTER_S1); +} + +void StateToSelf::FppTest_SmState_StateToSelf_action_enterS2(SmId smId, FppTest_SmState_StateToSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToSelf); + this->m_smStateStateToSelf_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToSelf::FppTest_SmState_StateToSelf_action_enterS3(SmId smId, FppTest_SmState_StateToSelf::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToSelf); + this->m_smStateStateToSelf_actionHistory.push(signal, ActionId::ENTER_S3); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void StateToSelf::testInit() { + this->m_smStateStateToSelf_actionHistory.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateStateToSelf_getState(), SmState_StateToSelf::State::S1_S2); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_smStateStateToSelf_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToSelf_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToSelf_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToSelf::Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S2); +} + +void StateToSelf::testS2_to_S1() { + this->m_smStateStateToSelf_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToSelf_actionHistory.clear(); + this->smStateStateToSelf_sendSignal_S1_to_S1(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToSelf_getState(), SmState_StateToSelf::State::S1_S2); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_smStateStateToSelf_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToSelf_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToSelf_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToSelf::Signal::S1_to_S1); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S2); +} + +void StateToSelf::testS2_to_S3() { + this->m_smStateStateToSelf_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToSelf_actionHistory.clear(); + this->smStateStateToSelf_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToSelf_getState(), SmState_StateToSelf::State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_smStateStateToSelf_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToSelf_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToSelf_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToSelf::Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToSelf::testS3_to_S1() { + this->m_smStateStateToSelf_actionHistory.clear(); + this->init(queueDepth, instanceId); + { + this->m_smStateStateToSelf_actionHistory.clear(); + this->smStateStateToSelf_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + { + this->m_smStateStateToSelf_actionHistory.clear(); + this->smStateStateToSelf_sendSignal_S1_to_S1(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + ASSERT_EQ(this->smStateStateToSelf_getState(), SmState_StateToSelf::State::S1_S2); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_smStateStateToSelf_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToSelf_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToSelf_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToSelf::Signal::S1_to_S1); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S2); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/StateToSelf.fpp b/FppTest/state_machine/internal_instance/state/StateToSelf.fpp new file mode 100644 index 0000000000..fe5fc3695f --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToSelf.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component StateToSelf { + + state machine instance smStateStateToSelf: SmState.StateToSelf + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/StateToSelf.hpp b/FppTest/state_machine/internal_instance/state/StateToSelf.hpp new file mode 100644 index 0000000000..aca1a59bc1 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToSelf.hpp @@ -0,0 +1,138 @@ +// ====================================================================== +// \title StateToSelf.hpp +// \author bocchino +// \brief hpp file for StateToSelf component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_StateToSelf_HPP +#define FppTest_SmInstanceState_StateToSelf_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToSelfComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class StateToSelf : public StateToSelfComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct StateToSelf object + StateToSelf(const char* const compName //!< The component name + ); + + //! Destroy StateToSelf object + ~StateToSelf(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_StateToSelf + using SmState_StateToSelf = FppTest_SmState_StateToSelf; + + //! Action IDs + enum class ActionId { EXIT_S1, EXIT_S2, EXIT_S3, A, ENTER_S1, ENTER_S2, ENTER_S3 }; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + //! Implementation for action exitS1 of state machine FppTest_SmState_StateToSelf + //! + //! Exit S1 + void FppTest_SmState_StateToSelf_action_exitS1(SmId smId, //!< The state machine id + FppTest_SmState_StateToSelf::Signal signal //!< The signal + ) override; + + //! Implementation for action exitS2 of state machine FppTest_SmState_StateToSelf + //! + //! Exit S2 + void FppTest_SmState_StateToSelf_action_exitS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToSelf::Signal signal //!< The signal + ) override; + + //! Implementation for action exitS3 of state machine FppTest_SmState_StateToSelf + //! + //! Exit S3 + void FppTest_SmState_StateToSelf_action_exitS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToSelf::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmState_StateToSelf + //! + //! Action a + void FppTest_SmState_StateToSelf_action_a(SmId smId, //!< The state machine id + FppTest_SmState_StateToSelf::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS1 of state machine FppTest_SmState_StateToSelf + //! + //! Enter S1 + void FppTest_SmState_StateToSelf_action_enterS1(SmId smId, //!< The state machine id + FppTest_SmState_StateToSelf::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS2 of state machine FppTest_SmState_StateToSelf + //! + //! Enter S2 + void FppTest_SmState_StateToSelf_action_enterS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToSelf::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS3 of state machine FppTest_SmState_StateToSelf + //! + //! Enter S3 + void FppTest_SmState_StateToSelf_action_enterS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToSelf::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test initial transition + void testInit(); + + //! Test transition S2 to S1 + void testS2_to_S1(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test transition S3 to S1 + void testS3_to_S1(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The action history for smStateStateToSelf + SmHarness::SignalValueHistory + m_smStateStateToSelf_actionHistory; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/StateToState.cpp b/FppTest/state_machine/internal_instance/state/StateToState.cpp new file mode 100644 index 0000000000..cfb782ec1c --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToState.cpp @@ -0,0 +1,217 @@ +// ====================================================================== +// \title StateToState.cpp +// \author bocchino +// \brief cpp file for StateToState component implementation class +// ====================================================================== + +#include + +#include "FppTest/state_machine/internal_instance/state/StateToState.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +// ---------------------------------------------------------------------- +// Component construction and destruction +// ---------------------------------------------------------------------- + +StateToState::StateToState(const char* const compName) + : StateToStateComponentBase(compName), m_smStateStateToState_actionHistory() {} + +StateToState::~StateToState() {} + +// ---------------------------------------------------------------------- +// Implementations for internal state machine actions +// ---------------------------------------------------------------------- + +void StateToState::FppTest_SmState_StateToState_action_exitS1(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::EXIT_S1); +} + +void StateToState::FppTest_SmState_StateToState_action_exitS2(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::EXIT_S2); +} + +void StateToState::FppTest_SmState_StateToState_action_exitS3(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::EXIT_S3); +} + +void StateToState::FppTest_SmState_StateToState_action_a(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::A); +} + +void StateToState::FppTest_SmState_StateToState_action_enterS1(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::ENTER_S1); +} + +void StateToState::FppTest_SmState_StateToState_action_enterS2(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::ENTER_S2); +} + +void StateToState::FppTest_SmState_StateToState_action_enterS3(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::ENTER_S3); +} + +void StateToState::FppTest_SmState_StateToState_action_enterS4(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::ENTER_S4); +} + +void StateToState::FppTest_SmState_StateToState_action_enterS5(SmId smId, FppTest_SmState_StateToState::Signal signal) { + ASSERT_EQ(smId, SmId::smStateStateToState); + this->m_smStateStateToState_actionHistory.push(signal, ActionId::ENTER_S5); +} + +// ---------------------------------------------------------------------- +// Tests +// ---------------------------------------------------------------------- + +void StateToState::testInit() { + this->m_smStateStateToState_actionHistory.clear(); + this->init(queueDepth, instanceId); + ASSERT_EQ(this->smStateStateToState_getState(), SmState_StateToState::State::S1_S2); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_smStateStateToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToState_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToState_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToState::Signal::__FPRIME_AC_INITIAL_TRANSITION); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::ENTER_S1); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S2); +} + +void StateToState::testS2_to_S3() { + this->m_smStateStateToState_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToState_actionHistory.clear(); + this->smStateStateToState_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToState_getState(), SmState_StateToState::State::S1_S3); + const FwSizeType expectedSize = 2; + ASSERT_EQ(this->m_smStateStateToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToState_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToState_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToState::Signal::S2_to_S3); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::ENTER_S3); +} + +void StateToState::testS2_to_S4() { + this->m_smStateStateToState_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToState_actionHistory.clear(); + this->smStateStateToState_sendSignal_S1_to_S4(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToState_getState(), SmState_StateToState::State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_smStateStateToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToState_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToState_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToState::Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +void StateToState::testS2_to_S5() { + this->m_smStateStateToState_actionHistory.clear(); + this->init(queueDepth, instanceId); + this->m_smStateStateToState_actionHistory.clear(); + this->smStateStateToState_sendSignal_S1_to_S5(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + ASSERT_EQ(this->smStateStateToState_getState(), SmState_StateToState::State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_smStateStateToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToState_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToState_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToState::Signal::S1_to_S5); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S2); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +void StateToState::testS3_to_S4() { + this->m_smStateStateToState_actionHistory.clear(); + this->init(queueDepth, instanceId); + { + this->m_smStateStateToState_actionHistory.clear(); + this->smStateStateToState_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + { + this->m_smStateStateToState_actionHistory.clear(); + this->smStateStateToState_sendSignal_S1_to_S4(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + ASSERT_EQ(this->smStateStateToState_getState(), SmState_StateToState::State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_smStateStateToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToState_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToState_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToState::Signal::S1_to_S4); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +void StateToState::testS3_to_S5() { + this->m_smStateStateToState_actionHistory.clear(); + this->init(queueDepth, instanceId); + { + this->m_smStateStateToState_actionHistory.clear(); + this->smStateStateToState_sendSignal_S2_to_S3(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + { + this->m_smStateStateToState_actionHistory.clear(); + this->smStateStateToState_sendSignal_S1_to_S5(); + const auto status = this->doDispatch(); + ASSERT_EQ(status, MSG_DISPATCH_OK); + } + ASSERT_EQ(this->smStateStateToState_getState(), SmState_StateToState::State::S4_S5); + const FwSizeType expectedSize = 5; + ASSERT_EQ(this->m_smStateStateToState_actionHistory.getSize(), expectedSize); + const auto& signals = this->m_smStateStateToState_actionHistory.getSignals(); + const auto& actions = this->m_smStateStateToState_actionHistory.getValues(); + for (FwSizeType i = 0; i < expectedSize; i++) { + ASSERT_EQ(signals.getItemAt(i), SmState_StateToState::Signal::S1_to_S5); + } + ASSERT_EQ(actions.getItemAt(0), ActionId::EXIT_S3); + ASSERT_EQ(actions.getItemAt(1), ActionId::EXIT_S1); + ASSERT_EQ(actions.getItemAt(2), ActionId::A); + ASSERT_EQ(actions.getItemAt(3), ActionId::ENTER_S4); + ASSERT_EQ(actions.getItemAt(4), ActionId::ENTER_S5); +} + +} // namespace SmInstanceState + +} // namespace FppTest diff --git a/FppTest/state_machine/internal_instance/state/StateToState.fpp b/FppTest/state_machine/internal_instance/state/StateToState.fpp new file mode 100644 index 0000000000..18dfa2d000 --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToState.fpp @@ -0,0 +1,13 @@ +module FppTest { + + module SmInstanceState { + + active component StateToState { + + state machine instance smStateStateToState: SmState.StateToState + + } + + } + +} diff --git a/FppTest/state_machine/internal_instance/state/StateToState.hpp b/FppTest/state_machine/internal_instance/state/StateToState.hpp new file mode 100644 index 0000000000..41fb10cc6e --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/StateToState.hpp @@ -0,0 +1,158 @@ +// ====================================================================== +// \title StateToState.hpp +// \author bocchino +// \brief hpp file for StateToState component implementation class +// ====================================================================== + +#ifndef FppTest_SmInstanceState_StateToState_HPP +#define FppTest_SmInstanceState_StateToState_HPP + +#include "FppTest/state_machine/internal/harness/Harness.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToStateComponentAc.hpp" + +namespace FppTest { + +namespace SmInstanceState { + +class StateToState : public StateToStateComponentBase { + // ---------------------------------------------------------------------- + // Constants + // ---------------------------------------------------------------------- + + //! The history size + static constexpr FwSizeType historySize = 10; + + //! The queue depth + static constexpr FwSizeType queueDepth = 10; + + //! The instance ID + static constexpr FwEnumStoreType instanceId = 0; + + public: + // ---------------------------------------------------------------------- + // Component construction and destruction + // ---------------------------------------------------------------------- + + //! Construct StateToState object + StateToState(const char* const compName //!< The component name + ); + + //! Destroy StateToState object + ~StateToState(); + + private: + // ---------------------------------------------------------------------- + // Types + // ---------------------------------------------------------------------- + + //! The type FppTest_SmState_StateToState + using SmState_StateToState = FppTest_SmState_StateToState; + + //! Action IDs + enum class ActionId { EXIT_S1, EXIT_S2, EXIT_S3, A, ENTER_S1, ENTER_S2, ENTER_S3, ENTER_S4, ENTER_S5 }; + + PRIVATE: + // ---------------------------------------------------------------------- + // Implementations for internal state machine actions + // ---------------------------------------------------------------------- + //! Implementation for action exitS1 of state machine FppTest_SmState_StateToState + //! + //! Exit S1 + void FppTest_SmState_StateToState_action_exitS1(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action exitS2 of state machine FppTest_SmState_StateToState + //! + //! Exit S2 + void FppTest_SmState_StateToState_action_exitS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action exitS3 of state machine FppTest_SmState_StateToState + //! + //! Exit S3 + void FppTest_SmState_StateToState_action_exitS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action a of state machine FppTest_SmState_StateToState + //! + //! Action a + void FppTest_SmState_StateToState_action_a(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS1 of state machine FppTest_SmState_StateToState + //! + //! Enter S1 + void FppTest_SmState_StateToState_action_enterS1(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS2 of state machine FppTest_SmState_StateToState + //! + //! Enter S2 + void FppTest_SmState_StateToState_action_enterS2(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS3 of state machine FppTest_SmState_StateToState + //! + //! Enter S3 + void FppTest_SmState_StateToState_action_enterS3(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS4 of state machine FppTest_SmState_StateToState + //! + //! Enter S4 + void FppTest_SmState_StateToState_action_enterS4(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + //! Implementation for action enterS5 of state machine FppTest_SmState_StateToState + //! + //! Enter S5 + void FppTest_SmState_StateToState_action_enterS5(SmId smId, //!< The state machine id + FppTest_SmState_StateToState::Signal signal //!< The signal + ) override; + + public: + // ---------------------------------------------------------------------- + // Tests + // ---------------------------------------------------------------------- + + //! Test initial transition + void testInit(); + + //! Test transition S2 to S3 + void testS2_to_S3(); + + //! Test transition S2 to S4 + void testS2_to_S4(); + + //! Test transition S2 to S5 + void testS2_to_S5(); + + //! Test transition S3 to S4 + void testS3_to_S4(); + + //! Test transition S3 to S5 + void testS3_to_S5(); + + private: + // ---------------------------------------------------------------------- + // Member variables + // ---------------------------------------------------------------------- + + //! The action history for smStateStateToState + SmHarness::SignalValueHistory + m_smStateStateToState_actionHistory; +}; + +} // namespace SmInstanceState + +} // namespace FppTest + +#endif diff --git a/FppTest/state_machine/internal_instance/state/main.cpp b/FppTest/state_machine/internal_instance/state/main.cpp new file mode 100644 index 0000000000..48110b7efd --- /dev/null +++ b/FppTest/state_machine/internal_instance/state/main.cpp @@ -0,0 +1,299 @@ +// ---------------------------------------------------------------------- +// main.cpp +// ---------------------------------------------------------------------- + +#include + +#include "FppTest/state_machine/internal_instance/state/Basic.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuard.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardString.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestAbsType.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestArray.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestEnum.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardTestStruct.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicGuardU32.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicInternal.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicSelf.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicString.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestAbsType.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestArray.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestEnum.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicTestStruct.hpp" +#include "FppTest/state_machine/internal_instance/state/BasicU32.hpp" +#include "FppTest/state_machine/internal_instance/state/Internal.hpp" +#include "FppTest/state_machine/internal_instance/state/Polymorphism.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToChild.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToChoice.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToSelf.hpp" +#include "FppTest/state_machine/internal_instance/state/StateToState.hpp" +#include "STest/STest/Random/Random.hpp" + +TEST(Basic, Test) { + FppTest::SmInstanceState::Basic basic("basic"); + basic.test(); +} + +TEST(BasicGuard, False) { + FppTest::SmInstanceState::BasicGuard basicGuard("basicGuard"); + basicGuard.testFalse(); +} + +TEST(BasicGuard, True) { + FppTest::SmInstanceState::BasicGuard basicGuard("basicGuard"); + basicGuard.testTrue(); +} + +TEST(BasicGuardString, False) { + FppTest::SmInstanceState::BasicGuardString basicGuardString("basicGuardString"); + basicGuardString.testFalse(); +} + +TEST(BasicGuardString, True) { + FppTest::SmInstanceState::BasicGuardString basicGuardString("basicGuardString"); + basicGuardString.testTrue(); +} + +TEST(BasicGuardTestAbsType, False) { + FppTest::SmInstanceState::BasicGuardTestAbsType basicGuardTestAbsType("basicGuardTestAbsType"); + basicGuardTestAbsType.testFalse(); +} + +TEST(BasicGuardTestAbsType, Overflow) { + FppTest::SmInstanceState::BasicGuardTestAbsType basicGuardTestAbsType("basicGuardTestAbsType"); + basicGuardTestAbsType.testOverflow(); +} + +TEST(BasicGuardTestAbsType, True) { + FppTest::SmInstanceState::BasicGuardTestAbsType basicGuardTestAbsType("basicGuardTestAbsType"); + basicGuardTestAbsType.testTrue(); +} + +TEST(BasicGuardTestArray, False) { + FppTest::SmInstanceState::BasicGuardTestArray basicGuardTestArray("basicGuardTestArray"); + basicGuardTestArray.testFalse(); +} + +TEST(BasicGuardTestArray, True) { + FppTest::SmInstanceState::BasicGuardTestArray basicGuardTestArray("basicGuardTestArray"); + basicGuardTestArray.testTrue(); +} + +TEST(BasicGuardTestEnum, False) { + FppTest::SmInstanceState::BasicGuardTestEnum basicGuardTestEnum("basicGuardTestEnum"); + basicGuardTestEnum.testFalse(); +} + +TEST(BasicGuardTestEnum, True) { + FppTest::SmInstanceState::BasicGuardTestEnum basicGuardTestEnum("basicGuardTestEnum"); + basicGuardTestEnum.testTrue(); +} + +TEST(BasicGuardTestStruct, False) { + FppTest::SmInstanceState::BasicGuardTestStruct basicGuardTestStruct("basicGuardTestStruct"); + basicGuardTestStruct.testFalse(); +} + +TEST(BasicGuardTestStruct, True) { + FppTest::SmInstanceState::BasicGuardTestStruct basicGuardTestStruct("basicGuardTestStruct"); + basicGuardTestStruct.testTrue(); +} + +TEST(BasicGuardU32, False) { + FppTest::SmInstanceState::BasicGuardU32 basicGuardU32("basicGuardU32"); + basicGuardU32.testFalse(); +} + +TEST(BasicGuardU32, True) { + FppTest::SmInstanceState::BasicGuardU32 basicGuardU32("basicGuardU32"); + basicGuardU32.testTrue(); +} + +TEST(BasicInternal, Test) { + FppTest::SmInstanceState::BasicInternal basicInternal("basicInternal"); + basicInternal.test(); +} + +TEST(BasicSelf, Test) { + FppTest::SmInstanceState::BasicSelf basicSelf("basicSelf"); + basicSelf.test(); +} + +TEST(BasicString, Test) { + FppTest::SmInstanceState::BasicString basicString("basicString"); + basicString.test(); +} + +TEST(BasicTestAbsType, Test) { + FppTest::SmInstanceState::BasicTestAbsType basicTestAbsType("basicTestAbsType"); + basicTestAbsType.test(); +} + +TEST(BasicTestArray, Test) { + FppTest::SmInstanceState::BasicTestArray basicTestArray("basicTestArray"); + basicTestArray.test(); +} + +TEST(BasicTestEnum, Test) { + FppTest::SmInstanceState::BasicTestEnum basicTestEnum("basicTestEnum"); + basicTestEnum.test(); +} + +TEST(BasicTestStruct, Test) { + FppTest::SmInstanceState::BasicTestStruct basicTestStruct("basicTestStruct"); + basicTestStruct.test(); +} + +TEST(BasicU32, Test) { + FppTest::SmInstanceState::BasicU32 basicU32("basicU32"); + basicU32.test(); +} + +TEST(Internal, Init) { + FppTest::SmInstanceState::Internal internal("internal"); + internal.testInit(); +} + +TEST(Internal, S2_internal) { + FppTest::SmInstanceState::Internal internal("internal"); + internal.testS2_internal(); +} + +TEST(Internal, S2_to_S3) { + FppTest::SmInstanceState::Internal internal("internal"); + internal.testS2_to_S3(); +} + +TEST(Internal, S3_internal) { + FppTest::SmInstanceState::Internal internal("internal"); + internal.testS3_internal(); +} + +TEST(Polymorphism, Init) { + FppTest::SmInstanceState::Polymorphism polymorphism("polymorphism"); + polymorphism.testInit(); +} + +TEST(Polymorphism, S2_poly) { + FppTest::SmInstanceState::Polymorphism polymorphism("polymorphism"); + polymorphism.testS2_poly(); +} + +TEST(Polymorphism, S2_to_S3) { + FppTest::SmInstanceState::Polymorphism polymorphism("polymorphism"); + polymorphism.testS2_to_S3(); +} + +TEST(Polymorphism, S3_poly) { + FppTest::SmInstanceState::Polymorphism polymorphism("polymorphism"); + polymorphism.testS3_poly(); +} + +TEST(StateToChild, Init) { + FppTest::SmInstanceState::StateToChild stateToChild("stateToChild"); + stateToChild.testInit(); +} + +TEST(StateToChild, S2_to_S2) { + FppTest::SmInstanceState::StateToChild stateToChild("stateToChild"); + stateToChild.testS2_to_S2(); +} + +TEST(StateToChild, S2_to_S3) { + FppTest::SmInstanceState::StateToChild stateToChild("stateToChild"); + stateToChild.testS2_to_S3(); +} + +TEST(StateToChild, S3_to_S2) { + FppTest::SmInstanceState::StateToChild stateToChild("stateToChild"); + stateToChild.testS3_to_S2(); +} + +TEST(StateToChoice, Init) { + FppTest::SmInstanceState::StateToChoice stateToChoice("stateToChoice"); + stateToChoice.testInit(); +} + +TEST(StateToChoice, S2_to_C) { + FppTest::SmInstanceState::StateToChoice stateToChoice("stateToChoice"); + stateToChoice.testS2_to_C(); +} + +TEST(StateToChoice, S2_to_S4) { + FppTest::SmInstanceState::StateToChoice stateToChoice("stateToChoice"); + stateToChoice.testS2_to_S4(); +} + +TEST(StateToChoice, S2_to_S3) { + FppTest::SmInstanceState::StateToChoice stateToChoice("stateToChoice"); + stateToChoice.testS2_to_S3(); +} + +TEST(StateToChoice, S3_to_C) { + FppTest::SmInstanceState::StateToChoice stateToChoice("stateToChoice"); + stateToChoice.testS3_to_C(); +} + +TEST(StateToChoice, S3_to_S4) { + FppTest::SmInstanceState::StateToChoice stateToChoice("stateToChoice"); + stateToChoice.testS3_to_S4(); +} + +TEST(StateToSelf, Init) { + FppTest::SmInstanceState::StateToSelf stateToSelf("stateToSelf"); + stateToSelf.testInit(); +} + +TEST(StateToSelf, S2_to_S1) { + FppTest::SmInstanceState::StateToSelf stateToSelf("stateToSelf"); + stateToSelf.testS2_to_S1(); +} + +TEST(StateToSelf, S2_to_S3) { + FppTest::SmInstanceState::StateToSelf stateToSelf("stateToSelf"); + stateToSelf.testS2_to_S3(); +} + +TEST(StateToSelf, S3_to_S1) { + FppTest::SmInstanceState::StateToSelf stateToSelf("stateToSelf"); + stateToSelf.testS3_to_S1(); +} + +TEST(StateToState, Init) { + FppTest::SmInstanceState::StateToState stateToState("stateToState"); + stateToState.testInit(); +} + +TEST(StateToState, S2_to_S3) { + FppTest::SmInstanceState::StateToState stateToState("stateToState"); + stateToState.testS2_to_S3(); +} + +TEST(StateToState, S2_to_S4) { + FppTest::SmInstanceState::StateToState stateToState("stateToState"); + stateToState.testS2_to_S4(); +} + +TEST(StateToState, S2_to_S5) { + FppTest::SmInstanceState::StateToState stateToState("stateToState"); + stateToState.testS2_to_S5(); +} + +TEST(StateToState, S3_to_S4) { + FppTest::SmInstanceState::StateToState stateToState("stateToState"); + stateToState.testS3_to_S4(); +} + +TEST(StateToState, S3_to_S5) { + FppTest::SmInstanceState::StateToState stateToState("stateToState"); + stateToState.testS3_to_S5(); +} + +// ---------------------------------------------------------------------- +// Main function +// ---------------------------------------------------------------------- + +int main(int argc, char** argv) { + ::testing::InitGoogleTest(&argc, argv); + STest::Random::seed(); + return RUN_ALL_TESTS(); +} diff --git a/FppTest/utils/Utils.cpp b/FppTest/utils/Utils.cpp index 74f2919f97..3750f7c8f4 100644 --- a/FppTest/utils/Utils.cpp +++ b/FppTest/utils/Utils.cpp @@ -36,7 +36,7 @@ namespace FppTest { } char getChar() { - return static_cast(STest::Pick::lowerUpper(32, 127)); + return static_cast(STest::Pick::lowerUpper(32, 126)); } void setString(char* buf, FwSizeType capacity, FwSizeType minLength) { diff --git a/Fw/Port/PortBase.cpp b/Fw/Port/PortBase.cpp index 5a63bb1b0a..75e97704e0 100644 --- a/Fw/Port/PortBase.cpp +++ b/Fw/Port/PortBase.cpp @@ -38,13 +38,13 @@ namespace Fw { } - bool PortBase::isConnected() { + bool PortBase::isConnected() const { return m_connObj == nullptr?false:true; } #if FW_PORT_TRACING == 1 - void PortBase::trace() { + void PortBase::trace() const { bool do_trace = false; if (this->m_ovr_trace) { diff --git a/Fw/Port/PortBase.hpp b/Fw/Port/PortBase.hpp index e9b9a6b8e8..0e81ddd56d 100644 --- a/Fw/Port/PortBase.hpp +++ b/Fw/Port/PortBase.hpp @@ -20,7 +20,7 @@ namespace Fw { void ovrTrace(bool ovr, bool trace); // !< override tracing for a particular port #endif - bool isConnected(); + bool isConnected() const; protected: // Should only be accessed by derived classes PortBase(); // Constructor @@ -28,7 +28,7 @@ namespace Fw { virtual void init(); // !< initialization function #if FW_PORT_TRACING == 1 - void trace(); // !< trace port calls if active + void trace() const; // !< trace port calls if active #endif Fw::ObjBase* m_connObj; // !< object port is connected to diff --git a/Ref/TypeDemo/TypeDemo.fpp b/Ref/TypeDemo/TypeDemo.fpp index 9c04c70a31..c472f7e653 100644 --- a/Ref/TypeDemo/TypeDemo.fpp +++ b/Ref/TypeDemo/TypeDemo.fpp @@ -60,14 +60,14 @@ module Ref { @ Single choice command sync command CHOICE( @ A single choice - choice: Choice + $choice: Choice ) @ Single choice channel telemetry ChoiceCh: Choice @ Single choice event - event ChoiceEv(choice: Choice) severity activity high format "Choice: {}" + event ChoiceEv($choice: Choice) severity activity high format "Choice: {}" @ Single enumeration parameter param CHOICE_PRM: Choice @@ -189,7 +189,7 @@ module Ref { ##### @ Single choice parameter event - event ChoicePrmEv(choice: Choice, validity: Fw.ParamValid) severity activity high \ + event ChoicePrmEv($choice: Choice, validity: Fw.ParamValid) severity activity high \ format "CHOICE_PRM: {} with validity: {}" @ Multiple choice parameter event via Array diff --git a/Svc/Health/Health.fpp b/Svc/Health/Health.fpp index 645b3e1bd3..6f29fe2235 100644 --- a/Svc/Health/Health.fpp +++ b/Svc/Health/Health.fpp @@ -63,14 +63,14 @@ module Svc { @ Ignore a particular ping entry async command HLTH_PING_ENABLE( - entry: string size 40 @< The entry to enable/disable + $entry: string size 40 @< The entry to enable/disable enable: Fw.Enabled @< whether or not a port is pinged ) \ opcode 0x1 @ Change ping value async command HLTH_CHNG_PING( - entry: string size 40 @< The entry to modify + $entry: string size 40 @< The entry to modify warningValue: U32 @< Ping warning threshold fatalValue: U32 @< Ping fatal threshold ) \ @@ -82,7 +82,7 @@ module Svc { @ Warn that a ping target is longer than the warning value event HLTH_PING_WARN( - entry: string size 40 @< The entry passing the warning level + $entry: string size 40 @< The entry passing the warning level ) \ severity warning high \ id 0x0 \ @@ -90,7 +90,7 @@ module Svc { @ Declare FATAL since task is no longer responding event HLTH_PING_LATE( - entry: string size 40 @< The entry passing the warning level + $entry: string size 40 @< The entry passing the warning level ) \ severity fatal \ id 0x1 \ @@ -98,7 +98,7 @@ module Svc { @ Declare FATAL since task is no longer responding event HLTH_PING_WRONG_KEY( - entry: string size 40 @< The entry passing the warning level + $entry: string size 40 @< The entry passing the warning level badKey: U32 @< The incorrect key value ) \ severity fatal \ @@ -116,7 +116,7 @@ module Svc { @ Report a particular entry on or off event HLTH_CHECK_PING( enabled: Fw.Enabled @< If health pinging is enabled for a particular entry - entry: string size 40 @< The entry passing the warning level + $entry: string size 40 @< The entry passing the warning level ) \ severity activity high \ id 0x4 \ @@ -124,7 +124,7 @@ module Svc { @ Entry was not found event HLTH_CHECK_LOOKUP_ERROR( - entry: string size 40 @< The entry passing the warning level + $entry: string size 40 @< The entry passing the warning level ) \ severity warning low \ id 0x5 \ @@ -132,7 +132,7 @@ module Svc { @ Report changed ping event HLTH_PING_UPDATED( - entry: string size 40 @< The entry changed + $entry: string size 40 @< The entry changed warn: U32 @< The new warning value $fatal: U32 @< The new FATAL value ) \ @@ -142,7 +142,7 @@ module Svc { @ Report changed ping event HLTH_PING_INVALID_VALUES( - entry: string size 40 @< The entry changed + $entry: string size 40 @< The entry changed warn: U32 @< The new warning value $fatal: U32 @< The new FATAL value ) \ diff --git a/Svc/PolyIf/PolyIf.fpp b/Svc/PolyIf/PolyIf.fpp index ecfa4c1fc7..983a6169a0 100644 --- a/Svc/PolyIf/PolyIf.fpp +++ b/Svc/PolyIf/PolyIf.fpp @@ -9,7 +9,7 @@ module Svc { @ Port for setting and getting PolyType values port Poly( - entry: PolyDbCfg.PolyDbEntry @< The entry to access + $entry: PolyDbCfg.PolyDbEntry @< The entry to access ref status: MeasurementStatus @< The command response argument ref $time: Fw.Time @< The time of the measurement ref val: Fw.PolyType @< The value to be passed diff --git a/Svc/SystemResources/SystemResources.hpp b/Svc/SystemResources/SystemResources.hpp index 7d0e47e153..8dda5bb646 100644 --- a/Svc/SystemResources/SystemResources.hpp +++ b/Svc/SystemResources/SystemResources.hpp @@ -35,7 +35,7 @@ class SystemResources : public SystemResourcesComponentBase { //! ~SystemResources(void); - typedef void (SystemResourcesComponentBase::*cpuTlmFunc)(F32, Fw::Time); + typedef void (SystemResourcesComponentBase::*cpuTlmFunc)(F32, Fw::Time) const; PRIVATE : diff --git a/docs/documentation/user-manual/design/state-machines.md b/docs/documentation/user-manual/design/state-machines.md new file mode 100644 index 0000000000..06c398a731 --- /dev/null +++ b/docs/documentation/user-manual/design/state-machines.md @@ -0,0 +1,429 @@ +# State Machines + +## 1. Introduction + +A **state machine** is a software subsystem whose behavior is +described by states and transitions, together with related concepts +such as signals, actions, and guards. +State machines are important in flight software and embedded programming. +In this section, we document the features of F Prime that support +programming with state machines. + +## 2. External and Internal State Machines + +F Prime supports two kinds of state machines: +**external state machines** and **internal state machines**. +An external state machine is specified by an external tool, +typically the +[State Autocoding for Real-Time Systems (STARS) +tool](https://github.com/JPLOpenSource/STARS/tree/main). +An internal state machine is specified in FPP, the modeling language +for F Prime. + +To program with external state machines, you typically do the following: + +1. Use an external tool, such as the Quantum Modeler or Plant UML, +to express the state machine. +1. Use the STARS autocoder to generate an implementation from the model. +1. Write a small amount of code to make the FPP model aware of +the implementation. +1. Instantiate the state machine in one or more F Prime components. +1. In the component implementations, write code that interacts with +the state machine instances. + +Steps 1, 2, and 5 are described in the STARS documentation. +Steps 3 and 4 are described in the +[_The FPP User's Guide_](https://nasa.github.io/fpp/fpp-users-guide.html). +In the rest of this document, we will focus on the design of internal +state machines. + +## 3. FPP Modeling and Code Generation + +To work with internal state machines in FPP, you do the following: + +1. Define one or more state machines, specifying their behavior. + +1. Add one or more instances of the state machines defined in step 1 to a + component _C_. + +1. In the implementation of _C_, write code that interacts with the +generated code for the instances defined in step 2. + +Steps 1 and 2 are fully documented in +[_The FPP User's Guide_](https://nasa.github.io/fpp/fpp-users-guide.html). +Here we focus on the generated code for state machines and for +state machine instances. + +## 4. State Machine Definitions + +In this section we describe the generated code for a state machine definition +_D_ with name _M_. +This code is generated into files _M_`StateMachineAc.hpp` and +_M_`StateMachineAc.cpp` +when you run `fpp-to-cpp` on an FPP model that includes _D_. + +In the ordinary way of programming with F Prime, it is unlikely +that you will directly interact with the code described here. +Instead, you will use the component interface to state machine instances +described in the [next section](#state-machine-instances). +Therefore, if your primary interest is to program with F Prime state +machines, you can skip this section. + +For examples of generated code, you can do the following: + +1. In a local installation of the `fprime` repository, go into `FppTest` and +run `fprime-util generate --ut` and then `fprime-util check`. + +1. Look at the FPP models in `fprime/FppTest/state_machine/internal/state`. + +1. Look at the generated files in + `fprime/FppTest/build-fprime-automatic-native-ut/FppTest/state_machine/internal/state`. + + +### 4.1. The State Machine Base Class + +Each state machine definition _D_ in the FPP model becomes a C++ base class +_M_`StateMachineBase`, where _M_ is the unqualified name of the definition. +This class is enclosed in the namespaces, if any, given by the qualified +name of _D_. +For example, a state machine definition whose qualified name is `A.B.M` in FPP +becomes a class `A::B::MStateMachineBase` in C++. +The base class provides a partial implementation which is completed when +the state machine is [instantiated](#state-machine-instances). + + +### 4.2. The Public Interface + +Each generated state machine has the following public interface. + +**Types:** + +* There is an enumeration representing the states of the state machine. +These are the leaf states specified in the FPP model +together with a special uninitialized state. + +* There is an enumeration representing the signals of the state machine. +These are the signals specified in the FPP model together with a +special signal that represents the initial transition on startup. + +**Member functions:** + +* There is a function `getState` for getting the current state +of the state machine. + +* There is one function `sendSignal` _s_ for each signal _s_ +specified in the FPP model. +If the signal _s_ carries a value of type _T_, then this function has one +formal parameter of type _paramType(T)_; otherwise it has no formal parameters. +Here _paramType(T)_ means (1) _T_ if _T_ is a primitive type; otherwise (2) +`const` reference to `Fw::StringBase` if _T_ is a string type; otherwise +(3) `const` reference to _T_. + + +### 4.3. The Protected Interface + +**Constructors and destructors:** +There is a zero-argument constructor and a destructor. + +**Initialization:** +There is a function `initBase` with a single formal parameter `id` +of type `FwEnumStoreType`. +This function must be called on a state machine instance before +any signals are sent to the instance. +The parameter `id` represents the state machine identifier. +The type is `FwEnumStoreType` because the state machine identifier +type is an enumeration defined in the subclass. + +**Actions:** +There is one pure virtual function `action_`_a_ for each action +_a_ specified in the FPP model. +Each action returns `void` has a formal parameter `signal` of type `Signal`. +If the action has a type _T_, then there is a second +formal parameter of type _paramType(T)_. + +**Guards:** +There is one pure virtual `const` function `guard_`_g_ for each guard +_g_ specified in the FPP model. +Each guard returns `bool` and has a formal parameter `signal` of type `Signal`. +If the guard has a type _T_, then there is a second +formal parameter of type _paramType(T)_. + +**Member variables:** +Each state machine base class has the following member variables: + +* A member `m_id` of type `FwEnumStoreType`. +This variable records the current state of the state machine, +represented as `FwEnumStoreType`. +The initial value is zero. + +* A member `m_state` of type `State`. +This variable records the current state of the state machine. +The initial value is `State::__FPRIME_AC_UNINITIALIZED`. + +### 4.4. The Private Interface + +For each state _S_ and choice _C_ in the state machine there is one +entry function for _S_ or _C_. +This function implements the entry behavior for _S_ or _C_ +as specified in +[_The FPP Language Specification_](https://nasa.github.io/fpp/fpp-spec.html). + + + +## 5. State Machine Instances + +In this section we describe the generated code for instances of state machines +that are part of a component _C_. +This code is part of the auto-generated base class for _C_. +In general there may be any number of instances of any number +of state machines. + +For examples of generated code, you can do the following: + +1. In a local installation of the `fprime` repository, go into `FppTest` and +run `fprime-util generate --ut` and then `fprime-util check`. + +1. Look at the FPP models in + `fprime/FppTest/state_machine/internal_instance/state`. + +1. Look at the generated files in + `fprime/FppTest/build-fprime-automatic-native-ut/FppTest/state_machine/internal_instance/state`. + +### 5.1. State Machine Identifiers + +There is an enumeration `SmId` with numeric type `FwEnumStoreType` +that represents the state machine identifiers. +There is one enumerated constant for each state machine instance +in _C_. + + +### 5.2. State Machine Implementation Classes + +There is one implementation class for each state machine definition +_M_ that is the type of a state machine instance in _C_. +For example, if a state machine instance +``` +state machine instance m: M +``` +appears in the definition of _C_, then the auto-generated base +class for _C_ contains an implementation class for _M_. +This class has the following properties: + +* It is a protected inner class of the auto-generated base class for _C_. + +* Its name is the fully qualified name of the state machine, +converted to a C++ identifier by replacing the dots with underscores. +For example, if a state machine has name `A.B.M` in FPP, +the C++ name of its implementation class is `A_B_M`. +We will refer to this name as _fqCppIdent(M)_. + +* It is a public derived class of the [state machine base +class for _M_](#sm-base-class). + +The following class diagram shows these properties, for a state +machine `A.B.M` instantiated in a component `C`: + +![State Machine Implementation Class Diagram](../../../img/sm-impl-class-diagram.png) + +Each state machine implementation class has the following +elements in its interface. + +**Member variables:** +There is a member `m_component` that is a reference to +the enclosing component instance. +This way the state machine instance can call into +the interface of the component instance. + +**Construction:** There is a public constructor +that takes a reference `*this` to the enclosing component +as an argument. +It initializes the member variable described above. + +**Initialization:** There is a public function +`init` with one formal parameter `smId` of type `SmId`. +This function casts its argument to `FwEnumStoreType` +and calls the function `initBase` defined in the base class. +Thus it provides a type-safe way to initialize the state +machine ID. + +**State ID:** There is a public function `getId` +that returns the state machine ID. +It gets the value out of the `m_id` field defined +in the base class and casts it to `SmId`. +Thus it provides a type-safe way to get the state +machine ID. + +**Actions:** For each action _a_ of _M_, there is one private function that +implements the [pure virtual function for _a_ defined in the base +class for _M_](#sm-protected). +The implementation calls the [pure virtual function in the bass class for _C_ +that corresponds to to _M_ and _a_](#component-pure-virtual). +It passes in the state machine ID of `*this`. + +**Guards:** For each guard _g_ of _M_, there is one private function that +implements the [pure virtual function for _g_ defined in the base +class for _M_](#sm-protected). +The implementation calls the [pure virtual function in the base class for _C_ +that corresponds to to _M_ and _g_](#component-pure-virtual). +It passes in the state machine ID of `*this` and returns the Boolean value returned +by that function. + +### 5.3. State Machine Instance Variables + +For each state machine _m_ in the FPP component model, there is +one private member variable `m_stateMachine_`_m_. +Its type is the [state machine implementation class](#state-machine-impl) +corresponding to the state machine _M_ instantiated by _m_. + +### 5.4. State Machine Initialization + +When a component _C_ instantiates one or more state machines, +the standard _init_ function of _C_ calls the _init_ function +on each state machine instance, passing in the enumerated +constant for each state machine ID. +In the standard sequence for F Prime FSW initialization, +the _init_ function is called before any component instances +are connected. +Therefore, the initial transition of any state machine, +including any entry actions of the initial state, may +not emit events or telemetry or invoke any output port. +If you need to emit events or telemetry or invoke an output port +at the start of steady-state execution, you can have the +initial state be a state _INIT_ that does nothing but transition to another +state _START_ on an RTI signal. +When the component instance receives an RTI call on its `schedIn` port, +it can send the RTI signal to the state machine, causing +the transition to _START_. +At this point the components are connected, and the transition +to _START_ can emit events or telemetry or invoke an output port. + +### 5.5. Protected Member Functions + +The auto-generated base class for _C_ has the following protected functions. + +#### 5.5.1. Implemented Functions + +The following functions have complete implementations. +They are available to call in the derived class that implements _C_. + +**State getter functions:** +For each state machine instance _m_ in _C_, there is a `const` function +_m_`_getState` that gets the current state of _m_. + +**Signal send functions:** +For each state machine instance _m_, and for each signal _s_ defined +in the state machine _M_ instantiated by _m_, there is a function +_m_`_sendSignal_`_s_ for sending _s_ to _m_. +If _s_ carries data of type _T_, then this function has a single +formal parameter of type [_paramType(T)_](#sm-public); otherwise it has no +formal parameters. + +Calling a signal send function puts a message on the queue of the +current instance of the component _C_. +When the message is dispatched, the auto-generated code calls +the function that sends the signal to the state machine. +This way state machines can safely send signals when they +are doing actions. + +Each send signal function does the following: + +1. Call [`sendSignalStart`](#component-private) to begin constructing a message + buffer _B_. + +1. If the signal carries data, then serialize the data into _B_. + +1. Call the appropriate [`sendSignalFinish`](#component-private) function to +put _B_ onto the component queue and handle overflow. + + +#### 5.5.2. Pure Virtual Functions + +The following functions are pure virtual in the generated base class for _C_. +You must implement them in the derived class that implements _C_. +When you generate a C++ component implementation template for _C_, you get +a stub for each of these functions that you can fill in. + +**Action functions:** +For each state machine _M_ instantiated in _C_, for each action _a_ +specified in _M_, there is a pure virtual function _fqCppIdent(M)_`_action_`_a_. +Recall that _fqCppIdent(M)_ is the fully qualified name of _M_ represented +as a C++ identifier, i.e., the fully qualified name of _M_ in FPP with +the dots replaced by underscores. +This function has at least two formal parameters: the state machine ID +and the signal. +If the action requires a value of type _T_, then there is a third +formal parameter of type [_paramType(T)_](#sm-public). + +When an instance _m_ of _M_ does action _a_, it calls the action function +for _a_ in the [auto-generated base class of _M_](#state-machine-impl). +That function calls _fqCppIdent(M)_`_action_`_a_ with the correct state machine +ID, signal, and value, if any. + +**Guard functions:** +For each state machine _M_ is instantiated in _C_, for each guard _g_ +specified in _M_, there is a pure virtual function _fqCppIdent(M)_`_guard_`_g_. +This is a `const` function that returns `bool`. +It has the same formal parameters as an action function that requires the same +value type, if any. + +When an instance _m_ of _M_ evaluates guard _g_, it calls the guard function +for _g_ in the [auto-generated base class of _M_](#state-machine-impl). +That function calls _fqCppIdent(M)_`_guard_`_g_ with the correct state machine +ID, signal, and value, if any, and returns the resulting Boolean value. + +**Overflow hook functions:** +For each state machine instance _m_ that has overflow behavior `hook`, +there is a pure virtual function _m_`_stateMachineOverflowHook` with +the following formal parameters: the state machine ID, +the signal, and a reference to the message buffer. +The deserialization pointer of the message buffer points to the start +of the message data, so the data can be deserialized if needed. +If the signal that caused the overflow carries no data, then the +deserialization pointer is at the end of the buffer, and deserializing +data from the buffer will return a `BUFFER_EMPTY` error. + + +### 5.6. Private Member Functions + +The generated base class for _C_ has the following private member functions. + +**Send signal helper functions:** + +* A function `sendSignalStart`. +Each send signal function calls this function to begin +constructing a message buffer for sending a state machine signal. +This function serializes the following data into the message buffer: +message type, the port number, the state machine ID, and the signal. + +* For each state machine instance _m_, a function _m_`_sendSignalFinish`. +This function puts the message buffer on the queue with the correct +priority and overflow behavior for _m_. + +**Helper functions for state machine dispatch:** + +* A function `smDispatch` for initial dispatch of a state machine +signal message from the queue. +This function does the following: + + 1. Call `deserializeSmIdAndSignal` to deserialize the state machine ID and + signal from the message buffer as `FwEnumStoreType` values. + + 1. Cast the state machine ID to `SmId` and use it to select the + target state machine instance _m_. + + 1. Cast the signal to the appropriate type for _m_. + + 1. Call the appropriate `smDispatch` helper for the state machine _M_ of + which _m_ is an instance, passing the message buffer, a reference to + `m_stateMachine_`_m_, and the signal. + +* A function `deserializeSmIdAndSignal` for deserializing the state + machine ID and signal from the message buffer as `FwEnumStoreType` values. + +* For each state machine _M_ that is instantiated in _C_, a function + _fqCppIdent(M)_`_smDispatch` for finishing the dispatch of a signal to a +state machine instance of type _M_. + It takes as arguments the message buffer _B_, a reference _sm_ to a state +machine instance, and a signal _s_. + It deserializes the data from _B_ if there is any for _s_. + Then it calls _sm_`.sendSignal_`_s_, passing in the data, if any. diff --git a/docs/img/sm-impl-class-diagram.png b/docs/img/sm-impl-class-diagram.png new file mode 100644 index 0000000000000000000000000000000000000000..424700da10507f80f2d74f25a631728cedd1c34f GIT binary patch literal 13144 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