16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-22 16:19: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)
ReactionTime = 0.1; // orientuj się szybciej
} // if (Im>Imin)
if (fabs(mvControlling->Im) > 0.75 * mvControlling->ImaxHi) // jeśli prąd jest duży
mvControlling->SandDoseOn(); // piaskujemy tory, coby się nie ślizgać
// NOTE: this step is likely to conflict with directive to operate sandbox based on the state of slipping wheels
// 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) ||
mvControlling->SlippingWheels) // jeśli prąd jest duży (można 690 na 750)
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
if (mvControlling->SlippingWheels)
{
mvControlling->SandDoseOn(); // piasku!
mvControlling->Sandbox(true); // piasku!
// Controlling->SlippingWheels=false; //a to tu nie ma sensu, flaga używana w dalszej
// części
}
else {
// deactivate sandbox if we aren't slipping
if( mvControlling->SandDose ) {
mvControlling->Sandbox( false );
}
}
}
// ABu-160305 testowanie gotowości do jazdy
// 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
Ready = true; //żeby uznać za odhamowany
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
if (AIControllFlag)
{

View File

@@ -1753,27 +1753,22 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
// wylaczanie hamulca
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
{
MoverParameters->BrakeStatus |= 128; // wylacz
MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz
MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
}
if (ActPar.find('E') != std::string::npos) // oprozniony
{
MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
MoverParameters->Pipe->CreatePress(0);
MoverParameters->Pipe2->CreatePress(0);
}
if (ActPar.find('Q') != std::string::npos) // oprozniony
{
// MoverParameters->Hamulec->ForceEmptiness(); //TODO: sprawdzic,
// dlaczego
// pojawia sie blad przy uzyciu tej linijki w lokomotywie
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->Pipe->CreatePress(0.0);
MoverParameters->PipePress = 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
{
MoverParameters->BrakeStatus |= 128; // wylacz
MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz
MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
}
}
if (ActPar.find('X') != std::string::npos) // agonalny wylaczanie 20%, usrednienie przekladni
{
if (Random(100) < 20) // losowanie 20/100
{
MoverParameters->BrakeStatus |= 128; // wylacz
MoverParameters->Hamulec->SetBrakeStatus( MoverParameters->Hamulec->GetBrakeStatus() | b_dmg ); // wylacz
MoverParameters->Hamulec->ForceEmptiness();
MoverParameters->BrakeReleaser(1); // odluznij automatycznie
}
if (MoverParameters->BrakeCylMult[2] * MoverParameters->BrakeCylMult[1] >
0.01) // jesli jest nastawiacz mechaniczny PL
@@ -2443,16 +2436,6 @@ bool TDynamicObject::Update(double dt, double dt1)
if (!bEnabled)
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
if ((MoverParameters->EnginePowerSource.SourceType == CurrentCollector) &&
(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 ) {
// 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;
}
}
@@ -2958,28 +2942,6 @@ bool TDynamicObject::Update(double dt, double dt1)
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
dDOMoveLen =
@@ -3323,6 +3285,9 @@ bool TDynamicObject::Update(double dt, double dt1)
sPantDown.Play(vol, 0, MechInside, vPosition);
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)
{ // Winger 240404 - wylaczanie sprezarki i
// 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!
}
}
*/
}
else if (MoverParameters->EnginePowerSource.SourceType == InternalSource)
if (MoverParameters->EnginePowerSource.PowerType == SteamPower)

View File

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

View File

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

View File

@@ -377,7 +377,7 @@ struct TBoilerType {
};
/*rodzaj odbieraka pradu*/
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 CSW{ 0.0 }; //szerokość części roboczej (styku) ślizgacza
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 };
struct power_coupling {
double outgoing{ 0.0 }; // power generated by coupling owner
double incoming{ 0.0 }; // power supplied from outside source
double current{ 0.0 };
double voltage{ 0.0 };
bool local{ false }; // whether the power comes from external or onboard source
};
struct TCoupling {
@@ -800,8 +801,8 @@ public:
#ifdef EU07_USE_OLD_HVCOUPLERS
double HVCouplers[ 2 ][ 2 ]; //przewod WN
enum hvcoupler {
incoming = 0,
outgoing
current = 0,
voltage
};
#endif
int ScanCounter = 0; /*pomocnicze do skanowania sprzegow*/
@@ -848,7 +849,9 @@ public:
int LocalBrakePos = 0; /*nastawa hamulca indywidualnego*/
int ManualBrakePos = 0; /*nastawa hamulca recznego*/
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*/
int BrakeDelayFlag = 0; /*nastawa opoznienia ham. osob/towar/posp/exp 0/1/2/4*/
int BrakeDelays = 0; /*nastawy mozliwe do uzyskania*/
@@ -1040,7 +1043,7 @@ public:
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*/
void SSReset(void);
@@ -1112,7 +1115,7 @@ public:
/*function ShowEngineRotation(VehN:int): integer; //Ra 2014-06: przeniesione do C++*/
/*funkcje uzalezniajace sile pociagowa od predkosci: v2n, n2r, current, momentum*/
double v2n(void);
double current(double n, double U);
double Current(double n, double U);
double Momentum(double I);
double MomentumF(double I, double Iw, int SCP);

View File

@@ -76,7 +76,7 @@ int DirF(int CouplerN)
// Q: 20160716
// 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
// w zaleznosci od polozenia nastawnikow MainCtrl i ScndCtrl oraz predkosci obrotowej n
@@ -338,9 +338,9 @@ Name( NameInit )
Couplers[b].FmaxC = 1000.0;
}
#ifdef EU07_USE_OLD_HVCOUPLERS
for( int b = 0; b < 2; ++b ) {
HVCouplers[ b ][ 0 ] = 0.0;
HVCouplers[ b ][ 1 ] = 0.0;
for( int side = 0; side < 2; ++side ) {
HVCouplers[ side ][ hvcoupler::current ] = 0.0;
HVCouplers[ side ][ hvcoupler::voltage ] = 0.0;
}
#endif
for( int b = 0; b < 3; ++b ) {
@@ -706,15 +706,22 @@ bool TMoverParameters::CurrentSwitch(int direction)
};
void TMoverParameters::UpdatePantVolume(double dt)
{ // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze
// nie tak
{ // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze 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
{
// 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: zbiornika rozrządu nie pompuje się tu, tylko pantografy; potem można zamknąć
// WS i odpalić resztę
// NOTE: custom variant for EMU disabled because it pretty much doesn't work
if ((TrainType == dt_EZT) ? (PantPress < ScndPipePress) :
bPantKurek3) // kurek zamyka połączenie z ZG
{ // 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
{ // zbiornik główny odcięty, można pompować pantografy
if (PantCompFlag && Battery) // włączona bateria i mała sprężarka
PantVolume += dt * (TrainType == dt_EZT ? 0.003 : 0.005) *
(2.0 * 0.45 - ((0.1 / PantVolume / 10) - 0.1)) /
0.45; // napełnianie zbiornika pantografów
if( PantCompFlag ) {
// włączona mała sprężarka
PantVolume +=
dt
// 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::max( PantPress, 0.0 );
}
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()
// TODO: determine if this isn't a mistake --
@@ -1100,31 +1110,31 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
|| ( ( Heating )
&& ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) {
#ifdef EU07_USE_OLD_HVCOUPLERS
HVCouplers[ oppositeside ][ hvcoupler::outgoing ] =
HVCouplers[ oppositeside ][ hvcoupler::voltage ] =
std::max(
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
auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ];
Couplers[ oppositeside ].power_high.outgoing =
Couplers[ oppositeside ].power_high.voltage =
std::max(
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
}
else {
#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
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
}
}
#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
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
if( ( std::abs( PantFrontVolt ) + std::abs( PantRearVolt ) < 1.0 )
@@ -1133,26 +1143,33 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
// przekazywanie pradow
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 )
|| ( ( Heating )
&& ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) {
#ifdef EU07_USE_OLD_HVCOUPLERS
HVCouplers[ side ][ hvcoupler::incoming ] =
Couplers[side].Connected->HVCouplers[Couplers[side].ConnectedNr][hvcoupler::outgoing] +
Itot * HVCouplers[side][hvcoupler::outgoing] / hvc; // obciążenie rozkladane stosownie do napiec
auto const oppositeside = ( Couplers[side].ConnectedNr == side::front ? side::rear : side::front );
HVCouplers[ side ][ hvcoupler::current ] =
Couplers[side].Connected->HVCouplers[oppositeside][hvcoupler::current] +
Itot * HVCouplers[side][hvcoupler::voltage] / hvc; // obciążenie rozkladane stosownie do napiec
#else
auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ];
Couplers[ side ].power_high.incoming =
connectedcoupler.power_high.outgoing
+ Itot * Couplers[ side ].power_high.outgoing / hvc; // obciążenie rozkladane stosownie do napiec
auto const &connectedsothercoupler =
Couplers[ side ].Connected->Couplers[
( Couplers[ side ].ConnectedNr == side::front ?
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
}
else {
#ifdef EU07_USE_OLD_HVCOUPLERS
// pierwszy pojazd
HVCouplers[side][hvcoupler::incoming] = Itot * HVCouplers[side][hvcoupler::outgoing] / hvc;
HVCouplers[side][hvcoupler::current] = Itot * HVCouplers[side][hvcoupler::voltage] / hvc;
#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
}
}
@@ -1160,16 +1177,24 @@ double TMoverParameters::ComputeMovement(double dt, double dt1, const TTrackShap
else
{
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 )
|| ( ( Heating )
&& ( Couplers[ side ].CouplingFlag & ctrain_heating ) ) ) {
#ifdef EU07_USE_OLD_HVCOUPLERS
TotalCurrent += Couplers[ side ].Connected->HVCouplers[ Couplers[ side ].ConnectedNr ][ hvcoupler::incoming ];
HVCouplers[ side ][ hvcoupler::incoming ] = 0.0;
auto const oppositeside = ( Couplers[ side ].ConnectedNr == side::front ? side::rear : side::front );
TotalCurrent += Couplers[ side ].Connected->HVCouplers[ oppositeside ][ hvcoupler::current ];
HVCouplers[ side ][ hvcoupler::current ] = 0.0;
#else
auto const &connectedcoupler = Couplers[ side ].Connected->Couplers[ Couplers[ side ].ConnectedNr ];
TotalCurrent += connectedcoupler.power_high.incoming;
Couplers[ side ].power_high.incoming = 0.0;
auto const &connectedsothercoupler =
Couplers[ side ].Connected->Couplers[
( Couplers[ side ].ConnectedNr == side::front ?
side::rear :
side::front ) ];
TotalCurrent += connectedsothercoupler.power_high.current;
Couplers[ side ].power_high.current = 0.0;
#endif
}
}
@@ -1528,8 +1553,7 @@ void TMoverParameters::ConverterCheck()
{ // sprawdzanie przetwornicy
if( ( ConverterAllow )
&& ( false == PantPressLockActive )
&& ( ( Mains )
|| ( GetTrainsetVoltage() > 0.5 * EnginePowerSource.MaxVoltage ) ) ) {
&& ( Mains ) ) {
ConverterFlag = true;
}
else {
@@ -2032,23 +2056,43 @@ bool TMoverParameters::AddPulseForce(int Multipler)
// Q: 20160713
// sypanie piasku
// *************************************************************************************************
bool TMoverParameters::SandDoseOn(void)
bool TMoverParameters::Sandbox( bool const State, int const Notify )
{
bool SDO;
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;
bool result{ 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)
@@ -2271,7 +2315,8 @@ bool TMoverParameters::DirectionBackward(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;
rBDS = true;
BrakeStatus &= 191;
Hamulec->SetBrakeStatus( Hamulec->GetBrakeStatus() & ~64 );
// kopowanie nastawy hamulca do kolejnego czlonu - do przemyślenia
if (CabNo != 0)
SendCtrlToNext("BrakeDelay", BrakeDelayFlag, CabNo);
@@ -3108,12 +3153,17 @@ void TMoverParameters::UpdatePipePressure(double dt)
else
dpLocalValve =
LocHandle->GetPF(LocalBrakePosA, Hamulec->GetBCP(), ScndPipePress, dt, 0);
if ((BrakeHandle == FV4a) &&
((PipePress < 2.75) && ((Hamulec->GetStatus() & b_rls) == 0)) &&
(BrakeSubsystem == ss_LSt) && (TrainType != dt_EZT))
if( ( BrakeHandle == FV4a )
&& ( ( PipePress < 2.75 )
&& ( ( Hamulec->GetStatus() & b_rls ) == 0 ) )
&& ( BrakeSubsystem == ss_LSt )
&& ( TrainType != dt_EZT ) ) {
temp = PipePress + 0.00001;
else
}
else {
temp = ScndPipePress;
}
Handle->SetReductor(BrakeCtrlPos2);
if ((BrakeOpModeFlag != bom_PS))
@@ -3255,20 +3305,21 @@ void TMoverParameters::UpdatePipePressure(double dt)
if ((BrakeHandle == FVel6) && (ActiveCab != 0))
{
if ((Battery) && (ActiveDir != 0) &&
(EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie -
if ((Battery)
&& (ActiveDir != 0)
&& (EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie -
// temp = (Handle as TFVel6).GetCP
temp = Handle->GetCP();
else
temp = 0.0;
Hamulec->SetEPS(temp);
SendCtrlToNext("Brake", temp,
CabNo); // Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach
// Ra 2014-11: na tym się wysypuje, ale nie wiem, w jakich warunkach
SendCtrlToNext("Brake", temp, CabNo);
}
Pipe->Act();
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
else
temp = 1.0; // połącz
@@ -3524,8 +3575,7 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
LastSwitchingTime += dt1;
if (EngineType == ElectricSeriesMotor)
LastRelayTime += dt1;
if( Mains && /*(abs(CabNo) < 2) &&*/ ( EngineType ==
ElectricSeriesMotor ) ) // potem ulepszyc! pantogtrafy!
if( Mains && /*(abs(CabNo) < 2) &&*/ ( EngineType == ElectricSeriesMotor ) ) // potem ulepszyc! pantogtrafy!
{ // Ra 2014-03: uwzględnienie kierunku jazdy w napięciu na silnikach, a powinien być
// zdefiniowany nawrotnik
if( CabNo == 0 )
@@ -3533,20 +3583,22 @@ void TMoverParameters::ComputeTotalForce(double dt, double dt1, bool FullVer)
else
Voltage = RunningTraction.TractionVoltage * DirAbsolute; // ActiveDir*CabNo;
} // bo nie dzialalo
else if( ( EngineType == ElectricInductionMotor ) ||
( ( ( Couplers[ 0 ].CouplingFlag & ctrain_power ) == ctrain_power ) ||
( ( Couplers[ 1 ].CouplingFlag & ctrain_power ) ==
ctrain_power ) ) ) // potem ulepszyc! pantogtrafy!
else if( ( EngineType == ElectricInductionMotor )
|| ( ( ( Couplers[ side::front ].CouplingFlag & ctrain_power ) == ctrain_power )
|| ( ( Couplers[ side::rear ].CouplingFlag & ctrain_power ) == ctrain_power ) ) ) {
// potem ulepszyc! pantogtrafy!
Voltage =
std::max(
RunningTraction.TractionVoltage,
#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
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
else
}
else {
Voltage = 0;
}
//if (Mains && /*(abs(CabNo) < 2) &&*/ (
// EngineType == ElectricInductionMotor)) // potem ulepszyc! pantogtrafy!
// Voltage = RunningTraction.TractionVoltage;
@@ -4059,7 +4111,7 @@ double TMoverParameters::TractionForce(double dt)
// yB: szereg dwoch sekcji w ET42
if ((TrainType == dt_ET42) && (Imax == ImaxHi))
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)
{
@@ -4253,47 +4305,59 @@ double TMoverParameters::TractionForce(double dt)
case 0: {
if( ( Im <= ( MPTRelay[ ScndCtrlPos ].Iup * PosRatio ) ) &&
( ScndCtrlPos < ScndCtrlPosNo ) )
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( Im <= ( MPTRelay[ ScndCtrlPos ].Iup * PosRatio ) ) ) {
++ScndCtrlPos;
if( ( Im >= ( MPTRelay[ ScndCtrlPos ].Idown * PosRatio ) ) && ( ScndCtrlPos > 0 ) )
}
if( ( ScndCtrlPos > 0 )
&& ( Im >= ( MPTRelay[ScndCtrlPos].Idown * PosRatio ) ) ) {
--ScndCtrlPos;
}
break;
}
case 1: {
if( ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) && ( ScndCtrlPos < ScndCtrlPosNo ) )
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) ) {
++ScndCtrlPos;
if( ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) && ( ScndCtrlPos > 0 ) )
}
if( ( ScndCtrlPos > 0 )
&& ( MPTRelay[ ScndCtrlPos ].Idown > Vel ) ) {
--ScndCtrlPos;
}
break;
}
case 2: {
if( ( MPTRelay[ ScndCtrlPos ].Iup < Vel ) && ( ScndCtrlPos < ScndCtrlPosNo ) &&
( EnginePower < ( tmp * 0.99 ) ) )
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( MPTRelay[ ScndCtrlPos ].Iup < Vel )
&& ( EnginePower < ( tmp * 0.99 ) ) ) {
++ScndCtrlPos;
if( ( MPTRelay[ ScndCtrlPos ].Idown < Im ) && ( ScndCtrlPos > 0 ) )
}
if( ( ScndCtrlPos > 0 )
&& ( MPTRelay[ ScndCtrlPos ].Idown < Im ) ) {
--ScndCtrlPos;
}
break;
}
case 41:
{
if( ( MainCtrlPos == MainCtrlPosNo )
&& ( tmpV * 3.6 > MPTRelay[ ScndCtrlPos ].Iup )
&& ( ScndCtrlPos < ScndCtrlPosNo ) ) {
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( MainCtrlPos == MainCtrlPosNo )
&& ( tmpV * 3.6 > MPTRelay[ ScndCtrlPos ].Iup ) ) {
++ScndCtrlPos;
enrot = enrot * 0.73;
}
if( ( Im > MPTRelay[ ScndCtrlPos ].Idown )
&& ( ScndCtrlPos > 0 ) ) {
if( ( ScndCtrlPos > 0 )
&& ( Im > MPTRelay[ ScndCtrlPos ].Idown ) ) {
--ScndCtrlPos;
}
break;
}
case 45:
{
if( ( MainCtrlPos >= 10 ) && ( ScndCtrlPos < ScndCtrlPosNo ) ) {
if( ( ScndCtrlPos < ScndCtrlPosNo )
&& ( MainCtrlPos >= 10 ) ) {
if( ScndCtrlPos == 0 ) {
if( Im < MPTRelay[ ScndCtrlPos ].Iup ) {
++ScndCtrlPos;
@@ -4455,26 +4519,28 @@ double TMoverParameters::TractionForce(double dt)
dmoment = eimv[eimv_Fful];
// else
// 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) >
0.95 * Adhesive(RunningTrack.friction) * TotalMassxg))
{
PosRatio = 0;
tmp = 4;
SandDoseOn();
Sandbox( true, command_range::local );
} // przeciwposlizg
if ((abs((PosRatio + 9.80 * dizel_fill) * dmoment * 100) >
0.95 * Adhesive(RunningTrack.friction) * TotalMassxg))
{
PosRatio = 0;
tmp = 9;
SandDoseOn();
Sandbox( true, command_range::local );
} // przeciwposlizg
if ((SlippingWheels))
{
// PosRatio = -PosRatio * 0; // serio -0 ???
PosRatio = 0;
tmp = 9;
SandDoseOn();
Sandbox( true, command_range::local );
} // przeciwposlizg
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)
{//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
// TODO: if we ever revert to this version, match the expanded alternative below
return std::max( HVCouplers[ 1 ][ 0 ], HVCouplers[ 0 ][ 0 ] ); // incoming, external power
return std::max(
HVCouplers[ side::front ][ hvcoupler::voltage ],
HVCouplers[ side::rear ][ hvcoupler::voltage ] );
#else
/*
return std::max(
Couplers[ side::front ].power_high.voltage,
Couplers[ side::rear ].power_high.voltage );
*/
return std::max(
( ( ( Couplers[side::front].Connected )
&& ( ( Couplers[ side::front ].CouplingFlag & ctrain_power )
|| ( ( 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 ),
( ( ( Couplers[side::rear].Connected )
&& ( ( Couplers[ side::rear ].CouplingFlag & ctrain_power )
|| ( ( 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 ) );
#endif
}
@@ -8059,16 +8125,19 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
}
else if (Command == "BrakeDelay")
{
BrakeDelayFlag = static_cast<int>(floor(CValue1));
auto const brakesetting = static_cast<int>( std::floor( CValue1 ) );
if( true == Hamulec->SetBDF( brakesetting ) ) {
BrakeDelayFlag = brakesetting;
OK = true;
}
else if (Command == "SandDoseOn")
{
if (SandDoseOn())
OK = true;
else
else {
OK = false;
}
}
else if (Command == "Sandbox")
{
OK = Sandbox( CValue1 == 1, command_range::local );
}
else if (Command == "CabSignal") /*SHP,Indusi*/
{ // Ra: to powinno działać tylko w członie obsadzonym
if (/*(TrainType=dt_EZT)or*/ (ActiveCab != 0) && (Battery) &&

View File

@@ -16,6 +16,7 @@ Copyright (C) 2007-2014 Maciej Cierniak
#include "hamulce.h"
#include <typeinfo>
#include "Mover.h"
#include "usefull.h"
//---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 PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne
double sg = PL / PH; // bezwymiarowy stosunek cisnien
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne
double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne
double const sg = PL / PH; // bezwymiarowy stosunek cisnien
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 ((PH - PL) < DP) // niewielka roznica cisnien
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;
double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne
double sg = PL / PH; // bezwymiarowy stosunek cisnien
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
if ((sg < DPS)) // niewielka roznica cisnien
return (1 - sg) / DPS * FM * 2 * std::sqrt((DPS) * (1 - DPS));
double const PH = std::max(P1, P2) + 1.0; // wyzsze cisnienie absolutne
double const PL = P1 + P2 - PH + 2.0; // nizsze cisnienie absolutne
double const sg = PL / PH; // bezwymiarowy stosunek cisnien
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 < DPS) // niewielka roznica cisnien
return (1.0 - sg) / DPS * FM * 2.0 * std::sqrt((DPS) * (1.0 - DPS));
else
return FM * 2 * std::sqrt((sg) * (1 - sg));
return FM * 2.0 * std::sqrt((sg) * (1.0 - sg));
else // powyzej stosunku krytycznego
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 result;
double dv;
double dV1;
double temp;
double VVP;
double BVP;
double BCP;
double CVP;
// ValveRes.CreatePress(LBP);
// LBP:=0;
BVP = BrakeRes->P();
VVP = ValveRes->P();
BCP = ImplsRes->P();
CVP = CntrlRes->P();
double const BVP{ BrakeRes->P() };
double const VVP{ ValveRes->P() };
double const BCP{ ImplsRes->P() };
double const CVP{ CntrlRes->P() };
dv = 0;
dV1 = 0;
double dV{ 0.0 };
double dV1{ 0.0 };
// sprawdzanie stanu
if ((BrakeStatus & b_rls) == b_rls)
if ((CVP < 0))
if( ( BrakeStatus & b_rls ) == b_rls ) {
if( CVP < 0.0 ) {
BrakeStatus &= ~b_rls;
}
else
{ // 008
dv = PF1(CVP, BCP, 0.024) * dt;
CntrlRes->Flow(+dv);
// dV1:=+dV; //minus potem jest
// ImplsRes->Flow(-dV1);
dV = PF1( CVP, BCP, 0.024 ) * dt;
CntrlRes->Flow( dV );
/*
// 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
if (((CVP - BCP) * BVM > 0.5))
temp = 0;
temp = 0.0;
else if ((VVP > CVP + 0.4))
temp = 0.5;
else
temp = 0.5;
dv = PF1(CVP, VVP, 0.0015 * temp / 1.8 / 2) * dt;
CntrlRes->Flow(+dv);
ValveRes->Flow(-0.04 * dv);
dV1 = dV1 - 0.96 * dv;
dV = PF1(CVP, VVP, 0.0015 * temp / 1.8 / 2) * dt;
CntrlRes->Flow(+dV);
ValveRes->Flow(-0.04 * dV);
dV1 = dV1 - 0.96 * dV;
// luzowanie KI {G}
// 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
// else dV:=0; 0.00025 P
/*P*/
if (VVP > BCP)
dv = PF(VVP, BCP,
0.00043 * (1.5 - int(((CVP - BCP) * BVM > 1) && (BrakeDelayFlag == bdelay_G))),
0.1) *
dt;
else if ((CVP - BCP) < 1.5)
dv = PF(VVP, BCP,
0.001472 * (1.36 - int(((CVP - BCP) * BVM > 1) && (BrakeDelayFlag == bdelay_G))),
0.1) *
dt;
else
dv = 0;
if( VVP > BCP ) {
dV =
PF( VVP, BCP,
0.00043 * ( 1.5 - (
true == ( ( ( CVP - BCP ) * BVM > 1.0 )
&& ( BrakeDelayFlag == bdelay_G ) ) ?
1.0 :
0.0 ) ),
0.1 )
* dt;
}
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);
ValveRes->Flow(+dv);
ImplsRes->Flow(-dV);
ValveRes->Flow(+dV);
// przeplyw PG <-> rozdzielacz
dv = PF(PP, VVP, 0.01, 0.1) * dt;
ValveRes->Flow(-dv);
dV = PF(PP, VVP, 0.01, 0.1) * dt;
ValveRes->Flow(-dV);
result = dv - dV1;
result = dV - dV1;
// if Vel>55 then temp:=0.72 else
// 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))
// dV:=PF(0,BrakeCyl->P(),0.0015*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
dv = 0;
BrakeCyl->Flow(-dv);
dV = 0;
BrakeCyl->Flow(-dV);
// przeplyw ZP <-> CH
if ((BrakeCyl->P() < temp - 0.005) && (temp > 0.29))
// 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
dv = 0;
BrakeRes->Flow(dv);
BrakeCyl->Flow(-dv);
dV = 0;
BrakeRes->Flow(dV);
BrakeCyl->Flow(-dV);
ImplsRes->Act();
ValveRes->Act();
@@ -2198,125 +2211,146 @@ double TFV4aM::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
static int const LBDelay = 100;
static double const xpM = 0.3; // mnoznik membrany komory pod
double LimPP;
double dpPipe;
double dpMainValve;
double ActFlowSpeed;
double DP;
double pom;
int i;
ep = (PP / 2.0) * 1.5 + (ep / 2.0) * 0.5; // SPKS!!
ep = PP / 2 * 1.5 + ep / 2 * 0.5; // SPKS!!
// ep:=pp;
// ep:=cp/3+pp/3+ep/3;
// ep:=cp;
for( int idx = 0; idx < 5; ++idx ) {
Sounds[ idx ] = 0;
}
for (i = 0; i < 5; ++i)
Sounds[i] = 0;
DP = 0;
// na wszelki wypadek, zeby nie wyszlo poza zakres
i_bcp = clamp( i_bcp, -1.999, 5.999 );
i_bcp = Max0R(Min0R(i_bcp, 5.999), -1.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
if ((TP > 0))
{ // jesli czasowy jest niepusty
// dp:=0.07; //od cisnienia 5 do 0 w 60 sekund ((5-0)*dt/75)
double DP{ 0.0 };
if( TP > 0.0 ) {
// jesli czasowy jest niepusty
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;
}
else //.08
{
TP = 0;
else {
//.08
TP = 0.0;
}
if ((XP > 0)) // jesli komora pod niepusta jest niepusty
{
if (XP > 0) {
// jesli komora pod niepusta jest niepusty
DP = 2.5;
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
ActFlowSpeed = BPT[lround(i_bcp) + 2][0];
double pom;
if( EQ( i_bcp, -1.0 ) ) {
pom = std::min( HP, 5.4 + RedAdj );
}
else {
pom = std::min( CP, HP );
}
if ((EQ(i_bcp, -1)))
pom = Min0R(HP, 5.4 + RedAdj);
else
pom = Min0R(CP, HP);
if ((pom > RP + 0.25))
if( pom > RP + 0.25 ) {
Fala = true;
if ((Fala))
if ((pom > RP + 0.3))
// if(ep>rp+0.11)then
XP = XP - 20 * PR(pom, XP) * dt;
// else
// xp:=xp-16*(ep-(ep+0.01))/(0.1)*PR(ep,xp)*dt;
else
}
if( Fala ) {
if( pom > RP + 0.3 ) {
XP = XP - 20.0 * PR( pom, XP ) * dt;
}
else {
Fala = false;
}
}
if ((LimPP > CP)) // podwyzszanie szybkie
CP = CP + 5 * 60 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy;
else
CP = CP + 13 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
double LimPP = std::min(
LPP_RP( i_bcp ) + TP * 0.08 + RedAdj,
HP ); // pozycja + czasowy lub zasilanie
// 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
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 ];
double dpMainValve;
if( dpPipe > PP ) {
dpMainValve = -PFVa( HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4 );
else
}
else {
dpMainValve = PFVd( PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4 );
if (EQ(i_bcp, -1))
{
if ((TP < 5))
TP = TP + dt; // 5/10
if ((TP < 1))
TP = TP - 0.5 * dt; // 5/10
// dpMainValve:=dpMainValve*2;
//+1*PF(dpPipe,pp,ActFlowSpeed/LBDelay)//coby
// nie przeszkadzal przy ladowaniu z zaworu obok
}
if (EQ(i_bcp, 0))
{
if ((TP > 2))
dpMainValve = dpMainValve * 1.5; //+0.5*PF(dpPipe,pp,ActFlowSpeed/LBDelay)//coby nie
// przeszkadzal przy ladowaniu z zaworu obok
if (EQ(i_bcp, -1)) {
if( TP < 5 ) { TP += dt; }
if( TP < 1 ) { TP -= 0.5 * dt; }
}
if (EQ(i_bcp, 0)) {
if( TP > 2 ) {
dpMainValve *= 1.5;
}
}
ep = dpPipe;
if ((EQ(i_bcp, 0) || (RP > ep)))
RP = RP + PF(RP, ep, 0.0007) * dt; // powolne wzrastanie, ale szybsze na jezdzie;
else
RP = RP + PF(RP, ep, 0.000093 / 2 * 2) * dt; // powolne wzrastanie i to bardzo
// jednak trzeba wydluzyc, bo
// obecnie zle dziala
if ((RP < ep) &&
(RP <
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
// potrzebny do napelnienia PG
if( ( EQ( i_bcp, 0 )
|| ( RP > ep ) ) ) {
// powolne wzrastanie, ale szybsze na jezdzie;
RP += PF( RP, ep, 0.0007 ) * dt;
}
else {
// powolne wzrastanie i to bardzo
RP += PF( RP, ep, 0.000093 / 2 * 2 ) * dt;
}
// jednak trzeba wydluzyc, bo obecnie zle dziala
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)))
{
DP = PF(0, PP, ActFlowSpeed / LBDelay);
if( ( EQ( i_bcp, i_bcpno ) )
|| ( EQ( i_bcp, -2 ) ) ) {
DP = PF( 0.0, PP, ActFlowSpeed / LBDelay );
dpMainValve = DP;
Sounds[s_fv4a_e] = DP;
Sounds[s_fv4a_u] = 0;
Sounds[s_fv4a_b] = 0;
Sounds[s_fv4a_x] = 0;
Sounds[s_fv4a_u] = 0.0;
Sounds[s_fv4a_b] = 0.0;
Sounds[s_fv4a_x] = 0.0;
}
else
{
if (dpMainValve > 0)
else {
if( dpMainValve > 0.0 ) {
Sounds[ s_fv4a_b ] = dpMainValve;
else
}
else {
Sounds[ s_fv4a_u ] = -dpMainValve;
}
}
return dpMainValve * dt;
}
@@ -2347,17 +2381,11 @@ double TFV4aM::GetPos(int i)
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
double i, j, k, l;
i = BPT[i_pos][1];
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;
return
BPT[i_pos][1]
+ (BPT[i_pos + 1][1] - BPT[i_pos][1]) * ((pos + 2) - i_pos); // interpolacja liniowa
}
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
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;
double LimPP;
@@ -2376,13 +2403,11 @@ double TMHZ_EN57::GetPF(double i_bcp, double PP, double HP, double dt, double ep
double ActFlowSpeed;
double DP;
double pom;
int i;
{
long i_end = 5;
for (i = 0; i < i_end; ++i)
Sounds[i] = 0;
for( int idx = 0; idx < 5; ++idx ) {
Sounds[ idx ] = 0;
}
DP = 0;
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
double ASBP = 0.0; //cisnienie hamulca pp
int BrakeStatus = 0; //flaga stanu
int BrakeStatus{ b_off }; //flaga stanu
int SoundFlag = 0;
public:
@@ -213,6 +213,8 @@ class TBrake {
void SetASBP( double const Press ); //ustalenie cisnienia pp
virtual void ForceEmptiness();
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
};

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ąć
i = iSkip; // domyślnie 0
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
pos1 = FastGetPoint(t); // wektor początku segmentu
dir = FastGetDirection(t, fOffset); // wektor kierunku

View File

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

View File

@@ -925,19 +925,17 @@ void TTrain::OnCommand_sandboxactivate( TTrain *Train, command_data const &Comma
return;
}
if( Command.action != GLFW_RELEASE ) {
// press or hold
Train->mvControlled->SandDose = true;
if( Command.action == GLFW_PRESS ) {
// press
Train->mvControlled->Sandbox( true );
// audio feedback
if( Train->ggSandButton.GetValue() < 0.05 ) {
Train->play_sound( Train->dsbSwitch );
}
// visual feedback
Train->ggSandButton.UpdateValue( 1.0 );
}
else {
else if( Command.action == GLFW_RELEASE) {
// release
Train->mvControlled->SandDose = false;
Train->mvControlled->Sandbox( false );
/*
// audio feedback
if( Train->ggAntiSlipButton.GetValue() > 0.5 ) {
@@ -4333,7 +4331,7 @@ bool TTrain::Update( double const Deltatime )
// if
// ((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
// hunter-121211: lampka zanikowo-pradowego wentylatorow:

View File

@@ -714,6 +714,9 @@ void TWorld::OnKeyDown(int cKey)
Train->OnKeyDown(cKey); // przekazanie klawisza do kabiny
if (FreeFlyModeFlag) // aby nie odluźniało wagonu za lokomotywą
{ // 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
{ // działa globalnie, sprawdzić zasięg
TDynamicObject *temp = Global::DynamicNearest();
@@ -721,7 +724,7 @@ void TWorld::OnKeyDown(int cKey)
{
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))
{
@@ -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
TDynamicObject *temp = Global::DynamicNearest();
if (temp)
@@ -1802,9 +1807,9 @@ TWorld::Update_UI() {
uitextline2 += ", BTP: " + to_string( tmp->MoverParameters->LoadFlag, 0 );
{
uitextline2 +=
"; pant. "
"; pant: "
+ to_string( tmp->MoverParameters->PantPress, 2 )
+ ( tmp->MoverParameters->bPantKurek3 ? "<ZG" : "|ZG" );
+ ( tmp->MoverParameters->bPantKurek3 ? "-ZG" : "|ZG" );
}
uitextline2 +=
@@ -1822,25 +1827,37 @@ TWorld::Update_UI() {
+ to_string( tmp->MoverParameters->TotalCurrent, 0 );
#ifdef EU07_USE_OLD_HVCOUPLERS
uitextline2 +=
", HV0: ("
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::outgoing ], 0 )
+ ")<-"
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::incoming ], 0 );
", HV0: "
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::voltage ], 0 )
+ "@"
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::front ][ TMoverParameters::hvcoupler::current ], 0 );
uitextline2 +=
", HV1: ("
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::outgoing ], 0 )
+ ")<-"
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::incoming ], 0 );
", HV1: "
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::voltage ], 0 )
+ "@"
+ to_string( tmp->MoverParameters->HVCouplers[ TMoverParameters::side::rear ][ TMoverParameters::hvcoupler::current ], 0 );
#else
auto const frontcouplerhighvoltage =
to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.voltage, 0 )
+ "@"
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.current, 0 );
auto const rearcouplerhighvoltage =
to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.voltage, 0 )
+ "@"
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.current, 0 );
uitextline2 += ", HV: ";
if( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.local == false ) {
uitextline2 +=
", HV: "
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.incoming, 0 )
+ "->("
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::front ].power_high.outgoing, 0 )
+ ")F" + (tmp->DirectionGet() ? "<<" : ">>") + "R("
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.outgoing, 0 )
+ ")<-"
+ to_string( tmp->MoverParameters->Couplers[ TMoverParameters::side::rear ].power_high.incoming, 0 );
"(" + frontcouplerhighvoltage + ")-"
+ ":F" + ( tmp->DirectionGet() ? "<<" : ">>" ) + "R:"
+ "-(" + rearcouplerhighvoltage + ")";
}
else {
uitextline2 +=
frontcouplerhighvoltage
+ ":F" + ( tmp->DirectionGet() ? "<<" : ">>" ) + "R:"
+ rearcouplerhighvoltage;
}
#endif
// equipment flags
uitextline3 = "";
@@ -1855,17 +1872,16 @@ TWorld::Update_UI() {
uitextline3 += ( tmp->MoverParameters->CompressorGovernorLock ? "!" : "." );
uitextline3 +=
" BP: " + to_string( tmp->MoverParameters->BrakePress, 2 )
+ " (" + to_string( tmp->MoverParameters->BrakeStatus, 0 )
+ "), LBP: " + to_string( tmp->MoverParameters->LocBrakePress, 2 )
+ ", PP: " + to_string( tmp->MoverParameters->PipePress, 2 )
" TrB: " + to_string( tmp->MoverParameters->BrakePress, 2 )
+ ", " + to_hex_str( tmp->MoverParameters->Hamulec->GetBrakeStatus(), 2 )
+ ", LcB: " + to_string( tmp->MoverParameters->LocBrakePress, 2 )
+ ", pipes: " + to_string( tmp->MoverParameters->PipePress, 2 )
+ "/" + to_string( tmp->MoverParameters->ScndPipePress, 2 )
+ "/" + to_string( tmp->MoverParameters->EqvtPipePress, 2 )
+ ", MT: " + to_string( tmp->MoverParameters->CompressedVolume, 3 )
+ ", BVP: " + to_string( tmp->MoverParameters->Volume, 3 )
+ ", " + to_string( tmp->MoverParameters->CntrlPipePress, 3 )
+ ", " + to_string( tmp->MoverParameters->Hamulec->GetCRP(), 3 )
+ ", " + to_string( tmp->MoverParameters->BrakeStatus, 0 );
+ ", BT: " + to_string( tmp->MoverParameters->Volume, 3 )
+ ", CtlP: " + to_string( tmp->MoverParameters->CntrlPipePress, 3 )
+ ", CtlT: " + to_string( tmp->MoverParameters->Hamulec->GetCRP(), 3 );
if( tmp->MoverParameters->ManualBrakePos > 0 ) {
@@ -2579,8 +2595,6 @@ world_environment::update() {
keylightintensity = sunlightlevel;
// diffuse (sun) intensity goes down after twilight, and reaches minimum 18 degrees below horizon
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;
keylightcolor = interpolate(
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_rightstick;
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;
float targetfactor;
if( framerate > 65.0 ) { targetsegments = 400; targetfactor = 3.0f; }
else if( framerate > 40.0 ) { targetsegments = 225; targetfactor = 1.5f; }
else if( framerate > 15.0 ) { targetsegments = 90; targetfactor = Global::ScreenHeight / 768.0f; }
if( framerate > 90.0 ) { targetsegments = 400; targetfactor = 3.0f; }
else if( framerate > 60.0 ) { targetsegments = 225; targetfactor = 1.5f; }
else if( framerate > 30.0 ) { targetsegments = 90; targetfactor = Global::ScreenHeight / 768.0f; }
else { targetsegments = 9; targetfactor = Global::ScreenHeight / 768.0f * 0.75f; }
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 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;
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