43LoggingTrain::LoggingTrain(
45 : legacyAddress_(legacy_address)
46 , legacyAddressType_(address_type)
49 TractionDefs::train_node_name_from_legacy(
50 legacyAddressType_, legacyAddress_)
54LoggingTrain::~LoggingTrain()
56 LOG(
INFO,
"Destructed train %s.",
57 TractionDefs::train_node_name_from_legacy(
58 legacyAddressType_, legacyAddress_)
64 LOG(
INFO,
"train %s : set speed to %c %.0f mph.",
65 TractionDefs::train_node_name_from_legacy(
66 legacyAddressType_, legacyAddress_)
69 currentSpeed_ = speed;
75 LOG(
INFO,
"train %s : get speed -> returns %c %.0f mph.",
76 TractionDefs::train_node_name_from_legacy(
77 legacyAddressType_, legacyAddress_)
79 currentSpeed_.direction() == currentSpeed_.FORWARD ?
'F' :
'R',
84void LoggingTrain::set_emergencystop()
86 LOG(
INFO,
"train %s : set emergency stop.",
87 TractionDefs::train_node_name_from_legacy(
88 legacyAddressType_, legacyAddress_)
90 currentSpeed_.set_mph(0);
94bool LoggingTrain::get_emergencystop()
96 LOG(
INFO,
"train %s : get emergency stop.",
97 TractionDefs::train_node_name_from_legacy(
98 legacyAddressType_, legacyAddress_)
103void LoggingTrain::set_fn(uint32_t address, uint16_t value)
105 LOG(
INFO,
"train %s : set fn %" PRIu32
" to %u.",
106 TractionDefs::train_node_name_from_legacy(
107 legacyAddressType_, legacyAddress_)
110 fnValues_[address] = value;
113uint16_t LoggingTrain::get_fn(uint32_t address)
115 uint16_t resp = fnValues_[address];
116 LOG(
INFO,
"train %s : get fn %" PRIu32
" -> current value is %u.",
117 TractionDefs::train_node_name_from_legacy(
118 legacyAddressType_, legacyAddress_)
124uint32_t LoggingTrain::legacy_address()
126 return legacyAddress_;
131 return legacyAddressType_;
This class provides a mechanism for working with velocity in different forms.
float mph() const
Convert the native meters/sec representation into mile per hour.
@ FORWARD
forward direction
bool direction() const
Return the direction independent of speed.
TrainAddressType
Which address type this legacy train node uses.
#define LOG(level, message...)
Conditionally write a message to the logging output.
static const int INFO
Loglevel that is printed by default, reporting some status information.