16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 19:49:19 +02:00

build 180609. vehicle engine revolutions parameter, minor ai logic tweaks

This commit is contained in:
tmj-fstate
2018-06-09 13:03:03 +02:00
parent 0fe26048e9
commit e3f7ea33b3
6 changed files with 89 additions and 64 deletions

View File

@@ -1006,7 +1006,10 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
sSpeedTable[i].iFlags = 0; // W4 nie liczy się już (nie wyśle SetVelocity) sSpeedTable[i].iFlags = 0; // W4 nie liczy się już (nie wyśle SetVelocity)
sSpeedTable[i].fVelNext = -1; // można jechać za W4 sSpeedTable[i].fVelNext = -1; // można jechać za W4
fLastStopExpDist = -1.0f; // nie ma rozkładu, nie ma usuwania stacji fLastStopExpDist = -1.0f; // nie ma rozkładu, nie ma usuwania stacji
/*
// NOTE: disabled as it's no longer needed, required time is calculated as part of loading/unloading procedure
WaitingSet(60); // tak ze 2 minuty, aż wszyscy wysiądą WaitingSet(60); // tak ze 2 minuty, aż wszyscy wysiądą
*/
// wykonanie kolejnego rozkazu (Change_direction albo Shunt) // wykonanie kolejnego rozkazu (Change_direction albo Shunt)
JumpToNextOrder(); JumpToNextOrder();
// ma się nie ruszać aż do momentu podania sygnału // ma się nie ruszać aż do momentu podania sygnału
@@ -2274,7 +2277,7 @@ bool TController::PrepareEngine()
{ // najpierw ustalamy kierunek, jeśli nie został ustalony { // najpierw ustalamy kierunek, jeśli nie został ustalony
if( !iDirection ) { if( !iDirection ) {
// jeśli nie ma ustalonego kierunku // jeśli nie ma ustalonego kierunku
if( mvOccupied->V == 0 ) { // ustalenie kierunku, gdy stoi if( mvOccupied->Vel < 0.01 ) { // ustalenie kierunku, gdy stoi
iDirection = mvOccupied->CabNo; // wg wybranej kabiny iDirection = mvOccupied->CabNo; // wg wybranej kabiny
if( !iDirection ) { if( !iDirection ) {
// jeśli nie ma ustalonego kierunku // jeśli nie ma ustalonego kierunku
@@ -4610,20 +4613,7 @@ TController::UpdateSituation(double dt) {
} }
// sprawdzamy możliwe ograniczenia prędkości // sprawdzamy możliwe ograniczenia prędkości
if( OrderCurrentGet() & ( Shunt | Obey_train ) ) { if( VelSignal >= 0 ) {
// w Connect nie, bo moveStopHere odnosi się do stanu po połączeniu
if( ( iDrivigFlags & moveStopHere )
&& ( vel == 0.0 )
&& ( VelSignal == 0.0 ) ) {
// jeśli ma czekać na wolną drogę, stoi a wyjazdu nie ma, to ma stać
VelDesired = 0.0;
}
}
if( fStopTime < 0 ) {
// czas postoju przed dalszą jazdą (np. na przystanku)
VelDesired = 0.0; // jak ma czekać, to nie ma jazdy
}
else if( VelSignal >= 0 ) {
// jeśli skład był zatrzymany na początku i teraz już może jechać // jeśli skład był zatrzymany na początku i teraz już może jechać
VelDesired = VelDesired =
min_speed( min_speed(
@@ -4640,10 +4630,19 @@ TController::UpdateSituation(double dt) {
if( VelforDriver >= 0 ) { if( VelforDriver >= 0 ) {
// tu jest zero przy zmianie kierunku jazdy // tu jest zero przy zmianie kierunku jazdy
// Ra: tu może być 40, jeśli mechanik nie ma znajomości szlaaku, albo kierowca jeździ 70 // Ra: tu może być 40, jeśli mechanik nie ma znajomości szlaaku, albo kierowca jeździ 70
VelDesired = min_speed( VelDesired, VelforDriver ); VelDesired =
min_speed(
VelDesired,
VelforDriver );
} }
if( ( TrainParams != nullptr ) if( fStopTime < 0 ) {
&& ( TrainParams->CheckTrainLatency() < 5.0 ) // czas postoju przed dalszą jazdą (np. na przystanku)
VelDesired = 0.0; // jak ma czekać, to nie ma jazdy
}
if( ( OrderCurrentGet() & Obey_train ) != 0 ) {
if( ( TrainParams->CheckTrainLatency() < 5.0 )
&& ( TrainParams->TTVmax > 0.0 ) ) { && ( TrainParams->TTVmax > 0.0 ) ) {
// jesli nie spozniony to nie przekraczać rozkladowej // jesli nie spozniony to nie przekraczać rozkladowej
VelDesired = VelDesired =
@@ -4652,15 +4651,35 @@ TController::UpdateSituation(double dt) {
TrainParams->TTVmax ); TrainParams->TTVmax );
} }
if( ( VelDesired > 0.0 ) if( ( ( iDrivigFlags & moveStopHere ) != 0 )
&& ( iDrivigFlags & moveGuardSignal ) && ( vel < 0.01 )
&& ( OrderCurrentGet() & Obey_train ) ) { && ( SemNextIndex != -1 )
&& ( SemNextIndex < sSpeedTable.size() ) // BUG: index can point at non-existing slot. investigate reason(s)
&& ( sSpeedTable[ SemNextIndex ].fVelNext == 0.0 ) ) {
// don't depart if told to wait at passenger stop until allowed to by the signal
VelDesired = 0.0;
}
}
if( ( OrderCurrentGet() & ( Shunt | Obey_train ) ) != 0 ) {
// w Connect nie, bo moveStopHere odnosi się do stanu po połączeniu
if( ( ( iDrivigFlags & moveStopHere ) != 0 )
&& ( vel < 0.01 )
&& ( VelSignal == 0.0 ) ) {
// jeśli ma czekać na wolną drogę, stoi a wyjazdu nie ma, to ma stać
VelDesired = 0.0;
}
}
// end of speed caps checks
if( ( ( OrderCurrentGet() & Obey_train ) != 0 )
&& ( ( iDrivigFlags & moveGuardSignal ) != 0 )
&& ( VelDesired > 0.0 ) ) {
// komunikat od kierownika tu, bo musi być wolna droga i odczekany czas stania // komunikat od kierownika tu, bo musi być wolna droga i odczekany czas stania
iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać iDrivigFlags &= ~moveGuardSignal; // tylko raz nadać
if( false == tsGuardSignal.empty() ) { if( false == tsGuardSignal.empty() ) {
tsGuardSignal.stop(); tsGuardSignal.stop();
// w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy // w zasadzie to powinien mieć flagę, czy jest dźwiękiem radiowym, czy bezpośrednim
// bezpośrednim
// albo trzeba zrobić dwa dźwięki, jeden bezpośredni, słyszalny w // albo trzeba zrobić dwa dźwięki, jeden bezpośredni, słyszalny w
// pobliżu, a drugi radiowy, słyszalny w innych lokomotywach // pobliżu, a drugi radiowy, słyszalny w innych lokomotywach
// na razie zakładam, że to nie jest dźwięk radiowy, bo trzeba by zrobić // na razie zakładam, że to nie jest dźwięk radiowy, bo trzeba by zrobić
@@ -4675,8 +4694,7 @@ TController::UpdateSituation(double dt) {
else { else {
// if (iGuardRadio==iRadioChannel) //zgodność kanału // if (iGuardRadio==iRadioChannel) //zgodność kanału
// if (!FreeFlyModeFlag) //obserwator musi być w środku pojazdu // if (!FreeFlyModeFlag) //obserwator musi być w środku pojazdu
// (albo może mieć radio przenośne) - kierownik mógłby powtarzać // (albo może mieć radio przenośne) - kierownik mógłby powtarzać przy braku reakcji
// przy braku reakcji
// TODO: proper system for sending/receiving radio messages // TODO: proper system for sending/receiving radio messages
// place the sound in appropriate cab of the manned vehicle // place the sound in appropriate cab of the manned vehicle
tsGuardSignal.owner( pVehicle ); tsGuardSignal.owner( pVehicle );
@@ -4684,17 +4702,9 @@ TController::UpdateSituation(double dt) {
tsGuardSignal.play( sound_flags::exclusive ); tsGuardSignal.play( sound_flags::exclusive );
} }
} }
/*
if( ( ( iDrivigFlags & moveStopHere ) == 0 )
|| ( ( SemNextIndex != -1 )
&& ( SemNextIndex < sSpeedTable.size() ) // BUG: index can point at non-existing slot. investigate reason(s)
&& ( sSpeedTable[SemNextIndex].fVelNext != 0.0 ) ) ) {
// jeśli można jechać, to odpalić dźwięk kierownika oraz zamknąć drzwi w
// składzie, jeśli nie mamy czekać na sygnał też trzeba odpalić
} }
*/
} if( mvOccupied->Vel < 0.01 ) {
if( mvOccupied->V == 0.0 ) {
// Ra 2014-03: jesli skład stoi, to działa na niego składowa styczna grawitacji // Ra 2014-03: jesli skład stoi, to działa na niego składowa styczna grawitacji
AbsAccS = fAccGravity; AbsAccS = fAccGravity;
} }
@@ -5235,14 +5245,23 @@ TController::UpdateSituation(double dt) {
} }
if (AIControllFlag) if (AIControllFlag)
{ // odhamowywanie składu po zatrzymaniu i zabezpieczanie lokomotywy { // odhamowywanie składu po zatrzymaniu i zabezpieczanie lokomotywy
if ((OrderList[OrderPos] & (Disconnect | Connect)) == if( ( ( OrderList[ OrderPos ] & ( Disconnect | Connect ) ) == 0 )
0) // przy (p)odłączaniu nie zwalniamy tu hamulca && ( std::abs( fAccGravity ) < 0.01 ) ) {
if ((mvOccupied->V == 0.0) && ((VelDesired == 0.0) || (AccDesired == 0.0))) // przy (p)odłączaniu nie zwalniamy tu hamulca
if (mvOccupied->BrakeCtrlPos == mvOccupied->Handle->GetPos(bh_RP)) // only do this on flats, on slopes keep applied the train brake
mvOccupied->IncLocalBrakeLevel(1); // dodatkowy na pozycję 1 if( ( mvOccupied->Vel < 0.01 )
else && ( ( VelDesired == 0.0 )
|| ( AccDesired == 0.0 ) ) ) {
if( mvOccupied->BrakeCtrlPos == mvOccupied->Handle->GetPos( bh_RP ) ) {
// dodatkowy na pozycję 1
mvOccupied->IncLocalBrakeLevel( 1 );
}
else {
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) );
} }
}
}
}
break; // rzeczy robione przy jezdzie break; // rzeczy robione przy jezdzie
} // switch (OrderList[OrderPos]) } // switch (OrderList[OrderPos])
} }

View File

@@ -4670,10 +4670,12 @@ void TDynamicObject::LoadMMediaFile( std::string BaseDir, std::string TypeName,
*/ */
if( true == pAnimations.empty() ) if( true == pAnimations.empty() )
{ // jeśli nie ma jeszcze tabeli animacji, można odczytać nowe ilości { // jeśli nie ma jeszcze tabeli animacji, można odczytać nowe ilości
int co = 0, ile = -1; int co = 0;
iAnimations = 0; iAnimations = 0;
int ile;
do do
{ // kolejne liczby to ilość animacj, -1 to znacznik końca { // kolejne liczby to ilość animacj, -1 to znacznik końca
ile = -1;
parser.getTokens( 1, false ); parser.getTokens( 1, false );
parser >> ile; // ilość danego typu animacji parser >> ile; // ilość danego typu animacji
if (ile >= 0) if (ile >= 0)
@@ -6426,7 +6428,7 @@ TDynamicObject::powertrain_sounds::render( TMoverParameters const &Vehicle, doub
// main engine sound // main engine sound
if( true == Vehicle.Mains ) { if( true == Vehicle.Mains ) {
if( ( std::fabs( Vehicle.enrot ) > 0.01 ) if( ( std::abs( Vehicle.enrot ) > 0.01 )
// McZapkie-280503: zeby dla dumb dzialal silnik na jalowych obrotach // McZapkie-280503: zeby dla dumb dzialal silnik na jalowych obrotach
|| ( Vehicle.EngineType == Dumb ) ) { || ( Vehicle.EngineType == Dumb ) ) {

View File

@@ -741,6 +741,7 @@ public:
double Mred = 0.0; /*Ra: zredukowane masy wirujące; potrzebne do obliczeń hamowania*/ double Mred = 0.0; /*Ra: zredukowane masy wirujące; potrzebne do obliczeń hamowania*/
double TotalMass = 0.0; /*wyliczane przez ComputeMass*/ double TotalMass = 0.0; /*wyliczane przez ComputeMass*/
double HeatingPower = 0.0; double HeatingPower = 0.0;
double EngineHeatingRPM { 0.0 }; // guaranteed engine revolutions with heating enabled
double LightPower = 0.0; /*moc pobierana na ogrzewanie/oswietlenie*/ double LightPower = 0.0; /*moc pobierana na ogrzewanie/oswietlenie*/
double BatteryVoltage = 0.0; /*Winger - baterie w elektrykach*/ double BatteryVoltage = 0.0; /*Winger - baterie w elektrykach*/
bool Battery = false; /*Czy sa zalavzone baterie*/ bool Battery = false; /*Czy sa zalavzone baterie*/

View File

@@ -3302,7 +3302,7 @@ void TMoverParameters::CompressorCheck(double dt)
CompressedVolume += CompressedVolume +=
CompressorSpeed CompressorSpeed
* ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor * ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor
* ( DElist[ MainCtrlPos ].RPM / DElist[ MainCtrlPosNo ].RPM ) * ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM )
* dt; * dt;
} }
else { else {
@@ -3467,7 +3467,7 @@ void TMoverParameters::CompressorCheck(double dt)
// the compressor is coupled with the diesel engine, engine revolutions affect the output // the compressor is coupled with the diesel engine, engine revolutions affect the output
if( false == CompressorGovernorLock ) { if( false == CompressorGovernorLock ) {
auto const enginefactor { ( auto const enginefactor { (
EngineType == DieselElectric ? ( DElist[ MainCtrlPos ].RPM / DElist[ MainCtrlPosNo ].RPM ) : EngineType == DieselElectric ? ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM ) :
EngineType == DieselEngine ? ( std::abs( enrot ) / nmax ) : EngineType == DieselEngine ? ( std::abs( enrot ) / nmax ) :
1.0 ) }; // shouldn't ever get here but, eh 1.0 ) }; // shouldn't ever get here but, eh
CompressedVolume += CompressedVolume +=
@@ -4442,13 +4442,15 @@ double TMoverParameters::TractionForce( double dt ) {
if( ( true == Heating ) if( ( true == Heating )
&& ( HeatingPower > 0 ) && ( HeatingPower > 0 )
&& ( MainCtrlPosNo > MainCtrlPos ) ) { && ( EngineHeatingRPM > 0 ) ) {
// bump engine revolutions up if needed, when heating is on
int i = MainCtrlPosNo; tmp =
while( DElist[ i - 2 ].RPM / 60.0 > tmp ) { std::max(
--i; tmp,
} std::min(
tmp = DElist[ i ].RPM / 60.0; DElist[ MainCtrlPosNo ].RPM,
EngineHeatingRPM )
/ 60.0 );
} }
} }
else { else {
@@ -4719,6 +4721,7 @@ double TMoverParameters::TractionForce( double dt ) {
if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) { if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) {
Voltage = ( SST[ MainCtrlPos ].Umax * AnPos ) + ( SST[ MainCtrlPos ].Umin * ( 1.0 - AnPos ) ); Voltage = ( SST[ MainCtrlPos ].Umax * AnPos ) + ( SST[ MainCtrlPos ].Umin * ( 1.0 - AnPos ) );
// NOTE: very crude way to approximate power generated at current rpm instead of instant top output // NOTE: very crude way to approximate power generated at current rpm instead of instant top output
// NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
auto const rpmratio { 60.0 * enrot / DElist[ MainCtrlPos ].RPM }; auto const rpmratio { 60.0 * enrot / DElist[ MainCtrlPos ].RPM };
tmp = rpmratio * ( SST[ MainCtrlPos ].Pmax * AnPos ) + ( SST[ MainCtrlPos ].Pmin * ( 1.0 - AnPos ) ); tmp = rpmratio * ( SST[ MainCtrlPos ].Pmax * AnPos ) + ( SST[ MainCtrlPos ].Pmin * ( 1.0 - AnPos ) );
Ft = tmp * 1000.0 / ( abs( tmpV ) + 1.6 ); Ft = tmp * 1000.0 / ( abs( tmpV ) + 1.6 );
@@ -4735,6 +4738,7 @@ double TMoverParameters::TractionForce( double dt ) {
if( true == Heating ) { power -= HeatingPower; } if( true == Heating ) { power -= HeatingPower; }
if( power < 0.0 ) { power = 0.0; } if( power < 0.0 ) { power = 0.0; }
// NOTE: very crude way to approximate power generated at current rpm instead of instant top output // NOTE: very crude way to approximate power generated at current rpm instead of instant top output
// NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
auto const currentgenpower { ( auto const currentgenpower { (
DElist[ MainCtrlPos ].RPM > 0 ? DElist[ MainCtrlPos ].RPM > 0 ?
DElist[ MainCtrlPos ].GenPower * ( 60.0 * enrot / DElist[ MainCtrlPos ].RPM ) : DElist[ MainCtrlPos ].GenPower * ( 60.0 * enrot / DElist[ MainCtrlPos ].RPM ) :
@@ -8444,6 +8448,7 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
ImaxHi = 2; ImaxHi = 2;
ImaxLo = 1; ImaxLo = 1;
} }
extract_value( EngineHeatingRPM, "HeatingRPM", Input, "" );
break; break;
} }
case ElectricInductionMotor: { case ElectricInductionMotor: {

View File

@@ -5198,10 +5198,8 @@ bool TTrain::Update( double const Deltatime )
//--------- //---------
// hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy
if( ( mvControlled->Heating == true ) if( ( mvControlled->Heating == true )
&& ( ( mvControlled->ConverterFlag )
|| ( ( mvControlled->EngineType == ElectricSeriesMotor )
&& ( mvControlled->Mains == true ) && ( mvControlled->Mains == true )
&& ( mvControlled->ConvOvldFlag == false ) ) ) ) && ( mvControlled->ConvOvldFlag == false ) )
btLampkaOgrzewanieSkladu.Turn( true ); btLampkaOgrzewanieSkladu.Turn( true );
else else
btLampkaOgrzewanieSkladu.Turn( false ); btLampkaOgrzewanieSkladu.Turn( false );

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 18 #define VERSION_MAJOR 18
#define VERSION_MINOR 531 #define VERSION_MINOR 609
#define VERSION_REVISION 0 #define VERSION_REVISION 0