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

build 170502. minor fixes for brakes subsystem, distribution of sandbox commands to other consist units

This commit is contained in:
tmj-fstate
2017-05-02 22:29:51 +02:00
parent ce7c2a3c49
commit 473837395c
15 changed files with 523 additions and 420 deletions

View File

@@ -2696,8 +2696,18 @@ void TController::SpeedSet()
if (ReactionTime > 0.1) if (ReactionTime > 0.1)
ReactionTime = 0.1; // orientuj się szybciej ReactionTime = 0.1; // orientuj się szybciej
} // if (Im>Imin) } // if (Im>Imin)
if (fabs(mvControlling->Im) > 0.75 * mvControlling->ImaxHi) // jeśli prąd jest duży // NOTE: this step is likely to conflict with directive to operate sandbox based on the state of slipping wheels
mvControlling->SandDoseOn(); // piaskujemy tory, coby się nie ślizgać // TODO: gather all sandbox operating logic in one place
if( fabs( mvControlling->Im ) > 0.75 * mvControlling->ImaxHi ) {
// jeśli prąd jest duży
mvControlling->Sandbox( true ); // piaskujemy tory, coby się nie ślizgać
}
else {
// otherwise we switch the sander off, if it's active
if( mvControlling->SandDose ) {
mvControlling->Sandbox( false );
}
}
if ((fabs(mvControlling->Im) > 0.96 * mvControlling->Imax) || if ((fabs(mvControlling->Im) > 0.96 * mvControlling->Imax) ||
mvControlling->SlippingWheels) // jeśli prąd jest duży (można 690 na 750) mvControlling->SlippingWheels) // jeśli prąd jest duży (można 690 na 750)
if (mvControlling->ScndCtrlPos > 0) // jeżeli jest bocznik if (mvControlling->ScndCtrlPos > 0) // jeżeli jest bocznik
@@ -3241,10 +3251,16 @@ bool TController::UpdateSituation(double dt)
// mvOccupied->PipePress=0.5; //yB: w SPKS są poprawnie zrobione pozycje // mvOccupied->PipePress=0.5; //yB: w SPKS są poprawnie zrobione pozycje
if (mvControlling->SlippingWheels) if (mvControlling->SlippingWheels)
{ {
mvControlling->SandDoseOn(); // piasku! mvControlling->Sandbox(true); // piasku!
// Controlling->SlippingWheels=false; //a to tu nie ma sensu, flaga używana w dalszej // Controlling->SlippingWheels=false; //a to tu nie ma sensu, flaga używana w dalszej
// części // części
} }
else {
// deactivate sandbox if we aren't slipping
if( mvControlling->SandDose ) {
mvControlling->Sandbox( false );
}
}
} }
// ABu-160305 testowanie gotowości do jazdy // ABu-160305 testowanie gotowości do jazdy
// Ra: przeniesione z DynObj, skład użytkownika też jest testowany, żeby mu przekazać, że ma // Ra: przeniesione z DynObj, skład użytkownika też jest testowany, żeby mu przekazać, że ma
@@ -3293,6 +3309,16 @@ bool TController::UpdateSituation(double dt)
if (fReady < 0.8) // delikatniejszy warunek, obejmuje wszystkie wagony if (fReady < 0.8) // delikatniejszy warunek, obejmuje wszystkie wagony
Ready = true; //żeby uznać za odhamowany Ready = true; //żeby uznać za odhamowany
HelpMeFlag = false; HelpMeFlag = false;
// crude way to deal with automatic door opening on W4 preventing further ride
// for human-controlled vehicles with no door control and dynamic brake auto-activating with door open
if( ( false == AIControllFlag )
&& ( iDrivigFlags & moveDoorOpened )
&& ( mvOccupied->DoorOpenCtrl != 1 )
&& ( mvControlling->MainCtrlPos > 0 ) ) {
Doors( false );
}
// Winger 020304 // Winger 020304
if (AIControllFlag) if (AIControllFlag)
{ {

View File

@@ -1753,27 +1753,22 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
// wylaczanie hamulca // wylaczanie hamulca
if (ActPar.find("<>") != std::string::npos) // wylaczanie na probe hamowania naglego if (ActPar.find("<>") != std::string::npos) // wylaczanie na probe hamowania naglego
{ {
MoverParameters->BrakeStatus |= 128; // wylacz MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz
} }
if (ActPar.find('0') != std::string::npos) // wylaczanie na sztywno if (ActPar.find('0') != std::string::npos) // wylaczanie na sztywno
{ {
MoverParameters->BrakeStatus |= 128; // wylacz MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz
MoverParameters->Hamulec->ForceEmptiness(); MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
} }
if (ActPar.find('E') != std::string::npos) // oprozniony if (ActPar.find('E') != std::string::npos) // oprozniony
{ {
MoverParameters->Hamulec->ForceEmptiness(); MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
MoverParameters->Pipe->CreatePress(0); MoverParameters->Pipe->CreatePress(0);
MoverParameters->Pipe2->CreatePress(0); MoverParameters->Pipe2->CreatePress(0);
} }
if (ActPar.find('Q') != std::string::npos) // oprozniony if (ActPar.find('Q') != std::string::npos) // oprozniony
{ {
// MoverParameters->Hamulec->ForceEmptiness(); //TODO: sprawdzic, MoverParameters->Hamulec->ForceEmptiness();
// dlaczego
// pojawia sie blad przy uzyciu tej linijki w lokomotywie
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
MoverParameters->Pipe->CreatePress(0.0); MoverParameters->Pipe->CreatePress(0.0);
MoverParameters->PipePress = 0.0; MoverParameters->PipePress = 0.0;
MoverParameters->Pipe2->CreatePress(0.0); MoverParameters->Pipe2->CreatePress(0.0);
@@ -1787,18 +1782,16 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
{ {
if (Random(10) < 1) // losowanie 1/10 if (Random(10) < 1) // losowanie 1/10
{ {
MoverParameters->BrakeStatus |= 128; // wylacz MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz
MoverParameters->Hamulec->ForceEmptiness(); MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
} }
} }
if (ActPar.find('X') != std::string::npos) // agonalny wylaczanie 20%, usrednienie przekladni if (ActPar.find('X') != std::string::npos) // agonalny wylaczanie 20%, usrednienie przekladni
{ {
if (Random(100) < 20) // losowanie 20/100 if (Random(100) < 20) // losowanie 20/100
{ {
MoverParameters->BrakeStatus |= 128; // wylacz MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz
MoverParameters->Hamulec->ForceEmptiness(); MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
} }
if (MoverParameters->BrakeCylMult[2] * MoverParameters->BrakeCylMult[1] > if (MoverParameters->BrakeCylMult[2] * MoverParameters->BrakeCylMult[1] >
0.01) // jesli jest nastawiacz mechaniczny PL 0.01) // jesli jest nastawiacz mechaniczny PL
@@ -2443,16 +2436,6 @@ bool TDynamicObject::Update(double dt, double dt1)
if (!bEnabled) if (!bEnabled)
return false; // a normalnie powinny mieć bEnabled==false return false; // a normalnie powinny mieć bEnabled==false
// Ra: przeniosłem - no już lepiej tu, niż w wyświetlaniu!
// if ((MoverParameters->ConverterFlag==false) &&
// (MoverParameters->TrainType!=dt_ET22))
// Ra: to nie może tu być, bo wyłącza sprężarkę w rozrządczym EZT!
// if
// ((MoverParameters->ConverterFlag==false)&&(MoverParameters->CompressorPower!=0))
// MoverParameters->CompressorFlag=false;
// if (MoverParameters->CompressorPower==2)
// MoverParameters->CompressorAllow=MoverParameters->ConverterFlag;
// McZapkie-260202 // McZapkie-260202
if ((MoverParameters->EnginePowerSource.SourceType == CurrentCollector) && if ((MoverParameters->EnginePowerSource.SourceType == CurrentCollector) &&
(MoverParameters->Power > 1.0)) // aby rozrządczy nie opuszczał silnikowemu (MoverParameters->Power > 1.0)) // aby rozrządczy nie opuszczał silnikowemu
@@ -2500,6 +2483,7 @@ bool TDynamicObject::Update(double dt, double dt1)
if( MoverParameters->PantPress >= 4.8 ) { if( MoverParameters->PantPress >= 4.8 ) {
// Winger - automatyczne wylaczanie malej sprezarki // Winger - automatyczne wylaczanie malej sprezarki
// TODO: governor lock, disables usage until pressure drop below 3.8 (should really make compressor object we could reuse)
MoverParameters->PantCompFlag = false; MoverParameters->PantCompFlag = false;
} }
} }
@@ -2958,28 +2942,6 @@ bool TDynamicObject::Update(double dt, double dt1)
MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) ); MoverParameters->PantRear( false, ( MoverParameters->TrainType == dt_EZT ? command_range::unit : command_range::local ) );
} }
} }
if (MoverParameters->TrainType == dt_ET42)
{ // powinny być wszystkie dwuczłony oraz EZT
/*
//Ra: to jest bez sensu, bo wyłącza WS przy przechodzeniu przez
"wewnętrzne" kabiny (z
powodu ActiveCab)
//trzeba to zrobić inaczej, np. dla członu A sprawdzać, czy jest B
//albo sprawdzać w momencie załączania WS i zmiany w sprzęgach
if
(((TestFlag(MoverParameters->Couplers[1].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab>0)&&(NextConnected->MoverParameters->TrainType!=dt_ET42))||((TestFlag(MoverParameters->Couplers[0].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab<0)&&(PrevConnected->MoverParameters->TrainType!=dt_ET42)))
{//sprawdzenie, czy z tyłu kabiny mamy drugi człon
if (MoverParameters->MainSwitch(false))
MoverParameters->EventFlag=true;
}
if
((!(TestFlag(MoverParameters->Couplers[1].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab>0))||(!(TestFlag(MoverParameters->Couplers[0].CouplingFlag,ctrain_controll))&&(MoverParameters->ActiveCab<0)))
{
if (MoverParameters->MainSwitch(false))
MoverParameters->EventFlag=true;
}
*/
}
// McZapkie-260202 - dMoveLen przyda sie przy stukocie kol // McZapkie-260202 - dMoveLen przyda sie przy stukocie kol
dDOMoveLen = dDOMoveLen =
@@ -3323,6 +3285,9 @@ bool TDynamicObject::Update(double dt, double dt1)
sPantDown.Play(vol, 0, MechInside, vPosition); sPantDown.Play(vol, 0, MechInside, vPosition);
MoverParameters->PantRearSP = true; MoverParameters->PantRearSP = true;
} }
/*
// NOTE: disabled because it's both redundant and doesn't take into account alternative power sources
// converter and compressor will (should) turn off during their individual checks, in the mover's (fast)computemovement() calls
if (MoverParameters->EnginePowerSource.SourceType == CurrentCollector) if (MoverParameters->EnginePowerSource.SourceType == CurrentCollector)
{ // Winger 240404 - wylaczanie sprezarki i { // Winger 240404 - wylaczanie sprezarki i
// przetwornicy przy braku napiecia // przetwornicy przy braku napiecia
@@ -3332,6 +3297,7 @@ bool TDynamicObject::Update(double dt, double dt1)
MoverParameters->CompressorFlag = false; // Ra: to jest wątpliwe - wyłączenie sprężarki powinno być w jednym miejscu! MoverParameters->CompressorFlag = false; // Ra: to jest wątpliwe - wyłączenie sprężarki powinno być w jednym miejscu!
} }
} }
*/
} }
else if (MoverParameters->EnginePowerSource.SourceType == InternalSource) else if (MoverParameters->EnginePowerSource.SourceType == InternalSource)
if (MoverParameters->EnginePowerSource.PowerType == SteamPower) if (MoverParameters->EnginePowerSource.PowerType == SteamPower)

View File

@@ -130,7 +130,9 @@ class TTranscript
float fHide; // czas ukrycia/usunięcia float fHide; // czas ukrycia/usunięcia
std::string asText; // tekst gotowy do wyświetlenia (usunięte znaczniki czasu) std::string asText; // tekst gotowy do wyświetlenia (usunięte znaczniki czasu)
bool bItalic; // czy kursywa (dźwięk nieistotny dla prowadzącego) bool bItalic; // czy kursywa (dźwięk nieistotny dla prowadzącego)
/*
int iNext; // następna używana linijka, żeby nie przestawiać fizycznie tabeli int iNext; // następna używana linijka, żeby nie przestawiać fizycznie tabeli
*/
}; };
/* /*

View File

@@ -69,7 +69,7 @@ struct TGroundVertex
{ {
vector3 Point; vector3 Point;
vector3 Normal; vector3 Normal;
float tu, tv; float tu{ 0.0f }, tv{ 0.0f };
void HalfSet(const TGroundVertex &v1, const TGroundVertex &v2) void HalfSet(const TGroundVertex &v1, const TGroundVertex &v2)
{ // wyliczenie współrzędnych i mapowania punktu na środku odcinka v1<->v2 { // wyliczenie współrzędnych i mapowania punktu na środku odcinka v1<->v2
Point = 0.5 * (v1.Point + v2.Point); Point = 0.5 * (v1.Point + v2.Point);

View File

@@ -377,7 +377,7 @@ struct TBoilerType {
}; };
/*rodzaj odbieraka pradu*/ /*rodzaj odbieraka pradu*/
struct TCurrentCollector { struct TCurrentCollector {
long CollectorsNo{ 0.0 }; //musi być tu, bo inaczej się kopie long CollectorsNo{ 0 }; //musi być tu, bo inaczej się kopie
double MinH{ 0.0 }; double MaxH{ 0.0 }; //zakres ruchu pantografu, nigdzie nie używany double MinH{ 0.0 }; double MaxH{ 0.0 }; //zakres ruchu pantografu, nigdzie nie używany
double CSW{ 0.0 }; //szerokość części roboczej (styku) ślizgacza double CSW{ 0.0 }; //szerokość części roboczej (styku) ślizgacza
double MinV{ 0.0 }; double MaxV{ 0.0 }; //minimalne i maksymalne akceptowane napięcie double MinV{ 0.0 }; double MaxV{ 0.0 }; //minimalne i maksymalne akceptowane napięcie
@@ -554,8 +554,9 @@ struct TTransmision
enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic }; enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic };
struct power_coupling { struct power_coupling {
double outgoing{ 0.0 }; // power generated by coupling owner double current{ 0.0 };
double incoming{ 0.0 }; // power supplied from outside source double voltage{ 0.0 };
bool local{ false }; // whether the power comes from external or onboard source
}; };
struct TCoupling { struct TCoupling {
@@ -800,8 +801,8 @@ public:
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
double HVCouplers[ 2 ][ 2 ]; //przewod WN double HVCouplers[ 2 ][ 2 ]; //przewod WN
enum hvcoupler { enum hvcoupler {
incoming = 0, current = 0,
outgoing voltage
}; };
#endif #endif
int ScanCounter = 0; /*pomocnicze do skanowania sprzegow*/ int ScanCounter = 0; /*pomocnicze do skanowania sprzegow*/
@@ -848,7 +849,9 @@ public:
int LocalBrakePos = 0; /*nastawa hamulca indywidualnego*/ int LocalBrakePos = 0; /*nastawa hamulca indywidualnego*/
int ManualBrakePos = 0; /*nastawa hamulca recznego*/ int ManualBrakePos = 0; /*nastawa hamulca recznego*/
double LocalBrakePosA = 0.0; double LocalBrakePosA = 0.0;
int BrakeStatus = b_off; /*0 - odham, 1 - ham., 2 - uszk., 4 - odluzniacz, 8 - antyposlizg, 16 - uzyte EP, 32 - pozycja R, 64 - powrot z R*/ /*
int BrakeStatus = b_off; //0 - odham, 1 - ham., 2 - uszk., 4 - odluzniacz, 8 - antyposlizg, 16 - uzyte EP, 32 - pozycja R, 64 - powrot z R
*/
bool EmergencyBrakeFlag = false; /*hamowanie nagle*/ bool EmergencyBrakeFlag = false; /*hamowanie nagle*/
int BrakeDelayFlag = 0; /*nastawa opoznienia ham. osob/towar/posp/exp 0/1/2/4*/ int BrakeDelayFlag = 0; /*nastawa opoznienia ham. osob/towar/posp/exp 0/1/2/4*/
int BrakeDelays = 0; /*nastawy mozliwe do uzyskania*/ int BrakeDelays = 0; /*nastawy mozliwe do uzyskania*/
@@ -1040,7 +1043,7 @@ public:
bool AddPulseForce(int Multipler);/*dla drezyny*/ bool AddPulseForce(int Multipler);/*dla drezyny*/
bool SandDoseOn(void);/*wlacza/wylacza sypanie piasku*/ bool Sandbox( bool const State, int const Notify = command_range::consist );/*wlacza/wylacza sypanie piasku*/
/*! zbijanie czuwaka/SHP*/ /*! zbijanie czuwaka/SHP*/
void SSReset(void); void SSReset(void);
@@ -1112,7 +1115,7 @@ public:
/*function ShowEngineRotation(VehN:int): integer; //Ra 2014-06: przeniesione do C++*/ /*function ShowEngineRotation(VehN:int): integer; //Ra 2014-06: przeniesione do C++*/
/*funkcje uzalezniajace sile pociagowa od predkosci: v2n, n2r, current, momentum*/ /*funkcje uzalezniajace sile pociagowa od predkosci: v2n, n2r, current, momentum*/
double v2n(void); double v2n(void);
double current(double n, double U); double Current(double n, double U);
double Momentum(double I); double Momentum(double I);
double MomentumF(double I, double Iw, int SCP); double MomentumF(double I, double Iw, int SCP);

View File

@@ -76,7 +76,7 @@ int DirF(int CouplerN)
// Q: 20160716 // Q: 20160716
// Obliczanie natężenie prądu w silnikach // Obliczanie natężenie prądu w silnikach
// ************************************************************************************************* // *************************************************************************************************
double TMoverParameters::current(double n, double U) double TMoverParameters::Current(double n, double U)
{ {
// wazna funkcja - liczy prad plynacy przez silniki polaczone szeregowo lub rownolegle // wazna funkcja - liczy prad plynacy przez silniki polaczone szeregowo lub rownolegle
// w zaleznosci od polozenia nastawnikow MainCtrl i ScndCtrl oraz predkosci obrotowej n // w zaleznosci od polozenia nastawnikow MainCtrl i ScndCtrl oraz predkosci obrotowej n
@@ -338,9 +338,9 @@ Name( NameInit )
Couplers[b].FmaxC = 1000.0; Couplers[b].FmaxC = 1000.0;
} }
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
for( int b = 0; b < 2; ++b ) { for( int side = 0; side < 2; ++side ) {
HVCouplers[ b ][ 0 ] = 0.0; HVCouplers[ side ][ hvcoupler::current ] = 0.0;
HVCouplers[ b ][ 1 ] = 0.0; HVCouplers[ side ][ hvcoupler::voltage ] = 0.0;
} }
#endif #endif
for( int b = 0; b < 3; ++b ) { for( int b = 0; b < 3; ++b ) {
@@ -706,15 +706,22 @@ bool TMoverParameters::CurrentSwitch(int direction)
}; };
void TMoverParameters::UpdatePantVolume(double dt) void TMoverParameters::UpdatePantVolume(double dt)
{ // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze { // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze nie tak
// nie tak
// check the pantograph compressor while at it
if( PantCompFlag ) {
if( ( false == Battery )
&& ( false == ConverterFlag ) ) {
PantCompFlag = false;
}
}
if (EnginePowerSource.SourceType == CurrentCollector) // tylko jeśli pantografujący if (EnginePowerSource.SourceType == CurrentCollector) // tylko jeśli pantografujący
{ {
// Ra 2014-07: zasadniczo, to istnieje zbiornik rozrządu i zbiornik pantografów - na razie mamy razem // Ra 2014-07: zasadniczo, to istnieje zbiornik rozrządu i zbiornik pantografów - na razie mamy razem
// Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym WS // Ra 2014-07: kurek trójdrogowy łączy spr.pom. z pantografami i wyłącznikiem ciśnieniowym WS
// Ra 2014-07: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć // Ra 2014-07: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć
// WS i odpalić resztę // WS i odpalić resztę
// NOTE: custom variant for EMU disabled because it pretty much doesn't work
if ((TrainType == dt_EZT) ? (PantPress < ScndPipePress) : if ((TrainType == dt_EZT) ? (PantPress < ScndPipePress) :
bPantKurek3) // kurek zamyka połączenie z ZG bPantKurek3) // kurek zamyka połączenie z ZG
{ // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie napompuje { // zbiornik pantografu połączony ze zbiornikiem głównym - małą sprężarką się tego nie napompuje
@@ -727,16 +734,19 @@ void TMoverParameters::UpdatePantVolume(double dt)
} }
else else
{ // zbiornik główny odcięty, można pompować pantografy { // zbiornik główny odcięty, można pompować pantografy
if (PantCompFlag && Battery) // włączona bateria i mała sprężarka if( PantCompFlag ) {
PantVolume += dt * (TrainType == dt_EZT ? 0.003 : 0.005) * // włączona mała sprężarka
(2.0 * 0.45 - ((0.1 / PantVolume / 10) - 0.1)) / PantVolume +=
0.45; // napełnianie zbiornika pantografów dt
// Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005 // Ra 2013-12: Niebugocław mówi, że w EZT nabija 1.5 raz wolniej niż jak było 0.005
* ( TrainType == dt_EZT ? 0.003 : 0.005 ) / std::max( 1.0, PantPress )
* ( 0.45 - ( ( 0.1 / PantVolume / 10 ) - 0.1 ) ) / 0.45;
}
PantPress = std::min( (10.0 * PantVolume) - 1.0, EnginePowerSource.CollectorParameters.MaxPress ); // tu by się przydała objętość zbiornika PantPress = std::min( (10.0 * PantVolume) - 1.0, EnginePowerSource.CollectorParameters.MaxPress ); // tu by się przydała objętość zbiornika
PantPress = std::max( PantPress, 0.0 ); PantPress = std::max( PantPress, 0.0 );
} }
if (!PantCompFlag && (PantVolume > 0.1)) if( !PantCompFlag && ( PantVolume > 0.1 ) )
PantVolume -= dt * 0.0003; // nieszczelności: 0.0003=0.3l/s PantVolume -= dt * 0.0003 * std::max( 1.0, PantPress * 0.5 ); // nieszczelności: 0.0003=0.3l/s
/* /*
// NOTE: disabled as this is redundant with check done in dynobj.update() // NOTE: disabled as this is redundant with check done in dynobj.update()
// TODO: determine if this isn't a mistake -- // TODO: determine if this isn't a mistake --
@@ -1100,31 +1110,31 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
|| ( ( Heating ) || ( ( Heating )
&& ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) { && ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) {
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
HVCouplers[ oppositeside ][ hvcoupler::outgoing ] = HVCouplers[ oppositeside ][ hvcoupler::voltage ] =
std::max( std::max(
std::abs( hvc ), std::abs( hvc ),
Couplers[ side ].Connected->HVCouplers[ Couplers[ side ].ConnectedNr ][ hvcoupler::outgoing ] - HVCouplers[ side ][ hvcoupler::incoming ] * 0.02 ); Couplers[ side ].Connected->HVCouplers[ Couplers[ side ].ConnectedNr ][ hvcoupler::voltage ] - HVCouplers[ side ][ hvcoupler::current ] * 0.02 );
#else #else
auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ]; auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ];
Couplers[ oppositeside ].power_high.outgoing = Couplers[ oppositeside ].power_high.voltage =
std::max( std::max(
std::abs( hvc ), std::abs( hvc ),
connectedcoupler.power_high.outgoing - Couplers[ side ].power_high.incoming * 0.02 ); connectedcoupler.power_high.voltage - Couplers[ side ].power_high.current * 0.02 );
#endif #endif
} }
else { else {
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
HVCouplers[ oppositeside ][ hvcoupler::outgoing ] = abs( hvc ) - HVCouplers[ side ][ hvcoupler::incoming ] * 0.02; HVCouplers[ oppositeside ][ hvcoupler::voltage ] = std::abs( hvc ) - HVCouplers[ side ][ hvcoupler::current ] * 0.02;
#else #else
Couplers[ oppositeside ].power_high.outgoing = std::abs( hvc ) - Couplers[ side ].power_high.incoming * 0.02; Couplers[ oppositeside ].power_high.voltage = std::abs( hvc ) - Couplers[ side ].power_high.current * 0.02;
#endif #endif
} }
} }
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
hvc = HVCouplers[ side::front ][ hvcoupler::outgoing ] + HVCouplers[ side::rear ][ hvcoupler::outgoing ]; hvc = HVCouplers[ side::front ][ hvcoupler::voltage ] + HVCouplers[ side::rear ][ hvcoupler::voltage ];
#else #else
hvc = Couplers[ side::front ].power_high.outgoing + Couplers[ side::rear ].power_high.outgoing; hvc = Couplers[ side::front ].power_high.voltage + Couplers[ side::rear ].power_high.voltage;
#endif #endif
if( ( std::abs( PantFrontVolt ) + std::abs( PantRearVolt ) < 1.0 ) if( ( std::abs( PantFrontVolt ) + std::abs( PantRearVolt ) < 1.0 )
@@ -1133,26 +1143,33 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
// przekazywanie pradow // przekazywanie pradow
for( int side = 0; side < 2; ++side ) { for( int side = 0; side < 2; ++side ) {
Couplers[ side ].power_high.local = false; // power, if any, will be from external source
if( ( Couplers[ side ].CouplingFlag & ctrain_power ) if( ( Couplers[ side ].CouplingFlag & ctrain_power )
|| ( ( Heating ) || ( ( Heating )
&& ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) { && ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) {
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
HVCouplers[ side ][ hvcoupler::incoming ] = auto const oppositeside = ( Couplers[side].ConnectedNr == side::front ? side::rear : side::front );
Couplers[side].Connected->HVCouplers[Couplers[side].ConnectedNr][hvcoupler::outgoing] + HVCouplers[ side ][ hvcoupler::current ] =
Itot * HVCouplers[side][hvcoupler::outgoing] / hvc; // obciążenie rozkladane stosownie do napiec Couplers[side].Connected->HVCouplers[oppositeside][hvcoupler::current] +
Itot * HVCouplers[side][hvcoupler::voltage] / hvc; // obciążenie rozkladane stosownie do napiec
#else #else
auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ]; auto const &connectedsothercoupler =
Couplers[ side ].power_high.incoming = Couplers[ side ].Connected->Couplers[
connectedcoupler.power_high.outgoing ( Couplers[ side ].ConnectedNr == side::front ?
+ Itot * Couplers[ side ].power_high.outgoing / hvc; // obciążenie rozkladane stosownie do napiec side::rear :
side::front ) ];
Couplers[ side ].power_high.current =
connectedsothercoupler.power_high.current
+ Itot * Couplers[ side ].power_high.voltage / hvc; // obciążenie rozkladane stosownie do napiec
#endif #endif
} }
else { else {
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
// pierwszy pojazd // pierwszy pojazd
HVCouplers[side][hvcoupler::incoming] = Itot * HVCouplers[side][hvcoupler::outgoing] / hvc; HVCouplers[side][hvcoupler::current] = Itot * HVCouplers[side][hvcoupler::voltage] / hvc;
#else #else
Couplers[ side ].power_high.incoming = Itot * Couplers[ side ].power_high.outgoing / hvc; Couplers[ side ].power_high.current = Itot * Couplers[ side ].power_high.voltage / hvc;
#endif #endif
} }
} }
@@ -1160,16 +1177,24 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
else else
{ {
for( int side = 0; side < 2; ++side ) { for( int side = 0; side < 2; ++side ) {
Couplers[ side ].power_high.local = true; // power is coming from local pantographs
if( ( Couplers[ side ].CouplingFlag & ctrain_power ) if( ( Couplers[ side ].CouplingFlag & ctrain_power )
|| ( ( Heating ) || ( ( Heating )
&& ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) { && ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) {
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
TotalCurrent += Couplers[ side ].Connected->HVCouplers[ Couplers[ side ].ConnectedNr ][ hvcoupler::incoming ]; auto const oppositeside = ( Couplers[ side ].ConnectedNr == side::front ? side::rear : side::front );
HVCouplers[ side ][ hvcoupler::incoming ] = 0.0; TotalCurrent += Couplers[ side ].Connected->HVCouplers[ oppositeside ][ hvcoupler::current ];
HVCouplers[ side ][ hvcoupler::current ] = 0.0;
#else #else
auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ]; auto const &connectedsothercoupler =
TotalCurrent += connectedcoupler.power_high.incoming; Couplers[ side ].Connected->Couplers[
Couplers[ side ].power_high.incoming = 0.0; ( Couplers[ side ].ConnectedNr == side::front ?
side::rear :
side::front ) ];
TotalCurrent += connectedsothercoupler.power_high.current;
Couplers[ side ].power_high.current = 0.0;
#endif #endif
} }
} }
@@ -1528,8 +1553,7 @@ void TMoverParameters::ConverterCheck()
{ // sprawdzanie przetwornicy { // sprawdzanie przetwornicy
if( ( ConverterAllow ) if( ( ConverterAllow )
&& ( false == PantPressLockActive ) && ( false == PantPressLockActive )
&& ( ( Mains ) && ( Mains ) ) {
|| ( GetTrainsetVoltage() > 0.5 * EnginePowerSource.MaxVoltage ) ) ) {
ConverterFlag = true; ConverterFlag = true;
} }
else { else {
@@ -2032,23 +2056,43 @@ bool TMoverParameters::AddPulseForce(int Multipler)
// Q: 20160713 // Q: 20160713
// sypanie piasku // sypanie piasku
// ************************************************************************************************* // *************************************************************************************************
bool TMoverParameters::SandDoseOn(void) bool TMoverParameters::Sandbox( bool const State, int const Notify )
{ {
bool SDO; bool result{ false };
if (SandCapacity > 0)
{
SDO = true;
if (SandDose)
SandDose = false;
else if (Sand > 0)
SandDose = true;
if (CabNo != 0)
SendCtrlToNext("SandDoseOn", 1, CabNo);
}
else
SDO = false;
return SDO; if( SandDose != State ) {
if( SandDose == false ) {
// switch on
if( Sand > 0 ) {
SandDose = true;
result = true;
}
}
else {
// switch off
SandDose = false;
result = true;
}
}
if( Notify != command_range::local ) {
// if requested pass the command on
auto const couplingtype =
( Notify == command_range::unit ?
ctrain_controll | ctrain_depot :
ctrain_controll );
if( State == true ) {
// switch on
SendCtrlToNext( "Sandbox", 1, CabNo, couplingtype );
}
else {
// switch off
SendCtrlToNext( "Sandbox", 0, CabNo, couplingtype );
}
}
return result;
} }
void TMoverParameters::SSReset(void) void TMoverParameters::SSReset(void)
@@ -2271,7 +2315,8 @@ bool TMoverParameters::DirectionBackward(void)
// ************************************************************************************************* // *************************************************************************************************
bool TMoverParameters::AntiSlippingButton(void) bool TMoverParameters::AntiSlippingButton(void)
{ {
return (AntiSlippingBrake() || SandDoseOn()); // NOTE: disabled the sandbox part, it's already controlled by another part of the AI routine
return (AntiSlippingBrake() /*|| Sandbox(true)*/);
} }
// ************************************************************************************************* // *************************************************************************************************
@@ -2865,7 +2910,7 @@ bool TMoverParameters::BrakeDelaySwitch(int BDS)
{ {
BrakeDelayFlag = BDS; BrakeDelayFlag = BDS;
rBDS = true; rBDS = true;
BrakeStatus &= 191; Hamulec->SetBrakeStatus( Hamulec->GetBrakeStatus() & ~64 );
// kopowanie nastawy hamulca do kolejnego czlonu - do przemyślenia // kopowanie nastawy hamulca do kolejnego czlonu - do przemyślenia
if (CabNo != 0) if (CabNo != 0)
SendCtrlToNext("BrakeDelay", BrakeDelayFlag, CabNo); SendCtrlToNext("BrakeDelay", BrakeDelayFlag, CabNo);
@@ -3108,12 +3153,17 @@ void TMoverParameters::UpdatePipePressure(double dt)
else else
dpLocalValve = dpLocalValve =
LocHandle->GetPF(LocalBrakePosA, Hamulec->GetBCP(), ScndPipePress, dt, 0); LocHandle->GetPF(LocalBrakePosA, Hamulec->GetBCP(), ScndPipePress, dt, 0);
if ((BrakeHandle == FV4a) &&
((PipePress < 2.75) && ((Hamulec->GetStatus() & b_rls) == 0)) && if( ( BrakeHandle == FV4a )
(BrakeSubsystem == ss_LSt) && (TrainType != dt_EZT)) && ( ( PipePress < 2.75 )
&& ( ( Hamulec->GetStatus() & b_rls ) == 0 ) )
&& ( BrakeSubsystem == ss_LSt )
&& ( TrainType != dt_EZT ) ) {
temp = PipePress + 0.00001; temp = PipePress + 0.00001;
else }
else {
temp = ScndPipePress; temp = ScndPipePress;
}
Handle->SetReductor(BrakeCtrlPos2); Handle->SetReductor(BrakeCtrlPos2);
if ((BrakeOpModeFlag != bom_PS)) if ((BrakeOpModeFlag != bom_PS))
@@ -3255,20 +3305,21 @@ void TMoverParameters::UpdatePipePressure(double dt)
if ((BrakeHandle == FVel6) && (ActiveCab != 0)) if ((BrakeHandle == FVel6) && (ActiveCab != 0))
{ {
if ((Battery) && (ActiveDir != 0) && if ((Battery)
(EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie - && (ActiveDir != 0)
&& (EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie -
// temp = (Handle as TFVel6).GetCP // temp = (Handle as TFVel6).GetCP
temp = Handle->GetCP(); temp = Handle->GetCP();
else else
temp = 0.0; temp = 0.0;
Hamulec->SetEPS(temp); Hamulec->SetEPS(temp);
SendCtrlToNext("Brake", temp, // Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach
CabNo); // Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach SendCtrlToNext("Brake", temp, CabNo);
} }
Pipe->Act(); Pipe->Act();
PipePress = Pipe->P(); PipePress = Pipe->P();
if ((BrakeStatus & 128) == 128) // jesli hamulec wyłączony if( ( Hamulec->GetBrakeStatus() & b_dmg ) == b_dmg ) // jesli hamulec wyłączony
temp = 0.0; // odetnij temp = 0.0; // odetnij
else else
temp = 1.0; // połącz temp = 1.0; // połącz
@@ -3524,8 +3575,7 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
LastSwitchingTime += dt1; LastSwitchingTime += dt1;
if (EngineType == ElectricSeriesMotor) if (EngineType == ElectricSeriesMotor)
LastRelayTime += dt1; LastRelayTime += dt1;
if( Mains && /*(abs(CabNo) < 2) &&*/ ( EngineType == if( Mains && /*(abs(CabNo) < 2) &&*/ ( EngineType == ElectricSeriesMotor ) ) // potem ulepszyc! pantogtrafy!
ElectricSeriesMotor ) ) // potem ulepszyc! pantogtrafy!
{ // Ra 2014-03: uwzględnienie kierunku jazdy w napięciu na silnikach, a powinien być { // Ra 2014-03: uwzględnienie kierunku jazdy w napięciu na silnikach, a powinien być
// zdefiniowany nawrotnik // zdefiniowany nawrotnik
if( CabNo == 0 ) if( CabNo == 0 )
@@ -3533,20 +3583,22 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
else else
Voltage = RunningTraction.TractionVoltage * DirAbsolute; // ActiveDir*CabNo; Voltage = RunningTraction.TractionVoltage * DirAbsolute; // ActiveDir*CabNo;
} // bo nie dzialalo } // bo nie dzialalo
else if( ( EngineType == ElectricInductionMotor ) || else if( ( EngineType == ElectricInductionMotor )
( ( ( Couplers[ 0 ].CouplingFlag & ctrain_power ) == ctrain_power ) || || ( ( ( Couplers[ side::front ].CouplingFlag & ctrain_power ) == ctrain_power )
( ( Couplers[ 1 ].CouplingFlag & ctrain_power ) == || ( ( Couplers[ side::rear ].CouplingFlag & ctrain_power ) == ctrain_power ) ) ) {
ctrain_power ) ) ) // potem ulepszyc! pantogtrafy! // potem ulepszyc! pantogtrafy!
Voltage = Voltage =
std::max( std::max(
RunningTraction.TractionVoltage, RunningTraction.TractionVoltage,
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
std::max( HVCouplers[side::front][hvcoupler::incoming], HVCouplers[side::rear][hvcoupler::incoming] ) ); std::max( HVCouplers[side::front][hvcoupler::voltage], HVCouplers[side::rear][hvcoupler::voltage] ) );
#else #else
std::max( Couplers[ side::front ].power_high.incoming, Couplers[ side::rear ].power_high.incoming ) ); std::max( Couplers[ side::front ].power_high.voltage, Couplers[ side::rear ].power_high.voltage ) );
#endif #endif
else }
else {
Voltage = 0; Voltage = 0;
}
//if (Mains && /*(abs(CabNo) < 2) &&*/ ( //if (Mains && /*(abs(CabNo) < 2) &&*/ (
// EngineType == ElectricInductionMotor)) // potem ulepszyc! pantogtrafy! // EngineType == ElectricInductionMotor)) // potem ulepszyc! pantogtrafy!
// Voltage = RunningTraction.TractionVoltage; // Voltage = RunningTraction.TractionVoltage;
@@ -4059,7 +4111,7 @@ double TMoverParameters::TractionForce(double dt)
// yB: szereg dwoch sekcji w ET42 // yB: szereg dwoch sekcji w ET42
if ((TrainType == dt_ET42) && (Imax == ImaxHi)) if ((TrainType == dt_ET42) && (Imax == ImaxHi))
Voltage = Voltage / 2.0; Voltage = Voltage / 2.0;
Mm = Momentum(current(enrot, Voltage)); // oblicza tez prad p/slinik Mm = Momentum(Current(enrot, Voltage)); // oblicza tez prad p/slinik
if (TrainType == dt_ET42) if (TrainType == dt_ET42)
{ {
@@ -4253,73 +4305,85 @@ double TMoverParameters::TractionForce(double dt)
case 0: { case 0: {
if( ( Im <= ( MPTRelay[ ScndCtrlPos ].Iup * PosRatio ) ) && if( ( ScndCtrlPos < ScndCtrlPosNo )
( ScndCtrlPos < ScndCtrlPosNo ) ) && ( Im <= ( MPTRelay[ ScndCtrlPos ].Iup * PosRatio ) ) ) {
++ScndCtrlPos; ++ScndCtrlPos;
if( ( Im >= ( MPTRelay[ ScndCtrlPos ].Idown * PosRatio ) ) && ( ScndCtrlPos > 0 ) ) }
--ScndCtrlPos; if( ( ScndCtrlPos > 0 )
break; && ( Im >= ( MPTRelay[ScndCtrlPos].Idown * PosRatio ) ) ) {
} --ScndCtrlPos;
}
break;
}
case 1: { case 1: {
if( ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) && ( ScndCtrlPos < ScndCtrlPosNo ) ) if( ( ScndCtrlPos < ScndCtrlPosNo )
++ScndCtrlPos; && ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) ) {
if( ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) && ( ScndCtrlPos > 0 ) ) ++ScndCtrlPos;
--ScndCtrlPos; }
break; if( ( ScndCtrlPos > 0 )
} && ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) {
--ScndCtrlPos;
}
break;
}
case 2: { case 2: {
if( ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) && ( ScndCtrlPos < ScndCtrlPosNo ) && if( ( ScndCtrlPos < ScndCtrlPosNo )
( EnginePower < ( tmp * 0.99 ) ) ) && ( MPTRelay[ ScndCtrlPos ].Iup < Vel )
++ScndCtrlPos; && ( EnginePower < ( tmp * 0.99 ) ) ) {
if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) && ( ScndCtrlPos > 0 ) ) ++ScndCtrlPos;
--ScndCtrlPos;
break;
}
case 41:
{
if( ( MainCtrlPos == MainCtrlPosNo )
&& ( tmpV * 3.6 > MPTRelay[ ScndCtrlPos ].Iup )
&& ( ScndCtrlPos < ScndCtrlPosNo ) ) {
++ScndCtrlPos;
enrot = enrot * 0.73;
}
if( ( Im > MPTRelay[ ScndCtrlPos ].Idown )
&& ( ScndCtrlPos > 0 ) ) {
--ScndCtrlPos;
} }
break; if( ( ScndCtrlPos > 0 )
} && ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) {
case 45: --ScndCtrlPos;
{ }
if( ( MainCtrlPos >= 10 ) && ( ScndCtrlPos < ScndCtrlPosNo ) ) { break;
}
case 41:
{
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( MainCtrlPos == MainCtrlPosNo )
&& ( tmpV * 3.6 > MPTRelay[ ScndCtrlPos ].Iup ) ) {
++ScndCtrlPos;
enrot = enrot * 0.73;
}
if( ( ScndCtrlPos > 0 )
&& ( Im > MPTRelay[ ScndCtrlPos ].Idown ) ) {
--ScndCtrlPos;
}
break;
}
case 45:
{
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( MainCtrlPos >= 10 ) ) {
if( ScndCtrlPos == 0 ) { if( ScndCtrlPos == 0 ) {
if( Im < MPTRelay[ ScndCtrlPos ].Iup ) { if( Im < MPTRelay[ ScndCtrlPos ].Iup ) {
++ScndCtrlPos; ++ScndCtrlPos;
} }
} }
else { else {
if( Vel > MPTRelay[ ScndCtrlPos ].Iup ) { if( Vel > MPTRelay[ ScndCtrlPos ].Iup ) {
++ScndCtrlPos; ++ScndCtrlPos;
} }
// check for cases where the speed drops below threshold for level 2 or 3 // check for cases where the speed drops below threshold for level 2 or 3
if( ( ScndCtrlPos > 1 ) if( ( ScndCtrlPos > 1 )
&& ( Vel < MPTRelay[ ScndCtrlPos - 1 ].Idown ) ){ && ( Vel < MPTRelay[ ScndCtrlPos - 1 ].Idown ) ) {
--ScndCtrlPos; --ScndCtrlPos;
} }
} }
} }
// malenie // malenie
if( ( ScndCtrlPos > 0 ) && ( MainCtrlPos < 10 ) ) { if( ( ScndCtrlPos > 0 ) && ( MainCtrlPos < 10 ) ) {
if( ScndCtrlPos == 1 ) { if( ScndCtrlPos == 1 ) {
if( Im > MPTRelay[ ScndCtrlPos - 1 ].Idown ) { if( Im > MPTRelay[ ScndCtrlPos - 1 ].Idown ) {
--ScndCtrlPos; --ScndCtrlPos;
} }
} }
else { else {
if( Vel < MPTRelay[ ScndCtrlPos ].Idown ) { if( Vel < MPTRelay[ ScndCtrlPos ].Idown ) {
--ScndCtrlPos; --ScndCtrlPos;
} }
} }
} }
@@ -4329,13 +4393,13 @@ double TMoverParameters::TractionForce(double dt)
} }
// ...and below position 7 field shunt drops altogether // ...and below position 7 field shunt drops altogether
if( MainCtrlPos < 7 ) { if( MainCtrlPos < 7 ) {
ScndCtrlPos = 0; ScndCtrlPos = 0;
} }
break; break;
} }
case 46: case 46:
{ {
// wzrastanie // wzrastanie
if( ( MainCtrlPos >= 10 ) if( ( MainCtrlPos >= 10 )
&& ( ScndCtrlPos < ScndCtrlPosNo ) ) { && ( ScndCtrlPos < ScndCtrlPosNo ) ) {
if( ( ScndCtrlPos ) % 2 == 0 ) { if( ( ScndCtrlPos ) % 2 == 0 ) {
@@ -4350,18 +4414,18 @@ double TMoverParameters::TractionForce(double dt)
} }
} }
} }
// malenie // malenie
if( ( MainCtrlPos < 10 ) if( ( MainCtrlPos < 10 )
&& ( ScndCtrlPos > 0 ) ) { && ( ScndCtrlPos > 0 ) ) {
if( ( ScndCtrlPos ) % 2 == 0 ) { if( ( ScndCtrlPos ) % 2 == 0 ) {
if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) { if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) {
--ScndCtrlPos; --ScndCtrlPos;
} }
} }
else { else {
if( ( MPTRelay[ ScndCtrlPos + 1 ].Idown < Im ) if( ( MPTRelay[ ScndCtrlPos + 1 ].Idown < Im )
&& ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) { && ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) {
--ScndCtrlPos; --ScndCtrlPos;
} }
} }
} }
@@ -4369,14 +4433,14 @@ double TMoverParameters::TractionForce(double dt)
ScndCtrlPos = std::min( 2, ScndCtrlPos ); ScndCtrlPos = std::min( 2, ScndCtrlPos );
} }
if( MainCtrlPos < 7 ) { if( MainCtrlPos < 7 ) {
ScndCtrlPos = 0; ScndCtrlPos = 0;
} }
break; break;
} }
default: { default: {
break; break;
} }
} // switch RelayType } // switch RelayType
} }
} }
break; break;
@@ -4455,26 +4519,28 @@ double TMoverParameters::TractionForce(double dt)
dmoment = eimv[eimv_Fful]; dmoment = eimv[eimv_Fful];
// else // else
// dmoment:=eimc[eimc_p_F0]*0.99; // dmoment:=eimc[eimc_p_F0]*0.99;
// NOTE: the commands to operate the sandbox are likely to conflict with other similar ai decisions
// TODO: gather these in single place so they can be resolved together
if ((abs((PosRatio + 9.66 * dizel_fill) * dmoment * 100) > if ((abs((PosRatio + 9.66 * dizel_fill) * dmoment * 100) >
0.95 * Adhesive(RunningTrack.friction) * TotalMassxg)) 0.95 * Adhesive(RunningTrack.friction) * TotalMassxg))
{ {
PosRatio = 0; PosRatio = 0;
tmp = 4; tmp = 4;
SandDoseOn(); Sandbox( true, command_range::local );
} // przeciwposlizg } // przeciwposlizg
if ((abs((PosRatio + 9.80 * dizel_fill) * dmoment * 100) > if ((abs((PosRatio + 9.80 * dizel_fill) * dmoment * 100) >
0.95 * Adhesive(RunningTrack.friction) * TotalMassxg)) 0.95 * Adhesive(RunningTrack.friction) * TotalMassxg))
{ {
PosRatio = 0; PosRatio = 0;
tmp = 9; tmp = 9;
SandDoseOn(); Sandbox( true, command_range::local );
} // przeciwposlizg } // przeciwposlizg
if ((SlippingWheels)) if ((SlippingWheels))
{ {
// PosRatio = -PosRatio * 0; // serio -0 ??? // PosRatio = -PosRatio * 0; // serio -0 ???
PosRatio = 0; PosRatio = 0;
tmp = 9; tmp = 9;
SandDoseOn(); Sandbox( true, command_range::local );
} // przeciwposlizg } // przeciwposlizg
dizel_fill += Max0R(Min0R(PosRatio - dizel_fill, 0.1), -0.1) * 2 * dizel_fill += Max0R(Min0R(PosRatio - dizel_fill, 0.1), -0.1) * 2 *
@@ -5682,28 +5748,28 @@ std::string TMoverParameters::EngineDescription(int what)
// ************************************************************************************************* // *************************************************************************************************
double TMoverParameters::GetTrainsetVoltage(void) double TMoverParameters::GetTrainsetVoltage(void)
{//ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT {//ABu: funkcja zwracajaca napiecie dla calego skladu, przydatna dla EZT
/*
return std::min(
std::max( HVCouplers[ 1 ][ 1 ], HVCouplers[ 0 ][ 1 ] ), // local
std::max( HVCouplers[ 1 ][ 0 ], HVCouplers[ 0 ][ 0 ] ) ); // remote
*/
// TODO: investigate what exactly is reported on these couplers, does it include heating?
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
// TODO: if we ever revert to this version, match the expanded alternative below return std::max(
return std::max( HVCouplers[ 1 ][ 0 ], HVCouplers[ 0 ][ 0 ] ); // incoming, external power HVCouplers[ side::front ][ hvcoupler::voltage ],
HVCouplers[ side::rear ][ hvcoupler::voltage ] );
#else #else
/*
return std::max(
Couplers[ side::front ].power_high.voltage,
Couplers[ side::rear ].power_high.voltage );
*/
return std::max( return std::max(
( ( ( Couplers[side::front].Connected ) ( ( ( Couplers[side::front].Connected )
&& ( ( Couplers[ side::front ].CouplingFlag & ctrain_power ) && ( ( Couplers[ side::front ].CouplingFlag & ctrain_power )
|| ( ( Heating ) || ( ( Heating )
&& ( Couplers[ side::front ].CouplingFlag & ctrain_heating ) ) ) ) ? && ( Couplers[ side::front ].CouplingFlag & ctrain_heating ) ) ) ) ?
Couplers[side::front].Connected->Couplers[ Couplers[side::front].ConnectedNr ].power_high.outgoing : Couplers[side::front].Connected->Couplers[ Couplers[side::front].ConnectedNr ].power_high.voltage :
0.0 ), 0.0 ),
( ( ( Couplers[side::rear].Connected ) ( ( ( Couplers[side::rear].Connected )
&& ( ( Couplers[ side::rear ].CouplingFlag & ctrain_power ) && ( ( Couplers[ side::rear ].CouplingFlag & ctrain_power )
|| ( ( Heating ) || ( ( Heating )
&& ( Couplers[ side::rear ].CouplingFlag & ctrain_heating ) ) ) ) ? && ( Couplers[ side::rear ].CouplingFlag & ctrain_heating ) ) ) ) ?
Couplers[ side::rear ].Connected->Couplers[ Couplers[ side::rear ].ConnectedNr ].power_high.outgoing : Couplers[ side::rear ].Connected->Couplers[ Couplers[ side::rear ].ConnectedNr ].power_high.voltage :
0.0 ) ); 0.0 ) );
#endif #endif
} }
@@ -8059,15 +8125,18 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
} }
else if (Command == "BrakeDelay") else if (Command == "BrakeDelay")
{ {
BrakeDelayFlag = static_cast<int>(floor(CValue1)); auto const brakesetting = static_cast<int>( std::floor( CValue1 ) );
OK = true; if( true == Hamulec->SetBDF( brakesetting ) ) {
BrakeDelayFlag = brakesetting;
OK = true;
}
else {
OK = false;
}
} }
else if (Command == "SandDoseOn") else if (Command == "Sandbox")
{ {
if (SandDoseOn()) OK = Sandbox( CValue1 == 1, command_range::local );
OK = true;
else
OK = false;
} }
else if (Command == "CabSignal") /*SHP,Indusi*/ else if (Command == "CabSignal") /*SHP,Indusi*/
{ // Ra: to powinno działać tylko w członie obsadzonym { // Ra: to powinno działać tylko w członie obsadzonym

View File

@@ -16,6 +16,7 @@ Copyright (C) 2007-2014 Maciej Cierniak
#include "hamulce.h" #include "hamulce.h"
#include <typeinfo> #include <typeinfo>
#include "Mover.h" #include "Mover.h"
#include "usefull.h"
//---FUNKCJE OGOLNE--- //---FUNKCJE OGOLNE---
@@ -51,10 +52,10 @@ double PF_old(double P1, double P2, double S)
double PF( double const P1, double const P2, double const S, double const DP ) double PF( double const P1, double const P2, double const S, double const DP )
{ {
double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne
double sg = PL / PH; // bezwymiarowy stosunek cisnien double const sg = PL / PH; // bezwymiarowy stosunek cisnien
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
if (sg > 0.5) // jesli ponizej stosunku krytycznego if (sg > 0.5) // jesli ponizej stosunku krytycznego
if ((PH - PL) < DP) // niewielka roznica cisnien if ((PH - PL) < DP) // niewielka roznica cisnien
return (1.0 - sg) / DPL * FM * 2.0 * std::sqrt((DP) * (PH - DP)); return (1.0 - sg) / DPL * FM * 2.0 * std::sqrt((DP) * (PH - DP));
@@ -69,15 +70,15 @@ double PF1( double const P1, double const P2, double const S )
{ {
static double const DPS = 0.001; static double const DPS = 0.001;
double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne
double sg = PL / PH; // bezwymiarowy stosunek cisnien double const sg = PL / PH; // bezwymiarowy stosunek cisnien
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem double const FM = PH * 197.0 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego if (sg > 0.5) // jesli ponizej stosunku krytycznego
if ((sg < DPS)) // niewielka roznica cisnien if (sg < DPS) // niewielka roznica cisnien
return (1 - sg) / DPS * FM * 2 * std::sqrt((DPS) * (1 - DPS)); return (1.0 - sg) / DPS * FM * 2.0 * std::sqrt((DPS) * (1.0 - DPS));
else else
return FM * 2 * std::sqrt((sg) * (1 - sg)); return FM * 2.0 * std::sqrt((sg) * (1.0 - sg));
else // powyzej stosunku krytycznego else // powyzej stosunku krytycznego
return FM; return FM;
} }
@@ -1184,50 +1185,50 @@ void TESt3AL2::Init( double const PP, double const HPP, double const LPP, double
double TLSt::GetPF( double const PP, double const dt, double const Vel ) double TLSt::GetPF( double const PP, double const dt, double const Vel )
{ {
double result; double result;
double dv;
double dV1;
double temp;
double VVP;
double BVP;
double BCP;
double CVP;
// ValveRes.CreatePress(LBP); // ValveRes.CreatePress(LBP);
// LBP:=0; // LBP:=0;
BVP = BrakeRes->P(); double const BVP{ BrakeRes->P() };
VVP = ValveRes->P(); double const VVP{ ValveRes->P() };
BCP = ImplsRes->P(); double const BCP{ ImplsRes->P() };
CVP = CntrlRes->P(); double const CVP{ CntrlRes->P() };
dv = 0; double dV{ 0.0 };
dV1 = 0; double dV1{ 0.0 };
// sprawdzanie stanu // sprawdzanie stanu
if ((BrakeStatus & b_rls) == b_rls) if( ( BrakeStatus & b_rls ) == b_rls ) {
if ((CVP < 0)) if( CVP < 0.0 ) {
BrakeStatus &= ~b_rls; BrakeStatus &= ~b_rls;
}
else else
{ // 008 { // 008
dv = PF1(CVP, BCP, 0.024) * dt; dV = PF1( CVP, BCP, 0.024 ) * dt;
CntrlRes->Flow(+dv); CntrlRes->Flow( dV );
// dV1:=+dV; //minus potem jest /*
// ImplsRes->Flow(-dV1); // NOTE: attempted fix, disabled because it breaks when releaser is used while releasing breakes
dV = PF1(CVP, VVP, 0.024) * dt;
CntrlRes->Flow( dV );
dV1 = dV; //minus potem jest
ImplsRes->Flow( -dV1 );
*/
} }
}
VVP = ValveRes->P(); double temp;
// przeplyw ZS <-> PG // przeplyw ZS <-> PG
if (((CVP - BCP) * BVM > 0.5)) if (((CVP - BCP) * BVM > 0.5))
temp = 0; temp = 0.0;
else if ((VVP > CVP + 0.4)) else if ((VVP > CVP + 0.4))
temp = 0.5; temp = 0.5;
else else
temp = 0.5; temp = 0.5;
dv = PF1(CVP, VVP, 0.0015 * temp / 1.8 / 2) * dt; dV = PF1(CVP, VVP, 0.0015 * temp / 1.8 / 2) * dt;
CntrlRes->Flow(+dv); CntrlRes->Flow(+dV);
ValveRes->Flow(-0.04 * dv); ValveRes->Flow(-0.04 * dV);
dV1 = dV1 - 0.96 * dv; dV1 = dV1 - 0.96 * dV;
// luzowanie KI {G} // luzowanie KI {G}
// if VVP>BCP then // if VVP>BCP then
@@ -1236,26 +1237,38 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel )
// dV:=PF(VVP,BCP,0.00020*(1.33-int((CVP-BCP)*BVM>0.65)))*dt // dV:=PF(VVP,BCP,0.00020*(1.33-int((CVP-BCP)*BVM>0.65)))*dt
// else dV:=0; 0.00025 P // else dV:=0; 0.00025 P
/*P*/ /*P*/
if (VVP > BCP) if( VVP > BCP ) {
dv = PF(VVP, BCP, dV =
0.00043 * (1.5 - int(((CVP - BCP) * BVM > 1) && (BrakeDelayFlag == bdelay_G))), PF( VVP, BCP,
0.1) * 0.00043 * ( 1.5 - (
dt; true == ( ( ( CVP - BCP ) * BVM > 1.0 )
else if ((CVP - BCP) < 1.5) && ( BrakeDelayFlag == bdelay_G ) ) ?
dv = PF(VVP, BCP, 1.0 :
0.001472 * (1.36 - int(((CVP - BCP) * BVM > 1) && (BrakeDelayFlag == bdelay_G))), 0.0 ) ),
0.1) * 0.1 )
dt; * dt;
else }
dv = 0; else if( ( CVP - BCP ) < 1.5 ) {
dV = PF( VVP, BCP,
0.001472 * ( 1.36 - (
true == ( ( ( CVP - BCP ) * BVM > 1.0 )
&& ( BrakeDelayFlag == bdelay_G ) ) ?
1.0 :
0.0 ) ),
0.1 )
* dt;
}
else {
dV = 0;
}
ImplsRes->Flow(-dv); ImplsRes->Flow(-dV);
ValveRes->Flow(+dv); ValveRes->Flow(+dV);
// przeplyw PG <-> rozdzielacz // przeplyw PG <-> rozdzielacz
dv = PF(PP, VVP, 0.01, 0.1) * dt; dV = PF(PP, VVP, 0.01, 0.1) * dt;
ValveRes->Flow(-dv); ValveRes->Flow(-dV);
result = dv - dV1; result = dV - dV1;
// if Vel>55 then temp:=0.72 else // if Vel>55 then temp:=0.72 else
// temp:=1;{R} // temp:=1;{R}
@@ -1272,18 +1285,18 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel )
if ((BrakeCyl->P() > temp + 0.005) || (temp < 0.28)) if ((BrakeCyl->P() > temp + 0.005) || (temp < 0.28))
// dV:=PF(0,BrakeCyl->P(),0.0015*3*sizeBC)*dt // dV:=PF(0,BrakeCyl->P(),0.0015*3*sizeBC)*dt
// dV:=PF(0,BrakeCyl->P(),0.005*3*sizeBC)*dt // dV:=PF(0,BrakeCyl->P(),0.005*3*sizeBC)*dt
dv = PFVd(BrakeCyl->P(), 0, 0.005 * 7 * SizeBC, temp) * dt; dV = PFVd(BrakeCyl->P(), 0, 0.005 * 7 * SizeBC, temp) * dt;
else else
dv = 0; dV = 0;
BrakeCyl->Flow(-dv); BrakeCyl->Flow(-dV);
// przeplyw ZP <-> CH // przeplyw ZP <-> CH
if ((BrakeCyl->P() < temp - 0.005) && (temp > 0.29)) if ((BrakeCyl->P() < temp - 0.005) && (temp > 0.29))
// dV:=PF(BVP,BrakeCyl->P(),0.002*3*sizeBC*2)*dt // dV:=PF(BVP,BrakeCyl->P(),0.002*3*sizeBC*2)*dt
dv = -PFVa(BVP, BrakeCyl->P(), 0.002 * 7 * SizeBC * 2, temp) * dt; dV = -PFVa(BVP, BrakeCyl->P(), 0.002 * 7 * SizeBC * 2, temp) * dt;
else else
dv = 0; dV = 0;
BrakeRes->Flow(dv); BrakeRes->Flow(dV);
BrakeCyl->Flow(-dv); BrakeCyl->Flow(-dV);
ImplsRes->Act(); ImplsRes->Act();
ValveRes->Act(); ValveRes->Act();
@@ -2198,124 +2211,145 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
static int const LBDelay = 100; static int const LBDelay = 100;
static double const xpM = 0.3; // mnoznik membrany komory pod static double const xpM = 0.3; // mnoznik membrany komory pod
double LimPP; ep = (PP / 2.0) * 1.5 + (ep / 2.0) * 0.5; // SPKS!!
double dpPipe;
double dpMainValve;
double ActFlowSpeed;
double DP;
double pom;
int i;
ep = PP / 2 * 1.5 + ep / 2 * 0.5; // SPKS!! for( int idx = 0; idx < 5; ++idx ) {
// ep:=pp; Sounds[ idx ] = 0;
// ep:=cp/3+pp/3+ep/3; }
// ep:=cp;
for (i = 0; i < 5; ++i) // na wszelki wypadek, zeby nie wyszlo poza zakres
Sounds[i] = 0; i_bcp = clamp( i_bcp, -1.999, 5.999 );
DP = 0;
i_bcp = Max0R(Min0R(i_bcp, 5.999), -1.999); // na wszelki wypadek, zeby nie wyszlo poza zakres double DP{ 0.0 };
if( TP > 0.0 ) {
if ((TP > 0)) // jesli czasowy jest niepusty
{ // jesli czasowy jest niepusty
// dp:=0.07; //od cisnienia 5 do 0 w 60 sekund ((5-0)*dt/75)
DP = 0.045; // 2.5 w 55 sekund (5,35->5,15 w PG) DP = 0.045; // 2.5 w 55 sekund (5,35->5,15 w PG)
TP = TP - DP * dt; TP -= DP * dt;
Sounds[s_fv4a_t] = DP; Sounds[s_fv4a_t] = DP;
} }
else //.08 else {
{ //.08
TP = 0; TP = 0.0;
} }
if ((XP > 0)) // jesli komora pod niepusta jest niepusty if (XP > 0) {
{ // jesli komora pod niepusta jest niepusty
DP = 2.5; DP = 2.5;
Sounds[s_fv4a_x] = DP * XP; Sounds[s_fv4a_x] = DP * XP;
XP = XP - dt * DP * 2; // od cisnienia 5 do 0 w 10 sekund ((5-0)*dt/10) XP -= dt * DP * 2.0; // od cisnienia 5 do 0 w 10 sekund ((5-0)*dt/10)
}
else {
// jak pusty, to pusty
XP = 0.0;
} }
else //.75
XP = 0; // jak pusty, to pusty
LimPP = Min0R(LPP_RP(i_bcp) + TP * 0.08 + RedAdj, HP); // pozycja + czasowy lub zasilanie double pom;
ActFlowSpeed = BPT[lround(i_bcp) + 2][0]; if( EQ( i_bcp, -1.0 ) ) {
pom = std::min( HP, 5.4 + RedAdj );
}
else {
pom = std::min( CP, HP );
}
if ((EQ(i_bcp, -1))) if( pom > RP + 0.25 ) {
pom = Min0R(HP, 5.4 + RedAdj);
else
pom = Min0R(CP, HP);
if ((pom > RP + 0.25))
Fala = true; Fala = true;
if ((Fala)) }
if ((pom > RP + 0.3)) if( Fala ) {
// if(ep>rp+0.11)then if( pom > RP + 0.3 ) {
XP = XP - 20 * PR(pom, XP) * dt; XP = XP - 20.0 * PR( pom, XP ) * dt;
// else }
// xp:=xp-16*(ep-(ep+0.01))/(0.1)*PR(ep,xp)*dt; else {
else
Fala = false; Fala = false;
}
}
if ((LimPP > CP)) // podwyzszanie szybkie double LimPP = std::min(
CP = CP + 5 * 60 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy; LPP_RP( i_bcp ) + TP * 0.08 + RedAdj,
else HP ); // pozycja + czasowy lub zasilanie
CP = CP + 13 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
// zbiornik sterujacy
if( LimPP > CP ) {
// podwyzszanie szybkie
CP +=
5.0 * 60.0
* std::min(
std::abs( LimPP - CP ),
0.05 )
* PR( CP, LimPP )
* dt;
}
else {
CP +=
13
* std::min(
std::abs( LimPP - CP ),
0.05 )
* PR( CP, LimPP )
* dt;
}
LimPP = pom; // cp LimPP = pom; // cp
dpPipe = Min0R(HP, LimPP + XP * xpM); double const dpPipe = std::min(HP, LimPP + XP * xpM);
if (dpPipe > PP) double const ActFlowSpeed = BPT[ std::lround( i_bcp ) + 2 ][ 0 ];
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4);
else
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
if (EQ(i_bcp, -1)) double dpMainValve;
{ if( dpPipe > PP ) {
if ((TP < 5)) dpMainValve = -PFVa( HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4 );
TP = TP + dt; // 5/10 }
if ((TP < 1)) else {
TP = TP - 0.5 * dt; // 5/10 dpMainValve = PFVd( PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4 );
// dpMainValve:=dpMainValve*2;
//+1*PF(dpPipe,pp,ActFlowSpeed/LBDelay)//coby
// nie przeszkadzal przy ladowaniu z zaworu obok
} }
if (EQ(i_bcp, 0)) if (EQ(i_bcp, -1)) {
{
if ((TP > 2)) if( TP < 5 ) { TP += dt; }
dpMainValve = dpMainValve * 1.5; //+0.5*PF(dpPipe,pp,ActFlowSpeed/LBDelay)//coby nie if( TP < 1 ) { TP -= 0.5 * dt; }
// przeszkadzal przy ladowaniu z zaworu obok }
if (EQ(i_bcp, 0)) {
if( TP > 2 ) {
dpMainValve *= 1.5;
}
} }
ep = dpPipe; ep = dpPipe;
if ((EQ(i_bcp, 0) || (RP > ep))) if( ( EQ( i_bcp, 0 )
RP = RP + PF(RP, ep, 0.0007) * dt; // powolne wzrastanie, ale szybsze na jezdzie; || ( RP > ep ) ) ) {
else // powolne wzrastanie, ale szybsze na jezdzie;
RP = RP + PF(RP, ep, 0.000093 / 2 * 2) * dt; // powolne wzrastanie i to bardzo RP += PF( RP, ep, 0.0007 ) * dt;
// jednak trzeba wydluzyc, bo }
// obecnie zle dziala else {
if ((RP < ep) && // powolne wzrastanie i to bardzo
(RP < RP += PF( RP, ep, 0.000093 / 2 * 2 ) * dt;
BPT[lround(i_bcpno) + 2][1])) // jesli jestesmy ponizej cisnienia w sterujacym (2.9 bar) }
RP = RP + PF(RP, CP, 0.005) * dt; // przypisz cisnienie w PG - wydluzanie napelniania o czas // jednak trzeba wydluzyc, bo obecnie zle dziala
// potrzebny do napelnienia PG if( ( RP < ep )
&& ( RP < BPT[ std::lround( i_bcpno ) + 2 ][ 1 ] ) ) {
// jesli jestesmy ponizej cisnienia w sterujacym (2.9 bar)
// przypisz cisnienie w PG - wydluzanie napelniania o czas potrzebny do napelnienia PG
RP += PF( RP, CP, 0.005 ) * dt;
}
if ((EQ(i_bcp, i_bcpno)) || (EQ(i_bcp, -2))) if( ( EQ( i_bcp, i_bcpno ) )
{ || ( EQ( i_bcp, -2 ) ) ) {
DP = PF(0, PP, ActFlowSpeed / LBDelay);
DP = PF( 0.0, PP, ActFlowSpeed / LBDelay );
dpMainValve = DP; dpMainValve = DP;
Sounds[s_fv4a_e] = DP; Sounds[s_fv4a_e] = DP;
Sounds[s_fv4a_u] = 0; Sounds[s_fv4a_u] = 0.0;
Sounds[s_fv4a_b] = 0; Sounds[s_fv4a_b] = 0.0;
Sounds[s_fv4a_x] = 0; Sounds[s_fv4a_x] = 0.0;
} }
else else {
{
if (dpMainValve > 0) if( dpMainValve > 0.0 ) {
Sounds[s_fv4a_b] = dpMainValve; Sounds[ s_fv4a_b ] = dpMainValve;
else }
Sounds[s_fv4a_u] = -dpMainValve; else {
Sounds[ s_fv4a_u ] = -dpMainValve;
}
} }
return dpMainValve * dt; return dpMainValve * dt;
@@ -2347,17 +2381,11 @@ double TFV4aM::GetPos(int i)
double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji; double TFV4aM::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji;
{ {
int i_pos; int const i_pos = 2 + std::floor( pos ); // zaokraglone w dol
i_pos = lround(pos - 0.5) + 2; // zaokraglone w dol return
double i, j, k, l; BPT[i_pos][1]
i = BPT[i_pos][1]; + (BPT[i_pos + 1][1] - BPT[i_pos][1]) * ((pos + 2) - i_pos); // interpolacja liniowa
j = BPT[i_pos + 1][1];
k = pos + 2 - i_pos;
l = i + (j - i) * k;
double r = BPT[i_pos][1] +
(BPT[i_pos + 1][1] - BPT[i_pos][1]) * (pos + 2 - i_pos); // interpolacja liniowa
return r;
} }
bool TFV4aM::EQ(double pos, double i_pos) bool TFV4aM::EQ(double pos, double i_pos)
{ {
@@ -2366,8 +2394,7 @@ bool TFV4aM::EQ(double pos, double i_pos)
//---FV4a/M--- nowonapisany kran bez poprawki IC //---FV4a/M--- nowonapisany kran bez poprawki IC
double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep) double TMHZ_EN57::GetPF( double i_bcp, double PP, double HP, double dt, double ep ) {
{
static int const LBDelay = 100; static int const LBDelay = 100;
double LimPP; double LimPP;
@@ -2376,13 +2403,11 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
double ActFlowSpeed; double ActFlowSpeed;
double DP; double DP;
double pom; double pom;
int i;
{ for( int idx = 0; idx < 5; ++idx ) {
long i_end = 5; Sounds[ idx ] = 0;
for (i = 0; i < i_end; ++i)
Sounds[i] = 0;
} }
DP = 0; DP = 0;
i_bcp = Max0R(Min0R(i_bcp, 9.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres i_bcp = Max0R(Min0R(i_bcp, 9.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres

View File

@@ -184,7 +184,7 @@ class TBrake {
bool DCV = false; //podwojny zawor zwrotny bool DCV = false; //podwojny zawor zwrotny
double ASBP = 0.0; //cisnienie hamulca pp double ASBP = 0.0; //cisnienie hamulca pp
int BrakeStatus = 0; //flaga stanu int BrakeStatus{ b_off }; //flaga stanu
int SoundFlag = 0; int SoundFlag = 0;
public: public:
@@ -213,6 +213,8 @@ class TBrake {
void SetASBP( double const Press ); //ustalenie cisnienia pp void SetASBP( double const Press ); //ustalenie cisnienia pp
virtual void ForceEmptiness(); virtual void ForceEmptiness();
int GetSoundFlag(); int GetSoundFlag();
int GetBrakeStatus() const { return BrakeStatus; }
void SetBrakeStatus( int const Status ) { BrakeStatus = Status; }
virtual void SetED( double const EDstate ) {}; //stan hamulca ED do luzowania virtual void SetED( double const EDstate ) {}; //stan hamulca ED do luzowania
}; };

View File

@@ -801,6 +801,7 @@ void TSegment::RaRenderLoft(CVertNormTex *&Vert, const vector6 *ShapePoints, int
s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć s = fStep * iSkip; // iSkip - ile odcinków z początku pominąć
i = iSkip; // domyślnie 0 i = iSkip; // domyślnie 0
t = fTsBuffer[i]; // tabela wattości t dla segmentów t = fTsBuffer[i]; // tabela wattości t dla segmentów
// BUG: length of spline can be 0, we should skip geometry generation for such cases
fOffset = 0.1 / fLength; // pierwsze 10cm fOffset = 0.1 / fLength; // pierwsze 10cm
pos1 = FastGetPoint(t); // wektor początku segmentu pos1 = FastGetPoint(t); // wektor początku segmentu
dir = FastGetDirection(t, fOffset); // wektor kierunku dir = FastGetDirection(t, fOffset); // wektor kierunku

View File

@@ -424,7 +424,6 @@ opengl_texture::load_TGA() {
else if( tgaheader[ 2 ] == 10 ) { else if( tgaheader[ 2 ] == 10 ) {
// compressed TGA // compressed TGA
int currentpixel = 0; int currentpixel = 0;
int currentbyte = 0;
unsigned char buffer[ 4 ] = { 255, 255, 255, 255 }; unsigned char buffer[ 4 ] = { 255, 255, 255, 255 };
const int pixelcount = data_width * data_height; const int pixelcount = data_width * data_height;

View File

@@ -925,19 +925,17 @@ void TTrain::OnCommand_sandboxactivate( TTrain *Train, command_data const &Comma
return; return;
} }
if( Command.action != GLFW_RELEASE ) { if( Command.action == GLFW_PRESS ) {
// press or hold // press
Train->mvControlled->SandDose = true; Train->mvControlled->Sandbox( true );
// audio feedback // audio feedback
if( Train->ggSandButton.GetValue() < 0.05 ) { Train->play_sound( Train->dsbSwitch );
Train->play_sound( Train->dsbSwitch );
}
// visual feedback // visual feedback
Train->ggSandButton.UpdateValue( 1.0 ); Train->ggSandButton.UpdateValue( 1.0 );
} }
else { else if( Command.action == GLFW_RELEASE) {
// release // release
Train->mvControlled->SandDose = false; Train->mvControlled->Sandbox( false );
/* /*
// audio feedback // audio feedback
if( Train->ggAntiSlipButton.GetValue() > 0.5 ) { if( Train->ggAntiSlipButton.GetValue() > 0.5 ) {
@@ -4333,7 +4331,7 @@ bool TTrain::Update( double const Deltatime )
// if // if
// ((TestFlag(mvControlled->BrakeStatus,+b_Rused+b_Ractive)))//Lampka drugiego stopnia hamowania // ((TestFlag(mvControlled->BrakeStatus,+b_Rused+b_Ractive)))//Lampka drugiego stopnia hamowania
btLampkaHamPosp.Turn((TestFlag(mvOccupied->BrakeStatus, 1))); // lampka drugiego stopnia hamowania btLampkaHamPosp.Turn((TestFlag(mvOccupied->Hamulec->GetBrakeStatus(), 1))); // lampka drugiego stopnia hamowania
//TODO: youBy wyciągnąć flagę wysokiego stopnia //TODO: youBy wyciągnąć flagę wysokiego stopnia
// hunter-121211: lampka zanikowo-pradowego wentylatorow: // hunter-121211: lampka zanikowo-pradowego wentylatorow:

View File

@@ -714,6 +714,9 @@ void TWorld::OnKeyDown(int cKey)
Train->OnKeyDown(cKey); // przekazanie klawisza do kabiny Train->OnKeyDown(cKey); // przekazanie klawisza do kabiny
if (FreeFlyModeFlag) // aby nie odluźniało wagonu za lokomotywą if (FreeFlyModeFlag) // aby nie odluźniało wagonu za lokomotywą
{ // operacje wykonywane na dowolnym pojeździe, przeniesione tu z kabiny { // operacje wykonywane na dowolnym pojeździe, przeniesione tu z kabiny
/*
// NOTE: disabled so it doesn't interfere with new system controls in outside view
// TODO: implement as part of the new system
if (cKey == Global::Keys[k_Releaser]) // odluźniacz if (cKey == Global::Keys[k_Releaser]) // odluźniacz
{ // działa globalnie, sprawdzić zasięg { // działa globalnie, sprawdzić zasięg
TDynamicObject *temp = Global::DynamicNearest(); TDynamicObject *temp = Global::DynamicNearest();
@@ -721,7 +724,7 @@ void TWorld::OnKeyDown(int cKey)
{ {
if (Global::ctrlState) // z ctrl odcinanie if (Global::ctrlState) // z ctrl odcinanie
{ {
temp->MoverParameters->BrakeStatus ^= 128; temp->MoverParameters->Hamulec->SetBrakeStatus( temp->MoverParameters->Hamulec->GetBrakeStatus() ^ 128 );
} }
else if (temp->MoverParameters->BrakeReleaser(1)) else if (temp->MoverParameters->BrakeReleaser(1))
{ {
@@ -731,7 +734,9 @@ void TWorld::OnKeyDown(int cKey)
} }
} }
} }
else if (cKey == Global::Keys[k_Heating]) // Ra: klawisz nie jest najszczęśliwszy else
*/
if (cKey == Global::Keys[k_Heating]) // Ra: klawisz nie jest najszczęśliwszy
{ // zmiana próżny/ładowny; Ra: zabrane z kabiny { // zmiana próżny/ładowny; Ra: zabrane z kabiny
TDynamicObject *temp = Global::DynamicNearest(); TDynamicObject *temp = Global::DynamicNearest();
if (temp) if (temp)
@@ -1799,12 +1804,12 @@ TWorld::Update_UI() {
if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_M ) == bdelay_M ) if( ( tmp->MoverParameters->BrakeDelayFlag & bdelay_M ) == bdelay_M )
uitextline2 += "+Mg"; uitextline2 += "+Mg";
uitextline2 += ", BTP:" + to_string( tmp->MoverParameters->LoadFlag, 0 ); uitextline2 += ", BTP: " + to_string( tmp->MoverParameters->LoadFlag, 0 );
{ {
uitextline2 += uitextline2 +=
"; pant. " "; pant: "
+ to_string( tmp->MoverParameters->PantPress, 2 ) + to_string( tmp->MoverParameters->PantPress, 2 )
+ ( tmp->MoverParameters->bPantKurek3 ? "<ZG" : "|ZG" ); + ( tmp->MoverParameters->bPantKurek3 ? "-ZG" : "|ZG" );
} }
uitextline2 += uitextline2 +=
@@ -1822,25 +1827,37 @@ TWorld::Update_UI() {
+ to_string( tmp->MoverParameters->TotalCurrent, 0 ); + to_string( tmp->MoverParameters->TotalCurrent, 0 );
#ifdef EU07_USE_OLD_HVCOUPLERS #ifdef EU07_USE_OLD_HVCOUPLERS
uitextline2 += uitextline2 +=
", HV0: (" ", HV0: "
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::outgoing ], 0 ) + to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::voltage ], 0 )
+ ")<-" + "@"
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::incoming ], 0 ); + to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::current ], 0 );
uitextline2 += uitextline2 +=
", HV1: (" ", HV1: "
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::outgoing ], 0 ) + to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::voltage ], 0 )
+ ")<-" + "@"
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::incoming ], 0 ); + to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::current ], 0 );
#else #else
uitextline2 += auto const frontcouplerhighvoltage =
", HV: " to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.voltage, 0 )
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.incoming, 0 ) + "@"
+ "->(" + to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.current, 0 );
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.outgoing, 0 ) auto const rearcouplerhighvoltage =
+ ")F" + (tmp->DirectionGet() ? "<<" : ">>") + "R(" to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.voltage, 0 )
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.outgoing, 0 ) + "@"
+ ")<-" + to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.current, 0 );
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.incoming, 0 ); uitextline2 += ", HV: ";
if( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.local == false ) {
uitextline2 +=
"(" + frontcouplerhighvoltage + ")-"
+ ":F" + ( tmp->DirectionGet() ? "<<" : ">>" ) + "R:"
+ "-(" + rearcouplerhighvoltage + ")";
}
else {
uitextline2 +=
frontcouplerhighvoltage
+ ":F" + ( tmp->DirectionGet() ? "<<" : ">>" ) + "R:"
+ rearcouplerhighvoltage;
}
#endif #endif
// equipment flags // equipment flags
uitextline3 = ""; uitextline3 = "";
@@ -1855,17 +1872,16 @@ TWorld::Update_UI() {
uitextline3 += ( tmp->MoverParameters->CompressorGovernorLock ? "!" : "." ); uitextline3 += ( tmp->MoverParameters->CompressorGovernorLock ? "!" : "." );
uitextline3 += uitextline3 +=
" BP: " + to_string( tmp->MoverParameters->BrakePress, 2 ) " TrB: " + to_string( tmp->MoverParameters->BrakePress, 2 )
+ " (" + to_string( tmp->MoverParameters->BrakeStatus, 0 ) + ", " + to_hex_str( tmp->MoverParameters->Hamulec->GetBrakeStatus(), 2 )
+ "), LBP: " + to_string( tmp->MoverParameters->LocBrakePress, 2 ) + ", LcB: " + to_string( tmp->MoverParameters->LocBrakePress, 2 )
+ ", PP: " + to_string( tmp->MoverParameters->PipePress, 2 ) + ", pipes: " + to_string( tmp->MoverParameters->PipePress, 2 )
+ "/" + to_string( tmp->MoverParameters->ScndPipePress, 2 ) + "/" + to_string( tmp->MoverParameters->ScndPipePress, 2 )
+ "/" + to_string( tmp->MoverParameters->EqvtPipePress, 2 ) + "/" + to_string( tmp->MoverParameters->EqvtPipePress, 2 )
+ ", MT: " + to_string( tmp->MoverParameters->CompressedVolume, 3 ) + ", MT: " + to_string( tmp->MoverParameters->CompressedVolume, 3 )
+ ", BVP: " + to_string( tmp->MoverParameters->Volume, 3 ) + ", BT: " + to_string( tmp->MoverParameters->Volume, 3 )
+ ", " + to_string( tmp->MoverParameters->CntrlPipePress, 3 ) + ", CtlP: " + to_string( tmp->MoverParameters->CntrlPipePress, 3 )
+ ", " + to_string( tmp->MoverParameters->Hamulec->GetCRP(), 3 ) + ", CtlT: " + to_string( tmp->MoverParameters->Hamulec->GetCRP(), 3 );
+ ", " + to_string( tmp->MoverParameters->BrakeStatus, 0 );
if( tmp->MoverParameters->ManualBrakePos > 0 ) { if( tmp->MoverParameters->ManualBrakePos > 0 ) {
@@ -2579,8 +2595,6 @@ world_environment::update() {
keylightintensity = sunlightlevel; keylightintensity = sunlightlevel;
// diffuse (sun) intensity goes down after twilight, and reaches minimum 18 degrees below horizon // diffuse (sun) intensity goes down after twilight, and reaches minimum 18 degrees below horizon
twilightfactor = clamp( -Global::SunAngle, 0.0f, 18.0f ) / 18.0f; twilightfactor = clamp( -Global::SunAngle, 0.0f, 18.0f ) / 18.0f;
// TODO: crank orange up at dawn/dusk
keylightcolor = float3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f );
float const duskfactor = 1.0f - clamp( Global::SunAngle, 0.0f, 18.0f ) / 18.0f; float const duskfactor = 1.0f - clamp( Global::SunAngle, 0.0f, 18.0f ) / 18.0f;
keylightcolor = interpolate( keylightcolor = interpolate(
float3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ), float3( 255.0f / 255.0f, 242.0f / 255.0f, 231.0f / 255.0f ),

View File

@@ -80,7 +80,7 @@ private:
glm::vec2 m_leftstick; glm::vec2 m_leftstick;
glm::vec2 m_rightstick; glm::vec2 m_rightstick;
glm::vec2 m_triggers; glm::vec2 m_triggers;
double m_modeaccumulator; // used to throttle command input rate for vehicle controls double m_modeaccumulator{ 0.0 }; // used to throttle command input rate for vehicle controls
}; };
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -871,9 +871,9 @@ opengl_renderer::Update ( double const Deltatime ) {
int targetsegments; int targetsegments;
float targetfactor; float targetfactor;
if( framerate > 65.0 ) { targetsegments = 400; targetfactor = 3.0f; } if( framerate > 90.0 ) { targetsegments = 400; targetfactor = 3.0f; }
else if( framerate > 40.0 ) { targetsegments = 225; targetfactor = 1.5f; } else if( framerate > 60.0 ) { targetsegments = 225; targetfactor = 1.5f; }
else if( framerate > 15.0 ) { targetsegments = 90; targetfactor = Global::ScreenHeight / 768.0f; } else if( framerate > 30.0 ) { targetsegments = 90; targetfactor = Global::ScreenHeight / 768.0f; }
else { targetsegments = 9; targetfactor = Global::ScreenHeight / 768.0f * 0.75f; } else { targetsegments = 9; targetfactor = Global::ScreenHeight / 768.0f * 0.75f; }
if( targetsegments > Global::iSegmentsRendered ) { if( targetsegments > Global::iSegmentsRendered ) {

View File

@@ -258,8 +258,6 @@ void cSun::irradiance() {
static double degrad = 57.295779513; // converts from radians to degrees static double degrad = 57.295779513; // converts from radians to degrees
static double raddeg = 0.0174532925; // converts from degrees to radians static double raddeg = 0.0174532925; // converts from degrees to radians
auto const &localtime = simulation::Time.data(); // time for the calculation
m_body.dayang = ( simulation::Time.year_day() - 1 ) * 360.0 / 365.0; m_body.dayang = ( simulation::Time.year_day() - 1 ) * 360.0 / 365.0;
double sd = sin( raddeg * m_body.dayang ); // sine of the day angle double sd = sin( raddeg * m_body.dayang ); // sine of the day angle
double cd = cos( raddeg * m_body.dayang ); // cosine of the day angle or delination double cd = cos( raddeg * m_body.dayang ); // cosine of the day angle or delination