Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
openlcb::LoggingTrain Class Reference

Test train implementation that just logs every action to the info log. More...

#include <TractionTestTrain.hxx>

Inheritance diagram for openlcb::LoggingTrain:
openlcb::TrainImpl

Public Member Functions

 LoggingTrain (uint32_t legacy_address, dcc::TrainAddressType address_type=dcc::TrainAddressType::DCC_LONG_ADDRESS)
 
void set_speed (SpeedType speed) OVERRIDE
 Sets the speed of the locomotive.
 
SpeedType get_speed () OVERRIDE
 
void set_emergencystop () OVERRIDE
 Sets the train to emergency stop.
 
bool get_emergencystop () OVERRIDE
 Get the current E-Stop state.
 
void set_fn (uint32_t address, uint16_t value) OVERRIDE
 Sets the value of a function.
 
uint16_t get_fn (uint32_t address) OVERRIDE
 
uint32_t legacy_address () OVERRIDE
 
dcc::TrainAddressType legacy_address_type () OVERRIDE
 
- Public Member Functions inherited from openlcb::TrainImpl
virtual SpeedType get_commanded_speed ()
 
virtual SpeedType get_actual_speed ()
 Returns the actual speed of the locomotive, as provided by feedback from the decoder.
 

Private Attributes

uint32_t legacyAddress_
 
dcc::TrainAddressType legacyAddressType_
 
SpeedType currentSpeed_
 
bool estopActive_
 
std::map< uint32_t, uint16_t > fnValues_
 

Detailed Description

Test train implementation that just logs every action to the info log.

Definition at line 46 of file TractionTestTrain.hxx.

Constructor & Destructor Documentation

◆ LoggingTrain()

openlcb::LoggingTrain::LoggingTrain ( uint32_t  legacy_address,
dcc::TrainAddressType  address_type = dcc::TrainAddressType::DCC_LONG_ADDRESS 
)

Definition at line 43 of file TractionTestTrain.cxx.

◆ ~LoggingTrain()

openlcb::LoggingTrain::~LoggingTrain ( )

Definition at line 54 of file TractionTestTrain.cxx.

Member Function Documentation

◆ get_emergencystop()

bool openlcb::LoggingTrain::get_emergencystop ( )
virtual

Get the current E-Stop state.

Returns
true if the train is E-Stopped, else false

Implements openlcb::TrainImpl.

Definition at line 94 of file TractionTestTrain.cxx.

◆ get_fn()

uint16_t openlcb::LoggingTrain::get_fn ( uint32_t  address)
virtual
Returns
the value of a function.

Implements openlcb::TrainImpl.

Definition at line 113 of file TractionTestTrain.cxx.

◆ get_speed()

SpeedType openlcb::LoggingTrain::get_speed ( )
virtual
Returns
the last set speed of the locomotive.

Implements openlcb::TrainImpl.

Definition at line 73 of file TractionTestTrain.cxx.

◆ legacy_address()

uint32_t openlcb::LoggingTrain::legacy_address ( )
virtual
Returns
the legacy (DCC) address of this train. This value is used in determining the train's NMRAnet NodeID.
Todo:
(balazs.racz) This function should not be here. Specifying the NodeID should be more generic, but it is not clear what would be the best interface for that.

Implements openlcb::TrainImpl.

Definition at line 124 of file TractionTestTrain.cxx.

◆ legacy_address_type()

dcc::TrainAddressType openlcb::LoggingTrain::legacy_address_type ( )
virtual
Returns
the type of legacy protocol in use.

Implements openlcb::TrainImpl.

Definition at line 129 of file TractionTestTrain.cxx.

◆ set_emergencystop()

void openlcb::LoggingTrain::set_emergencystop ( )
virtual

Sets the train to emergency stop.

Implements openlcb::TrainImpl.

Definition at line 84 of file TractionTestTrain.cxx.

◆ set_fn()

void openlcb::LoggingTrain::set_fn ( uint32_t  address,
uint16_t  value 
)
virtual

Sets the value of a function.

Parameters
addressis a 24-bit address of the function to set. For legacy DCC locomotives, see TractionDefs for the address definitions (0=light, 1-28= traditional function buttons).
valueis the function value. For binary functions, any non-zero value sets the function to on, zero sets it to off.

Implements openlcb::TrainImpl.

Definition at line 103 of file TractionTestTrain.cxx.

◆ set_speed()

void openlcb::LoggingTrain::set_speed ( SpeedType  speed)
virtual

Sets the speed of the locomotive.

Parameters
speedis the requested scale speed in m/s. The sign of the number means the direction.

Implements openlcb::TrainImpl.

Definition at line 62 of file TractionTestTrain.cxx.

Member Data Documentation

◆ currentSpeed_

SpeedType openlcb::LoggingTrain::currentSpeed_
private

Definition at line 65 of file TractionTestTrain.hxx.

◆ estopActive_

bool openlcb::LoggingTrain::estopActive_
private

Definition at line 66 of file TractionTestTrain.hxx.

◆ fnValues_

std::map<uint32_t, uint16_t> openlcb::LoggingTrain::fnValues_
private

Definition at line 67 of file TractionTestTrain.hxx.

◆ legacyAddress_

uint32_t openlcb::LoggingTrain::legacyAddress_
private

Definition at line 63 of file TractionTestTrain.hxx.

◆ legacyAddressType_

dcc::TrainAddressType openlcb::LoggingTrain::legacyAddressType_
private

Definition at line 64 of file TractionTestTrain.hxx.


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