forked from nasa/fprime
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Get unit tests updated and working for fpp state machines phase 1 del…
…ivery
- Loading branch information
watney
committed
Aug 28, 2024
1 parent
ff7b023
commit 08d8135
Showing
13 changed files
with
363 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,100 @@ | ||
|
||
// ====================================================================== | ||
// \title HackSm.cpp | ||
// \author Auto-generated | ||
// \brief cpp file for state machine HackSm | ||
// | ||
// ====================================================================== | ||
|
||
#include "stdio.h" | ||
#include "assert.h" | ||
#include "Fw/Types/SMSignalsSerializableAc.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::HackSmEvents signal, | ||
const Fw::SMSignalBuffer &data | ||
) | ||
{ | ||
switch (this->state) { | ||
|
||
/** | ||
* state OFF | ||
*/ | ||
case OFF: | ||
|
||
switch (signal) { | ||
|
||
case HackSm_Interface::HackSmEvents::RTI_SIG: | ||
parent->HackSm_turnOn(stateMachineId); | ||
this->state = ON; | ||
|
||
break; | ||
|
||
case HackSm_Interface::HackSmEvents::CHECK_SIG: | ||
parent->HackSm_doDiag(stateMachineId); | ||
this->state = DIAG; | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
break; | ||
|
||
/** | ||
* state ON | ||
*/ | ||
case ON: | ||
|
||
switch (signal) { | ||
|
||
case HackSm_Interface::HackSmEvents::RTI_SIG: | ||
parent->HackSm_turnOff(stateMachineId); | ||
this->state = OFF; | ||
|
||
break; | ||
|
||
case HackSm_Interface::HackSmEvents::CHECK_SIG: | ||
parent->HackSm_doDiag(stateMachineId); | ||
this->state = DIAG; | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
break; | ||
|
||
/** | ||
* state DIAG | ||
*/ | ||
case DIAG: | ||
|
||
switch (signal) { | ||
|
||
case HackSm_Interface::HackSmEvents::RTI_SIG: | ||
parent->HackSm_turnOff(stateMachineId); | ||
this->state = OFF; | ||
|
||
break; | ||
|
||
default: | ||
break; | ||
} | ||
break; | ||
|
||
default: | ||
assert(0); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
|
||
// ====================================================================== | ||
// \title HackSm.h | ||
// \author Auto-generated | ||
// \brief header file for state machine HackSm | ||
// | ||
// ====================================================================== | ||
|
||
#ifndef HACKSM_H_ | ||
#define HACKSM_H_ | ||
|
||
#include <Fw/SMSignal/SMSignalBuffer.hpp> | ||
#include <config/FpConfig.hpp> | ||
|
||
namespace Fw { | ||
class SMSignals; | ||
} | ||
|
||
namespace FppTest { | ||
|
||
class HackSm_Interface { | ||
public: | ||
enum HackSmEvents { | ||
RTI_SIG, | ||
CHECK_SIG, | ||
}; | ||
|
||
|
||
virtual void HackSm_turnOff(const FwEnumStoreType stateMachineId) = 0; | ||
|
||
|
||
virtual void HackSm_turnOn(const FwEnumStoreType stateMachineId) = 0; | ||
|
||
|
||
virtual void HackSm_doDiag(const FwEnumStoreType stateMachineId) = 0; | ||
|
||
|
||
}; | ||
|
||
class HackSm { | ||
|
||
private: | ||
HackSm_Interface *parent; | ||
|
||
public: | ||
|
||
HackSm(HackSm_Interface* parent) : parent(parent) {} | ||
|
||
enum HackSmStates { | ||
OFF, | ||
ON, | ||
DIAG, | ||
}; | ||
|
||
enum HackSmStates state; | ||
|
||
void * extension; | ||
|
||
void init(const FwEnumStoreType stateMachineId); | ||
void update( | ||
const FwEnumStoreType stateMachineId, | ||
const HackSm_Interface::HackSmEvents signal, | ||
const Fw::SMSignalBuffer &data | ||
); | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
@startuml | ||
|
||
[*] --> OFF | ||
|
||
state OFF { | ||
OFF::Entry: turnOff() | ||
} | ||
|
||
state ON { | ||
ON::Entry: turnOn() | ||
} | ||
|
||
state DIAG { | ||
DIAG::Entry: doDiag() | ||
} | ||
|
||
OFF --> ON : RTI | ||
ON --> OFF : RTI | ||
ON --> DIAG : CHECK | ||
OFF --> DIAG : CHECK | ||
DIAG --> OFF : RTI | ||
@enduml |
Oops, something went wrong.