-
Notifications
You must be signed in to change notification settings - Fork 0
/
srcp.h
62 lines (47 loc) · 1.57 KB
/
srcp.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
#ifndef SRCP_H
#define SRCP_H
#include <memory>
#include "Hardware.h"
class SRCPReply {
public:
SRCPReply(const char *message);
~SRCPReply();
enum SRCPReplyCodeType {INFO, OK, ERROR};
SRCPReplyCodeType type;
double timestamp;
char *message;
int code;
void operator = (const SRCPReply &rhs); // gibts nicht
};
typedef std::auto_ptr<SRCPReply> SRCPReplyPtr;
class SRCP {
public:
SRCP();
virtual ~SRCP();
virtual void pwrOn();
virtual void pwrOff();
static bool powered;
SRCPReplyPtr sendLocoInit(int addr, int nFahrstufen, int nFunc);
// add:0... dir:0 zurück 1 vor 2 notstop, nFahrstufen: 14, ,nFunc:4
SRCPReplyPtr sendLocoSpeed(int addr, int dir, int nFahrstufen, int speed, int nFunc, bool *func);
SRCPReplyPtr sendPOM(int addr, int cv, int value);
SRCPReplyPtr sendPOMBit(int addr, int cv, int bitNr, bool value);
bool getInfo(int addr, int *dir, int *dccSpeed, int nFunc, bool *func);
SRCPReplyPtr sendMessage(const char *msg);
SRCPReplyPtr readReply();
private:
int so;
};
// verwendet lokdef.h etc
class SRCP_Hardware : public Hardware, public SRCP {
virtual void pwrOn() { SRCP::pwrOn(); };
virtual void pwrOff() { SRCP::pwrOff(); };
virtual bool getPowerState() { return this->powered; };
void fullstop(bool stopAll, bool emergenyStop);
void sendLoco(int addr_index, bool emergencyStop);
virtual int sendPOM(int addr, int cv, int value);
virtual int sendPOMBit(int addr, int cv, int bitNr, bool value) { return SRCP::sendPOMBit(addr, cv, bitNr, value)->type != SRCPReply::OK ? -1 : value ; };
};
extern const char *cfg_hostname;
extern int cfg_port;
#endif