#ifndef _LOCOMOTIVE_H_ #define _LOCOMOTIVE_H_ #include "modelbahn.h" #include "server.h" #define LOCO_F_REVERSE 0x0001 enum { LOCO_INT_UNDEF = 0, LOCO_INT_DCC14, LOCO_INT_DCC28, LOCO_INT_DCC128 }; struct s_Locomotive { char name[REFERENCENAME_LEN]; char ifname[REFERENCENAME_LEN]; int stepcode; int speed; int64_t func; int flags; int addr; int vmin; int vslow; int vmid; int vfast; int vmax; } typedef Locomotive; class Locomotives { private: Locomotive *locomotives; int max; int changed; pthread_mutex_t mtx; int Lock(); int UnLock(); // not thread safe JSONParse _GetJSON(int idx); public: Locomotives(); ~Locomotives(); bool IsChanged() { return changed; } void ClearChanged() { changed = 0; }; int Change(Locomotive *loco); int Delete(string name); int SetSpeed(string name, int speed); int SetReverse(string name, int reverse); int SetFunction(string name, int func, int value); int SetSpeedFromBus (string ifname, int addr, int speed); int SetFunctionFromBus (string ifname, int addr, int func); string GetName(int idx); JSONParse GetJSON(string name); void GetJSONAll(JSONParse *json); Locomotive GetLocomotiveFromJSON(JSONParse *j); }; #endif