18
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-12-02 15:26:53 +01:00

refactor(physics): the faults of the equipment are a named set the physics sets

The faults the scenery or the network sets on a vehicle (TDynamicObject::
Damage() with the number of a message, held as EngDmgFlag and tested as its
bits 1, 4) are EquipmentFault and EquipmentFaultSet, and what each does moves
out of TDynamicObject into physics::Vehicle::SetEquipmentFaults(). The number of
a message comes in through FromBits() and goes back out through Bits(), as it
was.

The faults of the control and of the camshaft still hold the start and the
steps of the controller by delays moved out of reach by 100000001 and back,
the very same arithmetic, now named and in one place. Tests of it are added
(test_equipment_faults.cpp), as nothing reached it before.

The setters of the parts that took a parameter named as one of their queries
(Pressure, Voltage) take Value instead.

No change in behaviour: the golden traces recorded on dfb43c4f match bit for bit.
This commit is contained in:
2026-11-29 10:56:17 +01:00
parent d28b908ca4
commit 6b9558f588
12 changed files with 140 additions and 76 deletions
+44
View File
@@ -1300,3 +1300,47 @@ namespace simulation
weights_table Weights;
} // namespace simulation
void physics::Vehicle::SetEquipmentFaults(EquipmentFaultSet const Faults)
{
if (Faults.HasAll(EquipmentFault::differentialRelay)) // różnicówka nie robi nic
{
MainSwitch(false);
FuseOff();
}
// the faults of the control and of the camshaft hold the start, or the steps of the controller, by delays that never
// pass: the delays of the definition moved out of reach, and back when the fault clears
constexpr double faultoffset{100000001};
constexpr double faultthreshold{100000000};
if (Faults.HasAll(EquipmentFault::control)) // usterka sterowania
{
lineContactors.Open();
if (InitialCtrlDelay < faultthreshold)
InitialCtrlDelay += faultoffset;
}
else if (InitialCtrlDelay > faultthreshold)
{
InitialCtrlDelay -= faultoffset;
}
if (Faults.HasAll(EquipmentFault::converter) && converter.config.start != start_t::disabled) // blokada przetwornicy
{
converter.Overload();
}
air.compressor.SetFault(Faults.HasAll(EquipmentFault::compressor)); // blokada sprezarki
if (Faults.HasAll(EquipmentFault::camshaft)) // blokada wału
{
if (CtrlDelay < faultthreshold)
CtrlDelay += faultoffset;
if (CtrlDownDelay < faultthreshold)
CtrlDownDelay += faultoffset;
}
else
{
if (CtrlDelay > faultthreshold)
CtrlDelay -= faultoffset;
if (CtrlDownDelay > faultthreshold)
CtrlDownDelay -= faultoffset;
}
// hamowanie nagłe (emergencyBrake): nothing yet
equipmentFaults = Faults;
}