mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-10-28 22:47:28 +01:00
fix(ai): end brake charging on control reservoir overcharge, charge on blocked departures
- end the charging position when the control reservoir of any vehicle, the locomotive included, rises 0.05 bar above the nominal pipe pressure - standing and unable to depart for 10 s: allow the charging position regardless of the equivalent pipe pressure and the train type
This commit is contained in:
@@ -156,7 +156,9 @@ const double HeavyCargoTrainAcceleration = 0.10;
|
||||
const double PrepareTime = 2.0; //[s] przebłyski świadomości przy odpalaniu
|
||||
const double FSOverchargePipePress = 5.2;
|
||||
const double FSOverchargeTime = 2.0;
|
||||
const double FSOverchargeCRP = 0.05;
|
||||
const double FSMaxTime = 10.0;
|
||||
const double DepartBlockedFSDelay = 10.0;
|
||||
bool WriteLogFlag = false;
|
||||
double const deltalog = 0.05; // przyrost czasu
|
||||
|
||||
@@ -6016,6 +6018,17 @@ TController::determine_consist_state() {
|
||||
&& fReady < 0.8 ) { // delikatniejszy warunek, obejmuje wszystkie wagony
|
||||
Ready = true; //żeby uznać za odhamowany
|
||||
}
|
||||
auto const departblocked {
|
||||
AIControllFlag
|
||||
&& mvOccupied->Vel < EU07_AI_NOMOVEMENT
|
||||
&& VelDesired > 0.0
|
||||
&& ( false == Ready || fReady > 0.4 ) };
|
||||
if( false == departblocked ) {
|
||||
DepartBlockedStart = -1.0;
|
||||
}
|
||||
else if( DepartBlockedStart < 0.0 ) {
|
||||
DepartBlockedStart = ElapsedTime;
|
||||
}
|
||||
// second pass, for diesel engines verify the (live) engines are fully started
|
||||
// TODO: cache presence of diesel engines in the consist, to skip this test if there isn't any
|
||||
p = pVehicles[ end::front ]; // pojazd na czole składu
|
||||
@@ -8021,8 +8034,9 @@ void TController::control_main_pipe() {
|
||||
|| mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P
|
||||
|| mvOccupied->BrakeHandle == TBrakeHandle::M394 ) {
|
||||
|
||||
if( (iDrivigFlags & moveOerlikons || true == IsCargoTrain) && BrakeCtrlPosition == gbh_RP && AbsAccS < 0.03 && AccDesired > -0.03 && VelDesired - mvOccupied->Vel > 2.0 && fReady > 0.35 &&
|
||||
mvOccupied->EqvtPipePress < 4.5 // don't charge with a risk of overcharging the main pipe
|
||||
auto const departblocked { is_departure_blocked( DepartBlockedFSDelay ) };
|
||||
if( (iDrivigFlags & moveOerlikons || true == IsCargoTrain || departblocked) && BrakeCtrlPosition == gbh_RP && AbsAccS < 0.03 && AccDesired > -0.03 && VelDesired - mvOccupied->Vel > 2.0 && fReady > 0.35 &&
|
||||
( mvOccupied->EqvtPipePress < 4.5 || departblocked ) // don't charge with a risk of overcharging the main pipe
|
||||
&& mvOccupied->Compressor >= 7.5 // don't charge without sufficient pressure in the tank
|
||||
&& BrakeChargingCooldown >= 0.0 // don't charge while cooldown is active
|
||||
&& (ActualProximityDist > 100.0 // don't charge if we're about to be braking soon
|
||||
@@ -8066,12 +8080,28 @@ void TController::update_brake_charging() {
|
||||
}
|
||||
}
|
||||
|
||||
bool TController::is_departure_blocked( double const Delay ) const {
|
||||
|
||||
return DepartBlockedStart >= 0.0
|
||||
&& ElapsedTime - DepartBlockedStart > Delay;
|
||||
}
|
||||
|
||||
double TController::consist_max_crp() const {
|
||||
|
||||
auto result { 0.0 };
|
||||
for( auto const *vehicle { pVehicles[ end::front ] }; vehicle != nullptr; vehicle = vehicle->Next() ) {
|
||||
result = std::max( result, vehicle->MoverParameters->Hamulec->GetCRP() );
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
bool TController::is_brake_charging_done() const {
|
||||
|
||||
if( BrakeChargingStart < 0.0 ) {
|
||||
return false;
|
||||
}
|
||||
return ElapsedTime - BrakeChargingStart > FSMaxTime
|
||||
|| consist_max_crp() > mvOccupied->HighPipePress + FSOverchargeCRP
|
||||
|| std::ranges::any_of(
|
||||
BrakeChargingPipeOverchargeStart,
|
||||
[this]( auto const &Vehicle ) { return ElapsedTime - Vehicle.second > FSOverchargeTime; } );
|
||||
|
||||
@@ -350,6 +350,8 @@ private:
|
||||
void control_main_pipe();
|
||||
void update_brake_charging();
|
||||
bool is_brake_charging_done() const;
|
||||
double consist_max_crp() const;
|
||||
bool is_departure_blocked( double const Delay ) const;
|
||||
void control_relays();
|
||||
void control_motor_connectors();
|
||||
void control_tractive_force();
|
||||
@@ -454,6 +456,7 @@ private:
|
||||
double BrakeChargingCooldown{}; // prevents the ai from trying to charge the train brake too frequently
|
||||
double BrakeChargingStart = -1.0;
|
||||
std::unordered_map<TDynamicObject const *, double> BrakeChargingPipeOverchargeStart;
|
||||
double DepartBlockedStart = -1.0;
|
||||
TBrakeSystem BrakeSystem = TBrakeSystem::Individual; //type of main brake
|
||||
bool ForcePNBrake = false; //is it necessary to use PN brake instead of EP brake
|
||||
int DynamicBrakeTest = 0; //is it necessary to make brake test while driving
|
||||
|
||||
Reference in New Issue
Block a user