| 1 |
/* |
| 2 |
RailControl - Model Railway Control Software |
| 3 |
|
| 4 |
Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org |
| 5 |
|
| 6 |
RailControl is free software; you can redistribute it and/or modify it |
| 7 |
under the terms of the GNU General Public License as published by the |
| 8 |
Free Software Foundation; either version 3, or (at your option) any |
| 9 |
later version. |
| 10 |
|
| 11 |
RailControl is distributed in the hope that it will be useful, but |
| 12 |
WITHOUT ANY WARRANTY; without even the implied warranty of |
| 13 |
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. |
| 14 |
See the GNU General Public License for more details. |
| 15 |
|
| 16 |
You should have received a copy of the GNU General Public License |
| 17 |
along with RailControl; see the file LICENCE. If not see |
| 18 |
<http://www.gnu.org/licenses/>. |
| 19 |
*/ |
| 20 |
|
| 21 |
#pragma once |
| 22 |
|
| 23 |
#include <cstdint> |
| 24 |
#include <string> |
| 25 |
|
| 26 |
// common |
| 27 |
typedef uint8_t ControlID; |
| 28 |
|
| 29 |
// objects in db |
| 30 |
typedef uint16_t ObjectID; |
| 31 |
|
| 32 |
// loco |
| 33 |
typedef ObjectID LocoID; |
| 34 |
typedef uint16_t Address; |
| 35 |
typedef uint16_t Speed; |
| 36 |
typedef uint32_t Length; |
| 37 |
|
| 38 |
// multiple unit |
| 39 |
typedef ObjectID MultipleUnitID; |
| 40 |
|
| 41 |
// accessory |
| 42 |
typedef ObjectID AccessoryID; |
| 43 |
|
| 44 |
// feedback |
| 45 |
typedef ObjectID FeedbackID; |
| 46 |
typedef uint32_t FeedbackPin; |
| 47 |
|
| 48 |
// track |
| 49 |
typedef ObjectID TrackID; |
| 50 |
typedef ObjectID ClusterID; |
| 51 |
|
| 52 |
// switch |
| 53 |
typedef AccessoryID SwitchID; |
| 54 |
|
| 55 |
// signal |
| 56 |
typedef AccessoryID SignalID; |
| 57 |
|
| 58 |
// route |
| 59 |
typedef ObjectID RouteID; |
| 60 |
typedef uint16_t Delay; |
| 61 |
|
| 62 |
// layer |
| 63 |
typedef int16_t LayerID; |
| 64 |
|
| 65 |
// relations |
| 66 |
typedef uint16_t Priority; |
| 67 |
|
| 68 |
typedef uint8_t Pause; |
| 69 |
|
| 70 |
// text |
| 71 |
typedef ObjectID TextID; |
| 72 |
|
| 73 |
static const Address AddressNone = 0; |
| 74 |
static const Address AddressDefault = 3; |
| 75 |
static const LocoID LocoNone = 0; |
| 76 |
static const MultipleUnitID MultipleUnitNone = 0; |
| 77 |
static const MultipleUnitID MultipleUnitIdPrefix = 0x8000; |
| 78 |
static const ObjectID ObjectNone = 0; |
| 79 |
static const AccessoryID AccessoryNone = 0; |
| 80 |
static const FeedbackID FeedbackNone = 0; |
| 81 |
static const FeedbackPin FeedbackPinNone = 0; |
| 82 |
static const TrackID TrackNone = 0; |
| 83 |
static const SwitchID SwitchNone = 0; |
| 84 |
static const RouteID RouteNone = 0; |
| 85 |
static const RouteID RouteAuto = 0; |
| 86 |
static const RouteID RouteStop = 0xFFFF; |
| 87 |
static const ControlID ControlNone = 0; |
| 88 |
static const LayerID LayerNone = 0; |
| 89 |
static const LayerID LayerUndeletable = 1; |
| 90 |
static const SignalID SignalNone = 0; |
| 91 |
static const ClusterID ClusterNone = 0; |
| 92 |
static const TextID TextNone = 0; |
| 93 |
|
| 94 |
static const Speed MaxSpeed = 1023; |
| 95 |
static const Speed DefaultTravelSpeed = 700; |
| 96 |
static const Speed DefaultReducedSpeed = 400; |
| 97 |
static const Speed DefaultCreepingSpeed = 100; |
| 98 |
static const Speed MinSpeed = 0; |
| 99 |
|
| 100 |
enum ControlType : uint8_t |
| 101 |
{ |
| 102 |
ControlTypeHardware = 0, |
| 103 |
ControlTypeInternal, |
| 104 |
ControlTypeWebServer, |
| 105 |
ControlTypeZ21Server, |
| 106 |
ControlTypeCS2Server |
| 107 |
}; |
| 108 |
|
| 109 |
enum ControlIDs : ControlID |
| 110 |
{ |
| 111 |
ControlIdNone = 0, |
| 112 |
ControlIdWebServer, |
| 113 |
ControlIdZ21Server, |
| 114 |
ControlIdCS2Server, |
| 115 |
ControlIdFirstHardware = 10 |
| 116 |
}; |
| 117 |
|
| 118 |
enum BoosterState : bool |
| 119 |
{ |
| 120 |
BoosterStateStop = false, |
| 121 |
BoosterStateGo = true |
| 122 |
}; |
| 123 |
|
| 124 |
enum Protocol : uint8_t |
| 125 |
{ |
| 126 |
ProtocolNone = 0, |
| 127 |
ProtocolServer = 1, |
| 128 |
ProtocolMM1 = 2, |
| 129 |
ProtocolMM2 = 3, |
| 130 |
ProtocolMFX = 4, |
| 131 |
ProtocolDCC = 5, |
| 132 |
ProtocolDCC14 = 6, |
| 133 |
ProtocolDCC28 = 7, |
| 134 |
ProtocolDCC128 = 8, |
| 135 |
ProtocolMM = 9, |
| 136 |
ProtocolMM15 = 10, |
| 137 |
ProtocolSX1 = 11, |
| 138 |
ProtocolSX2 = 12, |
| 139 |
ProtocolFMZ = 13, |
| 140 |
ProtocolMultipleUnit = 14, |
| 141 |
ProtocolEnd = ProtocolMultipleUnit |
| 142 |
}; |
| 143 |
|
| 144 |
static const std::string ProtocolSymbols[] = |
| 145 |
{ |
| 146 |
"none", |
| 147 |
"all", |
| 148 |
"MM 1", |
| 149 |
"MM 2", |
| 150 |
"mfx", |
| 151 |
"DCC", |
| 152 |
"DCC 14", |
| 153 |
"DCC 28", |
| 154 |
"DCC 128", |
| 155 |
"MM", |
| 156 |
"MM 1.5", |
| 157 |
"SX1", |
| 158 |
"SX2", |
| 159 |
"FMZ", |
| 160 |
"Multi" |
| 161 |
}; |
| 162 |
|
| 163 |
enum AddressType : uint8_t |
| 164 |
{ |
| 165 |
AddressTypeLoco = 0, |
| 166 |
AddressTypeMultipleUnit, |
| 167 |
AddressTypeAccessory |
| 168 |
}; |
| 169 |
|
| 170 |
enum AddressPort : uint8_t |
| 171 |
{ |
| 172 |
AddressPortRed = 0, |
| 173 |
AddressPortGreen = 1 |
| 174 |
}; |
| 175 |
|
| 176 |
enum LocoType : uint8_t |
| 177 |
{ |
| 178 |
LocoTypeLoco = 0, |
| 179 |
LocoTypeMultipleUnit |
| 180 |
}; |
| 181 |
|
| 182 |
enum ArgumentType : uint8_t |
| 183 |
{ |
| 184 |
ArgumentTypeIpAddress = 1, |
| 185 |
ArgumentTypeSerialPort = 2, |
| 186 |
ArgumentTypeS88Modules = 3, |
| 187 |
ArgumentTypeMainSecundary = 4 |
| 188 |
}; |
| 189 |
|
| 190 |
enum HardwareType : uint8_t |
| 191 |
{ |
| 192 |
HardwareTypeNone = 0, |
| 193 |
HardwareTypeVirtual = 1, |
| 194 |
HardwareTypeCS2Udp = 2, |
| 195 |
HardwareTypeM6051 = 3, |
| 196 |
// HardwareTypeRM485 = 4, // not used anymore, but still reserved for old configurations |
| 197 |
HardwareTypeOpenDcc = 5, |
| 198 |
HardwareTypeHsi88 = 6, |
| 199 |
HardwareTypeZ21 = 7, |
| 200 |
HardwareTypeCcSchnitte = 8, |
| 201 |
HardwareTypeEcos = 9, |
| 202 |
HardwareTypeCS2Tcp = 10, |
| 203 |
HardwareTypeIntellibox = 11, |
| 204 |
HardwareTypeMasterControl = 12, |
| 205 |
HardwareTypeTwinCenter = 13, |
| 206 |
HardwareTypeMasterControl2 = 14, |
| 207 |
HardwareTypeRedBox = 15, |
| 208 |
HardwareTypeRektor = 16, |
| 209 |
HardwareTypeDR5000 = 17, |
| 210 |
HardwareTypeCS1 = 18, |
| 211 |
HardwareTypeDccPpExTcp = 19, |
| 212 |
HardwareTypeDccPpExSerial = 20, |
| 213 |
HardwareTypeIntellibox2 = 21, |
| 214 |
HardwareTypeLocoNetAdapter63120 = 22, |
| 215 |
HardwareTypeLocoNetAdapter63820 = 23, |
| 216 |
HardwareTypeSystemControl7 = 24 |
| 217 |
}; |
| 218 |
|
| 219 |
enum Automode : bool |
| 220 |
{ |
| 221 |
AutomodeNo = false, |
| 222 |
AutomodeYes = true |
| 223 |
}; |
| 224 |
|
| 225 |
enum ObjectType : uint8_t |
| 226 |
{ |
| 227 |
ObjectTypeNone = 0, |
| 228 |
ObjectTypeLoco = 1, |
| 229 |
ObjectTypeTrack = 2, |
| 230 |
ObjectTypeFeedback = 3, |
| 231 |
ObjectTypeAccessory = 4, |
| 232 |
ObjectTypeSwitch = 5, |
| 233 |
ObjectTypeRoute = 6, |
| 234 |
ObjectTypeLayer = 7, |
| 235 |
ObjectTypeSignal = 8, |
| 236 |
ObjectTypeCluster = 9, |
| 237 |
ObjectTypeTimeTable = 10, |
| 238 |
ObjectTypeText = 11, |
| 239 |
ObjectTypePause = 12, |
| 240 |
ObjectTypeMultipleUnit = 13, |
| 241 |
ObjectTypeBooster = 14 |
| 242 |
}; |
| 243 |
|
| 244 |
enum Orientation : uint8_t |
| 245 |
{ |
| 246 |
OrientationLeft = 0, |
| 247 |
OrientationRight = 1, |
| 248 |
OrientationChange = 2 |
| 249 |
}; |
| 250 |
|
| 251 |
enum StartupInitLocos : uint8_t |
| 252 |
{ |
| 253 |
StartupInitLocosNone = 0, |
| 254 |
StartupInitLocosSpeed = 1, |
| 255 |
StartupInitLocosAll = 2, |
| 256 |
}; |
| 257 |
|
| 258 |
enum ProgramMode : uint8_t |
| 259 |
{ |
| 260 |
ProgramModeNone, |
| 261 |
ProgramModeDccDirect, |
| 262 |
ProgramModeDccPomLoco, |
| 263 |
ProgramModeDccPomAccessory, |
| 264 |
ProgramModeMm, |
| 265 |
ProgramModeMmPom, |
| 266 |
ProgramModeMfx, |
| 267 |
ProgramModeDccPage, |
| 268 |
ProgramModeDccRegister |
| 269 |
}; |
| 270 |
|
| 271 |
typedef uint16_t CvNumber; |
| 272 |
typedef uint8_t CvValue; |
| 273 |
|
| 274 |
enum Propulsion : uint8_t |
| 275 |
{ |
| 276 |
PropulsionUnknown = 0x00, |
| 277 |
PropulsionSteam = 0x01, |
| 278 |
PropulsionDiesel = 0x02, |
| 279 |
PropulsionGas = 0x04, |
| 280 |
PropulsionElectric = 0x08, |
| 281 |
PropulsionHydrogen = 0x10, |
| 282 |
PropulsionAccu = 0x20, |
| 283 |
PropulsionOther = 0x80, |
| 284 |
PropulsionAll = PropulsionSteam |
| 285 |
| PropulsionDiesel |
| 286 |
| PropulsionGas |
| 287 |
| PropulsionElectric |
| 288 |
| PropulsionHydrogen |
| 289 |
| PropulsionAccu |
| 290 |
| PropulsionOther |
| 291 |
}; |
| 292 |
|
| 293 |
enum TrainType : uint32_t |
| 294 |
{ |
| 295 |
TrainTypeUnknown = 0x00000000, |
| 296 |
|
| 297 |
TrainTypeInternationalHighSpeed = 0x00000001, |
| 298 |
TrainTypeNationalHighSpeed = 0x00000002, |
| 299 |
TrainTypeInternationalLongDistance = 0x00000004, |
| 300 |
TrainTypeNationalLongDistance = 0x00000008, |
| 301 |
TrainTypeInternationalNight = 0x00000010, |
| 302 |
TrainTypeNationalNight = 0x00000020, |
| 303 |
TrainTypeLongDistanceFastLocal = 0x00000040, |
| 304 |
TrainTypeFastLocal = 0x00000080, |
| 305 |
TrainTypeLocal = 0x00000100, |
| 306 |
TrainTypeSuburban = 0x00000200, |
| 307 |
TrainTypeUnderground = 0x00000400, |
| 308 |
TrainTypeHistoric = 0x00001000, |
| 309 |
TrainTypeExtra = 0x00002000, |
| 310 |
|
| 311 |
TrainTypePassengerWithCargo = 0x00008000, |
| 312 |
|
| 313 |
TrainTypePassenger = TrainTypeInternationalHighSpeed |
| 314 |
| TrainTypeNationalHighSpeed |
| 315 |
| TrainTypeInternationalLongDistance |
| 316 |
| TrainTypeNationalLongDistance |
| 317 |
| TrainTypeInternationalNight |
| 318 |
| TrainTypeNationalNight |
| 319 |
| TrainTypeLongDistanceFastLocal |
| 320 |
| TrainTypeFastLocal |
| 321 |
| TrainTypeLocal |
| 322 |
| TrainTypeSuburban |
| 323 |
| TrainTypeUnderground |
| 324 |
| TrainTypeHistoric |
| 325 |
| TrainTypeExtra |
| 326 |
| TrainTypePassengerWithCargo, |
| 327 |
|
| 328 |
TrainTypeCargoLongDistance = 0x00010000, |
| 329 |
TrainTypeCargoLocal = 0x00020000, |
| 330 |
TrainTypeCargoBlock = 0x00040000, |
| 331 |
TrainTypeCargoTractor = 0x00080000, |
| 332 |
TrainTypeCargoExpress = 0x00100000, |
| 333 |
|
| 334 |
TrainTypeCargoWithPassenger = 0x00800000, |
| 335 |
|
| 336 |
TrainTypeCargo = TrainTypeCargoLongDistance |
| 337 |
| TrainTypeCargoLocal |
| 338 |
| TrainTypeCargoBlock |
| 339 |
| TrainTypeCargoTractor |
| 340 |
| TrainTypeCargoExpress |
| 341 |
| TrainTypeCargoWithPassenger, |
| 342 |
|
| 343 |
TrainTypeRescue = 0x01000000, |
| 344 |
TrainTypeConstruction = 0x02000000, |
| 345 |
TrainTypeEmpty = 0x04000000, |
| 346 |
TrainTypeLoco = 0x08000000, |
| 347 |
TrainTypeCleaning = 0x10000000, |
| 348 |
|
| 349 |
TrainTypeOther = 0x40000000, |
| 350 |
// Bit 32 (0x80000000) can not be used because of conversion functions that handle with signed int32_t |
| 351 |
|
| 352 |
TrainTypeAll = TrainTypePassenger |
| 353 |
| TrainTypeCargo |
| 354 |
| TrainTypeRescue |
| 355 |
| TrainTypeConstruction |
| 356 |
| TrainTypeEmpty |
| 357 |
| TrainTypeLoco |
| 358 |
| TrainTypeCleaning |
| 359 |
| TrainTypeOther |
| 360 |
}; |