[5] | 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 | namespace xplra {
|
---|
| 34 |
|
---|
| 35 | //------------------------------------------------------------------------------
|
---|
| 36 |
|
---|
| 37 | /**
|
---|
| 38 | * Constants and helpers for the protocol.
|
---|
| 39 | */
|
---|
| 40 | class Protocol
|
---|
| 41 | {
|
---|
| 42 | public:
|
---|
| 43 | /**
|
---|
| 44 | * Command: get the value of a single dataref.
|
---|
| 45 | */
|
---|
[6] | 46 | static const uint8_t COMMAND_GET_SINGLE = 0x01;
|
---|
[5] | 47 |
|
---|
| 48 | /**
|
---|
[7] | 49 | * Command: set the value of a single dataref.
|
---|
| 50 | */
|
---|
| 51 | static const uint8_t COMMAND_SET_SINGLE = 0x02;
|
---|
| 52 |
|
---|
| 53 | /**
|
---|
[10] | 54 | * Command: get the value of a multiple datarefs.
|
---|
| 55 | */
|
---|
| 56 | static const uint8_t COMMAND_GET_MULTI = 0x03;
|
---|
| 57 |
|
---|
| 58 | /**
|
---|
| 59 | * Command: set the value of a multiple datarefs.
|
---|
| 60 | */
|
---|
| 61 | static const uint8_t COMMAND_SET_MULTI = 0x04;
|
---|
| 62 |
|
---|
| 63 | /**
|
---|
[8] | 64 | * Command: register a multiple-data query request
|
---|
| 65 | */
|
---|
| 66 | static const uint8_t COMMAND_REGISTER_GET_MULTI = 0x11;
|
---|
| 67 |
|
---|
| 68 | /**
|
---|
| 69 | * Command: unregister a multiple-data query request
|
---|
| 70 | */
|
---|
| 71 | static const uint8_t COMMAND_UNREGISTER_GET_MULTI = 0x12;
|
---|
| 72 |
|
---|
| 73 | /**
|
---|
| 74 | * Command: execute a registered multiple-data query request
|
---|
| 75 | */
|
---|
| 76 | static const uint8_t COMMAND_EXECUTE_GET_MULTI = 0x13;
|
---|
| 77 |
|
---|
| 78 | /**
|
---|
[9] | 79 | * Command: register a multiple-data update request
|
---|
| 80 | */
|
---|
| 81 | static const uint8_t COMMAND_REGISTER_SET_MULTI = 0x21;
|
---|
| 82 |
|
---|
| 83 | /**
|
---|
| 84 | * Command: unregister a multiple-data update request
|
---|
| 85 | */
|
---|
| 86 | static const uint8_t COMMAND_UNREGISTER_SET_MULTI = 0x22;
|
---|
| 87 |
|
---|
| 88 | /**
|
---|
| 89 | * Command: execute a registered multiple-data update request
|
---|
| 90 | */
|
---|
| 91 | static const uint8_t COMMAND_EXECUTE_SET_MULTI = 0x23;
|
---|
| 92 |
|
---|
| 93 | /**
|
---|
[36] | 94 | * Command: get the versions of the simulator
|
---|
| 95 | */
|
---|
| 96 | static const uint8_t COMMAND_GET_VERSIONS = 0x31;
|
---|
| 97 |
|
---|
| 98 | /**
|
---|
[38] | 99 | * Command: show a message in the message window.
|
---|
| 100 | */
|
---|
| 101 | static const uint8_t COMMAND_SHOW_MESSAGE = 0x41;
|
---|
| 102 |
|
---|
| 103 | /**
|
---|
[5] | 104 | * Data type: int
|
---|
| 105 | */
|
---|
| 106 | static const uint8_t TYPE_INT = 0x01;
|
---|
| 107 |
|
---|
| 108 | /**
|
---|
| 109 | * Data type: float
|
---|
| 110 | */
|
---|
| 111 | static const uint8_t TYPE_FLOAT = 0x02;
|
---|
| 112 |
|
---|
| 113 | /**
|
---|
| 114 | * Data type: double
|
---|
| 115 | */
|
---|
| 116 | static const uint8_t TYPE_DOUBLE = 0x03;
|
---|
| 117 |
|
---|
| 118 | /**
|
---|
| 119 | * Data type: float array
|
---|
| 120 | */
|
---|
| 121 | static const uint8_t TYPE_FLOAT_ARRAY = 0x11;
|
---|
| 122 |
|
---|
| 123 | /**
|
---|
| 124 | * Data type: int array
|
---|
| 125 | */
|
---|
| 126 | static const uint8_t TYPE_INT_ARRAY = 0x12;
|
---|
| 127 |
|
---|
| 128 | /**
|
---|
| 129 | * Data type: byte array
|
---|
| 130 | */
|
---|
| 131 | static const uint8_t TYPE_BYTE_ARRAY = 0x13;
|
---|
| 132 |
|
---|
| 133 | /**
|
---|
| 134 | * Result code: no error, everything is OK.
|
---|
| 135 | */
|
---|
| 136 | static const uint8_t RESULT_OK = 0x00;
|
---|
| 137 |
|
---|
| 138 | /**
|
---|
| 139 | * Result code: invalid command
|
---|
| 140 | */
|
---|
| 141 | static const uint8_t RESULT_INVALID_COMMAND = 0x01;
|
---|
| 142 |
|
---|
| 143 | /**
|
---|
| 144 | * Result code: unknown dataref
|
---|
| 145 | */
|
---|
| 146 | static const uint8_t RESULT_UNKNOWN_DATAREF = 0x02;
|
---|
| 147 |
|
---|
| 148 | /**
|
---|
| 149 | * Result code: invalid type
|
---|
| 150 | */
|
---|
| 151 | static const uint8_t RESULT_INVALID_TYPE = 0x03;
|
---|
| 152 |
|
---|
| 153 | /**
|
---|
[7] | 154 | * Result code: invalid length
|
---|
| 155 | */
|
---|
| 156 | static const uint8_t RESULT_INVALID_LENGTH = 0x04;
|
---|
| 157 |
|
---|
| 158 | /**
|
---|
| 159 | * Result code: invalid offset
|
---|
| 160 | */
|
---|
| 161 | static const uint8_t RESULT_INVALID_OFFSET = 0x05;
|
---|
| 162 |
|
---|
| 163 | /**
|
---|
[8] | 164 | * Result code: invalid count
|
---|
| 165 | */
|
---|
| 166 | static const uint8_t RESULT_INVALID_COUNT = 0x06;
|
---|
| 167 |
|
---|
| 168 | /**
|
---|
| 169 | * Result code: invalid ID
|
---|
| 170 | */
|
---|
| 171 | static const uint8_t RESULT_INVALID_ID = 0x07;
|
---|
| 172 |
|
---|
| 173 | /**
|
---|
[38] | 174 | * Result code: invalid duration
|
---|
| 175 | */
|
---|
| 176 | static const uint8_t RESULT_INVALID_DURATION = 0x08;
|
---|
| 177 |
|
---|
| 178 | /**
|
---|
[5] | 179 | * Result code: other error
|
---|
| 180 | */
|
---|
| 181 | static const uint8_t RESULT_OTHER_ERROR = 0xff;
|
---|
[7] | 182 |
|
---|
| 183 | /**
|
---|
| 184 | * The maximal length we accept (in order to protect ourselves).
|
---|
| 185 | */
|
---|
| 186 | static const int MAX_LENGTH = 2048;
|
---|
[8] | 187 |
|
---|
| 188 | /**
|
---|
| 189 | * The maximal count of requests in a multiple-data query or
|
---|
| 190 | * update.
|
---|
| 191 | */
|
---|
| 192 | static const size_t MAX_MULTI_COUNT = 1024;
|
---|
[36] | 193 |
|
---|
| 194 | /**
|
---|
[38] | 195 | * The maximal message duration
|
---|
| 196 | */
|
---|
| 197 | static const float MAX_MESSAGE_DURATION = 5*60;
|
---|
| 198 |
|
---|
| 199 | /**
|
---|
[36] | 200 | * The version of the plugin.
|
---|
| 201 | */
|
---|
| 202 | static const int version = 10;
|
---|
[5] | 203 | };
|
---|
| 204 |
|
---|
| 205 | //------------------------------------------------------------------------------
|
---|
| 206 |
|
---|
| 207 | } /* namespace xplra */
|
---|
| 208 |
|
---|
| 209 | //------------------------------------------------------------------------------
|
---|
| 210 | #endif // XPLRA_PROTOCOL_H
|
---|
| 211 |
|
---|
| 212 | // Local Variables:
|
---|
| 213 | // mode: C++
|
---|
| 214 | // c-basic-offset: 4
|
---|
| 215 | // indent-tabs-mode: nil
|
---|
| 216 | // End:
|
---|