mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 13:26:08 +01:00
feat(cab): 401Da oil pump lamp and slotted speedometer lever (eu07/maszyna#546) (#261)
* feat: 401da oil pump lamp and slotted lever animation (eu07/maszyna#546) i-oilpump lights while the pre-lubrication oil pump works, so it goes off once the engine runs. animslottedlever: in the .mmd turns a lever by a pin on the coupling rod sliding in the lever's slot, which the speedometer drive of 401Da needs. The compressor start delay of #546 came with CompressorStartDelay (Brake section) of master. * fix: force GLM AVX2 only when the compiler targets AVX2 ENABLE_AVX2=OFF left GLM_FORCE_AVX2 defined, so MSVC still emitted AVX2 intrinsics and the exe crashed on CPUs without AVX2. * test: cover the compressor start delay and the oil pump lamp The delay of an engine stopped before it passed starts over, a compressor switched on by hand waits too, and the key is read from the Brake section. In the converter-fed set-up of 401Da the compressor waits for ConverterStartDelay and then its own delay. The oil pump (i-oilpump lamp) works before the engine start and stops once the engine runs.
This commit is contained in:
@@ -113,3 +113,93 @@ TEST_CASE("compressor: without a pressure switch the air over the cut-out pressu
|
||||
REQUIRE(vehicle->CompressorFlag); // nothing stops it
|
||||
CHECK(vehicle->CompressedVolume < 8.5 * 0.81); // a fifth of the air let out
|
||||
}
|
||||
|
||||
TEST_CASE("compressor: an engine stopped before the delay passed counts the whole delay again") {
|
||||
auto vehicle{compressor_vehicle(30.0)};
|
||||
vehicle->Mains = true; // engine started
|
||||
run_compressor(vehicle, 20.0);
|
||||
REQUIRE_FALSE(vehicle->CompressorFlag);
|
||||
|
||||
vehicle->Mains = false; // engine stopped, 10 s short of the delay
|
||||
run_compressor(vehicle, 1.0);
|
||||
vehicle->Mains = true;
|
||||
run_compressor(vehicle, 15.0); // 36 s since the first start, but only 15 s since this one
|
||||
CHECK_FALSE(vehicle->CompressorFlag);
|
||||
|
||||
run_compressor(vehicle, 15.1);
|
||||
CHECK(vehicle->CompressorFlag);
|
||||
}
|
||||
|
||||
TEST_CASE("compressor: the start delay holds back a compressor switched on by hand too") {
|
||||
auto vehicle{compressor_vehicle(30.0)};
|
||||
vehicle->CompressorStart = start_t::manual;
|
||||
vehicle->CompressorAllow = true; // switch in the cabinet on before the engine start
|
||||
vehicle->Mains = true;
|
||||
|
||||
run_compressor(vehicle, 29.9);
|
||||
CHECK_FALSE(vehicle->CompressorFlag);
|
||||
run_compressor(vehicle, 0.2);
|
||||
CHECK(vehicle->CompressorFlag);
|
||||
}
|
||||
|
||||
TEST_CASE("compressor: the start delay is read from the brake section") {
|
||||
auto const delay{[](std::string const &Section) {
|
||||
return vehicle{definition::load("wagon").set(Section, "CompressorStartDelay", 30)}->CompressorStartDelay;
|
||||
}};
|
||||
CHECK(delay("Brake") == doctest::Approx(30.0));
|
||||
CHECK(delay("Cntrl") == doctest::Approx(0.0)); // the key isn't taken from the control section
|
||||
}
|
||||
|
||||
namespace {
|
||||
|
||||
// 401Da: the compressor runs from the 110 V of the auxiliary generator driven by the engine, here the converter
|
||||
// started with the main circuit, which gets up to voltage the converter start delay after the engine start
|
||||
definition generator_vehicle(double const ConverterDelay, double const CompressorDelay) {
|
||||
return definition::load("cab_vehicle")
|
||||
.set("Param", "PWR", 370)
|
||||
.set("Light", "Light", "Generator")
|
||||
.set("Light", "LMaxVoltage", 110)
|
||||
.set("Brake", "Vv", 0.6)
|
||||
.set("Brake", "MinCP", 6.5)
|
||||
.set("Brake", "MaxCP", 8.0)
|
||||
.set("Brake", "CompressorSpeed", 0.003)
|
||||
.set("Brake", "CompressorPower", "Converter")
|
||||
.set("Brake", "CompressorStartDelay", CompressorDelay)
|
||||
.set("Cntrl", "CompressorStart", "Automatic")
|
||||
.set("Cntrl", "ConverterStart", "Automatic")
|
||||
.set("Cntrl", "ConverterStartDelay", ConverterDelay);
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
||||
TEST_CASE("compressor: fed from the converter it waits for the converter start delay") {
|
||||
vehicle loco{generator_vehicle(30.0, 0.0)};
|
||||
REQUIRE(loco->CompressorPower == 2);
|
||||
REQUIRE(loco->ConverterStartDelay == doctest::Approx(30.0));
|
||||
|
||||
loco.run(1.0); // engine off
|
||||
CHECK_FALSE(loco->Power110vIsAvailable);
|
||||
|
||||
loco->Mains = true; // engine started
|
||||
loco.run(25.0);
|
||||
CHECK_FALSE(loco->Power110vIsAvailable);
|
||||
CHECK_FALSE(loco->CompressorFlag);
|
||||
|
||||
loco.run(10.0);
|
||||
CHECK(loco->Power110vIsAvailable);
|
||||
CHECK(loco->CompressorFlag);
|
||||
}
|
||||
|
||||
TEST_CASE("compressor: fed from the converter the start delay counts from the converter voltage") {
|
||||
vehicle loco{generator_vehicle(20.0, 10.0)};
|
||||
REQUIRE(loco->CompressorStartDelay == doctest::Approx(10.0));
|
||||
|
||||
loco.run(1.0); // engine off
|
||||
loco->Mains = true; // engine started
|
||||
loco.run(25.0);
|
||||
REQUIRE(loco->Power110vIsAvailable); // the converter is up
|
||||
CHECK_FALSE(loco->CompressorFlag); // but the compressor waits for its own delay as well
|
||||
|
||||
loco.run(10.0);
|
||||
CHECK(loco->CompressorFlag);
|
||||
}
|
||||
|
||||
55
tests/unit/test_oil_pump.cpp
Normal file
55
tests/unit/test_oil_pump.cpp
Normal file
@@ -0,0 +1,55 @@
|
||||
#include "stdafx.h"
|
||||
#include "doctest.h"
|
||||
#include "vehicle.h"
|
||||
|
||||
using test::definition;
|
||||
using test::vehicle;
|
||||
|
||||
// the oil pump lamp of the cab (i-oilpump) shows OilPump.is_active: the pre-lubrication pump of 401Da, which works
|
||||
// before the engine start and stops once the engine runs and makes the oil pressure itself (eu07/maszyna#546)
|
||||
// NOTE: the test vehicle has no diesel engine, so the pump check is called the way dizel_Update() calls it
|
||||
|
||||
TEST_CASE("oil pump: the pre-lubrication pump works before the engine start and stops once the engine runs") {
|
||||
vehicle loco{definition::load("cab_vehicle").set("Cntrl", "OilStart", "Manual")};
|
||||
REQUIRE(loco->OilPump.start_type == start_t::manual);
|
||||
loco->Power24vIsAvailable = true; // battery on
|
||||
|
||||
loco->OilPumpCheck(0.01);
|
||||
CHECK_FALSE(loco->OilPump.is_active); // not switched on yet
|
||||
|
||||
loco->OilPump.is_enabled = true; // pump switch on: pre-lubrication
|
||||
loco->OilPumpCheck(0.01);
|
||||
CHECK(loco->OilPump.is_active);
|
||||
|
||||
loco->Mains = true; // engine started
|
||||
loco->OilPumpCheck(0.01);
|
||||
CHECK_FALSE(loco->OilPump.is_active);
|
||||
}
|
||||
|
||||
TEST_CASE("oil pump: the pump started with the engine start procedure stops once the engine runs") {
|
||||
vehicle loco{definition::load("cab_vehicle").set("Cntrl", "OilStart", "Automatic")};
|
||||
REQUIRE(loco->OilPump.start_type == start_t::automatic);
|
||||
loco->Power24vIsAvailable = true;
|
||||
|
||||
loco->dizel_startup = true; // starter button pressed
|
||||
loco->OilPumpCheck(0.01);
|
||||
CHECK(loco->OilPump.is_active);
|
||||
|
||||
loco->dizel_startup = false; // start procedure done, the pump keeps working until the engine runs
|
||||
loco->OilPumpCheck(0.01);
|
||||
CHECK(loco->OilPump.is_active);
|
||||
|
||||
loco->Mains = true;
|
||||
loco->OilPumpCheck(0.01);
|
||||
CHECK_FALSE(loco->OilPump.is_active);
|
||||
}
|
||||
|
||||
TEST_CASE("oil pump: without power the pump and its lamp stay off") {
|
||||
vehicle loco{definition::load("cab_vehicle")};
|
||||
loco->Power24vIsAvailable = false;
|
||||
loco->Power110vIsAvailable = false;
|
||||
|
||||
loco->OilPump.is_enabled = true;
|
||||
loco->OilPumpCheck(0.01);
|
||||
CHECK_FALSE(loco->OilPump.is_active);
|
||||
}
|
||||
Reference in New Issue
Block a user