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.
60 lines
1.0 KiB
60 lines
1.0 KiB
|
|
#ifndef _LOCOMOTIVE_H_
|
|
#define _LOCOMOTIVE_H_
|
|
|
|
#include "modelbahn.h"
|
|
#include "server.h"
|
|
|
|
#define LOCO_F_REVERSE 0x0001
|
|
|
|
struct s_Locomotive {
|
|
char name[REFERENCENAME_LEN];
|
|
char ifname[REFERENCENAME_LEN];
|
|
int steps;
|
|
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 SetFunction(string name, int func, int value);
|
|
|
|
int SetSpeedFromBus (string name, int addr, int speed);
|
|
int SetDirectionFromBus (string name, int addr, int speed);
|
|
|
|
JSONParse GetJSON(string name);
|
|
void GetJSONAll(JSONParse *json);
|
|
Locomotive GetLocomotiveFromJSON(JSONParse *j);
|
|
};
|
|
|
|
|
|
#endif
|