mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 20:24:59 +01:00
fix: a latching line breaker lever goes off with the breaker knocked out (#277)
The EP05's single two-state line breaker lever stayed on once the converter overload relay knocked the breaker out: every press of the toggle tried to close the open breaker, which the tripped relay refused. A press now puts a lever left on over an open breaker off first. (eu07/maszyna#394)
This commit is contained in:
@@ -15,6 +15,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include "stdafx.h"
|
||||
#include "vehicle/Train.h"
|
||||
#include "vehicle/horn.h"
|
||||
#include "vehicle/linebreaker.h"
|
||||
|
||||
#include "utilities/Globals.h"
|
||||
#include "simulation/simulation.h"
|
||||
@@ -3652,16 +3653,22 @@ void TTrain::OnCommand_linebreakertoggle(TTrain *Train, command_data const &Comm
|
||||
if (Command.action == GLFW_PRESS)
|
||||
{
|
||||
// press or hold...
|
||||
if (Train->m_linebreakerstate == 0)
|
||||
// a single two-state lever stays where it was put, also when the line breaker gets knocked out
|
||||
auto const latchinglever{Train->ggMainOnButton.SubModel == nullptr && Train->ggMainOffButton.SubModel == nullptr && Train->ggMainButton.SubModel != nullptr &&
|
||||
Train->ggMainButton.type() == TGaugeType::toggle};
|
||||
switch (linebreaker::pressed(Train->m_linebreakerstate, latchinglever, Train->ggMainButton.GetDesiredValue() > 0.5))
|
||||
{
|
||||
case linebreaker::toggle::close:
|
||||
// ...to close the circuit
|
||||
// NOTE: bit of a dirty shortcut here
|
||||
OnCommand_linebreakerclose(Train, Command);
|
||||
}
|
||||
else if (Train->m_linebreakerstate == 1)
|
||||
{
|
||||
// ...to open the circuit
|
||||
break;
|
||||
case linebreaker::toggle::open:
|
||||
// ...to open the circuit, or to put the lever off if the circuit was already opened
|
||||
OnCommand_linebreakeropen(Train, Command);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (Command.action == GLFW_RELEASE)
|
||||
|
||||
26
vehicle/linebreaker.cpp
Normal file
26
vehicle/linebreaker.cpp
Normal file
@@ -0,0 +1,26 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#include "stdafx.h"
|
||||
#include "vehicle/linebreaker.h"
|
||||
|
||||
namespace linebreaker {
|
||||
|
||||
toggle pressed(int const Breakerstate, bool const Latchinglever, bool const Leveron) {
|
||||
if (Breakerstate == 1) {
|
||||
return toggle::open;
|
||||
}
|
||||
if (Breakerstate != 0) {
|
||||
return toggle::none;
|
||||
}
|
||||
// the line breaker is open; a lever left on goes off first
|
||||
return Latchinglever && Leveron ? toggle::open : toggle::close;
|
||||
}
|
||||
|
||||
} // namespace linebreaker
|
||||
28
vehicle/linebreaker.h
Normal file
28
vehicle/linebreaker.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*
|
||||
This Source Code Form is subject to the
|
||||
terms of the Mozilla Public License, v.
|
||||
2.0. If a copy of the MPL was not
|
||||
distributed with this file, You can
|
||||
obtain one at
|
||||
http://mozilla.org/MPL/2.0/.
|
||||
*/
|
||||
|
||||
#pragma once
|
||||
|
||||
// the line breaker (main switch, WS) controls of the cab
|
||||
namespace linebreaker {
|
||||
|
||||
enum class toggle : int {
|
||||
none, // the press does nothing
|
||||
close, // the control goes to its on position, and the line breaker closes if it can
|
||||
open // the control goes to its off position, and the line breaker opens
|
||||
};
|
||||
|
||||
// what a press of the line breaker toggle does. Breakerstate is the state the cab keeps of the line
|
||||
// breaker (0: open, 1: closed, 2: freshly closed). Latchinglever is a single two-state switch which
|
||||
// stays where it was put, Leveron that it stands in its on position. such a lever doesn't follow the
|
||||
// line breaker: knocked out (by the converter overload relay, say) the breaker opens with the lever
|
||||
// left on, and the lever has to go off before it can be put on again (eu07/maszyna#394)
|
||||
toggle pressed(int Breakerstate, bool Latchinglever, bool Leveron);
|
||||
|
||||
} // namespace linebreaker
|
||||
Reference in New Issue
Block a user