DCCpp
This is the library version of a program for Arduino to control railroading DCC devices.
Turnout Struct Reference

#include "Turnout.h"

Public Member Functions

void begin (int id, int add, int subAdd)
 
void set (int id, int add, int subAdd)
 
void activate (int s = 1)
 
void inactivate ()
 
bool isActivated ()
 

Static Public Member Functions

static Turnout * get (int id)
 
static void remove (int id)
 
static int count ()
 
static void load ()
 
static void store ()
 
static void parse (char *c)
 
static Turnout * create (int id, int add, int subAdd)
 

Public Attributes

struct TurnoutData data
 
Turnout * nextTurnout
 
int eepromPos
 

Static Public Attributes

static Turnout * firstTurnout = NULL
 

Detailed Description

DCC++ BASE STATION can keep track of the direction of any turnout that is controlled by a DCC stationary accessory decoder.

If the TextCommand is used, all turnouts, as well as any other DCC accessories connected in this fashion, can always be operated using the DCC BASE STATION Turnout command.

When controlled as such, the Arduino updates and stores the direction of each Turnout in EEPROM so that it is retained even without power. A list of the current directions of each Turnout in the form <H ID THROW> is generated by this sketch whenever the <s> status command is invoked. This provides an efficient way of initializing the directions of any Turnouts being monitored or controlled by a separate interface or GUI program.

Once all turnouts have been properly defined, use the <E> command to store their definitions to EEPROM. If you later make edits/additions/deletions to the turnout definitions, you must invoke the <E> command if you want those new definitions updated in the EEPROM. You can also clear everything stored in the EEPROM by invoking the <e> command.

Without TextCommand, this is a classic C++ usage. An instance of the structure is created by the user, and functions like begin() and activate() can be applied on this instance. load() and store() of the class can still be used (if USE_EEPROM is activated).

Definition at line 117 of file Turnout.h.

Member Function Documentation

void begin ( int  id,
int  add,
int  subAdd 
)

Initialize the turnout created by regular C++ instantiation.

Parameters
idThe numeric ID (0-32767) of the sensor.
addThe primary address of the decoder controlling this turnout (0-511).
subAddThe sub-address of the decoder controlling this turnout (0-3).
Remarks
Should not be used in command line mode.

Definition at line 33 of file Turnout.cpp.

void set ( int  id,
int  add,
int  subAdd 
)

Force the turnout values created by command line.

Parameters
idThe numeric ID (0-32767) of the sensor.
addThe primary address of the decoder controlling this turnout (0-511).
subAddThe sub-address of the decoder controlling this turnout (0-3).
Remarks
Should not be used in C++ mode.

Definition at line 63 of file Turnout.cpp.

void activate ( int  s = 1)

Change the activation state of the turnout.

Parameters
snew state : 0 for off, 1 for on. Default is 1.

Definition at line 72 of file Turnout.cpp.

void inactivate ( )

Inactivate the turnout.

Definition at line 140 of file Turnout.h.

bool isActivated ( )

Checks if the output is activated or not.

Returns
True if the output is activated. Otherwise false (of course...).

Definition at line 144 of file Turnout.h.

Turnout * get ( int  id)
static

Get a particular turnout.

Parameters
idThe numeric ID (0-32767) of the turnout.
Returns
The found turnout or NULL if not found.
Remarks
Only available when USE_EEPROM or USE_TEXTCOMMAND is defined.

Definition at line 99 of file Turnout.cpp.

void remove ( int  id)
static

Removes a particular turnout.

Parameters
idThe numeric ID (0-32767) of the turnout.
Remarks
Only available when USE_EEPROM or USE_TEXTCOMMAND is defined.

Definition at line 107 of file Turnout.cpp.

int count ( )
static

Get the total number of turnouts.

Returns
Number of turnouts.
Remarks
Only available when USE_EEPROM or USE_TEXTCOMMAND is defined.

Definition at line 140 of file Turnout.cpp.

void load ( )
static

Load the content of all turnouts from EEPROM.

Remarks
Only available when USE_EEPROM is defined.

Definition at line 151 of file Turnout.cpp.

void store ( )
static

Store the content of all turnouts in EEPROM.

Remarks
Only available when USE_EEPROM is defined.

Definition at line 180 of file Turnout.cpp.

void parse ( char *  c)
static

Do command according to the given command string.

Parameters
cstring to interpret... See syntax in class description.
Remarks
Only available when USE_TEXTCOMMAND is defined.

Definition at line 205 of file Turnout.cpp.

Turnout * create ( int  id,
int  add,
int  subAdd 
)
static

Creates a new turnout in the list..

Parameters
idThe numeric ID (0-32767) of the sensor.
addThe primary address of the decoder controlling this turnout (0-511).
subAddThe sub-address of the decoder controlling this turnout (0-3).
Remarks
Should not be used in C++ mode.
Only available when USE_TEXTCOMMAND is defined.

Definition at line 242 of file Turnout.cpp.

Member Data Documentation

struct TurnoutData data

Data associated to this output.

Definition at line 118 of file Turnout.h.

Turnout * firstTurnout = NULL
static

Address of the first object of this class. NULL means empty list of turnouts. Do not change it !

Definition at line 147 of file Turnout.h.

Turnout* nextTurnout

Address of the next object of this class. NULL means end of the list of turnouts. Do not change it !

Definition at line 148 of file Turnout.h.

int eepromPos

EEPROM starting address for this Turnout storage.

Definition at line 174 of file Turnout.h.