Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Phase 1 state machines #2829

Merged
merged 36 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
eb935e9
Add a state machine unit test under FppTest
May 28, 2024
efc2c1b
Updated the base class and unit tests work
May 29, 2024
d1e5c99
Remove the sendEvent function as it did not allow for data to be passed
May 29, 2024
13511d1
Add state machine in SmTest.fpp
May 29, 2024
7ed6fd1
Add dependency in SmTest.fpp
May 29, 2024
b6bf575
state machine unit test passes with new fpp phase 1
Jun 10, 2024
26388de
Makefile for state machines don't use special switch
Jun 10, 2024
bfb983b
Rebase DeviceSm.hpp
Jun 11, 2024
116d5ac
Update on SMEvents inclusion
Jun 11, 2024
2912ebd
Merge branch 'devel' into sm-test
Jun 21, 2024
ab1f34d
Use latest phase1 fpp and STARS which uses _Interface
Jun 25, 2024
7dc40b6
Change SMEvents to SMSignals
Jul 1, 2024
2e22e08
Use SMSignals instead of SMEvents
Jul 2, 2024
ad3a39a
Update test for state machine instance priority and full queue behavior
Aug 7, 2024
a93d7a3
Merge branch 'devel' into sm-test
Aug 12, 2024
79e7b8f
Update requirements to use new fpp version
Aug 12, 2024
112b60b
Removed unneeded files
Aug 13, 2024
ff7b023
update FppTest for new autocoder changes
Aug 26, 2024
08d8135
Get unit tests updated and working for fpp state machines phase 1 del…
Aug 28, 2024
443da3b
Rename Fw/SMTest to Fw/Sm
Sep 3, 2024
0448d15
Update STARS to use FW_ASSERT
Sep 3, 2024
41cd2e5
Rename SMSignalBuffer to SmSignalBuffer
Sep 3, 2024
de9296f
Fix spelling issues with CI
Sep 5, 2024
003f591
Update requirements to the FPP alpha release v2.2.0a3
Sep 5, 2024
b728ae7
Merge branch 'devel' into sm-test
garthwatney Sep 5, 2024
e27598d
Fix requirements.txt
bocchino Sep 5, 2024
ae5727b
Fix requirements.txt
bocchino Sep 5, 2024
042adb7
Initialize data in the constructor of SmSignalBuffer
Sep 5, 2024
132d4b4
Merge branch 'sm-test' of github.com:garthwatney/fprime into sm-test
Sep 5, 2024
fa3db99
Add constructor list to all the constructors in SmSignalBuffer
Sep 5, 2024
2543824
Merge branch 'devel' into sm-test
LeStarch Sep 18, 2024
fe98ac6
Fixes for reserved word state and address review comments
Sep 19, 2024
f5eef35
Fix other review issues pertaining to unit tests and argument checks …
Sep 19, 2024
9d34778
Add a cast to NATIVE_UINT_TYPE in SmSignalBuffer
Sep 19, 2024
c99df29
Fixing type
LeStarch Sep 19, 2024
8a904b3
Fixing size type in cpp
LeStarch Sep 19, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .github/actions/spelling/allow.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,3 +6,5 @@ usec
usecs
workaround
workarounds
DEVICESM
HACKSM
4 changes: 2 additions & 2 deletions Drv/GpioDriverPorts/GpioDriverPorts.fpp
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
module Drv {

port GpioWrite(
state: Fw.Logic
$state: Fw.Logic
)

}

module Drv {

port GpioRead(
ref state: Fw.Logic
ref $state: Fw.Logic
)

}
2 changes: 2 additions & 0 deletions FppTest/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,14 @@ include("${CMAKE_CURRENT_LIST_DIR}/../cmake/FPrime-Code.cmake")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/array/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/component/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/dp/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/state_machine/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/enum/")
add_fprime_subdirectory("${CMAKE_CURRENT_LIST_DIR}/struct/")
set(SOURCE_FILES "source.cpp")
set(MOD_DEPS
${PROJECT_NAME}/array
${PROJECT_NAME}/dp
${PROJECT_NAME}/state_machine
${PROJECT_NAME}/enum
${PROJECT_NAME}/struct
${PROJECT_NAME}/component/empty
Expand Down
21 changes: 21 additions & 0 deletions FppTest/state_machine/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
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()
74 changes: 74 additions & 0 deletions FppTest/state_machine/DeviceSm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@

// ======================================================================
// \title DeviceSm.cpp
// \author Auto-generated
// \brief cpp file for state machine DeviceSm
//
// ======================================================================

#include <Fw/Types/Assert.hpp>
#include "DeviceSm.hpp"


void FppTest::DeviceSm::init(const FwEnumStoreType stateMachineId)
{
parent->DeviceSm_turnOff(stateMachineId);
this->state = OFF;

}


void FppTest::DeviceSm::update(
const FwEnumStoreType stateMachineId,
const DeviceSm_Interface::DeviceSm_Signals signal,
const Fw::SmSignalBuffer &data
)
{
switch (this->state) {

/**
* state OFF
*/
case OFF:

switch (signal) {

case DeviceSm_Interface::DeviceSm_Signals::RTI_SIG:
if ( parent->DeviceSm_g1(stateMachineId) ) {
parent->DeviceSm_a1(stateMachineId, signal, data);
parent->DeviceSm_turnOn(stateMachineId);
this->state = ON;
}

break;

default:
break;
}
break;

/**
* state ON
*/
case ON:

switch (signal) {

case DeviceSm_Interface::DeviceSm_Signals::RTI_SIG:
if (parent->DeviceSm_g2(stateMachineId, signal, data) ) {
parent->DeviceSm_a2(stateMachineId);
parent->DeviceSm_turnOff(stateMachineId);
this->state = OFF;
}

break;

default:
break;
}
break;

default:
FW_ASSERT(0);
}
}
7 changes: 7 additions & 0 deletions FppTest/state_machine/DeviceSm.fppi
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@


enum DeviceSmStates {
OFF = 0
ON = 1
}

76 changes: 76 additions & 0 deletions FppTest/state_machine/DeviceSm.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@

// ======================================================================
// \title DeviceSm.h
// \author Auto-generated
// \brief header file for state machine DeviceSm
//
// ======================================================================

#ifndef DEVICESM_H_
#define DEVICESM_H_

#include <Fw/Sm/SmSignalBuffer.hpp>
#include <config/FpConfig.hpp>

namespace FppTest {

class DeviceSm_Interface {
public:
enum DeviceSm_Signals {
RTI_SIG,
};


virtual bool DeviceSm_g1(const FwEnumStoreType stateMachineId) = 0;


virtual bool DeviceSm_g2(
const FwEnumStoreType stateMachineId,
const DeviceSm_Interface::DeviceSm_Signals signal,
const Fw::SmSignalBuffer &data) = 0;


virtual void DeviceSm_turnOff(const FwEnumStoreType stateMachineId) = 0;


virtual void DeviceSm_a1(
const FwEnumStoreType stateMachineId,
const DeviceSm_Interface::DeviceSm_Signals signal,
const Fw::SmSignalBuffer &data) = 0;


virtual void DeviceSm_turnOn(const FwEnumStoreType stateMachineId) = 0;


virtual void DeviceSm_a2(const FwEnumStoreType stateMachineId) = 0;


};

class DeviceSm {

private:
DeviceSm_Interface *parent;

public:

DeviceSm(DeviceSm_Interface* parent) : parent(parent) {}

enum DeviceSm_States {
OFF,
ON,
};

enum DeviceSm_States state;

void init(const FwEnumStoreType stateMachineId);
void update(
const FwEnumStoreType stateMachineId,
const DeviceSm_Interface::DeviceSm_Signals signal,
const Fw::SmSignalBuffer &data
);
};

}

#endif
16 changes: 16 additions & 0 deletions FppTest/state_machine/DeviceSm.plantuml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@

@startuml

[*] --> OFF

state OFF {
OFF::Entry: turnOff()
}

state ON {
ON::Entry: turnOn()
}

OFF --> ON : RTI [g1()]/a1(e)
ON --> OFF : RTI [g2(e)]/a2()
@enduml
98 changes: 98 additions & 0 deletions FppTest/state_machine/HackSm.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@

// ======================================================================
// \title HackSm.cpp
// \author Auto-generated
// \brief cpp file for state machine HackSm
//
// ======================================================================

#include <Fw/Types/Assert.hpp>
#include "HackSm.hpp"


void FppTest::HackSm::init(const FwEnumStoreType stateMachineId)
{
parent->HackSm_turnOff(stateMachineId);
this->state = OFF;

}


void FppTest::HackSm::update(
const FwEnumStoreType stateMachineId,
const HackSm_Interface::HackSm_Signals signal,
const Fw::SmSignalBuffer &data
)
{
switch (this->state) {

/**
* state OFF
*/
case OFF:

switch (signal) {

case HackSm_Interface::HackSm_Signals::RTI_SIG:
parent->HackSm_turnOn(stateMachineId);
this->state = ON;

break;

case HackSm_Interface::HackSm_Signals::CHECK_SIG:
parent->HackSm_doDiag(stateMachineId);
this->state = DIAG;

break;

default:
break;
}
break;

/**
* state ON
*/
case ON:

switch (signal) {

case HackSm_Interface::HackSm_Signals::RTI_SIG:
parent->HackSm_turnOff(stateMachineId);
this->state = OFF;

break;

case HackSm_Interface::HackSm_Signals::CHECK_SIG:
parent->HackSm_doDiag(stateMachineId);
this->state = DIAG;

break;

default:
break;
}
break;

/**
* state DIAG
*/
case DIAG:

switch (signal) {

case HackSm_Interface::HackSm_Signals::RTI_SIG:
parent->HackSm_turnOff(stateMachineId);
this->state = OFF;

break;

default:
break;
}
break;

default:
FW_ASSERT(0);
}
}
Loading
Loading