-
Notifications
You must be signed in to change notification settings - Fork 0
/
lib-api.h
79 lines (60 loc) · 2.91 KB
/
lib-api.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
#ifndef LIBAPI_H
#define LIBAPI_H
#include <array>
#include "xn.h"
#include "lib-api-common-def.h"
#include "lib-events.h"
namespace Xn {
constexpr std::array<unsigned int, 3> API_SUPPORTED_VERSIONS {
0x0001, 0x0100, 0x0101 // v0.1, v1.0, v1.1
};
extern "C" {
using LibCallbackFunc = void CALL_CONV (*) (void *sender, void *data);
struct LibStdCallback {
LibCallbackFunc func;
void *const data;
};
struct LocoInfo {
uint16_t addr;
bool direction;
uint8_t speed;
uint8_t maxSpeed;
uint32_t functions;
bool usedByAnother;
};
using TrkAcquiredCallback = void CALL_CONV (*)(const void *sender, LocoInfo);
XN_SHARED_EXPORT bool CALL_CONV apiSupportsVersion(unsigned int version);
XN_SHARED_EXPORT int CALL_CONV apiSetVersion(unsigned int version);
XN_SHARED_EXPORT unsigned int CALL_CONV features();
XN_SHARED_EXPORT int CALL_CONV loadConfig(char16_t *filename);
XN_SHARED_EXPORT int CALL_CONV saveConfig(char16_t *filename);
XN_SHARED_EXPORT int CALL_CONV connect();
XN_SHARED_EXPORT int CALL_CONV disconnect();
XN_SHARED_EXPORT bool CALL_CONV connected();
XN_SHARED_EXPORT int CALL_CONV trackStatus();
XN_SHARED_EXPORT void CALL_CONV setTrackStatus(unsigned int trkStatus, LibStdCallback ok,
LibStdCallback err);
XN_SHARED_EXPORT void CALL_CONV emergencyStop(LibStdCallback ok, LibStdCallback err);
XN_SHARED_EXPORT void CALL_CONV locoEmergencyStop(uint16_t addr, LibStdCallback ok,
LibStdCallback err);
XN_SHARED_EXPORT void CALL_CONV locoSetSpeed(uint16_t addr, int speed, bool dir, LibStdCallback ok,
LibStdCallback err);
XN_SHARED_EXPORT void CALL_CONV locoSetFunc(uint16_t addr, uint32_t funcMask, uint32_t funcState,
LibStdCallback ok, LibStdCallback err);
XN_SHARED_EXPORT void CALL_CONV locoAcquire(uint16_t addr, TrkAcquiredCallback,
LibStdCallback err);
XN_SHARED_EXPORT void CALL_CONV locoRelease(uint16_t addr, LibStdCallback ok);
XN_SHARED_EXPORT void CALL_CONV pomWriteCv(uint16_t addr, uint16_t cv, uint8_t value,
LibStdCallback ok, LibStdCallback err);
XN_SHARED_EXPORT void CALL_CONV bindBeforeOpen(TrkStdNotifyEvent f, void *data);
XN_SHARED_EXPORT void CALL_CONV bindAfterOpen(TrkStdNotifyEvent f, void *data);
XN_SHARED_EXPORT void CALL_CONV bindBeforeClose(TrkStdNotifyEvent f, void *data);
XN_SHARED_EXPORT void CALL_CONV bindAfterClose(TrkStdNotifyEvent f, void *data);
XN_SHARED_EXPORT void CALL_CONV bindOnTrackStatusChange(TrkStatusChangedEv f, void *data);
XN_SHARED_EXPORT void CALL_CONV bindOnLog(TrkLogEv f, void *data);
XN_SHARED_EXPORT void CALL_CONV bindOnLocoStolen(TrkLocoEv f, void *data);
XN_SHARED_EXPORT void CALL_CONV bindOnOpenError(TrkMsgEv f, void *data);
XN_SHARED_EXPORT void CALL_CONV showConfigDialog();
}
} // namespace Xn
#endif