mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 00:29:19 +02:00
build 210305. ai route scanning fix, power use meter, minor bug fixes
This commit is contained in:
32
Driver.cpp
32
Driver.cpp
@@ -2751,17 +2751,18 @@ bool TController::PrepareEngine()
|
|||||||
&& ( ( mvOccupied->fBrakeCtrlPos == mvOccupied->Handle->GetPos( bh_RP ) || ( mvOccupied->BrakeHandle == TBrakeHandle::NoHandle ) ) );
|
&& ( ( mvOccupied->fBrakeCtrlPos == mvOccupied->Handle->GetPos( bh_RP ) || ( mvOccupied->BrakeHandle == TBrakeHandle::NoHandle ) ) );
|
||||||
}
|
}
|
||||||
|
|
||||||
iEngineActive = isready;
|
if( true == isready ) {
|
||||||
|
|
||||||
if( true == iEngineActive ) {
|
|
||||||
// jeśli dotychczas spał teraz nie ma powodu do stania
|
// jeśli dotychczas spał teraz nie ma powodu do stania
|
||||||
eAction = TAction::actUnknown;
|
eAction = TAction::actUnknown;
|
||||||
if( eStopReason == stopSleep ) {
|
if( eStopReason == stopSleep ) {
|
||||||
eStopReason = stopNone;
|
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;
|
return iEngineActive;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -4755,7 +4756,9 @@ TController::Update( double const Timedelta ) {
|
|||||||
mvOccupied->Vel > 5.0 ?
|
mvOccupied->Vel > 5.0 ?
|
||||||
400 + fBrakeDist :
|
400 + fBrakeDist :
|
||||||
30.0 * fDriverDist ) }; // 1500m dla stojących pociągów;
|
30.0 * fDriverDist ) }; // 1500m dla stojących pociągów;
|
||||||
|
if( is_active() ) {
|
||||||
scan_route( awarenessrange );
|
scan_route( awarenessrange );
|
||||||
|
}
|
||||||
scan_obstacles( awarenessrange );
|
scan_obstacles( awarenessrange );
|
||||||
// generic actions
|
// generic actions
|
||||||
control_security_system( reactiontime );
|
control_security_system( reactiontime );
|
||||||
@@ -4782,8 +4785,6 @@ TController::Update( double const Timedelta ) {
|
|||||||
control_tractive_and_braking_force();
|
control_tractive_and_braking_force();
|
||||||
}
|
}
|
||||||
SetTimeControllers();
|
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
|
// 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
|
void
|
||||||
TController::scan_route( double const Range ) {
|
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).
|
TableCheck( Range );
|
||||||
// 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).
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// check for potential collisions
|
// check for potential collisions
|
||||||
@@ -6892,10 +6886,11 @@ TController::pick_optimal_speed( double const Range ) {
|
|||||||
SwitchClearDist = -1;
|
SwitchClearDist = -1;
|
||||||
|
|
||||||
// if we're idling bail out early
|
// if we're idling bail out early
|
||||||
if( false == TestFlag( iDrivigFlags, moveActive ) ) {
|
if( false == is_active() ) {
|
||||||
VelDesired = 0.0;
|
VelDesired = 0.0;
|
||||||
|
VelNext = 0.0;
|
||||||
AccDesired = std::min( AccDesired, EU07_AI_NOACCELERATION );
|
AccDesired = std::min( AccDesired, EU07_AI_NOACCELERATION );
|
||||||
// return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// basic velocity and acceleration adjustments
|
// basic velocity and acceleration adjustments
|
||||||
@@ -6961,6 +6956,9 @@ TController::pick_optimal_speed( double const Range ) {
|
|||||||
AccDesired,
|
AccDesired,
|
||||||
( is_car() ? -2.0 : -0.9 ),
|
( is_car() ? -2.0 : -0.9 ),
|
||||||
( 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
|
void
|
||||||
|
|||||||
7
Driver.h
7
Driver.h
@@ -228,14 +228,21 @@ public:
|
|||||||
TAction const & action() const {
|
TAction const & action() const {
|
||||||
return eAction; }
|
return eAction; }
|
||||||
inline
|
inline
|
||||||
|
bool is_active() const {
|
||||||
|
return TestFlag( iDrivigFlags, moveActive ); }
|
||||||
|
inline
|
||||||
bool is_train() const {
|
bool is_train() const {
|
||||||
return TestFlag( mvOccupied->CategoryFlag, 1 ); }
|
return TestFlag( mvOccupied->CategoryFlag, 1 ); }
|
||||||
|
inline
|
||||||
bool is_car() const {
|
bool is_car() const {
|
||||||
return TestFlag( mvOccupied->CategoryFlag, 2 ); }
|
return TestFlag( mvOccupied->CategoryFlag, 2 ); }
|
||||||
|
inline
|
||||||
bool is_emu() const {
|
bool is_emu() const {
|
||||||
return ( mvControlling->TrainType == dt_EZT ); }
|
return ( mvControlling->TrainType == dt_EZT ); }
|
||||||
|
inline
|
||||||
bool is_dmu() const {
|
bool is_dmu() const {
|
||||||
return ( mvControlling->TrainType == dt_DMU ); }
|
return ( mvControlling->TrainType == dt_DMU ); }
|
||||||
|
inline
|
||||||
bool has_diesel_engine() const {
|
bool has_diesel_engine() const {
|
||||||
return ( ( mvControlling->EngineType == TEngineType::DieselElectric )
|
return ( ( mvControlling->EngineType == TEngineType::DieselElectric )
|
||||||
|| ( mvControlling->EngineType == TEngineType::DieselEngine ) );
|
|| ( mvControlling->EngineType == TEngineType::DieselEngine ) );
|
||||||
|
|||||||
@@ -3636,6 +3636,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
MoverParameters->PantFrontVolt = 0.0;
|
MoverParameters->PantFrontVolt = 0.0;
|
||||||
|
( ( fPantCurrent > 0.0 ) ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantRearVolt * fPantCurrent * dt1 / 3600000.0;
|
||||||
break;
|
break;
|
||||||
case 1:
|
case 1:
|
||||||
if( ( false == Global.bLiveTraction )
|
if( ( false == Global.bLiveTraction )
|
||||||
@@ -3680,6 +3681,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
|||||||
// Global.iPause ^= 2;
|
// Global.iPause ^= 2;
|
||||||
MoverParameters->PantRearVolt = 0.0;
|
MoverParameters->PantRearVolt = 0.0;
|
||||||
}
|
}
|
||||||
|
( ( fPantCurrent > 0.0 ) ? MoverParameters->EnergyMeter.first : MoverParameters->EnergyMeter.second ) += MoverParameters->PantFrontVolt * fPantCurrent * dt1 / 3600000.0;
|
||||||
break;
|
break;
|
||||||
} // pozostałe na razie nie obsługiwane
|
} // pozostałe na razie nie obsługiwane
|
||||||
if( MoverParameters->PantPress > (
|
if( MoverParameters->PantPress > (
|
||||||
|
|||||||
@@ -1361,6 +1361,7 @@ public:
|
|||||||
int SoundFlag = 0; /*!o patrz stale sound_ */
|
int SoundFlag = 0; /*!o patrz stale sound_ */
|
||||||
int AIFlag{ 0 }; // HACK: events of interest for consist owner
|
int AIFlag{ 0 }; // HACK: events of interest for consist owner
|
||||||
double DistCounter = 0.0; /*! licznik kilometrow */
|
double DistCounter = 0.0; /*! licznik kilometrow */
|
||||||
|
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 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 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 AccS = 0.0; //efektywne przyspieszenie styczne w [m/s^2] (wszystkie siły)
|
||||||
|
|||||||
@@ -9853,8 +9853,8 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
|
|||||||
*/
|
*/
|
||||||
extract_value( MinCompressor, "MinCP", line, "" );
|
extract_value( MinCompressor, "MinCP", line, "" );
|
||||||
extract_value( MaxCompressor, "MaxCP", line, "" );
|
extract_value( MaxCompressor, "MaxCP", line, "" );
|
||||||
extract_value( MinCompressor, "MinCP_B", line, "" );
|
extract_value( MinCompressor_cabB, "MinCP_B", line, "" );
|
||||||
extract_value( MaxCompressor, "MaxCP_B", line, "" );
|
extract_value( MaxCompressor_cabB, "MaxCP_B", line, "" );
|
||||||
extract_value( CompressorTankValve, "CompressorTankValve", line, "" );
|
extract_value( CompressorTankValve, "CompressorTankValve", line, "" );
|
||||||
extract_value( CompressorSpeed, "CompressorSpeed", line, "" );
|
extract_value( CompressorSpeed, "CompressorSpeed", line, "" );
|
||||||
extract_value( EmergencyValveOff, "MinEVP", line, "" );
|
extract_value( EmergencyValveOff, "MinEVP", line, "" );
|
||||||
|
|||||||
@@ -867,6 +867,34 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
|
|||||||
|
|
||||||
Output.emplace_back( m_buffer.data(), Global.UITextColor );
|
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
|
std::string
|
||||||
|
|||||||
@@ -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",
|
"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",
|
" 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]",
|
"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",
|
||||||
"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",
|
"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",
|
" 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]",
|
"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",
|
||||||
"nastawnik jazdy",
|
"nastawnik jazdy",
|
||||||
|
|||||||
@@ -172,6 +172,8 @@ enum string {
|
|||||||
debug_vehicle_brakespressures,
|
debug_vehicle_brakespressures,
|
||||||
debug_vehicle_pantograph,
|
debug_vehicle_pantograph,
|
||||||
debug_vehicle_forcesaccelerationvelocityposition,
|
debug_vehicle_forcesaccelerationvelocityposition,
|
||||||
|
debug_vehicle_poweruse,
|
||||||
|
debug_vehicle_powerwire,
|
||||||
|
|
||||||
cab_mainctrl,
|
cab_mainctrl,
|
||||||
cab_jointctrl,
|
cab_jointctrl,
|
||||||
|
|||||||
Reference in New Issue
Block a user