diff --git a/Driver.cpp b/Driver.cpp index 2fdb2f99..e61d9db7 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -3181,6 +3181,16 @@ bool TController::DecSpeedEIM() return OK; } +bool TController::BrakeLevelSet(double b) +{ + return false; +} + +bool TController::BrakeLevelAdd(double b) +{ + return false; +} + void TController::SpeedSet() { // Ra: regulacja prędkości, wykonywana w każdym przebłysku świadomości AI // ma dokręcać do bezoporowych i zdejmować pozycje w przypadku przekroczenia prądu @@ -3356,13 +3366,52 @@ void TController::SpeedCntrl(double DesiredSpeed) void TController::SetTimeControllers() { + //1. Check the type of Main Brake Handle + if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) + { + if (mvOccupied->Handle->Time) + { + if ((BrakeCtrlPosition > 0) && (mvOccupied->PipePress - 0.05 > mvOccupied->HighPipePress - BrakeCtrlPosition*0.25*mvOccupied->DeltaPipePress)) + mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_MB)); + else if ((BrakeCtrlPosition > 0) && (mvOccupied->PipePress + 0.05 < mvOccupied->HighPipePress - BrakeCtrlPosition*0.25*mvOccupied->DeltaPipePress)) + mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); + else if (BrakeCtrlPosition == 0) + mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); + else if (BrakeCtrlPosition == -1) + mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_FS)); + } + if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) mvOccupied->BrakeLevelSet(BrakeCtrlPosition); + } + //2. Check the type of Secondary Brake Handle + //3. Check the type od EIMCtrlType + if (mvOccupied->EIMCtrlType > 0) + { + if (mvOccupied->EIMCtrlType == 1) //traxx + { + if (mvOccupied->LocalBrakePosA > 0.95 * LocalBrakePosNo) mvOccupied->MainCtrlPos = 0; + } + else if (mvOccupied->EIMCtrlType == 2) //elf + { + if (mvOccupied->LocalBrakePosA > 0.95 * LocalBrakePosNo) mvOccupied->MainCtrlPos = 1; + } + } }; void TController::CheckTimeControllers() { //1. Check the type of Main Brake Handle - + if (mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic && mvOccupied->Handle->TimeEP) + { + mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPN)); + } + if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic && mvOccupied->Handle->Time) + { + if (BrakeCtrlPosition > 0) + mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_MB)); + else + mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP)); + } //2. Check the type of Secondary Brake Handle //3. Check the type od EIMCtrlType diff --git a/Driver.h b/Driver.h index 1b7c32bd..0b8156bc 100644 --- a/Driver.h +++ b/Driver.h @@ -216,6 +216,8 @@ private: bool DecBrakeEIM(); bool IncSpeedEIM(); bool DecSpeedEIM(); + bool BrakeLevelSet(double b); + bool BrakeLevelAdd(double b); void SpeedSet(); void SpeedCntrl(double DesiredSpeed); void SetTimeControllers(); /*setting state of time controllers depending of desired action*/ @@ -310,6 +312,7 @@ private: double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca double BrakeChargingCooldown {}; // prevents the ai from trying to charge the train brake too frequently + double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller double LastReactionTime = 0.0; double fActionTime = 0.0; // czas używany przy regulacji prędkości i zamykaniu drzwi double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations