From 7ba6383c758318fc25ac9334f7f0119baa6eeeb3 Mon Sep 17 00:00:00 2001 From: tmj-fstate Date: Fri, 21 Feb 2020 22:20:10 +0100 Subject: [PATCH] vehicle configuration ai hints section, pantograph setup ai hint, vehicle screens drawing optimization --- Driver.cpp | 74 ++++++++++++++++++++++++++++------------------ McZapkie/MOVER.h | 3 ++ McZapkie/Mover.cpp | 12 ++++++++ Train.cpp | 3 +- 4 files changed, 63 insertions(+), 29 deletions(-) diff --git a/Driver.cpp b/Driver.cpp index 9a78bb68..981dd90a 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -4714,40 +4714,58 @@ TController::UpdateSituation(double dt) { } else { // jeśli nie trzeba opuszczać pantografów - // jazda na tylnym - if( ( iDirection >= 0 ) && ( useregularpantographlayout ) ) { - // jak jedzie w kierunku sprzęgu 0 - if( ( mvControlling->PantRearVolt == 0.0 ) - // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( ( mvControlling->PantographVoltage == 0.0 ) - || ( mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) ) { - mvControlling->OperatePantographValve( end::rear, operation_t::enable ); + if( mvOccupied->AIHintPantstate == 0 ) { + // jazda na tylnym + if( ( iDirection >= 0 ) && ( useregularpantographlayout ) ) { + // jak jedzie w kierunku sprzęgu 0 + if( ( mvControlling->PantRearVolt == 0.0 ) + // filter out cases with single _other_ working pantograph so we don't try to raise something we can't + && ( ( mvControlling->PantographVoltage == 0.0 ) + || ( mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) ) { + mvControlling->OperatePantographValve( end::rear, operation_t::enable ); + } } - } - else { - // jak jedzie w kierunku sprzęgu 0 - if( ( mvControlling->PantFrontVolt == 0.0 ) - // filter out cases with single _other_ working pantograph so we don't try to raise something we can't - && ( ( mvControlling->PantographVoltage == 0.0 ) - || ( mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) ) { - mvControlling->OperatePantographValve( end::front, operation_t::enable ); + else { + // jak jedzie w kierunku sprzęgu 0 + if( ( mvControlling->PantFrontVolt == 0.0 ) + // filter out cases with single _other_ working pantograph so we don't try to raise something we can't + && ( ( mvControlling->PantographVoltage == 0.0 ) + || ( mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) ) ) { + mvControlling->OperatePantographValve( end::front, operation_t::enable ); + } } } } if( mvOccupied->Vel > 5 ) { - // opuszczenie przedniego po rozpędzeniu się o ile jest więcej niż jeden - if( mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) { - if( ( iDirection >= 0 ) && ( useregularpantographlayout ) ) // jak jedzie w kierunku sprzęgu 0 - { // poczekać na podniesienie tylnego - if( ( mvControlling->PantFrontVolt != 0.0 ) - && ( mvControlling->PantRearVolt != 0.0 ) ) { // czy jest napięcie zasilające na tylnym? - mvControlling->OperatePantographValve( end::front, operation_t::disable ); // opuszcza od sprzęgu 0 + if( mvOccupied->AIHintPantstate != 0 ) { + // use suggested pantograph setup + auto const pantographsetup { mvOccupied->AIHintPantstate }; + mvControlling->OperatePantographValve( + end::front, + ( pantographsetup & ( 1 << 0 ) ? + operation_t::enable : + operation_t::disable ) ); + mvControlling->OperatePantographValve( + end::rear, + ( pantographsetup & ( 1 << 1 ) ? + operation_t::enable : + operation_t::disable ) ); + } + else { + // opuszczenie przedniego po rozpędzeniu się o ile jest więcej niż jeden + if( mvControlling->EnginePowerSource.CollectorParameters.CollectorsNo > 1 ) { + if( ( iDirection >= 0 ) && ( useregularpantographlayout ) ) // jak jedzie w kierunku sprzęgu 0 + { // poczekać na podniesienie tylnego + if( ( mvControlling->PantFrontVolt != 0.0 ) + && ( mvControlling->PantRearVolt != 0.0 ) ) { // czy jest napięcie zasilające na tylnym? + mvControlling->OperatePantographValve( end::front, operation_t::disable ); // opuszcza od sprzęgu 0 + } } - } - else { // poczekać na podniesienie przedniego - if( ( mvControlling->PantRearVolt != 0.0 ) - && ( mvControlling->PantFrontVolt != 0.0 ) ) { // czy jest napięcie zasilające na przednim? - mvControlling->OperatePantographValve( end::rear, operation_t::disable ); // opuszcza od sprzęgu 1 + else { // poczekać na podniesienie przedniego + if( ( mvControlling->PantRearVolt != 0.0 ) + && ( mvControlling->PantFrontVolt != 0.0 ) ) { // czy jest napięcie zasilające na przednim? + mvControlling->OperatePantographValve( end::rear, operation_t::disable ); // opuszcza od sprzęgu 1 + } } } } diff --git a/McZapkie/MOVER.h b/McZapkie/MOVER.h index 500bc062..b9a25bef 100644 --- a/McZapkie/MOVER.h +++ b/McZapkie/MOVER.h @@ -1534,6 +1534,8 @@ public: int iProblem = 0; // flagi problemów z taborem, aby AI nie musiało porównywać; 0=może jechać int iLights[2]; // bity zapalonych świateł tutaj, żeby dało się liczyć pobór prądu + int AIHintPantstate{ 0 }; // suggested pantograph setup + public: TMoverParameters(double VelInitial, std::string TypeNameInit, std::string NameInit, int Cab); // obsługa sprzęgów @@ -1777,6 +1779,7 @@ private: void LoadFIZ_Switches( std::string const &Input ); void LoadFIZ_MotorParamTable( std::string const &Input ); void LoadFIZ_Circuit( std::string const &Input ); + void LoadFIZ_AI( std::string const &Input ); void LoadFIZ_RList( std::string const &Input ); void LoadFIZ_UCList(std::string const &Input); void LoadFIZ_DList( std::string const &Input ); diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 07700c31..b02a8238 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -8912,6 +8912,13 @@ bool TMoverParameters::LoadFIZ(std::string chkpath) continue; } + if( issection( "AI:", inputline ) ) { + startBPT = false; + fizlines.emplace( "AI", inputline ); + LoadFIZ_AI( inputline ); + continue; + } + if( issection( "RList:", inputline ) ) { startBPT = false; @@ -10151,6 +10158,11 @@ void TMoverParameters::LoadFIZ_Circuit( std::string const &Input ) { } +void TMoverParameters::LoadFIZ_AI( std::string const &Input ) { + + extract_value( AIHintPantstate, "Pantstate", Input, "" ); +} + void TMoverParameters::LoadFIZ_RList( std::string const &Input ) { extract_value( RlistSize, "Size", Input, "" ); diff --git a/Train.cpp b/Train.cpp index cd95447e..a4520ec2 100644 --- a/Train.cpp +++ b/Train.cpp @@ -6908,7 +6908,8 @@ bool TTrain::Update( double const Deltatime ) } // screens fScreenTimer += Deltatime; - if( ( fScreenTimer > Global.PythonScreenUpdateRate * 0.001f ) + if( ( this == simulation::Train ) // no point in drawing screens for vehicles other than our own + && ( fScreenTimer > Global.PythonScreenUpdateRate * 0.001f ) && ( false == FreeFlyModeFlag ) ) { // don't bother if we're outside fScreenTimer = 0.f; for( auto const &screen : m_screens ) {