diff --git a/DCCEXProtocol_8h_source.html b/DCCEXProtocol_8h_source.html index edfd72c..f00f82b 100644 --- a/DCCEXProtocol_8h_source.html +++ b/DCCEXProtocol_8h_source.html @@ -106,347 +106,348 @@
34 /*
35 Version information:
36 
-
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
+
37 0.0.15 - any acquired loco is now retained in the roster
+
38 0.0.14 - add getNumberSupportedLocos() used for the fake heartbeat
+
39 0.0.13 - Fix bug to allow compilation on AVR platforms, change ssize_t to int
+
40  - Add serial connectivity example
+
41  - Add support for SCREEN updates to delegate
+
42  - Enhance buffer management to clear command buffer if full
+
43 0.0.12 - Improved memory management
+
44 0.0.11 - support for individual track power receivedIndividualTrackPower(TrackPower state, int track)
+
45  - improved logic for overall track power
+
46 0.0.10 - Add support for broadcast messages
+
47 0.0.9 - if loco is selected by address and that loco is in the roster (with the same DCC Address), updated and send
+
48  speed commands for both
+
49 0.0.8 - No functional changes, add cross-platform and unit testing capabilities (credit to
+
50  higaski)
+
51 0.0.7 - Add isFunctionMomentary(int function);
+
52 0.0.6 - Add getFunctionName(int function);
+
53 0.0.5 - Increase MAX_FUNCTIONS to 32.
+
54  - Also add check to make sure the incoming does not exceed MAX_FUNCTIONS
+
55 0.0.4 - No functional changes, update author/maintainer and URL library properties
+
56 0.0.3 - Add getByAddress method to ConsistLoco
+
57  - Fix bug when removing locos from a consist
+
58  - Tidy setTrackType() method
+
59 0.0.2 - Add TrackManager configuration method and broadcast processing
+
60  - Add TrackManager, SSID, and mDNS examples
+
61 0.0.1 - Initial library release via the Arduino Library Manager
+
62 */
+
63 
+
64 #ifndef DCCEXPROTOCOL_H
+
65 #define DCCEXPROTOCOL_H
+
66 
+
67 #include "DCCEXInbound.h"
+
68 #include "DCCEXLoco.h"
+
69 #include "DCCEXRoutes.h"
+
70 #include "DCCEXTurnouts.h"
+
71 #include "DCCEXTurntables.h"
+
72 #include <Arduino.h>
+
73 
+
74 const int MAX_OUTBOUND_COMMAND_LENGTH = 100; // Max number of bytes for outbound commands
+
75 const int MAX_SERVER_DESCRIPTION_PARAM_LENGTH = 100; // Max number of bytes for <s> server details response
+
76 const int MAX_COMMAND_PARAMS = 50; // Max number of params to parse via DCCEXInbound parser
+
77 
+
78 // Valid track power state values
+
79 enum TrackPower {
+
80  PowerOff = 0,
+
81  PowerOn = 1,
+
82  PowerUnknown = 2,
+
83 };
+
84 
+
85 // Valid TrackManager types
+
86 enum TrackManagerMode {
+
87  MAIN, // Normal DCC track mode
+
88  PROG, // Programming DCC track mode
+
89  DC, // DC mode
+
90  DCX, // Reverse polarity DC mode
+
91  NONE, // Track is unused
+
92 };
+
93 
+
95 class NullStream : public Stream {
+
96 public:
+
98  NullStream() {}
+
99 
+
102  int available() { return 0; }
+
103 
+
105  void flush() {}
+
106 
+
109  int peek() { return -1; }
+
110 
+
113  int read() { return -1; }
+
114 
+
118  size_t write(uint8_t c) { return 1; }
+
119 
+
124  size_t write(const uint8_t *buffer, size_t size) { return size; }
+
125 };
+
126 
+
128 class DCCEXProtocolDelegate {
+
129 public:
+
134  virtual void receivedServerVersion(int major, int minor, int patch) {}
+
135 
+
138  virtual void receivedMessage(char *message) {}
+
139 
+
141  virtual void receivedRosterList() {}
+
142 
+
144  virtual void receivedTurnoutList() {}
+
145 
+
147  virtual void receivedRouteList() {}
+
148 
+
150  virtual void receivedTurntableList() {}
+
151 
+
154  virtual void receivedLocoUpdate(Loco *loco) {}
+
155 
+
158  virtual void receivedTrackPower(TrackPower state) {}
+
159 
+
163  virtual void receivedIndividualTrackPower(TrackPower state, int track) {}
+
164 
+
169  virtual void receivedTrackType(char track, TrackManagerMode type, int address) {}
+
170 
+
174  virtual void receivedTurnoutAction(int turnoutId, bool thrown) {}
+
175 
+
180  virtual void receivedTurntableAction(int turntableId, int position, bool moving) {}
+
181 
+
184  virtual void receivedReadLoco(int address) {}
+
185 
+
190  virtual void receivedScreenUpdate(int screen, int row, char *message) {}
+
191 };
+
192 
+
194 class DCCEXProtocol {
+
195 public:
+
196  // Protocol and server methods
+
197 
+
200  DCCEXProtocol(int maxCmdBuffer = 500);
+
201 
+
203  ~DCCEXProtocol();
+
204 
+
207  void setDelegate(DCCEXProtocolDelegate *delegate);
+
208 
+
211  void setLogStream(Stream *console);
+
212 
+
215  void connect(Stream *stream);
+
216 
+
218  void disconnect();
+
219 
+
221  void check();
+
222 
+
228  void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired);
+
229 
+
232  bool receivedLists();
+
233 
+
235  void requestServerVersion();
+
236 
+
239  bool receivedVersion();
+
240 
+
243  int getMajorVersion();
+
244 
+
247  int getMinorVersion();
+
248 
+
251  int getPatchVersion();
+
252 
+
255  unsigned long getLastServerResponseTime(); // seconds since Arduino start
+
256 
+
257  // Consist/Loco methods
+
258 
+
263  void setThrottle(Loco *loco, int speed, Direction direction);
+
264 
+
269  void setThrottle(Consist *consist, int speed, Direction direction);
+
270 
+
274  void functionOn(Loco *loco, int function);
+
275 
+
279  void functionOff(Loco *loco, int function);
+
280 
+
285  bool isFunctionOn(Loco *loco, int function);
+
286 
+
290  void functionOn(Consist *consist, int function);
+
291 
+
295  void functionOff(Consist *consist, int function);
+
296 
+
301  bool isFunctionOn(Consist *consist, int function);
+
302 
+
305  void requestLocoUpdate(int address);
+
306 
+
308  void readLoco();
+
309 
+
311  void emergencyStop();
+
312 
+
313  // Roster methods
+
314 
+
317  int getRosterCount();
+
318 
+
321  bool receivedRoster();
+
322 
+
326  Loco *findLocoInRoster(int address);
+
327 
+
328  // Turnout methods
+
329 
+
332  int getTurnoutCount();
+
333 
+
336  bool receivedTurnoutList();
+
337 
+
341  Turnout *getTurnoutById(int turnoutId);
+
342 
+
345  void closeTurnout(int turnoutId);
+
346 
+
349  void throwTurnout(int turnoutId);
+
350 
+
353  void toggleTurnout(int turnoutId);
+
354 
+
355  // Route methods
+
356 
+
359  int getRouteCount();
+
360 
+
363  bool receivedRouteList();
+
364 
+
367  void startRoute(int routeId);
+
368 
+
370  void pauseRoutes();
+
371 
+
373  void resumeRoutes();
+
374 
+
375  // Turntable methods
+
376 
+
379  int getTurntableCount();
+
380 
+
383  bool receivedTurntableList();
+
384 
+
388  Turntable *getTurntableById(int turntableId);
+
389 
+
394  void rotateTurntable(int turntableId, int position, int activity = 0);
+
395 
+
396  // Track management methods
+
397 
+
399  void powerOn();
+
400 
+
402  void powerOff();
+
403 
+
406  void powerTrackOn(char track);
+
407 
+
410  void powerTrackOff(char track);
+
411 
+
416  void setTrackType(char track, TrackManagerMode type, int address);
+
417 
+
418  // DCC accessory methods
+
419 
+
423  void activateAccessory(int accessoryAddress, int accessorySubAddr);
+
424 
+
428  void deactivateAccessory(int accessoryAddress, int accessorySubAddr);
+
429 
+
432  void activateLinearAccessory(int linearAddress);
+
433 
+
436  void deactivateLinearAccessory(int linearAddress);
+
437 
+
439  void getNumberSupportedLocos();
+
440 
+
441  // Attributes
+
442 
+
444  Loco *roster = nullptr;
+
445 
+
447  Turnout *turnouts = nullptr;
+
448 
+
450  Route *routes = nullptr;
+
451 
+
453  Turntable *turntables = nullptr;
+
454 
+
455 private:
+
456  // Methods
+
457  // Protocol and server methods
+
458  void _init();
+
459  void _sendCommand();
+
460  void _processCommand();
+
461  void _processServerDescription();
+
462  void _processMessage();
+
463  void _processScreenUpdate();
+
464 
+
465  // Consist/loco methods
+
466  void _processLocoBroadcast();
+
467  int _getValidFunctionMap(int functionMap);
+
468  int _getSpeedFromSpeedByte(int speedByte);
+
469  Direction _getDirectionFromSpeedByte(int speedByte);
+
470  void _setLoco(int address, int speed, Direction direction);
+
471  void _processReadResponse();
+
472 
+
473  // Roster methods
+
474  void _getRoster();
+
475  bool _requestedRoster();
+
476  void _processRosterList();
+
477  void _requestRosterEntry(int address);
+
478  void _processRosterEntry();
+
479 
+
480  // Turnout methods
+
481  void _getTurnouts();
+
482  bool _requestedTurnouts();
+
483  void _processTurnoutList();
+
484  void _requestTurnoutEntry(int id);
+
485  void _processTurnoutEntry();
+
486  void _processTurnoutBroadcast();
+
487 
+
488  // Route methods
+
489  void _getRoutes();
+
490  bool _requestedRoutes();
+
491  void _processRouteList();
+
492  void _requestRouteEntry(int id);
+
493  void _processRouteEntry();
+
494 
+
495  // Turntable methods
+
496  void _getTurntables();
+
497  bool _requestedTurntables();
+
498  void _processTurntableList();
+
499  void _requestTurntableEntry(int id);
+
500  void _processTurntableEntry();
+
501  void _requestTurntableIndexEntry(int id);
+
502  void _processTurntableIndexEntry();
+
503  void _processTurntableBroadcast();
+
504 
+
505  // Track management methods
+
506  void _processTrackPower();
+
507  void _processTrackType();
+
508 
+
509  // Attributes
+
510  int _rosterCount = 0; // Count of roster items received
+
511  int _turnoutCount = 0; // Count of turnout objects received
+
512  int _routeCount = 0; // Count of route objects received
+
513  int _turntableCount = 0; // Count of turntable objects received
+
514  int _version[3] = {}; // EX-CommandStation version x.y.z
+
515  Stream *_stream; // Stream object where commands are sent/received
+
516  Stream *_console; // Stream object for console output
+
517  NullStream _nullStream; // Send streams to null if no object provided
+
518  int _bufflen; // Used to ensure command buffer size not exceeded
+
519  int _maxCmdBuffer; // Max size for the command buffer
+
520  char *_cmdBuffer; // Char array for inbound command buffer
+
521  char _outboundCommand[MAX_OUTBOUND_COMMAND_LENGTH]; // Char array for outbound commands
+
522  DCCEXProtocolDelegate *_delegate = nullptr; // Pointer to the delegate for notifications
+
523  unsigned long _lastServerResponseTime; // Records the timestamp of the last server response
+
524  char _inputBuffer[512]; // Char array for input buffer
+
525  int _nextChar; // where the next character to be read goes in the buffer
+
526  bool _receivedVersion = false; // Flag that server version has been received
+
527  bool _receivedLists = false; // Flag if all requested lists have been received
+
528  bool _rosterRequested = false; // Flag that roster has been requested
+
529  bool _receivedRoster = false; // Flag that roster has been received
+
530  bool _turnoutListRequested = false; // Flag that turnout list requested
+
531  bool _receivedTurnoutList = false; // Flag that turnout list received
+
532  bool _routeListRequested = false; // Flag that route list requested
+
533  bool _receivedRouteList = false; // Flag that route list received
+
534  bool _turntableListRequested = false; // Flag that turntable list requested
+
535  bool _receivedTurntableList = false; // Flag that turntable list received
+
536 };
+
537 
+
538 #endif // DCCEXPROTOCOL_H
Consist
Class to create a software consist of one or more ConsistLoco objects.
Definition: DCCEXLoco.h:185
-
DCCEXProtocolDelegate
Delegate responses and broadcast events to the client software to enable custom event handlers.
Definition: DCCEXProtocol.h:127
-
DCCEXProtocolDelegate::receivedServerVersion
virtual void receivedServerVersion(int major, int minor, int patch)
Notify when the server version has been received.
Definition: DCCEXProtocol.h:133
-
DCCEXProtocolDelegate::receivedRosterList
virtual void receivedRosterList()
Notify when the roster list is received.
Definition: DCCEXProtocol.h:140
-
DCCEXProtocolDelegate::receivedTurnoutAction
virtual void receivedTurnoutAction(int turnoutId, bool thrown)
Notify when a turnout state change is received.
Definition: DCCEXProtocol.h:173
-
DCCEXProtocolDelegate::receivedMessage
virtual void receivedMessage(char *message)
Notify when a broadcast message has been received.
Definition: DCCEXProtocol.h:137
-
DCCEXProtocolDelegate::receivedTrackType
virtual void receivedTrackType(char track, TrackManagerMode type, int address)
Notify when a track type change is received.
Definition: DCCEXProtocol.h:168
-
DCCEXProtocolDelegate::receivedScreenUpdate
virtual void receivedScreenUpdate(int screen, int row, char *message)
Notify when a screen update is received.
Definition: DCCEXProtocol.h:189
-
DCCEXProtocolDelegate::receivedIndividualTrackPower
virtual void receivedIndividualTrackPower(TrackPower state, int track)
Notify when an individual track power state change is received.
Definition: DCCEXProtocol.h:162
-
DCCEXProtocolDelegate::receivedLocoUpdate
virtual void receivedLocoUpdate(Loco *loco)
Notify when an update to a Loco object is received.
Definition: DCCEXProtocol.h:153
-
DCCEXProtocolDelegate::receivedTurntableList
virtual void receivedTurntableList()
Notify when the turntable list is received.
Definition: DCCEXProtocol.h:149
-
DCCEXProtocolDelegate::receivedRouteList
virtual void receivedRouteList()
Notify when the route list is received.
Definition: DCCEXProtocol.h:146
-
DCCEXProtocolDelegate::receivedReadLoco
virtual void receivedReadLoco(int address)
Notify when a loco address is read from the programming track.
Definition: DCCEXProtocol.h:183
-
DCCEXProtocolDelegate::receivedTurnoutList
virtual void receivedTurnoutList()
Notify when the turnout list is received.
Definition: DCCEXProtocol.h:143
-
DCCEXProtocolDelegate::receivedTurntableAction
virtual void receivedTurntableAction(int turntableId, int position, bool moving)
Notify when a turntable index change is received.
Definition: DCCEXProtocol.h:179
-
DCCEXProtocolDelegate::receivedTrackPower
virtual void receivedTrackPower(TrackPower state)
Notify when the global track power state change is received.
Definition: DCCEXProtocol.h:157
-
DCCEXProtocol
Main class for the DCCEXProtocol library.
Definition: DCCEXProtocol.h:193
+
DCCEXProtocolDelegate
Delegate responses and broadcast events to the client software to enable custom event handlers.
Definition: DCCEXProtocol.h:128
+
DCCEXProtocolDelegate::receivedServerVersion
virtual void receivedServerVersion(int major, int minor, int patch)
Notify when the server version has been received.
Definition: DCCEXProtocol.h:134
+
DCCEXProtocolDelegate::receivedRosterList
virtual void receivedRosterList()
Notify when the roster list is received.
Definition: DCCEXProtocol.h:141
+
DCCEXProtocolDelegate::receivedTurnoutAction
virtual void receivedTurnoutAction(int turnoutId, bool thrown)
Notify when a turnout state change is received.
Definition: DCCEXProtocol.h:174
+
DCCEXProtocolDelegate::receivedMessage
virtual void receivedMessage(char *message)
Notify when a broadcast message has been received.
Definition: DCCEXProtocol.h:138
+
DCCEXProtocolDelegate::receivedTrackType
virtual void receivedTrackType(char track, TrackManagerMode type, int address)
Notify when a track type change is received.
Definition: DCCEXProtocol.h:169
+
DCCEXProtocolDelegate::receivedScreenUpdate
virtual void receivedScreenUpdate(int screen, int row, char *message)
Notify when a screen update is received.
Definition: DCCEXProtocol.h:190
+
DCCEXProtocolDelegate::receivedIndividualTrackPower
virtual void receivedIndividualTrackPower(TrackPower state, int track)
Notify when an individual track power state change is received.
Definition: DCCEXProtocol.h:163
+
DCCEXProtocolDelegate::receivedLocoUpdate
virtual void receivedLocoUpdate(Loco *loco)
Notify when an update to a Loco object is received.
Definition: DCCEXProtocol.h:154
+
DCCEXProtocolDelegate::receivedTurntableList
virtual void receivedTurntableList()
Notify when the turntable list is received.
Definition: DCCEXProtocol.h:150
+
DCCEXProtocolDelegate::receivedRouteList
virtual void receivedRouteList()
Notify when the route list is received.
Definition: DCCEXProtocol.h:147
+
DCCEXProtocolDelegate::receivedReadLoco
virtual void receivedReadLoco(int address)
Notify when a loco address is read from the programming track.
Definition: DCCEXProtocol.h:184
+
DCCEXProtocolDelegate::receivedTurnoutList
virtual void receivedTurnoutList()
Notify when the turnout list is received.
Definition: DCCEXProtocol.h:144
+
DCCEXProtocolDelegate::receivedTurntableAction
virtual void receivedTurntableAction(int turntableId, int position, bool moving)
Notify when a turntable index change is received.
Definition: DCCEXProtocol.h:180
+
DCCEXProtocolDelegate::receivedTrackPower
virtual void receivedTrackPower(TrackPower state)
Notify when the global track power state change is received.
Definition: DCCEXProtocol.h:158
+
DCCEXProtocol
Main class for the DCCEXProtocol library.
Definition: DCCEXProtocol.h:194
DCCEXProtocol::setThrottle
void setThrottle(Loco *loco, int speed, Direction direction)
Set the provided loco to the specified speed and direction.
Definition: DCCEXProtocol.cpp:178
DCCEXProtocol::getMinorVersion
int getMinorVersion()
Retrieve the minor version of EX-Commandstation.
Definition: DCCEXProtocol.cpp:170
DCCEXProtocol::receivedTurntableList
bool receivedTurntableList()
Check if turntable list has been received.
Definition: DCCEXProtocol.cpp:381
@@ -460,18 +461,18 @@
DCCEXProtocol::connect
void connect(Stream *stream)
Connect the stream object to interact with DCC-EX.
Definition: DCCEXProtocol.cpp:79
DCCEXProtocol::startRoute
void startRoute(int routeId)
Start a route/automation.
Definition: DCCEXProtocol.cpp:350
DCCEXProtocol::getLastServerResponseTime
unsigned long getLastServerResponseTime()
Retrieve the last time the server responded.
Definition: DCCEXProtocol.cpp:174
-
DCCEXProtocol::routes
Route * routes
Linked list of Route objects to form the list of routes and automations.
Definition: DCCEXProtocol.h:449
+
DCCEXProtocol::routes
Route * routes
Linked list of Route objects to form the list of routes and automations.
Definition: DCCEXProtocol.h:450
DCCEXProtocol::receivedRouteList
bool receivedRouteList()
Check if route list has been received.
Definition: DCCEXProtocol.cpp:348
DCCEXProtocol::receivedTurnoutList
bool receivedTurnoutList()
Check if turnout list has been received.
Definition: DCCEXProtocol.cpp:307
DCCEXProtocol::getTurntableCount
int getTurntableCount()
Get the number of turntable entries.
Definition: DCCEXProtocol.cpp:379
DCCEXProtocol::rotateTurntable
void rotateTurntable(int turntableId, int position, int activity=0)
Rotate a turntable object.
Definition: DCCEXProtocol.cpp:392
DCCEXProtocol::receivedRoster
bool receivedRoster()
Check if roster has been received.
Definition: DCCEXProtocol.cpp:289
DCCEXProtocol::~DCCEXProtocol
~DCCEXProtocol()
Destructor for the DCCEXProtocol object.
Definition: DCCEXProtocol.cpp:65
-
DCCEXProtocol::roster
Loco * roster
Linked list of Loco objects to form the roster.
Definition: DCCEXProtocol.h:443
+
DCCEXProtocol::roster
Loco * roster
Linked list of Loco objects to form the roster.
Definition: DCCEXProtocol.h:444
DCCEXProtocol::powerTrackOff
void powerTrackOff(char track)
Turn power off for the specified track.
Definition: DCCEXProtocol.cpp:434
DCCEXProtocol::deactivateAccessory
void deactivateAccessory(int accessoryAddress, int accessorySubAddr)
Deactivate DCC accessory at the specified address and subaddress.
Definition: DCCEXProtocol.cpp:477
DCCEXProtocol::getNumberSupportedLocos
void getNumberSupportedLocos()
Request the number of supported cabs(locos)
Definition: DCCEXProtocol.cpp:504
-
DCCEXProtocol::turntables
Turntable * turntables
Linked list of Turntable objects to form the list of turntables.
Definition: DCCEXProtocol.h:452
+
DCCEXProtocol::turntables
Turntable * turntables
Linked list of Turntable objects to form the list of turntables.
Definition: DCCEXProtocol.h:453
DCCEXProtocol::functionOn
void functionOn(Loco *loco, int function)
Turn the specified function on for the provided loco.
Definition: DCCEXProtocol.cpp:201
DCCEXProtocol::getRouteCount
int getRouteCount()
Get the number of route entries.
Definition: DCCEXProtocol.cpp:346
DCCEXProtocol::setTrackType
void setTrackType(char track, TrackManagerMode type, int address)
set track type for the specified track
Definition: DCCEXProtocol.cpp:441
@@ -488,7 +489,7 @@
DCCEXProtocol::getTurntableById
Turntable * getTurntableById(int turntableId)
Retrieve a turntable object by its ID.
Definition: DCCEXProtocol.cpp:383
DCCEXProtocol::powerOn
void powerOn()
Global track power on command.
Definition: DCCEXProtocol.cpp:413
DCCEXProtocol::getTurnoutById
Turnout * getTurnoutById(int turnoutId)
Retrieve a turnout/point object by its ID.
Definition: DCCEXProtocol.cpp:310
-
DCCEXProtocol::turnouts
Turnout * turnouts
Linked list of Turnout objects to form the turnout list.
Definition: DCCEXProtocol.h:446
+
DCCEXProtocol::turnouts
Turnout * turnouts
Linked list of Turnout objects to form the turnout list.
Definition: DCCEXProtocol.h:447
DCCEXProtocol::pauseRoutes
void pauseRoutes()
Pause all routes/automations.
Definition: DCCEXProtocol.cpp:359
DCCEXProtocol::getTurnoutCount
int getTurnoutCount()
Get the number of turnouts.
Definition: DCCEXProtocol.cpp:305
DCCEXProtocol::setLogStream
void setLogStream(Stream *console)
Set the stream object for console output.
Definition: DCCEXProtocol.cpp:77
@@ -502,14 +503,14 @@
DCCEXProtocol::check
void check()
Check for incoming DCC-EX broadcasts/responses and parse them.
Definition: DCCEXProtocol.cpp:90
DCCEXProtocol::emergencyStop
void emergencyStop()
Initiate an emergency stop.
Definition: DCCEXProtocol.cpp:276
Loco
Class for a Loco object representing a DCC addressed locomotive.
Definition: DCCEXLoco.h:54
-
NullStream
Nullstream class for initial DCCEXProtocol instantiation to direct streams to nothing.
Definition: DCCEXProtocol.h:94
-
NullStream::write
size_t write(uint8_t c)
Dummy write method for single int.
Definition: DCCEXProtocol.h:117
-
NullStream::peek
int peek()
Dummy peek method.
Definition: DCCEXProtocol.h:108
-
NullStream::available
int available()
Dummy availability check.
Definition: DCCEXProtocol.h:101
-
NullStream::flush
void flush()
Dummy flush method.
Definition: DCCEXProtocol.h:104
-
NullStream::NullStream
NullStream()
Constructor for the NullStream object.
Definition: DCCEXProtocol.h:97
-
NullStream::read
int read()
Dummy read method.
Definition: DCCEXProtocol.h:112
-
NullStream::write
size_t write(const uint8_t *buffer, size_t size)
Dummy write method for buffered input.
Definition: DCCEXProtocol.h:123
+
NullStream
Nullstream class for initial DCCEXProtocol instantiation to direct streams to nothing.
Definition: DCCEXProtocol.h:95
+
NullStream::write
size_t write(uint8_t c)
Dummy write method for single int.
Definition: DCCEXProtocol.h:118
+
NullStream::peek
int peek()
Dummy peek method.
Definition: DCCEXProtocol.h:109
+
NullStream::available
int available()
Dummy availability check.
Definition: DCCEXProtocol.h:102
+
NullStream::flush
void flush()
Dummy flush method.
Definition: DCCEXProtocol.h:105
+
NullStream::NullStream
NullStream()
Constructor for the NullStream object.
Definition: DCCEXProtocol.h:98
+
NullStream::read
int read()
Dummy read method.
Definition: DCCEXProtocol.h:113
+
NullStream::write
size_t write(const uint8_t *buffer, size_t size)
Dummy write method for buffered input.
Definition: DCCEXProtocol.h:124
Route
Class to contain and maintain the various Route attributes and methods.
Definition: DCCEXRoutes.h:40
Turnout
Class to contain and maintain the various Turnout/Point attributes and methods.
Definition: DCCEXTurnouts.h:35
Turntable
Class to contain and maintain the various Turntable attributes and methods.
Definition: DCCEXTurntables.h:82