|
Open Model Railroad Network (OpenMRN)
|
AbstractTrain is a templated class for train implementations in a command station. More...
#include <Loco.hxx>
Public Member Functions | |
| void | set_speed (SpeedType speed) OVERRIDE |
| Sets the train speed (asking for a high-priority outgoing update packet to be generated). | |
| SpeedType | get_speed () OVERRIDE |
| SpeedType | get_commanded_speed () OVERRIDE |
| void | set_emergencystop () OVERRIDE |
| Sets the train to ESTOP state, generating an emergency stop packet. | |
| bool | get_emergencystop () OVERRIDE |
| Gets the train's ESTOP state. | |
| void | set_fn (uint32_t address, uint16_t value) OVERRIDE |
| Sets a function to a given value. | |
| uint16_t | get_fn (uint32_t address) OVERRIDE |
| uint32_t | legacy_address () OVERRIDE |
| TrainAddressType | legacy_address_type () OVERRIDE |
Public Member Functions inherited from dcc::PacketSource | |
| virtual void | get_next_packet (unsigned code, Packet *packet)=0 |
| Generates the next packet to send out to the track. | |
Public Member Functions inherited from openlcb::TrainImpl | |
| virtual SpeedType | get_actual_speed () |
| Returns the actual speed of the locomotive, as provided by feedback from the decoder. | |
Protected Member Functions | |
| unsigned | get_effective_f0 () |
| void | update_f0_direction_changed () |
| Updates the f0 states after a direction change occurred. | |
Protected Attributes | |
| P | p |
| Payload – actual data we know about the train. | |
Static Protected Attributes | |
| static constexpr unsigned | VIRTF0_DIRECTIONAL_ENABLE = 0 |
| Function number of "enable directional F0". | |
| static constexpr unsigned | VIRTF0_BLANK_FWD = 1 |
| Function number of "Blank F0 Forward". | |
| static constexpr unsigned | VIRTF0_BLANK_REV = 2 |
| Function number of "Blank F0 Reverse". | |
AbstractTrain is a templated class for train implementations in a command station.
It gives implementations for most functions that the OpenLCB command station neeeds, while using a compact structure for representing the state the command station needs to know about the train itself.
The only shared assumption about the train is that it has to participate in the standard command station packet loop. The exact protocol, number of speed steps, number of functions etc. are all defined by the template argument. The goal is to minimize the number of bytes needed to store information about one train in the RAM so that command stations with limited memory can still serve a large number of trains in their update loop.
Example implementations of the template payload are Dcc28Payload, Dcc128Payload, MMOldPayload, MMNewPayload.
|
inline |
|
inlinevirtual |
Reimplemented from openlcb::TrainImpl.
|
inlineprotected |
|
inlinevirtual |
Gets the train's ESTOP state.
Implements openlcb::TrainImpl.
|
inlinevirtual |
| address | is the function address. |
Implements openlcb::TrainImpl.
|
inlinevirtual |
|
inlinevirtual |
Implements openlcb::TrainImpl.
|
inlinevirtual |
Implements openlcb::TrainImpl.
|
inlinevirtual |
Sets the train to ESTOP state, generating an emergency stop packet.
Implements openlcb::TrainImpl.
|
inlinevirtual |
Sets a function to a given value.
| address | is the function number (0..28), |
| value | is 0 for funciton OFF, 1 for function ON. |
Implements openlcb::TrainImpl.
|
inlinevirtual |
Sets the train speed (asking for a high-priority outgoing update packet to be generated).
| speed | is the desired speed that came from the throttle. |
Implements openlcb::TrainImpl.
|
inlineprotected |
|
protected |
|
staticconstexprprotected |
|
staticconstexprprotected |
|
staticconstexprprotected |