mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-19 20:24:59 +01:00
fix: the diesel throttle marker follows the controller only with a scaletable:
A mainctrlact: without a scaletable: (the shipped ST43 cabs) keeps its marker still, as before, instead of sweeping on an unchecked linear scale. A gauge redefined in the fixed form drops the scaletable: of its earlier definition.
This commit is contained in:
@@ -79,7 +79,7 @@ TEST_CASE("gauge scale: two points of the same value make a step") {
|
|||||||
CHECK(gauge_scale::interpolate(table.points, 1.5f) == doctest::Approx(0.55));
|
CHECK(gauge_scale::interpolate(table.points, 1.5f) == doctest::Approx(0.55));
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("main ctrl act: the marker of a diesel locomotive follows its controller (MaSzyna-EU07/maszyna#74)") {
|
TEST_CASE("main ctrl act: the marker of a diesel locomotive with a scaletable: follows its controller (MaSzyna-EU07/maszyna#74)") {
|
||||||
// nothing sets the actual position of a diesel engine's controller, the marker stayed at 0
|
// nothing sets the actual position of a diesel engine's controller, the marker stayed at 0
|
||||||
for (auto const *path : {"st44_v2/m62-1151", "sm42_v1/6d1", "su45_v2/301d"}) {
|
for (auto const *path : {"st44_v2/m62-1151", "sm42_v1/6d1", "su45_v2/301d"}) {
|
||||||
CAPTURE(path);
|
CAPTURE(path);
|
||||||
@@ -89,22 +89,42 @@ TEST_CASE("main ctrl act: the marker of a diesel locomotive follows its controll
|
|||||||
REQUIRE(locomotive.EIMCtrlType == 0);
|
REQUIRE(locomotive.EIMCtrlType == 0);
|
||||||
locomotive.MainCtrlPos = 5;
|
locomotive.MainCtrlPos = 5;
|
||||||
CHECK(locomotive.MainCtrlActualPos == 0);
|
CHECK(locomotive.MainCtrlActualPos == 0);
|
||||||
CHECK(main_ctrl_act::position(locomotive) == doctest::Approx(5.0));
|
CHECK(main_ctrl_act::position(locomotive, true) == doctest::Approx(5.0));
|
||||||
// one with a controller of the EIM kind keeps its actual position itself
|
// one with a controller of the EIM kind keeps its actual position itself
|
||||||
locomotive.EIMCtrlType = 2;
|
locomotive.EIMCtrlType = 2;
|
||||||
CHECK(main_ctrl_act::position(locomotive) == doctest::Approx(0.0));
|
CHECK(main_ctrl_act::position(locomotive, true) == doctest::Approx(0.0));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("main ctrl act: the marker of a diesel locomotive without a scaletable: stays still, as before") {
|
||||||
|
// the shipped ST43 cabs define mainctrlact: with a linear scale nobody has seen working; it is not opted in
|
||||||
|
for (auto const *path : {"st44_v2/m62-1151", "sm42_v1/6d1", "su45_v2/301d"}) {
|
||||||
|
CAPTURE(path);
|
||||||
|
consist train;
|
||||||
|
auto &locomotive{train.add(definition::fiz(path), 1).mover()};
|
||||||
|
REQUIRE(locomotive.EIMCtrlType == 0);
|
||||||
|
locomotive.MainCtrlPos = 5;
|
||||||
|
locomotive.ScndCtrlPos = 1;
|
||||||
|
for (auto const coupled : {false, true}) {
|
||||||
|
CAPTURE(coupled);
|
||||||
|
locomotive.CoupledCtrl = coupled;
|
||||||
|
CHECK(main_ctrl_act::position(locomotive, false) == doctest::Approx(0.0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_CASE("main ctrl act: the marker of an electric locomotive shows its actual position, as before") {
|
TEST_CASE("main ctrl act: the marker of an electric locomotive shows its actual position, as before") {
|
||||||
consist train;
|
for (auto const scaletable : {false, true}) {
|
||||||
auto &locomotive{train.add(definition::fiz("et22_v3/201e-w"), 1).mover()};
|
CAPTURE(scaletable);
|
||||||
locomotive.MainCtrlPos = 10;
|
consist train;
|
||||||
locomotive.MainCtrlActualPos = 3;
|
auto &locomotive{train.add(definition::fiz("et22_v3/201e-w"), 1).mover()};
|
||||||
locomotive.ScndCtrlPos = 2;
|
locomotive.MainCtrlPos = 10;
|
||||||
locomotive.ScndCtrlActualPos = 1;
|
locomotive.MainCtrlActualPos = 3;
|
||||||
locomotive.CoupledCtrl = false;
|
locomotive.ScndCtrlPos = 2;
|
||||||
CHECK(main_ctrl_act::position(locomotive) == doctest::Approx(3.0));
|
locomotive.ScndCtrlActualPos = 1;
|
||||||
locomotive.CoupledCtrl = true;
|
locomotive.CoupledCtrl = false;
|
||||||
CHECK(main_ctrl_act::position(locomotive) == doctest::Approx(4.0));
|
CHECK(main_ctrl_act::position(locomotive, scaletable) == doctest::Approx(3.0));
|
||||||
|
locomotive.CoupledCtrl = true;
|
||||||
|
CHECK(main_ctrl_act::position(locomotive, scaletable) == doctest::Approx(4.0));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -112,6 +112,8 @@ void TGauge::Load( cParser &Parser, TDynamicObject const *Owner, double const mu
|
|||||||
Parser.getTokens();
|
Parser.getTokens();
|
||||||
if( Parser.peek() != "{" ) {
|
if( Parser.peek() != "{" ) {
|
||||||
// old fixed size config
|
// old fixed size config
|
||||||
|
// it has no scaletable:, drop the one of an earlier definition of the same control
|
||||||
|
m_scaletable.clear();
|
||||||
Parser >> submodelname;
|
Parser >> submodelname;
|
||||||
gaugetypename = Parser.getToken<std::string>( true );
|
gaugetypename = Parser.getToken<std::string>( true );
|
||||||
Parser.getTokens( 3, false );
|
Parser.getTokens( 3, false );
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ public:
|
|||||||
return ( static_cast<int>( type() ) & static_cast<int>( TGaugeType::toggle ) ) != 0; }
|
return ( static_cast<int>( type() ) & static_cast<int>( TGaugeType::toggle ) ) != 0; }
|
||||||
bool is_delayed() const {
|
bool is_delayed() const {
|
||||||
return ( static_cast<int>( type() ) & static_cast<int>( TGaugeType::delayed ) ) != 0; }
|
return ( static_cast<int>( type() ) & static_cast<int>( TGaugeType::delayed ) ) != 0; }
|
||||||
|
// true if the gauge was given a non-uniform scale (scaletable:)
|
||||||
|
bool has_scaletable() const {
|
||||||
|
return false == m_scaletable.empty(); }
|
||||||
// members
|
// members
|
||||||
TSubModel *SubModel { nullptr }; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie
|
TSubModel *SubModel { nullptr }; // McZapkie-310302: zeby mozna bylo sprawdzac czy zainicjowany poprawnie
|
||||||
TSubModel *SubModelOn { nullptr }; // optional submodel visible when the state input is set
|
TSubModel *SubModelOn { nullptr }; // optional submodel visible when the state input is set
|
||||||
|
|||||||
@@ -9337,7 +9337,7 @@ bool TTrain::Update(double const Deltatime)
|
|||||||
}
|
}
|
||||||
if (ggMainCtrlAct.SubModel != nullptr)
|
if (ggMainCtrlAct.SubModel != nullptr)
|
||||||
{
|
{
|
||||||
ggMainCtrlAct.UpdateValue(main_ctrl_act::position(*mvControlled));
|
ggMainCtrlAct.UpdateValue(main_ctrl_act::position(*mvControlled, ggMainCtrlAct.has_scaletable()));
|
||||||
ggMainCtrlAct.Update();
|
ggMainCtrlAct.Update();
|
||||||
}
|
}
|
||||||
if (ggScndCtrl.SubModel != nullptr)
|
if (ggScndCtrl.SubModel != nullptr)
|
||||||
|
|||||||
@@ -21,8 +21,11 @@ inline bool follows_controller(TMoverParameters const &Vehicle) {
|
|||||||
return (Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric) && Vehicle.EIMCtrlType == 0;
|
return (Vehicle.EngineType == TEngineType::DieselEngine || Vehicle.EngineType == TEngineType::DieselElectric) && Vehicle.EIMCtrlType == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
inline float position(TMoverParameters const &Vehicle) {
|
// Scaletable: the cab's gauge has a scaletable:. only such a marker follows the controller; the cabs that define
|
||||||
auto const controller{follows_controller(Vehicle)};
|
// mainctrlact: without one (the ST43 so far) keep their marker still, as before, instead of moving it on a scale
|
||||||
|
// nobody has checked
|
||||||
|
inline float position(TMoverParameters const &Vehicle, bool const Scaletable) {
|
||||||
|
auto const controller{Scaletable && follows_controller(Vehicle)};
|
||||||
auto const main{controller ? Vehicle.MainCtrlPos : Vehicle.MainCtrlActualPos};
|
auto const main{controller ? Vehicle.MainCtrlPos : Vehicle.MainCtrlActualPos};
|
||||||
auto const scnd{controller ? Vehicle.ScndCtrlPos : Vehicle.ScndCtrlActualPos};
|
auto const scnd{controller ? Vehicle.ScndCtrlPos : Vehicle.ScndCtrlActualPos};
|
||||||
return static_cast<float>(Vehicle.CoupledCtrl ? main + scnd : main);
|
return static_cast<float>(Vehicle.CoupledCtrl ? main + scnd : main);
|
||||||
|
|||||||
Reference in New Issue
Block a user