-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSmartUVStateMachine.h
69 lines (55 loc) · 1.83 KB
/
SmartUVStateMachine.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
/*
* File: Smart UV State Machine
* Author: Nicole Baldy
* Comments: State Machine Definition
*/
#ifndef SMART_UV_STATE_MACHINE_H
#define SMART_UV_STATE_MACHINE_H
#include <xc.h> // include processor files - each processor file is guarded.
/* strcpy */
#include <stdio.h>
#include <string.h>
#include "StateInformation.h"
#define TRUE 1
#define FALSE 0
#define bool unsigned int
typedef struct State
{
// Parent state or unknown if None. Parent executes first.
enum StateName state_name;
unsigned char display;
enum FaultName active_fault;
bool cycle_ok;
int seconds_remaining;
// TODO(NEB): Store last known sensor status, Estop status, etc here.
} State;
/* Takes current state, does all required actions,
* and then returns the state to process next cycle.
* "Public Interface", handles calls to all functions below*/
void processCurrentState(State* current_state);
State InitStateMachine();
// Treat below functions as private.
void Initialization(State* state);
void OpenDoor(State* state);
void WaitForObject(State* state);
void VerifyChamberReady(State* state);
void WaitForCycleClart(State* state);
void ActiveCycle(State* state);
void WaitForRelease(State* state);
void Fault(State* state);
// "Parent" States
void Running(State* state);
void SetFault(State* state); // TODO(NEB): Fault Codes, for now just set state.
void printFaultState(FaultName fault_name);
// Perform standard state transition actions
// Clear LCD 2nd Row
// Clear U2 Commands
void Transition(State *state, StateName new_state);
// TODO(NEB): Temporary for state proof.
enum Buttons
{
BUTTON_READY_FOR_NEXT=0x0001, // S4 generally moves forward/input recieved as per "usual use case"
BUTTON_FAULT = 0x0004, // S6 injects a fault (skip S5)
BUTTON_CLEAR_FAULT = 0x0008 // S3 clears a fault.
};
#endif /* SMART_UV_STATE_MACHINE_H */