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

Merge with TMJ

This commit is contained in:
Królik Uszasty
2019-05-08 21:47:05 +02:00
7 changed files with 73 additions and 40 deletions

View File

@@ -1476,7 +1476,8 @@ TController::braking_distance_multiplier( float const Targetvelocity ) const {
if( ( mvOccupied->TrainType == dt_DMU ) if( ( mvOccupied->TrainType == dt_DMU )
&& ( mvOccupied->Vel < 40.0 ) && ( mvOccupied->Vel < 40.0 )
&& ( Targetvelocity == 0.f ) ) { && ( Targetvelocity == 0.f ) ) {
return interpolate( 2.f, 1.f, static_cast<float>( mvOccupied->Vel / 40.0 ) ); auto const multiplier { clamp( 1.f + iVehicles * 0.5f, 2.f, 4.f ) };
return interpolate( multiplier, 1.f, static_cast<float>( mvOccupied->Vel / 40.0 ) );
} }
// HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop // HACK: cargo trains or trains going downhill with high braking threshold need more distance to come to a full stop
if( ( fBrake_a0[ 1 ] > 0.2 ) if( ( fBrake_a0[ 1 ] > 0.2 )
@@ -2372,8 +2373,10 @@ double TController::BrakeAccFactor() const
|| ( mvOccupied->Vel > VelDesired + fVelPlus ) ) ) { || ( mvOccupied->Vel > VelDesired + fVelPlus ) ) ) {
Factor += ( fBrakeReaction * ( /*mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.5 ? 1.5 : 1 ) ) * mvOccupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS_pub ) / fAccThreshold ); Factor += ( fBrakeReaction * ( /*mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.5 ? 1.5 : 1 ) ) * mvOccupied->Vel / ( std::max( 0.0, ActualProximityDist ) + 1 ) * ( ( AccDesired - AbsAccS_pub ) / fAccThreshold );
} }
/*
if (mvOccupied->TrainType == dt_DMU && mvOccupied->Vel > 40 && VelNext<40) if (mvOccupied->TrainType == dt_DMU && mvOccupied->Vel > 40 && VelNext<40)
Factor *= 1 + 0.25 * ( (1600 - VelNext * VelNext) / (mvOccupied->Vel * mvOccupied->Vel) ); Factor *= 1 + 0.25 * ( (1600 - VelNext * VelNext) / (mvOccupied->Vel * mvOccupied->Vel) );
*/
return Factor; return Factor;
} }
@@ -2778,17 +2781,15 @@ bool TController::IncBrake()
{ {
if( /*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) { if( /*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) {
OK = /*mvOccupied->*/BrakeLevelAdd( BrakingInitialLevel ); //GBH OK = /*mvOccupied->*/BrakeLevelAdd( BrakingInitialLevel ); //GBH
/*
// HACK: stronger braking to overcome SA134 engine behaviour // HACK: stronger braking to overcome SA134 engine behaviour
if( ( mvOccupied->TrainType == dt_DMU ) if( ( mvOccupied->TrainType == dt_DMU )
&& ( VelNext == 0.0 ) && ( VelNext == 0.0 )
&& ( fBrakeDist < 200.0 ) ) { && ( fBrakeDist < 200.0 ) ) {
mvOccupied->BrakeLevelAdd( BrakeLevelAdd(
fBrakeDist / ActualProximityDist < 0.8 ? fBrakeDist / ActualProximityDist < 0.8 ?
1.0 : 0.5 :
3.0 ); 1.0 );
} }
*/
} }
else else
{ {
@@ -2809,8 +2810,10 @@ bool TController::IncBrake()
} }
} }
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition > 0 ) { if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition > 0 ) {
if( mvOccupied->Hamulec->Releaser() ) {
mvOccupied->BrakeReleaser( 0 ); mvOccupied->BrakeReleaser( 0 );
} }
}
break; break;
} }
case TBrakeSystem::ElectroPneumatic: { case TBrakeSystem::ElectroPneumatic: {
@@ -2863,7 +2866,7 @@ bool TController::IncBrakeEIM()
bool TController::DecBrake() bool TController::DecBrake()
{ // zmniejszenie siły hamowania { // zmniejszenie siły hamowania
bool OK = false; bool OK = false;
double deltaAcc = 0; double deltaAcc = -1.0;
double pos_diff = 1.0; double pos_diff = 1.0;
switch (mvOccupied->BrakeSystem) switch (mvOccupied->BrakeSystem)
{ {
@@ -2874,9 +2877,12 @@ bool TController::DecBrake()
OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired))); OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
break; break;
case TBrakeSystem::Pneumatic: case TBrakeSystem::Pneumatic:
if (mvOccupied->TrainType == dt_DMU) if( ( fBrake_a0[ 0 ] != 0.0 )
|| ( fBrake_a1[ 0 ] != 0.0 ) ) {
if( mvOccupied->TrainType == dt_DMU )
pos_diff = 0.25; pos_diff = 0.25;
deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - pos_diff)*fBrake_a1[0]); deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - pos_diff)*fBrake_a1[0]);
}
if (deltaAcc < 0) if (deltaAcc < 0)
{ {
if (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition > 0) if (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition > 0)
@@ -2895,8 +2901,11 @@ bool TController::DecBrake()
if (!OK) { if (!OK) {
OK = DecBrakeEIM(); OK = DecBrakeEIM();
} }
/*
// NOTE: disabled, duplicate of AI's behaviour in UpdateSituation()
if (mvOccupied->PipePress < 3.0) if (mvOccupied->PipePress < 3.0)
Need_BrakeRelease = true; Need_BrakeRelease = true;
*/
break; break;
case TBrakeSystem::ElectroPneumatic: case TBrakeSystem::ElectroPneumatic:
if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor) { if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor) {
@@ -5713,46 +5722,68 @@ TController::UpdateSituation(double dt) {
ReactionTime = 0.25; ReactionTime = 0.25;
} }
} }
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) // napełnianie uderzeniowe if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) {
if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P // napełnianie uderzeniowe
|| mvOccupied->BrakeHandle == TBrakeHandle::M394) if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a )
{ || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P )
|| ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) {
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) { if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) {
/*mvOccupied->*/BrakeLevelSet( gbh_RP ); /*mvOccupied->*/BrakeLevelSet( gbh_RP );
} }
if( ( mvOccupied->PipePress < 3.0 )
&& ( AccDesired > -0.03 ) ) { // TODO: combine all releaser handling in single decision tree instead of having bits all over the place
if( ( AccDesired > -0.03 )
&& ( false == mvOccupied->Hamulec->Releaser() ) ) {
if( mvOccupied->PipePress < 3.0 ) {
mvOccupied->BrakeReleaser( 1 ); mvOccupied->BrakeReleaser( 1 );
} }
if( ( mvOccupied->BrakePress > 0.4 )
&& ( mvOccupied->Hamulec->GetCRP() > 4.9 ) ) {
// wyluzuj lokomotywę, to szybciej ruszymy
mvOccupied->BrakeReleaser( 1 );
}
}
if( ( mvOccupied->PipePress > 3.0 )
&& ( mvOccupied->Hamulec->Releaser() ) ) {
// don't overcharge train brake pipe
mvOccupied->BrakeReleaser( 0 );
}
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 ) if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 )
&& ( AbsAccS < 0.03 ) && ( AbsAccS < 0.03 )
&& ( AccDesired > -0.03 ) && ( AccDesired > -0.03 )
&& ( VelDesired - mvOccupied->Vel > 2.0 ) ) { && ( VelDesired - mvOccupied->Vel > 2.0 ) ) {
if( ( mvOccupied->EqvtPipePress < 4.95 ) if( ( mvOccupied->EqvtPipePress < 4.5 )
&& ( fReady > 0.35 ) && ( fReady > 0.35 )
&& ( BrakeChargingCooldown >= 0.0 ) ) { && ( BrakeChargingCooldown >= 0.0 )
&& ( ( ActualProximityDist > 100.0 ) // don't charge if we're about to be braking soon
|| ( min_speed( mvOccupied->Vel, VelNext ) == mvOccupied->Vel ) ) ) {
if( ( iDrivigFlags & moveOerlikons ) if( ( iDrivigFlags & moveOerlikons )
|| ( true == IsCargoTrain ) ) { || ( true == IsCargoTrain ) ) {
// napełnianie w Oerlikonie // napełnianie w Oerlikonie
/* mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_FS ) ); GBH */ /* mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_FS ) ); GBH */
BrakeLevelSet(gbh_FS); BrakeLevelSet( gbh_FS );
// don't charge the brakes too often, or we risk overcharging // don't charge the brakes too often, or we risk overcharging
BrakeChargingCooldown = -120.0; BrakeChargingCooldown = -120.0;
} }
} }
/*
// NOTE: disabled, duplicate of release activation in #5732
else if( Need_BrakeRelease ) { else if( Need_BrakeRelease ) {
Need_BrakeRelease = false; Need_BrakeRelease = false;
mvOccupied->BrakeReleaser( 1 ); mvOccupied->BrakeReleaser( 1 );
} }
*/
} }
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition < 0 ) if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition < 0 )
&& ( mvOccupied->EqvtPipePress > ( fReady < 0.25 ? 5.1 : 5.2 ) ) ) { && ( mvOccupied->EqvtPipePress > ( fReady < 0.25 ? 5.1 : 5.2 ) ) ) {
/* GBH mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); */ /* GBH mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); */
BrakeLevelSet(gbh_RP); BrakeLevelSet( gbh_RP );
}
} }
} }
#if LOGVELOCITY #if LOGVELOCITY
@@ -5793,17 +5824,6 @@ TController::UpdateSituation(double dt) {
AccDesired > 0.0 ) ) { AccDesired > 0.0 ) ) {
// on slopes disengage the brakes only if you actually intend to accelerate // on slopes disengage the brakes only if you actually intend to accelerate
while( true == DecBrake() ) { ; } // jeśli przyspieszamy, to nie hamujemy while( true == DecBrake() ) { ; } // jeśli przyspieszamy, to nie hamujemy
if( ( mvOccupied->BrakePress > 0.4 )
&& ( mvOccupied->Hamulec->GetCRP() > 4.9 ) ) {
// wyluzuj lokomotywę, to szybciej ruszymy
mvOccupied->BrakeReleaser( 1 );
}
else {
if( mvOccupied->PipePress >= 3.0 ) {
// TODO: combine all releaser handling in single decision tree instead of having bits all over the place
mvOccupied->BrakeReleaser( 0 );
}
}
} }
} }
} }

View File

@@ -280,7 +280,7 @@ private:
int iCoupler = 0; // maska sprzęgu, jaką należy użyć przy łączeniu (po osiągnięciu trybu Connect), 0 gdy jazda bez łączenia int iCoupler = 0; // maska sprzęgu, jaką należy użyć przy łączeniu (po osiągnięciu trybu Connect), 0 gdy jazda bez łączenia
int iDriverFailCount = 0; // licznik błędów AI int iDriverFailCount = 0; // licznik błędów AI
bool Need_TryAgain = false; // true, jeśli druga pozycja w elektryku nie załapała bool Need_TryAgain = false; // true, jeśli druga pozycja w elektryku nie załapała
bool Need_BrakeRelease = true; // bool Need_BrakeRelease = true;
bool IsAtPassengerStop{ false }; // true if the consist is within acceptable range of w4 post bool IsAtPassengerStop{ false }; // true if the consist is within acceptable range of w4 post
double fMinProximityDist = 30.0; // stawanie między 30 a 60 m przed przeszkodą // minimalna oległość do przeszkody, jaką należy zachować double fMinProximityDist = 30.0; // stawanie między 30 a 60 m przed przeszkodą // minimalna oległość do przeszkody, jaką należy zachować
double fOverhead1 = 3000.0; // informacja o napięciu w sieci trakcyjnej (0=brak drutu, zatrzymaj!) double fOverhead1 = 3000.0; // informacja o napięciu w sieci trakcyjnej (0=brak drutu, zatrzymaj!)

View File

@@ -4935,7 +4935,14 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
if( false == MoverParameters->LoadAttributes.empty() ) { if( false == MoverParameters->LoadAttributes.empty() ) {
// Ra: tu wczytywanie modelu ładunku jest w porządku // Ra: tu wczytywanie modelu ładunku jest w porządku
// bieżąca ścieżka do tekstur to dynamic/...
Global.asCurrentTexturePath = asBaseDir;
mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name ); mdLoad = LoadMMediaFile_mdload( MoverParameters->LoadType.name );
// z powrotem defaultowa sciezka do tekstur
Global.asCurrentTexturePath = std::string( szTexturePath );
} }
} // models } // models

View File

@@ -385,6 +385,11 @@ void TBrake::Releaser( int const state )
BrakeStatus = (BrakeStatus & ~b_rls) | ( state * b_rls ); BrakeStatus = (BrakeStatus & ~b_rls) | ( state * b_rls );
} }
bool TBrake::Releaser() const {
return ( ( BrakeStatus & b_rls ) == b_rls );
}
void TBrake::SetEPS( double const nEPS ) void TBrake::SetEPS( double const nEPS )
{ {
} }

View File

@@ -203,6 +203,7 @@ class TBrake {
virtual double GetCRP(); //cisnienie zbiornika sterujacego virtual double GetCRP(); //cisnienie zbiornika sterujacego
bool SetBDF( int const nBDF ); //nastawiacz GPRM bool SetBDF( int const nBDF ); //nastawiacz GPRM
void Releaser( int const state ); //odluzniacz void Releaser( int const state ); //odluzniacz
bool Releaser() const;
virtual void SetEPS( double const nEPS ); //hamulec EP virtual void SetEPS( double const nEPS ); //hamulec EP
virtual void SetRM( double const RMR ) {}; //ustalenie przelozenia rapida virtual void SetRM( double const RMR ) {}; //ustalenie przelozenia rapida
virtual void SetRV( double const RVR) {}; //ustalenie przelozenia rapida virtual void SetRV( double const RVR) {}; //ustalenie przelozenia rapida

View File

@@ -450,10 +450,10 @@ dictionary_source *TTrain::GetTrainState() {
// reverser // reverser
dict->insert( "direction", mover->ActiveDir ); dict->insert( "direction", mover->ActiveDir );
// throttle // throttle
dict->insert( "mainctrl_pos", mover->MainCtrlPos ); dict->insert( "mainctrl_pos", mvControlled->MainCtrlPos );
dict->insert( "main_ctrl_actual_pos", mover->MainCtrlActualPos ); dict->insert( "main_ctrl_actual_pos", mvControlled->MainCtrlActualPos );
dict->insert( "scndctrl_pos", mover->ScndCtrlPos ); dict->insert( "scndctrl_pos", mvControlled->ScndCtrlPos );
dict->insert( "scnd_ctrl_actual_pos", mover->ScndCtrlActualPos ); dict->insert( "scnd_ctrl_actual_pos", mvControlled->ScndCtrlActualPos );
dict->insert( "new_speed", mover->NewSpeed); dict->insert( "new_speed", mover->NewSpeed);
// brakes // brakes
dict->insert( "manual_brake", ( mvOccupied->ManualBrakePos > 0 ) ); dict->insert( "manual_brake", ( mvOccupied->ManualBrakePos > 0 ) );

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 19 #define VERSION_MAJOR 19
#define VERSION_MINOR 419 #define VERSION_MINOR 430
#define VERSION_REVISION 0 #define VERSION_REVISION 0