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 show ()
 
static void load ()
 
static void store ()
 
static bool 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 Turnout::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 73 of file Turnout.cpp.

void Turnout::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 34 of file Turnout.cpp.

int Turnout::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 141 of file Turnout.cpp.

Turnout * 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 259 of file Turnout.cpp.

Turnout * 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 100 of file Turnout.cpp.

void Turnout::inactivate ( )
inline

Inactivate the turnout.

Definition at line 140 of file Turnout.h.

bool Turnout::isActivated ( )
inline

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.

void Turnout::load ( )
static

Load the content of all turnouts from EEPROM.

Remarks
Only available when USE_EEPROM is defined.

Definition at line 152 of file Turnout.cpp.

bool Turnout::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 206 of file Turnout.cpp.

void Turnout::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 108 of file Turnout.cpp.

void Turnout::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 64 of file Turnout.cpp.

void Turnout::show ( )
static

Show the content of all the turnouts.

Remarks
Only available when DCCPP_PRINT_DCCPP is defined.

Definition at line 284 of file Turnout.cpp.

void Turnout::store ( )
static

Store the content of all turnouts in EEPROM.

Remarks
Only available when USE_EEPROM is defined.

Definition at line 181 of file Turnout.cpp.

Member Data Documentation

struct TurnoutData Turnout::data

Data associated to this output.

Definition at line 118 of file Turnout.h.

int Turnout::eepromPos

EEPROM starting address for this Turnout storage.

Definition at line 174 of file Turnout.h.

Turnout * 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* 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.


The documentation for this struct was generated from the following files: