Debian Codegraph @

nex_dome_constants.h

raw
1 /*******************************************************************************
2 Copyright(c) 2019 Jasem Mutlaq. All rights reserved.
3
4 NexDome Driver for Firmware v3+
5
6 Change Log:
7
8 2019.10.07: Driver is completely re-written to work with Firmware v3 since
9 Firmware v1 is obsolete from NexDome.
10 2017.01.01: Driver for Firmware v1 is developed by Rozeware Development Ltd.
11
12 This library is free software; you can redistribute it and/or
13 modify it under the terms of the GNU Library General Public
14 License version 2 as published by the Free Software Foundation.
15 .
16 This library is distributed in the hope that it will be useful,
17 but WITHOUT ANY WARRANTY; without even the implied warranty of
18 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
19 Library General Public License for more details.
20 .
21 You should have received a copy of the GNU Library General Public License
22 along with this library; see the file COPYING.LIB. If not, write to
23 the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
24 Boston, MA 02110-1301, USA.
25 *******************************************************************************/
26
27 #pragma once
28
29 #include <map>
30 #include <string>
31
32 namespace ND
33 {
34 enum
35 {
36 ENABLED,
37 DISABLED,
38 };
39
40 typedef enum
41 {
42 ROTATOR,
43 SHUTTER
44 } Targets;
45
46 typedef enum
47 {
48 ACCELERATION_RAMP,
49 BATTERY_VOLTAGE,
50 DEAD_ZONE,
51 SEMANTIC_VERSION,
52 GOTO_AZ,
53 GOTO_HOME,
54 GOTO_STEP,
55 HOME_POSITION,
56 POSITION,
57 RANGE,
58 REPORT,
59 EMERGENCY_STOP,
60 VELOCITY,
61 EEPROM,
62 OPEN_SHUTTER,
63 CLOSE_SHUTTER,
64 } Commands;
65
66 // Command Strings
67 static const std::map<Commands, std::string> CommandsMap =
68 {
69 {ACCELERATION_RAMP, "A"},
70 {BATTERY_VOLTAGE, "B"}, // Added in firmware V3.4.0
71 {DEAD_ZONE, "D"},
72 {SEMANTIC_VERSION, "F"},
73 {GOTO_AZ, "GA"},
74 {GOTO_HOME, "GH"},
75 {GOTO_STEP, "GS"},
76 {HOME_POSITION, "H"},
77 {POSITION, "P"},
78 {RANGE, "R"},
79 {REPORT, "S"},
80 {EMERGENCY_STOP, "S"},
81 {VELOCITY, "V"},
82 {EEPROM, "Z"},
83 {OPEN_SHUTTER, "OP"},
84 {CLOSE_SHUTTER, "CL"},
85 };
86
87 typedef enum
88 {
89 XBEE_START,
90 XBEE_WAIT,
91 XBEE_CONFIG,
92 XBEE_DETECT,
93 XBEE_ONLINE
94 } XBee;
95
96 static const std::map<XBee, std::string> XBeeMap =
97 {
98 {XBEE_START, "Start"},
99 {XBEE_WAIT, "WaitAt"},
100 {XBEE_CONFIG, "Config"},
101 {XBEE_DETECT, "Detect"},
102 {XBEE_ONLINE, "Online"},
103 };
104
105 typedef enum
106 {
107 XBEE_STATE,
108 ROTATOR_REPORT,
109 SHUTTER_REPORT,
110 ROTATOR_LEFT,
111 ROTATOR_RIGHT,
112 SHUTTER_OPENING,
113 SHUTTER_CLOSING,
114 SHUTTER_BATTERY,
115 RAIN_DETECTED,
116 RAIN_STOPPED,
117 ROTATOR_STOPPED,
118 ROTATOR_POSITION,
119 SHUTTER_POSITION,
120 BATTERY_LOW,
121 } Events;
122
123 static const std::map<Events, std::string> EventsMap =
124 {
125 {XBEE_STATE, "XB->"},
126 {ROTATOR_REPORT, "SER,"},
127 {SHUTTER_REPORT, "SES,"},
128 {ROTATOR_LEFT, "left"},
129 {ROTATOR_RIGHT, "right"},
130 {SHUTTER_OPENING, "open"},
131 {SHUTTER_CLOSING, "close"},
132 {SHUTTER_BATTERY, "BV"},
133 {RAIN_DETECTED, "Rain"},
134 {RAIN_STOPPED, "RainStopped"},
135 {ROTATOR_STOPPED, "STOP"},
136 {ROTATOR_POSITION, "P"},
137 {SHUTTER_POSITION, "S"},
138 {BATTERY_LOW, "Volts"},
139 };
140
141 // # is the stop char
142 const char DRIVER_STOP_CHAR { '#' };
143 // \n is the event stop char
144 const char DRIVER_EVENT_CHAR { '\n' };
145 // Wait up to a maximum of 3 seconds for serial input
146 const uint8_t DRIVER_TIMEOUT {3};
147 // Wait up to a maximum of 1 for event input
148 const uint8_t DRIVER_EVENT_TIMEOUT {1};
149 // Maximum buffer for sending/receving.
150 const uint16_t DRIVER_LEN {512};
151 // ADU to VRef
152 const double ADU_TO_VREF { 5.0 / 1023 * 3.0 };
153 // Minimim supported version
154 const std::string MINIMUM_VERSION { "3.1.0" };
155 // Tabs
156 const std::string SHUTTER_TAB {"Shutter"};
157 const std::string ROTATOR_TAB {"Rotator"};
158 }
159