18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-01 09:27:10 +01:00
Files
maszyna/tests/unit/test_radio.cpp
T
Hirek 89258eb72c refactor(physics): the low voltage, the train heating and the electrodynamic brake as components
The rest of the electrics of physics::Vehicle beside the traction motors
becomes components, with English names:

  lowVoltage (LowVoltageSupply,   Battery batteryOn, BatteryVoltage,
  physics/components/lowvoltage.h) NominalBatteryVoltage, BatteryStart,
                                  Power110vIsAvailable / Power24vIsAvailable /
                                  Power24vVoltage power110vAvailable /
                                  power24vAvailable / power24vVoltage, the
                                  battery button of the cab: batteryButtonFired,
                                  batteryButtonImpulse, batteryButtonHeld,
                                  batteryButtonHoldTime
  trainHeating (TrainHeating)     Heating on, HeatingAllow allow,
                                  HeatingSwitchImpulse switchImpulse,
                                  HeatingPower power, EngineHeatingRPM engineRpm
  brakes.electrodynamic           the DynamicBrake* fields: type, ammeters,
  (ElectrodynamicBrake,           controllerPositions, controllerPosition,
  physics/components/braking.h)   resistance(1, 2), on, emuWorking;
                                  SplitEDPneumaticBrake splitFromPneumatic;
                                  the fans of the braking resistor (BRVentilators,
                                  BRVto, BRVtimer, Imaxrpc): resistorFansRunning,
                                  resistorFansSustain, resistorFansTimer,
                                  resistorPassiveMaxCurrent

The diesel-electric dynamic brake (DEDynamicBrake) and the currents of the
traction circuit (Im, Itot, EngineVoltage ...) stay for the traction stage.

No string literal changed (checked over all the changed files).

No change in behaviour: 1149/1149 tests, golden traces exact against staging
62f7a29b.
2026-11-29 03:15:56 +01:00

59 lines
2.0 KiB
C++

#include "stdafx.h"
#include "doctest.h"
#include "vehicle.h"
// the radio works only switched on and with the low voltage (eu07/maszyna#429): its channel and volume buttons,
// the calls and the radio-stop all ask RadioPowered()
TEST_CASE("radio: a radio switched on with the low voltage works") {
test::vehicle vehicle{test::definition::load("wagon")};
vehicle->Radio = true;
SUBCASE("24 V") { vehicle->lowVoltage.power24vAvailable = true; }
SUBCASE("110 V") { vehicle->lowVoltage.power110vAvailable = true; }
CHECK(vehicle->RadioPowered());
}
TEST_CASE("radio: a radio switched off or without the low voltage doesn't") {
test::vehicle vehicle{test::definition::load("wagon")};
SUBCASE("switched off") {
vehicle->Radio = false;
vehicle->lowVoltage.power24vAvailable = true;
}
SUBCASE("batteries off") {
vehicle->Radio = true;
vehicle->lowVoltage.power24vAvailable = false;
vehicle->lowVoltage.power110vAvailable = false;
}
CHECK_FALSE(vehicle->RadioPowered());
}
// the cut-off in the radio's power supply (eu07/maszyna#438): a fuse, a desk lever or the switch on the radio's
// power supply, closed unless the driver opens it
TEST_CASE("radio: the radio fuse is closed by default") {
test::vehicle vehicle{test::definition::load("wagon")};
CHECK(vehicle->RadioFuse);
}
TEST_CASE("radio: an opened radio fuse cuts the radio off") {
test::vehicle vehicle{test::definition::load("wagon")};
vehicle->Radio = true;
vehicle->lowVoltage.power24vAvailable = true;
vehicle->RadioFuse = false;
CHECK_FALSE(vehicle->RadioPowered());
vehicle->RadioFuse = true;
CHECK(vehicle->RadioPowered());
}
TEST_CASE("radio: opening the radio fuse at a standstill resets the radio-stop, as switching the radio off does") {
test::vehicle loco{test::definition::fiz("4e_v1/4e")};
loco->lowVoltage.batteryOn = true;
loco->Radio = true;
REQUIRE(loco->RadiostopSwitch(true));
loco->SecuritySystemCheck(0.1);
CHECK(loco->RadioStopFlag);
loco->RadioFuse = false;
loco->SecuritySystemCheck(0.1);
CHECK_FALSE(loco->RadioStopFlag);
}