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.
82 lines
1.9 KiB
82 lines
1.9 KiB
|
|
#ifndef _INTERFACE_Z21_H_
|
|
#define _INTERFACE_Z21_H_
|
|
|
|
#include "modelbahn.h"
|
|
#include "interface.h"
|
|
#include <UDPTCPNetwork.h>
|
|
|
|
#define INTF_Z21_TIMEOUT 10
|
|
#define INTF_Z21_INBUFFER 2048
|
|
|
|
// STATUSCHANGED / CENTRALSTATE
|
|
#define INTF_Z21_CS_EmergencyStop 0x01
|
|
#define INTF_Z21_CS_TrackVoltageOff 0x02
|
|
#define INTF_Z21_CS_ShortCircuit 0x04
|
|
#define INTF_Z21_CS_ProgModeActive 0x20
|
|
|
|
#define INTF_Z21_LOCONET_MAXADDR 255
|
|
#define INTF_Z21_RMSENSOR_GROUPS 2
|
|
#define INTF_Z21_RMSENSOR_BYTES 10
|
|
#define INTF_Z21_RMGETDATA_TIMEOUT 30
|
|
|
|
struct s_loconet_map{
|
|
int addr;
|
|
int dir;
|
|
int steps;
|
|
int speed;
|
|
int maxspeed;
|
|
};
|
|
|
|
class InterfaceZ21 {
|
|
private:
|
|
string hostname;
|
|
string serial;
|
|
char inbuffer[INTF_Z21_INBUFFER];
|
|
struct s_loconet_map loconet_map[INTF_Z21_LOCONET_MAXADDR];
|
|
struct s_loconet_map loconet_last; // needed for detecting loco_changes
|
|
|
|
UDP udp;
|
|
time_t timeout;
|
|
time_t rmgetdatatimeout;
|
|
bool send_logon;
|
|
|
|
bool status_poweron;
|
|
bool status_shortcircuit;
|
|
bool status_programmingmode;
|
|
bool status_connected;
|
|
bool status_emergencystop;
|
|
|
|
unsigned char rmsensors[INTF_Z21_RMSENSOR_BYTES * INTF_Z21_RMSENSOR_GROUPS];
|
|
int rmsensorinit;
|
|
|
|
// void send_X_SET_TRACK_POWER_ON();
|
|
// void send_X_SET_TRACK_POWER_OFF();
|
|
void send_GET_SERIAL_NUMBER();
|
|
void send_SET_BROADCASTFLAGS();
|
|
void send_LOGOFF();
|
|
void send_RM_GETDATA(int group);
|
|
|
|
public:
|
|
InterfaceZ21();
|
|
~InterfaceZ21();
|
|
|
|
void Connect(string destination);
|
|
void Disconnect();
|
|
|
|
bool IsConnected() { return status_connected; };
|
|
bool IsPoweron() { return status_poweron; };
|
|
bool IsSortCircuit() { return status_shortcircuit; };
|
|
bool IsProgramminnMode() { return status_programmingmode; };
|
|
bool IsEmergencyStop() { return status_emergencystop; };
|
|
|
|
int Loop(string interfacename);
|
|
void PowerOnOff(int onoff);
|
|
void SetLocoSpeed(Locomotive *l, int step);
|
|
void SetLocoFunction(Locomotive *l, int func, int value);
|
|
void SetTurnout(Turnout *t, int activate, int motoractive);
|
|
};
|
|
|
|
|
|
#endif
|