Library
-
class Consist
- #include <DCCEXLoco.h>
Class to create a software consist of one or more ConsistLoco objects.
Public Functions
-
Consist()
Constructor.
-
void setName(const char *name)
Set consist name.
- Parameters:
name – Name to set for the consist
-
const char *getName()
Get consist name.
- Returns:
Current name of the consist
-
void addLoco(Loco *loco, Facing facing)
Add a loco to the consist using a Loco object.
- Parameters:
loco – Pointer to a loco object
facing – Direction the loco is facing (FacingForward|FacingReversed)
-
void addLoco(int address, Facing facing)
Add a loco to the consist using a DCC address.
- Parameters:
address – DCC address of the loco to add
facing – Direction the loco is facing (FacingForward|FacingReversed)
-
void removeLoco(Loco *loco)
Remove a loco from the consist - Loco objects with LocoSourceEntry will also be deleted.
- Parameters:
loco – Pointer to a loco object to remove
-
void removeAllLocos()
Remove all locos from a consist - Loco objects with LocoSourceEntry will also be deleted.
-
void setLocoFacing(Loco *loco, Facing facing)
Update the direction of a loco in the consist.
- Parameters:
loco – Pointer to the loco object to update
facing – Direction to set it to (FacingForward|FacingReversed)
-
int getLocoCount()
Get the count of locos in the consist.
- Returns:
Count of locos
-
bool inConsist(Loco *loco)
Check if the provided loco is in the consist.
- Parameters:
loco – Pointer to the loco object to check
- Returns:
true|false
-
bool inConsist(int address)
Check if the loco with the provided address is in the consist.
- Parameters:
address – DCC address of loco to check
- Returns:
true|false
-
int getSpeed()
Get consist speed - obtained from first linked loco.
- Returns:
Current speed (0 - 126)
-
Direction getDirection()
Get consist direction - obtained from first linked loco.
- Returns:
Current direction (Forward|Reverse)
-
ConsistLoco *getFirst()
Get the first loco in the consist.
- Returns:
Pointer to the first ConsistLoco object
-
ConsistLoco *getByAddress(int address)
Get the loco in the consist with the specified address.
- Parameters:
address – DCC address of loco to retrieve
- Returns:
Pointer to the first ConsistLoco object
Private Functions
-
void _addLocoToConsist(ConsistLoco *consistLoco)
-
Consist()
-
class ConsistLoco
- #include <DCCEXLoco.h>
Class to add an additional attribute to a Loco object to specify the direction it is facing in a consist.
Public Functions
-
ConsistLoco(Loco *loco, Facing facing)
Constructor.
- Parameters:
loco – Pointer to the Loco object to add
facing – Direction loco is facing in the consist (FacingForward|FacingReversed)
-
Loco *getLoco()
Get the associated Loco object for this consist entry.
- Returns:
Pointer to the Loco object
-
void setFacing(Facing facing)
Set which way the loco is facing in the consist (FacingForward, FacingReversed)
- Parameters:
facing – FacingForward|FacingReversed
-
Facing getFacing()
Get which way the loco is facing in the consist (FacingForward, FacingReversed)
- Returns:
FacingForward|FacingReversed
-
ConsistLoco *getNext()
Get the next consist loco object.
- Returns:
Pointer to the next ConsistLoco object
-
void setNext(ConsistLoco *consistLoco)
Set the next consist loco object.
- Parameters:
consistLoco – Pointer to the ConsistLoco object
-
~ConsistLoco()
Destructor for a ConsistLoco.
Friends
- friend class Consist
-
ConsistLoco(Loco *loco, Facing facing)
-
class DCCEXInbound
- #include <DCCEXInbound.h>
Inbound DCC-EX command parser class to parse commands and provide interpreted parameters.
Public Static Functions
-
static void setup(int16_t maxParameterValues)
Setup parser once with enough space to handle the maximum number of parameters expected from the command station.
- Parameters:
maxParameterValues – Maximum parameter values to accommodate
-
static void cleanup()
Cleanup parser.
-
static bool parse(char *command)
Pass in a command string to parse.
- Parameters:
command – Char array of command to parse
- Returns:
True if parsed ok, false if badly terminated command or too many parameters
-
static byte getOpcode()
Gets the DCC-EX OPCODE of the parsed command (the first char after the <)
-
static int16_t getParameterCount()
Gets number of parameters detected after OPCODE <JR 1 2 3> is 4 parameters!
- Returns:
Number of parameters
-
static int32_t getNumber(int16_t parameterNumber)
Gets a numeric parameter (or hashed keyword) from parsed command.
- Returns:
The numeric parameter
-
static bool isTextParameter(int16_t parameterNumber)
Checks if a parameter is actually text rather than numeric.
- Parameters:
parameterNumber – The number of the parameter to check
- Returns:
true|false
-
static char *getTextParameter(int16_t parameterNumber)
Gets address of text type parameter. does not create permanent copy.
- Parameters:
parameterNumber – The number of the parameter to retrieve
- Returns:
Char array of text (use once and discard)
-
static char *copyTextParameter(int16_t parameterNumber)
gets address of a heap copy of text type parameter.
- Parameters:
parameterNumber –
- Returns:
-
static void dump(Print*)
dump list of parameters obtained
- Parameters:
out – Address of output e.g. &Serial
Private Static Functions
-
static bool _isTextInternal(int16_t n)
-
static void setup(int16_t maxParameterValues)
-
class DCCEXProtocol
- #include <DCCEXProtocol.h>
Main class for the DCCEXProtocol library.
Public Functions
-
DCCEXProtocol(int maxCmdBuffer = 500, int maxCommandParams = 50)
Constructor for the DCCEXProtocol object.
- Parameters:
maxCmdBuffer – Optional - maximum number of bytes for the command buffer (default 500)
maxCommandParams – Optional - maximum number of parameters to parse via the DCCEXInbound parser (default 50)
-
~DCCEXProtocol()
Destructor for the DCCEXProtocol object.
-
void setDelegate(DCCEXProtocolDelegate *delegate)
Set the delegate object for callbacks.
- Parameters:
delegate –
-
void setLogStream(Stream *console)
Set the stream object for console output.
- Parameters:
console –
-
void enableHeartbeat(unsigned long heartbeatDelay = 60000)
Enable heartbeat if required - can help WiFi connections that drop out.
- Parameters:
heartbeatDelay – Time in milliseconds between heartbeats - defaults to one minute (60000ms)
-
void connect(Stream *stream)
Connect the stream object to interact with DCC-EX.
- Parameters:
stream –
-
void disconnect()
Disconnect from DCC-EX.
-
void check()
Check for incoming DCC-EX broadcasts/responses and parse them.
-
void sendCommand(char *cmd)
allows sending of an arbitray command
- Parameters:
cmd – Command to send
-
void getLists(bool rosterRequired, bool turnoutListRequired, bool routeListRequired, bool turntableListRequired)
Request DCC-EX object lists (Roster, Turnouts, Routes, Turntables)
- Parameters:
rosterRequired – Request the roster list (true|false)
turnoutListRequired – Request the turnout list (true|false)
routeListRequired – Request the route list (true|false)
turntableListRequired – Request the turntable list (true|false)
-
bool receivedLists()
Check if all lists have been received (roster, routes, turnouts, turntables)
- Returns:
true|false
-
void requestServerVersion()
Request server version information.
-
bool receivedVersion()
Check if server version has been received.
- Returns:
-
int getMajorVersion()
Retrieve the major version of EX-CommandStation.
- Returns:
Major version number eg. 5.y.z
-
int getMinorVersion()
Retrieve the minor version of EX-Commandstation.
- Returns:
Minor version number eg. x.0.z
-
int getPatchVersion()
Retreive the patch version of EX-CommandStation.
- Returns:
Patch version number eg. x.y.7
-
unsigned long getLastServerResponseTime()
Retrieve the last time the server responded.
- Returns:
Last response time in milliseconds (from millis())
-
void clearAllLists()
Clear roster, turnout, turntable, and route lists.
-
void refreshAllLists()
Clear roster, turnout, turntable, and route lists and request new ones.
-
void setThrottle(Loco *loco, int speed, Direction direction)
Set the provided loco to the specified speed and direction.
- Parameters:
loco – Pointer to a Loco object
speed – Speed (0 - 126)
direction – Direction (Forward|Reverse)
-
void setThrottle(Consist *consist, int speed, Direction direction)
Set all locos in the provided consist to the specified speed and direction.
- Parameters:
consist – Pointer to a consist object
speed – Speed (0 - 126)
direction – Direction (Forward|Reverse) - reverse facing locos will be adjusted automatically
-
void functionOn(Loco *loco, int function)
Turn the specified function on for the provided loco.
- Parameters:
loco – Pointer to a loco object
function – Function number (0 - 27)
-
void functionOff(Loco *loco, int function)
Turn the specified function off for the provided loco.
- Parameters:
loco – Pointer to a loco object
function – Function number (0 - 27)
-
bool isFunctionOn(Loco *loco, int function)
Test if the specified function for the provided loco is on.
- Parameters:
loco – Pointer to a loco object
function – Function number to test (0 - 27)
- Returns:
true = on, false = off
-
void functionOn(Consist *consist, int function)
Turn the specified function on for the provided consist.
- Parameters:
consist – Pointer to a consist object
function – Function number (0 - 27)
-
void functionOff(Consist *consist, int function)
Turn the specified function off for the provided consist.
- Parameters:
consist – Pointer to a consist object
function – Function number (0 - 27)
-
bool isFunctionOn(Consist *consist, int function)
Test if the specified function for the provided consist is on (Checks first loco)
- Parameters:
consist – Pointer to a consist object
function – Function number to test (0 - 27)
- Returns:
true = on, false = off
-
void requestLocoUpdate(int address)
Explicitly request an update for the specified loco.
- Parameters:
address – DCC address of the loco
-
void readLoco()
Initiate reading a loco address from the programming track, response will be a delegate notification.
-
void emergencyStop()
Initiate an emergency stop.
-
int getRosterCount()
Get the number of roster entries.
- Returns:
Number of roster entries received
-
bool receivedRoster()
Check if roster has been received.
- Returns:
true|false
-
Loco *findLocoInRoster(int address)
Search for the specified DCC address in the roster.
- Parameters:
address – DCC address to search for
- Returns:
Pointer to the Loco object
-
void clearRoster()
Clear the roster.
-
void refreshRoster()
Clear the roster and request again.
-
int getTurnoutCount()
Get the number of turnouts.
- Returns:
Number of turnouts received
-
bool receivedTurnoutList()
Check if turnout list has been received.
- Returns:
true|false
-
Turnout *getTurnoutById(int turnoutId)
Retrieve a turnout/point object by its ID.
- Parameters:
turnoutId – ID of the turnout/point
- Returns:
The turnout/point object
-
void closeTurnout(int turnoutId)
Close the specified turnout/point.
- Parameters:
turnoutId – ID of the turnout/point
-
void throwTurnout(int turnoutId)
Throw the specified turnout/point.
- Parameters:
turnoutId – ID of the turnout/point
-
void toggleTurnout(int turnoutId)
Toggle the specified turnout/point (if closed, will throw, and vice versa)
- Parameters:
turnoutId – ID of the turnout/point
-
void clearTurnoutList()
Clear the list of turnouts.
-
void refreshTurnoutList()
Clear the list of turnouts and request again.
-
int getRouteCount()
Get the number of route entries.
- Returns:
Number of routes received
-
bool receivedRouteList()
Check if route list has been received.
- Returns:
true|false
-
void startRoute(int routeId)
Start a route/automation.
- Parameters:
routeId – ID of the route/automation to start
-
void pauseRoutes()
Pause all routes/automations.
-
void resumeRoutes()
Resume all routes/automations.
-
void clearRouteList()
Clear all routes.
-
void refreshRouteList()
Clear all routes and request a new list.
-
int getTurntableCount()
Get the number of turntable entries.
- Returns:
Number of turntables received
-
bool receivedTurntableList()
Check if turntable list has been received.
- Returns:
true|false
-
Turntable *getTurntableById(int turntableId)
Retrieve a turntable object by its ID.
- Parameters:
turntableId – ID of the turntable
- Returns:
The turntable object
-
void rotateTurntable(int turntableId, int position, int activity = 0)
Rotate a turntable object.
- Parameters:
turntableId – ID of the turntable
position – Position index to rotate to
activity – Optional activity for EX-Turntable objects only
-
void clearTurntableList()
Clear all turntables.
-
void refreshTurntableList()
Clear all turntables and request a new list.
-
void powerOn()
Global track power on command.
-
void powerOff()
Global track power off command.
-
void powerTrackOn(char track)
Turn power on for the specified track.
- Parameters:
track – Track name (A - H)
-
void powerTrackOff(char track)
Turn power off for the specified track.
- Parameters:
track – Track name (A - H)
-
void setTrackType(char track, TrackManagerMode type, int address)
set track type for the specified track
- Parameters:
track – Track name (A - H)
type – Track type (MAIN, PROG, DC, DCX, NONE)
address – dcc address for DC and DCX (Required, but ignored if not DC or DCX)
-
void activateAccessory(int accessoryAddress, int accessorySubAddr)
Activate DCC accessory at the specified address and subaddress.
- Parameters:
accessoryAddress – Address of the DCC accessory
accessorySubAddr – Subaddress of the DCC accessory
-
void deactivateAccessory(int accessoryAddress, int accessorySubAddr)
Deactivate DCC accessory at the specified address and subaddress.
- Parameters:
accessoryAddress – Address of the DCC accessory
accessorySubAddr – Subaddress of the DCC accessory
-
void activateLinearAccessory(int linearAddress)
Activate DCC accessory at the specified linear address.
- Parameters:
linearAddress – Linear address of the DCC accessory
-
void deactivateLinearAccessory(int linearAddress)
Deactivate DCC accessory at the specified linear address.
- Parameters:
linearAddress – Linear address of the DCC accessory
-
void getNumberSupportedLocos()
Request the number of supported cabs(locos)
Public Members
Private Functions
-
void _init()
-
void _sendCommand()
-
void _processCommand()
-
void _processServerDescription()
-
void _processMessage()
-
void _processScreenUpdate()
-
void _sendHeartbeat()
-
void _processLocoBroadcast()
-
int _getValidFunctionMap(int functionMap)
-
int _getSpeedFromSpeedByte(int speedByte)
-
void _processReadResponse()
-
void _getRoster()
-
bool _requestedRoster()
-
void _processRosterList()
-
void _requestRosterEntry(int address)
-
void _processRosterEntry()
-
void _getTurnouts()
-
bool _requestedTurnouts()
-
void _processTurnoutList()
-
void _requestTurnoutEntry(int id)
-
void _processTurnoutEntry()
-
void _processTurnoutBroadcast()
-
void _getRoutes()
-
bool _requestedRoutes()
-
void _processRouteList()
-
void _requestRouteEntry(int id)
-
void _processRouteEntry()
-
void _getTurntables()
-
bool _requestedTurntables()
-
void _processTurntableList()
-
void _requestTurntableEntry(int id)
-
void _processTurntableEntry()
-
void _requestTurntableIndexEntry(int id)
-
void _processTurntableIndexEntry()
-
void _processTurntableBroadcast()
-
void _processTrackPower()
-
void _processTrackType()
Private Members
-
int _rosterCount = 0
-
int _turnoutCount = 0
-
int _routeCount = 0
-
int _turntableCount = 0
-
int _version[3] = {}
-
Stream *_stream
-
Stream *_console
-
NullStream _nullStream
-
int _bufflen
-
int _maxCmdBuffer
-
char *_cmdBuffer
-
char _outboundCommand[MAX_OUTBOUND_COMMAND_LENGTH]
-
DCCEXProtocolDelegate *_delegate = nullptr
-
unsigned long _lastServerResponseTime
-
char _inputBuffer[512]
-
int _nextChar
-
bool _receivedVersion = false
-
bool _receivedLists = false
-
bool _rosterRequested = false
-
bool _receivedRoster = false
-
bool _turnoutListRequested = false
-
bool _receivedTurnoutList = false
-
bool _routeListRequested = false
-
bool _receivedRouteList = false
-
bool _turntableListRequested = false
-
bool _receivedTurntableList = false
-
bool _enableHeartbeat
-
unsigned long _heartbeatDelay
-
unsigned long _lastHeartbeat
-
DCCEXProtocol(int maxCmdBuffer = 500, int maxCommandParams = 50)
-
class DCCEXProtocolDelegate
- #include <DCCEXProtocol.h>
Delegate responses and broadcast events to the client software to enable custom event handlers.
Public Functions
-
inline virtual void receivedServerVersion(int major, int minor, int patch)
Notify when the server version has been received.
- Parameters:
major – Major version of EX-CommandStation (eg. 5.0.7 returns 5)
minor – Minor version of EX-CommandStation (eg. 5.0.7 returns 0)
patch – Patch version of EX-CommandStation (eg. 5.0.7 returns 7)
-
inline virtual void receivedMessage(char *message)
Notify when a broadcast message has been received.
- Parameters:
message – message that has been broadcast
-
inline virtual void receivedRosterList()
Notify when the roster list is received.
-
inline virtual void receivedTurnoutList()
Notify when the turnout list is received.
-
inline virtual void receivedRouteList()
Notify when the route list is received.
-
inline virtual void receivedTurntableList()
Notify when the turntable list is received.
-
inline virtual void receivedLocoUpdate(Loco *loco)
Notify when an update to a Loco object is received.
- Parameters:
loco – Pointer to the loco object
-
inline virtual void receivedTrackPower(TrackPower state)
Notify when the global track power state change is received.
- Parameters:
state – Power state received (PowerOff|PowerOn|PowerUnknown)
-
inline virtual void receivedIndividualTrackPower(TrackPower state, int track)
Notify when an individual track power state change is received.
- Parameters:
state – Power state received (PowerOff|PowerOn|PowerUnknown)
track – which track changed 65=A..72=H | 2698315=MAIN | 2788330=PROG | 2183=DC | 71999=DCX
-
inline virtual void receivedTrackType(char track, TrackManagerMode type, int address)
Notify when a track type change is received.
- Parameters:
track – track that changed
type – type received (MAIN|PROG|DC|DCX|NONE)
address – address received for DC and DCX (zero if other types)
-
inline virtual void receivedTurnoutAction(int turnoutId, bool thrown)
Notify when a turnout state change is received.
- Parameters:
turnoutId – ID of the turnout
thrown – Wether it is thrown or not (true|false)
-
inline virtual void receivedTurntableAction(int turntableId, int position, bool moving)
Notify when a turntable index change is received.
- Parameters:
turntableId – ID of the turntable
position – Index of the position it is moving (or has moved) to
moving – Whether it is moving or not (true|false)
-
inline virtual void receivedReadLoco(int address)
Notify when a loco address is read from the programming track.
- Parameters:
address – DCC address read from the programming track, or -1 for a failure to read
-
inline virtual void receivedScreenUpdate(int screen, int row, char *message)
Notify when a screen update is received.
- Parameters:
screen – Screen number
row – Row number
message – Message to display on the screen/row
-
inline virtual void receivedServerVersion(int major, int minor, int patch)
-
class Loco
- #include <DCCEXLoco.h>
Class for a Loco object representing a DCC addressed locomotive.
Public Functions
-
Loco(int address, LocoSource source)
Constructor.
- Parameters:
address – DCC address of loco
source – LocoSourceRoster (from roster) or LocoSourceEntry (from user input)
-
int getAddress()
Get loco address.
- Returns:
DCC address of loco
-
void setName(const char *name)
Set loco name.
- Parameters:
name – Name of the loco
-
const char *getName()
Get loco name.
- Returns:
Name of the loco
-
void setSpeed(int speed)
Set loco speed.
- Parameters:
speed – Valid speed (0 - 126)
-
int getSpeed()
Get loco speed.
- Returns:
Speed (0 - 126)
-
void setDirection(Direction direction)
Set loco direction (enums Forward, Reverse)
- Parameters:
direction – Direction to set (Forward|Reverse)
-
Direction getDirection()
Get loco direction (enums Forward, Reverse)
- Returns:
Current direction (Forward|Reverse)
-
LocoSource getSource()
Get loco source (enums LocoSourceRoster, LocoSourceEntry)
- Returns:
Source of loco (LocoSourceRoster|LocoSourceEntry)
-
void setupFunctions(const char *functionNames)
Setup functions for the loco.
- Parameters:
functionNames – Char array of function names
-
bool isFunctionOn(int function)
Test if function is on.
- Parameters:
function – Number of the function to test
- Returns:
true|false
-
void setFunctionStates(int functionStates)
Set function states.
- Parameters:
functionStates – Integer representing all function states
-
int getFunctionStates()
Get function states.
- Returns:
Integer representing current function states
-
const char *getFunctionName(int function)
Get the name/label for a function.
- Parameters:
function – Number of the function to return the name/label of
- Returns:
char* representing the function name/label
-
bool isFunctionMomentary(int function)
Get the name/label for a function.
- Parameters:
function – Number of the function to return the name/label of
- Returns:
char* representing the function name/label
Public Static Functions
-
static Loco *getByAddress(int address)
Get Loco object by its DCC address.
- Parameters:
address – DCC address of the loco to get
- Returns:
Loco object or nullptr if it doesn’t exist
-
static void clearRoster()
Clear all Locos from the roster.
Private Members
-
int _address
-
char *_name
-
int _speed
-
LocoSource _source
-
char *_functionNames[MAX_FUNCTIONS]
-
int32_t _functionStates
-
int32_t _momentaryFlags
Private Static Functions
Friends
- friend class Consist
-
Loco(int address, LocoSource source)
-
class NullStream : public Stream
- #include <DCCEXProtocol.h>
Nullstream class for initial DCCEXProtocol instantiation to direct streams to nothing.
Public Functions
-
inline NullStream()
Constructor for the NullStream object.
-
inline int available()
Dummy availability check.
- Returns:
Returns false (0) always
-
inline void flush()
Dummy flush method.
-
inline int peek()
Dummy peek method.
- Returns:
Returns -1 always
-
inline int read()
Dummy read method.
- Returns:
Returns -1 always
-
inline size_t write(uint8_t c)
Dummy write method for single int.
- Parameters:
c – Number received
- Returns:
Returns 1 always
-
inline size_t write(const uint8_t *buffer, size_t size)
Dummy write method for buffered input.
- Parameters:
buffer – Buffer received
size – Size of buffer
- Returns:
Returns size of buffer always
-
inline NullStream()
-
class Route
- #include <DCCEXRoutes.h>
Class to contain and maintain the various Route attributes and methods.
Public Functions
-
int getId()
Get route ID.
- Returns:
ID of the route
-
void setName(const char *name)
Set route name.
- Parameters:
name – Name to set for the route
-
const char *getName()
Get route name.
- Returns:
Current name of the route
-
void setType(RouteType type)
Set route type (A automation, R route)
- Parameters:
type – RouteType - RouteTypeAutomation|RouteTypeRoute
-
RouteType getType()
Get route type (A automation, R route)
- Returns:
RouteTypeAutomation|RouteTypeRoute
-
void setNext(Route *route)
Set the next route in the list.
- Parameters:
route – Pointer to the next route
-
~Route()
Destructor for a route.
Public Static Functions
-
static Route *getById(int id)
Get route object by its ID.
- Returns:
Pointer to the Route, or nullptr if not found
-
static void clearRouteList()
Clear the list of routes.
Private Functions
-
int getId()
-
class Turnout
- #include <DCCEXTurnouts.h>
Class to contain and maintain the various Turnout/Point attributes and methods.
Public Functions
-
Turnout(int id, bool thrown)
Constructor for a Turnout object.
- Parameters:
id – Turnout ID
thrown – true (thrown)|false (closed)
-
void setThrown(bool thrown)
Set thrown state (true thrown, false closed)
- Parameters:
thrown – true|false
-
void setName(const char *_name)
Set turnout name.
- Parameters:
_name – Name to set the turnout
-
int getId()
Get turnout Id.
- Returns:
ID of the turnout
-
const char *getName()
Get turnout name.
- Returns:
Current name of the turnout
-
bool getThrown()
Get thrown state (true thrown, false closed)
- Returns:
true|false
Public Static Functions
-
static Turnout *getById(int id)
Get turnout object by turnout ID.
- Parameters:
id – ID of the turnout to retrieve
- Returns:
Pointer to the turnout object or nullptr if not found
-
static void clearTurnoutList()
Clear the list of turnouts.
Private Functions
-
Turnout(int id, bool thrown)
-
class Turntable
- #include <DCCEXTurntables.h>
Class to contain and maintain the various Turntable attributes and methods.
Public Functions
-
Turntable(int id)
Constructor.
- Parameters:
id – ID of the turntable
-
int getId()
Get turntable ID.
- Returns:
ID of the turntable
-
void setType(TurntableType type)
Set turntable type.
- Parameters:
type – TurntableTypeDCC|TurntableTypeEXTT|TurntableTypeUnknown
-
TurntableType getType()
Get turntable type.
- Returns:
TurntableTypeDCC|TurntableTypeEXTT|TurntableTypeUnknown
-
void setIndex(int index)
Set the current index for the turntable.
- Parameters:
index – ID of the index to set
-
int getIndex()
Get the current index for the turntable.
- Returns:
ID of the current index
-
void setNumberOfIndexes(int numberOfIndexes)
Set the number of indexes the turntable has defined (from the <JT id> command response)
- Parameters:
numberOfIndexes – Count of the indexes defined for the turntable including home
-
int getNumberOfIndexes()
Get the number of indexes defined for the turntable.
- Returns:
Count of the indexes defined
-
void setName(const char *name)
Set the turntable name.
- Parameters:
name – Name to set for the turntable
-
const char *getName()
Get the turntable name.
- Returns:
Current name of the turntable
-
void setMoving(bool moving)
Set the movement state (false stationary, true moving)
- Parameters:
moving – true|false
-
bool isMoving()
Get movement state (false stationary, true moving)
- Returns:
true|false
-
int getIndexCount()
Get the count of indexes added to the index list (counted from the <JP id> command response)
- Returns:
Count of indexes received for this turntable including home
-
void setNext(Turntable *turntable)
Set the next turntable in the list.
- Parameters:
turntable – Pointer to the next turntable
-
void addIndex(TurntableIndex *index)
Add a turntable index object to the index list for this turntable.
- Parameters:
index – TurntableIndex object to add
-
TurntableIndex *getFirstIndex()
Get the first associated turntable index.
- Returns:
Pointer to the first associated TurntableIndex object
-
TurntableIndex *getIndexById(int id)
Get TurntableIndex object by its ID.
- Parameters:
id – ID of the index to retrieve
- Returns:
Pointer to the TurntableIndex object or nullptr if not found
-
~Turntable()
Destructor for a turntable.
Public Static Functions
-
static Turntable *getFirst()
Get the first turntable object.
- Returns:
Pointer to the first Turntable object
-
static Turntable *getById(int id)
Get a turntable object by its ID.
- Parameters:
id – ID of the turntable to retrieve
- Returns:
Pointer to the Turntable object or nullptr if not found
-
static void clearTurntableList()
Clear the list of turntables.
Private Functions
Private Members
-
int _id
-
TurntableType _type
-
int _index
-
int _numberOfIndexes
-
char *_name
-
bool _isMoving
-
int _indexCount
-
TurntableIndex *_firstIndex
-
Turntable(int id)
-
class TurntableIndex
- #include <DCCEXTurntables.h>
Class to contain and maintain the various Turntable Index attributes and methods associated with a Turntable.
Public Functions
-
TurntableIndex(int ttId, int id, int angle, const char *name)
Constructor.
- Parameters:
ttId – ID of the turntable the index is associated with
id – ID of the index
angle – Angle from home for this index (0 - 3600)
name – Name of the index
-
int getTTId()
Get the turntable ID.
- Returns:
ID of the turntable this index is associated with
-
int getId()
Get index ID (0 is always home)
- Returns:
ID of this index
-
int getAngle()
Get angle of the index from home.
- Returns:
Angle of this index from home (0 - 3600)
-
const char *getName()
Get index name.
- Returns:
Current name of the index
-
TurntableIndex *getNextIndex()
Get next TurntableIndex object.
- Returns:
Pointer to the next TurntableIndex object
-
~TurntableIndex()
Destructor for an index.
Friends
- friend class Turntable
-
TurntableIndex(int ttId, int id, int angle, const char *name)
- file DCCEXInbound.cpp
- #include “DCCEXInbound.h”#include <Arduino.h>
Enums
- file DCCEXInbound.h
- #include <Arduino.h>
- file DCCEXLoco.cpp
- #include “DCCEXLoco.h”#include <Arduino.h>
- file DCCEXLoco.h
- #include <Arduino.h>
Defines
-
MAX_SINGLE_COMMAND_PARAM_LENGTH
Enums
-
MAX_SINGLE_COMMAND_PARAM_LENGTH
- file DCCEXProtocol.cpp
- #include “DCCEXProtocol.h”
- file DCCEXProtocol.h
- #include “DCCEXInbound.h”#include “DCCEXLoco.h”#include “DCCEXRoutes.h”#include “DCCEXTurnouts.h”#include “DCCEXTurntables.h”#include <Arduino.h>
Enums
Variables
-
const int MAX_OUTBOUND_COMMAND_LENGTH = 100
-
const int MAX_OUTBOUND_COMMAND_LENGTH = 100
- file DCCEXRoutes.cpp
- #include “DCCEXRoutes.h”#include <Arduino.h>
- file DCCEXRoutes.h
- #include <Arduino.h>
- file DCCEXTurnouts.cpp
- #include “DCCEXTurnouts.h”#include <Arduino.h>
- file DCCEXTurnouts.h
- #include <Arduino.h>
- file DCCEXTurntables.cpp
- #include “DCCEXTurntables.h”#include <Arduino.h>
- file DCCEXTurntables.h
- #include <Arduino.h>
- dir /home/runner/work/DCCEXProtocol/DCCEXProtocol/src