|
|
@ -29,8 +29,40 @@
|
|
|
|
#include "sensor.h"
|
|
|
|
#include "sensor.h"
|
|
|
|
#include "interface.h"
|
|
|
|
#include "interface.h"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
|
|
|
SSTATUS_STARTUP,
|
|
|
|
|
|
|
|
SSTATUS_RESET,
|
|
|
|
|
|
|
|
SSTATUS_MANUAL,
|
|
|
|
|
|
|
|
SSTATUS_AUTO,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
SSTATUS_MAX
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
enum {
|
|
|
|
|
|
|
|
MRESET_STEP_INTERFACES,
|
|
|
|
|
|
|
|
MRESET_STEP_LOCOMOTIVES,
|
|
|
|
|
|
|
|
MRESET_STEP_TURNOUTS,
|
|
|
|
|
|
|
|
MRESET_STEP_SENSORS,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
MRESET_STEP_MAX
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
struct {
|
|
|
|
|
|
|
|
int mr_step; // current step
|
|
|
|
|
|
|
|
int mr_timestamp; // timestamp ( needed for times )
|
|
|
|
|
|
|
|
int mr_idx; // mode index
|
|
|
|
|
|
|
|
} typedef ModeResetData;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Server {
|
|
|
|
class Server {
|
|
|
|
private:
|
|
|
|
private:
|
|
|
|
|
|
|
|
int status; // holds the current mode
|
|
|
|
|
|
|
|
int status_progress; // to return a value from 0-100
|
|
|
|
|
|
|
|
string status_text; // some text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
ModeResetData data_reset;
|
|
|
|
|
|
|
|
|
|
|
|
pthread_mutex_t mtx;
|
|
|
|
pthread_mutex_t mtx;
|
|
|
|
pthread_t thread;
|
|
|
|
pthread_t thread;
|
|
|
|
int thread_running;
|
|
|
|
int thread_running;
|
|
|
@ -74,6 +106,24 @@ public:
|
|
|
|
int GetHeight() { return railways.GetHeight(); };
|
|
|
|
int GetHeight() { return railways.GetHeight(); };
|
|
|
|
int GetWidth() { return railways.GetWidth(); };
|
|
|
|
int GetWidth() { return railways.GetWidth(); };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Load Save Part
|
|
|
|
|
|
|
|
int Load();
|
|
|
|
|
|
|
|
int Save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Reset dynamic data
|
|
|
|
|
|
|
|
// FIXME:
|
|
|
|
|
|
|
|
// FIXME:
|
|
|
|
|
|
|
|
// FIXME: finish me
|
|
|
|
|
|
|
|
// FIXME:
|
|
|
|
|
|
|
|
// FIXME:
|
|
|
|
|
|
|
|
JSONParse GetJSONServerStatus();
|
|
|
|
|
|
|
|
void ModeReset(); // mode Reset if finished will go to Manual
|
|
|
|
|
|
|
|
void ModeManual(); // Manual Mode
|
|
|
|
|
|
|
|
void ModeAuto(); // only allowed if Manual was set
|
|
|
|
|
|
|
|
void ModeError(); // will cut power and keep this mode, until reset or Mode Manual
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////
|
|
|
|
// Railway
|
|
|
|
// Railway
|
|
|
|
int RailwayChange(Railway *rw) { return railways.Change(rw);};
|
|
|
|
int RailwayChange(Railway *rw) { return railways.Change(rw);};
|
|
|
@ -104,6 +154,7 @@ public:
|
|
|
|
JSONParse LocomotiveGetJSON(string name) { return locomotives.GetJSON(name); };
|
|
|
|
JSONParse LocomotiveGetJSON(string name) { return locomotives.GetJSON(name); };
|
|
|
|
int LocomotiveDelete(string name) { return locomotives.Delete(name); };
|
|
|
|
int LocomotiveDelete(string name) { return locomotives.Delete(name); };
|
|
|
|
int LocomotiveSetSpeed(string name, int speed) { return locomotives.SetSpeed(name, speed); };
|
|
|
|
int LocomotiveSetSpeed(string name, int speed) { return locomotives.SetSpeed(name, speed); };
|
|
|
|
|
|
|
|
int LocomotiveSetReverse(string name, int reverse) { return locomotives.SetReverse(name, reverse); };
|
|
|
|
int LocomotiveSetFunction(string name, int func, int value) { return locomotives.SetFunction(name, func, value); };
|
|
|
|
int LocomotiveSetFunction(string name, int func, int value) { return locomotives.SetFunction(name, func, value); };
|
|
|
|
|
|
|
|
|
|
|
|
/////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////
|
|
|
@ -118,16 +169,10 @@ public:
|
|
|
|
/////////////////////////////////////////
|
|
|
|
/////////////////////////////////////////
|
|
|
|
// reports from interfaces
|
|
|
|
// reports from interfaces
|
|
|
|
int LocomotiveAddrSpeed(string name, int addr, int speed) { return locomotives.SetSpeedFromBus(name, addr, speed); };
|
|
|
|
int LocomotiveAddrSpeed(string name, int addr, int speed) { return locomotives.SetSpeedFromBus(name, addr, speed); };
|
|
|
|
int LocomotiveAddrDirection(string name, int addr, int reverse) { return locomotives.SetDirectionFromBus(name, addr, reverse); };
|
|
|
|
int LocomotiveAddrFunction(string name, int addr, int func) { return locomotives.SetFunctionFromBus(name, addr, func); };
|
|
|
|
int TurnoutAddrMode(string name, int addr, int active) { turnouts.SetFromBus(name, addr, active); return 1; };
|
|
|
|
int TurnoutAddrMode(string name, int addr, int active) { turnouts.SetFromBus(name, addr, active); return 1; };
|
|
|
|
int SensorAddrChange(string name, int addr, int active) { sensors.SetFromBus(name, addr, active); return 1; };
|
|
|
|
int SensorAddrChange(string name, int addr, int active) { sensors.SetFromBus(name, addr, active); return 1; };
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//
|
|
|
|
|
|
|
|
// Load Save Part
|
|
|
|
|
|
|
|
int Load();
|
|
|
|
|
|
|
|
int Save();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
protected:
|
|
|
|
protected:
|
|
|
|
static void *ThreadEntry (void *This) { ((Server*)This)->ThreadProcess(); return NULL;};
|
|
|
|
static void *ThreadEntry (void *This) { ((Server*)This)->ThreadProcess(); return NULL;};
|
|
|
|
};
|
|
|
|
};
|
|
|
|