mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-12-02 02:42:46 +01:00
refactor(physics): the revolutions of the engine and the steps of the master controller in the drives
Two more switches on EngineType go into the classes of the drives:
- TractionDrive::UpdateEngineRevolutions(): the diesel-electric engine
follows the revolutions it aims for, the diesel engine with a mechanical
transmission gives its ratio and its moment, the others turn with the
wheels (UpdateEngineRevolutions() before)
- TractionDrive::IncreaseMainController(), DecreaseMainController(): a notch
of the master controller as the kind of the engine takes it: the series
motors through their own steps, the diesel engine running to the end at
a fast step, the draisine by a push, the others one position at a time
(IncMainCtrlByEngine(), DecMainCtrlByEngine() before)
NoDrive splits in two: NoEngineDrive for a vehicle without an engine (its
controller steps, for the vehicles it controls) and UnmodelledDrive for the
steam engine and Main, which did nothing in these steps and still don't.
No change in behaviour: 1144/1144 tests, golden traces exact against staging
62f7a29b.
This commit is contained in:
@@ -28,6 +28,7 @@ http://mozilla.org/MPL/2.0/.
|
||||
#include <utility>
|
||||
#include <vector>
|
||||
#include "physics/components/internal.h"
|
||||
#include "physics/components/drive.h"
|
||||
|
||||
|
||||
// *************************************************************************************************
|
||||
@@ -108,62 +109,7 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
|
||||
// a notch up, as the kind of the engine takes it; returns whether the controller moved
|
||||
bool TMoverParameters::IncMainCtrlByEngine(int const CtrlSpeed)
|
||||
{
|
||||
bool OK = false;
|
||||
switch (EngineType)
|
||||
{
|
||||
case TEngineType::None:
|
||||
case TEngineType::Dumb:
|
||||
case TEngineType::DieselElectric:
|
||||
case TEngineType::ElectricInductionMotor:
|
||||
{
|
||||
if (CtrlSpeed > 1)
|
||||
{
|
||||
OK = IncMainCtrl(1) && IncMainCtrl(CtrlSpeed - 1); // a fail will propagate up the recursion chain. should this be || instead?
|
||||
break;
|
||||
}
|
||||
++MainCtrlPos;
|
||||
OK = true;
|
||||
if (EIMCtrlType == 0 && ( SpeedCtrlAutoTurnOffFlag & 1 ) == 1 && MainCtrlActualPos != MainCtrlPos)
|
||||
{
|
||||
SpeedCtrlSwitch(false);
|
||||
SpeedCtrlUnit.IsActive = false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
case TEngineType::ElectricSeriesMotor:
|
||||
{
|
||||
OK = IncMainCtrlSeriesMotor(CtrlSpeed);
|
||||
break;
|
||||
}
|
||||
|
||||
case TEngineType::DieselEngine:
|
||||
{
|
||||
if (CtrlSpeed > 1)
|
||||
{
|
||||
while (MainCtrlPos < MainCtrlPosNo && IncMainCtrl(1))
|
||||
{
|
||||
// all work is done in the loop header
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
++MainCtrlPos;
|
||||
}
|
||||
CompressorAllow = MainCtrlPowerPos() > 0;
|
||||
OK = true;
|
||||
break;
|
||||
}
|
||||
|
||||
case TEngineType::WheelsDriven:
|
||||
{
|
||||
OK = AddPulseForce(CtrlSpeed);
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
} // switch EngineType of
|
||||
return OK;
|
||||
return Drive().IncreaseMainController(*this, CtrlSpeed);
|
||||
}
|
||||
|
||||
// a notch up of the series motors' controller: CtrlSpeed over 1 runs it to the first position without resistors;
|
||||
@@ -292,54 +238,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
|
||||
// a notch down, as the kind of the engine takes it; returns whether the controller moved
|
||||
bool TMoverParameters::DecMainCtrlByEngine(int const CtrlSpeed)
|
||||
{
|
||||
bool OK = false;
|
||||
switch (EngineType)
|
||||
{
|
||||
case TEngineType::None:
|
||||
case TEngineType::Dumb:
|
||||
case TEngineType::DieselElectric:
|
||||
case TEngineType::ElectricInductionMotor:
|
||||
{
|
||||
if (CtrlSpeed == 1)
|
||||
{
|
||||
MainCtrlPos--;
|
||||
OK = true;
|
||||
if (EIMCtrlType == 0 && (SpeedCtrlAutoTurnOffFlag & 1) == 1 && MainCtrlActualPos != MainCtrlPos)
|
||||
{
|
||||
SpeedCtrlSwitch(false);
|
||||
SpeedCtrlUnit.IsActive = false;
|
||||
}
|
||||
}
|
||||
else if (CtrlSpeed > 1)
|
||||
OK = DecMainCtrl(1) && DecMainCtrl(CtrlSpeed - 1); // CtrlSpeed-1);
|
||||
break;
|
||||
}
|
||||
|
||||
case TEngineType::ElectricSeriesMotor:
|
||||
{
|
||||
OK = DecMainCtrlSeriesMotor(CtrlSpeed);
|
||||
break;
|
||||
}
|
||||
|
||||
case TEngineType::DieselEngine:
|
||||
{
|
||||
if (CtrlSpeed == 1)
|
||||
{
|
||||
MainCtrlPos--;
|
||||
OK = true;
|
||||
}
|
||||
else if (CtrlSpeed > 1)
|
||||
{
|
||||
while (MainCtrlPos > 0 || RList[MainCtrlPos].Mn > 0)
|
||||
DecMainCtrl(1);
|
||||
OK = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
} // switch EngineType
|
||||
return OK;
|
||||
return Drive().DecreaseMainController(*this, CtrlSpeed);
|
||||
}
|
||||
|
||||
// a notch down of the series motors' controller: CtrlSpeed over 1 runs it down to the first position without resistors
|
||||
|
||||
Reference in New Issue
Block a user