X-Plane Remote Access Plugin and Client Library
Protocol.h
1 // Copyright (c) 2013 by István Váradi
2 
3 // This file is part of XPLRA, a remote-access plugin for X-Plane
4 
5 // Redistribution and use in source and binary forms, with or without
6 // modification, are permitted provided that the following conditions are met:
7 
8 // 1. Redistributions of source code must retain the above copyright notice, this
9 // list of conditions and the following disclaimer.
10 // 2. Redistributions in binary form must reproduce the above copyright notice,
11 // this list of conditions and the following disclaimer in the documentation
12 // and/or other materials provided with the distribution.
13 
14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
15 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
16 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
17 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
18 // ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
19 // (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
20 // LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
21 // ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
22 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
23 // SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
24 
25 // The views and conclusions contained in the software and documentation are those
26 // of the authors and should not be interpreted as representing official policies,
27 // either expressed or implied, of the FreeBSD Project.
28 
29 #ifndef XPLRA_PROTOCOL_H
30 #define XPLRA_PROTOCOL_H
31 //------------------------------------------------------------------------------
32 
33 #include <cstdlib>
34 #include <inttypes.h>
35 
36 //------------------------------------------------------------------------------
37 
38 namespace xplra {
39 
40 //------------------------------------------------------------------------------
41 
45 class Protocol
46 {
47 public:
51  static const uint8_t COMMAND_GET_SINGLE = 0x01;
52 
56  static const uint8_t COMMAND_SET_SINGLE = 0x02;
57 
61  static const uint8_t COMMAND_GET_MULTI = 0x03;
62 
66  static const uint8_t COMMAND_SET_MULTI = 0x04;
67 
71  static const uint8_t COMMAND_REGISTER_GET_MULTI = 0x11;
72 
76  static const uint8_t COMMAND_UNREGISTER_GET_MULTI = 0x12;
77 
81  static const uint8_t COMMAND_EXECUTE_GET_MULTI = 0x13;
82 
86  static const uint8_t COMMAND_REGISTER_SET_MULTI = 0x21;
87 
91  static const uint8_t COMMAND_UNREGISTER_SET_MULTI = 0x22;
92 
96  static const uint8_t COMMAND_EXECUTE_SET_MULTI = 0x23;
97 
101  static const uint8_t COMMAND_GET_VERSIONS = 0x31;
102 
106  static const uint8_t COMMAND_RELOAD_PLUGINS = 0x32;
107 
114  static const uint8_t COMMAND_SAVE_SITUATION = 0x33;
115 
119  static const uint8_t COMMAND_SHOW_MESSAGE = 0x41;
120 
136  static const uint8_t COMMAND_REGISTER_HOTKEYS = 0x51;
137 
153  static const uint8_t COMMAND_QUERY_HOTKEYS = 0x52;
154 
160  static const uint8_t COMMAND_UNREGISTER_HOTKEYS = 0x53;
161 
165  static const uint8_t TYPE_INT = 0x01;
166 
170  static const uint8_t TYPE_FLOAT = 0x02;
171 
175  static const uint8_t TYPE_DOUBLE = 0x03;
176 
180  static const uint8_t TYPE_FLOAT_ARRAY = 0x11;
181 
185  static const uint8_t TYPE_INT_ARRAY = 0x12;
186 
190  static const uint8_t TYPE_BYTE_ARRAY = 0x13;
191 
195  static const uint8_t RESULT_OK = 0x00;
196 
200  static const uint8_t RESULT_INVALID_COMMAND = 0x01;
201 
205  static const uint8_t RESULT_UNKNOWN_DATAREF = 0x02;
206 
210  static const uint8_t RESULT_INVALID_TYPE = 0x03;
211 
215  static const uint8_t RESULT_INVALID_LENGTH = 0x04;
216 
220  static const uint8_t RESULT_INVALID_OFFSET = 0x05;
221 
225  static const uint8_t RESULT_INVALID_COUNT = 0x06;
226 
230  static const uint8_t RESULT_INVALID_ID = 0x07;
231 
235  static const uint8_t RESULT_INVALID_DURATION = 0x08;
236 
240  static const uint8_t RESULT_OTHER_ERROR = 0xff;
241 
245  static const uint16_t HOTKEY_MODIFIER_SHIFT = 0x0100;
246 
250  static const uint16_t HOTKEY_MODIFIER_CONTROL = 0x0200;
251 
255  static const int MAX_LENGTH = 2048;
256 
261  static const size_t MAX_MULTI_COUNT = 1024;
262 
266  static constexpr float MAX_MESSAGE_DURATION = 5*60;
267 
272  static const size_t MAX_HOTKEY_COUNT = 128;
273 
277  static const int version = 30;
278 };
279 
280 //------------------------------------------------------------------------------
281 
282 } /* namespace xplra */
283 
284 //------------------------------------------------------------------------------
285 #endif // XPLRA_PROTOCOL_H
286 
287 // Local Variables:
288 // mode: C++
289 // c-basic-offset: 4
290 // indent-tabs-mode: nil
291 // End:
static const int version
Definition: Protocol.h:277
static const uint8_t COMMAND_UNREGISTER_GET_MULTI
Definition: Protocol.h:76
static const uint8_t COMMAND_EXECUTE_GET_MULTI
Definition: Protocol.h:81
static const uint8_t COMMAND_REGISTER_GET_MULTI
Definition: Protocol.h:71
static const uint8_t RESULT_INVALID_LENGTH
Definition: Protocol.h:215
static const uint8_t TYPE_FLOAT_ARRAY
Definition: Protocol.h:180
static const uint8_t COMMAND_QUERY_HOTKEYS
Definition: Protocol.h:153
static const size_t MAX_MULTI_COUNT
Definition: Protocol.h:261
static const uint8_t RESULT_OK
Definition: Protocol.h:195
static const uint8_t COMMAND_SET_SINGLE
Definition: Protocol.h:56
static constexpr float MAX_MESSAGE_DURATION
Definition: Protocol.h:266
static const uint8_t COMMAND_REGISTER_HOTKEYS
Definition: Protocol.h:136
static const uint8_t COMMAND_GET_SINGLE
Definition: Protocol.h:51
static const uint8_t TYPE_INT
Definition: Protocol.h:165
static const uint8_t RESULT_INVALID_OFFSET
Definition: Protocol.h:220
static const uint8_t COMMAND_SET_MULTI
Definition: Protocol.h:66
static const uint16_t HOTKEY_MODIFIER_CONTROL
Definition: Protocol.h:250
static const uint8_t COMMAND_UNREGISTER_HOTKEYS
Definition: Protocol.h:160
static const uint8_t RESULT_OTHER_ERROR
Definition: Protocol.h:240
static const uint8_t COMMAND_REGISTER_SET_MULTI
Definition: Protocol.h:86
static const uint8_t RESULT_INVALID_COMMAND
Definition: Protocol.h:200
static const uint8_t RESULT_INVALID_ID
Definition: Protocol.h:230
static const uint8_t RESULT_UNKNOWN_DATAREF
Definition: Protocol.h:205
static const uint8_t RESULT_INVALID_COUNT
Definition: Protocol.h:225
static const uint8_t TYPE_DOUBLE
Definition: Protocol.h:175
static const uint8_t COMMAND_GET_MULTI
Definition: Protocol.h:61
static const uint8_t COMMAND_GET_VERSIONS
Definition: Protocol.h:101
static const uint8_t COMMAND_UNREGISTER_SET_MULTI
Definition: Protocol.h:91
static const uint8_t COMMAND_SHOW_MESSAGE
Definition: Protocol.h:119
static const uint8_t COMMAND_EXECUTE_SET_MULTI
Definition: Protocol.h:96
static const uint16_t HOTKEY_MODIFIER_SHIFT
Definition: Protocol.h:245
static const size_t MAX_HOTKEY_COUNT
Definition: Protocol.h:272
static const uint8_t RESULT_INVALID_TYPE
Definition: Protocol.h:210
static const uint8_t TYPE_FLOAT
Definition: Protocol.h:170
static const uint8_t COMMAND_SAVE_SITUATION
Definition: Protocol.h:114
static const uint8_t COMMAND_RELOAD_PLUGINS
Definition: Protocol.h:106
static const uint8_t RESULT_INVALID_DURATION
Definition: Protocol.h:235
static const uint8_t TYPE_INT_ARRAY
Definition: Protocol.h:185
static const uint8_t TYPE_BYTE_ARRAY
Definition: Protocol.h:190
static const int MAX_LENGTH
Definition: Protocol.h:255
Python client module for the X-Plane Remote Access plugin.
Definition: DataRefTask.h:41