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.
57 lines
1.2 KiB
57 lines
1.2 KiB
|
|
#ifndef _TURNOUT_H_
|
|
#define _TURNOUT_H_
|
|
|
|
#include "modelbahn.h"
|
|
#include "server.h"
|
|
//
|
|
#define TURNOUT_F_INVERSE 0x0001 // inverse output
|
|
#define TURNOUT_F_ACTIVE 0x0002 // motor active
|
|
#define TURNOUT_F_TURNOUT 0x0004 // turnout active
|
|
|
|
#define TURNOUT_DEFAULT_ACTIVETIMEOUT 250 // active timeout default value
|
|
|
|
struct s_Turnout {
|
|
char name[REFERENCENAME_LEN]; // reference name
|
|
char ifname[REFERENCENAME_LEN]; // controllername
|
|
int addr; // address on bus
|
|
int flags; // setup of some flags;
|
|
int activetimeout; // time in ms // 0 will be set to DEFAULT
|
|
struct timeval activatetime; // set both to 0 for inactive
|
|
} typedef Turnout;
|
|
|
|
|
|
class Turnouts {
|
|
private:
|
|
Turnout *turnouts;
|
|
int max;
|
|
int changed;
|
|
|
|
pthread_mutex_t mtx;
|
|
int Lock();
|
|
int UnLock();
|
|
|
|
// not thread safe
|
|
JSONParse _GetJSON(int idx);
|
|
public:
|
|
Turnouts();
|
|
~Turnouts();
|
|
|
|
bool IsChanged() { return changed; };
|
|
void ClearChanged() { changed = 0; };
|
|
|
|
int Change(Turnout *to);
|
|
int Delete(string name);
|
|
int Set(string name, int active);
|
|
|
|
void Loop();
|
|
|
|
JSONParse GetJSON(string name);
|
|
void GetJSONAll(JSONParse *json);
|
|
Turnout GetTurnoutFromJSON(JSONParse *j);
|
|
|
|
void SetFromBus(string name, int addr, int active);
|
|
};
|
|
|
|
#endif
|