-
Notifications
You must be signed in to change notification settings - Fork 0
/
Drone.h
103 lines (79 loc) · 2.72 KB
/
Drone.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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#ifndef _drone_h
#define _drone_h
#include "application.h"
typedef enum
{
SENSOR_MODE_PULSE = (1),
SENSOR_MODE_TIME = (2)
} sensor_mode;
typedef struct
{
float value; //sensor value
float lastValue; //sensor lastValue
float acumulatedValue; //sensor acumulatedValue (between Publish)
bool changed; //value changed since last read
float lastPublishedValue = 0; //LastPublished Value
int timestamp; //LastRead
int lastChange; //Elapsed time since last change
bool triggerNotification; //If must trigger a Notification
bool triggerWorker; //If must trigger a Worker
float acumulatedNotification; //Number of times Notification has fired
bool triggerPublish; //If must trigger a Publish to cloud (sin importar si paso el tiempo)
bool firstTriggerPublish = true; //Only Fire ONE time per Notification.
} sensor_event;
typedef struct
{
int droneID;
int type; //Sensor type example SENSOR_TYPE_SWITCH
int pin; //Pin conected to Photon
int pin2; //Used for some sensors
int buzzerNotificationID; /**< Has a Buzer ID */
int rgbNotificationID; /**< Has a RGB ID */
int notificationElapsedTime; /**< Notification en elapsed Time */
int fieldID;
int notificationFieldID;
sensor_mode mode; /**< Pulse or Time Sensor*/
int workerID = -1; /**< Asociated with a Worker */
int workerElapsedTime = 0; /**< WorkerDelayedTime */
bool inverted; //If triggers on HIGH or LOW value
} sensor;
typedef enum
{
SENSOR_TYPE_SWITCH = (1),
SENSOR_TYPE_TEMP = (2),
SENSOR_TYPE_DIGITAL = (3),
SENSOR_TYPE_ANALOG = (4),
SENSOR_TYPE_AMBIENT_TEMP= (5)
} sensor_type;
//DronePresence;
//DroneLight;
//DroneButton; ???
//DroneLine1;
//DroneLine2;
//DroneLine3;
//DroneDistance;
//DroneAmbientTemperature;
//DroneAmbientHumidity
//DroneTemperature1;
//DroneTemperature2;
//DroneSoilMoisture1;
//DroneSoilMoisture2;
//DroneRain;
//DroneWaterLevel1;
//DroneWaterLevel2;
//DroneSound;
//DroneLightLevel;
//DroneAmp;
//DroneVolt;
//DroneGas;
class Drone {
public:
Drone() {}
//virtual ~Drone() {}
//Thease must be defined by the subClass
virtual void SetUpSensor(sensor);
virtual void GetEvent(sensor_event*);
virtual void GetSensor(sensor*);
virtual void Publish(sensor_event*);
};
#endif