-
Notifications
You must be signed in to change notification settings - Fork 79
Expand file tree
/
Copy pathMeadeParserGet.cpp
More file actions
126 lines (119 loc) · 2.89 KB
/
MeadeParserGet.cpp
File metadata and controls
126 lines (119 loc) · 2.89 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
/**
* @file MeadeParserGet.cpp
* @brief Get-family (`:G...`) dispatcher for the Meade LX200 parser.
*/
#include "MeadeParser.hpp"
#include "MeadeParserHelpers.hpp"
namespace oat
{
namespace core
{
namespace meade
{
void handleMeadeGet(MeadeResponse &r, const char *s, IMeadeGetHandlers &h)
{
if (!s || s[0] == '\0')
{
return;
}
// Two-character commands.
if (s[1] != '\0' && s[2] == '\0')
{
if (s[0] == 'V')
{
switch (s[1])
{
case 'N':
writeCString(r, h.onFirmwareVersion());
return;
case 'P':
writeCString(r, h.onProductName());
return;
default:
return;
}
}
if (s[0] == 'I')
{
switch (s[1])
{
case 'S':
writeBool01(r, h.onIsSlewing());
return;
case 'T':
writeBool01(r, h.onIsTracking());
return;
case 'G':
writeBool01(r, h.onIsGuiding());
return;
default:
return;
}
}
return;
}
// Single-character commands.
if (s[1] != '\0')
{
return;
}
switch (s[0])
{
case 'R':
writeRa(r, h.onCurrentRa());
return;
case 'r':
writeRa(r, h.onTargetRa());
return;
case 'D':
writeDec(r, h.onCurrentDec());
return;
case 'd':
writeDec(r, h.onTargetDec());
return;
case 'X':
writeCString(r, h.onMountStatus());
return;
case 't':
writeLatitude(r, h.onSiteLatitude());
return;
case 'g':
writeLongitude(r, h.onSiteLongitude());
return;
case 'G':
writeUtcOffset(r, h.onUtcOffset());
return;
case 'a':
writeTime12h(r, h.onLocalTime());
return;
case 'L':
writeTime24h(r, h.onLocalTime());
return;
case 'C':
writeLocalDate(r, h.onLocalDate());
return;
case 'c':
writeClockFormat(r, h.onClockFormat());
return;
case 'T':
writeTrackingRate(r, h.onTrackingRate());
return;
case 'M':
writeCString(r, h.onSiteName(1));
return;
case 'N':
writeCString(r, h.onSiteName(2));
return;
case 'O':
writeCString(r, h.onSiteName(3));
return;
case 'P':
writeCString(r, h.onSiteName(4));
return;
default:
return;
}
}
} // namespace meade
} // namespace core
} // namespace oat