-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathio.cpp
More file actions
68 lines (53 loc) · 1.42 KB
/
io.cpp
File metadata and controls
68 lines (53 loc) · 1.42 KB
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
#include "settings.h"
#include "types.h"
#include "engine_connector.h"
#include "io.h"
bool CmdCallback(HCMD callId, EngineCommand cmd, EngineConnectorResult res, EngineEvent event);
void ResponseSend(HCMD callId, EngineConnectorResult res, EngineEvent event);
static RemoteConnection subs[MAX_CONNECTIONS + 1] = { 0 };
static unsigned int freeSubIndex = 0;
static unsigned int subId = 1;
bool CmdCallback(HCMD callId, EngineCommand cmd, EngineConnectorResult res, EngineEvent event) {
switch (cmd)
{
case CMD_START_ENGINE:
if (res == ENGINE_MESSAGE && event.msg == ENGINE_START_OK)
break;
if (res == ENGINE_ERROR) {
switch (event.err)
{
case ENGINE_IN_MANUAL_MODE:
case ENGINE_STARTING_PROGRESS:
case ENGINE_SWITCHED_TO_MANUAL:
case ENGINE_START_ABORTED:
break;
}
}
return false;
case CMD_STOP_ENGINE:
if (res == ENGINE_MESSAGE && event.msg == ENGINE_STOP_OK)
break;
if (res == ENGINE_ERROR) {
switch (event.err)
{
case ENGINE_ALREADY_STOPPED:
case ENGINE_IN_MANUAL_MODE:
case ENGINE_SWITCHED_TO_MANUAL:
break;
}
}
return false;
}
ResponseSend(callId, res, event);
return true;
}
void ResponseSend(HCMD callId, EngineConnectorResult res, EngineEvent event) {
char response[2] = { res, event.msg };
for (unsigned i = 0; i < freeSubIndex; i++) {
if (subs[i].callId == callId) {
// Отправляем response[]
freeSubIndex--;
return;
}
}
}