File: DataTypes.h

package info (click to toggle)
railcontrol 24%2Bdfsg1-6
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,540 kB
  • sloc: cpp: 40,823; javascript: 2,509; makefile: 110; php: 97; sh: 60
file content (365 lines) | stat: -rw-r--r-- 8,704 bytes parent folder | download
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
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
/*
RailControl - Model Railway Control Software

Copyright (c) 2017-2025 by Teddy / Dominik Mahrer - www.railcontrol.org

RailControl is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the
Free Software Foundation; either version 3, or (at your option) any
later version.

RailControl is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.

You should have received a copy of the GNU General Public License
along with RailControl; see the file LICENCE. If not see
<http://www.gnu.org/licenses/>.
*/

#pragma once

#include <cstdint>
#include <string>

// common
typedef uint8_t ControlID;

// objects in db
typedef uint16_t ObjectID;

// loco
typedef ObjectID LocoID;
typedef uint16_t Address;
typedef uint16_t Speed;
typedef uint32_t Length;

// multiple unit
typedef ObjectID MultipleUnitID;

// accessory
typedef ObjectID AccessoryID;

// feedback
typedef ObjectID FeedbackID;
typedef uint32_t FeedbackPin;

// track
typedef ObjectID TrackID;
typedef ObjectID ClusterID;

// switch
typedef AccessoryID SwitchID;

// signal
typedef AccessoryID SignalID;

// route
typedef ObjectID RouteID;
typedef uint16_t Delay;

// layer
typedef int16_t LayerID;

// relations
typedef uint16_t Priority;

typedef uint8_t Pause;

// text
typedef ObjectID TextID;

// counter
typedef ObjectID CounterID;

static const Address AddressNone = 0;
static const Address AddressDefault = 3;
static const LocoID LocoNone = 0;
static const MultipleUnitID MultipleUnitNone = 0;
static const MultipleUnitID MultipleUnitIdPrefix = 0x8000;
static const ObjectID ObjectNone = 0;
static const AccessoryID AccessoryNone = 0;
static const FeedbackID FeedbackNone = 0;
static const FeedbackPin FeedbackPinNone = 0;
static const TrackID TrackNone = 0;
static const SwitchID SwitchNone = 0;
static const RouteID RouteNone = 0;
static const RouteID RouteAuto = 0;
static const RouteID RouteStop = 0xFFFF;
static const ControlID ControlNone = 0;
static const LayerID LayerNone = 0;
static const LayerID LayerUndeletable = 1;
static const SignalID SignalNone = 0;
static const ClusterID ClusterNone = 0;
static const TextID TextNone = 0;
static const CounterID CounterNone = 0;

static const Speed MaxSpeed = 1023;
static const Speed DefaultTravelSpeed = 700;
static const Speed DefaultReducedSpeed = 400;
static const Speed DefaultCreepingSpeed = 100;
static const Speed MinSpeed = 0;

enum ControlType : uint8_t
{
	ControlTypeHardware = 0,
	ControlTypeInternal,
	ControlTypeWebServer,
	ControlTypeZ21Server,
	ControlTypeCS2Server
};

enum ControlIDs : ControlID
{
	ControlIdNone = 0,
	ControlIdWebServer,
	ControlIdZ21Server,
	ControlIdCS2Server,
	ControlIdFirstHardware = 10
};

enum BoosterState : bool
{
	BoosterStateStop = false,
	BoosterStateGo = true
};

enum Protocol : uint8_t
{
	ProtocolNone = 0,
	ProtocolServer = 1,
	ProtocolMM1 = 2,
	ProtocolMM2 = 3,
	ProtocolMFX = 4,
	ProtocolDCC = 5,
	ProtocolDCC14 = 6,
	ProtocolDCC28 = 7,
	ProtocolDCC128 = 8,
	ProtocolMM = 9,
	ProtocolMM15 = 10,
	ProtocolSX1 = 11,
	ProtocolSX2 = 12,
	ProtocolFMZ = 13,
	ProtocolMultipleUnit = 14,
	ProtocolEnd = ProtocolMultipleUnit
};

static const std::string ProtocolSymbols[] =
{
	"none",
	"all",
	"MM 1",
	"MM 2",
	"mfx",
	"DCC",
	"DCC 14",
	"DCC 28",
	"DCC 128",
	"MM",
	"MM 1.5",
	"SX1",
	"SX2",
	"FMZ",
	"Multi"
};

enum AddressType : uint8_t
{
	AddressTypeLoco = 0,
	AddressTypeMultipleUnit,
	AddressTypeAccessory
};

enum AddressPort : uint8_t
{
	AddressPortRed   = 0,
	AddressPortGreen = 1
};

enum LocoType : uint8_t
{
	LocoTypeLoco = 0,
	LocoTypeMultipleUnit
};

enum ArgumentType : uint8_t
{
	ArgumentTypeIpAddress = 1,
	ArgumentTypeSerialPort = 2,
	ArgumentTypeS88Modules = 3,
	ArgumentTypeMainSecundary = 4
};

enum HardwareType : uint8_t
{
	HardwareTypeNone = 0,
	HardwareTypeVirtual = 1,
	HardwareTypeCS2Udp = 2,
	HardwareTypeM6051 = 3,
	// HardwareTypeRM485 = 4, // not used anymore, but still reserved for old configurations
	HardwareTypeOpenDcc = 5,
	HardwareTypeHsi88 = 6,
	HardwareTypeZ21 = 7,
	HardwareTypeCcSchnitte = 8,
	HardwareTypeEcos = 9,
	HardwareTypeCS2Tcp = 10,
	HardwareTypeIntellibox = 11,
	HardwareTypeMasterControl = 12,
	HardwareTypeTwinCenter = 13,
	HardwareTypeMasterControl2 = 14,
	HardwareTypeRedBox = 15,
	HardwareTypeRektor = 16,
	HardwareTypeDR5000 = 17,
	HardwareTypeCS1 = 18,
	HardwareTypeDccPpExTcp = 19,
	HardwareTypeDccPpExSerial = 20,
	HardwareTypeIntellibox2 = 21,
	HardwareTypeLocoNetAdapter63120 = 22,
	HardwareTypeLocoNetAdapter63820 = 23,
	HardwareTypeSystemControl7 = 24
};

enum Automode : bool
{
	AutomodeNo = false,
	AutomodeYes = true
};

enum ObjectType : uint8_t
{
	ObjectTypeNone = 0,
	ObjectTypeLoco = 1,
	ObjectTypeTrack = 2,
	ObjectTypeFeedback = 3,
	ObjectTypeAccessory = 4,
	ObjectTypeSwitch = 5,
	ObjectTypeRoute = 6,
	ObjectTypeLayer = 7,
	ObjectTypeSignal = 8,
	ObjectTypeCluster = 9,
	ObjectTypeTimeTable = 10,
	ObjectTypeText = 11,
	ObjectTypePause = 12,
	ObjectTypeMultipleUnit = 13,
	ObjectTypeBooster = 14,
	ObjectTypeCounter = 15
};

enum Orientation : uint8_t
{
	OrientationLeft = 0,
	OrientationRight = 1,
	OrientationChange = 2
};

enum StartupInitLocos : uint8_t
{
	StartupInitLocosNone  = 0,
	StartupInitLocosSpeed = 1,
	StartupInitLocosAll   = 2,
};

enum ProgramMode : uint8_t
{
	ProgramModeNone,
	ProgramModeDccDirect,
	ProgramModeDccPomLoco,
	ProgramModeDccPomAccessory,
	ProgramModeMm,
	ProgramModeMmPom,
	ProgramModeMfx,
	ProgramModeDccPage,
	ProgramModeDccRegister
};

typedef uint16_t CvNumber;
typedef uint8_t CvValue;

enum Propulsion : uint8_t
{
	PropulsionUnknown  = 0x00,
	PropulsionSteam    = 0x01,
	PropulsionDiesel   = 0x02,
	PropulsionGas      = 0x04,
	PropulsionElectric = 0x08,
	PropulsionHydrogen = 0x10,
	PropulsionAccu     = 0x20,
	PropulsionOther    = 0x80,
	PropulsionAll      = PropulsionSteam
							| PropulsionDiesel
							| PropulsionGas
							| PropulsionElectric
							| PropulsionHydrogen
							| PropulsionAccu
							| PropulsionOther
};

enum TrainType : uint32_t
{
	TrainTypeUnknown                   = 0x00000000,

	TrainTypeInternationalHighSpeed    = 0x00000001,
	TrainTypeNationalHighSpeed         = 0x00000002,
	TrainTypeInternationalLongDistance = 0x00000004,
	TrainTypeNationalLongDistance      = 0x00000008,
	TrainTypeInternationalNight        = 0x00000010,
	TrainTypeNationalNight             = 0x00000020,
	TrainTypeLongDistanceFastLocal     = 0x00000040,
	TrainTypeFastLocal                 = 0x00000080,
	TrainTypeLocal                     = 0x00000100,
	TrainTypeSuburban                  = 0x00000200,
	TrainTypeUnderground               = 0x00000400,
	TrainTypeHistoric                  = 0x00001000,
	TrainTypeExtra                     = 0x00002000,

 	TrainTypePassengerWithCargo        = 0x00008000,

	TrainTypePassenger                 = TrainTypeInternationalHighSpeed
											| TrainTypeNationalHighSpeed
											| TrainTypeInternationalLongDistance
											| TrainTypeNationalLongDistance
											| TrainTypeInternationalNight
											| TrainTypeNationalNight
											| TrainTypeLongDistanceFastLocal
											| TrainTypeFastLocal
											| TrainTypeLocal
											| TrainTypeSuburban
											| TrainTypeUnderground
											| TrainTypeHistoric
											| TrainTypeExtra
											| TrainTypePassengerWithCargo,

	TrainTypeCargoLongDistance         = 0x00010000,
	TrainTypeCargoLocal                = 0x00020000,
	TrainTypeCargoBlock                = 0x00040000,
	TrainTypeCargoTractor              = 0x00080000,
	TrainTypeCargoExpress              = 0x00100000,

	TrainTypeCargoWithPassenger        = 0x00800000,

 	TrainTypeCargo                     = TrainTypeCargoLongDistance
 											| TrainTypeCargoLocal
 											| TrainTypeCargoBlock
 											| TrainTypeCargoTractor
 											| TrainTypeCargoExpress
 											| TrainTypeCargoWithPassenger,

	TrainTypeRescue                    = 0x01000000,
	TrainTypeConstruction              = 0x02000000,
	TrainTypeEmpty                     = 0x04000000,
	TrainTypeLoco                      = 0x08000000,
	TrainTypeCleaning                  = 0x10000000,

	TrainTypeOther                     = 0x40000000,
	// Bit 32 (0x80000000) can not be used because of conversion functions that handle with signed int32_t

	TrainTypeAll                       = TrainTypePassenger
											| TrainTypeCargo
											| TrainTypeRescue
											| TrainTypeConstruction
											| TrainTypeEmpty
											| TrainTypeLoco
											| TrainTypeCleaning
											| TrainTypeOther
};