mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
Merge branch 'gfx-work' into sim
This commit is contained in:
357
Driver.cpp
357
Driver.cpp
@@ -1406,9 +1406,12 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
|
||||
// if (v==0.0) fAcc=-0.9; //hamowanie jeśli stop
|
||||
continue; // i tyle wystarczy
|
||||
}
|
||||
else // event trzyma tylko jeśli VelNext=0, nawet po przejechaniu (nie powinno
|
||||
// dotyczyć samochodów?)
|
||||
a = (v == 0.0 ? -1.0 : fAcc); // ruszanie albo hamowanie
|
||||
else // event trzyma tylko jeśli VelNext=0, nawet po przejechaniu (nie powinno dotyczyć samochodów?)
|
||||
a = (v > 0.0 ?
|
||||
fAcc :
|
||||
mvOccupied->Vel < 0.01 ?
|
||||
0.0 : // already standing still so no need to bother with brakes
|
||||
-2.0 ); // ruszanie albo hamowanie
|
||||
|
||||
if ((a < fAcc) && (v == std::min(v, fNext))) {
|
||||
// mniejsze przyspieszenie to mniejsza możliwość rozpędzenia się albo konieczność hamowania
|
||||
@@ -1763,15 +1766,10 @@ void TController::Activation()
|
||||
if (iDirection)
|
||||
{ // jeśli jest ustalony kierunek
|
||||
TDynamicObject *old = pVehicle, *d = pVehicle; // w tym siedzi AI
|
||||
TController *drugi; // jakby były dwa, to zamienić miejscami, a nie robić wycieku pamięci
|
||||
// poprzez nadpisanie
|
||||
TController *drugi; // jakby były dwa, to zamienić miejscami, a nie robić wycieku pamięci poprzez nadpisanie
|
||||
auto const localbrakelevel { mvOccupied->LocalBrakePosA };
|
||||
while (mvControlling->MainCtrlPos) // samo zapętlenie DecSpeed() nie wystarcza :/
|
||||
DecSpeed(true); // wymuszenie zerowania nastawnika jazdy
|
||||
while (mvOccupied->ActiveDir < 0)
|
||||
mvOccupied->DirectionForward(); // kierunek na 0
|
||||
while (mvOccupied->ActiveDir > 0)
|
||||
mvOccupied->DirectionBackward();
|
||||
ZeroSpeed();
|
||||
ZeroDirection();
|
||||
if (TestFlag(d->MoverParameters->Couplers[iDirectionOrder < 0 ? 1 : 0].CouplingFlag, ctrain_controll)) {
|
||||
mvControlling->MainSwitch( false); // dezaktywacja czuwaka, jeśli przejście do innego członu
|
||||
mvOccupied->DecLocalBrakeLevel(LocalBrakePosNo); // zwolnienie hamulca w opuszczanym pojeździe
|
||||
@@ -1779,6 +1777,7 @@ void TController::Activation()
|
||||
// zaworze maszynisty, FVel6 po drugiej stronie nie luzuje
|
||||
mvOccupied->BrakeLevelSet(
|
||||
mvOccupied->Handle->GetPos(bh_NP)); // odcięcie na zaworze maszynisty
|
||||
BrakeLevelSet(gbh_NP); //ustawienie zmiennej GBH
|
||||
}
|
||||
mvOccupied->ActiveCab = mvOccupied->CabNo; // użytkownik moze zmienić ActiveCab wychodząc
|
||||
mvOccupied->CabDeactivisation(); // tak jest w Train.cpp
|
||||
@@ -2357,7 +2356,7 @@ double TController::BrakeAccFactor() const
|
||||
double Factor = 1.0;
|
||||
if( ( ActualProximityDist > fMinProximityDist )
|
||||
|| ( mvOccupied->Vel > VelDesired + fVelPlus ) ) {
|
||||
Factor += ( fBrakeReaction * ( mvOccupied->BrakeCtrlPosR < 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 );
|
||||
}
|
||||
return Factor;
|
||||
}
|
||||
@@ -2394,9 +2393,9 @@ void TController::SetDriverPsyche()
|
||||
}
|
||||
if (mvControlling && mvOccupied)
|
||||
{ // with Controlling do
|
||||
if (mvControlling->MainCtrlPos < 3)
|
||||
if (mvControlling->MainCtrlPowerPos() < 3)
|
||||
ReactionTime = mvControlling->InitialCtrlDelay + ReactionTime;
|
||||
if (mvOccupied->BrakeCtrlPos > 1)
|
||||
if (/* GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition > 1)
|
||||
ReactionTime = 0.5 * ReactionTime;
|
||||
}
|
||||
};
|
||||
@@ -2491,17 +2490,16 @@ bool TController::PrepareEngine()
|
||||
{ // część wykonawcza dla sterowania przez komputer
|
||||
if (mvControlling->ConvOvldFlag)
|
||||
{ // wywalił bezpiecznik nadmiarowy przetwornicy
|
||||
while (DecSpeed(true))
|
||||
; // zerowanie napędu
|
||||
ZeroSpeed();
|
||||
mvControlling->ConvOvldFlag = false; // reset nadmiarowego
|
||||
}
|
||||
else if (false == IsLineBreakerClosed) {
|
||||
while (DecSpeed(true))
|
||||
; // zerowanie napędu
|
||||
ZeroSpeed();
|
||||
if( mvOccupied->TrainType == dt_SN61 ) {
|
||||
// specjalnie dla SN61 żeby nie zgasł
|
||||
if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) {
|
||||
mvControlling->IncMainCtrl( 1 );
|
||||
while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 )
|
||||
&& ( mvControlling->IncMainCtrl( 1 ) ) ) {
|
||||
;
|
||||
}
|
||||
}
|
||||
if( ( mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector )
|
||||
@@ -2522,6 +2520,7 @@ bool TController::PrepareEngine()
|
||||
// enable train brake if it's off
|
||||
if( mvOccupied->fBrakeCtrlPos == mvOccupied->Handle->GetPos( bh_NP ) ) {
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) );
|
||||
BrakeLevelSet(gbh_RP); // GBH
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2560,9 +2559,7 @@ bool TController::ReleaseEngine() {
|
||||
VelDesired = 0.0;
|
||||
AccDesired = std::min( AccDesired, -1.25 ); // hamuj solidnie
|
||||
ReactionTime = 0.1;
|
||||
while( DecSpeed( true ) ) {
|
||||
; // zerowanie nastawników
|
||||
}
|
||||
ZeroSpeed();
|
||||
IncBrake();
|
||||
// don't bother with the rest until we're standing still
|
||||
return false;
|
||||
@@ -2599,12 +2596,8 @@ bool TController::ReleaseEngine() {
|
||||
;
|
||||
}
|
||||
}
|
||||
while( DecSpeed( true ) ) {
|
||||
; // zerowanie nastawników
|
||||
}
|
||||
// set direction to neutral
|
||||
while( ( mvOccupied->ActiveDir > 0 ) && ( mvOccupied->DirectionBackward() ) ) { ; }
|
||||
while( ( mvOccupied->ActiveDir < 0 ) && ( mvOccupied->DirectionForward() ) ) { ; }
|
||||
ZeroSpeed();
|
||||
ZeroDirection();
|
||||
|
||||
// zamykanie drzwi
|
||||
mvOccupied->OperateDoors( side::right, false );
|
||||
@@ -2716,14 +2709,22 @@ bool TController::IncBrake()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//standalone = standalone && ( mvControlling->EIMCtrlType == 0 );
|
||||
|
||||
if( true == standalone ) {
|
||||
OK = mvOccupied->IncLocalBrakeLevel(
|
||||
1 + static_cast<int>( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); // hamowanie lokalnym bo luzem jedzie
|
||||
if( mvControlling->EIMCtrlType > 0 ) {
|
||||
OK = IncBrakeEIM();
|
||||
}
|
||||
else {
|
||||
OK = mvOccupied->IncLocalBrakeLevel(
|
||||
1 + static_cast<int>( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); // hamowanie lokalnym bo luzem jedzie
|
||||
}
|
||||
}
|
||||
else {
|
||||
if( mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo ) {
|
||||
if( /*GBH mvOccupied->BrakeCtrlPos*/ BrakeCtrlPosition + 1 == gbh_MAX ) {
|
||||
if (AccDesired < -1.5) // hamowanie nagle
|
||||
OK = mvOccupied->BrakeLevelAdd(1.0);
|
||||
OK = /*mvOccupied->*/BrakeLevelAdd(1.0); //GBH
|
||||
else
|
||||
OK = false;
|
||||
}
|
||||
@@ -2747,12 +2748,12 @@ bool TController::IncBrake()
|
||||
pos_corr += mvOccupied->Handle->GetCP()*0.2;
|
||||
|
||||
}
|
||||
double deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4.0 * (mvOccupied->BrakeCtrlPosR - 1 - pos_corr)*fBrake_a1[0]);
|
||||
double deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4.0 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition - 1 - pos_corr)*fBrake_a1[0]);
|
||||
|
||||
if( deltaAcc > fBrake_a1[0])
|
||||
{
|
||||
if( mvOccupied->BrakeCtrlPosR < 0.1 ) {
|
||||
OK = mvOccupied->BrakeLevelAdd( BrakingInitialLevel );
|
||||
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 )
|
||||
@@ -2767,19 +2768,23 @@ bool TController::IncBrake()
|
||||
}
|
||||
else
|
||||
{
|
||||
OK = mvOccupied->BrakeLevelAdd( BrakingLevelIncrease );
|
||||
OK = /*mvOccupied->*/BrakeLevelAdd( BrakingLevelIncrease ); //GBH
|
||||
// brake harder if the acceleration is much higher than desired
|
||||
if( ( deltaAcc > 2 * fBrake_a1[ 0 ] )
|
||||
/*if( ( deltaAcc > 2 * fBrake_a1[ 0 ] )
|
||||
&& ( mvOccupied->BrakeCtrlPosR + BrakingLevelIncrease <= 5.0 ) ) {
|
||||
mvOccupied->BrakeLevelAdd( BrakingLevelIncrease );
|
||||
}
|
||||
} GBH */
|
||||
if ((deltaAcc > 2 * fBrake_a1[0])
|
||||
&& (BrakeCtrlPosition + BrakingLevelIncrease <= 5.0)) {
|
||||
/*mvOccupied->*/BrakeLevelAdd(BrakingLevelIncrease);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
OK = false;
|
||||
}
|
||||
}
|
||||
if( mvOccupied->BrakeCtrlPos > 0 ) {
|
||||
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition > 0 ) {
|
||||
mvOccupied->BrakeReleaser( 0 );
|
||||
}
|
||||
break;
|
||||
@@ -2844,20 +2849,25 @@ bool TController::DecBrake()
|
||||
OK = mvOccupied->DecLocalBrakeLevel(1 + floor(0.5 + fabs(AccDesired)));
|
||||
break;
|
||||
case TBrakeSystem::Pneumatic:
|
||||
deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (mvOccupied->BrakeCtrlPosR-1.0)*fBrake_a1[0]);
|
||||
deltaAcc = -AccDesired*BrakeAccFactor() - (fBrake_a0[0] + 4 * (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition -1.0)*fBrake_a1[0]);
|
||||
if (deltaAcc < 0)
|
||||
{
|
||||
if (mvOccupied->BrakeCtrlPosR > 0)
|
||||
if (/*GBH mvOccupied->BrakeCtrlPosR*/BrakeCtrlPosition > 0)
|
||||
{
|
||||
OK = mvOccupied->BrakeLevelAdd(-0.25);
|
||||
OK = /*mvOccupied->*/BrakeLevelAdd(-0.25);
|
||||
//if ((deltaAcc < 5 * fBrake_a1[0]) && (mvOccupied->BrakeCtrlPosR >= 1.2))
|
||||
// mvOccupied->BrakeLevelAdd(-1.0);
|
||||
if (mvOccupied->BrakeCtrlPosR < 0.74)
|
||||
mvOccupied->BrakeLevelSet(0.0);
|
||||
/* if (mvOccupied->BrakeCtrlPosR < 0.74) GBH */
|
||||
if (BrakeCtrlPosition < 0.74)
|
||||
/*mvOccupied->*/BrakeLevelSet(0.0);
|
||||
}
|
||||
}
|
||||
if (!OK)
|
||||
if( !OK ) {
|
||||
OK = mvOccupied->DecLocalBrakeLevel(2);
|
||||
}
|
||||
if (!OK) {
|
||||
OK = DecBrakeEIM();
|
||||
}
|
||||
if (mvOccupied->PipePress < 3.0)
|
||||
Need_BrakeRelease = true;
|
||||
break;
|
||||
@@ -2942,7 +2952,7 @@ bool TController::IncSpeed()
|
||||
return false; // to nici z ruszania
|
||||
}
|
||||
if (!mvControlling->FuseFlag) //&&mvControlling->StLinFlag) //yBARC
|
||||
if ((mvControlling->MainCtrlPos == 0) ||
|
||||
if ((mvControlling->IsMainCtrlNoPowerPos()) ||
|
||||
(mvControlling->StLinFlag)) // youBy polecił dodać 2012-09-08 v367
|
||||
// na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag)
|
||||
if (Ready || (iDrivigFlags & movePress)) {
|
||||
@@ -3024,7 +3034,7 @@ bool TController::IncSpeed()
|
||||
}
|
||||
|
||||
if( ( mvControlling->Im == 0 )
|
||||
&& ( mvControlling->MainCtrlPos > 2 ) ) {
|
||||
&& ( mvControlling->MainCtrlPowerPos() > 1 ) ) {
|
||||
// brak prądu na dalszych pozycjach
|
||||
// nie załączona lokomotywa albo wywalił nadmiarowy
|
||||
Need_TryAgain = true;
|
||||
@@ -3092,6 +3102,13 @@ bool TController::IncSpeed()
|
||||
return OK;
|
||||
}
|
||||
|
||||
void TController::ZeroSpeed( bool const Enforce ) {
|
||||
|
||||
while( DecSpeed( Enforce ) ) {
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
bool TController::DecSpeed(bool force)
|
||||
{ // zmniejszenie prędkości (ale nie hamowanie)
|
||||
bool OK = false; // domyślnie false, aby wyszło z pętli while
|
||||
@@ -3101,20 +3118,20 @@ bool TController::DecSpeed(bool force)
|
||||
iDrivigFlags &= ~moveIncSpeed; // usunięcie flagi jazdy
|
||||
if (force) // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania
|
||||
if (mvControlling->MainCtrlPosNo > 0) // McZapkie-041003: wagon sterowniczy, np. EZT
|
||||
mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0));
|
||||
mvControlling->DecMainCtrl((mvControlling->MainCtrlPowerPos() > 1 ? 2 : 1));
|
||||
mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania
|
||||
return false;
|
||||
case TEngineType::ElectricSeriesMotor:
|
||||
OK = mvControlling->DecScndCtrl(2); // najpierw bocznik na zero
|
||||
if (!OK)
|
||||
OK = mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0));
|
||||
OK = mvControlling->DecMainCtrl((mvControlling->MainCtrlPowerPos() > 1 ? 2 : 1));
|
||||
mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania
|
||||
break;
|
||||
case TEngineType::Dumb:
|
||||
case TEngineType::DieselElectric:
|
||||
OK = mvControlling->DecScndCtrl(2);
|
||||
if (!OK)
|
||||
OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPos / 2));
|
||||
OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPowerPos() / 2));
|
||||
break;
|
||||
case TEngineType::ElectricInductionMotor:
|
||||
OK = DecSpeedEIM();
|
||||
@@ -3133,12 +3150,14 @@ bool TController::DecSpeed(bool force)
|
||||
if (mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0)
|
||||
OK = mvControlling->DecMainCtrl(1);
|
||||
}
|
||||
else
|
||||
while ((mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0) &&
|
||||
(mvControlling->MainCtrlPos > 1))
|
||||
OK = mvControlling->DecMainCtrl(1);
|
||||
else {
|
||||
while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 )
|
||||
&& ( mvControlling->MainCtrlPowerPos() > 1 ) ) {
|
||||
OK = mvControlling->DecMainCtrl( 1 );
|
||||
}
|
||||
}
|
||||
if (force) // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania
|
||||
OK = mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0));
|
||||
OK = mvControlling->DecMainCtrl((mvControlling->MainCtrlPowerPos() > 2 ? 2 : 1));
|
||||
break;
|
||||
}
|
||||
return OK;
|
||||
@@ -3166,6 +3185,22 @@ bool TController::DecSpeedEIM()
|
||||
return OK;
|
||||
}
|
||||
|
||||
void TController::BrakeLevelSet(double b)
|
||||
{ // ustawienie pozycji hamulca na wartość (b) w zakresie od -2 do BrakeCtrlPosNo
|
||||
// jedyny dopuszczalny sposób przestawienia hamulca zasadniczego
|
||||
if (BrakeCtrlPosition == b)
|
||||
return; // nie przeliczać, jak nie ma zmiany
|
||||
BrakeCtrlPosition = clamp(b, (double)gbh_MIN, (double)gbh_MAX);
|
||||
}
|
||||
|
||||
bool TController::BrakeLevelAdd(double b)
|
||||
{ // dodanie wartości (b) do pozycji hamulca (w tym ujemnej)
|
||||
// zwraca false, gdy po dodaniu było by poza zakresem
|
||||
BrakeLevelSet(BrakeCtrlPosition + b);
|
||||
return b > 0.0 ? (BrakeCtrlPosition < gbh_MAX) :
|
||||
(BrakeCtrlPosition > -1.0); // true, jeśli można kontynuować
|
||||
}
|
||||
|
||||
void TController::SpeedSet()
|
||||
{ // Ra: regulacja prędkości, wykonywana w każdym przebłysku świadomości AI
|
||||
// ma dokręcać do bezoporowych i zdejmować pozycje w przypadku przekroczenia prądu
|
||||
@@ -3238,8 +3273,7 @@ void TController::SpeedSet()
|
||||
if( ( false == mvControlling->StLinFlag )
|
||||
&& ( false == mvControlling->DelayCtrlFlag ) ) {
|
||||
// styczniki liniowe rozłączone yBARC
|
||||
while( DecSpeed() )
|
||||
; // zerowanie napędu
|
||||
ZeroSpeed();
|
||||
}
|
||||
else if (Ready || (iDrivigFlags & movePress)) // o ile może jechać
|
||||
if (fAccGravity < -0.10) // i jedzie pod górę większą niż 10 promil
|
||||
@@ -3340,6 +3374,74 @@ void TController::SpeedCntrl(double DesiredSpeed)
|
||||
}
|
||||
};
|
||||
|
||||
void TController::SetTimeControllers()
|
||||
{
|
||||
//1. Check the type of Main Brake Handle
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic)
|
||||
{
|
||||
if (mvOccupied->Handle->Time)
|
||||
{
|
||||
if ((BrakeCtrlPosition > 0) && (mvOccupied->Handle->GetCP() - 0.05 > mvOccupied->HighPipePress - BrakeCtrlPosition*0.25*mvOccupied->DeltaPipePress))
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_FB));
|
||||
else if ((BrakeCtrlPosition > 0) && (mvOccupied->Handle->GetCP() + 0.05 < mvOccupied->HighPipePress - BrakeCtrlPosition*0.25*mvOccupied->DeltaPipePress))
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP));
|
||||
else if (BrakeCtrlPosition == 0)
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP));
|
||||
else if (BrakeCtrlPosition == -1)
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_FS));
|
||||
else if (BrakeCtrlPosition == -2)
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_NP));
|
||||
}
|
||||
if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a) mvOccupied->BrakeLevelSet(BrakeCtrlPosition);
|
||||
}
|
||||
//2. Check the type of Secondary Brake Handle
|
||||
|
||||
//3. Check the type od EIMCtrlType
|
||||
if (mvOccupied->EIMCtrlType > 0)
|
||||
{
|
||||
if (mvOccupied->EIMCtrlType == 1) //traxx
|
||||
{
|
||||
if (mvOccupied->LocalBrakePosA > 0.95) mvOccupied->MainCtrlPos = 0;
|
||||
}
|
||||
else if (mvOccupied->EIMCtrlType == 2) //elf
|
||||
{
|
||||
if (mvOccupied->LocalBrakePosA > 0.95) mvOccupied->MainCtrlPos = 1;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
void TController::CheckTimeControllers()
|
||||
{
|
||||
//1. Check the type of Main Brake Handle
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic && mvOccupied->Handle->TimeEP)
|
||||
{
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_EPN));
|
||||
}
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic && mvOccupied->Handle->Time)
|
||||
{
|
||||
if (BrakeCtrlPosition > 0)
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_MB));
|
||||
else
|
||||
mvOccupied->BrakeLevelSet(mvOccupied->Handle->GetPos(bh_RP));
|
||||
}
|
||||
//2. Check the type of Secondary Brake Handle
|
||||
|
||||
//3. Check the type od EIMCtrlType
|
||||
if (mvOccupied->EIMCtrlType > 0)
|
||||
{
|
||||
if (mvOccupied->EIMCtrlType == 1) //traxx
|
||||
{
|
||||
if (mvOccupied->MainCtrlPos > 3) mvOccupied->MainCtrlPos = 5;
|
||||
if (mvOccupied->MainCtrlPos < 3) mvOccupied->MainCtrlPos = 1;
|
||||
}
|
||||
else if (mvOccupied->EIMCtrlType == 2) //elf
|
||||
{
|
||||
if (mvOccupied->eimic > 0) mvOccupied->MainCtrlPos = 3;
|
||||
if (mvOccupied->eimic < 0) mvOccupied->MainCtrlPos = 2;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
// otwieranie/zamykanie drzwi w składzie albo (tylko AI) EZT
|
||||
void TController::Doors( bool const Open, int const Side ) {
|
||||
|
||||
@@ -4013,7 +4115,7 @@ TController::UpdateSituation(double dt) {
|
||||
// Ra: odluźnianie przeładowanych lokomotyw, ciągniętych na zimno - prowizorka...
|
||||
if (AIControllFlag) // skład jak dotąd był wyluzowany
|
||||
{
|
||||
if( ( mvOccupied->BrakeCtrlPos == 0 ) // jest pozycja jazdy
|
||||
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 ) // jest pozycja jazdy
|
||||
&& ( ( vehicle->Hamulec->GetBrakeStatus() & b_dmg ) == 0 ) // brake isn't broken
|
||||
&& ( vehicle->PipePress - 5.0 > -0.1 ) // jeśli ciśnienie jak dla jazdy
|
||||
&& ( vehicle->Hamulec->GetCRP() > vehicle->PipePress + 0.12 ) ) { // za dużo w zbiorniku
|
||||
@@ -4102,9 +4204,14 @@ TController::UpdateSituation(double dt) {
|
||||
// TODO: check if this situation still happens and the hack is still needed
|
||||
if( ( false == AIControllFlag )
|
||||
&& ( iDrivigFlags & moveDoorOpened )
|
||||
&& ( mvOccupied->Doors.close_control != control_t::driver )
|
||||
&& ( mvControlling->MainCtrlPos > ( mvControlling->EngineType != TEngineType::DieselEngine ? 0 : 1 ) ) ) { // for diesel 1st position is effectively 0
|
||||
Doors( false );
|
||||
&& ( mvOccupied->Doors.close_control != control_t::driver ) ) {
|
||||
// for diesel engines react when engine is put past idle revolutions
|
||||
// for others straightforward master controller check
|
||||
if( ( mvControlling->EngineType == TEngineType::DieselEngine ?
|
||||
mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 :
|
||||
mvControlling->MainCtrlPowerPos() > 0 ) ) {
|
||||
Doors( false );
|
||||
}
|
||||
}
|
||||
|
||||
// basic situational ai operations
|
||||
@@ -4165,7 +4272,7 @@ TController::UpdateSituation(double dt) {
|
||||
// is moving
|
||||
if( ( fOverhead2 >= 0.0 ) || iOverheadZero ) {
|
||||
// jeśli jazda bezprądowa albo z opuszczonym pantografem
|
||||
while( DecSpeed( true ) ) { ; } // zerowanie napędu
|
||||
ZeroSpeed();
|
||||
}
|
||||
if( ( fOverhead2 > 0.0 ) || iOverheadDown ) {
|
||||
// jazda z opuszczonymi pantografami
|
||||
@@ -4261,7 +4368,7 @@ TController::UpdateSituation(double dt) {
|
||||
if( ( true == TestFlag( iDrivigFlags, moveStartHornNow ) )
|
||||
&& ( true == Ready )
|
||||
&& ( iEngineActive != 0 )
|
||||
&& ( mvControlling->MainCtrlPos > 0 ) ) {
|
||||
&& ( mvControlling->MainCtrlPowerPos() > 0 ) ) {
|
||||
// uruchomienie trąbienia przed ruszeniem
|
||||
fWarningDuration = 0.3; // czas trąbienia
|
||||
mvOccupied->WarningSignal = pVehicle->iHornWarning; // wysokość tonu (2=wysoki)
|
||||
@@ -4274,6 +4381,10 @@ TController::UpdateSituation(double dt) {
|
||||
auto const reactiontime = std::min( ReactionTime, 2.0 );
|
||||
if( LastReactionTime < reactiontime ) { return; }
|
||||
|
||||
if (AIControllFlag) {
|
||||
CheckTimeControllers();
|
||||
}
|
||||
|
||||
LastReactionTime -= reactiontime;
|
||||
// Ra: nie wiem czemu ReactionTime potrafi dostać 12 sekund, to jest przegięcie, bo przeżyna STÓJ
|
||||
// yB: otóż jest to jedna trzecia czasu napełniania na towarowym; może się przydać przy
|
||||
@@ -4393,6 +4504,13 @@ TController::UpdateSituation(double dt) {
|
||||
if( mvOccupied->SecuritySystem.is_blinking() ) {
|
||||
// jak zadziałało CA/SHP
|
||||
mvOccupied->SecuritySystemReset(); // to skasuj
|
||||
if( ( /*mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 )
|
||||
&& ( AccDesired > 0.0 )
|
||||
&& mvOccupied->SecuritySystem.is_braking() ) {
|
||||
//!!! hm, może po prostu normalnie sterować hamulcem?
|
||||
//mvOccupied->BrakeLevelSet( 0 ); GBH
|
||||
BrakeLevelSet(gbh_RP);
|
||||
}
|
||||
}
|
||||
// basic emergency stop handling, while at it
|
||||
if( ( true == mvOccupied->RadioStopFlag ) // radio-stop
|
||||
@@ -4773,7 +4891,7 @@ TController::UpdateSituation(double dt) {
|
||||
// jeśli dociskanie w celu odczepienia
|
||||
// 3. faza odczepiania.
|
||||
SetVelocity(2, 0); // jazda w ustawionym kierunku z prędkością 2
|
||||
if( ( mvControlling->MainCtrlPos > 0 )
|
||||
if( ( mvControlling->MainCtrlPowerPos() > 0 )
|
||||
|| ( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) {
|
||||
// jeśli jazda
|
||||
WriteLog(mvOccupied->Name + " odczepianie w kierunku " + std::to_string(mvOccupied->DirAbsolute));
|
||||
@@ -4792,7 +4910,8 @@ TController::UpdateSituation(double dt) {
|
||||
// (ustalić po czym poznać taki tor)
|
||||
++n; // to liczymy człony jako jeden
|
||||
p->MoverParameters->BrakeReleaser(1); // wyluzuj pojazd, aby dało się dopychać
|
||||
p->MoverParameters->BrakeLevelSet(0); // hamulec na zero, aby nie hamował
|
||||
// GBH p->MoverParameters->BrakeLevelSet(0); // hamulec na zero, aby nie hamował
|
||||
BrakeLevelSet(gbh_RP);
|
||||
if (n)
|
||||
{ // jeśli jeszcze nie koniec
|
||||
p = p->Prev(); // kolejny w stronę czoła składu (licząc od tyłu), bo dociskamy
|
||||
@@ -4826,10 +4945,12 @@ TController::UpdateSituation(double dt) {
|
||||
// za radą yB ustawiamy pozycję 3 kranu (ruszanie kranem w innych miejscach
|
||||
// powino zostać wyłączone)
|
||||
// WriteLog("Zahamowanie składu");
|
||||
mvOccupied->BrakeLevelSet(
|
||||
mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ?
|
||||
1 :
|
||||
3 );
|
||||
if( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) {
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_EPB ) );
|
||||
}
|
||||
else {
|
||||
BrakeCtrlPosition = 3;
|
||||
}
|
||||
double p = mvOccupied->BrakePressureActual.PipePressureVal;
|
||||
if( p < 3.9 ) {
|
||||
// tu może być 0 albo -1 nawet
|
||||
@@ -4864,16 +4985,16 @@ TController::UpdateSituation(double dt) {
|
||||
if (iDrivigFlags & movePress)
|
||||
{ // 4. faza odczepiania: zwolnij i zmień kierunek
|
||||
SetVelocity(0, 0, stopJoin); // wyłączyć przyspieszanie
|
||||
if (!DecSpeed()) // jeśli już bardziej wyłączyć się nie da
|
||||
{ // ponowna zmiana kierunku
|
||||
WriteLog( mvOccupied->Name + " ponowna zmiana kierunku" );
|
||||
DirectionForward(mvOccupied->ActiveDir < 0); // zmiana kierunku jazdy na właściwy
|
||||
iDrivigFlags &= ~movePress; // koniec dociskania
|
||||
JumpToNextOrder(); // zmieni światła
|
||||
TableClear(); // skanowanie od nowa
|
||||
iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem
|
||||
SetVelocity(fShuntVelocity, fShuntVelocity); // ustawienie prędkości jazdy
|
||||
}
|
||||
ZeroSpeed();
|
||||
// ponowna zmiana kierunku
|
||||
WriteLog( mvOccupied->Name + " ponowna zmiana kierunku" );
|
||||
DirectionForward(mvOccupied->ActiveDir < 0); // zmiana kierunku jazdy na właściwy
|
||||
iDrivigFlags &= ~movePress; // koniec dociskania
|
||||
JumpToNextOrder(); // zmieni światła
|
||||
TableClear(); // skanowanie od nowa
|
||||
iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem
|
||||
SetVelocity(fShuntVelocity, fShuntVelocity); // ustawienie prędkości jazdy
|
||||
mvOccupied->BrakeReleaser(0); // wyłączyć luzowanie
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5419,7 +5540,7 @@ TController::UpdateSituation(double dt) {
|
||||
// część wykonawcza tylko dla AI, dla człowieka jedynie napisy
|
||||
|
||||
// zapobieganie poslizgowi u nas
|
||||
if (mvControlling->SlippingWheels) {
|
||||
if (mvControlling->SlippingWheels && mvControlling->EngineType != TEngineType::ElectricInductionMotor) {
|
||||
|
||||
if( false == mvControlling->DecScndCtrl( 2 ) ) {
|
||||
// bocznik na zero
|
||||
@@ -5439,7 +5560,7 @@ TController::UpdateSituation(double dt) {
|
||||
if( ( true == mvOccupied->RadioStopFlag ) // radio-stop
|
||||
&& ( mvOccupied->Vel > 0.0 ) ) { // and still moving
|
||||
// if the radio-stop was issued don't waste effort trying to fight it
|
||||
while( true == DecSpeed() ) { ; } // just throttle down...
|
||||
ZeroSpeed(); // just throttle down...
|
||||
return; // ...and don't touch any other controls
|
||||
}
|
||||
|
||||
@@ -5485,17 +5606,18 @@ TController::UpdateSituation(double dt) {
|
||||
}
|
||||
}
|
||||
if (mvOccupied->BrakeSystem == TBrakeSystem::Pneumatic) // napełnianie uderzeniowe
|
||||
if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a)
|
||||
if (mvOccupied->BrakeHandle == TBrakeHandle::FV4a || mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P
|
||||
|| mvOccupied->BrakeHandle == TBrakeHandle::M394)
|
||||
{
|
||||
if( mvOccupied->BrakeCtrlPos == -2 ) {
|
||||
mvOccupied->BrakeLevelSet( 0 );
|
||||
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) {
|
||||
/*mvOccupied->*/BrakeLevelSet( gbh_RP );
|
||||
}
|
||||
if( ( mvOccupied->PipePress < 3.0 )
|
||||
&& ( AccDesired > -0.03 ) ) {
|
||||
mvOccupied->BrakeReleaser( 1 );
|
||||
}
|
||||
|
||||
if( ( mvOccupied->BrakeCtrlPos == 0 )
|
||||
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 )
|
||||
&& ( AbsAccS < 0.03 )
|
||||
&& ( AccDesired > -0.03 )
|
||||
&& ( VelDesired - mvOccupied->Vel > 2.0 ) ) {
|
||||
@@ -5507,7 +5629,8 @@ TController::UpdateSituation(double dt) {
|
||||
if( ( iDrivigFlags & moveOerlikons )
|
||||
|| ( true == IsCargoTrain ) ) {
|
||||
// napełnianie w Oerlikonie
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_FS ) );
|
||||
/* mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_FS ) ); GBH */
|
||||
BrakeLevelSet(gbh_FS);
|
||||
// don't charge the brakes too often, or we risk overcharging
|
||||
BrakeChargingCooldown = -120.0;
|
||||
}
|
||||
@@ -5518,9 +5641,10 @@ TController::UpdateSituation(double dt) {
|
||||
}
|
||||
}
|
||||
|
||||
if( ( mvOccupied->BrakeCtrlPos < 0 )
|
||||
if( ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition < 0 )
|
||||
&& ( mvOccupied->EqvtPipePress > ( fReady < 0.25 ? 5.1 : 5.2 ) ) ) {
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) );
|
||||
/* GBH mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); */
|
||||
BrakeLevelSet(gbh_RP);
|
||||
}
|
||||
}
|
||||
#if LOGVELOCITY
|
||||
@@ -5603,13 +5727,14 @@ TController::UpdateSituation(double dt) {
|
||||
if( false == TestFlag( iDrivigFlags, movePress ) ) {
|
||||
// jeśli nie dociskanie
|
||||
if( AccDesired < -0.05 ) {
|
||||
while( true == DecSpeed() ) { ; } // jeśli hamujemy, to nie przyspieszamy
|
||||
ZeroSpeed();
|
||||
}
|
||||
else if( ( vel > VelDesired )
|
||||
|| ( fAccGravity < -0.01 ?
|
||||
AccDesired < 0.0 :
|
||||
AbsAccS > AccDesired ) ) {
|
||||
(AbsAccS > AccDesired && AccDesired < 0.75) ) ) {
|
||||
// jak za bardzo przyspiesza albo prędkość przekroczona
|
||||
// dodany wyjatek na "pelna w przod"
|
||||
DecSpeed(); // pojedyncze cofnięcie pozycji, bo na zero to przesada
|
||||
}
|
||||
}
|
||||
@@ -5623,7 +5748,7 @@ TController::UpdateSituation(double dt) {
|
||||
std::max( -0.2, fAccThreshold ) ) };
|
||||
if( ( AccDesired <= accthreshold ) // jeśli hamować - u góry ustawia się hamowanie na fAccThreshold
|
||||
&& ( ( AbsAccS > AccDesired )
|
||||
|| ( mvOccupied->BrakeCtrlPos < 0 ) ) ) {
|
||||
|| ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition < 0 ) ) ) {
|
||||
// hamować bardziej, gdy aktualne opóźnienie hamowania mniejsze niż (AccDesired)
|
||||
IncBrake();
|
||||
}
|
||||
@@ -5631,7 +5756,7 @@ TController::UpdateSituation(double dt) {
|
||||
// przy odłączaniu nie zwalniamy tu hamulca
|
||||
if( AbsAccS < AccDesired - 0.05 ) {
|
||||
// jeśli opóźnienie większe od wymaganego (z histerezą) luzowanie, gdy za dużo
|
||||
if( mvOccupied->BrakeCtrlPos >= 0 ) {
|
||||
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition >= 0 ) {
|
||||
DecBrake(); // tutaj zmniejszało o 1 przy odczepianiu
|
||||
}
|
||||
}
|
||||
@@ -5654,7 +5779,7 @@ TController::UpdateSituation(double dt) {
|
||||
// u góry ustawia się hamowanie na fAccThreshold
|
||||
if( ( fBrakeTime < 0.0 )
|
||||
|| ( AccDesired < fAccGravity - 0.5 )
|
||||
|| ( mvOccupied->BrakeCtrlPos <= 0 ) ) {
|
||||
|| ( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition <= 0 ) ) {
|
||||
// jeśli upłynął czas reakcji hamulca, chyba że nagłe albo luzował
|
||||
if( true == IncBrake() ) {
|
||||
fBrakeTime =
|
||||
@@ -5727,13 +5852,15 @@ TController::UpdateSituation(double dt) {
|
||||
mvOccupied->IncLocalBrakeLevel( 1 );
|
||||
}
|
||||
else {
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) );
|
||||
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) ); //GBH
|
||||
BrakeLevelSet(gbh_RP);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break; // rzeczy robione przy jezdzie
|
||||
} // switch (OrderList[OrderPos])
|
||||
if (AIControllFlag) SetTimeControllers();
|
||||
}
|
||||
|
||||
// configures vehicle heating given current situation; returns: true if vehicle can be operated normally, false otherwise
|
||||
@@ -6392,21 +6519,35 @@ void TController::TakeControl(bool yes)
|
||||
|
||||
void TController::DirectionForward(bool forward)
|
||||
{ // ustawienie jazdy do przodu dla true i do tyłu dla false (zależy od kabiny)
|
||||
while (mvControlling->MainCtrlPos) // samo zapętlenie DecSpeed() nie wystarcza
|
||||
DecSpeed(true); // wymuszenie zerowania nastawnika jazdy, inaczej się może zawiesić
|
||||
if (forward)
|
||||
while (mvOccupied->ActiveDir <= 0)
|
||||
mvOccupied->DirectionForward(); // do przodu w obecnej kabinie
|
||||
else
|
||||
while (mvOccupied->ActiveDir >= 0)
|
||||
mvOccupied->DirectionBackward(); // do tyłu w obecnej kabinie
|
||||
if( mvOccupied->TrainType == dt_SN61 ) {
|
||||
// specjalnie dla SN61 żeby nie zgasł
|
||||
if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) {
|
||||
mvControlling->IncMainCtrl( 1 );
|
||||
ZeroSpeed( true ); // TODO: check if force switch is needed anymore here
|
||||
if( forward ) {
|
||||
// do przodu w obecnej kabinie
|
||||
while( ( mvOccupied->ActiveDir <= 0 )
|
||||
&& ( mvOccupied->DirectionForward() ) ) {
|
||||
; // all work is done in the header
|
||||
}
|
||||
}
|
||||
};
|
||||
else {
|
||||
// do tyłu w obecnej kabinie
|
||||
while( ( mvOccupied->ActiveDir >= 0 )
|
||||
&& ( mvOccupied->DirectionBackward() ) ) {
|
||||
; // all work is done in the header
|
||||
}
|
||||
}
|
||||
if( mvOccupied->TrainType == dt_SN61 ) {
|
||||
// specjalnie dla SN61 żeby nie zgasł
|
||||
while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 )
|
||||
&& ( mvControlling->IncMainCtrl( 1 ) ) ) {
|
||||
; // all work is done in the header
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TController::ZeroDirection() {
|
||||
|
||||
while( ( mvOccupied->ActiveDir > 0 ) && ( mvOccupied->DirectionBackward() ) ) { ; }
|
||||
while( ( mvOccupied->ActiveDir < 0 ) && ( mvOccupied->DirectionForward() ) ) { ; }
|
||||
}
|
||||
|
||||
Mtable::TTrainParameters const *
|
||||
TController::TrainTimetable() const {
|
||||
|
||||
13
Driver.h
13
Driver.h
@@ -169,6 +169,12 @@ static const int maxorders = 64; // ilość rozkazów w tabelce
|
||||
static const int maxdriverfails = 4; // ile błędów może zrobić AI zanim zmieni nastawienie
|
||||
extern bool WriteLogFlag; // logowanie parametrów fizycznych
|
||||
static const int BrakeAccTableSize = 20;
|
||||
|
||||
static const int gbh_NP = -2; //odciecie w hamulcu ogolnym
|
||||
static const int gbh_RP = 0; //jazda w hamulcu ogolnym
|
||||
static const int gbh_FS = -1; //napelnianie uderzeniowe w hamulcu ogolnym
|
||||
static const int gbh_MIN = -2; //minimalna pozycja w hamulcu ogolnym
|
||||
static const int gbh_MAX = 6; //maksymalna pozycja w hamulcu ogolnym
|
||||
//----------------------------------------------------------------------------
|
||||
|
||||
class TController {
|
||||
@@ -211,12 +217,17 @@ private:
|
||||
bool DecBrake();
|
||||
bool IncSpeed();
|
||||
bool DecSpeed(bool force = false);
|
||||
void ZeroSpeed( bool const Enforce = false );
|
||||
bool IncBrakeEIM();
|
||||
bool DecBrakeEIM();
|
||||
bool IncSpeedEIM();
|
||||
bool DecSpeedEIM();
|
||||
void BrakeLevelSet(double b);
|
||||
bool BrakeLevelAdd(double b);
|
||||
void SpeedSet();
|
||||
void SpeedCntrl(double DesiredSpeed);
|
||||
void SetTimeControllers(); /*setting state of time controllers depending of desired action*/
|
||||
void CheckTimeControllers(); /*checking state of time controllers to reset them to stable position*/
|
||||
double ESMVelocity(bool Main);
|
||||
bool UpdateHeating();
|
||||
// uaktualnia informacje o prędkości
|
||||
@@ -224,6 +235,7 @@ private:
|
||||
int CheckDirection();
|
||||
void WaitingSet(double Seconds);
|
||||
void DirectionForward(bool forward);
|
||||
void ZeroDirection();
|
||||
int OrderDirectionChange(int newdir, TMoverParameters *Vehicle);
|
||||
void Lights(int head, int rear);
|
||||
std::string StopReasonText() const;
|
||||
@@ -306,6 +318,7 @@ private:
|
||||
double ReactionTime = 0.0; // czas reakcji Ra: czego i na co? świadomości AI
|
||||
double fBrakeTime = 0.0; // wpisana wartość jest zmniejszana do 0, gdy ujemna należy zmienić nastawę hamulca
|
||||
double BrakeChargingCooldown {}; // prevents the ai from trying to charge the train brake too frequently
|
||||
double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller
|
||||
double LastReactionTime = 0.0;
|
||||
double fActionTime = 0.0; // czas używany przy regulacji prędkości i zamykaniu drzwi
|
||||
double m_radiocontroltime{ 0.0 }; // timer used to control speed of radio operations
|
||||
|
||||
33
DynObj.cpp
33
DynObj.cpp
@@ -1589,6 +1589,8 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
|
||||
Error("Parameters mismatch: dynamic object " + asName + " from \"" + BaseDir + "/" + Type_Name + "\"" );
|
||||
return 0.0; // zerowa długość to brak pojazdu
|
||||
}
|
||||
// controller position
|
||||
MoverParameters->MainCtrlPos = MoverParameters->MainCtrlNoPowerPos();
|
||||
// ustawienie pozycji hamulca
|
||||
MoverParameters->LocalBrakePosA = 0.0;
|
||||
if (driveractive)
|
||||
@@ -2956,7 +2958,7 @@ bool TDynamicObject::Update(double dt, double dt1)
|
||||
}
|
||||
MEDLogTime += dt1;
|
||||
|
||||
if ((MoverParameters->Vel < 0.1) || (MoverParameters->MainCtrlPos > 0))
|
||||
if ((MoverParameters->Vel < 0.1) || (MoverParameters->MainCtrlPowerPos() > 0))
|
||||
{
|
||||
MEDLogInactiveTime += dt1;
|
||||
}
|
||||
@@ -4086,7 +4088,7 @@ void TDynamicObject::RenderSounds() {
|
||||
else {
|
||||
// basic clash
|
||||
couplersounds.dsbBufferClamp
|
||||
.gain( 0.65f )
|
||||
.gain( 1.f )
|
||||
.play( sound_flags::exclusive );
|
||||
}
|
||||
}
|
||||
@@ -4111,7 +4113,7 @@ void TDynamicObject::RenderSounds() {
|
||||
else {
|
||||
// basic clash
|
||||
couplersounds.dsbCouplerStretch
|
||||
.gain( 0.65f )
|
||||
.gain( 1.f )
|
||||
.play( sound_flags::exclusive );
|
||||
}
|
||||
}
|
||||
@@ -4349,6 +4351,20 @@ void TDynamicObject::LoadMMediaFile( std::string const &TypeName, std::string co
|
||||
mdLowPolyInt = TModelsManager::GetModel(asModel, true);
|
||||
}
|
||||
|
||||
else if(token == "loads:") {
|
||||
// default load visualization models overrides
|
||||
// content provided as "key: value" pairs together enclosed in "{}"
|
||||
// value can be optionally set of values enclosed in "[]" in which case one value will be picked randomly
|
||||
while( ( ( token = parser.getToken<std::string>() ) != "" )
|
||||
&& ( token != "}" ) ) {
|
||||
if( token[ token.size() - 1 ] == ':' ) {
|
||||
auto loadmodel { deserialize_random_set( parser ) };
|
||||
replace_slashes( loadmodel );
|
||||
LoadModelOverrides.emplace( token.erase( token.size() - 1 ), loadmodel );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
else if( token == "brakemode:" ) {
|
||||
// Ra 15-01: gałka nastawy hamulca
|
||||
parser.getTokens();
|
||||
@@ -5661,8 +5677,17 @@ TDynamicObject::LoadMMediaFile_mdload( std::string const &Name ) const {
|
||||
|
||||
if( Name.empty() ) { return nullptr; }
|
||||
|
||||
// try first specialized version of the load model, vehiclename_loadname
|
||||
TModel3d *loadmodel { nullptr };
|
||||
|
||||
// check if we don't have model override for this load type
|
||||
auto const lookup { LoadModelOverrides.find( Name ) };
|
||||
if( lookup != LoadModelOverrides.end() ) {
|
||||
loadmodel = TModelsManager::GetModel( asBaseDir + lookup->second, true );
|
||||
// if the override was succesfully loaded call it a day
|
||||
if( loadmodel != nullptr ) { return loadmodel; }
|
||||
}
|
||||
// regular routine if there's no override or it couldn't be loaded
|
||||
// try first specialized version of the load model, vehiclename_loadname
|
||||
auto const specializedloadfilename { asBaseDir + MoverParameters->TypeName + "_" + Name };
|
||||
if( ( true == FileExists( specializedloadfilename + ".e3d" ) )
|
||||
|| ( true == FileExists( specializedloadfilename + ".t3d" ) ) ) {
|
||||
|
||||
1
DynObj.h
1
DynObj.h
@@ -206,6 +206,7 @@ public:
|
||||
bool JointCabs{ false }; // flag for vehicles with multiple virtual 'cabs' sharing location and 3d model(s)
|
||||
float fShade; // zacienienie: 0:normalnie, -1:w ciemności, +1:dodatkowe światło (brak koloru?)
|
||||
float LoadOffset { 0.f };
|
||||
std::unordered_map<std::string, std::string> LoadModelOverrides; // potential overrides of default load visualization models
|
||||
glm::vec3 InteriorLight { 0.9f * 255.f / 255.f, 0.9f * 216.f / 255.f, 0.9f * 176.f / 255.f }; // tungsten light. TODO: allow definition of light type?
|
||||
float InteriorLightLevel { 0.0f }; // current level of interior lighting
|
||||
struct vehicle_section {
|
||||
|
||||
@@ -97,6 +97,7 @@ static int const maxcc = 4; /*max. ilosc odbierakow pradu*/
|
||||
//static int const MainBrakeMaxPos = 10; /*max. ilosc nastaw hamulca zasadniczego*/
|
||||
static int const ManualBrakePosNo = 20; /*ilosc nastaw hamulca recznego*/
|
||||
static int const LightsSwitchPosNo = 16;
|
||||
static int const UniversalCtrlArraySize = 32; /*max liczba pozycji uniwersalnego nastawnika*/
|
||||
|
||||
/*uszkodzenia toru*/
|
||||
static int const dtrack_railwear = 2;
|
||||
@@ -562,6 +563,20 @@ struct TMotorParameters
|
||||
}
|
||||
};
|
||||
|
||||
struct TUniversalCtrl
|
||||
{
|
||||
int mode = 0; /*tryb pracy zadajnika - pomocnicze*/
|
||||
double MinCtrlVal = 0.0; /*minimalna wartosc nastawy*/
|
||||
double MaxCtrlVal = 0.0; /*maksymalna wartosc nastawy*/
|
||||
double SetCtrlVal = 0.0; /*docelowa wartosc nastawy*/
|
||||
double SpeedUp = 0.0; /*szybkosc zwiekszania nastawy*/
|
||||
double SpeedDown = 0.0; /*szybkosc zmniejszania nastawy*/
|
||||
int ReturnPosition = 0; /*pozycja na ktora odskakuje zadajnik*/
|
||||
int NextPosFastInc = 0; /*nastepna duza pozycja przy przechodzeniu szybkim*/
|
||||
int PrevPosFastDec = 0; /*poprzednia duza pozycja przy przechodzeniu szybkim*/
|
||||
};
|
||||
typedef TUniversalCtrl TUniversalCtrlTable[UniversalCtrlArraySize + 1]; /*tablica sterowania uniwersalnego nastawnika*/
|
||||
|
||||
class TSecuritySystem
|
||||
{
|
||||
bool vigilance_enabled = false;
|
||||
@@ -954,6 +969,8 @@ public:
|
||||
bool MBrake = false; /*Czy jest hamulec reczny*/
|
||||
double StopBrakeDecc = 0.0;
|
||||
TSecuritySystem SecuritySystem;
|
||||
TUniversalCtrlTable UniCtrlList; /*lista pozycji uniwersalnego nastawnika*/
|
||||
int UniCtrlListSize = 0; /*wielkosc listy pozycji uniwersalnego nastawnika*/
|
||||
|
||||
/*-sekcja parametrow dla lokomotywy elektrycznej*/
|
||||
TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/
|
||||
@@ -1222,6 +1239,7 @@ public:
|
||||
int LightsPos = 0;
|
||||
int ActiveDir = 0; //czy lok. jest wlaczona i w ktorym kierunku:
|
||||
//względem wybranej kabiny: -1 - do tylu, +1 - do przodu, 0 - wylaczona
|
||||
int MaxMainCtrlPosNoDirChange { 0 }; // can't change reverser state with master controller set above this position
|
||||
int CabNo = 0; //numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad
|
||||
int DirAbsolute = 0; //zadany kierunek jazdy względem sprzęgów (1=w strone 0,-1=w stronę 1)
|
||||
int ActiveCab = 0; //numer kabiny, w ktorej jest obsada (zwykle jedna na skład)
|
||||
@@ -1302,6 +1320,7 @@ public:
|
||||
double eimic = 0; /*aktualna pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
||||
double eimic_real = 0; /*faktycznie uzywana pozycja zintegrowanego sterowania jazda i hamowaniem*/
|
||||
int EIMCtrlType = 0; /*rodzaj wariantu zadajnika jazdy*/
|
||||
bool SpeedCtrlTypeTime = false; /*czy tempomat sterowany czasowo*/
|
||||
double eimv_pr = 0; /*realizowany procent dostepnej sily rozruchu/hamowania*/
|
||||
double eimv[21];
|
||||
static std::vector<std::string> const eimv_labels;
|
||||
@@ -1370,6 +1389,7 @@ public:
|
||||
int DettachStatus(int ConnectNo);
|
||||
bool Dettach(int ConnectNo);
|
||||
bool DirectionForward();
|
||||
bool DirectionBackward( void );/*! kierunek ruchu*/
|
||||
void BrakeLevelSet(double b);
|
||||
bool BrakeLevelAdd(double b);
|
||||
bool IncBrakeLevel(); // wersja na użytek AI
|
||||
@@ -1406,6 +1426,9 @@ public:
|
||||
/*! glowny nastawnik:*/
|
||||
bool IncMainCtrl(int CtrlSpeed);
|
||||
bool DecMainCtrl(int CtrlSpeed);
|
||||
bool IsMainCtrlNoPowerPos() const; // whether the master controller is set to position which won't generate any extra power
|
||||
int MainCtrlNoPowerPos() const; // highest setting of master controller which won't cause engine to generate extra power
|
||||
int MainCtrlPowerPos() const; // current setting of master controller, relative to the highest setting not generating extra power
|
||||
/*! pomocniczy nastawnik:*/
|
||||
bool IncScndCtrl(int CtrlSpeed);
|
||||
bool DecScndCtrl(int CtrlSpeed);
|
||||
@@ -1468,7 +1491,6 @@ public:
|
||||
double ComputeRotatingWheel(double WForce, double dt, double n) const;
|
||||
|
||||
/*--funkcje dla lokomotyw*/
|
||||
bool DirectionBackward(void);/*! kierunek ruchu*/
|
||||
bool WaterPumpBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water pump breaker state toggle
|
||||
bool WaterPumpSwitch( bool State, range_t const Notify = range_t::consist ); // water pump state toggle
|
||||
bool WaterPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // water pump state toggle
|
||||
@@ -1571,6 +1593,7 @@ private:
|
||||
void LoadFIZ_MotorParamTable( std::string const &Input );
|
||||
void LoadFIZ_Circuit( std::string const &Input );
|
||||
void LoadFIZ_RList( std::string const &Input );
|
||||
void LoadFIZ_UCList(std::string const &Input);
|
||||
void LoadFIZ_DList( std::string const &Input );
|
||||
void LoadFIZ_FFList( std::string const &Input );
|
||||
void LoadFIZ_LightsList( std::string const &Input );
|
||||
@@ -1585,12 +1608,14 @@ private:
|
||||
bool readMPTDieselEngine( std::string const &line );
|
||||
bool readBPT(/*int const ln,*/ std::string const &line); //Q 20160721
|
||||
bool readRList( std::string const &Input );
|
||||
bool readUCList(std::string const &Input);
|
||||
bool readDList( std::string const &line );
|
||||
bool readFFList( std::string const &line );
|
||||
bool readWWList( std::string const &line );
|
||||
bool readLightsList( std::string const &Input );
|
||||
void BrakeValveDecode( std::string const &s ); //Q 20160719
|
||||
void BrakeSubsystemDecode(); //Q 20160719
|
||||
bool EIMDirectionChangeAllow( void );
|
||||
};
|
||||
|
||||
//double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);
|
||||
|
||||
@@ -609,14 +609,14 @@ bool TMoverParameters::Dettach(int ConnectNo)
|
||||
|
||||
bool TMoverParameters::DirectionForward()
|
||||
{
|
||||
if ((MainCtrlPosNo > 0) && (ActiveDir < 1) && (MainCtrlPos == 0))
|
||||
if ((MainCtrlPosNo > 0) && (ActiveDir < 1) && (MainCtrlPos <= MaxMainCtrlPosNoDirChange) && (EIMDirectionChangeAllow()))
|
||||
{
|
||||
++ActiveDir;
|
||||
DirAbsolute = ActiveDir * CabNo;
|
||||
SendCtrlToNext("Direction", ActiveDir, CabNo);
|
||||
return true;
|
||||
}
|
||||
else if ((ActiveDir == 1) && (MainCtrlPos == 0) && (TrainType == dt_EZT) && (EngineType != TEngineType::ElectricInductionMotor))
|
||||
else if ((ActiveDir == 1) && (IsMainCtrlNoPowerPos()) && (TrainType == dt_EZT) && (EngineType != TEngineType::ElectricInductionMotor))
|
||||
return MinCurrentSwitch(true); //"wysoki rozruch" EN57
|
||||
return false;
|
||||
};
|
||||
@@ -745,7 +745,7 @@ TMoverParameters::CurrentSwitch(bool const State) {
|
||||
// for SM42/SP42
|
||||
if( ( EngineType == TEngineType::DieselElectric )
|
||||
&& ( true == ShuntModeAllow )
|
||||
&& ( MainCtrlPos == 0 ) ) {
|
||||
&& ( IsMainCtrlNoPowerPos() ) ) {
|
||||
ShuntMode = State;
|
||||
return true;
|
||||
}
|
||||
@@ -1836,17 +1836,17 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
|
||||
|
||||
case TEngineType::DieselEngine:
|
||||
{
|
||||
if( CtrlSpeed > 1 ) {
|
||||
while( MainCtrlPos < MainCtrlPosNo ) {
|
||||
IncMainCtrl( 1 );
|
||||
if( CtrlSpeed > 1 ) {
|
||||
while( ( MainCtrlPos < MainCtrlPosNo )
|
||||
&& ( IncMainCtrl( 1 ) ) ) {
|
||||
;
|
||||
}
|
||||
}
|
||||
else {
|
||||
++MainCtrlPos;
|
||||
}
|
||||
else {
|
||||
++MainCtrlPos;
|
||||
if( MainCtrlPos > 0 ) { CompressorAllow = true; }
|
||||
else { CompressorAllow = false; }
|
||||
}
|
||||
OK = true;
|
||||
CompressorAllow = ( MainCtrlPowerPos() > 0 );
|
||||
OK = true;
|
||||
break;
|
||||
}
|
||||
|
||||
@@ -1909,6 +1909,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
|
||||
}
|
||||
else
|
||||
{
|
||||
// TBD, TODO: replace with mainctrlpowerpos() check?
|
||||
if (MainCtrlPos > 0)
|
||||
{
|
||||
if ((TrainType != dt_ET22) ||
|
||||
@@ -2007,6 +2008,25 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
|
||||
return OK;
|
||||
}
|
||||
|
||||
bool TMoverParameters::IsMainCtrlNoPowerPos() const {
|
||||
// TODO: wrap controller pieces into a class for potential specializations, similar to brake subsystems
|
||||
return MainCtrlPos <= MainCtrlNoPowerPos();
|
||||
}
|
||||
|
||||
int TMoverParameters::MainCtrlNoPowerPos() const {
|
||||
|
||||
switch( EIMCtrlType ) {
|
||||
case 1: { return 3; }
|
||||
case 2: { return 3; }
|
||||
default: { return 0; }
|
||||
}
|
||||
}
|
||||
|
||||
int TMoverParameters::MainCtrlPowerPos() const {
|
||||
|
||||
return MainCtrlPos - MainCtrlNoPowerPos();
|
||||
}
|
||||
|
||||
// *************************************************************************************************
|
||||
// Q: 20160710
|
||||
// zwiększenie bocznika
|
||||
@@ -2015,14 +2035,13 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
|
||||
{
|
||||
bool OK = false;
|
||||
|
||||
if ((MainCtrlPos == 0) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) &&
|
||||
(DynamicBrakeFlag))
|
||||
if ((IsMainCtrlNoPowerPos()) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) && (DynamicBrakeFlag))
|
||||
{
|
||||
OK = DynamicBrakeSwitch(false);
|
||||
}
|
||||
else if ((ScndCtrlPosNo > 0) && (CabNo != 0) &&
|
||||
!((TrainType == dt_ET42) &&
|
||||
((Imax == ImaxHi) || ((DynamicBrakeFlag) && (MainCtrlPos > 0)))))
|
||||
((Imax == ImaxHi) || ((DynamicBrakeFlag) && (MainCtrlPowerPos() > 0)))))
|
||||
{
|
||||
// if (RList[MainCtrlPos].R=0) and (MainCtrlPos>0) and (ScndCtrlPos<ScndCtrlPosNo) and
|
||||
// (not CoupledCtrl) then
|
||||
@@ -2077,7 +2096,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
|
||||
{
|
||||
bool OK = false;
|
||||
|
||||
if ((MainCtrlPos == 0) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) &&
|
||||
if ((IsMainCtrlNoPowerPos()) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) &&
|
||||
!(DynamicBrakeFlag) && (CtrlSpeed == 1))
|
||||
{
|
||||
// Ra: AI wywołuje z CtrlSpeed=2 albo gdy ScndCtrlPos>0
|
||||
@@ -2323,7 +2342,7 @@ bool TMoverParameters::DirectionBackward(void)
|
||||
DB = true; //
|
||||
return DB; // exit; TODO: czy dobrze przetlumaczone?
|
||||
}
|
||||
if ((MainCtrlPosNo > 0) && (ActiveDir > -1) && (MainCtrlPos == 0))
|
||||
if ((MainCtrlPosNo > 0) && (ActiveDir > -1) && (MainCtrlPos <= MaxMainCtrlPosNoDirChange) && (EIMDirectionChangeAllow()))
|
||||
{
|
||||
if (EngineType == TEngineType::WheelsDriven)
|
||||
CabNo--;
|
||||
@@ -2338,6 +2357,13 @@ bool TMoverParameters::DirectionBackward(void)
|
||||
return DB;
|
||||
}
|
||||
|
||||
bool TMoverParameters::EIMDirectionChangeAllow(void)
|
||||
{
|
||||
bool OK = false;
|
||||
OK = (EngineType != TEngineType::ElectricInductionMotor || ((eimic <= 0) && (eimic_real <= 0) && (Vel < 0.1)));
|
||||
return OK;
|
||||
}
|
||||
|
||||
// *************************************************************************************************
|
||||
// Q: 20160710
|
||||
// załączenie przycisku przeciwpoślizgowego
|
||||
@@ -2940,7 +2966,7 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch)
|
||||
{
|
||||
bool DBS;
|
||||
|
||||
if ((DynamicBrakeType == dbrake_switch) && (MainCtrlPos == 0))
|
||||
if ((DynamicBrakeType == dbrake_switch) && (IsMainCtrlNoPowerPos()))
|
||||
{
|
||||
DynamicBrakeFlag = Switch;
|
||||
DBS = true;
|
||||
@@ -3234,7 +3260,7 @@ void TMoverParameters::CompressorCheck(double dt)
|
||||
if( ( true == CompressorAllow )
|
||||
&& ( true == CompressorAllowLocal )
|
||||
&& ( true == Mains )
|
||||
&& ( MainCtrlPos > 0 ) ) {
|
||||
&& ( MainCtrlPowerPos() > 0 ) ) {
|
||||
if( Compressor < MaxCompressor ) {
|
||||
if( ( EngineType == TEngineType::DieselElectric )
|
||||
&& ( CompressorPower > 0 ) ) {
|
||||
@@ -3962,12 +3988,18 @@ void TMoverParameters::ComputeTotalForce(double dt) {
|
||||
&& ( std::abs(Fwheels) > TotalMassxg * Adhesive( RunningTrack.friction ) ) ) {
|
||||
SlippingWheels = true;
|
||||
}
|
||||
if( true == SlippingWheels ) {
|
||||
double temp_nrot = nrot;
|
||||
if (true == SlippingWheels) {
|
||||
|
||||
double temp_nrot = ComputeRotatingWheel(Fwheels -
|
||||
Sign(nrot * M_PI * WheelDiameter - V) *
|
||||
Adhesive(RunningTrack.friction) * TotalMassxg,
|
||||
dt, nrot);
|
||||
temp_nrot = ComputeRotatingWheel(Fwheels - Sign(nrot * M_PI * WheelDiameter - V) *
|
||||
Adhesive(RunningTrack.friction) * TotalMassxg, dt, nrot);
|
||||
if (Sign(nrot * M_PI * WheelDiameter - V)*Sign(temp_nrot * M_PI * WheelDiameter - V) < 0)
|
||||
{
|
||||
SlippingWheels = false;
|
||||
temp_nrot = V / M_PI / WheelDiameter;
|
||||
}
|
||||
}
|
||||
if (true == SlippingWheels) {
|
||||
Fwheels = Sign(temp_nrot * M_PI * WheelDiameter - V) * TotalMassxg * Adhesive(RunningTrack.friction);
|
||||
if (Fwheels*Sign(V)>0)
|
||||
{
|
||||
@@ -3986,12 +4018,6 @@ void TMoverParameters::ComputeTotalForce(double dt) {
|
||||
{
|
||||
WheelFlat = sqrt(square(WheelFlat) + abs(Fwheels) / NAxles*Vel*0.000002);
|
||||
}
|
||||
if (Sign(nrot * M_PI * WheelDiameter - V)*Sign(temp_nrot * M_PI * WheelDiameter - V) < 0)
|
||||
{
|
||||
SlippingWheels = false;
|
||||
temp_nrot = V / M_PI / WheelDiameter;
|
||||
}
|
||||
|
||||
|
||||
nrot = temp_nrot;
|
||||
}
|
||||
@@ -4476,7 +4502,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
}
|
||||
case TEngineType::DieselEngine: {
|
||||
EnginePower = ( 2 * dizel_Mstand + dmoment ) * enrot * ( 2.0 * M_PI / 1000.0 );
|
||||
if( MainCtrlPos > 1 ) {
|
||||
if( MainCtrlPowerPos() > 1 ) {
|
||||
// dodatkowe opory z powodu sprezarki}
|
||||
dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax );
|
||||
}
|
||||
@@ -4673,7 +4699,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
auto const tmpV { nrot * Pirazy2 * 0.5 * WheelDiameter * DirAbsolute }; //*CabNo*ActiveDir;
|
||||
// jazda manewrowa
|
||||
if( true == ShuntMode ) {
|
||||
if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) {
|
||||
if( ( true == Mains ) && ( MainCtrlPowerPos() > 0 ) ) {
|
||||
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, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
|
||||
@@ -4704,7 +4730,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
PosRatio = currentgenpower / DElist[MainCtrlPosNo].GenPower;
|
||||
// stosunek mocy teraz do mocy max
|
||||
// NOTE: Mains in this context is working diesel engine
|
||||
if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) {
|
||||
if( ( true == Mains ) && ( MainCtrlPowerPos() > 0 ) ) {
|
||||
|
||||
if( tmpV < ( Vhyp * power / DElist[ MainCtrlPosNo ].GenPower ) ) {
|
||||
// czy na czesci prostej, czy na hiperboli
|
||||
@@ -4806,7 +4832,7 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
Voltage = 0;
|
||||
|
||||
// przekazniki bocznikowania, kazdy inny dla kazdej pozycji
|
||||
if ((MainCtrlPos == 0) || (ShuntMode) || (false==Mains))
|
||||
if ((IsMainCtrlNoPowerPos()) || (ShuntMode) || (false==Mains))
|
||||
ScndCtrlPos = 0;
|
||||
|
||||
else {
|
||||
@@ -4972,7 +4998,44 @@ double TMoverParameters::TractionForce( double dt ) {
|
||||
{
|
||||
if( true == Mains && !SecuritySystem.is_engine_blocked() ) {
|
||||
//tempomat
|
||||
if (ScndCtrlPosNo > 1)
|
||||
if (ScndCtrlPosNo == 4 && SpeedCtrlTypeTime)
|
||||
{
|
||||
switch (ScndCtrlPos) {
|
||||
case 0:
|
||||
NewSpeed = 0;
|
||||
ScndCtrlActualPos = 0;
|
||||
SpeedCtrlTimer = 10;
|
||||
break;
|
||||
case 1:
|
||||
if (SpeedCtrlTimer > SpeedCtrlDelay) {
|
||||
SpeedCtrlTimer = 0;
|
||||
NewSpeed -= 10;
|
||||
if (NewSpeed < 0) NewSpeed = 0;
|
||||
}
|
||||
else
|
||||
SpeedCtrlTimer += dt;
|
||||
break;
|
||||
case 2:
|
||||
SpeedCtrlTimer = 10;
|
||||
ScndCtrlActualPos = NewSpeed;
|
||||
break;
|
||||
case 3:
|
||||
if (SpeedCtrlTimer > SpeedCtrlDelay) {
|
||||
SpeedCtrlTimer = 0;
|
||||
NewSpeed += 10;
|
||||
if (NewSpeed > Vmax) NewSpeed = Vmax;
|
||||
}
|
||||
else
|
||||
SpeedCtrlTimer += dt;
|
||||
break;
|
||||
case 4:
|
||||
NewSpeed = Vmax;
|
||||
ScndCtrlActualPos = Vmax;
|
||||
SpeedCtrlTimer = 10;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (ScndCtrlPosNo > 1)
|
||||
{
|
||||
if (ScndCtrlPos != NewSpeed)
|
||||
{
|
||||
@@ -5289,7 +5352,7 @@ bool TMoverParameters::FuseFlagCheck(void) const
|
||||
bool TMoverParameters::FuseOn(void)
|
||||
{
|
||||
bool FO = false;
|
||||
if ((MainCtrlPos == 0) && (ScndCtrlPos == 0) && (TrainType != dt_ET40) &&
|
||||
if ((IsMainCtrlNoPowerPos()) && (ScndCtrlPos == 0) && (TrainType != dt_ET40) &&
|
||||
((Mains) || (TrainType != dt_EZT)) && (!TestFlag(EngDmgFlag, 1)))
|
||||
{ // w ET40 jest blokada nastawnika, ale czy działa dobrze?
|
||||
SendCtrlToNext("FuseSwitch", 1, CabNo);
|
||||
@@ -5329,9 +5392,9 @@ double TMoverParameters::v2n(void)
|
||||
|
||||
n = V / (M_PI * WheelDiameter); // predkosc obrotowa wynikajaca z liniowej [obr/s]
|
||||
deltan = n - nrot; //"pochodna" prędkości obrotowej
|
||||
if (SlippingWheels)
|
||||
/* if (SlippingWheels)
|
||||
if (std::abs(deltan) < 0.001)
|
||||
SlippingWheels = false; // wygaszenie poslizgu
|
||||
SlippingWheels = false; // wygaszenie poslizgu */ //poslizg jest w innym miejscu wygaszany też
|
||||
if (SlippingWheels) // nie ma zwiazku z predkoscia liniowa V
|
||||
{ // McZapkie-221103: uszkodzenia kol podczas poslizgu
|
||||
if (deltan > dmgn)
|
||||
@@ -5777,7 +5840,7 @@ bool TMoverParameters::MotorConnectorsCheck() {
|
||||
( false == Mains )
|
||||
|| ( true == FuseFlag )
|
||||
|| ( true == StLinSwitchOff )
|
||||
|| ( MainCtrlPos == 0 )
|
||||
|| ( IsMainCtrlNoPowerPos() )
|
||||
|| ( ActiveDir == 0 ) };
|
||||
|
||||
if( connectorsoff ) { return false; }
|
||||
@@ -5785,8 +5848,9 @@ bool TMoverParameters::MotorConnectorsCheck() {
|
||||
auto const connectorson {
|
||||
( true == StLinFlag )
|
||||
|| ( ( MainCtrlActualPos == 0 )
|
||||
&& ( ( MainCtrlPos == 1 )
|
||||
|| ( ( TrainType == dt_EZT ) && ( MainCtrlPos > 0 ) ) ) ) };
|
||||
&& ( ( TrainType != dt_EZT ?
|
||||
MainCtrlPowerPos() == 1 :
|
||||
MainCtrlPowerPos() > 0 ) ) ) };
|
||||
|
||||
return connectorson;
|
||||
}
|
||||
@@ -5954,6 +6018,10 @@ void TMoverParameters::CheckEIMIC(double dt)
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case 3:
|
||||
eimic -= clamp(-UniCtrlList[MainCtrlPos].SetCtrlVal + eimic, 0.0, dt * UniCtrlList[MainCtrlPos].SpeedDown); //odejmuj do X
|
||||
eimic += clamp(UniCtrlList[MainCtrlPos].SetCtrlVal - eimic, 0.0, dt * UniCtrlList[MainCtrlPos].SpeedUp); //dodawaj do X
|
||||
eimic = clamp(eimic, UniCtrlList[MainCtrlPos].MinCtrlVal, UniCtrlList[MainCtrlPos].MaxCtrlVal);
|
||||
}
|
||||
eimic = clamp(eimic, -1.0, 1.0);
|
||||
}
|
||||
@@ -6034,7 +6102,7 @@ bool TMoverParameters::dizel_AutoGearCheck(void)
|
||||
{
|
||||
if (dizel_engagestate > 0)
|
||||
dizel_EngageSwitch(0);
|
||||
if ((MainCtrlPos == 0) && (ScndCtrlActualPos > 0))
|
||||
if ((IsMainCtrlNoPowerPos()) && (ScndCtrlActualPos > 0))
|
||||
dizel_automaticgearstatus = -1;
|
||||
}
|
||||
else
|
||||
@@ -6122,12 +6190,13 @@ bool TMoverParameters::dizel_StartupCheck() {
|
||||
|
||||
// test the fuel pump
|
||||
// TODO: add fuel pressure check
|
||||
if( false == FuelPump.is_active ) {
|
||||
if( ( false == FuelPump.is_active )
|
||||
|| ( ( EngineType == TEngineType::DieselEngine ) && ( RList[ MainCtrlPos ].R == 0.0 ) ) ) {
|
||||
engineisready = false;
|
||||
if( FuelPump.start_type == start_t::manual ) {
|
||||
// if( FuelPump.start_type == start_t::manual ) {
|
||||
// with manual pump control startup procedure is done only once per starter switch press
|
||||
dizel_startup = false;
|
||||
}
|
||||
// }
|
||||
}
|
||||
// test the oil pump
|
||||
if( ( false == OilPump.is_active )
|
||||
@@ -6317,10 +6386,10 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
|
||||
if (hydro_TC) //jesli przetwornik momentu
|
||||
{
|
||||
//napelnianie przetwornika
|
||||
if ((MainCtrlPos > 0) && (Mains) && (enrot>dizel_nmin*0.9))
|
||||
if ((MainCtrlPowerPos() > 0) && (Mains) && (enrot>dizel_nmin*0.9))
|
||||
hydro_TC_Fill += hydro_TC_FillRateInc * dt;
|
||||
//oproznianie przetwornika
|
||||
if (((MainCtrlPos == 0) && (Vel<3))
|
||||
if (((IsMainCtrlNoPowerPos()) && (Vel<3))
|
||||
|| (!Mains)
|
||||
|| (enrot<dizel_nmin*0.8))
|
||||
hydro_TC_Fill -= hydro_TC_FillRateDec * dt;
|
||||
@@ -6328,10 +6397,10 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
|
||||
hydro_TC_Fill = clamp(hydro_TC_Fill, 0.0, 1.0);
|
||||
|
||||
//blokowanie sprzegla blokującego
|
||||
if ((Vel > hydro_TC_LockupSpeed) && (Mains) && (enrot > 0.9 * dizel_nmin) && (MainCtrlPos>0))
|
||||
if ((Vel > hydro_TC_LockupSpeed) && (Mains) && (enrot > 0.9 * dizel_nmin) && (MainCtrlPowerPos() > 0))
|
||||
hydro_TC_LockupRate += hydro_TC_FillRateInc*dt;
|
||||
//luzowanie sprzegla blokujacego
|
||||
if ((Vel < (MainCtrlPos>0 ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed)) || (!Mains) || (enrot < 0.8 * dizel_nmin))
|
||||
if ((Vel < (MainCtrlPowerPos() > 0 ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed)) || (!Mains) || (enrot < 0.8 * dizel_nmin))
|
||||
hydro_TC_LockupRate -= hydro_TC_FillRateDec*dt;
|
||||
//obcinanie zakresu
|
||||
hydro_TC_LockupRate = clamp(hydro_TC_LockupRate, 0.0, 1.0);
|
||||
@@ -7201,7 +7270,7 @@ bool TMoverParameters::switch_physics(bool const State) // DO PRZETLUMACZENIA NA
|
||||
// *************************************************************************************************
|
||||
bool startBPT;
|
||||
bool startMPT, startMPT0;
|
||||
bool startRLIST;
|
||||
bool startRLIST, startUCLIST;
|
||||
bool startDLIST, startFFLIST, startWWLIST;
|
||||
bool startLIGHTSLIST;
|
||||
int LISTLINE;
|
||||
@@ -7396,6 +7465,31 @@ bool TMoverParameters::readRList( std::string const &Input ) {
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readUCList(std::string const &line) {
|
||||
|
||||
cParser parser(line);
|
||||
parser.getTokens(10, false);
|
||||
auto idx = LISTLINE++;
|
||||
if (idx >= sizeof(UniCtrlList) / sizeof(TUniversalCtrl)) {
|
||||
WriteLog("Read UCList: number of entries exceeded capacity of the data table");
|
||||
return false;
|
||||
}
|
||||
int i = 0;
|
||||
parser
|
||||
>> i
|
||||
>> UniCtrlList[idx].mode
|
||||
>> UniCtrlList[idx].MinCtrlVal
|
||||
>> UniCtrlList[idx].MaxCtrlVal
|
||||
>> UniCtrlList[idx].SetCtrlVal
|
||||
>> UniCtrlList[idx].SpeedUp
|
||||
>> UniCtrlList[idx].SpeedDown
|
||||
>> UniCtrlList[idx].ReturnPosition
|
||||
>> UniCtrlList[idx].NextPosFastInc
|
||||
>> UniCtrlList[idx].PrevPosFastDec;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool TMoverParameters::readDList( std::string const &line ) {
|
||||
|
||||
cParser parser( line );
|
||||
@@ -7585,6 +7679,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
startMPT = false;
|
||||
startMPT0 = false;
|
||||
startRLIST = false;
|
||||
startUCLIST = false;
|
||||
startDLIST = false;
|
||||
startFFLIST = false;
|
||||
startWWLIST = false;
|
||||
@@ -7641,6 +7736,11 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
startRLIST = false;
|
||||
continue;
|
||||
}
|
||||
if (issection("END-RL", inputline)) {
|
||||
startBPT = false;
|
||||
startUCLIST = false;
|
||||
continue;
|
||||
}
|
||||
if( issection( "END-DL", inputline ) ) {
|
||||
startBPT = false;
|
||||
startDLIST = false;
|
||||
@@ -7844,6 +7944,15 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (issection("UCList:", inputline))
|
||||
{
|
||||
startBPT = false;
|
||||
fizlines.emplace("UCList", inputline);
|
||||
startUCLIST = true; LISTLINE = 0;
|
||||
LoadFIZ_RList(inputline);
|
||||
continue;
|
||||
}
|
||||
|
||||
if( issection( "DList:", inputline ) )
|
||||
{
|
||||
startBPT = false;
|
||||
@@ -7893,6 +8002,10 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
||||
readRList( inputline );
|
||||
continue;
|
||||
}
|
||||
if (true == startUCLIST) {
|
||||
readRList(inputline);
|
||||
continue;
|
||||
}
|
||||
if( true == startDLIST ) {
|
||||
readDList( inputline );
|
||||
continue;
|
||||
@@ -8491,6 +8604,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
extract_value( MainCtrlPosNo, "MCPN", line, "" );
|
||||
extract_value( ScndCtrlPosNo, "SCPN", line, "" );
|
||||
extract_value( ScndInMain, "SCIM", line, "" );
|
||||
extract_value( MaxMainCtrlPosNoDirChange, "DirChangeMaxPos", line, "" );
|
||||
|
||||
std::string autorelay;
|
||||
extract_value( autorelay, "AutoRelay", line, "" );
|
||||
@@ -8500,7 +8614,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
|
||||
extract_value( CoupledCtrl, "CoupledCtrl", line, "" );
|
||||
extract_value( EIMCtrlType, "EIMCtrlType", line, "" );
|
||||
clamp( EIMCtrlType, 0, 2 );
|
||||
clamp( EIMCtrlType, 0, 3 );
|
||||
|
||||
extract_value( ScndS, "ScndS", line, "" ); // brak pozycji rownoleglej przy niskiej nastawie PSR
|
||||
|
||||
@@ -8519,6 +8633,10 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
|
||||
// speed control
|
||||
extract_value( SpeedCtrlDelay, "SpeedCtrlDelay", line, "" );
|
||||
SpeedCtrlTypeTime =
|
||||
(extract_value("SpeedCtrlType", line) == "Time") ?
|
||||
true :
|
||||
false;
|
||||
|
||||
// converter
|
||||
{
|
||||
@@ -8911,6 +9029,12 @@ void TMoverParameters::LoadFIZ_RList( std::string const &Input ) {
|
||||
extract_value( DynamicBrakeRes2, "DynBrakeRes2", Input, "");
|
||||
}
|
||||
|
||||
void TMoverParameters::LoadFIZ_UCList(std::string const &Input) {
|
||||
|
||||
extract_value(UniCtrlListSize, "Size", Input, "");
|
||||
|
||||
}
|
||||
|
||||
void TMoverParameters::LoadFIZ_DList( std::string const &Input ) {
|
||||
|
||||
extract_value( dizel_Mmax, "Mmax", Input, "" );
|
||||
|
||||
@@ -346,7 +346,7 @@ double TBrake::GetVRP()
|
||||
// cisnienie zbiornika sterujacego
|
||||
double TBrake::GetCRP()
|
||||
{
|
||||
return 0;
|
||||
return GetBRP();
|
||||
}
|
||||
|
||||
// przeplyw z przewodu glowneg
|
||||
@@ -481,6 +481,12 @@ double TWest::GetPF( double const PP, double const dt, double const Vel )
|
||||
dv = 0;
|
||||
BrakeCyl->Flow(-dv);
|
||||
|
||||
if ((BrakeStatus & b_rls) == b_rls) //odluzniacz
|
||||
dv = PF(0, CVP, 0.1 * SizeBC) * dt;
|
||||
else
|
||||
dv = 0;
|
||||
BrakeCyl->Flow(-dv);
|
||||
|
||||
// hamulec EP
|
||||
temp = BVP * int(EPS > 0);
|
||||
dv = PF(temp, LBP, 0.0015) * dt * EPS * EPS * int(LBP * EPS < MaxBP * LoadC);
|
||||
@@ -2788,7 +2794,7 @@ double TMHZ_K5P::GetPos(int i)
|
||||
|
||||
double TMHZ_K5P::GetCP()
|
||||
{
|
||||
return RP;
|
||||
return CP;
|
||||
}
|
||||
|
||||
void TMHZ_K5P::SetParams(bool AO, bool MO, double, double)
|
||||
@@ -2890,6 +2896,8 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
|
||||
void TMHZ_6P::Init(double Press)
|
||||
{
|
||||
CP = Press;
|
||||
Time = true;
|
||||
TimeEP = true;
|
||||
}
|
||||
|
||||
void TMHZ_6P::SetReductor(double nAdj)
|
||||
@@ -2912,7 +2920,7 @@ double TMHZ_6P::GetPos(int i)
|
||||
|
||||
double TMHZ_6P::GetCP()
|
||||
{
|
||||
return RP;
|
||||
return CP;
|
||||
}
|
||||
|
||||
void TMHZ_6P::SetParams(bool AO, bool MO, double OverP, double)
|
||||
|
||||
20
Train.cpp
20
Train.cpp
@@ -462,6 +462,7 @@ dictionary_source *TTrain::GetTrainState() {
|
||||
dict->insert( "main_ctrl_actual_pos", mover->MainCtrlActualPos );
|
||||
dict->insert( "scndctrl_pos", mover->ScndCtrlPos );
|
||||
dict->insert( "scnd_ctrl_actual_pos", mover->ScndCtrlActualPos );
|
||||
dict->insert( "new_speed", mover->NewSpeed);
|
||||
// brakes
|
||||
dict->insert( "manual_brake", ( mvOccupied->ManualBrakePos > 0 ) );
|
||||
bool const bEP = ( mvControlled->LocHandle->GetCP() > 0.2 ) || ( fEIMParams[ 0 ][ 2 ] > 0.01 );
|
||||
@@ -789,8 +790,8 @@ void TTrain::OnCommand_jointcontrollerset( TTrain *Train, command_data const &Co
|
||||
clamp(
|
||||
1.0 - ( Command.param1 * 2 ),
|
||||
0.0, 1.0 ) );
|
||||
if( Train->mvControlled->MainCtrlPos > 0 ) {
|
||||
Train->set_master_controller( 0 );
|
||||
if( Train->mvControlled->MainCtrlPowerPos() > 0 ) {
|
||||
Train->set_master_controller( Train->mvControlled->MainCtrlNoPowerPos() );
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -846,7 +847,7 @@ void TTrain::OnCommand_mastercontrollerdecrease( TTrain *Train, command_data con
|
||||
if( Command.action != GLFW_RELEASE ) {
|
||||
// on press or hold
|
||||
if( ( Train->ggJointCtrl.SubModel != nullptr )
|
||||
&& ( Train->mvControlled->MainCtrlPos == 0 ) ) {
|
||||
&& ( Train->mvControlled->IsMainCtrlNoPowerPos() ) ) {
|
||||
OnCommand_independentbrakeincrease( Train, Command );
|
||||
}
|
||||
else {
|
||||
@@ -866,7 +867,7 @@ void TTrain::OnCommand_mastercontrollerdecreasefast( TTrain *Train, command_data
|
||||
if( Command.action != GLFW_RELEASE ) {
|
||||
// on press or hold
|
||||
if( ( Train->ggJointCtrl.SubModel != nullptr )
|
||||
&& ( Train->mvControlled->MainCtrlPos == 0 ) ) {
|
||||
&& ( Train->mvControlled->IsMainCtrlNoPowerPos() ) ) {
|
||||
OnCommand_independentbrakeincreasefast( Train, Command );
|
||||
}
|
||||
else {
|
||||
@@ -5521,7 +5522,12 @@ bool TTrain::Update( double const Deltatime )
|
||||
}
|
||||
if (ggIgnitionKey.SubModel)
|
||||
{
|
||||
ggIgnitionKey.UpdateValue(mvControlled->dizel_startup);
|
||||
ggIgnitionKey.UpdateValue(
|
||||
( mvControlled->Mains )
|
||||
|| ( mvControlled->dizel_startup )
|
||||
|| ( fMainRelayTimer > 0.f )
|
||||
|| ( ggMainButton.GetDesiredValue() > 0.95 )
|
||||
|| ( ggMainOnButton.GetDesiredValue() > 0.95 ) );
|
||||
ggIgnitionKey.Update();
|
||||
}
|
||||
}
|
||||
@@ -5719,6 +5725,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
// others
|
||||
btLampkaMalfunction.Turn( mvControlled->dizel_heat.PA );
|
||||
btLampkaMotorBlowers.Turn( ( mvControlled->MotorBlowers[ end::front ].is_active ) && ( mvControlled->MotorBlowers[ end::rear ].is_active ) );
|
||||
btLampkaCoolingFans.Turn( mvControlled->RventRot > 1.0 );
|
||||
// universal devices state indicators
|
||||
for( auto idx = 0; idx < btUniversals.size(); ++idx ) {
|
||||
btUniversals[ idx ].Turn( ggUniversals[ idx ].GetValue() > 0.5 );
|
||||
@@ -5779,6 +5786,7 @@ bool TTrain::Update( double const Deltatime )
|
||||
// others
|
||||
btLampkaMalfunction.Turn( false );
|
||||
btLampkaMotorBlowers.Turn( false );
|
||||
btLampkaCoolingFans.Turn( false );
|
||||
// universal devices state indicators
|
||||
for( auto &universal : btUniversals ) {
|
||||
universal.Turn( false );
|
||||
@@ -7535,6 +7543,7 @@ void TTrain::clear_cab_controls()
|
||||
btLampkaMalfunction.Clear();
|
||||
btLampkaMalfunctionB.Clear();
|
||||
btLampkaMotorBlowers.Clear();
|
||||
btLampkaCoolingFans.Clear();
|
||||
|
||||
ggLeftLightButton.Clear();
|
||||
ggRightLightButton.Clear();
|
||||
@@ -7879,6 +7888,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
|
||||
{ "i-highcurrent:", btLampkaWysRozr },
|
||||
{ "i-vent_trim:", btLampkaWentZaluzje },
|
||||
{ "i-motorblowers:", btLampkaMotorBlowers },
|
||||
{ "i-coolingfans:", btLampkaCoolingFans },
|
||||
{ "i-trainheating:", btLampkaOgrzewanieSkladu },
|
||||
{ "i-security_aware:", btLampkaCzuwaka },
|
||||
{ "i-security_cabsignal:", btLampkaSHP },
|
||||
|
||||
1
Train.h
1
Train.h
@@ -590,6 +590,7 @@ public: // reszta może by?publiczna
|
||||
TButton btLampkaMalfunction;
|
||||
TButton btLampkaMalfunctionB;
|
||||
TButton btLampkaMotorBlowers;
|
||||
TButton btLampkaCoolingFans;
|
||||
|
||||
TButton btCabLight; // hunter-171012: lampa oswietlajaca kabine
|
||||
// Ra 2013-12: wirtualne "lampki" do odbijania na haslerze w PoKeys
|
||||
|
||||
@@ -175,9 +175,7 @@ openal_source::bind( sound_source *Controller, uint32_sequence Sounds, Iterator_
|
||||
First, Last,
|
||||
[&]( audio::buffer_handle const &bufferhandle ) {
|
||||
auto const &buffer { audio::renderer.buffer( bufferhandle ) };
|
||||
buffers.emplace_back( buffer.id );
|
||||
if( false == buffer.caption.empty() ) {
|
||||
ui::Transcripts.Add( buffer.caption ); } } );
|
||||
buffers.emplace_back( buffer.id ); } );
|
||||
|
||||
if( id != audio::null_resource ) {
|
||||
::alSourceQueueBuffers( id, static_cast<ALsizei>( buffers.size() ), buffers.data() );
|
||||
|
||||
@@ -208,7 +208,7 @@ scenario_panel::render() {
|
||||
auto const assignmentheader { locale::strings[ locale::string::driver_scenario_assignment ] };
|
||||
if( ( false == owner->assignment().empty() )
|
||||
&& ( true == ImGui::CollapsingHeader( assignmentheader.c_str() ) ) ) {
|
||||
ImGui::TextWrapped( owner->assignment().c_str() );
|
||||
ImGui::TextWrapped( "%s", owner->assignment().c_str() );
|
||||
ImGui::Separator();
|
||||
}
|
||||
}
|
||||
@@ -825,7 +825,8 @@ debug_panel::update_section_ai( std::vector<text_line> &Output ) {
|
||||
+ ", slope: " + to_string( mechanik.fAccGravity + 0.001f, 2 ) + " (" + ( mechanik.fAccGravity > 0.01 ? "\\" : ( mechanik.fAccGravity < -0.01 ? "/" : "-" ) ) + ")"
|
||||
+ "\n brake threshold: " + to_string( mechanik.fAccThreshold, 2 )
|
||||
+ ", delays: " + to_string( mechanik.fBrake_a0[ 0 ], 2 )
|
||||
+ "+" + to_string( mechanik.fBrake_a1[ 0 ], 2 );
|
||||
+ "+" + to_string( mechanik.fBrake_a1[ 0 ], 2 )
|
||||
+ "\n virtual brake position: " + to_string(mechanik.BrakeCtrlPosition, 2);
|
||||
|
||||
Output.emplace_back( textline, Global.UITextColor );
|
||||
|
||||
@@ -1002,10 +1003,8 @@ transcripts_panel::update() {
|
||||
text_lines.clear();
|
||||
|
||||
for( auto const &transcript : ui::Transcripts.aLines ) {
|
||||
if( Global.fTimeAngleDeg >= transcript.fShow ) {
|
||||
// NOTE: legacy transcript lines use | as new line mark
|
||||
text_lines.emplace_back( ExchangeCharInString( transcript.asText, '|', ' ' ), colors::white );
|
||||
}
|
||||
if( Global.fTimeAngleDeg + ( transcript.fShow - Global.fTimeAngleDeg > 180 ? 360 : 0 ) < transcript.fShow ) { continue; }
|
||||
text_lines.emplace_back( ExchangeCharInString( transcript.asText, '|', ' ' ), colors::white );
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1034,7 +1033,7 @@ transcripts_panel::render() {
|
||||
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
|
||||
// header section
|
||||
for( auto const &line : text_lines ) {
|
||||
ImGui::TextWrapped( line.data.c_str() );
|
||||
ImGui::TextWrapped( "%s", line.data.c_str() );
|
||||
}
|
||||
}
|
||||
ImGui::End();
|
||||
|
||||
@@ -94,6 +94,17 @@ world_environment::update() {
|
||||
// NOTE: sun light receives extra padding to prevent moon from kicking in too soon
|
||||
auto const sunlightlevel = m_sun.getIntensity() + 0.05f * ( 1.f - twilightfactor );
|
||||
auto const moonlightlevel = m_moon.getIntensity() * 0.65f; // scaled down by arbitrary factor, it's pretty bright otherwise
|
||||
|
||||
// ...update skydome to match the current sun position as well...
|
||||
// twilight factor can be reset later down, so we do it here while it's still reflecting state of the sun
|
||||
// turbidity varies from 2-3 during the day based on overcast, 3-4 after sunset to deal with sunlight bleeding too much into the sky from below horizon
|
||||
m_skydome.SetTurbidity(
|
||||
2.f
|
||||
+ clamp( Global.Overcast, 0.f, 1.f )
|
||||
+ interpolate( 0.f, 1.f, clamp( twilightfactor * 1.5f, 0.f, 1.f ) ) );
|
||||
m_skydome.SetOvercastFactor( Global.Overcast );
|
||||
m_skydome.Update( m_sun.getDirection() );
|
||||
|
||||
float keylightintensity;
|
||||
glm::vec3 keylightcolor;
|
||||
if( moonlightlevel > sunlightlevel ) {
|
||||
@@ -119,9 +130,6 @@ world_environment::update() {
|
||||
glm::vec3( 235.0f / 255.0f, 140.0f / 255.0f, 36.0f / 255.0f ),
|
||||
duskfactor );
|
||||
}
|
||||
// ...update skydome to match the current sun position as well...
|
||||
m_skydome.SetOvercastFactor( Global.Overcast );
|
||||
m_skydome.Update( m_sun.getDirection() );
|
||||
// ...retrieve current sky colour and brightness...
|
||||
auto const skydomecolour = m_skydome.GetAverageColor();
|
||||
auto const skydomehsv = colors::RGBtoHSV( skydomecolour );
|
||||
|
||||
@@ -171,7 +171,7 @@ bool CSkyDome::SetSunPosition( glm::vec3 const &Direction ) {
|
||||
|
||||
void CSkyDome::SetTurbidity( float const Turbidity ) {
|
||||
|
||||
m_turbidity = clamp( Turbidity, 1.0f, 512.0f );
|
||||
m_turbidity = clamp( Turbidity, 1.f, 4.f );
|
||||
}
|
||||
|
||||
void CSkyDome::SetExposure( bool const Linearexposure, float const Expfactor ) {
|
||||
|
||||
@@ -861,6 +861,13 @@ sound_source::update_counter( sound_handle const Sound, int const Value ) {
|
||||
|
||||
// sound( Sound ).playing = std::max( 0, sound( Sound ).playing + Value );
|
||||
sound( Sound ).playing += Value;
|
||||
if( ( m_properties.gain > 0.f )
|
||||
&& ( sound( Sound ).playing == 1 ) ) {
|
||||
auto const &buffer { audio::renderer.buffer( sound( Sound ).buffer ) };
|
||||
if( false == buffer.caption.empty() ) {
|
||||
ui::Transcripts.Add( buffer.caption );
|
||||
}
|
||||
}
|
||||
assert( sound( Sound ).playing >= 0 );
|
||||
}
|
||||
|
||||
|
||||
@@ -15,11 +15,12 @@ TTranscripts::AddLine( std::string const &txt, float show, float hide, bool it )
|
||||
|
||||
if( show == hide ) { return; } // komentarz jest ignorowany
|
||||
|
||||
// TODO: replace the timeangledeg mess with regular time points math
|
||||
show = Global.fTimeAngleDeg + show / 240.0; // jeśli doba to 360, to 1s będzie równe 1/240
|
||||
hide = Global.fTimeAngleDeg + hide / 240.0;
|
||||
|
||||
TTranscript transcript;
|
||||
transcript.asText = txt;
|
||||
transcript.asText = ExchangeCharInString( txt, '|', ' ' ); // NOTE: legacy transcript lines use | as new line mark
|
||||
transcript.fShow = show;
|
||||
transcript.fHide = hide;
|
||||
transcript.bItalic = it;
|
||||
@@ -62,12 +63,25 @@ TTranscripts::Add( std::string const &txt, bool backgorund ) {
|
||||
void
|
||||
TTranscripts::Update() {
|
||||
|
||||
// HACK: detect day change
|
||||
if( fRefreshTime - Global.fTimeAngleDeg > 180 ) {
|
||||
fRefreshTime -= 360;
|
||||
}
|
||||
|
||||
if( Global.fTimeAngleDeg < fRefreshTime ) { return; } // nie czas jeszcze na zmiany
|
||||
|
||||
while( ( false == aLines.empty() )
|
||||
&& ( Global.fTimeAngleDeg >= aLines.front().fHide ) ) {
|
||||
// remove expired lines
|
||||
aLines.pop_front();
|
||||
// remove expired lines
|
||||
while( false == aLines.empty() ) {
|
||||
// HACK: detect day change
|
||||
if( aLines.front().fHide - Global.fTimeAngleDeg > 180 ) {
|
||||
aLines.front().fShow -= 360;
|
||||
aLines.front().fHide -= 360;
|
||||
}
|
||||
if( Global.fTimeAngleDeg <= aLines.front().fHide ) {
|
||||
// no expired lines yet
|
||||
break;
|
||||
}
|
||||
aLines.pop_front(); // this line expired, discard it and start anew with the next one
|
||||
}
|
||||
// update next refresh time
|
||||
if( false == aLines.empty() ) { fRefreshTime = aLines.front().fHide; }
|
||||
|
||||
Reference in New Issue
Block a user