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 )
&& ( mvOccupied->Vel < 40.0 )
&& ( 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
if( ( fBrake_a0[ 1 ] > 0.2 )
@@ -2372,8 +2373,10 @@ double TController::BrakeAccFactor() const
|| ( 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 );
}
/*
if (mvOccupied->TrainType == dt_DMU && mvOccupied->Vel > 40 && VelNext<40)
Factor *= 1 + 0.25 * ( (1600 - VelNext * VelNext) / (mvOccupied->Vel * mvOccupied->Vel) );
*/
return Factor;
}
@@ -2778,17 +2781,15 @@ bool TController::IncBrake()
{
if( /*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition < 0.1 ) {
OK = /*mvOccupied->*/BrakeLevelAdd( BrakingInitialLevel ); //GBH
/*
// HACK: stronger braking to overcome SA134 engine behaviour
if( ( mvOccupied->TrainType == dt_DMU )
&& ( VelNext == 0.0 )
&& ( fBrakeDist < 200.0 ) ) {
mvOccupied->BrakeLevelAdd(
BrakeLevelAdd(
fBrakeDist / ActualProximityDist < 0.8 ?
1.0 :
3.0 );
0.5 :
1.0 );
}
*/
}
else
{
@@ -2809,7 +2810,9 @@ bool TController::IncBrake()
}
}
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition > 0 ) {
mvOccupied->BrakeReleaser( 0 );
if( mvOccupied->Hamulec->Releaser() ) {
mvOccupied->BrakeReleaser( 0 );
}
}
break;
}
@@ -2863,8 +2866,8 @@ bool TController::IncBrakeEIM()
bool TController::DecBrake()
{ // zmniejszenie siły hamowania
bool OK = false;
double deltaAcc = 0;
double pos_diff = 1.0;
double deltaAcc = -1.0;
double pos_diff = 1.0;
switch (mvOccupied->BrakeSystem)
{
case TBrakeSystem::Individual:
@@ -2874,9 +2877,12 @@ bool TController::DecBrake()
OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
break;
case TBrakeSystem::Pneumatic:
if (mvOccupied->TrainType == dt_DMU)
pos_diff = 0.25;
deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - pos_diff)*fBrake_a1[0]);
if( ( fBrake_a0[ 0 ] != 0.0 )
|| ( fBrake_a1[ 0 ] != 0.0 ) ) {
if( mvOccupied->TrainType == dt_DMU )
pos_diff = 0.25;
deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - pos_diff)*fBrake_a1[0]);
}
if (deltaAcc < 0)
{
if (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition > 0)
@@ -2895,8 +2901,11 @@ bool TController::DecBrake()
if (!OK) {
OK = DecBrakeEIM();
}
/*
// NOTE: disabled, duplicate of AI's behaviour in UpdateSituation()
if (mvOccupied->PipePress < 3.0)
Need_BrakeRelease = true;
*/
break;
case TBrakeSystem::ElectroPneumatic:
if (mvOccupied->EngineType == TEngineType::ElectricInductionMotor) {
@@ -5713,16 +5722,32 @@ TController::UpdateSituation(double dt) {
ReactionTime = 0.25;
}
}
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) // napełnianie uderzeniowe
if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P
|| mvOccupied->BrakeHandle == TBrakeHandle::M394)
{
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) {
// napełnianie uderzeniowe
if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a )
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P )
|| ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) {
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) {
/*mvOccupied->*/BrakeLevelSet( gbh_RP );
}
if( ( mvOccupied->PipePress < 3.0 )
&& ( AccDesired > -0.03 ) ) {
mvOccupied->BrakeReleaser( 1 );
// 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 );
}
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 )
@@ -5730,31 +5755,37 @@ TController::UpdateSituation(double dt) {
&& ( AccDesired > -0.03 )
&& ( VelDesired - mvOccupied->Vel > 2.0 ) ) {
if( ( mvOccupied->EqvtPipePress < 4.95 )
if( ( mvOccupied->EqvtPipePress < 4.5 )
&& ( 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 )
|| ( true == IsCargoTrain ) ) {
// napełnianie w Oerlikonie
/* 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
BrakeChargingCooldown = -120.0;
}
}
/*
// NOTE: disabled, duplicate of release activation in #5732
else if( Need_BrakeRelease ) {
Need_BrakeRelease = false;
mvOccupied->BrakeReleaser( 1 );
}
*/
}
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition < 0 )
&& ( mvOccupied->EqvtPipePress > ( fReady < 0.25 ? 5.1 : 5.2 ) ) ) {
/* GBH mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); */
BrakeLevelSet(gbh_RP);
BrakeLevelSet( gbh_RP );
}
}
}
#if LOGVELOCITY
WriteLog("Dist=" + FloatToStrF(ActualProximityDist, ffFixed, 7, 1) +
", VelDesired=" + FloatToStrF(VelDesired, ffFixed, 7, 1) +
@@ -5793,17 +5824,6 @@ TController::UpdateSituation(double dt) {
AccDesired > 0.0 ) ) {
// on slopes disengage the brakes only if you actually intend to accelerate
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 iDriverFailCount = 0; // licznik błędów AI
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
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!)

View File

@@ -4935,7 +4935,14 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
if( false == MoverParameters->LoadAttributes.empty() ) {
// 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 );
// z powrotem defaultowa sciezka do tekstur
Global.asCurrentTexturePath = std::string( szTexturePath );
}
} // models

View File

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

View File

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

View File

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

View File

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