-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCyranoHandler.h
executable file
·83 lines (72 loc) · 2.58 KB
/
CyranoHandler.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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef CYRANOHANDLER_H
#define CYRANOHANDLER_H
#include <WiFi.h>
#include "AsyncUDP.h"
#include <iostream>
#include "EFP1Message.h"
#include "SubjectObserverTemplate.h"
#include "FencingStateMachine.h"
#include "EventDefinitions.h"
#include <Preferences.h>
#define CYRANO_PORT 50101
#define CYRANO_BROADCAST_PORT 50100
enum CyranoState
{
FENCING,
HALT,
PAUSE,
ENDING,
WAITING
};
/*enum EventType
{
NextButtonPressed,
PrevButtonPressed,
BeginButtonPressed,
EndButtonPressed
};*/
class UDPIOHandler;
class CyranoHandler : public Observer<FencingStateMachine> , public Observer<UDPIOHandler>, public Subject<CyranoHandler>, public SingletonMixin<CyranoHandler>
{
public:
/** Default destructor */
virtual ~CyranoHandler();
void ProcessMessageFromSoftware(const EFP1Message &input);
void SendInfoMessage();
void ProcessUIEvents(uint32_t const event);
void SetPisteID(const string & ID){m_MachineStatus[PisteId]=ID;};
void update (FencingStateMachine *subject, uint32_t eventtype);
void update (UDPIOHandler *subject, uint32_t eventtype){ProcessUIEvents(eventtype);};
void StateChanged (uint32_t eventtype) {notify(eventtype);}
void StateChanged (string eventtype) {notify(eventtype);}
void ProcessLightsChange(uint32_t eventtype);
void CheckConnection();
void PeriodicallyBroadcastStatus();
void Begin();
bool SoftwareIsLive(){return bSoftwareIsLive;};
IPAddress SoftwareIPAddress() {return mSoftwareIPAddress;};
void SoftwareIPAddress(IPAddress theSoftwareIPAddress) {mSoftwareIPAddress = theSoftwareIPAddress;};
protected:
private:
friend class SingletonMixin<CyranoHandler>;
/** Default constructor */
CyranoHandler();
EFP1Message m_MachineStatus; //!< Member variable "m_Status"
EFP1Message m_IncompleteMessage;
CyranoState m_State = WAITING;
int previous_seconds =99; // This will always result in setting a correct initial value
uint32_t m_timeToShowTimer = 0;
long NextTimeToCheckConnection = 0;
bool bWifiConnected = false;
bool bCyranoConnected = false;
AsyncUDP CyranoHandlerudpRcv;
AsyncUDP CyranoHandlerudpBroadcast;
bool bOKToSend = false;
Preferences networkpreferences;
uint16_t CyranoPort = CYRANO_PORT;
uint16_t CyranoBroadcastPort = CYRANO_BROADCAST_PORT;
long NextPeriodicalUpdate;
bool bSoftwareIsLive = false;
IPAddress mSoftwareIPAddress;
};
#endif // CYRANOHANDLER_H