Open Model Railroad Network (OpenMRN)
Loading...
Searching...
No Matches
TrainInterface.hxx
Go to the documentation of this file.
1
35#ifndef _OPENLCB_TRAININTERFACE_HXX_
36#define _OPENLCB_TRAININTERFACE_HXX_
37
38#include "dcc/Defs.hxx"
39#include "openlcb/Velocity.hxx"
40
41namespace openlcb
42{
43
46typedef Velocity SpeedType;
47
51{
52public:
53 virtual ~TrainImpl() {}
54
59 virtual void set_speed(SpeedType speed) = 0;
61 virtual SpeedType get_speed() = 0;
64 return nan_to_speed();
65 }
69 return nan_to_speed();
70 }
71
73 virtual void set_emergencystop() = 0;
74
78 virtual bool get_emergencystop() = 0;
79
86 virtual void set_fn(uint32_t address, uint16_t value) = 0;
87
89 virtual uint16_t get_fn(uint32_t address) = 0;
90
97 virtual uint32_t legacy_address() = 0;
98
101};
102
103} // namespace openlcb
104
105#endif // _OPENLCB_TRAININTERFACE_HXX_
106
Abstract base class for train implementations.
virtual void set_speed(SpeedType speed)=0
Sets the speed of the locomotive.
virtual void set_emergencystop()=0
Sets the train to emergency stop.
virtual SpeedType get_commanded_speed()
virtual void set_fn(uint32_t address, uint16_t value)=0
Sets the value of a function.
virtual bool get_emergencystop()=0
Get the current E-Stop state.
virtual uint16_t get_fn(uint32_t address)=0
virtual uint32_t legacy_address()=0
virtual SpeedType get_speed()=0
virtual SpeedType get_actual_speed()
Returns the actual speed of the locomotive, as provided by feedback from the decoder.
virtual dcc::TrainAddressType legacy_address_type()=0
This class provides a mechanism for working with velocity in different forms.
Definition Velocity.hxx:73
TrainAddressType
Which address type this legacy train node uses.
Definition dcc/Defs.hxx:46
Velocity nan_to_speed()
Definition Velocity.hxx:491
Velocity SpeedType
Represents an OpenLCB speed value with accessors to convert to and from various formats.