mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-11-24 15:29:14 +01:00
* fix(ai): an uphill start keeps the power on until the train brake is off The uphill start of #265 ended as soon as the power held the train (or the head of the train moved back 0.5 km/h). From then on the brake still on in the wagons made Ready false, the power went off, the train rolled back, was braked again and the start began anew; only the cylinders falling below 0.8 bar let the train get away. - Once the power holds the train, the start goes on while the train brake is released: Ready holds, the power stays on, bounded to 1.5 x the grade force. It ends when the consist is released (the same test as Ready, without the hold) or after 60 s. - A start is given up for rolling back on the mass-weighted speed of the consist, not on the speed of the locomotive, which runs back into the slack of the train held by its brake. - A train slipping back uphill is not released by the rule for a train to go on. * fix(ai): an uphill start begins only with the whole train at a stand * fix(ai): an uphill start applies the train brake further while it doesn't hold the train without the locomotive brake * fix(ai): the speed and the tractive force of an uphill start in the direction of travel also from cab 2 * fix(ai): an uphill start tops up the train brake a full application time a step, at most to full service, and keeps the power between 1.1 and 1.5 times the grade force while the brake releases * fix(ai): an uphill start no longer takes a notch back in the release phase: the notch below doesn't hold the train * refactor(ai): the train brake top-up of an uphill start in uphill_start::brake_top_up(), with unit tests
42 lines
1.9 KiB
C++
42 lines
1.9 KiB
C++
/*
|
|
This Source Code Form is subject to the
|
|
terms of the Mozilla Public License, v.
|
|
2.0. If a copy of the MPL was not
|
|
distributed with this file, You can
|
|
obtain one at
|
|
http://mozilla.org/MPL/2.0/.
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
// starting uphill (TController::control_uphill_start()), the AI's driver lets the locomotive brake off only once
|
|
// the brake of the rest of the train holds the train on its own: a train stopped on a light application stands on
|
|
// the locomotive brake too, and rolls back as soon as it is off. until then the train brake is applied further, a
|
|
// step at a time
|
|
namespace uphill_start {
|
|
|
|
auto const holding_force{1.1}; // a force that holds a train uphill, as a multiple of the grade force
|
|
auto const top_up_position{4.0}; // full service: the furthest the train brake is applied to hold the train
|
|
// a step that adds less brake force than this, as a multiple of the grade force, is the last one
|
|
auto const top_up_gain{0.02};
|
|
|
|
// what has been done to apply the train brake further, in one start
|
|
struct top_up {
|
|
double last_force{-1.0}; // the brake force when the last step was given, -1 before the first [N]
|
|
bool done{false}; // a step added next to nothing: no more of them in this start
|
|
};
|
|
|
|
enum class top_up_action {
|
|
none, // the brake holds the train, or can't be made to: the start goes on
|
|
wait, // the cylinders are still filling after the last step
|
|
step // apply the train brake one step further
|
|
};
|
|
|
|
// Brakeforce: the brake force of the unpowered vehicles [N]; Holdingforce: the grade force on the train [N];
|
|
// Brakeposition: the train brake handle, as BrakeCtrlPosition; Heldtime: how long the handle has been where it
|
|
// is [s]; Applicationtime: the time the train brake takes to apply, for the cylinders along the train to fill [s]
|
|
top_up_action brake_top_up(
|
|
top_up &State, double Brakeforce, double Holdingforce, double Brakeposition, double Heldtime, double Applicationtime);
|
|
|
|
} // namespace uphill_start
|