You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
49 lines
801 B
49 lines
801 B
|
|
#ifndef _SENSOR_H_
|
|
#define _SENSOR_H_
|
|
|
|
#define SENSOR_F_INVERSE 0x0001
|
|
#define SENSOR_F_ACTIVE 0x0002
|
|
|
|
#include "modelbahn.h"
|
|
#include "server.h"
|
|
|
|
struct s_Sensor {
|
|
char name[REFERENCENAME_LEN];
|
|
char ifname[REFERENCENAME_LEN];
|
|
int addr;
|
|
int flags;
|
|
} typedef Sensor;
|
|
|
|
class Sensors {
|
|
private:
|
|
Sensor *sensors;
|
|
int max;
|
|
int changed;
|
|
|
|
pthread_mutex_t mtx;
|
|
int Lock();
|
|
int UnLock();
|
|
|
|
// not thread safe
|
|
JSONParse _GetJSON(int idx);
|
|
public:
|
|
Sensors();
|
|
~Sensors();
|
|
|
|
bool IsChanged() { return changed; }
|
|
void ClearChanged() { changed = 0; };
|
|
|
|
int Change(Sensor *se);
|
|
int Delete(string name);
|
|
|
|
JSONParse GetJSON(string name);
|
|
void GetJSONAll(JSONParse *json);
|
|
Sensor GetSensorFromJSON(JSONParse *j);
|
|
|
|
void SetFromBus(string name, int addr, int active);
|
|
};
|
|
|
|
|
|
#endif
|