PUD: split position and gateway paths
[olsrd.git] / lib / pud / src / state.h
1 #ifndef _PUD_STATE_H_
2 #define _PUD_STATE_H_
3
4 /* Plugin includes */
5 #include "receiver.h"
6
7 /* OLSRD includes */
8
9 /* System includes */
10 #include <stdbool.h>
11
12 /*
13  * Types
14  */
15
16 /** Type describing a tri-state boolean */
17 typedef enum _TristateBoolean {
18         TRISTATE_BOOLEAN_UNKNOWN = 0,
19         TRISTATE_BOOLEAN_UNSET = 1,
20         TRISTATE_BOOLEAN_SET = 2
21 } TristateBoolean;
22
23 #define TristateBooleanToString(s)      ((s == TRISTATE_BOOLEAN_SET) ? "set" : \
24                                                                          (s == TRISTATE_BOOLEAN_UNSET) ? "unset" : \
25                                                                          "unknown")
26
27 /** Type describing movement state */
28 typedef enum _MovementState {
29         MOVEMENT_STATE_STATIONARY = 0,
30         MOVEMENT_STATE_MOVING = 1
31 } MovementState;
32
33 #define MovementStateToString(s)        ((s == MOVEMENT_STATE_MOVING) ? "moving" : \
34                                                                          "stationary")
35
36 /** Type describing substate indexes */
37 typedef enum _SubStateIndex {
38         SUBSTATE_POSITION = 0,
39         SUBSTATE_GATEWAY = 1,
40         SUBSTATE_COUNT = 2
41 } SubStateIndex;
42
43 /*
44  * Functions
45  */
46
47 bool initState(void);
48 void destroyState(void);
49 MovementState getExternalState(void);
50 MovementState getInternalState(SubStateIndex subStateIndex);
51 bool determineStateWithHysteresis(SubStateIndex subStateIndex, TristateBoolean movingNow,
52                 MovementState * externalState);
53
54 #endif /* _PUD_STATE_H_ */