18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-11-24 14:19:12 +01:00

Merge pull request #275 from MaSzyna-EU07/fix/sm42-shunt-mode-toggle

SM42: shunt mode at the first move of the switch, CA off in the shunt mode
This commit is contained in:
2026-11-09 12:54:21 +00:00
committed by GitHub
4 changed files with 270 additions and 18 deletions

View File

@@ -1164,6 +1164,7 @@ class TSecuritySystem
bool is_sifa = false; // Sifa-like pedal device, with inverted input for convenient keyboard usage
bool separate_acknowledge = false; // cabsignal reset button is separate from vigilance
bool cabsignal_lock = false;
bool vigilance_suspended = false; // the vigilance device switched off by the shunt mode of the vehicle, see AwareOffInShuntMode
double vigilance_timer = 0.0;
double alert_timer = 0.0;
@@ -1179,6 +1180,7 @@ class TSecuritySystem
double EmergencyBrakeDelay = 5.0;
double MaxHoldTime = 1.5;
bool CabDependent = false;
bool AwareOffInShuntMode = false; // the shunt mode of the vehicle switches the vigilance device off, as on the SM42
public:
void set_enabled(bool e);
@@ -1188,6 +1190,7 @@ class TSecuritySystem
void update(double dt, double Vel, bool pwr, int cab);
void set_cabsignal();
void set_cabsignal_lock(bool);
void set_shunt_mode(bool State);
bool is_blinking() const;
bool is_vigilance_blinking() const;
bool is_cabsignal_blinking() const;

View File

@@ -153,11 +153,23 @@ void TSecuritySystem::update(double dt, double vel, bool pwr, int cab)
velocity = vel;
cabactive = cab;
if (vigilance_enabled && velocity > AwareMinSpeed)
vigilance_timer += dt;
if (vigilance_suspended)
{
// the vigilance device is switched off: no time counts towards a new alarm, of the alerter or of the button held
// too long. an alarm already on, with the emergency braking it leads to, stays until it's acknowledged as usual
if (vigilance_timer <= AwareDelay)
vigilance_timer = 0.0;
if (press_timer <= MaxHoldTime)
press_timer = 0.0;
}
else
{
if (vigilance_enabled && velocity > AwareMinSpeed)
vigilance_timer += dt;
if (pressed && (!is_sifa || velocity > AwareMinSpeed))
press_timer += dt;
if (pressed && (!is_sifa || velocity > AwareMinSpeed))
press_timer += dt;
}
if (vigilance_timer > AwareDelay || press_timer > MaxHoldTime || cabsignal_active)
alert_timer += dt;
@@ -232,6 +244,11 @@ void TSecuritySystem::set_cabsignal_lock(bool v)
cabsignal_lock = v;
}
void TSecuritySystem::set_shunt_mode(bool const State)
{
vigilance_suspended = State && AwareOffInShuntMode;
}
bool TSecuritySystem::is_engine_blocked() const
{
if (!is_sifa)
@@ -261,6 +278,7 @@ void TSecuritySystem::load(std::string const &line, double Vmax)
extract_value(radiostop_enabled, "RadioStop", line, "");
extract_value(MagnetLocation, "MagnetLocation", line, "");
extract_value(CabDependent, "CabDependent", line, "");
extract_value(AwareOffInShuntMode, "AwareOffInShuntMode", line, "");
}
double TableInterpolation(std::map<double, double> &Map, double Parameter)
@@ -823,6 +841,19 @@ bool TMoverParameters::ChangeCab(int direction)
// rozruch wysoki (true) albo niski (false)
bool TMoverParameters::CurrentSwitch(bool const State)
{
// TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that
// the diesels with a shunt mode have no motor overload relay threshold to switch, the switch sets their shunt mode alone.
// MaxCurrentSwitch() takes any change of the setting, so asked first it took the first move of the switch (eu07/maszyna#497)
if (true == ShuntModeAllow && (EngineType == TEngineType::DieselEngine || EngineType == TEngineType::DieselElectric))
{
// dla 2Ls150 przed ustawieniem kierunku, for SM42/SP42 at the controller's zero position
if (EngineType == TEngineType::DieselEngine ? DirActive != 0 : false == IsMainCtrlNoPowerPos())
{
return false;
}
ShuntMode = State;
return true;
}
if (MaxCurrentSwitch(State))
{
@@ -832,20 +863,6 @@ bool TMoverParameters::CurrentSwitch(bool const State)
}
return true;
}
// TBD, TODO: split off shunt mode toggle into a separate command? It doesn't make much sense to have these two together like that
// dla 2Ls150
if (EngineType == TEngineType::DieselEngine && true == ShuntModeAllow && DirActive == 0)
{
// przed ustawieniem kierunku
ShuntMode = State;
return true;
}
// for SM42/SP42
if (EngineType == TEngineType::DieselElectric && true == ShuntModeAllow && IsMainCtrlNoPowerPos())
{
ShuntMode = State;
return true;
}
return false;
};
@@ -3230,6 +3247,8 @@ void TMoverParameters::SecuritySystemReset(void) // zbijanie czuwaka/SHP
void TMoverParameters::SecuritySystemCheck(double dt)
{
bool isPower = Power24vIsAvailable || Power110vIsAvailable;
// the shunt mode of the SM42 switches its vigilance device (CA) off, on the vehicles with AwareOffInShuntMode=Yes (eu07/maszyna#457)
SecuritySystem.set_shunt_mode(ShuntMode);
SecuritySystem.update(dt, Vel, isPower, CabActive);
if (!Battery || !Radio || !RadioFuse)