build 210305. ai route scanning fix, power use meter, minor bug fixes

This commit is contained in:
tmj-fstate
2021-03-06 05:24:44 +01:00
parent 029a063970
commit 98ef06e8fd
9 changed files with 64 additions and 22 deletions

View File

@@ -2751,17 +2751,18 @@ bool TController::PrepareEngine()
&& ( ( mvOccupied->fBrakeCtrlPos == mvOccupied->Handle->GetPos( bh_RP ) || ( mvOccupied->BrakeHandle == TBrakeHandle::NoHandle ) ) );
}
iEngineActive = isready;
if( true == iEngineActive ) {
if( true == isready ) {
// jeśli dotychczas spał teraz nie ma powodu do stania
eAction = TAction::actUnknown;
if( eStopReason == stopSleep ) {
eStopReason = stopNone;
}
iDrivigFlags |= moveActive; // może skanować sygnały i reagować na komendy
// może skanować sygnały i reagować na komendy
iDrivigFlags |= moveActive;
}
iEngineActive = isready;
return iEngineActive;
}
@@ -4755,7 +4756,9 @@ TController::Update( double const Timedelta ) {
mvOccupied->Vel > 5.0 ?
400 + fBrakeDist :
30.0 * fDriverDist ) }; // 1500m dla stojących pociągów;
scan_route( awarenessrange );
if( is_active() ) {
scan_route( awarenessrange );
}
scan_obstacles( awarenessrange );
// generic actions
control_security_system( reactiontime );
@@ -4782,8 +4785,6 @@ TController::Update( double const Timedelta ) {
control_tractive_and_braking_force();
}
SetTimeControllers();
// if the route ahead is blocked we might need to head the other way
check_route_behind( 1000 ); // NOTE: legacy scan range value
}
// configures vehicle heating given current situation; returns: true if vehicle can be operated normally, false otherwise
@@ -6330,15 +6331,8 @@ TController::determine_braking_distance() {
void
TController::scan_route( double const Range ) {
// Ra 2015-01: przy dłuższej drodze skanowania AI jeździ spokojniej
// 2. Sprawdzić, czy tabelka pokrywa założony odcinek (nie musi, jeśli jest STOP).
// 3. Sprawdzić, czy trajektoria ruchu przechodzi przez zwrotnice - jeśli tak, to sprawdzić, czy stan się nie zmienił.
// 4. Ewentualnie uzupełnić tabelkę informacjami o sygnałach i ograniczeniach, jeśli się "zużyła".
TableCheck( Range ); // wypełnianie tabelki i aktualizacja odległości
// 5. Sprawdzić stany sygnalizacji zapisanej w tabelce, wyznaczyć prędkości.
// 6. Z tabelki wyznaczyć krytyczną odległość i prędkość (najmniejsze przyspieszenie).
// 7. Jeśli jest inny pojazd z przodu, ewentualnie skorygować odległość i prędkość.
// 8. Ustalić częstotliwość świadomości AI (zatrzymanie precyzyjne - częściej, brak atrakcji - rzadziej).
TableCheck( Range );
}
// check for potential collisions
@@ -6892,10 +6886,11 @@ TController::pick_optimal_speed( double const Range ) {
SwitchClearDist = -1;
// if we're idling bail out early
if( false == TestFlag( iDrivigFlags, moveActive ) ) {
if( false == is_active() ) {
VelDesired = 0.0;
VelNext = 0.0;
AccDesired = std::min( AccDesired, EU07_AI_NOACCELERATION );
// return;
return;
}
// basic velocity and acceleration adjustments
@@ -6961,6 +6956,9 @@ TController::pick_optimal_speed( double const Range ) {
AccDesired,
( is_car() ? -2.0 : -0.9 ),
( is_car() ? 2.0 : 0.9 ) );
// if the route ahead is blocked we might need to head the other way
check_route_behind( 1000 ); // NOTE: legacy scan range value
}
void

View File

@@ -228,14 +228,21 @@ public:
TAction const & action() const {
return eAction; }
inline
bool is_active() const {
return TestFlag( iDrivigFlags, moveActive ); }
inline
bool is_train() const {
return TestFlag( mvOccupied->CategoryFlag, 1 ); }
inline
bool is_car() const {
return TestFlag( mvOccupied->CategoryFlag, 2 ); }
inline
bool is_emu() const {
return ( mvControlling->TrainType == dt_EZT ); }
inline
bool is_dmu() const {
return ( mvControlling->TrainType == dt_DMU ); }
inline
bool has_diesel_engine() const {
return ( ( mvControlling->EngineType == TEngineType::DieselElectric )
|| ( mvControlling->EngineType == TEngineType::DieselEngine ) );

View File

@@ -3636,6 +3636,7 @@ bool TDynamicObject::Update(double dt, double dt1)
}
else
MoverParameters->PantFrontVolt = 0.0;
( ( fPantCurrent > 0.0 ) ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantRearVolt * fPantCurrent * dt1 / 3600000.0;
break;
case 1:
if( ( false == Global.bLiveTraction )
@@ -3680,6 +3681,7 @@ bool TDynamicObject::Update(double dt, double dt1)
// Global.iPause ^= 2;
MoverParameters->PantRearVolt = 0.0;
}
( ( fPantCurrent > 0.0 ) ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantFrontVolt * fPantCurrent * dt1 / 3600000.0;
break;
} // pozostałe na razie nie obsługiwane
if( MoverParameters->PantPress > (

View File

@@ -1361,7 +1361,8 @@ public:
int SoundFlag = 0; /*!o patrz stale sound_ */
int AIFlag{ 0 }; // HACK: events of interest for consist owner
double DistCounter = 0.0; /*! licznik kilometrow */
double V = 0.0; //predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
std::pair<double, double> EnergyMeter; // energy <drawn, returned> from grid [kWh]
double V = 0.0; //predkosc w [m/s] względem sprzęgów (dodania gdy jedzie w stronę 0)
double Vel = 0.0; //moduł prędkości w [km/h], używany przez AI
double AccS = 0.0; //efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły)
double AccSVBased {}; // tangential acceleration calculated from velocity change

View File

@@ -9853,8 +9853,8 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
*/
extract_value( MinCompressor, "MinCP", line, "" );
extract_value( MaxCompressor, "MaxCP", line, "" );
extract_value( MinCompressor, "MinCP_B", line, "" );
extract_value( MaxCompressor, "MaxCP_B", line, "" );
extract_value( MinCompressor_cabB, "MinCP_B", line, "" );
extract_value( MaxCompressor_cabB, "MaxCP_B", line, "" );
extract_value( CompressorTankValve, "CompressorTankValve", line, "" );
extract_value( CompressorSpeed, "CompressorSpeed", line, "" );
extract_value( EmergencyValveOff, "MinEVP", line, "" );

View File

@@ -867,6 +867,34 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
Output.emplace_back( m_buffer.data(), Global.UITextColor );
if( mover.EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) {
std::snprintf(
m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_poweruse ].c_str(),
std::abs( mover.EnergyMeter.first ),
std::abs( mover.EnergyMeter.second ),
mover.EnergyMeter.first + mover.EnergyMeter.second );
textline = m_buffer.data();
if( DebugTractionFlag ) {
for( int i = 0; i < vehicle.iAnimType[ ANIM_PANTS ]; ++i ) { // pętla po wszystkich pantografach
auto const *p { vehicle.pants[ i ].fParamPants };
if( p && p->hvPowerWire ) {
auto const *powerwire { p->hvPowerWire };
std::snprintf(
m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::debug_vehicle_powerwire ].c_str(),
i,
powerwire->psPower[ 0 ] ? powerwire->psPower[ 0 ]->name() : "none",
powerwire->psPower[ 1 ] ? powerwire->psPower[ 1 ]->name() : "none",
powerwire->pPoint1[ 0 ],
powerwire->pPoint1[ 1 ],
powerwire->pPoint1[ 2 ] );
textline += m_buffer.data();
}
}
}
}
Output.emplace_back( textline, Global.UITextColor );
}
std::string

View File

@@ -183,6 +183,8 @@ init() {
"Brakes:\n train: %.2f (mode: %d, delay: %s, load flag: %d)\n independent: %.2f (%.2f), manual: %.2f, spring: %.2f\nBrake cylinder pressures:\n train: %.2f, independent: %.2f, status: 0x%.2x\nPipe pressures:\n brake: %.2f (hat: %.2f), main: %.2f, control: %.2f\nTank pressures:\n auxiliary: %.2f, main: %.2f, control: %.2f",
" pantograph: %.2f%cMT",
"Forces:\n tractive: %.1f, brake: %.1f, friction: %.2f%s\nAcceleration:\n tangential: %.2f, normal: %.2f (path radius: %s)\nVelocity: %.2f, distance traveled: %.2f\nPosition: [%.2f, %.2f, %.2f]",
"Power use:\n drawn: %.1f kWh, returned: %.1f kWh, balance: %.1f kWh",
"\n pantograph %d: drawing from: [%s, %s] through: [%.2f, %.2f, %.2f]",
"master controller",
"master controller",
@@ -492,6 +494,8 @@ init() {
"Hamulce:\n zespolony: %.2f (tryb: %d, nastawa: %s, ladunek: %d)\n pomocniczy: %.2f (%.2f), postojowy: %.2f, sprezynowy: %.2f\nCisnienie w cylindrach:\n zespolony: %.2f, pomocniczy: %.2f, status: 0x%.2x\nCisnienia w przewodach:\n glowny: %.2f (kapturek: %.2f), zasilajacy: %.2f, kontrolny: %.2f\nCisnienia w zbiornikach:\n pomocniczy: %.2f, glowny: %.2f, sterujacy: %.2f",
" pantograf: %.2f%cZG",
"Sily:\n napedna: %.1f, hamowania: %.1f, tarcie: %.2f%s\nPrzyspieszenia:\n styczne: %.2f, normalne: %.2f (promien: %s)\nPredkosc: %.2f, pokonana odleglosc: %.2f\nPozycja: [%.2f, %.2f, %.2f]",
"Zuzycie pradu:\n pobrane: %.1f kWh, oddane: %.1f kWh, zuzyte: %.1f kWh",
"\n pantograf %d: zrodla: [%s, %s] przeslo: [%.2f, %.2f, %.2f]",
"nastawnik jazdy",
"nastawnik jazdy",

View File

@@ -172,6 +172,8 @@ enum string {
debug_vehicle_brakespressures,
debug_vehicle_pantograph,
debug_vehicle_forcesaccelerationvelocityposition,
debug_vehicle_poweruse,
debug_vehicle_powerwire,
cab_mainctrl,
cab_jointctrl,

View File

@@ -1,5 +1,5 @@
#pragma once
#define VERSION_MAJOR 21
#define VERSION_MINOR 304
#define VERSION_MINOR 305
#define VERSION_REVISION 0