Files
fprime/FppTest/state_machine/DeviceSm.cpp
garthwatney d2bcd0e97c Phase 1 state machines (#2829)
* Add a state machine unit test under FppTest

* Updated the base class and unit tests work

* Remove the sendEvent function as it did not allow for data to be passed

* Add state machine in SmTest.fpp

* Add dependency in SmTest.fpp

* state machine unit test passes with new fpp phase 1

* Makefile for state machines don't use special switch

* Rebase DeviceSm.hpp

* Update on SMEvents inclusion

* Use latest phase1 fpp and STARS which uses _Interface

* Change SMEvents to SMSignals

* Use SMSignals instead of SMEvents

* Update test for state machine instance priority and full queue behavior

* 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

* Fixes for reserved word state and address review comments

* Fix other review issues pertaining to unit tests and argument checks in the SmSignalBuffer constructors

* Add a cast to NATIVE_UINT_TYPE in SmSignalBuffer

* Fixing type

* Fixing size type in cpp

---------

Co-authored-by: watney <garth.j.watney@jpl.nasa.gov>
Co-authored-by: Rob Bocchino <bocchino@jpl.nasa.gov>
Co-authored-by: M Starch <LeStarch@googlemail.com>
2024-09-19 12:19:11 -07:00

75 lines
1.9 KiB
C++

// ======================================================================
// \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);
}
}