diff --git a/Driver.cpp b/Driver.cpp index d99c45ba..d253e5df 100644 --- a/Driver.cpp +++ b/Driver.cpp @@ -2906,15 +2906,12 @@ bool TController::IncSpeed() if (Ready || (iDrivigFlags & movePress) || (mvOccupied->ShuntMode)) //{(BrakePress<=0.01*MaxBrakePress)} { OK = mvControlling->IncMainCtrl(std::max(1,mvOccupied->MainCtrlPosNo/10)); - //tutaj jeszcze powinien być tempomat - - double SpeedCntrlVel = VelDesired; - if (fProximityDist < 50) - { - SpeedCntrlVel = std::min(SpeedCntrlVel, VelNext); - } + // cruise control + auto const SpeedCntrlVel { ( + ( ActualProximityDist > std::max( 50.0, fMaxProximityDist ) ) ? + VelDesired : + min_speed( VelDesired, VelNext ) ) }; SpeedCntrl(SpeedCntrlVel); - } break; case TEngineType::WheelsDriven: @@ -3081,20 +3078,15 @@ void TController::SpeedSet() else if (Ready || (iDrivigFlags & movePress)) // o ile może jechać if (fAccGravity < -0.10) // i jedzie pod górę większą niż 10 promil { // procedura wjeżdżania na ekstremalne wzniesienia - if (fabs(mvControlling->Im) > - 0.85 * mvControlling->Imax) // a prąd jest większy niż 85% nadmiarowego - // if (mvControlling->Imin*mvControlling->Voltage/(fMass*fAccGravity)<-2.8) //a - // na niskim się za szybko nie pojedzie - if (mvControlling->Imax * mvControlling->Voltage / (fMass * fAccGravity) < - -2.8) // a na niskim się za szybko nie pojedzie + if (fabs(mvControlling->Im) > 0.85 * mvControlling->Imax) // a prąd jest większy niż 85% nadmiarowego + if (mvControlling->Imax * mvControlling->Voltage / (fMass * fAccGravity) < -2.8) // a na niskim się za szybko nie pojedzie { // włączenie wysokiego rozruchu; // (I*U)[A*V=W=kg*m*m/sss]/(m[kg]*a[m/ss])=v[m/s]; 2.8m/ss=10km/h if (mvControlling->RList[mvControlling->MainCtrlPos].Bn > 1) { // jeśli jedzie na równoległym, to zbijamy do szeregowego, aby włączyć // wysoki rozruch if (mvControlling->ScndCtrlPos > 0) // jeżeli jest bocznik - mvControlling->DecScndCtrl( - 2); // wyłączyć bocznik, bo może blokować skręcenie NJ + mvControlling->DecScndCtrl(2); // wyłączyć bocznik, bo może blokować skręcenie NJ do // skręcanie do bezoporowej na szeregowym mvControlling->DecMainCtrl(1); // kręcimy nastawnik jazdy o 1 wstecz while (mvControlling->MainCtrlPos ? @@ -3102,8 +3094,7 @@ void TController::SpeedSet() false); // oporowa zapętla } if (mvControlling->Imax < mvControlling->ImaxHi) // jeśli da się na wysokim - mvControlling->CurrentSwitch( - true); // rozruch wysoki (za to może się ślizgać) + mvControlling->CurrentSwitch(true); // rozruch wysoki (za to może się ślizgać) if (ReactionTime > 0.1) ReactionTime = 0.1; // orientuj się szybciej } // if (Im>Imin) @@ -3132,23 +3123,12 @@ void TController::SpeedSet() if (mvOccupied->Vel >= 30.0) // jak się rozpędził if (fAccGravity > -0.02) // a i pochylenie mnijsze niż 2‰ mvControlling->CurrentSwitch(false); // rozruch wysoki wyłącz - // dokręcanie do bezoporowej, bo IncSpeed() może nie być wywoływane - // if (mvOccupied->Vel-0.1) //nie ma hamować - // if (Controlling->RList[MainCtrlPos].R>0.0) - // if (Im<1.3*Imin) //lekkie przekroczenie miimalnego prądu jest dopuszczalne - // IncMainCtrl(1); //zwieksz nastawnik skoro możesz - tak aby się ustawic na - // bezoporowej } break; case TEngineType::Dumb: case TEngineType::DieselElectric: case TEngineType::ElectricInductionMotor: break; - // WheelsDriven : - // begin - // OK:=False; - // end; case TEngineType::DieselEngine: // Ra 2014-06: "automatyczna" skrzynia biegów... if (!mvControlling->MotorParam[mvControlling->ScndCtrlPos].AutoSwitch) // gdy biegi ręczne @@ -4901,13 +4881,10 @@ TController::UpdateSituation(double dt) { #endif // ustalanie zadanego przyspieszenia //(ActualProximityDist) - odległość do miejsca zmniejszenia prędkości - //(AccPreferred) - wynika z psychyki oraz uwzglęnia już ewentualne zderzenie z - // pojazdem z przodu, ujemne gdy należy hamować + //(AccPreferred) - wynika z psychyki oraz uwzglęnia już ewentualne zderzenie z pojazdem z przodu, ujemne gdy należy hamować //(AccDesired) - uwzględnia sygnały na drodze ruchu, ujemne gdy należy hamować - //(fAccGravity) - chwilowe przspieszenie grawitacyjne, ujemne działa przeciwnie do - // zadanego kierunku jazdy - //(AbsAccS) - chwilowe przyspieszenie pojazu (uwzględnia grawitację), ujemne działa - // przeciwnie do zadanego kierunku jazdy + //(fAccGravity) - chwilowe przspieszenie grawitacyjne, ujemne działa przeciwnie do zadanego kierunku jazdy + //(AbsAccS) - chwilowe przyspieszenie pojazu (uwzględnia grawitację), ujemne działa przeciwnie do zadanego kierunku jazdy //(AccDesired) porównujemy z (fAccGravity) albo (AbsAccS) if( ( VelNext >= 0.0 ) && ( ActualProximityDist <= routescanrange ) diff --git a/Driver.h b/Driver.h index e7a05617..6ec94085 100644 --- a/Driver.h +++ b/Driver.h @@ -265,7 +265,6 @@ private: double VelNext = 120.0; // prędkość, jaka ma być po przejechaniu długości ProximityDist double VelRestricted = -1.0; // speed of travel after passing a permissive signal at stop private: - double fProximityDist = 0.0; // odleglosc podawana w SetProximityVelocity(); >0:przeliczać do punktu, <0:podana wartość double FirstSemaphorDist = 10000.0; // odległość do pierwszego znalezionego semafora public: double ActualProximityDist = 1.0; // odległość brana pod uwagę przy wyliczaniu prędkości i przyspieszenia diff --git a/McZapkie/Mover.cpp b/McZapkie/Mover.cpp index 1fb943dd..b1a2408e 100644 --- a/McZapkie/Mover.cpp +++ b/McZapkie/Mover.cpp @@ -5398,8 +5398,6 @@ bool TMoverParameters::AutoRelaySwitch(bool State) bool TMoverParameters::AutoRelayCheck(void) { bool OK = false; // b:int; - bool ARFASI = false; - bool ARFASI2 = false; // sprawdzenie wszystkich warunkow (AutoRelayFlag, AutoSwitch, Im= 4 ) && ( ToLower( Stream.substr( Stream.size() - 4 ) ) == ".inc" ) ) { mIncFile = true; - scene::Groups.begin(); + scene::Groups.create(); } break; } @@ -75,7 +75,7 @@ cParser::~cParser() { if( true == mIncFile ) { // wrap up the node group holding content of processed file - scene::Groups.end(); + scene::Groups.close(); } } diff --git a/scenenodegroups.cpp b/scenenodegroups.cpp index 0399af7f..c8720c25 100644 --- a/scenenodegroups.cpp +++ b/scenenodegroups.cpp @@ -16,7 +16,7 @@ node_groups Groups; // requests creation of a new node group. returns: handle to the group scene::group_handle -node_groups::begin() { +node_groups::create() { m_activegroup.push( create_handle() ); @@ -25,7 +25,7 @@ node_groups::begin() { // indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty scene::group_handle -node_groups::end() { +node_groups::close() { if( false == m_activegroup.empty() ) { @@ -58,7 +58,7 @@ node_groups::handle() const { // places provided node in specified group void -node_groups::register_node( scene::basic_node *Node, scene::group_handle const Group ) { +node_groups::insert( scene::group_handle const Group, scene::basic_node *Node ) { // TBD, TODO: automatically unregister the node from its current group? Node->group( Group ); diff --git a/scenenodegroups.h b/scenenodegroups.h index 906b8639..762f4789 100644 --- a/scenenodegroups.h +++ b/scenenodegroups.h @@ -27,16 +27,16 @@ public: // methods // requests creation of a new node group. returns: handle to the group group_handle - begin(); + create(); // indicates creation of current group ended. returns: handle to the parent group or null_handle if group stack is empty group_handle - end(); + close(); // returns current active group, or null_handle if group stack is empty group_handle handle() const; // places provided node in specified group void - register_node( scene::basic_node *Node, scene::group_handle const Group ); + insert( scene::group_handle const Group, scene::basic_node *Node ); std::pair group( scene::group_handle const Group ) { auto &group { m_groupmap[ Group ] }; diff --git a/simulationstateserializer.cpp b/simulationstateserializer.cpp index f2cdc672..6de89e12 100644 --- a/simulationstateserializer.cpp +++ b/simulationstateserializer.cpp @@ -305,7 +305,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch delete pathnode; */ } - scene::Groups.register_node( path, scene::Groups.handle() ); + scene::Groups.insert( scene::Groups.handle(), path ); simulation::Region->insert_and_register( path ); } else if( nodedata.type == "traction" ) { @@ -317,7 +317,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch if( false == simulation::Traction.insert( traction ) ) { ErrorLog( "Bad scenario: traction piece with duplicate name \"" + traction->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } - scene::Groups.register_node( traction, scene::Groups.handle() ); + scene::Groups.insert( scene::Groups.handle(), traction ); simulation::Region->insert_and_register( traction ); } else if( nodedata.type == "tractionpowersource" ) { @@ -378,7 +378,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch if( false == simulation::Instances.insert( instance ) ) { ErrorLog( "Bad scenario: 3d model instance with duplicate name \"" + instance->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } - scene::Groups.register_node( instance, scene::Groups.handle() ); + scene::Groups.insert( scene::Groups.handle(), instance ); simulation::Region->insert( instance ); } } @@ -421,7 +421,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch if( false == simulation::Memory.insert( memorycell ) ) { ErrorLog( "Bad scenario: memory memorycell with duplicate name \"" + memorycell->name() + "\" encountered in file \"" + Input.Name() + "\" (line " + std::to_string( inputline ) + ")" ); } - scene::Groups.register_node( memorycell, scene::Groups.handle() ); + scene::Groups.insert( scene::Groups.handle(), memorycell ); simulation::Region->insert( memorycell ); } else if( nodedata.type == "eventlauncher" ) { @@ -436,7 +436,7 @@ state_serializer::deserialize_node( cParser &Input, scene::scratch_data &Scratch simulation::Events.queue( eventlauncher ); } else { - scene::Groups.register_node( eventlauncher, scene::Groups.handle() ); + scene::Groups.insert( scene::Groups.handle(), eventlauncher ); simulation::Region->insert( eventlauncher ); } }