From bc5ee8dc7124bfedaa07ec7881feb590f304301a Mon Sep 17 00:00:00 2001 From: flash62au Date: Tue, 21 May 2024 04:45:30 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20DCC-EX/D?= =?UTF-8?q?CCEXProtocol@1ba099c044813667c3590b990b57a63f57ef3b00=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- DCCEXProtocol_8h_source.html | 703 ++++++++++++++++++----------------- 1 file changed, 352 insertions(+), 351 deletions(-) diff --git a/DCCEXProtocol_8h_source.html b/DCCEXProtocol_8h_source.html index dbf52cb..edfd72c 100644 --- a/DCCEXProtocol_8h_source.html +++ b/DCCEXProtocol_8h_source.html @@ -106,346 +106,347 @@
34 /*
35 Version information:
36 
-
37 0.0.13 - Fix bug to allow compilation on AVR platforms, change ssize_t to int
-
38  - Add serial connectivity example
-
39  - Add support for SCREEN updates to delegate
-
40  - Enhance buffer management to clear command buffer if full
-
41 0.0.12 - Improved memory management
-
42 0.0.11 - support for individual track power receivedIndividualTrackPower(TrackPower state, int track)
-
43  - improved logic for overall track power
-
44 0.0.10 - Add support for broadcast messages
-
45 0.0.9 - if loco is selected by address and that loco is in the roster (with the same DCC Address), updated and send
-
46  speed commands for both
-
47 0.0.8 - No functional changes, add cross-platform and unit testing capabilities (credit to
-
48  higaski)
-
49 0.0.7 - Add isFunctionMomentary(int function);
-
50 0.0.6 - Add getFunctionName(int function);
-
51 0.0.5 - Increase MAX_FUNCTIONS to 32.
-
52  - Also add check to make sure the incoming does not exceed MAX_FUNCTIONS
-
53 0.0.4 - No functional changes, update author/maintainer and URL library properties
-
54 0.0.3 - Add getByAddress method to ConsistLoco
-
55  - Fix bug when removing locos from a consist
-
56  - Tidy setTrackType() method
-
57 0.0.2 - Add TrackManager configuration method and broadcast processing
-
58  - Add TrackManager, SSID, and mDNS examples
-
59 0.0.1 - Initial library release via the Arduino Library Manager
-
60 */
-
61 
-
62 #ifndef DCCEXPROTOCOL_H
-
63 #define DCCEXPROTOCOL_H
-
64 
-
65 #include "DCCEXInbound.h"
-
66 #include "DCCEXLoco.h"
-
67 #include "DCCEXRoutes.h"
-
68 #include "DCCEXTurnouts.h"
-
69 #include "DCCEXTurntables.h"
-
70 #include <Arduino.h>
-
71 
-
72 const int MAX_OUTBOUND_COMMAND_LENGTH = 100; // Max number of bytes for outbound commands
-
73 const int MAX_SERVER_DESCRIPTION_PARAM_LENGTH = 100; // Max number of bytes for <s> server details response
-
74 const int MAX_COMMAND_PARAMS = 50; // Max number of params to parse via DCCEXInbound parser
-
75 
-
76 // Valid track power state values
-
77 enum TrackPower {
-
78  PowerOff = 0,
-
79  PowerOn = 1,
-
80  PowerUnknown = 2,
-
81 };
-
82 
-
83 // Valid TrackManager types
-
84 enum TrackManagerMode {
-
85  MAIN, // Normal DCC track mode
-
86  PROG, // Programming DCC track mode
-
87  DC, // DC mode
-
88  DCX, // Reverse polarity DC mode
-
89  NONE, // Track is unused
-
90 };
-
91 
-
93 class NullStream : public Stream {
-
94 public:
-
96  NullStream() {}
-
97 
-
100  int available() { return 0; }
-
101 
-
103  void flush() {}
-
104 
-
107  int peek() { return -1; }
-
108 
-
111  int read() { return -1; }
-
112 
-
116  size_t write(uint8_t c) { return 1; }
-
117 
-
122  size_t write(const uint8_t *buffer, size_t size) { return size; }
-
123 };
-
124 
-
126 class DCCEXProtocolDelegate {
-
127 public:
-
132  virtual void receivedServerVersion(int major, int minor, int patch) {}
-
133 
-
136  virtual void receivedMessage(char *message) {}
-
137 
-
139  virtual void receivedRosterList() {}
-
140 
-
142  virtual void receivedTurnoutList() {}
-
143 
-
145  virtual void receivedRouteList() {}
-
146 
-
148  virtual void receivedTurntableList() {}
-
149 
-
152  virtual void receivedLocoUpdate(Loco *loco) {}
-
153 
-
156  virtual void receivedTrackPower(TrackPower state) {}
-
157 
-
161  virtual void receivedIndividualTrackPower(TrackPower state, int track) {}
-
162 
-
167  virtual void receivedTrackType(char track, TrackManagerMode type, int address) {}
-
168 
-
172  virtual void receivedTurnoutAction(int turnoutId, bool thrown) {}
-
173 
-
178  virtual void receivedTurntableAction(int turntableId, int position, bool moving) {}
-
179 
-
182  virtual void receivedReadLoco(int address) {}
-
183 
-
188  virtual void receivedScreenUpdate(int screen, int row, char *message) {}
-
189 };
-
190 
-
192 class DCCEXProtocol {
-
193 public:
-
194  // Protocol and server methods
-
195 
-
198  DCCEXProtocol(int maxCmdBuffer = 500);
-
199 
-
201  ~DCCEXProtocol();
-
202 
-
205  void setDelegate(DCCEXProtocolDelegate *delegate);
-
206 
-
209  void setLogStream(Stream *console);
-
210 
-
213  void connect(Stream *stream);
-
214 
-
216  void disconnect();
-
217 
-
219  void check();
-
220 
-
226  void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired);
-
227 
-
230  bool receivedLists();
-
231 
-
233  void requestServerVersion();
-
234 
-
237  bool receivedVersion();
-
238 
-
241  int getMajorVersion();
-
242 
-
245  int getMinorVersion();
-
246 
-
249  int getPatchVersion();
-
250 
-
253  unsigned long getLastServerResponseTime(); // seconds since Arduino start
-
254 
-
255  // Consist/Loco methods
-
256 
-
261  void setThrottle(Loco *loco, int speed, Direction direction);
-
262 
-
267  void setThrottle(Consist *consist, int speed, Direction direction);
-
268 
-
272  void functionOn(Loco *loco, int function);
-
273 
-
277  void functionOff(Loco *loco, int function);
-
278 
-
283  bool isFunctionOn(Loco *loco, int function);
-
284 
-
288  void functionOn(Consist *consist, int function);
-
289 
-
293  void functionOff(Consist *consist, int function);
-
294 
-
299  bool isFunctionOn(Consist *consist, int function);
-
300 
-
303  void requestLocoUpdate(int address);
-
304 
-
306  void readLoco();
-
307 
-
309  void emergencyStop();
-
310 
-
311  // Roster methods
-
312 
-
315  int getRosterCount();
-
316 
-
319  bool receivedRoster();
-
320 
-
324  Loco *findLocoInRoster(int address);
-
325 
-
326  // Turnout methods
-
327 
-
330  int getTurnoutCount();
-
331 
-
334  bool receivedTurnoutList();
-
335 
-
339  Turnout *getTurnoutById(int turnoutId);
-
340 
-
343  void closeTurnout(int turnoutId);
-
344 
-
347  void throwTurnout(int turnoutId);
-
348 
-
351  void toggleTurnout(int turnoutId);
-
352 
-
353  // Route methods
-
354 
-
357  int getRouteCount();
-
358 
-
361  bool receivedRouteList();
-
362 
-
365  void startRoute(int routeId);
-
366 
-
368  void pauseRoutes();
-
369 
-
371  void resumeRoutes();
-
372 
-
373  // Turntable methods
-
374 
-
377  int getTurntableCount();
-
378 
-
381  bool receivedTurntableList();
-
382 
-
386  Turntable *getTurntableById(int turntableId);
-
387 
-
392  void rotateTurntable(int turntableId, int position, int activity = 0);
-
393 
-
394  // Track management methods
-
395 
-
397  void powerOn();
-
398 
-
400  void powerOff();
-
401 
-
404  void powerTrackOn(char track);
-
405 
-
408  void powerTrackOff(char track);
-
409 
-
414  void setTrackType(char track, TrackManagerMode type, int address);
-
415 
-
416  // DCC accessory methods
-
417 
-
421  void activateAccessory(int accessoryAddress, int accessorySubAddr);
-
422 
-
426  void deactivateAccessory(int accessoryAddress, int accessorySubAddr);
-
427 
-
430  void activateLinearAccessory(int linearAddress);
-
431 
-
434  void deactivateLinearAccessory(int linearAddress);
-
435 
-
437  void getNumberSupportedLocos();
-
438 
-
439  // Attributes
-
440 
-
442  Loco *roster = nullptr;
-
443 
-
445  Turnout *turnouts = nullptr;
-
446 
-
448  Route *routes = nullptr;
-
449 
-
451  Turntable *turntables = nullptr;
-
452 
-
453 private:
-
454  // Methods
-
455  // Protocol and server methods
-
456  void _init();
-
457  void _sendCommand();
-
458  void _processCommand();
-
459  void _processServerDescription();
-
460  void _processMessage();
-
461  void _processScreenUpdate();
-
462 
-
463  // Consist/loco methods
-
464  void _processLocoBroadcast();
-
465  int _getValidFunctionMap(int functionMap);
-
466  int _getSpeedFromSpeedByte(int speedByte);
-
467  Direction _getDirectionFromSpeedByte(int speedByte);
-
468  void _setLoco(int address, int speed, Direction direction);
-
469  void _processReadResponse();
-
470 
-
471  // Roster methods
-
472  void _getRoster();
-
473  bool _requestedRoster();
-
474  void _processRosterList();
-
475  void _requestRosterEntry(int address);
-
476  void _processRosterEntry();
-
477 
-
478  // Turnout methods
-
479  void _getTurnouts();
-
480  bool _requestedTurnouts();
-
481  void _processTurnoutList();
-
482  void _requestTurnoutEntry(int id);
-
483  void _processTurnoutEntry();
-
484  void _processTurnoutBroadcast();
-
485 
-
486  // Route methods
-
487  void _getRoutes();
-
488  bool _requestedRoutes();
-
489  void _processRouteList();
-
490  void _requestRouteEntry(int id);
-
491  void _processRouteEntry();
-
492 
-
493  // Turntable methods
-
494  void _getTurntables();
-
495  bool _requestedTurntables();
-
496  void _processTurntableList();
-
497  void _requestTurntableEntry(int id);
-
498  void _processTurntableEntry();
-
499  void _requestTurntableIndexEntry(int id);
-
500  void _processTurntableIndexEntry();
-
501  void _processTurntableBroadcast();
-
502 
-
503  // Track management methods
-
504  void _processTrackPower();
-
505  void _processTrackType();
-
506 
-
507  // Attributes
-
508  int _rosterCount = 0; // Count of roster items received
-
509  int _turnoutCount = 0; // Count of turnout objects received
-
510  int _routeCount = 0; // Count of route objects received
-
511  int _turntableCount = 0; // Count of turntable objects received
-
512  int _version[3] = {}; // EX-CommandStation version x.y.z
-
513  Stream *_stream; // Stream object where commands are sent/received
-
514  Stream *_console; // Stream object for console output
-
515  NullStream _nullStream; // Send streams to null if no object provided
-
516  int _bufflen; // Used to ensure command buffer size not exceeded
-
517  int _maxCmdBuffer; // Max size for the command buffer
-
518  char *_cmdBuffer; // Char array for inbound command buffer
-
519  char _outboundCommand[MAX_OUTBOUND_COMMAND_LENGTH]; // Char array for outbound commands
-
520  DCCEXProtocolDelegate *_delegate = nullptr; // Pointer to the delegate for notifications
-
521  unsigned long _lastServerResponseTime; // Records the timestamp of the last server response
-
522  char _inputBuffer[512]; // Char array for input buffer
-
523  int _nextChar; // where the next character to be read goes in the buffer
-
524  bool _receivedVersion = false; // Flag that server version has been received
-
525  bool _receivedLists = false; // Flag if all requested lists have been received
-
526  bool _rosterRequested = false; // Flag that roster has been requested
-
527  bool _receivedRoster = false; // Flag that roster has been received
-
528  bool _turnoutListRequested = false; // Flag that turnout list requested
-
529  bool _receivedTurnoutList = false; // Flag that turnout list received
-
530  bool _routeListRequested = false; // Flag that route list requested
-
531  bool _receivedRouteList = false; // Flag that route list received
-
532  bool _turntableListRequested = false; // Flag that turntable list requested
-
533  bool _receivedTurntableList = false; // Flag that turntable list received
-
534 };
-
535 
-
536 #endif // DCCEXPROTOCOL_H
+
37 0.0.14 - add getNumberSupportedLocos() used for the fake heartbeat
+
38 0.0.13 - Fix bug to allow compilation on AVR platforms, change ssize_t to int
+
39  - Add serial connectivity example
+
40  - Add support for SCREEN updates to delegate
+
41  - Enhance buffer management to clear command buffer if full
+
42 0.0.12 - Improved memory management
+
43 0.0.11 - support for individual track power receivedIndividualTrackPower(TrackPower state, int track)
+
44  - improved logic for overall track power
+
45 0.0.10 - Add support for broadcast messages
+
46 0.0.9 - if loco is selected by address and that loco is in the roster (with the same DCC Address), updated and send
+
47  speed commands for both
+
48 0.0.8 - No functional changes, add cross-platform and unit testing capabilities (credit to
+
49  higaski)
+
50 0.0.7 - Add isFunctionMomentary(int function);
+
51 0.0.6 - Add getFunctionName(int function);
+
52 0.0.5 - Increase MAX_FUNCTIONS to 32.
+
53  - Also add check to make sure the incoming does not exceed MAX_FUNCTIONS
+
54 0.0.4 - No functional changes, update author/maintainer and URL library properties
+
55 0.0.3 - Add getByAddress method to ConsistLoco
+
56  - Fix bug when removing locos from a consist
+
57  - Tidy setTrackType() method
+
58 0.0.2 - Add TrackManager configuration method and broadcast processing
+
59  - Add TrackManager, SSID, and mDNS examples
+
60 0.0.1 - Initial library release via the Arduino Library Manager
+
61 */
+
62 
+
63 #ifndef DCCEXPROTOCOL_H
+
64 #define DCCEXPROTOCOL_H
+
65 
+
66 #include "DCCEXInbound.h"
+
67 #include "DCCEXLoco.h"
+
68 #include "DCCEXRoutes.h"
+
69 #include "DCCEXTurnouts.h"
+
70 #include "DCCEXTurntables.h"
+
71 #include <Arduino.h>
+
72 
+
73 const int MAX_OUTBOUND_COMMAND_LENGTH = 100; // Max number of bytes for outbound commands
+
74 const int MAX_SERVER_DESCRIPTION_PARAM_LENGTH = 100; // Max number of bytes for <s> server details response
+
75 const int MAX_COMMAND_PARAMS = 50; // Max number of params to parse via DCCEXInbound parser
+
76 
+
77 // Valid track power state values
+
78 enum TrackPower {
+
79  PowerOff = 0,
+
80  PowerOn = 1,
+
81  PowerUnknown = 2,
+
82 };
+
83 
+
84 // Valid TrackManager types
+
85 enum TrackManagerMode {
+
86  MAIN, // Normal DCC track mode
+
87  PROG, // Programming DCC track mode
+
88  DC, // DC mode
+
89  DCX, // Reverse polarity DC mode
+
90  NONE, // Track is unused
+
91 };
+
92 
+
94 class NullStream : public Stream {
+
95 public:
+
97  NullStream() {}
+
98 
+
101  int available() { return 0; }
+
102 
+
104  void flush() {}
+
105 
+
108  int peek() { return -1; }
+
109 
+
112  int read() { return -1; }
+
113 
+
117  size_t write(uint8_t c) { return 1; }
+
118 
+
123  size_t write(const uint8_t *buffer, size_t size) { return size; }
+
124 };
+
125 
+
127 class DCCEXProtocolDelegate {
+
128 public:
+
133  virtual void receivedServerVersion(int major, int minor, int patch) {}
+
134 
+
137  virtual void receivedMessage(char *message) {}
+
138 
+
140  virtual void receivedRosterList() {}
+
141 
+
143  virtual void receivedTurnoutList() {}
+
144 
+
146  virtual void receivedRouteList() {}
+
147 
+
149  virtual void receivedTurntableList() {}
+
150 
+
153  virtual void receivedLocoUpdate(Loco *loco) {}
+
154 
+
157  virtual void receivedTrackPower(TrackPower state) {}
+
158 
+
162  virtual void receivedIndividualTrackPower(TrackPower state, int track) {}
+
163 
+
168  virtual void receivedTrackType(char track, TrackManagerMode type, int address) {}
+
169 
+
173  virtual void receivedTurnoutAction(int turnoutId, bool thrown) {}
+
174 
+
179  virtual void receivedTurntableAction(int turntableId, int position, bool moving) {}
+
180 
+
183  virtual void receivedReadLoco(int address) {}
+
184 
+
189  virtual void receivedScreenUpdate(int screen, int row, char *message) {}
+
190 };
+
191 
+
193 class DCCEXProtocol {
+
194 public:
+
195  // Protocol and server methods
+
196 
+
199  DCCEXProtocol(int maxCmdBuffer = 500);
+
200 
+
202  ~DCCEXProtocol();
+
203 
+
206  void setDelegate(DCCEXProtocolDelegate *delegate);
+
207 
+
210  void setLogStream(Stream *console);
+
211 
+
214  void connect(Stream *stream);
+
215 
+
217  void disconnect();
+
218 
+
220  void check();
+
221 
+
227  void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired);
+
228 
+
231  bool receivedLists();
+
232 
+
234  void requestServerVersion();
+
235 
+
238  bool receivedVersion();
+
239 
+
242  int getMajorVersion();
+
243 
+
246  int getMinorVersion();
+
247 
+
250  int getPatchVersion();
+
251 
+
254  unsigned long getLastServerResponseTime(); // seconds since Arduino start
+
255 
+
256  // Consist/Loco methods
+
257 
+
262  void setThrottle(Loco *loco, int speed, Direction direction);
+
263 
+
268  void setThrottle(Consist *consist, int speed, Direction direction);
+
269 
+
273  void functionOn(Loco *loco, int function);
+
274 
+
278  void functionOff(Loco *loco, int function);
+
279 
+
284  bool isFunctionOn(Loco *loco, int function);
+
285 
+
289  void functionOn(Consist *consist, int function);
+
290 
+
294  void functionOff(Consist *consist, int function);
+
295 
+
300  bool isFunctionOn(Consist *consist, int function);
+
301 
+
304  void requestLocoUpdate(int address);
+
305 
+
307  void readLoco();
+
308 
+
310  void emergencyStop();
+
311 
+
312  // Roster methods
+
313 
+
316  int getRosterCount();
+
317 
+
320  bool receivedRoster();
+
321 
+
325  Loco *findLocoInRoster(int address);
+
326 
+
327  // Turnout methods
+
328 
+
331  int getTurnoutCount();
+
332 
+
335  bool receivedTurnoutList();
+
336 
+
340  Turnout *getTurnoutById(int turnoutId);
+
341 
+
344  void closeTurnout(int turnoutId);
+
345 
+
348  void throwTurnout(int turnoutId);
+
349 
+
352  void toggleTurnout(int turnoutId);
+
353 
+
354  // Route methods
+
355 
+
358  int getRouteCount();
+
359 
+
362  bool receivedRouteList();
+
363 
+
366  void startRoute(int routeId);
+
367 
+
369  void pauseRoutes();
+
370 
+
372  void resumeRoutes();
+
373 
+
374  // Turntable methods
+
375 
+
378  int getTurntableCount();
+
379 
+
382  bool receivedTurntableList();
+
383 
+
387  Turntable *getTurntableById(int turntableId);
+
388 
+
393  void rotateTurntable(int turntableId, int position, int activity = 0);
+
394 
+
395  // Track management methods
+
396 
+
398  void powerOn();
+
399 
+
401  void powerOff();
+
402 
+
405  void powerTrackOn(char track);
+
406 
+
409  void powerTrackOff(char track);
+
410 
+
415  void setTrackType(char track, TrackManagerMode type, int address);
+
416 
+
417  // DCC accessory methods
+
418 
+
422  void activateAccessory(int accessoryAddress, int accessorySubAddr);
+
423 
+
427  void deactivateAccessory(int accessoryAddress, int accessorySubAddr);
+
428 
+
431  void activateLinearAccessory(int linearAddress);
+
432 
+
435  void deactivateLinearAccessory(int linearAddress);
+
436 
+
438  void getNumberSupportedLocos();
+
439 
+
440  // Attributes
+
441 
+
443  Loco *roster = nullptr;
+
444 
+
446  Turnout *turnouts = nullptr;
+
447 
+
449  Route *routes = nullptr;
+
450 
+
452  Turntable *turntables = nullptr;
+
453 
+
454 private:
+
455  // Methods
+
456  // Protocol and server methods
+
457  void _init();
+
458  void _sendCommand();
+
459  void _processCommand();
+
460  void _processServerDescription();
+
461  void _processMessage();
+
462  void _processScreenUpdate();
+
463 
+
464  // Consist/loco methods
+
465  void _processLocoBroadcast();
+
466  int _getValidFunctionMap(int functionMap);
+
467  int _getSpeedFromSpeedByte(int speedByte);
+
468  Direction _getDirectionFromSpeedByte(int speedByte);
+
469  void _setLoco(int address, int speed, Direction direction);
+
470  void _processReadResponse();
+
471 
+
472  // Roster methods
+
473  void _getRoster();
+
474  bool _requestedRoster();
+
475  void _processRosterList();
+
476  void _requestRosterEntry(int address);
+
477  void _processRosterEntry();
+
478 
+
479  // Turnout methods
+
480  void _getTurnouts();
+
481  bool _requestedTurnouts();
+
482  void _processTurnoutList();
+
483  void _requestTurnoutEntry(int id);
+
484  void _processTurnoutEntry();
+
485  void _processTurnoutBroadcast();
+
486 
+
487  // Route methods
+
488  void _getRoutes();
+
489  bool _requestedRoutes();
+
490  void _processRouteList();
+
491  void _requestRouteEntry(int id);
+
492  void _processRouteEntry();
+
493 
+
494  // Turntable methods
+
495  void _getTurntables();
+
496  bool _requestedTurntables();
+
497  void _processTurntableList();
+
498  void _requestTurntableEntry(int id);
+
499  void _processTurntableEntry();
+
500  void _requestTurntableIndexEntry(int id);
+
501  void _processTurntableIndexEntry();
+
502  void _processTurntableBroadcast();
+
503 
+
504  // Track management methods
+
505  void _processTrackPower();
+
506  void _processTrackType();
+
507 
+
508  // Attributes
+
509  int _rosterCount = 0; // Count of roster items received
+
510  int _turnoutCount = 0; // Count of turnout objects received
+
511  int _routeCount = 0; // Count of route objects received
+
512  int _turntableCount = 0; // Count of turntable objects received
+
513  int _version[3] = {}; // EX-CommandStation version x.y.z
+
514  Stream *_stream; // Stream object where commands are sent/received
+
515  Stream *_console; // Stream object for console output
+
516  NullStream _nullStream; // Send streams to null if no object provided
+
517  int _bufflen; // Used to ensure command buffer size not exceeded
+
518  int _maxCmdBuffer; // Max size for the command buffer
+
519  char *_cmdBuffer; // Char array for inbound command buffer
+
520  char _outboundCommand[MAX_OUTBOUND_COMMAND_LENGTH]; // Char array for outbound commands
+
521  DCCEXProtocolDelegate *_delegate = nullptr; // Pointer to the delegate for notifications
+
522  unsigned long _lastServerResponseTime; // Records the timestamp of the last server response
+
523  char _inputBuffer[512]; // Char array for input buffer
+
524  int _nextChar; // where the next character to be read goes in the buffer
+
525  bool _receivedVersion = false; // Flag that server version has been received
+
526  bool _receivedLists = false; // Flag if all requested lists have been received
+
527  bool _rosterRequested = false; // Flag that roster has been requested
+
528  bool _receivedRoster = false; // Flag that roster has been received
+
529  bool _turnoutListRequested = false; // Flag that turnout list requested
+
530  bool _receivedTurnoutList = false; // Flag that turnout list received
+
531  bool _routeListRequested = false; // Flag that route list requested
+
532  bool _receivedRouteList = false; // Flag that route list received
+
533  bool _turntableListRequested = false; // Flag that turntable list requested
+
534  bool _receivedTurntableList = false; // Flag that turntable list received
+
535 };
+
536 
+
537 #endif // DCCEXPROTOCOL_H
Class to create a software consist of one or more ConsistLoco objects.
Definition: DCCEXLoco.h:185
-
Delegate responses and broadcast events to the client software to enable custom event handlers.
Definition: DCCEXProtocol.h:126
-
virtual void receivedServerVersion(int major, int minor, int patch)
Notify when the server version has been received.
Definition: DCCEXProtocol.h:132
-
virtual void receivedRosterList()
Notify when the roster list is received.
Definition: DCCEXProtocol.h:139
-
virtual void receivedTurnoutAction(int turnoutId, bool thrown)
Notify when a turnout state change is received.
Definition: DCCEXProtocol.h:172
-
virtual void receivedMessage(char *message)
Notify when a broadcast message has been received.
Definition: DCCEXProtocol.h:136
-
virtual void receivedTrackType(char track, TrackManagerMode type, int address)
Notify when a track type change is received.
Definition: DCCEXProtocol.h:167
-
virtual void receivedScreenUpdate(int screen, int row, char *message)
Notify when a screen update is received.
Definition: DCCEXProtocol.h:188
-
virtual void receivedIndividualTrackPower(TrackPower state, int track)
Notify when an individual track power state change is received.
Definition: DCCEXProtocol.h:161
-
virtual void receivedLocoUpdate(Loco *loco)
Notify when an update to a Loco object is received.
Definition: DCCEXProtocol.h:152
-
virtual void receivedTurntableList()
Notify when the turntable list is received.
Definition: DCCEXProtocol.h:148
-
virtual void receivedRouteList()
Notify when the route list is received.
Definition: DCCEXProtocol.h:145
-
virtual void receivedReadLoco(int address)
Notify when a loco address is read from the programming track.
Definition: DCCEXProtocol.h:182
-
virtual void receivedTurnoutList()
Notify when the turnout list is received.
Definition: DCCEXProtocol.h:142
-
virtual void receivedTurntableAction(int turntableId, int position, bool moving)
Notify when a turntable index change is received.
Definition: DCCEXProtocol.h:178
-
virtual void receivedTrackPower(TrackPower state)
Notify when the global track power state change is received.
Definition: DCCEXProtocol.h:156
-
Main class for the DCCEXProtocol library.
Definition: DCCEXProtocol.h:192
+
Delegate responses and broadcast events to the client software to enable custom event handlers.
Definition: DCCEXProtocol.h:127
+
virtual void receivedServerVersion(int major, int minor, int patch)
Notify when the server version has been received.
Definition: DCCEXProtocol.h:133
+
virtual void receivedRosterList()
Notify when the roster list is received.
Definition: DCCEXProtocol.h:140
+
virtual void receivedTurnoutAction(int turnoutId, bool thrown)
Notify when a turnout state change is received.
Definition: DCCEXProtocol.h:173
+
virtual void receivedMessage(char *message)
Notify when a broadcast message has been received.
Definition: DCCEXProtocol.h:137
+
virtual void receivedTrackType(char track, TrackManagerMode type, int address)
Notify when a track type change is received.
Definition: DCCEXProtocol.h:168
+
virtual void receivedScreenUpdate(int screen, int row, char *message)
Notify when a screen update is received.
Definition: DCCEXProtocol.h:189
+
virtual void receivedIndividualTrackPower(TrackPower state, int track)
Notify when an individual track power state change is received.
Definition: DCCEXProtocol.h:162
+
virtual void receivedLocoUpdate(Loco *loco)
Notify when an update to a Loco object is received.
Definition: DCCEXProtocol.h:153
+
virtual void receivedTurntableList()
Notify when the turntable list is received.
Definition: DCCEXProtocol.h:149
+
virtual void receivedRouteList()
Notify when the route list is received.
Definition: DCCEXProtocol.h:146
+
virtual void receivedReadLoco(int address)
Notify when a loco address is read from the programming track.
Definition: DCCEXProtocol.h:183
+
virtual void receivedTurnoutList()
Notify when the turnout list is received.
Definition: DCCEXProtocol.h:143
+
virtual void receivedTurntableAction(int turntableId, int position, bool moving)
Notify when a turntable index change is received.
Definition: DCCEXProtocol.h:179
+
virtual void receivedTrackPower(TrackPower state)
Notify when the global track power state change is received.
Definition: DCCEXProtocol.h:157
+
Main class for the DCCEXProtocol library.
Definition: DCCEXProtocol.h:193
void setThrottle(Loco *loco, int speed, Direction direction)
Set the provided loco to the specified speed and direction.
Definition: DCCEXProtocol.cpp:178
int getMinorVersion()
Retrieve the minor version of EX-Commandstation.
Definition: DCCEXProtocol.cpp:170
bool receivedTurntableList()
Check if turntable list has been received.
Definition: DCCEXProtocol.cpp:381
@@ -459,18 +460,18 @@
void connect(Stream *stream)
Connect the stream object to interact with DCC-EX.
Definition: DCCEXProtocol.cpp:79
void startRoute(int routeId)
Start a route/automation.
Definition: DCCEXProtocol.cpp:350
unsigned long getLastServerResponseTime()
Retrieve the last time the server responded.
Definition: DCCEXProtocol.cpp:174
-
Route * routes
Linked list of Route objects to form the list of routes and automations.
Definition: DCCEXProtocol.h:448
+
Route * routes
Linked list of Route objects to form the list of routes and automations.
Definition: DCCEXProtocol.h:449
bool receivedRouteList()
Check if route list has been received.
Definition: DCCEXProtocol.cpp:348
bool receivedTurnoutList()
Check if turnout list has been received.
Definition: DCCEXProtocol.cpp:307
int getTurntableCount()
Get the number of turntable entries.
Definition: DCCEXProtocol.cpp:379
void rotateTurntable(int turntableId, int position, int activity=0)
Rotate a turntable object.
Definition: DCCEXProtocol.cpp:392
bool receivedRoster()
Check if roster has been received.
Definition: DCCEXProtocol.cpp:289
~DCCEXProtocol()
Destructor for the DCCEXProtocol object.
Definition: DCCEXProtocol.cpp:65
-
Loco * roster
Linked list of Loco objects to form the roster.
Definition: DCCEXProtocol.h:442
+
Loco * roster
Linked list of Loco objects to form the roster.
Definition: DCCEXProtocol.h:443
void powerTrackOff(char track)
Turn power off for the specified track.
Definition: DCCEXProtocol.cpp:434
void deactivateAccessory(int accessoryAddress, int accessorySubAddr)
Deactivate DCC accessory at the specified address and subaddress.
Definition: DCCEXProtocol.cpp:477
void getNumberSupportedLocos()
Request the number of supported cabs(locos)
Definition: DCCEXProtocol.cpp:504
-
Turntable * turntables
Linked list of Turntable objects to form the list of turntables.
Definition: DCCEXProtocol.h:451
+
Turntable * turntables
Linked list of Turntable objects to form the list of turntables.
Definition: DCCEXProtocol.h:452
void functionOn(Loco *loco, int function)
Turn the specified function on for the provided loco.
Definition: DCCEXProtocol.cpp:201
int getRouteCount()
Get the number of route entries.
Definition: DCCEXProtocol.cpp:346
void setTrackType(char track, TrackManagerMode type, int address)
set track type for the specified track
Definition: DCCEXProtocol.cpp:441
@@ -487,7 +488,7 @@
Turntable * getTurntableById(int turntableId)
Retrieve a turntable object by its ID.
Definition: DCCEXProtocol.cpp:383
void powerOn()
Global track power on command.
Definition: DCCEXProtocol.cpp:413
Turnout * getTurnoutById(int turnoutId)
Retrieve a turnout/point object by its ID.
Definition: DCCEXProtocol.cpp:310
-
Turnout * turnouts
Linked list of Turnout objects to form the turnout list.
Definition: DCCEXProtocol.h:445
+
Turnout * turnouts
Linked list of Turnout objects to form the turnout list.
Definition: DCCEXProtocol.h:446
void pauseRoutes()
Pause all routes/automations.
Definition: DCCEXProtocol.cpp:359
int getTurnoutCount()
Get the number of turnouts.
Definition: DCCEXProtocol.cpp:305
void setLogStream(Stream *console)
Set the stream object for console output.
Definition: DCCEXProtocol.cpp:77
@@ -501,14 +502,14 @@
void check()
Check for incoming DCC-EX broadcasts/responses and parse them.
Definition: DCCEXProtocol.cpp:90
void emergencyStop()
Initiate an emergency stop.
Definition: DCCEXProtocol.cpp:276
Class for a Loco object representing a DCC addressed locomotive.
Definition: DCCEXLoco.h:54
-
Nullstream class for initial DCCEXProtocol instantiation to direct streams to nothing.
Definition: DCCEXProtocol.h:93
-
size_t write(uint8_t c)
Dummy write method for single int.
Definition: DCCEXProtocol.h:116
-
int peek()
Dummy peek method.
Definition: DCCEXProtocol.h:107
-
int available()
Dummy availability check.
Definition: DCCEXProtocol.h:100
-
void flush()
Dummy flush method.
Definition: DCCEXProtocol.h:103
-
NullStream()
Constructor for the NullStream object.
Definition: DCCEXProtocol.h:96
-
int read()
Dummy read method.
Definition: DCCEXProtocol.h:111
-
size_t write(const uint8_t *buffer, size_t size)
Dummy write method for buffered input.
Definition: DCCEXProtocol.h:122
+
Nullstream class for initial DCCEXProtocol instantiation to direct streams to nothing.
Definition: DCCEXProtocol.h:94
+
size_t write(uint8_t c)
Dummy write method for single int.
Definition: DCCEXProtocol.h:117
+
int peek()
Dummy peek method.
Definition: DCCEXProtocol.h:108
+
int available()
Dummy availability check.
Definition: DCCEXProtocol.h:101
+
void flush()
Dummy flush method.
Definition: DCCEXProtocol.h:104
+
NullStream()
Constructor for the NullStream object.
Definition: DCCEXProtocol.h:97
+
int read()
Dummy read method.
Definition: DCCEXProtocol.h:112
+
size_t write(const uint8_t *buffer, size_t size)
Dummy write method for buffered input.
Definition: DCCEXProtocol.h:123
Class to contain and maintain the various Route attributes and methods.
Definition: DCCEXRoutes.h:40
Class to contain and maintain the various Turnout/Point attributes and methods.
Definition: DCCEXTurnouts.h:35
Class to contain and maintain the various Turntable attributes and methods.
Definition: DCCEXTurntables.h:82