18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-27 21:45:16 +01:00
Files
maszyna/vehicle/linebreaker.h
jerrrrycho 02c4c81694 refactor: the line breaker state as an enum class, fcfuH without the text round trip (L16) (#478)
* refactor(cab): the cab's state of the line breaker is an enum class

TTrain::m_linebreakerstate kept 0, 1 and 2 for open, closed and closing
(the closing control held long enough). It is linebreaker::state now, which
linebreaker::pressed() takes too; every comparison and assignment names the
state. Nothing writes the state out: it isn't in the Python dictionary of
the cab, the black box, the physics log or the network. No change in
behaviour (eu07/maszyna#148).

* refactor(physics): fcfuH takes fcfu without writing it out and reading it back

A definition of an induction motor drive without fcfuH gave the dynamic
brake fcfu through text: std::to_string() of the value as the default of
extract_value(). The loader assigns it now. For any figure of up to six
decimals the value is the same to the bit (the test compares both ways over
more than 70000 figures, and through the loader); the game's definitions
have one or two. Only a figure of more than six decimals, which the text
rounded to six, or one past the largest value, which read back as 0 from
"inf", gives another; the test pins both (eu07/maszyna#99).
2026-11-25 05:14:50 +01:00

36 lines
1.3 KiB
C++

/*
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 {
// the state the cab keeps of the line breaker, besides the vehicle's own (TMoverParameters::Mains)
enum class state : int {
open,
closed,
closing // the closing control was held long enough; the line breaker closes when it's released, or right away
};
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. 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(state Breakerstate, bool Latchinglever, bool Leveron);
} // namespace linebreaker