Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
traction_modem::ModemTrain Class Reference
Inheritance diagram for traction_modem::ModemTrain:
openlcb::TrainImpl

Public Member Functions

 ModemTrain (Service *service)
 
void start (int uart_fd)
 
void set_is_active (bool is_active)
 Set the active state of the wireless control.
 
openlcb::MemorySpaceget_cv_space ()
 
void set_speed (openlcb::SpeedType speed) override
 Sets the speed of the locomotive.
 
openlcb::SpeedType get_speed () override
 Returns the last set speed of the locomotive.
 
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 Member Functions

void send_packet (Defs::Payload p)
 

Private Attributes

bool isRunning_ = false
 
int fd_
 UART fd to send traffic to the device.
 
openlcb::SpeedType lastSpeed_ = 0.0
 
bool inEStop_ = false
 True if the last set was estop, false if it was a speed.
 
TxFlow txFlow_
 
RxFlow rxFlow_
 
CvSpace cvSpace_ {&txFlow_}
 
bool isActive_
 

Detailed Description

Definition at line 574 of file TractionModem.hxx.

Constructor & Destructor Documentation

◆ ModemTrain()

traction_modem::ModemTrain::ModemTrain ( Service service)
inline

Definition at line 577 of file TractionModem.hxx.

Member Function Documentation

◆ get_cv_space()

openlcb::MemorySpace * traction_modem::ModemTrain::get_cv_space ( )
inline

Definition at line 602 of file TractionModem.hxx.

◆ get_emergencystop()

bool traction_modem::ModemTrain::get_emergencystop ( )
inlineoverridevirtual

Get the current E-Stop state.

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

Implements openlcb::TrainImpl.

Definition at line 631 of file TractionModem.hxx.

◆ get_fn()

uint16_t traction_modem::ModemTrain::get_fn ( uint32_t  address)
inlineoverridevirtual
Returns
the value of a function.
Todo:
Need to implement this.

Implements openlcb::TrainImpl.

Definition at line 712 of file TractionModem.hxx.

◆ get_speed()

openlcb::SpeedType traction_modem::ModemTrain::get_speed ( )
inlineoverridevirtual

Returns the last set speed of the locomotive.

Implements openlcb::TrainImpl.

Definition at line 618 of file TractionModem.hxx.

◆ legacy_address()

uint32_t traction_modem::ModemTrain::legacy_address ( )
inlineoverridevirtual
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.
Todo:
what should this be?

Implements openlcb::TrainImpl.

Definition at line 718 of file TractionModem.hxx.

◆ legacy_address_type()

dcc::TrainAddressType traction_modem::ModemTrain::legacy_address_type ( )
inlineoverridevirtual
Returns
the type of legacy protocol in use.

Implements openlcb::TrainImpl.

Definition at line 725 of file TractionModem.hxx.

◆ send_packet()

void traction_modem::ModemTrain::send_packet ( Defs::Payload  p)
inlineprivate

Definition at line 731 of file TractionModem.hxx.

◆ set_emergencystop()

void traction_modem::ModemTrain::set_emergencystop ( )
inlineoverridevirtual

Sets the train to emergency stop.

Implements openlcb::TrainImpl.

Definition at line 624 of file TractionModem.hxx.

◆ set_fn()

void traction_modem::ModemTrain::set_fn ( uint32_t  address,
uint16_t  value 
)
inlineoverridevirtual

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.
Todo:
The following switch statement is for hardware testing only. In production software, the main MCU should have the on/off logical by "output" number, and not by function number. The main MCU should instruct the modem of the activity state.

Implements openlcb::TrainImpl.

Definition at line 642 of file TractionModem.hxx.

◆ set_is_active()

void traction_modem::ModemTrain::set_is_active ( bool  is_active)
inline

Set the active state of the wireless control.

Parameters
is_activetrue if under wireless control, else false

Definition at line 593 of file TractionModem.hxx.

◆ set_speed()

void traction_modem::ModemTrain::set_speed ( openlcb::SpeedType  speed)
inlineoverridevirtual

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 609 of file TractionModem.hxx.

◆ start()

void traction_modem::ModemTrain::start ( int  uart_fd)
inline

Definition at line 585 of file TractionModem.hxx.

Member Data Documentation

◆ cvSpace_

CvSpace traction_modem::ModemTrain::cvSpace_ {&txFlow_}
private

Definition at line 748 of file TractionModem.hxx.

◆ fd_

int traction_modem::ModemTrain::fd_
private

UART fd to send traffic to the device.

Definition at line 740 of file TractionModem.hxx.

◆ inEStop_

bool traction_modem::ModemTrain::inEStop_ = false
private

True if the last set was estop, false if it was a speed.

Definition at line 744 of file TractionModem.hxx.

◆ isActive_

bool traction_modem::ModemTrain::isActive_
private

Definition at line 749 of file TractionModem.hxx.

◆ isRunning_

bool traction_modem::ModemTrain::isRunning_ = false
private

Definition at line 738 of file TractionModem.hxx.

◆ lastSpeed_

openlcb::SpeedType traction_modem::ModemTrain::lastSpeed_ = 0.0
private

Definition at line 742 of file TractionModem.hxx.

◆ rxFlow_

RxFlow traction_modem::ModemTrain::rxFlow_
private

Definition at line 747 of file TractionModem.hxx.

◆ txFlow_

TxFlow traction_modem::ModemTrain::txFlow_
private

Definition at line 746 of file TractionModem.hxx.


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