-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSensorProxy.ph
82 lines (62 loc) · 2.43 KB
/
SensorProxy.ph
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
/**
*
*
* @author Laurent Winkler based on work by Valentin Bourqui
* @date Dec 2014
* @brief Proxy class that handles communication with one sensor but resides on the same machine as the gateway. Each proxy is connected to one sensor on the network.
*
*
*/
#ifndef SENSOR_PROXY_H
#define SENSOR_PROXY_H
#include <atomic>
#include <fstream>
#include "POPSensor.ph"
#include "lineComm/popwin_messages.h"
parclass SensorProxy {
classuid(1903);
public:
SensorProxy(int x_id, const std::string& x_url, const std::string& x_device) @{ od.url(x_url); };
~SensorProxy();
/// Send notification to the connected sensor
async seq void Notify(int x_measurementType, int x_measurementUnit, const std::string& x_message);
async seq void Notify(int x_measurementType, int x_measurementUnit, double x_data);
async seq void Notify(int x_measurementType, int x_measurementUnit, int x_data);
/// Send a publication to the connected sensor
async seq void Publish(int x_measurementType);
/// Gateway cannot send notifications to actuators anymore
async seq void UnPublish(int x_measurementType);
//async seq void Publish(int x_publicationType, int x_data);
//async seq void Publish(int x_publicationType, double x_data);
//async seq void Publish(int x_publicationType, const std::string& x_data);
/// Apply a reduce function to the data {size, min, max, aver, sum, stdev}
sync seq double Reduce(int x_mtype, int x_dataType, int x_fct);
/// Gateway can send notifications to actuators
//async seq void CanPublish(int x_publicationType);
/// Send a subscription to the connected sensor
async seq void Subscribe(int x_measurementType, int x_dataType);
/// Send an unsubscription to the connected sensor
async seq void UnSubscribe(int x_measurementType, int x_dataType);
/// Send a notification to set the gwID GW as a GW
async seq void SetAsGateway(int gwID);
/// Send data to the remote sensors
async conc void StartListening();
async conc void StopListening();
/// Retrieve data gathered
sync conc POPSensorData Gather();
/// Clear data gathered
async conc void Clear();
sync conc int GetDataSize();
private:
void SendRawData(const std::string& x_data);
void ReadData(std::ostream& xr_ostream);
void HandleIncomingMessage(const std::string& x_msg);
int m_fd;
int m_id;
std::atomic<bool> m_listening;
std::map<int,bool> m_subscriptions;
std::map<int,bool> m_publications;
// Different containers of data
POPSensorData m_sensorData;
};
#endif