Z21 ClientKernel: do not propagate external changes
Decoder changes caused by Z21 should not be sent back to Z21
Dieser Commit ist enthalten in:
Ursprung
5bdbeeb72e
Commit
1e6d350d0b
@ -173,9 +173,18 @@ void ClientKernel::receive(const Message& message)
|
||||
|
||||
if(changed)
|
||||
{
|
||||
//Set the bool guard for each change
|
||||
isUpdatingDecoderFromKernel = true;
|
||||
decoder->emergencyStop = isEStop;
|
||||
|
||||
isUpdatingDecoderFromKernel = true;
|
||||
decoder->direction = dir;
|
||||
|
||||
isUpdatingDecoderFromKernel = true;
|
||||
decoder->throttle = throttle;
|
||||
|
||||
//Reset at end
|
||||
isUpdatingDecoderFromKernel = false;
|
||||
}
|
||||
|
||||
for(int i = 0; i <= maxFunc; i++)
|
||||
@ -420,10 +429,23 @@ void ClientKernel::decoderChanged(const Decoder& decoder, DecoderChangeFlags cha
|
||||
if(const auto& f = decoder.getFunction(functionNumber))
|
||||
funcVal = toTriState(f->value);
|
||||
|
||||
if(isUpdatingDecoderFromKernel)
|
||||
{
|
||||
//This change was caused by Z21 message so there is not point
|
||||
//on informing back Z21 with another message
|
||||
//Skip updating LocoCache again which might already be
|
||||
//at a new value (EventLoop is slower to process callbacks)
|
||||
//But reset the guard to allow Train and other parts of code
|
||||
//to react to this change and further edit decoder state
|
||||
isUpdatingDecoderFromKernel = false;
|
||||
return;
|
||||
}
|
||||
|
||||
m_ioContext.post([this, addr, longAddr, direction, throttle, speedSteps, isEStop, changes, functionNumber, funcVal]()
|
||||
{
|
||||
LanXSetLocoDrive cmd;
|
||||
cmd.setAddress(addr, longAddr);
|
||||
|
||||
cmd.setSpeedSteps(speedSteps);
|
||||
int speedStep = Decoder::throttleToSpeedStep(throttle, cmd.speedSteps());
|
||||
|
||||
|
||||
@ -119,6 +119,7 @@ class ClientKernel final : public Kernel
|
||||
};
|
||||
|
||||
std::unordered_map<uint16_t, LocoCache> m_locoCache;
|
||||
bool isUpdatingDecoderFromKernel = false;
|
||||
|
||||
InputController* m_inputController = nullptr;
|
||||
std::array<TriState, rbusAddressMax - rbusAddressMin + 1> m_rbusFeedbackStatus;
|
||||
|
||||
Laden…
x
In neuem Issue referenzieren
Einen Benutzer sperren