mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-18 04:45:58 +01:00
Merge pull request #274 from MaSzyna-EU07/feat/elf-master-controller-emergency-brake
Elf: emergency brake position in the master controller (eu07/maszyna#413)
This commit is contained in:
@@ -2265,6 +2265,7 @@ class TMoverParameters
|
||||
int SpeedCtrlAutoTurnOffFlag = 0; /*czy tempomat sam się wyłącza*/
|
||||
bool EIMCtrlAdditionalZeros = false; /*czy ma dodatkowe zero jazdy i zero hamowania */
|
||||
bool EIMCtrlEmergency = false; /*czy ma dodatkowe zero jazdy i zero hamowania */
|
||||
bool EIMCtrlMainEmergency = false; /*czy zadajnik typu 2 (Elf) ma pozycje hamowania naglego ponizej swojej pozycji 0*/
|
||||
double eimv_pr = 0; /*realizowany procent dostepnej sily rozruchu/hamowania*/
|
||||
double eimv[21];
|
||||
static std::vector<std::string> const eimv_labels;
|
||||
@@ -2439,6 +2440,15 @@ class TMoverParameters
|
||||
int MainCtrlNoPowerPos() const; // highest setting of master controller which won't cause engine to generate extra power
|
||||
int MainCtrlActualPowerPos() const; // current actual setting of master controller, relative to the highest setting not generating extra power
|
||||
int MainCtrlPowerPos() const; // current setting of master controller, relative to the highest setting not generating extra power
|
||||
// positions the master controller of the EIMCtrlType 2 (Elf) has below its own position 0, the emergency brake (0 or 1)
|
||||
int EIMCtrlEmergencyPositions() const;
|
||||
// whether the master controller is in its emergency brake position (EIMCtrlType 2 with EIMCtrlMainEmergency)
|
||||
bool IsMainCtrlEmergencyPos() const;
|
||||
// the master controller position sent to the coupled vehicles ("MainCtrl"), the same with and without
|
||||
// EIMCtrlMainEmergency: the Elf's positions without the emergency brake one, which goes as the full braking
|
||||
int MainCtrlPosForCoupled() const;
|
||||
// the master controller position of this vehicle for one received from a coupled vehicle ("MainCtrl")
|
||||
int MainCtrlPosFromCoupled(int Position) const;
|
||||
/*! pomocniczy nastawnik:*/
|
||||
bool IncScndCtrl(int CtrlSpeed);
|
||||
bool DecScndCtrl(int CtrlSpeed);
|
||||
|
||||
@@ -2624,7 +2624,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
|
||||
if (true == OK)
|
||||
{
|
||||
ScndCtrlResistiveLockCheck(); // e.g. from the last series position on to the resistive parallel ones
|
||||
SendCtrlToNext("MainCtrl", MainCtrlPos, CabActive); //???
|
||||
SendCtrlToNext("MainCtrl", MainCtrlPosForCoupled(), CabActive); //???
|
||||
SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabActive);
|
||||
}
|
||||
|
||||
@@ -2750,7 +2750,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
|
||||
if (OK)
|
||||
{
|
||||
ScndCtrlResistiveLockCheck(); // the shunt drops when the master controller leaves a resistance-free position
|
||||
/*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPos, CabActive); // hmmmm...???!!!
|
||||
/*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPosForCoupled(), CabActive); // hmmmm...???!!!
|
||||
/*OK:=*/SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabActive);
|
||||
}
|
||||
}
|
||||
@@ -2798,7 +2798,7 @@ int TMoverParameters::MainCtrlNoPowerPos() const
|
||||
}
|
||||
case 2:
|
||||
{
|
||||
return 3;
|
||||
return 3 + EIMCtrlEmergencyPositions();
|
||||
}
|
||||
case 3:
|
||||
{
|
||||
@@ -2823,6 +2823,27 @@ int TMoverParameters::MainCtrlPowerPos() const
|
||||
return MainCtrlPos - MainCtrlNoPowerPos();
|
||||
}
|
||||
|
||||
int TMoverParameters::EIMCtrlEmergencyPositions() const
|
||||
{
|
||||
return (EIMCtrlType == 2 && EIMCtrlMainEmergency) ? 1 : 0;
|
||||
}
|
||||
|
||||
bool TMoverParameters::IsMainCtrlEmergencyPos() const
|
||||
{
|
||||
return MainCtrlPos < EIMCtrlEmergencyPositions();
|
||||
}
|
||||
|
||||
int TMoverParameters::MainCtrlPosForCoupled() const
|
||||
{
|
||||
// the emergency brake itself reaches the train through the brake pipe, vented by the vehicle driven from
|
||||
return std::max(0, MainCtrlPos - EIMCtrlEmergencyPositions());
|
||||
}
|
||||
|
||||
int TMoverParameters::MainCtrlPosFromCoupled(int const Position) const
|
||||
{
|
||||
return Position + EIMCtrlEmergencyPositions();
|
||||
}
|
||||
|
||||
// *************************************************************************************************
|
||||
// Q: 20160710
|
||||
// zwiększenie bocznika
|
||||
@@ -2864,7 +2885,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
|
||||
OK = false;
|
||||
if (OK)
|
||||
{
|
||||
/*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPos, CabActive); //???
|
||||
/*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPosForCoupled(), CabActive); //???
|
||||
/*OK:=*/SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabActive);
|
||||
}
|
||||
}
|
||||
@@ -2926,7 +2947,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
|
||||
OK = false;
|
||||
if (OK)
|
||||
{
|
||||
/*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPos, CabActive); //???
|
||||
/*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPosForCoupled(), CabActive); //???
|
||||
/*OK:=*/SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabActive);
|
||||
}
|
||||
}
|
||||
@@ -4688,8 +4709,9 @@ void TMoverParameters::UpdatePipePressure(double dt)
|
||||
|
||||
|
||||
// EngDmgFlag 32 (load destroyed) used to trigger this too; dropped, it has nothing to do with
|
||||
// the emergency brake (a broken coupler sets AlarmChainFlag instead)
|
||||
if (RadioStopFlag || AlarmChainFlag || (EIMCtrlEmergency && LocalBrakePosA >= 1.0) || SecuritySystem.is_braking() ||
|
||||
// the emergency brake (a broken coupler sets AlarmChainFlag instead). the Elf's emergency brake position
|
||||
// vents the pipe only from the vehicle driven from, whatever the controllers of the others show
|
||||
if (RadioStopFlag || AlarmChainFlag || (EIMCtrlEmergency && LocalBrakePosA >= 1.0) || (IsMainCtrlEmergencyPos() && IsCabMaster()) || SecuritySystem.is_braking() ||
|
||||
(SpringBrakeDriveEmergencyVel >= 0 && Vel > SpringBrakeDriveEmergencyVel && SpringBrake.IsActive) ||
|
||||
(0 == CabActive && (InactiveCabFlag & activation::emergencybrake) != 0))
|
||||
{
|
||||
@@ -7530,10 +7552,16 @@ void TMoverParameters::CheckEIMIC(double dt)
|
||||
eimic = 0;
|
||||
break;
|
||||
case 2:
|
||||
if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay)
|
||||
if (IsMainCtrlEmergencyPos())
|
||||
{
|
||||
// hamowanie nagle: pelne hamowanie od razu, przewod glowny oproznia UpdatePipePressure()
|
||||
eimic = -1.0;
|
||||
}
|
||||
else if (MainCtrlActualPos != MainCtrlPos || LastRelayTime > InitialCtrlDelay)
|
||||
{
|
||||
double delta = MainCtrlActualPos == MainCtrlPos ? dt * CtrlDelay : 0.01;
|
||||
switch (MainCtrlPos)
|
||||
// the positions below are those of the controller without the emergency brake position
|
||||
switch (MainCtrlPos - EIMCtrlEmergencyPositions())
|
||||
{
|
||||
case 0:
|
||||
case 1:
|
||||
@@ -11203,6 +11231,16 @@ void TMoverParameters::LoadFIZ_Cntrl(std::string const &line)
|
||||
extract_value(LocHandleTimeTraxx, "LocalBrakeTraxx", line, "");
|
||||
extract_value(EIMCtrlAdditionalZeros, "EIMCtrlAddZeros", line, "");
|
||||
extract_value(EIMCtrlEmergency, "EIMCtrlEmergency", line, "");
|
||||
// Elf (EIMCtrlType 2): an emergency brake position below the controller's position 0, which shifts the other positions up by one
|
||||
extract_value(EIMCtrlMainEmergency, "EIMCtrlMainEmergency", line, "");
|
||||
if (auto const elfpositions{4 + EIMCtrlEmergencyPositions()}; EIMCtrlEmergencyPositions() > 0 && MainCtrlPosNo < elfpositions)
|
||||
{
|
||||
// the old positions in the file: without the fix-up the controller would have no power position, and the
|
||||
// reverser would stop working at neutral (DirChangeMaxPos read before, in the old positions)
|
||||
MainCtrlMaxDirChangePos += EIMCtrlEmergencyPositions();
|
||||
ErrorLog(std::format("Bad fiz: EIMCtrlMainEmergency needs MCPN={} in {}, DirChangeMaxPos taken as {}", elfpositions, TypeName, MainCtrlMaxDirChangePos));
|
||||
MainCtrlPosNo = elfpositions;
|
||||
}
|
||||
|
||||
extract_value(ScndS, "ScndS", line, ""); // brak pozycji rownoleglej przy niskiej nastawie PSR
|
||||
extract_value(ScndCtrlResistiveLock, "ScndCtrlResistiveLock", line, ""); // bocznikowanie tylko na pozycjach bezoporowych
|
||||
@@ -12548,9 +12586,10 @@ bool TMoverParameters::RunCommand(std::string const &Command, double CValue1, do
|
||||
|
||||
if (Command == "MainCtrl")
|
||||
{
|
||||
if (MainCtrlPosNo >= floor(CValue1))
|
||||
// sent as MainCtrlPosForCoupled(), passed on unchanged
|
||||
if (auto const position{MainCtrlPosFromCoupled(static_cast<int>(floor(CValue1)))}; MainCtrlPosNo >= position)
|
||||
{
|
||||
MainCtrlPos = static_cast<int>(floor(CValue1));
|
||||
MainCtrlPos = position;
|
||||
if (DelayCtrlFlag)
|
||||
{
|
||||
if (LastRelayTime >= InitialCtrlDelay && MainCtrlPos == 1)
|
||||
|
||||
256
tests/unit/test_elf_controller.cpp
Normal file
256
tests/unit/test_elf_controller.cpp
Normal file
@@ -0,0 +1,256 @@
|
||||
#include "stdafx.h"
|
||||
#include "doctest.h"
|
||||
#include "consist.h"
|
||||
#include "drive.h"
|
||||
|
||||
#include "McZapkie/hamulce.h"
|
||||
|
||||
#include <initializer_list>
|
||||
#include <string>
|
||||
|
||||
// the master controller of the Elf (EIMCtrlType 2): its positions, and the emergency brake position below
|
||||
// them which EIMCtrlMainEmergency adds (eu07/maszyna#413)
|
||||
|
||||
using test::definition;
|
||||
using test::vehicle;
|
||||
|
||||
namespace {
|
||||
|
||||
// the data of an Elf: without the emergency brake position as now, with it in the files updated for it
|
||||
// (EIMCtrlMainEmergency, MCPN=5, DirChangeMaxPos=4), or with the key alone added to the old files, which the
|
||||
// loader fixes up
|
||||
enum class data { plain, emergency, emergency_old_layout };
|
||||
|
||||
// three-car Elfs coupled into one train, of the given data each, ready to run, standing with their brakes
|
||||
// released and the driver in the front cab of the head car of the first one, which also drives (the
|
||||
// controller's eimic is worked out there)
|
||||
struct elf {
|
||||
explicit elf(bool Emergency) : elf({Emergency ? data::emergency : data::plain}) {}
|
||||
explicit elf(std::initializer_list<data> Units) {
|
||||
for (auto const units : Units) {
|
||||
for (auto const *car : {"elf_v1/21we-a", "elf_v1/21we-b", "elf_v1/21we-c"}) {
|
||||
auto cardefinition{definition::fiz(car)};
|
||||
if (units != data::plain) {
|
||||
cardefinition.set("Cntrl", "EIMCtrlMainEmergency", "Yes");
|
||||
}
|
||||
if (units == data::emergency) {
|
||||
cardefinition.set("Cntrl", "MCPN", 5);
|
||||
if (std::string{car} != "elf_v1/21we-b") {
|
||||
// the cars with a cab have it, at neutral: 3 before, one up with the key
|
||||
cardefinition.set("Cntrl", "DirChangeMaxPos", 4);
|
||||
}
|
||||
}
|
||||
unit.add(cardefinition, unit.size() == 0 ? 1 : 0);
|
||||
}
|
||||
}
|
||||
ready = test::start_up(test::driving(unit), line);
|
||||
// the start-up of the tests leaves the controller at its position 0 (close_line_breaker() in drive.cpp),
|
||||
// the emergency brake one with EIMCtrlMainEmergency; the driver sets it to neutral, as the AI does. a unit
|
||||
// moves its controller only with a direction set
|
||||
for (int i = 0; i < 3 && cab().DirActive <= 0; ++i) {
|
||||
cab().DirectionForward();
|
||||
}
|
||||
while (cab().MainCtrlPos < cab().MainCtrlNoPowerPos() && cab().IncMainCtrl(1)) {
|
||||
// up to neutral
|
||||
}
|
||||
test::release_brakes(cab());
|
||||
recharge();
|
||||
charged = cab().PipePress > 4.5;
|
||||
}
|
||||
// the pipe charged again after an emergency stop: the Elf locks its emptied pipe off the brake handle (LPOn,
|
||||
// LPOff) until the unlock button (UBB1, the first universal brake button) is held, the handle at running
|
||||
void recharge() {
|
||||
cab().BrakeLevelSet(cab().Handle->GetPos(bh_RP));
|
||||
cab().UniversalBrakeButton(0, 1);
|
||||
wait(30.0);
|
||||
cab().UniversalBrakeButton(0, 0);
|
||||
wait(30.0);
|
||||
}
|
||||
TMoverParameters &cab() { return unit[0].mover(); }
|
||||
TMoverParameters &car(std::size_t Index) { return unit[Index].mover(); }
|
||||
// the driver moves the controller notch by notch, which the cab sends on to the coupled vehicles
|
||||
void set_controller(int Position) {
|
||||
while (cab().MainCtrlPos < Position && cab().IncMainCtrl(1)) {
|
||||
}
|
||||
while (cab().MainCtrlPos > Position && cab().DecMainCtrl(1)) {
|
||||
}
|
||||
}
|
||||
void wait(double Seconds) { test::drive(test::driving(unit), line, Seconds); }
|
||||
test::consist unit;
|
||||
test::track line{0.15, 0.0, test::catenary_3kv};
|
||||
bool ready{false};
|
||||
bool charged{false};
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("elf controller: without EIMCtrlMainEmergency the positions stay as they were") {
|
||||
elf unit{false};
|
||||
REQUIRE(unit.ready);
|
||||
REQUIRE(unit.charged);
|
||||
auto &mover{unit.cab()};
|
||||
CHECK_FALSE(mover.EIMCtrlMainEmergency);
|
||||
CHECK(mover.EIMCtrlEmergencyPositions() == 0);
|
||||
CHECK(mover.MainCtrlPosNo == 4);
|
||||
CHECK(mover.MainCtrlNoPowerPos() == 3);
|
||||
CHECK(mover.MainCtrlPos == 3);
|
||||
// the lowest position brakes fully, without emptying the pipe
|
||||
mover.MainCtrlPos = 0;
|
||||
CHECK_FALSE(mover.IsMainCtrlEmergencyPos());
|
||||
unit.wait(10.0);
|
||||
CHECK(mover.eimic == doctest::Approx(-1.0));
|
||||
CHECK(mover.PipePress > 4.5);
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: EIMCtrlMainEmergency shifts the positions up by the emergency brake one") {
|
||||
elf unit{true};
|
||||
REQUIRE(unit.ready);
|
||||
REQUIRE(unit.charged);
|
||||
auto &mover{unit.cab()};
|
||||
CHECK(mover.EIMCtrlMainEmergency);
|
||||
CHECK(mover.EIMCtrlEmergencyPositions() == 1);
|
||||
CHECK(mover.MainCtrlPosNo == 5);
|
||||
CHECK(mover.MainCtrlNoPowerPos() == 4);
|
||||
CHECK(mover.MainCtrlPos == 4);
|
||||
CHECK_FALSE(mover.IsMainCtrlEmergencyPos());
|
||||
SUBCASE("the neutral position neither drives nor brakes") {
|
||||
unit.wait(5.0);
|
||||
CHECK(mover.eimic == doctest::Approx(0.0));
|
||||
}
|
||||
SUBCASE("the full braking position, formerly 0, brakes fully without emptying the pipe") {
|
||||
mover.MainCtrlPos = 1;
|
||||
unit.wait(10.0);
|
||||
CHECK(mover.eimic == doctest::Approx(-1.0));
|
||||
CHECK(mover.PipePress > 4.5);
|
||||
}
|
||||
SUBCASE("the braking position, formerly 1, ramps the braking up") {
|
||||
mover.MainCtrlPos = 2;
|
||||
unit.wait(1.0);
|
||||
CHECK(mover.eimic < 0.0);
|
||||
CHECK(mover.eimic > -1.0);
|
||||
CHECK(mover.PipePress > 4.5);
|
||||
}
|
||||
SUBCASE("the emergency brake position brakes fully at once and empties the pipe") {
|
||||
mover.MainCtrlPos = 0;
|
||||
CHECK(mover.IsMainCtrlEmergencyPos());
|
||||
// a single step of the physics
|
||||
unit.unit.step(unit.line);
|
||||
CHECK(mover.eimic == doctest::Approx(-1.0));
|
||||
unit.wait(10.0);
|
||||
CHECK(mover.PipePress < 0.5);
|
||||
CHECK(mover.BrakePress > 1.0);
|
||||
// out of it the pipe charges again
|
||||
mover.MainCtrlPos = mover.MainCtrlNoPowerPos();
|
||||
CHECK_FALSE(mover.IsMainCtrlEmergencyPos());
|
||||
unit.recharge();
|
||||
CHECK(mover.PipePress > 4.5);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: EIMCtrlMainEmergency with the old MCPN gets its positions all the same") {
|
||||
vehicle car{definition::fiz("elf_v1/21we-a").set("Cntrl", "EIMCtrlMainEmergency", "Yes")};
|
||||
CHECK(car->MainCtrlPosNo == 5);
|
||||
CHECK(car->MainCtrlNoPowerPos() == 4);
|
||||
// DirChangeMaxPos=3 of the file, the old neutral, moves up with the positions
|
||||
CHECK(car->MainCtrlMaxDirChangePos == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: EIMCtrlMainEmergency leaves DirChangeMaxPos of the files updated for it alone") {
|
||||
vehicle car{definition::fiz("elf_v1/21we-a").set("Cntrl", "EIMCtrlMainEmergency", "Yes").set("Cntrl", "MCPN", 5).set("Cntrl", "DirChangeMaxPos", 4)};
|
||||
CHECK(car->MainCtrlPosNo == 5);
|
||||
CHECK(car->MainCtrlMaxDirChangePos == 4);
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: the reverser works at the neutral shifted by EIMCtrlMainEmergency") {
|
||||
// the key added to the old files, DirChangeMaxPos=3 in them
|
||||
elf unit{{data::emergency_old_layout}};
|
||||
REQUIRE(unit.ready);
|
||||
auto &mover{unit.cab()};
|
||||
REQUIRE(mover.MainCtrlPos == mover.MainCtrlNoPowerPos());
|
||||
REQUIRE(mover.DirActive == 1);
|
||||
CHECK(mover.DirectionBackward());
|
||||
CHECK(mover.DirActive == 0);
|
||||
CHECK(mover.DirectionForward());
|
||||
CHECK(mover.DirActive == 1);
|
||||
// not in the power position
|
||||
unit.set_controller(mover.MainCtrlNoPowerPos() + 1);
|
||||
REQUIRE(mover.MainCtrlPos == 5);
|
||||
CHECK_FALSE(mover.DirectionBackward());
|
||||
CHECK(mover.DirActive == 1);
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: the emergency brake position vents the pipe only from the vehicle driven from") {
|
||||
elf unit{true};
|
||||
REQUIRE(unit.ready);
|
||||
REQUIRE(unit.charged);
|
||||
// the rear car, with its own cab, has its controller in the emergency brake position, the driven one not
|
||||
auto &rear{unit.car(2)};
|
||||
rear.MainCtrlPos = 0;
|
||||
CHECK(rear.IsMainCtrlEmergencyPos());
|
||||
CHECK_FALSE(rear.IsCabMaster());
|
||||
unit.wait(10.0);
|
||||
CHECK(unit.cab().PipePress > 4.5);
|
||||
CHECK(rear.PipePress > 4.5);
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: an Elf with the emergency brake position leading one without it") {
|
||||
elf unit{{data::emergency, data::plain}};
|
||||
REQUIRE(unit.ready);
|
||||
REQUIRE(unit.charged);
|
||||
auto &lead{unit.cab()};
|
||||
auto &other{unit.car(3)};
|
||||
REQUIRE_FALSE(other.EIMCtrlMainEmergency);
|
||||
// neutral of the lead is neutral of the other
|
||||
CHECK(lead.MainCtrlPos == 4);
|
||||
CHECK(other.MainCtrlPos == other.MainCtrlNoPowerPos());
|
||||
SUBCASE("power") {
|
||||
unit.set_controller(5);
|
||||
CHECK(other.MainCtrlPos == 4);
|
||||
}
|
||||
SUBCASE("full braking") {
|
||||
unit.set_controller(1);
|
||||
CHECK(other.MainCtrlPos == 0);
|
||||
unit.wait(10.0);
|
||||
CHECK(lead.PipePress > 4.5);
|
||||
}
|
||||
SUBCASE("the emergency brake: the other one at its full braking, the pipe vented by the lead") {
|
||||
unit.set_controller(0);
|
||||
REQUIRE(lead.IsMainCtrlEmergencyPos());
|
||||
CHECK(other.MainCtrlPos == 0);
|
||||
unit.wait(10.0);
|
||||
CHECK(lead.PipePress < 0.5);
|
||||
CHECK(other.PipePress < 0.5);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: an Elf without the emergency brake position leading one with it") {
|
||||
elf unit{{data::plain, data::emergency}};
|
||||
REQUIRE(unit.ready);
|
||||
REQUIRE(unit.charged);
|
||||
auto &lead{unit.cab()};
|
||||
auto &other{unit.car(3)};
|
||||
REQUIRE(other.EIMCtrlMainEmergency);
|
||||
CHECK(lead.MainCtrlPos == 3);
|
||||
CHECK(other.MainCtrlPos == other.MainCtrlNoPowerPos());
|
||||
SUBCASE("power") {
|
||||
unit.set_controller(4);
|
||||
CHECK(other.MainCtrlPos == 5);
|
||||
}
|
||||
SUBCASE("the full braking of the lead is the full braking of the other, not its emergency brake") {
|
||||
unit.set_controller(0);
|
||||
CHECK(other.MainCtrlPos == 1);
|
||||
CHECK_FALSE(other.IsMainCtrlEmergencyPos());
|
||||
unit.wait(10.0);
|
||||
CHECK(lead.PipePress > 4.5);
|
||||
CHECK(other.PipePress > 4.5);
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE("elf controller: EIMCtrlMainEmergency leaves the other controllers alone") {
|
||||
// the Impuls (EIMCtrlType 0) has its emergency brake in the brake range of its controller (EIMCtrlEmergency)
|
||||
vehicle impuls{definition::fiz("impuls_v1/31we-a_pr").set("Cntrl", "EIMCtrlMainEmergency", "Yes"), 60.0, "impuls", 1};
|
||||
CHECK(impuls->EIMCtrlEmergencyPositions() == 0);
|
||||
CHECK(impuls->MainCtrlPosNo == 10);
|
||||
impuls->MainCtrlPos = 0;
|
||||
CHECK_FALSE(impuls->IsMainCtrlEmergencyPos());
|
||||
}
|
||||
@@ -3255,9 +3255,11 @@ bool TController::IncBrakeEIM()
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
OK = mvOccupied->MainCtrlPos > 1;
|
||||
// the braking position, above the emergency brake one where the controller has it
|
||||
auto const brakepos{1 + mvOccupied->EIMCtrlEmergencyPositions()};
|
||||
OK = mvOccupied->MainCtrlPos > brakepos;
|
||||
if( OK )
|
||||
mvOccupied->MainCtrlPos = 1;
|
||||
mvOccupied->MainCtrlPos = brakepos;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
@@ -3423,9 +3425,10 @@ bool TController::DecBrakeEIM()
|
||||
break;
|
||||
}
|
||||
case 2: {
|
||||
OK = mvOccupied->MainCtrlPos < 3;
|
||||
auto const neutralpos{mvOccupied->MainCtrlNoPowerPos()};
|
||||
OK = mvOccupied->MainCtrlPos < neutralpos;
|
||||
if( OK )
|
||||
mvOccupied->MainCtrlPos = 3;
|
||||
mvOccupied->MainCtrlPos = neutralpos;
|
||||
break;
|
||||
}
|
||||
case 3: {
|
||||
@@ -3786,12 +3789,14 @@ bool TController::IncSpeedEIM() {
|
||||
}
|
||||
*/
|
||||
break;
|
||||
case 2:
|
||||
OK = mvControlling->MainCtrlPos < 4;
|
||||
case 2: {
|
||||
auto const powerpos{4 + mvControlling->EIMCtrlEmergencyPositions()};
|
||||
OK = mvControlling->MainCtrlPos < powerpos;
|
||||
if( OK ) {
|
||||
mvControlling->MainCtrlPos = 4;
|
||||
mvControlling->MainCtrlPos = powerpos;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
return OK;
|
||||
}
|
||||
@@ -3819,9 +3824,10 @@ bool TController::DecSpeedEIM( int const Amount )
|
||||
mvControlling->SpeedCtrlPowerDec();
|
||||
}
|
||||
else {
|
||||
OK = mvControlling->MainCtrlPos > 2;
|
||||
auto const holdpos{2 + mvControlling->EIMCtrlEmergencyPositions()};
|
||||
OK = mvControlling->MainCtrlPos > holdpos;
|
||||
if( OK ) {
|
||||
mvControlling->MainCtrlPos = 2;
|
||||
mvControlling->MainCtrlPos = holdpos;
|
||||
}
|
||||
}
|
||||
break;
|
||||
@@ -4294,8 +4300,9 @@ void TController::CheckTimeControllers()
|
||||
}
|
||||
else if (mvOccupied->EIMCtrlType == 2) //elf
|
||||
{
|
||||
if (mvOccupied->eimic > 0) mvOccupied->MainCtrlPos = 3;
|
||||
if (mvOccupied->eimic < 0) mvOccupied->MainCtrlPos = 2;
|
||||
auto const emergencypositions{mvOccupied->EIMCtrlEmergencyPositions()};
|
||||
if (mvOccupied->eimic > 0) mvOccupied->MainCtrlPos = 3 + emergencypositions;
|
||||
if (mvOccupied->eimic < 0) mvOccupied->MainCtrlPos = 2 + emergencypositions;
|
||||
}
|
||||
}
|
||||
//4. Check Speed Control System
|
||||
|
||||
@@ -3293,7 +3293,8 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
|
||||
auto eimic = std::min(MoverParameters->eimic, MoverParameters->eimicSpeedCtrl);
|
||||
MoverParameters->eimic_real = eimic;
|
||||
if (MoverParameters->EIMCtrlType == 2 && MoverParameters->MainCtrlPos == 0)
|
||||
// Elf: full braking at once in the lowest position, and in the emergency brake position below it
|
||||
if (MoverParameters->EIMCtrlType == 2 && MoverParameters->MainCtrlPos <= MoverParameters->EIMCtrlEmergencyPositions())
|
||||
eimic = -1.0;
|
||||
MoverParameters->SendCtrlToNext("EIMIC", std::max(0., eimic), MoverParameters->CabActive);
|
||||
auto LBR = std::max(-eimic, 0.);
|
||||
|
||||
Reference in New Issue
Block a user