From a4183abea716eb7d17c1958b9a51450aba25240f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kr=C3=B3lik=20Uszasty?= Date: Tue, 31 Oct 2017 22:14:10 +0100 Subject: [PATCH] Speed control is changed to a command; AI Driver use speed control in EIM vehicles now --- Driver.cpp | 23 +++++++++++++++++++++-- McZapkie/Mover.cpp | 29 +++++++++++++++++------------ 2 files changed, 38 insertions(+), 14 deletions(-) diff --git a/Driver.cpp b/Driver.cpp index ee8d8e2d..097af2e7 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -2607,7 +2607,15 @@ bool TController::IncSpeed() if (!mvControlling->FuseFlag) if (Ready || (iDrivigFlags & movePress) || (mvOccupied->ShuntMode)) //{(BrakePress<=0.01*MaxBrakePress)} { - OK = mvControlling->IncMainCtrl(1); + OK = mvControlling->IncMainCtrl(std::max(1,mvOccupied->MainCtrlPosNo/10)); + //tutaj jeszcze powinien być tempomat + mvControlling->IncScndCtrl(1); + double SpeedCntrl = VelDesired; + if (fProximityDist < 50) + { + SpeedCntrl = std::min(SpeedCntrl, VelNext); + } + mvControlling->RunCommand("SpeedCntrl", VelDesired, mvControlling->CabNo); } break; case WheelsDriven: @@ -2660,11 +2668,22 @@ bool TController::DecSpeed(bool force) break; case Dumb: case DieselElectric: - case ElectricInductionMotor: OK = mvControlling->DecScndCtrl(2); if (!OK) OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPos / 2)); break; + case ElectricInductionMotor: + OK = mvControlling->DecMainCtrl(1); + if ((mvControlling->ScndCtrlPosNo > 0)&&(mvControlling->Mains)) //jeżeli tempomat + { + mvControlling->IncScndCtrl(1); + mvControlling->RunCommand("SpeedCntrl", VelDesired, mvControlling->CabNo); + } + else + { + mvControlling->DecScndCtrl(2); + } + break; case WheelsDriven: if (!mvControlling->CabNo) mvControlling->CabActivisation(); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 06bc5830..96012866 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -1942,6 +1942,7 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed) { /*OK:=*/SendCtrlToNext("MainCtrl", MainCtrlPos, CabNo); //??? /*OK:=*/SendCtrlToNext("ScndCtrl", ScndCtrlPos, CabNo); + } } else // nie ma sterowania @@ -1953,11 +1954,14 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed) LastRelayTime = 0; if ((OK) && (EngineType == ElectricInductionMotor)) - // NOTE: round() already adds 0.5, are the ones added here as well correct? + { + // NOTE: round() already adds 0.5, are the ones added here as well correct? if ((Vmax < 250)) - ScndCtrlActualPos = Round(Vel + 0.5); + ScndCtrlActualPos = Round(Vel); else - ScndCtrlActualPos = Round(Vel * 1.0 / 2 + 0.5); + ScndCtrlActualPos = Round(Vel * 0.5); + SendCtrlToNext("SpeedCntrl", ScndCtrlActualPos, CabNo); + } return OK; } @@ -2008,7 +2012,10 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed) LastRelayTime = 0; if ((OK) && (EngineType == ElectricInductionMotor)) + { ScndCtrlActualPos = 0; + SendCtrlToNext("SpeedCntrl", ScndCtrlActualPos, CabNo); + } return OK; } @@ -2359,7 +2366,7 @@ bool TMoverParameters::MainSwitch( bool const State, int const Notify ) if ((Mains != State) && (MainCtrlPosNo > 0)) { if ((State == false) || - ((ScndCtrlPos == 0) && ((ConvOvldFlag == false) || (TrainType == dt_EZT)) && + (((ScndCtrlPos == 0)||(EngineType == ElectricInductionMotor)) && ((ConvOvldFlag == false) || (TrainType == dt_EZT)) && (LastSwitchingTime > CtrlDelay) && !TestFlag(DamageFlag, dtrain_out) && !TestFlag(EngDmgFlag, 1))) { @@ -8046,14 +8053,6 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C } else if (Command == "ScndCtrl") { - if ((EngineType == ElectricInductionMotor)) - if ((ScndCtrlPos == 0) && (floor(CValue1) > 0)) - if ((Vmax < 250)) - ScndCtrlActualPos = Round(Vel + 0.5); - else - ScndCtrlActualPos = Round(Vel / 2 + 0.5); - else if ((floor(CValue1) == 0)) - ScndCtrlActualPos = 0; if (ScndCtrlPosNo >= floor(CValue1)) ScndCtrlPos = static_cast(floor(CValue1)); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); @@ -8376,6 +8375,12 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C } // if OK then LoadStatus:=0; } + else if (Command == "SpeedCntrl") + { + if ((EngineType == ElectricInductionMotor)) + ScndCtrlActualPos = static_cast(round(CValue1)); + OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); + } return OK; // dla true komenda będzie usunięta, dla false wykonana ponownie }