create hsmc repo
This commit is contained in:
commit
0506ec019b
26 files changed
+5413
No files matched your search
@@ -0,0 +1,72 @@
|
||||
#include "traffic.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include <windows.h> // for Sleep()
|
||||
#include <conio.h> // for kbhit()
|
||||
|
||||
|
||||
class MyStoplight: public stoplight
|
||||
{
|
||||
public:
|
||||
virtual void DoPOST()
|
||||
{
|
||||
printf("DoPOST\n");
|
||||
}
|
||||
virtual void CheckForError()
|
||||
{
|
||||
if ( kbhit() )
|
||||
{
|
||||
printf("Encountered critical error\n");
|
||||
HSMTrigger(FAILURE);
|
||||
}
|
||||
}
|
||||
virtual void GreenOff ()
|
||||
{
|
||||
printf("Green Off\n");
|
||||
}
|
||||
virtual void GreenOn()
|
||||
{
|
||||
printf("Green On\n");
|
||||
}
|
||||
virtual void YellowOff()
|
||||
{
|
||||
printf("Yellow Off\n");
|
||||
}
|
||||
virtual void YellowOn()
|
||||
{
|
||||
printf("Yellow On\n");
|
||||
}
|
||||
virtual void RedOff()
|
||||
{
|
||||
printf("Red Off\n");
|
||||
}
|
||||
virtual void RedOn()
|
||||
{
|
||||
printf("Red On\n");
|
||||
}
|
||||
|
||||
virtual void EnableRedFlashMode()
|
||||
{
|
||||
printf("Setting Red Flash mode\n");
|
||||
}
|
||||
|
||||
virtual void HSMDebug(char* msg)
|
||||
{
|
||||
printf("HSMDebug: %s\n",msg);
|
||||
}
|
||||
};
|
||||
|
||||
int main()
|
||||
{
|
||||
printf("Press any key to simulate Error.\n");
|
||||
|
||||
MyStoplight s;
|
||||
s.HSMConstruct();
|
||||
while ( s.HSMUpdate(0.1f) )
|
||||
{
|
||||
Sleep(100);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
|
||||
Machine(stoplight,30)
|
||||
{
|
||||
// perform power on self test
|
||||
Entry(DoPOST);
|
||||
|
||||
// first state is Red
|
||||
Default(Red);
|
||||
|
||||
// poll for a FAILURE event
|
||||
Idle(CheckForError);
|
||||
|
||||
// machine exits on FAILURE event
|
||||
Terminate(FAILURE);
|
||||
|
||||
// if machine exits, switch to Flash Mode
|
||||
Exit(EnableRedFlashMode);
|
||||
|
||||
// red light state
|
||||
State(Red)
|
||||
{
|
||||
Entry(RedOn);
|
||||
Exit(RedOff);
|
||||
|
||||
Transition(5.0,Green);
|
||||
}
|
||||
|
||||
// green light state
|
||||
State(Green)
|
||||
{
|
||||
Entry(GreenOn);
|
||||
Exit(GreenOff);
|
||||
|
||||
Transition(5,Yellow);
|
||||
}
|
||||
|
||||
// yellow light state
|
||||
State(Yellow)
|
||||
{
|
||||
Entry(YellowOn);
|
||||
Exit(YellowOff);
|
||||
|
||||
Transition(1.000000,Red);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user