mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
AI uses pneumatic brake in EMUs when pulling non-ep-brake vehicles
This commit is contained in:
69
Driver.cpp
69
Driver.cpp
@@ -1996,8 +1996,8 @@ void TController::Activation()
|
||||
}
|
||||
ControllingSet(); // utworzenie połączenia do sterowanego pojazdu (może się zmienić) - silnikowy dla EZT
|
||||
if( ( mvOccupied->BrakeCtrlPosNo > 0 )
|
||||
&& ( ( mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic )
|
||||
|| ( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) ) {
|
||||
&& ( ( BrakeSystem == TBrakeSystem::Pneumatic )
|
||||
|| ( BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) ) {
|
||||
mvOccupied->LimPipePress = mvOccupied->PipePress;
|
||||
mvOccupied->ActFlowSpeed = 0;
|
||||
}
|
||||
@@ -2126,6 +2126,7 @@ void TController::AutoRewident()
|
||||
}
|
||||
// potentially release manual brake
|
||||
d->MoverParameters->DecManualBrakeLevel( ManualBrakePosNo );
|
||||
d->MoverParameters->SpringBrake.Activate = false;
|
||||
}
|
||||
d = d->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła)
|
||||
}
|
||||
@@ -2217,6 +2218,31 @@ void TController::AutoRewident()
|
||||
}
|
||||
fAccThreshold = fNominalAccThreshold;
|
||||
}
|
||||
|
||||
BrakeSystem = mvOccupied->BrakeSystem;
|
||||
if (BrakeSystem == TBrakeSystem::ElectroPneumatic)
|
||||
{
|
||||
bool fullep = true;
|
||||
if (pVehicles[end::front] != pVehicles[end::rear]) {
|
||||
// more detailed version, will use manual braking also for coupled sets of controlled vehicles
|
||||
auto *vehicle = pVehicles[end::front]; // start from first
|
||||
while ((true == fullep)
|
||||
&& (vehicle != nullptr)) {
|
||||
// NOTE: we could simplify this by doing only check of the rear coupler, but this can be quite tricky in itself
|
||||
// TODO: add easier ways to access front/rear coupler taking into account vehicle's direction
|
||||
fullep =
|
||||
(((vehicle->MoverParameters->Couplers[end::front].Connected == nullptr)
|
||||
|| ((vehicle->MoverParameters->Couplers[end::front].CouplingFlag & coupling::control)
|
||||
&& (vehicle->MoverParameters->Couplers[end::front].Connected->Power > -1)))
|
||||
&& ((vehicle->MoverParameters->Couplers[end::rear].Connected == nullptr)
|
||||
|| ((vehicle->MoverParameters->Couplers[end::rear].CouplingFlag & coupling::control)
|
||||
&& (vehicle->MoverParameters->Couplers[end::rear].Connected->Power > -1))));
|
||||
vehicle = vehicle->Next(); // kolejny pojazd, podłączony od tyłu (licząc od czoła)
|
||||
}
|
||||
}
|
||||
if (!fullep) BrakeSystem = TBrakeSystem::Pneumatic;
|
||||
mvOccupied->EpFuseSwitch( fullep );
|
||||
}
|
||||
}
|
||||
|
||||
double TController::ESMVelocity(bool Main)
|
||||
@@ -2966,7 +2992,9 @@ bool TController::ReleaseEngine() {
|
||||
bool TController::IncBrake()
|
||||
{ // zwiększenie hamowania
|
||||
bool OK = false;
|
||||
switch( mvOccupied->BrakeSystem ) {
|
||||
TBrakeSystem bs = BrakeSystem == TBrakeSystem::ElectroPneumatic && ForcePNBrake ?
|
||||
TBrakeSystem::Pneumatic : BrakeSystem;
|
||||
switch( bs ) {
|
||||
case TBrakeSystem::Individual: {
|
||||
if( mvOccupied->LocalBrake == TLocalBrake::ManualBrake ) {
|
||||
OK = mvOccupied->IncManualBrakeLevel( 1 + static_cast<int>( std::floor( 0.5 + std::fabs( AccDesired ) ) ) );
|
||||
@@ -2977,6 +3005,13 @@ bool TController::IncBrake()
|
||||
break;
|
||||
}
|
||||
case TBrakeSystem::Pneumatic: {
|
||||
if (bs != mvOccupied->BrakeSystem)
|
||||
{
|
||||
while (mvOccupied->BrakeOpModeFlag > bom_PN)
|
||||
{
|
||||
mvOccupied->BrakeOpModeFlag >>= 1;
|
||||
}
|
||||
}
|
||||
// NOTE: can't perform just test whether connected vehicle == nullptr, due to virtual couplers formed with nearby vehicles
|
||||
bool standalone { true };
|
||||
if( ( mvOccupied->TrainType == dt_ET41 )
|
||||
@@ -3028,7 +3063,7 @@ bool TController::IncBrake()
|
||||
|
||||
//standalone = standalone && ( mvControlling->EIMCtrlType == 0 );
|
||||
|
||||
if( true == standalone ) {
|
||||
if( true == standalone && false == ForcePNBrake ) {
|
||||
if( mvControlling->EIMCtrlType > 0 ) {
|
||||
OK = IncBrakeEIM();
|
||||
}
|
||||
@@ -3106,6 +3141,10 @@ bool TController::IncBrake()
|
||||
break;
|
||||
}
|
||||
case TBrakeSystem::ElectroPneumatic: {
|
||||
while ((mvOccupied->BrakeOpModeFlag << 1) <= mvOccupied->BrakeOpModes)
|
||||
{
|
||||
mvOccupied->BrakeOpModeFlag <<= 1;
|
||||
}
|
||||
if( mvOccupied->EngineType == TEngineType::ElectricInductionMotor ) {
|
||||
if (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57) {
|
||||
if (mvOccupied->BrakeCtrlPos < mvOccupied->Handle->GetPos(bh_FB))
|
||||
@@ -3194,7 +3233,9 @@ bool TController::DecBrake()
|
||||
bool OK = false;
|
||||
double deltaAcc = -1.0;
|
||||
double pos_diff = 1.0;
|
||||
switch (mvOccupied->BrakeSystem)
|
||||
TBrakeSystem bs = BrakeSystem == TBrakeSystem::ElectroPneumatic && ForcePNBrake ?
|
||||
TBrakeSystem::Pneumatic : BrakeSystem;
|
||||
switch (bs)
|
||||
{
|
||||
case TBrakeSystem::Individual:
|
||||
if (mvOccupied->LocalBrake == TLocalBrake::ManualBrake)
|
||||
@@ -3928,7 +3969,7 @@ void TController::SpeedCntrl(double DesiredSpeed)
|
||||
void TController::SetTimeControllers()
|
||||
{
|
||||
//1. Check the type of Main Brake Handle
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic)
|
||||
if (BrakeSystem == TBrakeSystem::Pneumatic)
|
||||
{
|
||||
if (mvOccupied->Handle->Time)
|
||||
{
|
||||
@@ -3944,7 +3985,8 @@ void TController::SetTimeControllers()
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_NP));
|
||||
}
|
||||
if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) mvOccupied->BrakeLevelSet(BrakeCtrlPosition);
|
||||
if (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P)
|
||||
if ((mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P)
|
||||
|| (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_EN57))
|
||||
{
|
||||
if (BrakeCtrlPosition == 0)
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP));
|
||||
@@ -4129,11 +4171,11 @@ void TController::SetTimeControllers()
|
||||
void TController::CheckTimeControllers()
|
||||
{
|
||||
//1. Check the type of Main Brake Handle
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic && mvOccupied->Handle->TimeEP)
|
||||
if (BrakeSystem == TBrakeSystem::ElectroPneumatic && mvOccupied->Handle->TimeEP)
|
||||
{
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPN));
|
||||
}
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic && mvOccupied->Handle->Time)
|
||||
if (BrakeSystem == TBrakeSystem::Pneumatic && mvOccupied->Handle->Time)
|
||||
{
|
||||
if (BrakeCtrlPosition > 0)
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_MB));
|
||||
@@ -5861,7 +5903,7 @@ TController::UpdateSituation(double dt) {
|
||||
// powino zostać wyłączone)
|
||||
// WriteLog("Zahamowanie składu");
|
||||
AccDesired = std::min( AccDesired, -0.9 ); // HACK: make sure the ai doesn't try to release the brakes to accelerate
|
||||
if( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) {
|
||||
if( BrakeSystem == TBrakeSystem::ElectroPneumatic ) {
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) );
|
||||
}
|
||||
else {
|
||||
@@ -5873,11 +5915,11 @@ TController::UpdateSituation(double dt) {
|
||||
// TODO: zabezpieczenie przed dziwnymi CHK do czasu wyjaśnienia sensu 0 oraz -1 w tym miejscu
|
||||
p = 3.9;
|
||||
}
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ?
|
||||
if (BrakeSystem == TBrakeSystem::ElectroPneumatic ?
|
||||
mvOccupied->BrakePress > 2 :
|
||||
mvOccupied->PipePress < p + 0.1)
|
||||
{ // jeśli w miarę został zahamowany (ciśnienie mniejsze niż podane na pozycji 3, zwyle 0.37)
|
||||
if( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) {
|
||||
if( BrakeSystem == TBrakeSystem::ElectroPneumatic ) {
|
||||
// wyłączenie EP, gdy wystarczy (może nie być potrzebne, bo na początku jest)
|
||||
mvOccupied->BrakeLevelSet( 0 );
|
||||
}
|
||||
@@ -6548,7 +6590,7 @@ TController::UpdateSituation(double dt) {
|
||||
ReactionTime = 0.25;
|
||||
}
|
||||
}
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) {
|
||||
if (BrakeSystem == TBrakeSystem::Pneumatic) {
|
||||
// napełnianie uderzeniowe
|
||||
if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a )
|
||||
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P )
|
||||
@@ -7662,6 +7704,7 @@ void TController::ControllingSet()
|
||||
// dzięki temu będzie wirtualna kabina w silnikowym, działająca w rozrządczym
|
||||
// w plikach FIZ zostały zgubione ujemne maski sprzęgów, stąd problemy z EZT
|
||||
mvOccupied = pVehicle->MoverParameters; // domyślny skrót do obiektu parametrów
|
||||
BrakeSystem = mvOccupied->BrakeSystem; // domyślny sposób hamowania
|
||||
mvControlling = pVehicle->FindPowered()->MoverParameters; // poszukiwanie członu sterowanego
|
||||
{
|
||||
auto *lookup { pVehicle->FindPantographCarrier() };
|
||||
|
||||
Reference in New Issue
Block a user