DCC++: added check on load if decoders are configured properly
Dieser Commit ist enthalten in:
Ursprung
2c4ee5e142
Commit
f13e4ccae4
@ -32,6 +32,21 @@ TODO
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
## C2002: DCC++ only supports the DCC protocol {#c2002}
|
||||
|
||||
**Cause:** The selected decoder protocol isn't supported by the DCC++ command station.
|
||||
|
||||
**Solution:** Change the decoder protocol to *DCC* or *Auto*.
|
||||
|
||||
|
||||
## C2003: DCC++ doesn't support DCC long addresses below 128 {#c2003}
|
||||
|
||||
**Cause:** The DCC++ command station considers all addresses below 128 a DCC short address.
|
||||
|
||||
**Solution:** Change the locomotive decoder address.
|
||||
|
||||
|
||||
## C9999: *message* {#c9999}
|
||||
|
||||
Custom critical message generated by a [Lua script](../scripting.md).
|
||||
|
||||
@ -18,6 +18,21 @@ TODO
|
||||
TODO
|
||||
|
||||
|
||||
## W2002: Command station doesn't support functions above F*number* {#w2002}
|
||||
|
||||
**Cause:** The command station or interface can't control these function, e.g. due hardware or protocol limitations.
|
||||
|
||||
**Solution:** Check if command station is setup properly, some command stations have options which specify how to control additional functions.
|
||||
If not, remapping decoder functions or using a different command station is the only solution.
|
||||
|
||||
|
||||
## W2003: Command station doesn't support *number* speed steps, using *number* {#w2003}
|
||||
|
||||
**Cause:** The command station or interface can't control decoders using *number* speed steps, e.g. due hardware or protocol limitations.
|
||||
|
||||
**Solution:** The number of speed steps that can be used is determinded by the command station or interface. Changing the decoders speed steps to *Auto* should usally work.
|
||||
|
||||
|
||||
## W9999: *message* {#w9999}
|
||||
|
||||
Custom warning message generated by a [Lua script](../scripting.md).
|
||||
|
||||
@ -84,6 +84,13 @@ CommandStation::CommandStation(const std::weak_ptr<World>& world, std::string_vi
|
||||
m_interfaceItems.add(notes);
|
||||
}
|
||||
|
||||
void CommandStation::loaded()
|
||||
{
|
||||
IdObject::loaded();
|
||||
|
||||
checkAllDecoders();
|
||||
}
|
||||
|
||||
void CommandStation::addToWorld()
|
||||
{
|
||||
IdObject::addToWorld();
|
||||
@ -159,6 +166,12 @@ void CommandStation::powerOnChanged(bool value)
|
||||
controller->powerOnChanged(value);
|
||||
}
|
||||
|
||||
void CommandStation::checkAllDecoders() const
|
||||
{
|
||||
for(const auto& decoder : *decoders)
|
||||
checkDecoder(*decoder);
|
||||
}
|
||||
|
||||
void CommandStation::decoderChanged(const Decoder& decoder, DecoderChangeFlags changes, uint32_t functionNumber)
|
||||
{
|
||||
for(auto& controller : *controllers)
|
||||
|
||||
@ -37,13 +37,15 @@ class CommandStation : public IdObject
|
||||
friend class ::Decoder;
|
||||
|
||||
protected:
|
||||
void loaded() override;
|
||||
void addToWorld() final;
|
||||
void worldEvent(WorldState state, WorldEvent event) override;
|
||||
|
||||
virtual bool setOnline(bool& value) = 0;
|
||||
virtual void emergencyStopChanged(bool value);
|
||||
virtual void powerOnChanged(bool value);
|
||||
//virtual bool isDecoderSupported(Decoder& decoder) const = 0;
|
||||
void checkAllDecoders() const;
|
||||
virtual void checkDecoder(const Decoder& decoder) const {}
|
||||
virtual void decoderChanged(const Decoder& decoder, DecoderChangeFlags changes, uint32_t functionNumber);
|
||||
|
||||
void restoreSpeed();
|
||||
|
||||
@ -52,6 +52,12 @@ void DCCPlusPlusSerial::powerOnChanged(bool value)
|
||||
dccPlusPlus->powerOnChanged(value);
|
||||
}
|
||||
|
||||
void DCCPlusPlusSerial::checkDecoder(const Decoder& decoder) const
|
||||
{
|
||||
CommandStation::checkDecoder(decoder);
|
||||
dccPlusPlus->checkDecoder(decoder);
|
||||
}
|
||||
|
||||
void DCCPlusPlusSerial::decoderChanged(const Decoder& decoder, DecoderChangeFlags changes, uint32_t functionNumber)
|
||||
{
|
||||
CommandStation::decoderChanged(decoder, changes, functionNumber);
|
||||
|
||||
@ -31,6 +31,7 @@ class DCCPlusPlusSerial : public SerialCommandStation
|
||||
protected:
|
||||
void emergencyStopChanged(bool value) final;
|
||||
void powerOnChanged(bool value) final;
|
||||
void checkDecoder(const Decoder& decoder) const;
|
||||
void decoderChanged(const Decoder& decoder, DecoderChangeFlags changes, uint32_t functionNumber) final;
|
||||
|
||||
bool send(std::string_view message);
|
||||
|
||||
@ -52,6 +52,7 @@ class Decoder : public IdObject
|
||||
CLASS_ID("decoder")
|
||||
CREATE(Decoder)
|
||||
|
||||
static constexpr uint8_t speedStepsAuto = 0;
|
||||
static constexpr float throttleMin = 0;
|
||||
static constexpr float throttleStop = throttleMin;
|
||||
static constexpr float throttleMax = 1;
|
||||
|
||||
@ -104,6 +104,27 @@ void DCCPlusPlus::powerOnChanged(bool value)
|
||||
send(Ex::powerOff());
|
||||
}
|
||||
|
||||
void DCCPlusPlus::checkDecoder(const Decoder& decoder) const
|
||||
{
|
||||
assert(m_commandStation);
|
||||
|
||||
if(decoder.protocol != DecoderProtocol::Auto && decoder.protocol != DecoderProtocol::DCC)
|
||||
Log::log(decoder, LogMessage::C2002_DCCPLUSPLUS_ONLY_SUPPORTS_THE_DCC_PROTOCOL);
|
||||
|
||||
if(decoder.protocol == DecoderProtocol::DCC && decoder.address <= 127 && decoder.longAddress)
|
||||
Log::log(decoder, LogMessage::C2003_DCCPLUSPLUS_DOESNT_SUPPORT_DCC_LONG_ADDRESSES_BELOW_128);
|
||||
|
||||
if(decoder.speedSteps != Decoder::speedStepsAuto && decoder.speedSteps != speedSteps)
|
||||
Log::log(decoder, LogMessage::W2003_COMMAND_STATION_DOESNT_SUPPORT_X_SPEEDSTEPS_USING_X, decoder.speedSteps.value(), speedSteps.value());
|
||||
|
||||
for(const auto& function : *decoder.functions)
|
||||
if(function->number > functionNumberMax)
|
||||
{
|
||||
Log::log(decoder, LogMessage::W2002_COMMAND_STATION_DOESNT_SUPPORT_FUNCTIONS_ABOVE_FX, functionNumberMax);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void DCCPlusPlus::decoderChanged(const Decoder& decoder, DecoderChangeFlags changes, uint32_t functionNumber)
|
||||
{
|
||||
if(has(changes, DecoderChangeFlags::EmergencyStop | DecoderChangeFlags::Throttle | DecoderChangeFlags::Direction))
|
||||
|
||||
@ -60,6 +60,8 @@ class DCCPlusPlus : public SubObject
|
||||
|
||||
void emergencyStopChanged(bool value);
|
||||
void powerOnChanged(bool value);
|
||||
|
||||
void checkDecoder(const Decoder& decoder) const;
|
||||
void decoderChanged(const Decoder& decoder, DecoderChangeFlags changes, uint32_t functionNumber);
|
||||
};
|
||||
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren