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

Merge branch 'tmj-dev' into milek-dev

This commit is contained in:
milek7
2019-09-15 21:24:15 +02:00
22 changed files with 1095 additions and 147 deletions

View File

@@ -1786,6 +1786,7 @@ void TController::Activation()
auto const localbrakelevel { mvOccupied->LocalBrakePosA }; auto const localbrakelevel { mvOccupied->LocalBrakePosA };
ZeroSpeed(); ZeroSpeed();
ZeroDirection(); ZeroDirection();
mvOccupied->SpringBrakeActivate(true);
if (TestFlag(d->MoverParameters->Couplers[iDirectionOrder < 0 ? 1 : 0].CouplingFlag, ctrain_controll)) { if (TestFlag(d->MoverParameters->Couplers[iDirectionOrder < 0 ? 1 : 0].CouplingFlag, ctrain_controll)) {
mvControlling->MainSwitch( false); // dezaktywacja czuwaka, jeśli przejście do innego członu mvControlling->MainSwitch( false); // dezaktywacja czuwaka, jeśli przejście do innego członu
mvOccupied->DecLocalBrakeLevel(LocalBrakePosNo); // zwolnienie hamulca w opuszczanym pojeździe mvOccupied->DecLocalBrakeLevel(LocalBrakePosNo); // zwolnienie hamulca w opuszczanym pojeździe
@@ -2108,12 +2109,18 @@ bool TController::CheckVehicles(TOrders user)
{ // sprawdzanie, czy jest głównym sterującym, żeby nie było konfliktu { // sprawdzanie, czy jest głównym sterującym, żeby nie było konfliktu
if (p->Mechanik) // jeśli ma obsadę if (p->Mechanik) // jeśli ma obsadę
if (p->Mechanik != this) // ale chodzi o inny pojazd, niż aktualnie sprawdzający if (p->Mechanik != this) // ale chodzi o inny pojazd, niż aktualnie sprawdzający
if (p->Mechanik->iDrivigFlags & movePrimary) // a tamten ma priorytet if( p->Mechanik->iDrivigFlags & movePrimary ) {
if ((iDrivigFlags & movePrimary) && (mvOccupied->DirAbsolute) && // a tamten ma priorytet
(mvOccupied->BrakeCtrlPos >= -1)) // jeśli rządzi i ma kierunek if( ( iDrivigFlags & movePrimary )
p->Mechanik->iDrivigFlags &= ~movePrimary; // dezaktywuje tamtego && ( mvOccupied->DirAbsolute )
else && ( mvOccupied->BrakeCtrlPos >= -1 ) ) {
// jeśli rządzi i ma kierunek
p->Mechanik->primary( false ); // dezaktywuje tamtego
}
else {
main = false; // nici z rządzenia main = false; // nici z rządzenia
}
}
++iVehicles; // jest jeden pojazd więcej ++iVehicles; // jest jeden pojazd więcej
pVehicles[1] = p; // zapamiętanie ostatniego pVehicles[1] = p; // zapamiętanie ostatniego
fLength += p->MoverParameters->Dim.L; // dodanie długości pojazdu fLength += p->MoverParameters->Dim.L; // dodanie długości pojazdu
@@ -2686,6 +2693,7 @@ bool TController::ReleaseEngine() {
} }
// gasimy światła // gasimy światła
Lights( 0, 0 ); Lights( 0, 0 );
mvOccupied->SpringBrakeActivate(true);
mvOccupied->BatterySwitch( false ); mvOccupied->BatterySwitch( false );
} }
} }
@@ -2997,6 +3005,9 @@ bool TController::IncSpeed()
// zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime) // zamykanie drzwi - tutaj wykonuje tylko AI (zmienia fActionTime)
Doors( false ); Doors( false );
} }
if (mvOccupied->SpringBrake.IsActive && mvOccupied->SpringBrake.Activate) {
mvOccupied->SpringBrakeActivate(false);
}
if( fActionTime < 0.0 ) { if( fActionTime < 0.0 ) {
// gdy jest nakaz poczekać z jazdą, to nie ruszać // gdy jest nakaz poczekać z jazdą, to nie ruszać
return false; return false;
@@ -3637,6 +3648,18 @@ void TController::SetTimeControllers()
} }
} }
} }
//6. UniversalBrakeButtons
//6.1. Checking flags for Over pressure
if (std::abs(BrakeCtrlPosition - gbh_FS)<0.5) {
UniversalBrakeButtons |= (TUniversalBrake::ub_HighPressure | TUniversalBrake::ub_Overload);
}
else {
UniversalBrakeButtons &= ~(TUniversalBrake::ub_HighPressure | TUniversalBrake::ub_Overload);
}
//6.2. Setting buttons
for (int i = 0; i < 3; i++) {
mvOccupied->UniversalBrakeButton(i, (UniversalBrakeButtons & mvOccupied->UniversalBrakeButtonFlag[i]));
}
}; };
void TController::CheckTimeControllers() void TController::CheckTimeControllers()
@@ -4761,7 +4784,7 @@ TController::UpdateSituation(double dt) {
// rozpoznaj komende bo lokomotywa jej nie rozpoznaje // rozpoznaj komende bo lokomotywa jej nie rozpoznaje
RecognizeCommand(); // samo czyta komendę wstawioną do pojazdu? RecognizeCommand(); // samo czyta komendę wstawioną do pojazdu?
} }
if( mvOccupied->SecuritySystem.Status > 1 ) { if( mvOccupied->SecuritySystem.Status != s_off ) {
// jak zadziałało CA/SHP // jak zadziałało CA/SHP
if( !mvOccupied->SecuritySystemReset() ) { // to skasuj if( !mvOccupied->SecuritySystemReset() ) { // to skasuj
if( ( /*mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 ) if( ( /*mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == 0 )
@@ -5875,6 +5898,8 @@ TController::UpdateSituation(double dt) {
// napełnianie uderzeniowe // napełnianie uderzeniowe
if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a ) if( ( mvOccupied->BrakeHandle == TBrakeHandle::FV4a )
|| ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P ) || ( mvOccupied->BrakeHandle == TBrakeHandle::MHZ_6P )
|| (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K5P)
|| (mvOccupied->BrakeHandle == TBrakeHandle::MHZ_K8P)
|| ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) { || ( mvOccupied->BrakeHandle == TBrakeHandle::M394 ) ) {
if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) { if( /*GBH mvOccupied->BrakeCtrlPos*/BrakeCtrlPosition == -2 ) {
@@ -5935,6 +5960,14 @@ TController::UpdateSituation(double dt) {
} }
} }
} }
// unlocking main pipe
if ((AccDesired > -0.03)
&& (true == mvOccupied->LockPipe)) {
UniversalBrakeButtons |= TUniversalBrake::ub_UnlockPipe;
}
else if (false == mvOccupied->LockPipe) {
UniversalBrakeButtons &= ~TUniversalBrake::ub_UnlockPipe;
}
#if LOGVELOCITY #if LOGVELOCITY
WriteLog("Dist=" + FloatToStrF(ActualProximityDist, ffFixed, 7, 1) + WriteLog("Dist=" + FloatToStrF(ActualProximityDist, ffFixed, 7, 1) +
", VelDesired=" + FloatToStrF(VelDesired, ffFixed, 7, 1) + ", VelDesired=" + FloatToStrF(VelDesired, ffFixed, 7, 1) +
@@ -6757,43 +6790,56 @@ void TController::UpdateDelayFlag() {
//-----------koniec skanowania semaforow //-----------koniec skanowania semaforow
void TController::TakeControl(bool yes) void TController::TakeControl( bool const Aidriver, bool const Forcevehiclecheck )
{ // przejęcie kontroli przez AI albo oddanie { // przejęcie kontroli przez AI albo oddanie
if (AIControllFlag == yes) if (AIControllFlag == Aidriver)
return; // już jest jak ma być return; // już jest jak ma być
if (yes) //żeby nie wykonywać dwa razy if (Aidriver) //żeby nie wykonywać dwa razy
{ // teraz AI prowadzi { // teraz AI prowadzi
AIControllFlag = AIdriver; AIControllFlag = AIdriver;
pVehicle->Controller = AIdriver; pVehicle->Controller = AIdriver;
iDirection = 0; // kierunek jazdy trzeba dopiero zgadnąć iDirection = 0; // kierunek jazdy trzeba dopiero zgadnąć
// gdy zgaszone światła, flaga podjeżdżania pod semafory pozostaje bez zmiany
// conditional below disabled to get around the situation where the AI train does nothing ever
// because it is waiting for orders which don't come until the engine is engaged, i.e. effectively never
if (OrderCurrentGet()) // jeśli coś robi
PrepareEngine(); // niech sprawdzi stan silnika
else // jeśli nic nie robi
if (pVehicle->iLights[ ( mvOccupied->CabNo < 0 ?
end::rear :
end::front ) ]
& (light::headlight_left | light::headlight_right | light::headlight_upper)) // któreś ze świateł zapalone?
{ // od wersji 357 oczekujemy podania komend dla AI przez scenerię
OrderNext(Prepare_engine);
if (pVehicle->iLights[mvOccupied->CabNo < 0 ? end::rear : end::front] & light::headlight_upper) // górne światło zapalone
OrderNext(Obey_train); // jazda pociągowa
else
OrderNext(Shunt); // jazda manewrowa
if (mvOccupied->Vel >= 1.0) // jeśli jedzie (dla 0.1 ma stać)
iDrivigFlags &= ~moveStopHere; // to ma nie czekać na sygnał, tylko jechać
else
iDrivigFlags |= moveStopHere; // a jak stoi, to niech czeka
}
CheckVehicles(); // ustawienie świateł
TableClear(); // ponowne utworzenie tabelki, bo człowiek mógł pojechać niezgodnie z sygnałami TableClear(); // ponowne utworzenie tabelki, bo człowiek mógł pojechać niezgodnie z sygnałami
if( action() != TAction::actSleep ) {
// gdy zgaszone światła, flaga podjeżdżania pod semafory pozostaje bez zmiany
// conditional below disabled to get around the situation where the AI train does nothing ever
// because it is waiting for orders which don't come until the engine is engaged, i.e. effectively never
if( OrderCurrentGet() ) {
// jeśli coś robi
PrepareEngine(); // niech sprawdzi stan silnika
}
else {
// jeśli nic nie robi
if( pVehicle->iLights[ ( mvOccupied->CabNo < 0 ?
end::rear :
end::front ) ]
& ( light::headlight_left | light::headlight_right | light::headlight_upper ) ) // któreś ze świateł zapalone?
{ // od wersji 357 oczekujemy podania komend dla AI przez scenerię
OrderNext( Prepare_engine );
if( pVehicle->iLights[ mvOccupied->CabNo < 0 ? end::rear : end::front ] & light::headlight_upper ) // górne światło zapalone
OrderNext( Obey_train ); // jazda pociągowa
else
OrderNext( Shunt ); // jazda manewrowa
if( mvOccupied->Vel >= 1.0 ) // jeśli jedzie (dla 0.1 ma stać)
iDrivigFlags &= ~moveStopHere; // to ma nie czekać na sygnał, tylko jechać
else
iDrivigFlags |= moveStopHere; // a jak stoi, to niech czeka
}
}
CheckVehicles(); // ustawienie świateł
}
} }
else else
{ // a teraz użytkownik { // a teraz użytkownik
AIControllFlag = Humandriver; AIControllFlag = Humandriver;
pVehicle->Controller = Humandriver; pVehicle->Controller = Humandriver;
if( eAction == TAction::actSleep ) {
eAction = TAction::actUnknown;
}
if( Forcevehiclecheck ) {
// update consist ownership and other consist data
CheckVehicles();
}
} }
}; };

View File

@@ -194,9 +194,13 @@ public:
public: public:
void UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę void UpdateSituation(double dt); // uruchamiac przynajmniej raz na sekundę
void MoveTo(TDynamicObject *to); void MoveTo(TDynamicObject *to);
void TakeControl(bool yes); void TakeControl(bool const Aidriver, bool const Forcevehiclecheck = false);
inline inline
bool Primary() const { bool primary( bool const Primary ) {
SetFlag( iDrivigFlags, ( Primary ? movePrimary : -movePrimary ) );
return primary(); }
inline
bool primary() const {
return ( ( iDrivigFlags & movePrimary ) != 0 ); }; return ( ( iDrivigFlags & movePrimary ) != 0 ); };
inline inline
TMoverParameters const *Controlling() const { TMoverParameters const *Controlling() const {
@@ -210,8 +214,11 @@ public:
inline inline
int Direction() const { int Direction() const {
return iDirection; } return iDirection; }
inline
TAction & action() {
return eAction; }
inline inline
TAction GetAction() { TAction const & action() const {
return eAction; } return eAction; }
private: private:
void Activation(); // umieszczenie obsady w odpowiednim członie void Activation(); // umieszczenie obsady w odpowiednim członie
@@ -256,6 +263,7 @@ public:
int iOverheadZero = 0; // suma bitowa jezdy bezprądowej, bity ustawiane przez pojazdy z podniesionymi pantografami int iOverheadZero = 0; // suma bitowa jezdy bezprądowej, bity ustawiane przez pojazdy z podniesionymi pantografami
int iOverheadDown = 0; // suma bitowa opuszczenia pantografów, bity ustawiane przez pojazdy z podniesionymi pantografami int iOverheadDown = 0; // suma bitowa opuszczenia pantografów, bity ustawiane przez pojazdy z podniesionymi pantografami
double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller double BrakeCtrlPosition = 0.0; // intermediate position of main brake controller
int UniversalBrakeButtons = 0.0; // flag of which universal buttons need to be pressed
int DizelPercentage = 0; // oczekiwane procenty jazdy/hamowania szynobusem int DizelPercentage = 0; // oczekiwane procenty jazdy/hamowania szynobusem
int DizelPercentage_Speed = 0; // oczekiwane procenty jazdy/hamowania szynobusem w związku z osiąganiem VelDesired int DizelPercentage_Speed = 0; // oczekiwane procenty jazdy/hamowania szynobusem w związku z osiąganiem VelDesired
private: private:

View File

@@ -982,8 +982,8 @@ void TDynamicObject::ABuLittleUpdate(double ObjSqrDist)
if( ( false == bDisplayCab ) // edge case, lowpoly may act as a stand-in for the hi-fi cab, so make sure not to show the driver when inside if( ( false == bDisplayCab ) // edge case, lowpoly may act as a stand-in for the hi-fi cab, so make sure not to show the driver when inside
&& ( Mechanik != nullptr ) && ( Mechanik != nullptr )
&& ( ( Mechanik->GetAction() != TAction::actSleep ) && ( ( Mechanik->action() != TAction::actSleep )
|| ( MoverParameters->Battery ) ) ) { /* || ( MoverParameters->Battery ) */ ) ) {
// rysowanie figurki mechanika // rysowanie figurki mechanika
btMechanik1.Turn( MoverParameters->ActiveCab > 0 ); btMechanik1.Turn( MoverParameters->ActiveCab > 0 );
btMechanik2.Turn( MoverParameters->ActiveCab < 0 ); btMechanik2.Turn( MoverParameters->ActiveCab < 0 );
@@ -2763,14 +2763,14 @@ bool TDynamicObject::Update(double dt, double dt1)
if (Mechanik) if (Mechanik)
{ // Ra 2F3F: do Driver.cpp to przenieść? { // Ra 2F3F: do Driver.cpp to przenieść?
MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG MoverParameters->EqvtPipePress = GetEPP(); // srednie cisnienie w PG
if ((Mechanik->Primary()) if ((Mechanik->primary())
&& (MoverParameters->EngineType == TEngineType::DieselEngine) && (MoverParameters->EngineType == TEngineType::DieselEngine)
&& (MoverParameters->EIMCtrlType > 0)) { && (MoverParameters->EIMCtrlType > 0)) {
MoverParameters->CheckEIMIC(dt1); MoverParameters->CheckEIMIC(dt1);
MoverParameters->eimic_real = MoverParameters->eimic; MoverParameters->eimic_real = MoverParameters->eimic;
MoverParameters->SendCtrlToNext("EIMIC", MoverParameters->eimic, MoverParameters->CabNo); MoverParameters->SendCtrlToNext("EIMIC", MoverParameters->eimic, MoverParameters->CabNo);
} }
if( ( Mechanik->Primary() ) if( ( Mechanik->primary() )
&& ( MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) ) { && ( MoverParameters->EngineType == TEngineType::ElectricInductionMotor ) ) {
// jesli glowny i z asynchronami, to niech steruje hamulcem i napedem lacznie dla calego pociagu/ezt // jesli glowny i z asynchronami, to niech steruje hamulcem i napedem lacznie dla calego pociagu/ezt
auto const kier = (DirectionGet() * MoverParameters->ActiveCab > 0); auto const kier = (DirectionGet() * MoverParameters->ActiveCab > 0);

View File

@@ -897,7 +897,7 @@ whois_event::run_() {
// jeśli typ pojazdu // jeśli typ pojazdu
// TODO: define and recognize individual request types // TODO: define and recognize individual request types
auto const owner { ( auto const owner { (
( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->Primary() ) ) ? ( ( m_activator->Mechanik != nullptr ) && ( m_activator->Mechanik->primary() ) ) ?
m_activator->Mechanik : m_activator->Mechanik :
m_activator->ctOwner ) }; m_activator->ctOwner ) };
auto const consistbrakelevel { ( auto const consistbrakelevel { (
@@ -952,7 +952,7 @@ whois_event::run_() {
} }
// +0 // +0
else if( m_activator->Mechanik ) { else if( m_activator->Mechanik ) {
if( m_activator->Mechanik->Primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera! if( m_activator->Mechanik->primary() ) { // tylko jeśli ktoś tam siedzi - nie powinno dotyczyć pasażera!
targetcell->UpdateValues( targetcell->UpdateValues(
m_activator->Mechanik->TrainName(), m_activator->Mechanik->TrainName(),
m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex(), // ile przystanków do końca m_activator->Mechanik->StationCount() - m_activator->Mechanik->StationIndex(), // ile przystanków do końca

View File

@@ -204,6 +204,7 @@ static int const dbrake_automatic = 8;
/*status czuwaka/SHP*/ /*status czuwaka/SHP*/
//hunter-091012: rozdzielenie alarmow, dodanie testu czuwaka //hunter-091012: rozdzielenie alarmow, dodanie testu czuwaka
static int const s_off = 0; //disabled
static int const s_waiting = 1; //działa static int const s_waiting = 1; //działa
static int const s_aware = 2; //czuwak miga static int const s_aware = 2; //czuwak miga
static int const s_active = 4; //SHP świeci static int const s_active = 4; //SHP świeci
@@ -305,6 +306,14 @@ enum TProblem // lista problemów taboru, które uniemożliwiają jazdę
pr_Ostatni = 0x80000000 // ostatnia flaga bitowa pr_Ostatni = 0x80000000 // ostatnia flaga bitowa
}; };
enum TCompressorList // lista parametrów w programatorze sprężarek
{ // pozycje kolejne
cl_Allow = 0, // zezwolenie na pracę sprężarek
cl_SpeedFactor = 1, // mnożnik wydajności
cl_MinFactor = 2, // mnożnik progu załącznika ciśnieniowego
cl_MaxFactor = 3 // mnożnik progu wyłącznika ciśnieniowego
};
/*ogolne*/ /*ogolne*/
/*lokacja*/ /*lokacja*/
struct TLocation struct TLocation
@@ -861,6 +870,31 @@ private:
float temperatura2 { 40.0 }; float temperatura2 { 40.0 };
}; };
struct spring_brake {
std::shared_ptr<TReservoir> Cylinder;
bool Activate { false }; //Input: switching brake on/off in exploitation - main valve/switch
bool ShuttOff { true }; //Input: shutting brake off during failure - valve in pneumatic container
bool Release { false }; //Input: emergency releasing rod
bool IsReady{ false }; //Output: readyness to braking - cylinder is armed, spring is tentioned
bool IsActive{ false }; //Output: brake is working
double SBP{ 0.0 }; //Output: pressure in spring brake cylinder
bool PNBrakeConnection{ false }; //Conf: connection to pneumatic brake cylinders
double MaxSetPressure { 0.0 }; //Conf: Maximal pressure for switched off brake
double ResetPressure{ 0.0 }; //Conf: Pressure for arming brake cylinder
double MinForcePressure{ 0.1 }; //Conf: Minimal pressure for zero force
double MaxBrakeForce{ 0.0 }; //Conf: Maximal tension for brake pads/shoes
double PressureOn{ -2.0 }; //Conf: Pressure changing ActiveFlag to "On"
double PressureOff{ -1.0 }; //Conf: Pressure changing ActiveFlag to "Off"
double ValveOffArea{ 0.0 }; //Conf: Area of filling valve
double ValveOnArea{ 0.0 }; //Conf: Area of dumping valve
double ValvePNBrakeArea{ 0.0 }; //Conf: Area of bypass to brake cylinders
int MultiTractionCoupler{ 127 }; //Conf: Coupling flag necessary for transmitting the command
};
public: public:
double dMoveLen = 0.0; double dMoveLen = 0.0;
@@ -920,11 +954,13 @@ public:
std::shared_ptr<TDriverHandle> LocHandle; std::shared_ptr<TDriverHandle> LocHandle;
std::shared_ptr<TReservoir> Pipe; std::shared_ptr<TReservoir> Pipe;
std::shared_ptr<TReservoir> Pipe2; std::shared_ptr<TReservoir> Pipe2;
spring_brake SpringBrake;
TLocalBrake LocalBrake = TLocalBrake::NoBrake; /*rodzaj hamulca indywidualnego*/ TLocalBrake LocalBrake = TLocalBrake::NoBrake; /*rodzaj hamulca indywidualnego*/
TBrakePressureTable BrakePressureTable; /*wyszczegolnienie cisnien w rurze*/ TBrakePressureTable BrakePressureTable; /*wyszczegolnienie cisnien w rurze*/
TBrakePressure BrakePressureActual; //wartości ważone dla aktualnej pozycji kranu TBrakePressure BrakePressureActual; //wartości ważone dla aktualnej pozycji kranu
int ASBType = 0; /*0: brak hamulca przeciwposlizgowego, 1: reczny, 2: automat*/ int ASBType = 0; /*0: brak hamulca przeciwposlizgowego, 1: reczny, 2: automat*/
int UniversalBrakeButtonFlag[3] = { 0, 0, 0 }; /* mozliwe działania przycisków hamulcowych */
int TurboTest = 0; int TurboTest = 0;
double MaxBrakeForce = 0.0; /*maksymalna sila nacisku hamulca*/ double MaxBrakeForce = 0.0; /*maksymalna sila nacisku hamulca*/
double MaxBrakePress[5]; //pomocniczy, proz, sred, lad, pp double MaxBrakePress[5]; //pomocniczy, proz, sred, lad, pp
@@ -962,6 +998,17 @@ public:
double MinCompressor = 0.0; double MinCompressor = 0.0;
double MaxCompressor = 0.0; double MaxCompressor = 0.0;
double CompressorSpeed = 0.0; double CompressorSpeed = 0.0;
int CompressorList[4][9]; // pozycje świateł, przód - tył, 1 .. 16
double EmergencyValveOn = 0.0;
double EmergencyValveOff = 0.0;
bool EmergencyValveOpen = false;
double EmergencyValveArea = 0.0;
double LockPipeOn = -1.0;
double LockPipeOff = -1.0;
double HandleUnlock = -3.0;
int CompressorListPosNo = 0;
int CompressorListDefPos = 1;
bool CompressorListWrap = false;
/*cisnienie wlaczania, zalaczania sprezarki, wydajnosc sprezarki*/ /*cisnienie wlaczania, zalaczania sprezarki, wydajnosc sprezarki*/
TBrakeDelayTable BrakeDelay; /*opoznienie hamowania/odhamowania t/o*/ TBrakeDelayTable BrakeDelay; /*opoznienie hamowania/odhamowania t/o*/
double AirLeakRate{ 0.01 }; // base rate of air leak from brake system components ( 0.001 = 1 l/sec ) double AirLeakRate{ 0.01 }; // base rate of air leak from brake system components ( 0.001 = 1 l/sec )
@@ -979,6 +1026,8 @@ public:
TSecuritySystem SecuritySystem; TSecuritySystem SecuritySystem;
TUniversalCtrlTable UniCtrlList; /*lista pozycji uniwersalnego nastawnika*/ TUniversalCtrlTable UniCtrlList; /*lista pozycji uniwersalnego nastawnika*/
int UniCtrlListSize = 0; /*wielkosc listy pozycji uniwersalnego nastawnika*/ int UniCtrlListSize = 0; /*wielkosc listy pozycji uniwersalnego nastawnika*/
bool UniCtrlIntegratedBrakePNCtrl = false; /*zintegrowany nastawnik JH obsluguje hamulec PN*/
bool UniCtrlIntegratedBrakeCtrl = false; /*zintegrowany nastawnik JH obsluguje hamowanie*/
/*-sekcja parametrow dla lokomotywy elektrycznej*/ /*-sekcja parametrow dla lokomotywy elektrycznej*/
TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/ TSchemeTable RList; /*lista rezystorow rozruchowych i polaczen silnikow, dla dizla: napelnienia*/
@@ -1169,6 +1218,9 @@ public:
double UnitBrakeForce = 0.0; /*!s siła hamowania przypadająca na jeden element*/ double UnitBrakeForce = 0.0; /*!s siła hamowania przypadająca na jeden element*/
double Ntotal = 0.0; /*!s siła nacisku klockow*/ double Ntotal = 0.0; /*!s siła nacisku klockow*/
bool SlippingWheels = false; bool SandDose = false; /*! poslizg kol, sypanie piasku*/ bool SlippingWheels = false; bool SandDose = false; /*! poslizg kol, sypanie piasku*/
bool SandDoseManual = false; /*piaskowanie reczne*/
bool SandDoseAuto = false; /*piaskowanie automatyczne*/
bool SandDoseAutoAllow = true; /*zezwolenie na automatyczne piaskowanie*/
double Sand = 0.0; /*ilosc piasku*/ double Sand = 0.0; /*ilosc piasku*/
double BrakeSlippingTimer = 0.0; /*pomocnicza zmienna do wylaczania przeciwposlizgu*/ double BrakeSlippingTimer = 0.0; /*pomocnicza zmienna do wylaczania przeciwposlizgu*/
double dpBrake = 0.0; double dpPipe = 0.0; double dpMainValve = 0.0; double dpLocalValve = 0.0; double dpBrake = 0.0; double dpPipe = 0.0; double dpMainValve = 0.0; double dpLocalValve = 0.0;
@@ -1212,11 +1264,14 @@ public:
int ManualBrakePos = 0; /*nastawa hamulca recznego*/ int ManualBrakePos = 0; /*nastawa hamulca recznego*/
double LocalBrakePosA = 0.0; /*nastawa hamulca pomocniczego*/ double LocalBrakePosA = 0.0; /*nastawa hamulca pomocniczego*/
double LocalBrakePosAEIM = 0.0; /*pozycja hamulca pomocniczego ep dla asynchronicznych ezt*/ double LocalBrakePosAEIM = 0.0; /*pozycja hamulca pomocniczego ep dla asynchronicznych ezt*/
bool UniversalBrakeButtonActive[3] = { false, false, false }; /* brake button pressed */
/* /*
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 AlarmChainFlag = false; // manual emergency brake bool AlarmChainFlag = false; // manual emergency brake
bool RadioStopFlag = false; /*hamowanie nagle*/ bool RadioStopFlag = false; /*hamowanie nagle*/
bool LockPipe = false; /*locking brake pipe in emergency state*/
bool UnlockPipe = false; /*unlockig brake pipe button pressed*/
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*/
int BrakeOpModeFlag = 0; /*nastawa trybu pracy PS/PN/EP/MED 1/2/4/8*/ int BrakeOpModeFlag = 0; /*nastawa trybu pracy PS/PN/EP/MED 1/2/4/8*/
@@ -1254,7 +1309,8 @@ public:
double MainsInitTimeCountdown{ 0.0 }; // current state of main circuit initialization, remaining time (in seconds) until it's ready double MainsInitTimeCountdown{ 0.0 }; // current state of main circuit initialization, remaining time (in seconds) until it's ready
int MainCtrlPos = 0; /*polozenie glownego nastawnika*/ int MainCtrlPos = 0; /*polozenie glownego nastawnika*/
int ScndCtrlPos = 0; /*polozenie dodatkowego nastawnika*/ int ScndCtrlPos = 0; /*polozenie dodatkowego nastawnika*/
int LightsPos = 0; int LightsPos = 0; /*polozenie przelacznika wielopozycyjnego swiatel*/
int CompressorListPos = 0; /*polozenie przelacznika wielopozycyjnego sprezarek*/
int ActiveDir = 0; //czy lok. jest wlaczona i w ktorym kierunku: int ActiveDir = 0; //czy lok. jest wlaczona i w ktorym kierunku:
//względem wybranej kabiny: -1 - do tylu, +1 - do przodu, 0 - wylaczona //względem wybranej kabiny: -1 - do tylu, +1 - do przodu, 0 - wylaczona
int MaxMainCtrlPosNoDirChange { 0 }; // can't change reverser state with master controller set above this position int MaxMainCtrlPosNoDirChange { 0 }; // can't change reverser state with master controller set above this position
@@ -1460,7 +1516,10 @@ public:
bool AddPulseForce(int Multipler);/*dla drezyny*/ bool AddPulseForce(int Multipler);/*dla drezyny*/
bool SandboxManual( bool const State, range_t const Notify = range_t::consist );/*wlacza/wylacza reczne sypanie piasku*/
bool SandboxAuto( bool const State, range_t const Notify = range_t::consist );/*wlacza/wylacza automatyczne sypanie piasku*/
bool Sandbox( bool const State, range_t const Notify = range_t::consist );/*wlacza/wylacza sypanie piasku*/ bool Sandbox( bool const State, range_t const Notify = range_t::consist );/*wlacza/wylacza sypanie piasku*/
bool SandboxAutoAllow(bool const State);/*wlacza/wylacza zezwolenie na automatyczne sypanie piasku*/
/*! zbijanie czuwaka/SHP*/ /*! zbijanie czuwaka/SHP*/
void SSReset(void); void SSReset(void);
@@ -1469,6 +1528,9 @@ public:
bool BatterySwitch(bool State); bool BatterySwitch(bool State);
bool EpFuseSwitch(bool State); bool EpFuseSwitch(bool State);
bool SpringBrakeActivate(bool State);
bool SpringBrakeShutOff(bool State);
bool SpringBrakeRelease();
/*! stopnie hamowania - hamulec zasadniczy*/ /*! stopnie hamowania - hamulec zasadniczy*/
bool IncBrakeLevelOld(void); bool IncBrakeLevelOld(void);
@@ -1483,6 +1545,7 @@ public:
bool AlarmChainSwitch( bool const State ); bool AlarmChainSwitch( bool const State );
bool AntiSlippingBrake(void); bool AntiSlippingBrake(void);
bool BrakeReleaser(int state); bool BrakeReleaser(int state);
bool UniversalBrakeButton(int button, int state); /*uniwersalny przycisk hamulca*/
bool SwitchEPBrake(int state); bool SwitchEPBrake(int state);
bool AntiSlippingButton(void); /*! reczny wlacznik urzadzen antyposlizgowych*/ bool AntiSlippingButton(void); /*! reczny wlacznik urzadzen antyposlizgowych*/
@@ -1498,6 +1561,7 @@ public:
void CompressorCheck(double dt);/*wlacza, wylacza kompresor, laduje zbiornik*/ void CompressorCheck(double dt);/*wlacza, wylacza kompresor, laduje zbiornik*/
void UpdatePantVolume(double dt); //Ra void UpdatePantVolume(double dt); //Ra
void UpdateScndPipePressure(double dt); void UpdateScndPipePressure(double dt);
void UpdateSpringBrake(double dt);
double GetDVc(double dt); double GetDVc(double dt);
/*funkcje obliczajace sily*/ /*funkcje obliczajace sily*/
@@ -1615,6 +1679,7 @@ private:
void LoadFIZ_Cntrl( std::string const &line ); void LoadFIZ_Cntrl( std::string const &line );
void LoadFIZ_Blending(std::string const &line); void LoadFIZ_Blending(std::string const &line);
void LoadFIZ_DCEMUED(std::string const &line); void LoadFIZ_DCEMUED(std::string const &line);
void LoadFIZ_SpringBrake(std::string const &line);
void LoadFIZ_Light( std::string const &line ); void LoadFIZ_Light( std::string const &line );
void LoadFIZ_Security( std::string const &line ); void LoadFIZ_Security( std::string const &line );
void LoadFIZ_Clima( std::string const &line ); void LoadFIZ_Clima( std::string const &line );
@@ -1628,6 +1693,7 @@ private:
void LoadFIZ_DList( std::string const &Input ); void LoadFIZ_DList( std::string const &Input );
void LoadFIZ_FFList( std::string const &Input ); void LoadFIZ_FFList( std::string const &Input );
void LoadFIZ_LightsList( std::string const &Input ); void LoadFIZ_LightsList( std::string const &Input );
void LoadFIZ_CompressorList(std::string const &Input);
void LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Input ); void LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Input );
TPowerType LoadFIZ_PowerDecode( std::string const &Power ); TPowerType LoadFIZ_PowerDecode( std::string const &Power );
TPowerSource LoadFIZ_SourceDecode( std::string const &Source ); TPowerSource LoadFIZ_SourceDecode( std::string const &Source );
@@ -1644,6 +1710,7 @@ private:
bool readFFList( std::string const &line ); bool readFFList( std::string const &line );
bool readWWList( std::string const &line ); bool readWWList( std::string const &line );
bool readLightsList( std::string const &Input ); bool readLightsList( std::string const &Input );
bool readCompressorList(std::string const &Input);
void BrakeValveDecode( std::string const &s ); //Q 20160719 void BrakeValveDecode( std::string const &s ); //Q 20160719
void BrakeSubsystemDecode(); //Q 20160719 void BrakeSubsystemDecode(); //Q 20160719
bool EIMDirectionChangeAllow( void ); bool EIMDirectionChangeAllow( void );

View File

@@ -295,6 +295,12 @@ ActiveCab( Cab )
for (int k = 0; k < 17; ++k) for (int k = 0; k < 17; ++k)
Lights[b][k] = 0; Lights[b][k] = 0;
for (int b = 0; b < 4; ++b)
for (int k = 1; k < 9; ++k)
CompressorList[ b ][ k ] = 0;
CompressorList[0][0] = 0.0;
CompressorList[1][0] = CompressorList[2][0] = CompressorList[3][0] = 1.0;
for (int b = -1; b <= MainBrakeMaxPos; ++b) for (int b = -1; b <= MainBrakeMaxPos; ++b)
{ {
BrakePressureTable[b].PipePressureVal = 0.0; BrakePressureTable[b].PipePressureVal = 0.0;
@@ -1051,7 +1057,10 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
if( velocitydifference > safevelocitylimit ) { if( velocitydifference > safevelocitylimit ) {
// HACK: crude estimation for potential derail, will take place with velocity difference > 15 km/h adjusted for vehicle mass ratio // HACK: crude estimation for potential derail, will take place with velocity difference > 15 km/h adjusted for vehicle mass ratio
WriteLog( "Bad driving: " + Name + " and " + othervehicle->Name + " collided with velocity " + to_string( velocitydifference, 0 ) + " km/h" ); if( ( false == TestFlag( DamageFlag, dtrain_out ) )
|| ( false == TestFlag( othervehicle->DamageFlag, dtrain_out ) ) ) {
WriteLog( "Bad driving: " + Name + " and " + othervehicle->Name + " collided with velocity " + to_string( velocitydifference, 0 ) + " km/h" );
}
if( velocitydifference > safevelocitylimit * ( TotalMass / othervehicle->TotalMass ) ) { if( velocitydifference > safevelocitylimit * ( TotalMass / othervehicle->TotalMass ) ) {
derail( 5 ); derail( 5 );
@@ -1084,12 +1093,14 @@ void TMoverParameters::CollisionDetect(int const End, double const dt)
void void
TMoverParameters::damage_coupler( int const End ) { TMoverParameters::damage_coupler( int const End ) {
auto &coupler{ Couplers[ End ] };
if( coupler.CouplerType == TCouplerType::Articulated ) { return; } // HACK: don't break articulated couplings no matter what
if( SetFlag( DamageFlag, dtrain_coupling ) ) if( SetFlag( DamageFlag, dtrain_coupling ) )
EventFlag = true; EventFlag = true;
auto &coupler { Couplers[ End ] }; if( ( coupler.CouplingFlag & coupling::brakehose ) == coupling::brakehose ) {
if( ( coupler.CouplingFlag & ctrain_pneumatic ) == ctrain_pneumatic ) {
// hamowanie nagle - zerwanie przewodow hamulcowych // hamowanie nagle - zerwanie przewodow hamulcowych
AlarmChainFlag = true; AlarmChainFlag = true;
} }
@@ -1100,11 +1111,11 @@ TMoverParameters::damage_coupler( int const End ) {
switch( End ) { switch( End ) {
// break connection with other vehicle, if there's any // break connection with other vehicle, if there's any
case 0: { case 0: {
coupler.Connected->Couplers[ end::rear ].CouplingFlag = 0; coupler.Connected->Couplers[ end::rear ].CouplingFlag = coupling::faux;
break; break;
} }
case 1: { case 1: {
coupler.Connected->Couplers[ end::front ].CouplingFlag = 0; coupler.Connected->Couplers[ end::front ].CouplingFlag = coupling::faux;
break; break;
} }
default: { default: {
@@ -2311,7 +2322,7 @@ bool TMoverParameters::CabDeactivisation(void)
CabNo = 0; CabNo = 0;
DirAbsolute = ActiveDir * CabNo; DirAbsolute = ActiveDir * CabNo;
DepartureSignal = false; // nie buczeć z nieaktywnej kabiny DepartureSignal = false; // nie buczeć z nieaktywnej kabiny
SecuritySystem.Status = 0; // deactivate alerter TODO: make it part of control based cab selection SecuritySystem.Status = s_off; // deactivate alerter TODO: make it part of control based cab selection
SendCtrlToNext("CabActivisation", 0, ActiveCab); // CabNo==0! SendCtrlToNext("CabActivisation", 0, ActiveCab); // CabNo==0!
} }
@@ -2346,6 +2357,63 @@ bool TMoverParameters::AddPulseForce(int Multipler)
return APF; return APF;
} }
// *************************************************************************************************
// yB: 20190909
// sypanie piasku reczne
// *************************************************************************************************
bool TMoverParameters::SandboxManual(bool const State, range_t const Notify)
{
bool result{ false };
if (SandDoseManual != State) {
if (SandDoseManual == false) {
// switch on
if (Sand > 0) {
SandDoseManual = true;
result = true;
}
}
else {
// switch off
SandDoseManual = false;
result = true;
}
}
Sandbox(SandDoseManual || SandDoseAuto, Notify);
return result;
}
// *************************************************************************************************
// yB: 20190909
// sypanie piasku automatyczne
// *************************************************************************************************
bool TMoverParameters::SandboxAuto(bool const State, range_t const Notify)
{
bool result{ false };
bool NewState = State && SandDoseAutoAllow;
if (SandDoseAuto != NewState) {
if (SandDoseAuto == false) {
// switch on
if (Sand > 0) {
SandDoseAuto = true;
result = true;
}
}
else {
// switch off
SandDoseAuto = false;
result = true;
}
}
Sandbox(SandDoseManual || SandDoseAuto, Notify);
return result;
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160713 // Q: 20160713
// sypanie piasku // sypanie piasku
@@ -2389,6 +2457,24 @@ bool TMoverParameters::Sandbox( bool const State, range_t const Notify )
return result; return result;
} }
// *************************************************************************************************
// yB: 20190909
// włączenie / wyłączenie automatycznej piasecznicy
// *************************************************************************************************
bool TMoverParameters::SandboxAutoAllow(bool State)
{
//SendCtrlToNext("SandboxAutoAllow", int(State), CabNo, ctrain_controll);
if (SandDoseAutoAllow != State)
{
SandDoseAutoAllow = State;
return true;
}
else
return false;
}
void TMoverParameters::SSReset(void) void TMoverParameters::SSReset(void)
{ // funkcja pomocnicza dla SecuritySystemReset - w Delphi Reset() { // funkcja pomocnicza dla SecuritySystemReset - w Delphi Reset()
SecuritySystem.SystemTimer = 0; SecuritySystem.SystemTimer = 0;
@@ -2456,7 +2542,7 @@ void TMoverParameters::SecuritySystemCheck(double dt)
RadiostopSwitch(false); RadiostopSwitch(false);
if ((SecuritySystem.SystemType > 0) if ((SecuritySystem.SystemType > 0)
&& (SecuritySystem.Status > 0) && (SecuritySystem.Status != s_off)
&& (Battery)) // Ra: EZT ma teraz czuwak w rozrządczym && (Battery)) // Ra: EZT ma teraz czuwak w rozrządczym
{ {
// CA // CA
@@ -2547,8 +2633,8 @@ bool TMoverParameters::BatterySwitch(bool State)
SendCtrlToNext("BatterySwitch", 0, CabNo); SendCtrlToNext("BatterySwitch", 0, CabNo);
BS = true; BS = true;
if ((Battery) && (ActiveCab != 0)) /*|| (TrainType==dt_EZT)*/ if ((Battery) && (ActiveCab != 0))
SecuritySystem.Status = (SecuritySystem.Status | s_waiting); // aktywacja czuwaka SecuritySystem.Status |= s_waiting; // aktywacja czuwaka
else else
SecuritySystem.Status = 0; // wyłączenie czuwaka SecuritySystem.Status = 0; // wyłączenie czuwaka
@@ -2572,6 +2658,57 @@ bool TMoverParameters::EpFuseSwitch(bool State)
// else SendCtrlToNext("EpFuseSwitch", 0, CabNo); // else SendCtrlToNext("EpFuseSwitch", 0, CabNo);
} }
// *************************************************************************************************
// yB: 20190906
// włączenie / wyłączenie hamulca sprezynowego
// *************************************************************************************************
bool TMoverParameters::SpringBrakeActivate(bool State)
{
if (Battery)
{
SendCtrlToNext("SpringBrakeActivate", int(State), CabNo, SpringBrake.MultiTractionCoupler);
if (SpringBrake.Activate != State)
{
SpringBrake.Activate = State;
return true;
}
}
return false;
}
// *************************************************************************************************
// yB: 20190906
// włączenie / wyłączenie odciecia hamulca sprezynowego
// *************************************************************************************************
bool TMoverParameters::SpringBrakeShutOff(bool State)
{
if (SpringBrake.ShuttOff != State)
{
SpringBrake.ShuttOff = State;
return true;
}
else
return false;
}
// *************************************************************************************************
// yB: 20190906
// wyluzowanie hamulca sprezynowego
// *************************************************************************************************
bool TMoverParameters::SpringBrakeRelease()
{
if (SpringBrake.IsReady && SpringBrake.Cylinder->P() < SpringBrake.MinForcePressure)
{
SpringBrake.IsReady = false;
return true;
}
else
return false;
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160710 // Q: 20160710
// kierunek do tyłu // kierunek do tyłu
@@ -3313,6 +3450,37 @@ bool TMoverParameters::BrakeReleaser(int state)
return OK; return OK;
} }
// *************************************************************************************************
// yB: 20160711
// włączenie / wyłączenie uniwersalnego przycisku hamulcowego
// *************************************************************************************************
bool TMoverParameters::UniversalBrakeButton(int button, int state)
{
bool OK = true; //false tylko jeśli nie uda się wysłać, GF 20161124
UniversalBrakeButtonActive[button] = state > 0;
int flag = 0;
if (Battery) {
for (int i = 0; i < 3; i++) {
flag = flag | (UniversalBrakeButtonActive[i] ? UniversalBrakeButtonFlag[i] : 0);
}
}
Hamulec->SetUniversalFlag(flag);
Handle->SetUniversalFlag(flag);
LocHandle->SetUniversalFlag(flag);
UnlockPipe = (flag & TUniversalBrake::ub_UnlockPipe) > 0;
//if the releaser can be activated by switch
if ( TestFlag ( UniversalBrakeButtonFlag[0] & UniversalBrakeButtonFlag[1] & UniversalBrakeButtonFlag[2],
TUniversalBrake::ub_Release ) )
{
Hamulec->Releaser( int ( TestFlag ( flag, TUniversalBrake::ub_Release ) ));
if (CabNo != 0) // rekurencyjne wysłanie do następnego
OK = SendCtrlToNext("BrakeReleaser", state, CabNo);
}
return OK;
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160711 // Q: 20160711
// włączenie / wyłączenie hamulca elektro-pneumatycznego // włączenie / wyłączenie hamulca elektro-pneumatycznego
@@ -3491,12 +3659,31 @@ void TMoverParameters::UpdateBrakePressure(double dt)
// TODO: clean the method up, a lot of the code is redundant // TODO: clean the method up, a lot of the code is redundant
void TMoverParameters::CompressorCheck(double dt) void TMoverParameters::CompressorCheck(double dt)
{ {
double MaxCompressorF = CompressorList[TCompressorList::cl_MaxFactor][CompressorListPos] * MaxCompressor;
double MinCompressorF = CompressorList[TCompressorList::cl_MinFactor][CompressorListPos] * MinCompressor;
double CompressorSpeedF = CompressorList[TCompressorList::cl_SpeedFactor][CompressorListPos] * CompressorSpeed;
double AllowFactor = CompressorList[TCompressorList::cl_Allow][CompressorListPos];
//checking the impact on the compressor allowance
if (AllowFactor > 0.5) {
CompressorAllow = AllowFactor > 1.5;
}
if( VeselVolume == 0.0 ) { return; } if( VeselVolume == 0.0 ) { return; }
//EmergencyValve
EmergencyValveOpen = (Compressor > (EmergencyValveOpen ? EmergencyValveOff : EmergencyValveOn));
if (EmergencyValveOpen) {
float dV = PF(0, Compressor, EmergencyValveArea)* dt;
CompressedVolume -= dV;
}
CompressedVolume = std::max( 0.0, CompressedVolume - dt * AirLeakRate * 0.1 ); // nieszczelności: 0.001=1l/s CompressedVolume = std::max( 0.0, CompressedVolume - dt * AirLeakRate * 0.1 ); // nieszczelności: 0.001=1l/s
if( ( true == CompressorGovernorLock ) if( ( true == CompressorGovernorLock )
&& ( Compressor < MinCompressor ) ) { && ( Compressor < MinCompressorF ) ) {
// if the pressure drops below the cut-in level, we can reset compressor governor // if the pressure drops below the cut-in level, we can reset compressor governor
// TBD, TODO: don't operate the lock without battery power? // TBD, TODO: don't operate the lock without battery power?
CompressorGovernorLock = false; CompressorGovernorLock = false;
@@ -3506,25 +3693,25 @@ void TMoverParameters::CompressorCheck(double dt)
CompressorAllow = ConverterAllow; CompressorAllow = ConverterAllow;
} }
if (MaxCompressor - MinCompressor < 0.0001) { if (MaxCompressorF - MinCompressorF < 0.0001) {
// TODO: investigate purpose of this branch and whether it can be removed as it duplicates later code // TODO: investigate purpose of this branch and whether it can be removed as it duplicates later code
if( ( true == CompressorAllow ) if( ( true == CompressorAllow )
&& ( true == CompressorAllowLocal ) && ( true == CompressorAllowLocal )
&& ( true == Mains ) && ( true == Mains )
&& ( MainCtrlPowerPos() > 0 ) ) { && ( MainCtrlPowerPos() > 0 ) ) {
if( Compressor < MaxCompressor ) { if( Compressor < MaxCompressorF ) {
if( ( EngineType == TEngineType::DieselElectric ) if( ( EngineType == TEngineType::DieselElectric )
&& ( CompressorPower > 0 ) ) { && ( CompressorPower > 0 ) ) {
CompressedVolume += CompressedVolume +=
CompressorSpeed CompressorSpeedF
* ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor * ( 2.0 * MaxCompressorF - Compressor ) / MaxCompressorF
* ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM ) * ( ( 60.0 * std::abs( enrot ) ) / DElist[ MainCtrlPosNo ].RPM )
* dt; * dt;
} }
else { else {
CompressedVolume += CompressedVolume +=
CompressorSpeed CompressorSpeedF
* ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor * ( 2.0 * MaxCompressorF - Compressor ) / MaxCompressorF
* dt; * dt;
TotalCurrent += 0.0015 * Voltage; // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę TotalCurrent += 0.0015 * Voltage; // tymczasowo tylko obciążenie sprężarki, tak z 5A na sprężarkę
} }
@@ -3576,7 +3763,7 @@ void TMoverParameters::CompressorCheck(double dt)
|| ( CompressorPower == 0 ) || ( CompressorPower == 0 )
|| ( CompressorPower == 3 ) ) ); || ( CompressorPower == 3 ) ) );
if( Compressor > MaxCompressor ) { if( Compressor > MaxCompressorF ) {
// wyłącznik ciśnieniowy jest niezależny od sposobu zasilania // wyłącznik ciśnieniowy jest niezależny od sposobu zasilania
// TBD, TODO: don't operate the lock without battery power? // TBD, TODO: don't operate the lock without battery power?
if( CompressorPower == 3 ) { if( CompressorPower == 3 ) {
@@ -3612,8 +3799,8 @@ void TMoverParameters::CompressorCheck(double dt)
else { else {
// jeśli nie załączona // jeśli nie załączona
if( ( LastSwitchingTime > CtrlDelay ) if( ( LastSwitchingTime > CtrlDelay )
&& ( ( Compressor < MinCompressor ) && ( ( Compressor < MinCompressorF )
|| ( ( Compressor < MaxCompressor ) || ( ( Compressor < MaxCompressorF )
&& ( false == CompressorGovernorLock ) ) ) ) { && ( false == CompressorGovernorLock ) ) ) ) {
// załączenie przy małym ciśnieniu // załączenie przy małym ciśnieniu
// jeśli nie załączona, a ciśnienie za małe // jeśli nie załączona, a ciśnienie za małe
@@ -3688,7 +3875,7 @@ void TMoverParameters::CompressorCheck(double dt)
1.0 ) }; // shouldn't ever get here but, eh 1.0 ) }; // shouldn't ever get here but, eh
CompressedVolume += CompressedVolume +=
CompressorSpeed CompressorSpeed
* ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor * ( 2.0 * MaxCompressorF - Compressor ) / MaxCompressorF
* enginefactor * enginefactor
* dt; * dt;
} }
@@ -3702,8 +3889,8 @@ void TMoverParameters::CompressorCheck(double dt)
else { else {
// the compressor is a stand-alone device, working at steady pace // the compressor is a stand-alone device, working at steady pace
CompressedVolume += CompressedVolume +=
CompressorSpeed CompressorSpeedF
* ( 2.0 * MaxCompressor - Compressor ) / MaxCompressor * ( 2.0 * MaxCompressorF - Compressor ) / MaxCompressorF
* dt; * dt;
if( ( CompressorPower == 5 ) && ( Couplers[ 1 ].Connected != NULL ) ) { if( ( CompressorPower == 5 ) && ( Couplers[ 1 ].Connected != NULL ) ) {
@@ -3752,11 +3939,17 @@ void TMoverParameters::UpdatePipePressure(double dt)
dpLocalValve = LocHandle->GetPF(std::max(LocalBrakePosA, LocalBrakePosAEIM), Hamulec->GetBCP(), ScndPipePress, dt, 0); dpLocalValve = LocHandle->GetPF(std::max(LocalBrakePosA, LocalBrakePosAEIM), Hamulec->GetBCP(), ScndPipePress, dt, 0);
else else
dpLocalValve = LocHandle->GetPF(LocalBrakePosAEIM, Hamulec->GetBCP(), ScndPipePress, dt, 0); dpLocalValve = LocHandle->GetPF(LocalBrakePosAEIM, Hamulec->GetBCP(), ScndPipePress, dt, 0);
if( ( BrakeHandle == TBrakeHandle::FV4a )
&& ( ( PipePress < 2.75 ) LockPipe = PipePress < (LockPipe ? LockPipeOff : LockPipeOn);
&& ( ( Hamulec->GetStatus() & b_rls ) == 0 ) ) bool lock_new = (LockPipe && !UnlockPipe && (BrakeCtrlPosR > HandleUnlock)); //new simple codition based on .fiz
&& ( BrakeSubsystem == TBrakeSubSystem::ss_LSt ) bool lock_old = ((BrakeHandle == TBrakeHandle::FV4a) //old complex condition based on assumptions
&& ( TrainType != dt_EZT ) ) { && ((PipePress < 2.75)
&& ((Hamulec->GetStatus() & b_rls) == 0))
&& (BrakeSubsystem == TBrakeSubSystem::ss_LSt)
&& (TrainType != dt_EZT)
&& (!UnlockPipe));
if( ( lock_old ) || ( lock_new ) ) {
temp = PipePress + 0.00001; temp = PipePress + 0.00001;
} }
else { else {
@@ -3985,6 +4178,8 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
TMoverParameters *c; TMoverParameters *c;
double dv1, dv2, dV; double dv1, dv2, dV;
UpdateSpringBrake(dt);
dv1 = 0; dv1 = 0;
dv2 = 0; dv2 = 0;
@@ -4037,6 +4232,37 @@ void TMoverParameters::UpdateScndPipePressure(double dt)
} }
} }
// *************************************************************************************************
// yB: 20190906
// Aktualizacja ciśnienia w hamulcu sprezynowym
// *************************************************************************************************
void TMoverParameters::UpdateSpringBrake(double dt)
{
double BP = SpringBrake.PNBrakeConnection ? BrakePress : 0;
double MSP = SpringBrake.ShuttOff ? 0 : SpringBrake.MaxSetPressure;
if (!SpringBrake.Activate)
{
double desired_press = std::min(std::max(MSP, BP), Pipe2->P());
double dv = PF(desired_press, SpringBrake.SBP, SpringBrake.ValveOffArea);
SpringBrake.Cylinder->Flow(-dv);
Pipe2->Flow(std::max(dv,0.0));
}
else
{
double dv = PF(BP, SpringBrake.SBP, SpringBrake.ValveOnArea);
SpringBrake.Cylinder->Flow(-dv);
}
if (SpringBrake.SBP > SpringBrake.ResetPressure)
SpringBrake.IsReady = true;
SpringBrake.IsActive = SpringBrake.SBP < (SpringBrake.IsActive ? SpringBrake.PressureOff : SpringBrake.PressureOn);
SpringBrake.Release = false;
SpringBrake.Cylinder->Act();
SpringBrake.SBP = SpringBrake.Cylinder->P();
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160715 // Q: 20160715
// oblicza i zwraca przepływ powietrza pomiędzy pojazdami // oblicza i zwraca przepływ powietrza pomiędzy pojazdami
@@ -4378,6 +4604,9 @@ double TMoverParameters::BrakeForce( TTrackParam const &Track ) {
K = MaxBrakeForce * ManualBrakeRatio(); K = MaxBrakeForce * ManualBrakeRatio();
} }
if (SpringBrake.IsReady)
K += std::max(0.0, SpringBrake.MinForcePressure - SpringBrake.Cylinder->P()) * SpringBrake.MaxBrakeForce;
u = ((BrakePress * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj; u = ((BrakePress * P2FTrans) - BrakeCylSpring) * BrakeCylMult[0] - BrakeSlckAdj;
if (u * BrakeRigEff > Ntotal) // histereza na nacisku klockow if (u * BrakeRigEff > Ntotal) // histereza na nacisku klockow
Ntotal = u * BrakeRigEff; Ntotal = u * BrakeRigEff;
@@ -5425,11 +5654,11 @@ double TMoverParameters::TractionForce( double dt ) {
if( ( SlippingWheels ) ) { if( ( SlippingWheels ) ) {
PosRatio = 0; PosRatio = 0;
tmp = 10; tmp = 10;
Sandbox( true, range_t::unit ); SandboxAuto( true, range_t::unit );
} // przeciwposlizg } // przeciwposlizg
else { else {
// switch sandbox off // switch sandbox off
Sandbox( false, range_t::unit ); SandboxAuto( false, range_t::unit );
} }
eimv_pr += Max0R(Min0R(PosRatio - eimv_pr, 0.02), -0.02) * 12 * eimv_pr += Max0R(Min0R(PosRatio - eimv_pr, 0.02), -0.02) * 12 *
@@ -6341,17 +6570,20 @@ void TMoverParameters::CheckEIMIC(double dt)
} }
break; break;
case 3: case 3:
if ((UniCtrlList[MainCtrlPos].mode != BrakeCtrlPos) && (MainCtrlActualPos == MainCtrlPos)) //there was no move of controller, but brake only if (UniCtrlIntegratedBrakePNCtrl)
{ {
if (BrakeCtrlPos < UniCtrlList[MainCtrlPosNo].mode) if ((UniCtrlList[MainCtrlPos].mode != BrakeCtrlPos) && (MainCtrlActualPos == MainCtrlPos)) //there was no move of controller, but brake only
BrakeLevelSet(UniCtrlList[MainCtrlPosNo].mode); //bottom clamping {
if (BrakeCtrlPos > UniCtrlList[0].mode) if (BrakeCtrlPos < UniCtrlList[MainCtrlPosNo].mode)
BrakeLevelSet(UniCtrlList[0].mode); //top clamping BrakeLevelSet(UniCtrlList[MainCtrlPosNo].mode); //bottom clamping
while (BrakeCtrlPos > UniCtrlList[MainCtrlPos].mode) DecMainCtrl(1); //find nearest position if (BrakeCtrlPos > UniCtrlList[0].mode)
while (BrakeCtrlPos < UniCtrlList[MainCtrlPos].mode) IncMainCtrl(1); //find nearest position BrakeLevelSet(UniCtrlList[0].mode); //top clamping
while (BrakeCtrlPos > UniCtrlList[MainCtrlPos].mode) DecMainCtrl(1); //find nearest position
while (BrakeCtrlPos < UniCtrlList[MainCtrlPos].mode) IncMainCtrl(1); //find nearest position
}
else //controller was moved
BrakeLevelSet(UniCtrlList[MainCtrlPos].mode);
} }
else //controller was moved
BrakeLevelSet(UniCtrlList[MainCtrlPos].mode);
if ((MainCtrlActualPos != MainCtrlPos) || (LastRelayTime>InitialCtrlDelay)) if ((MainCtrlActualPos != MainCtrlPos) || (LastRelayTime>InitialCtrlDelay))
{ {
@@ -6368,12 +6600,17 @@ void TMoverParameters::CheckEIMIC(double dt)
} }
if (Hamulec->GetEDBCP() > 0.3 && eimic < 0) //when braking with pneumatic brake if (Hamulec->GetEDBCP() > 0.3 && eimic < 0) //when braking with pneumatic brake
eimic = 0; //shut off retarder eimic = 0; //shut off retarder
if (UniCtrlIntegratedBrakeCtrl == false)
{
eimic = (LocalBrakeRatio() > 0.01 ? -LocalBrakeRatio() : eimic);
}
} }
auto const eimicpowerenabled { auto const eimicpowerenabled {
( ( true == Mains ) || ( Power == 0.0 ) ) ( ( true == Mains ) || ( Power == 0.0 ) )
&& ( ( Doors.instances[ side::left ].open_permit == false ) && ( ( Doors.instances[ side::left ].open_permit == false )
&& ( Doors.instances[ side::right ].open_permit == false ) ) }; && ( Doors.instances[ side::right ].open_permit == false ) )
&& ( !SpringBrake.IsActive ) };
eimic = clamp(eimic, -1.0, eimicpowerenabled ? 1.0 : 0.0); eimic = clamp(eimic, -1.0, eimicpowerenabled ? 1.0 : 0.0);
} }
@@ -7727,6 +7964,7 @@ bool startMPT, startMPT0;
bool startRLIST, startUCLIST; bool startRLIST, startUCLIST;
bool startDLIST, startFFLIST, startWWLIST; bool startDLIST, startFFLIST, startWWLIST;
bool startLIGHTSLIST; bool startLIGHTSLIST;
bool startCOMPRESSORLIST;
int LISTLINE; int LISTLINE;
bool issection( std::string const &Name, std::string const &Input ) { bool issection( std::string const &Name, std::string const &Input ) {
@@ -8026,12 +8264,33 @@ bool TMoverParameters::readLightsList( std::string const &Input ) {
return false; return false;
} }
parser parser
>> Lights[ 0 ][ idx ] >> Lights[0][idx]
>> Lights[ 1 ][ idx ]; >> Lights[1][idx];
return true; return true;
} }
bool TMoverParameters::readCompressorList(std::string const &Input) {
cParser parser(Input);
if (false == parser.getTokens(4, false)) {
WriteLog("Read CompressorList: arguments missing in line " + std::to_string(LISTLINE + 1));
return false;
}
int idx = LISTLINE++;
if (idx > 8) {
WriteLog("Read CompressorList: number of entries exceeded capacity of the data table");
return false;
}
parser
>> CompressorList[ 0 ][ idx + 1 ]
>> CompressorList[ 1 ][ idx + 1 ]
>> CompressorList[ 2 ][ idx + 1 ]
>> CompressorList[ 3 ][ idx + 1 ];
return true;
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160719 // Q: 20160719
// ************************************************************************************************* // *************************************************************************************************
@@ -8138,6 +8397,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
startFFLIST = false; startFFLIST = false;
startWWLIST = false; startWWLIST = false;
startLIGHTSLIST = false; startLIGHTSLIST = false;
startCOMPRESSORLIST = false;
std::string file = chkpath + TypeName + ".fiz"; std::string file = chkpath + TypeName + ".fiz";
WriteLog("LOAD FIZ FROM " + file); WriteLog("LOAD FIZ FROM " + file);
@@ -8226,6 +8486,11 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
startLIGHTSLIST = false; startLIGHTSLIST = false;
continue; continue;
} }
if ( issection( "endCL", inputline ) ) {
startBPT = false;
startCOMPRESSORLIST = false;
continue;
}
// ...then all recognized sections... // ...then all recognized sections...
if( issection( "Param.", inputline ) ) if( issection( "Param.", inputline ) )
{ {
@@ -8317,7 +8582,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("Blending:", inputline)) { if (issection("Blending:", inputline)) {
startBPT = true; LISTLINE = 0; startBPT = false; LISTLINE = 0;
fizlines.emplace( "Blending", inputline); fizlines.emplace( "Blending", inputline);
LoadFIZ_Blending( inputline ); LoadFIZ_Blending( inputline );
continue; continue;
@@ -8325,12 +8590,20 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
if (issection("DCEMUED:", inputline)) { if (issection("DCEMUED:", inputline)) {
startBPT = true; LISTLINE = 0; startBPT = false; LISTLINE = 0;
fizlines.emplace("DCEMUED", inputline); fizlines.emplace("DCEMUED", inputline);
LoadFIZ_DCEMUED(inputline); LoadFIZ_DCEMUED(inputline);
continue; continue;
} }
if (issection("SpringBrake:", inputline)) {
startBPT = false; LISTLINE = 0;
fizlines.emplace("SpringBrake", inputline);
LoadFIZ_SpringBrake(inputline);
continue;
}
if( issection( "Light:", inputline ) ) { if( issection( "Light:", inputline ) ) {
startBPT = false; startBPT = false;
@@ -8449,6 +8722,14 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
continue; continue;
} }
if (issection("CompressorList:", inputline)) {
startBPT = false;
fizlines.emplace("CompressorList", inputline);
startCOMPRESSORLIST = true; LISTLINE = 0;
LoadFIZ_CompressorList( inputline );
continue;
}
// ...and finally, table parsers. // ...and finally, table parsers.
// NOTE: once table parsing is enabled it lasts until switched off, when another section is recognized // NOTE: once table parsing is enabled it lasts until switched off, when another section is recognized
if( true == startBPT ) { if( true == startBPT ) {
@@ -8487,6 +8768,10 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
readLightsList( inputline ); readLightsList( inputline );
continue; continue;
} }
if (true == startCOMPRESSORLIST) {
readCompressorList(inputline);
continue;
}
} // while line } // while line
/* /*
in.close(); in.close();
@@ -8728,6 +9013,15 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
extract_value( MinCompressor, "MinCP", line, "" ); extract_value( MinCompressor, "MinCP", line, "" );
extract_value( MaxCompressor, "MaxCP", line, "" ); extract_value( MaxCompressor, "MaxCP", line, "" );
extract_value( CompressorSpeed, "CompressorSpeed", line, "" ); extract_value( CompressorSpeed, "CompressorSpeed", line, "" );
extract_value( EmergencyValveOff, "MinEVP", line, "" );
extract_value( EmergencyValveOn, "MaxEVP", line, "" );
extract_value( EmergencyValveArea, "EVArea", line, "" );
extract_value( UniversalBrakeButtonFlag[0], "UBB1", line, "");
extract_value( UniversalBrakeButtonFlag[1], "UBB2", line, "");
extract_value( UniversalBrakeButtonFlag[2], "UBB3", line, "");
extract_value( LockPipeOn, "LPOn", line, "-1");
extract_value( LockPipeOff, "LPOff", line, "-1");
extract_value( HandleUnlock, "HandlePipeUnlockPos", line, "-3");
{ {
std::map<std::string, int> compressorpowers{ std::map<std::string, int> compressorpowers{
{ "Main", 0 }, { "Main", 0 },
@@ -9198,6 +9492,30 @@ void TMoverParameters::LoadFIZ_DCEMUED(std::string const &line) {
} }
void TMoverParameters::LoadFIZ_SpringBrake(std::string const &line) {
double vol;
extract_value(vol, "Volume", line, "1");
if (!SpringBrake.Cylinder)
SpringBrake.Cylinder = std::make_shared<TReservoir>();
SpringBrake.Cylinder->CreateCap(vol);
extract_value(SpringBrake.MaxBrakeForce, "MBF", line, "");
extract_value(SpringBrake.MaxSetPressure, "MaxSP", line, "");
extract_value(SpringBrake.ResetPressure, "ResetP", line, "");
extract_value(SpringBrake.MinForcePressure, "MinFP", line, "");
extract_value(SpringBrake.PressureOff, "PressOff", line, "");
extract_value(SpringBrake.PressureOn, "PressOn", line, "");
extract_value(SpringBrake.ValveOffArea, "ValveOnArea", line, "");
extract_value(SpringBrake.ValveOnArea, "ValveOffArea", line, "");
extract_value(SpringBrake.ValvePNBrakeArea, "ValvePNBArea", line, "");
SpringBrake.PNBrakeConnection = SpringBrake.ValvePNBrakeArea > 0;
extract_value(SpringBrake.MultiTractionCoupler, "MTC", line, "");
SpringBrake.ShuttOff = false;
SpringBrake.Activate = false;
SpringBrake.IsReady = true;
}
void TMoverParameters::LoadFIZ_Light( std::string const &line ) { void TMoverParameters::LoadFIZ_Light( std::string const &line ) {
LightPowerSource.SourceType = LoadFIZ_SourceDecode( extract_value( "Light", line ) ); LightPowerSource.SourceType = LoadFIZ_SourceDecode( extract_value( "Light", line ) );
@@ -9543,6 +9861,8 @@ void TMoverParameters::LoadFIZ_RList( std::string const &Input ) {
void TMoverParameters::LoadFIZ_UCList(std::string const &Input) { void TMoverParameters::LoadFIZ_UCList(std::string const &Input) {
extract_value(UniCtrlListSize, "Size", Input, ""); extract_value(UniCtrlListSize, "Size", Input, "");
UniCtrlIntegratedBrakeCtrl = (extract_value("IntegratedBrake", Input) == "Yes");
UniCtrlIntegratedBrakePNCtrl = (extract_value("IntegratedBrakePN", Input) == "Yes");
} }
@@ -9573,6 +9893,13 @@ void TMoverParameters::LoadFIZ_LightsList( std::string const &Input ) {
extract_value( LightsDefPos, "Default", Input, "" ); extract_value( LightsDefPos, "Default", Input, "" );
} }
void TMoverParameters::LoadFIZ_CompressorList(std::string const &Input) {
extract_value( CompressorListPosNo, "Size", Input, "" );
extract_value( CompressorListWrap, "Wrap", Input, "" );
extract_value( CompressorListDefPos, "Default", Input, "" );
}
void TMoverParameters::LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Line ) { void TMoverParameters::LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Line ) {
switch( Powerparameters.SourceType ) { switch( Powerparameters.SourceType ) {
@@ -9930,9 +10257,16 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
Pipe2 = std::make_shared<TReservoir>(); // zabezpieczenie, bo sie PG wywala... :( Pipe2 = std::make_shared<TReservoir>(); // zabezpieczenie, bo sie PG wywala... :(
Pipe->CreateCap( ( std::max( Dim.L, 14.0 ) + 0.5 ) * Spg * 1 ); // dlugosc x przekroj x odejscia i takie tam Pipe->CreateCap( ( std::max( Dim.L, 14.0 ) + 0.5 ) * Spg * 1 ); // dlugosc x przekroj x odejscia i takie tam
Pipe2->CreateCap( ( std::max( Dim.L, 14.0 ) + 0.5 ) * Spg * 1 ); Pipe2->CreateCap( ( std::max( Dim.L, 14.0 ) + 0.5 ) * Spg * 1 );
if (!SpringBrake.Cylinder)
{
SpringBrake.Cylinder = std::make_shared<TReservoir>();
SpringBrake.Cylinder->CreateCap(1);
}
if( LightsPosNo > 0 ) if( LightsPosNo > 0 )
LightsPos = LightsDefPos; LightsPos = LightsDefPos;
if (CompressorListPosNo > 0)
CompressorListPos = CompressorListDefPos;
// NOTE: legacy compatibility behaviour for vehicles without defined heating power source // NOTE: legacy compatibility behaviour for vehicles without defined heating power source
if( ( EnginePowerSource.SourceType == TPowerSource::CurrentCollector ) if( ( EnginePowerSource.SourceType == TPowerSource::CurrentCollector )
@@ -10412,10 +10746,13 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
Battery = true; Battery = true;
else if ((CValue1 == 0)) else if ((CValue1 == 0))
Battery = false; Battery = false;
if ((Battery) && (ActiveCab != 0) /*or (TrainType=dt_EZT)*/) /*
// TBD: makes no sense to activate alerters in entire consist
if ((Battery) && (ActiveCab != 0) )
SecuritySystem.Status = SecuritySystem.Status | s_waiting; // aktywacja czuwaka SecuritySystem.Status = SecuritySystem.Status | s_waiting; // aktywacja czuwaka
else else
SecuritySystem.Status = 0; // wyłączenie czuwaka SecuritySystem.Status = 0; // wyłączenie czuwaka
*/
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
} }
// else if command='EpFuseSwitch' then {NBMX} // else if command='EpFuseSwitch' then {NBMX}
@@ -10698,6 +11035,16 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
ScndCtrlActualPos = static_cast<int>(round(CValue1)); ScndCtrlActualPos = static_cast<int>(round(CValue1));
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype); OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
} }
else if (Command == "SpringBrakeActivate")
{
if (Battery)
{
SpringBrake.Activate = CValue1 > 0;
OK = SendCtrlToNext(Command, CValue1, CValue2, Couplertype);
}
else
OK = true;
}
return OK; // dla true komenda będzie usunięta, dla false wykonana ponownie return OK; // dla true komenda będzie usunięta, dla false wykonana ponownie
} }

View File

@@ -1300,7 +1300,9 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel )
SoundFlag |= sf_CylU; SoundFlag |= sf_CylU;
} }
// equivalent of checkreleaser() in the base class? // equivalent of checkreleaser() in the base class?
if( ( BrakeStatus & b_rls ) == b_rls ) { bool is_releasing = ( ( BrakeStatus & b_rls)
|| ( UniversalFlag & TUniversalBrake::ub_Release ) );
if ( is_releasing ) {
if( CVP < 0.0 ) { if( CVP < 0.0 ) {
BrakeStatus &= ~b_rls; BrakeStatus &= ~b_rls;
} }
@@ -1373,9 +1375,12 @@ double TLSt::GetPF( double const PP, double const dt, double const Vel )
temp = 1 - RapidTemp; temp = 1 - RapidTemp;
if (EDFlag > 0.2) if (EDFlag > 0.2)
temp = 10000; temp = 10000;
double tempasb = 0;
if ( ( (UniversalFlag & TUniversalBrake::ub_AntiSlipBrake) > 0)
|| ( (BrakeStatus & b_asb_unbrake) == b_asb_unbrake ) )
tempasb = ASBP;
// powtarzacz — podwojny zawor zwrotny // powtarzacz — podwojny zawor zwrotny
temp = Max0R(((CVP - BCP) * BVM + ASBP * int((BrakeStatus & b_asb_unbrake) == b_asb_unbrake)) / temp, LBP); temp = Max0R( ( (CVP - BCP) * BVM + tempasb ) / temp, LBP );
// luzowanie CH // luzowanie CH
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
@@ -1556,6 +1561,10 @@ double TEStED::GetPF( double const PP, double const dt, double const Vel )
// powtarzacz — podwojny zawor zwrotny // powtarzacz — podwojny zawor zwrotny
temp = Max0R(LoadC * BCP / temp * Min0R(Max0R(1 - EDFlag, 0), 1), LBP); temp = Max0R(LoadC * BCP / temp * Min0R(Max0R(1 - EDFlag, 0), 1), LBP);
if ( ( UniversalFlag & TUniversalBrake::ub_AntiSlipBrake ) > 0 )
temp = std::max(temp, ASBP);
double speed = 1; double speed = 1;
if ((ASBP < 0.1) && ((BrakeStatus & b_asb_unbrake) == b_asb_unbrake)) if ((ASBP < 0.1) && ((BrakeStatus & b_asb_unbrake) == b_asb_unbrake))
{ {
@@ -2292,6 +2301,11 @@ void TDriverHandle::OvrldButton(bool Active)
{ {
ManualOvrldActive = Active; ManualOvrldActive = Active;
} }
void TDriverHandle::SetUniversalFlag(int flag)
{
UniversalFlag = flag;
}
//---FV4a--- //---FV4a---
double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep) double TFV4a::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
@@ -2576,7 +2590,7 @@ double TMHZ_EN57::GetPF( double i_bcp, double PP, double HP, double dt, double e
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
if ((TP > 0)) if ((TP > 0)&&(CP > 4.9))
{ {
DP = 0.045; DP = 0.045;
if (EQ(i_bcp, 0)) if (EQ(i_bcp, 0))
@@ -2591,8 +2605,13 @@ double TMHZ_EN57::GetPF( double i_bcp, double PP, double HP, double dt, double e
LimPP = Min0R(LPP_RP(i_bcp) + TP * 0.08 + RedAdj, HP); // pozycja + czasowy lub zasilanie LimPP = Min0R(LPP_RP(i_bcp) + TP * 0.08 + RedAdj, HP); // pozycja + czasowy lub zasilanie
ActFlowSpeed = 4; ActFlowSpeed = 4;
if ((EQ(i_bcp, -1))) double uop = UnbrakeOverPressure; //unbrake over pressure in actual state
pom = Min0R(HP, 5.4 + RedAdj); ManualOvrldActive = (UniversalFlag & TUniversalBrake::ub_HighPressure); //button is pressed
if (ManualOvrld && !ManualOvrldActive) //no overpressure for not pressed button if it does not exists
uop = 0;
if ( ( EQ( i_bcp, -1 ) ) && ( uop > 0 ) )
pom = Min0R(HP, 5.4 + RedAdj + uop);
else else
pom = Min0R(CP, HP); pom = Min0R(CP, HP);
@@ -2602,9 +2621,9 @@ double TMHZ_EN57::GetPF( double i_bcp, double PP, double HP, double dt, double e
CP = CP + 13 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy CP = CP + 13 * Min0R(abs(LimPP - CP), 0.05) * PR(CP, LimPP) * dt; // zbiornik sterujacy
LimPP = pom; // cp LimPP = pom; // cp
if (EQ(i_bcp, -1)) //if (EQ(i_bcp, -1))
dpPipe = HP; // dpPipe = HP;
else // else
dpPipe = Min0R(HP, LimPP); dpPipe = Min0R(HP, LimPP);
if (dpPipe > PP) if (dpPipe > PP)
@@ -2612,7 +2631,8 @@ double TMHZ_EN57::GetPF( double i_bcp, double PP, double HP, double dt, double e
else else
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
if (EQ(i_bcp, -1)) if ( ( EQ(i_bcp, -1) && ( AutoOvrld ) )
||(i_bcp<0.5 && (UniversalFlag & TUniversalBrake::ub_Overload)))
{ {
if ((TP < 5)) if ((TP < 5))
TP = TP + dt; // 5/10 TP = TP + dt; // 5/10
@@ -2691,6 +2711,15 @@ double TMHZ_EN57::LPP_RP(double pos) // cisnienie z zaokraglonej pozycji;
return 5.0; return 5.0;
} }
void TMHZ_EN57::SetParams(bool AO, bool MO, double OverP, double)
{
AutoOvrld = AO;
ManualOvrld = MO;
UnbrakeOverPressure = std::max(0.0, OverP);
Fala = (OverP > 0.01);
}
bool TMHZ_EN57::EQ(double pos, double i_pos) bool TMHZ_EN57::EQ(double pos, double i_pos)
{ {
return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5); return (pos <= i_pos + 0.5) && (pos > i_pos - 0.5);
@@ -2716,7 +2745,7 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
i_bcp = Max0R(Min0R(i_bcp, 2.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres i_bcp = Max0R(Min0R(i_bcp, 2.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
if ((TP > 0)) if ((TP > 0)&&(CP>4.9))
{ {
DP = 0.004; DP = 0.004;
TP = TP - DP * dt; TP = TP - DP * dt;
@@ -2742,14 +2771,19 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
else else
CP = CP + 9 * Min0R(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy CP = CP + 9 * Min0R(abs(LimCP - CP), 0.05) * PR(CP, LimCP) * dt; // zbiornik sterujacy
dpPipe = Min0R(HP, CP + TP + RedAdj); double uop = UnbrakeOverPressure; //unbrake over pressure in actual state
ManualOvrldActive = (UniversalFlag & TUniversalBrake::ub_HighPressure); //button is pressed
if (ManualOvrld && !ManualOvrldActive) //no overpressure for not pressed button if it does not exists
uop = 0;
dpPipe = Min0R(HP, CP + TP + RedAdj);
if (dpPipe > PP) if (dpPipe > PP)
dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4); dpMainValve = -PFVa(HP, PP, ActFlowSpeed / LBDelay, dpPipe, 0.4);
else else
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
if ((EQ(i_bcp, -1)&&(AutoOvrld))||(ManualOvrld && ManualOvrldActive)) if ((EQ(i_bcp, -1) && (AutoOvrld)) || ((i_bcp<0.5) && (UniversalFlag & TUniversalBrake::ub_Overload)))
{ {
if ((TP < 1)) if ((TP < 1))
TP = TP + 0.03 * dt; TP = TP + 0.03 * dt;
@@ -2805,10 +2839,13 @@ double TMHZ_K5P::GetCP()
return CP; return CP;
} }
void TMHZ_K5P::SetParams(bool AO, bool MO, double, double) void TMHZ_K5P::SetParams(bool AO, bool MO, double OverP, double)
{ {
AutoOvrld = AO; AutoOvrld = AO;
ManualOvrld = MO; ManualOvrld = MO;
UnbrakeOverPressure = std::max(0.0, OverP);
Fala = (OverP > 0.01);
} }
bool TMHZ_K5P::EQ(double pos, double i_pos) bool TMHZ_K5P::EQ(double pos, double i_pos)
@@ -2836,7 +2873,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
i_bcp = Max0R(Min0R(i_bcp, 3.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres i_bcp = Max0R(Min0R(i_bcp, 3.999), -0.999); // na wszelki wypadek, zeby nie wyszlo poza zakres
if ((TP > 0)) if ((TP > 0)&&(CP>4.9))
{ {
DP = 0.004; DP = 0.004;
TP = TP - DP * dt; TP = TP - DP * dt;
@@ -2864,9 +2901,14 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
dpPipe = Min0R(HP, CP + TP + RedAdj); dpPipe = Min0R(HP, CP + TP + RedAdj);
double uop = UnbrakeOverPressure; //unbrake over pressure in actual state
ManualOvrldActive = (UniversalFlag & TUniversalBrake::ub_HighPressure); //button is pressed
if (ManualOvrld && !ManualOvrldActive) //no overpressure for not pressed button if it does not exists
uop = 0;
if (Fala && EQ(i_bcp, -1)) if (Fala && EQ(i_bcp, -1))
{ {
dpPipe = 5.0 + TP + RedAdj + UnbrakeOverPressure; dpPipe = 5.0 + TP + RedAdj + uop;
ActFlowSpeed = 12; ActFlowSpeed = 12;
} }
@@ -2875,7 +2917,7 @@ double TMHZ_6P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
else else
dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4); dpMainValve = PFVd(PP, 0, ActFlowSpeed / LBDelay, dpPipe, 0.4);
if ((EQ(i_bcp, -1) && (AutoOvrld)) || (ManualOvrld && ManualOvrldActive)) if ((EQ(i_bcp, -1) && (AutoOvrld)) || ((i_bcp<0.5) && (UniversalFlag & TUniversalBrake::ub_Overload)))
{ {
if ((TP < 1)) if ((TP < 1))
TP = TP + 0.03 * dt; TP = TP + 0.03 * dt;

View File

@@ -133,6 +133,16 @@ static double const BPT_394[7][2] = { {13 , 10.0} , {5 , 5.0} , {0 , -1} , {5 ,
static int const i_bcpno = 6; static int const i_bcpno = 6;
// static double const pi = 3.141592653589793; //definicja w mctools // static double const pi = 3.141592653589793; //definicja w mctools
enum TUniversalBrake // możliwe działania uniwersalnego przycisku hamulca
{ // kolejne flagi
ub_Release = 0x01, // odluźniacz - ZR
ub_UnlockPipe = 0x02, // odblok PG / mostkowanie hamulca bezpieczeństwa - POJAZD
ub_HighPressure = 0x04, // impuls wysokiego ciśnienia - ZM
ub_Overload = 0x08, // przycisk asymilacji / kontrolowanego przeładowania - ZM
ub_AntiSlipBrake = 0x10, // przycisk przyhamowania przeciwposlizgowego - ZR
ub_Ostatni = 0x80000000 // ostatnia flaga bitowa
};
//klasa obejmujaca pojedyncze zbiorniki //klasa obejmujaca pojedyncze zbiorniki
class TReservoir { class TReservoir {
@@ -183,6 +193,7 @@ class TBrake {
double SizeBC = 0.0; //rozmiar^2 CH (w stosunku do 14") double SizeBC = 0.0; //rozmiar^2 CH (w stosunku do 14")
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 UniversalFlag = 0; //flaga wcisnietych przyciskow uniwersalnych
int BrakeStatus{ b_off }; //flaga stanu int BrakeStatus{ b_off }; //flaga stanu
int SoundFlag = 0; int SoundFlag = 0;
@@ -220,6 +231,7 @@ class TBrake {
int GetBrakeStatus() const { return BrakeStatus; } int GetBrakeStatus() const { return BrakeStatus; }
void SetBrakeStatus( int const Status ) { BrakeStatus = Status; } 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
virtual void SetUniversalFlag(int flag) { UniversalFlag = flag; } //przycisk uniwersalny
}; };
class TWest : public TBrake { class TWest : public TBrake {
@@ -520,6 +532,7 @@ class TDriverHandle {
bool AutoOvrld = false; //czy jest asymilacja automatyczna na pozycji -1 bool AutoOvrld = false; //czy jest asymilacja automatyczna na pozycji -1
bool ManualOvrld = false; //czy jest asymilacja reczna przyciskiem bool ManualOvrld = false; //czy jest asymilacja reczna przyciskiem
bool ManualOvrldActive = false; //czy jest wcisniety przycisk asymilacji bool ManualOvrldActive = false; //czy jest wcisniety przycisk asymilacji
int UniversalFlag = 0; //flaga wcisnietych przyciskow uniwersalnych
public: public:
bool Time = false; bool Time = false;
bool TimeEP = false; bool TimeEP = false;
@@ -534,7 +547,7 @@ class TDriverHandle {
virtual double GetEP(double pos); //pobranie sily hamulca ep virtual double GetEP(double pos); //pobranie sily hamulca ep
virtual void SetParams(bool AO, bool MO, double, double) {}; //ustawianie jakichs parametrów dla zaworu virtual void SetParams(bool AO, bool MO, double, double) {}; //ustawianie jakichs parametrów dla zaworu
virtual void OvrldButton(bool Active); //przycisk recznego przeladowania/asymilacji virtual void OvrldButton(bool Active); //przycisk recznego przeladowania/asymilacji
virtual void SetUniversalFlag(int flag); //przycisk uniwersalny
inline TDriverHandle() { memset( Sounds, 0, sizeof( Sounds ) ); } inline TDriverHandle() { memset( Sounds, 0, sizeof( Sounds ) ); }
}; };
@@ -589,6 +602,7 @@ class TMHZ_EN57 : public TDriverHandle {
double RP = 0.0; //zbiornik redukcyjny double RP = 0.0; //zbiornik redukcyjny
double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
bool Fala = false; bool Fala = false;
double UnbrakeOverPressure = 0.0;
static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 };
double LPP_RP(double pos); double LPP_RP(double pos);
@@ -602,7 +616,7 @@ class TMHZ_EN57 : public TDriverHandle {
double GetPos(int i)/*override*/; double GetPos(int i)/*override*/;
double GetCP()/*override*/; double GetCP()/*override*/;
double GetEP(double pos); double GetEP(double pos);
void SetParams(bool AO, bool MO, double OverP, double);
inline TMHZ_EN57(void) : inline TMHZ_EN57(void) :
TDriverHandle() TDriverHandle()
{} {}
@@ -616,6 +630,7 @@ private:
double RP = 0.0; //zbiornik redukcyjny double RP = 0.0; //zbiornik redukcyjny
double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem) double RedAdj = 0.0; //dostosowanie reduktora cisnienia (krecenie kapturkiem)
bool Fala = false; //czy jest napelnianie uderzeniowe bool Fala = false; //czy jest napelnianie uderzeniowe
double UnbrakeOverPressure = 0.0;
static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 }; static double const pos_table[11]; //= { -2, 10, -1, 0, 0, 2, 9, 10, 0, 0, 0 };
bool EQ(double pos, double i_pos); bool EQ(double pos, double i_pos);

337
Train.cpp
View File

@@ -180,6 +180,9 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::independentbrakedecreasefast, &TTrain::OnCommand_independentbrakedecreasefast }, { user_command::independentbrakedecreasefast, &TTrain::OnCommand_independentbrakedecreasefast },
{ user_command::independentbrakeset, &TTrain::OnCommand_independentbrakeset }, { user_command::independentbrakeset, &TTrain::OnCommand_independentbrakeset },
{ user_command::independentbrakebailoff, &TTrain::OnCommand_independentbrakebailoff }, { user_command::independentbrakebailoff, &TTrain::OnCommand_independentbrakebailoff },
{ user_command::universalbrakebutton1, &TTrain::OnCommand_universalbrakebutton1 },
{ user_command::universalbrakebutton2, &TTrain::OnCommand_universalbrakebutton2 },
{ user_command::universalbrakebutton3, &TTrain::OnCommand_universalbrakebutton3 },
{ user_command::trainbrakeincrease, &TTrain::OnCommand_trainbrakeincrease }, { user_command::trainbrakeincrease, &TTrain::OnCommand_trainbrakeincrease },
{ user_command::trainbrakedecrease, &TTrain::OnCommand_trainbrakedecrease }, { user_command::trainbrakedecrease, &TTrain::OnCommand_trainbrakedecrease },
{ user_command::trainbrakeset, &TTrain::OnCommand_trainbrakeset }, { user_command::trainbrakeset, &TTrain::OnCommand_trainbrakeset },
@@ -262,6 +265,9 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::compressorenable, &TTrain::OnCommand_compressorenable }, { user_command::compressorenable, &TTrain::OnCommand_compressorenable },
{ user_command::compressordisable, &TTrain::OnCommand_compressordisable }, { user_command::compressordisable, &TTrain::OnCommand_compressordisable },
{ user_command::compressortogglelocal, &TTrain::OnCommand_compressortogglelocal }, { user_command::compressortogglelocal, &TTrain::OnCommand_compressortogglelocal },
{ user_command::compressorpresetactivatenext, &TTrain::OnCommand_compressorpresetactivatenext },
{ user_command::compressorpresetactivateprevious, &TTrain::OnCommand_compressorpresetactivateprevious },
{ user_command::compressorpresetactivatedefault, &TTrain::OnCommand_compressorpresetactivatedefault },
{ user_command::motorblowerstogglefront, &TTrain::OnCommand_motorblowerstogglefront }, { user_command::motorblowerstogglefront, &TTrain::OnCommand_motorblowerstogglefront },
{ user_command::motorblowerstogglerear, &TTrain::OnCommand_motorblowerstogglerear }, { user_command::motorblowerstogglerear, &TTrain::OnCommand_motorblowerstogglerear },
{ user_command::motorblowersdisableall, &TTrain::OnCommand_motorblowersdisableall }, { user_command::motorblowersdisableall, &TTrain::OnCommand_motorblowersdisableall },
@@ -352,7 +358,14 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::generictoggle6, &TTrain::OnCommand_generictoggle }, { user_command::generictoggle6, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle7, &TTrain::OnCommand_generictoggle }, { user_command::generictoggle7, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle8, &TTrain::OnCommand_generictoggle }, { user_command::generictoggle8, &TTrain::OnCommand_generictoggle },
{ user_command::generictoggle9, &TTrain::OnCommand_generictoggle } { user_command::generictoggle9, &TTrain::OnCommand_generictoggle },
{ user_command::springbraketoggle, &TTrain::OnCommand_springbraketoggle },
{ user_command::springbrakeenable, &TTrain::OnCommand_springbrakeenable },
{ user_command::springbrakedisable, &TTrain::OnCommand_springbrakedisable },
{ user_command::springbrakeshutofftoggle, &TTrain::OnCommand_springbrakeshutofftoggle },
{ user_command::springbrakeshutoffenable, &TTrain::OnCommand_springbrakeshutoffenable },
{ user_command::springbrakeshutoffdisable, &TTrain::OnCommand_springbrakeshutoffdisable },
{ user_command::springbrakerelease, &TTrain::OnCommand_springbrakerelease }
}; };
std::vector<std::string> const TTrain::fPress_labels = { std::vector<std::string> const TTrain::fPress_labels = {
@@ -397,9 +410,12 @@ TTrain::TTrain() {
fDieselParams[i][j] = 0.0; fDieselParams[i][j] = 0.0;
} }
for( int i = 0; i < 20; ++i ) for ( int i = 0; i < 20; ++i )
for( int j = 0; j < 3; ++j ) {
fPress[ i ][ j ] = 0.0; for ( int j = 0; j < 3; ++j )
fPress[i][j] = 0.0;
bBrakes[i][0] = bBrakes[i][1] = 0.0;
}
} }
TTrain::~TTrain() TTrain::~TTrain()
@@ -459,6 +475,8 @@ dictionary_source *TTrain::GetTrainState() {
dict->insert( "converter", mvControlled->ConverterFlag ); dict->insert( "converter", mvControlled->ConverterFlag );
dict->insert( "converter_overload", mvControlled->ConvOvldFlag ); dict->insert( "converter_overload", mvControlled->ConvOvldFlag );
dict->insert( "compress", mvControlled->CompressorFlag ); dict->insert( "compress", mvControlled->CompressorFlag );
dict->insert( "lights_front", mvOccupied->iLights[ end::front ] );
dict->insert( "lights_rear", mvOccupied->iLights[ end::rear ] );
// reverser // reverser
dict->insert( "direction", mover->ActiveDir ); dict->insert( "direction", mover->ActiveDir );
// throttle // throttle
@@ -506,6 +524,7 @@ dictionary_source *TTrain::GetTrainState() {
char const *TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" }; char const *TXTC[ 10 ] = { "fr", "frt", "frb", "pr", "prt", "prb", "im", "vm", "ihv", "uhv" };
char const *TXTD[ 10 ] = { "enrot", "nrot", "fill_des", "fill_real", "clutch_des", "clutch_real", "water_temp", "oil_press", "engine_temp", "res1" }; char const *TXTD[ 10 ] = { "enrot", "nrot", "fill_des", "fill_real", "clutch_des", "clutch_real", "water_temp", "oil_press", "engine_temp", "res1" };
char const *TXTP[ 3 ] = { "bc", "bp", "sp" }; char const *TXTP[ 3 ] = { "bc", "bp", "sp" };
char const *TXTB[ 2 ] = { "spring_active", "spring_shutoff" };
for( int j = 0; j < 10; ++j ) for( int j = 0; j < 10; ++j )
dict->insert( ( "eimp_t_" + std::string( TXTT[ j ] ) ), fEIMParams[ 0 ][ j ] ); dict->insert( ( "eimp_t_" + std::string( TXTT[ j ] ) ), fEIMParams[ 0 ][ j ] );
for( int i = 0; i < 8; ++i ) { for( int i = 0; i < 8; ++i ) {
@@ -531,6 +550,9 @@ dictionary_source *TTrain::GetTrainState() {
for( int j = 0; j < 3; ++j ) { for( int j = 0; j < 3; ++j ) {
dict->insert( ( "eimp_pn" + std::to_string( i + 1 ) + "_" + TXTP[ j ] ), fPress[ i ][ j ] ); dict->insert( ( "eimp_pn" + std::to_string( i + 1 ) + "_" + TXTP[ j ] ), fPress[ i ][ j ] );
} }
for ( int j = 0; j < 2; ++j) {
dict->insert( ( "brakes_" + std::to_string( i + 1 ) + "_" + TXTB[ j ] ), bBrakes[ i ][ j ] );
}
} }
// multi-unit state data // multi-unit state data
dict->insert( "car_no", iCarNo ); dict->insert( "car_no", iCarNo );
@@ -1152,6 +1174,60 @@ void TTrain::OnCommand_independentbrakebailoff( TTrain *Train, command_data cons
} }
} }
void TTrain::OnCommand_universalbrakebutton1(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// press or hold
// visual feedback
Train->ggUniveralBrakeButton1.UpdateValue(1.0, Train->dsbSwitch);
Train->mvOccupied->UniversalBrakeButton(0,1);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggUniveralBrakeButton1.UpdateValue(0.0, Train->dsbSwitch);
Train->mvOccupied->UniversalBrakeButton(0,0);
}
}
void TTrain::OnCommand_universalbrakebutton2(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// press or hold
// visual feedback
Train->ggUniveralBrakeButton2.UpdateValue(1.0, Train->dsbSwitch);
Train->mvOccupied->UniversalBrakeButton(1, 1);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggUniveralBrakeButton2.UpdateValue(0.0, Train->dsbSwitch);
Train->mvOccupied->UniversalBrakeButton(1, 0);
}
}
void TTrain::OnCommand_universalbrakebutton3(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// press or hold
// visual feedback
Train->ggUniveralBrakeButton3.UpdateValue(1.0, Train->dsbSwitch);
Train->mvOccupied->UniversalBrakeButton(2, 1);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggUniveralBrakeButton3.UpdateValue(0.0, Train->dsbSwitch);
Train->mvOccupied->UniversalBrakeButton(2, 0);
}
}
void TTrain::OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command ) {
if (Command.action == GLFW_REPEAT && Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a) if (Command.action == GLFW_REPEAT && Train->mvOccupied->BrakeHandle == TBrakeHandle::FV4a)
Train->mvOccupied->BrakeLevelAdd( Global.brake_speed * Command.time_delta * Train->mvOccupied->BrakeCtrlPosNo ); Train->mvOccupied->BrakeLevelAdd( Global.brake_speed * Command.time_delta * Train->mvOccupied->BrakeCtrlPosNo );
@@ -1416,16 +1492,47 @@ void TTrain::OnCommand_sandboxactivate( TTrain *Train, command_data const &Comma
// visual feedback // visual feedback
Train->ggSandButton.UpdateValue( 1.0, Train->dsbSwitch ); Train->ggSandButton.UpdateValue( 1.0, Train->dsbSwitch );
Train->mvControlled->Sandbox( true ); Train->mvControlled->SandboxManual( true );
} }
else if( Command.action == GLFW_RELEASE) { else if( Command.action == GLFW_RELEASE) {
// visual feedback // visual feedback
Train->ggSandButton.UpdateValue( 0.0 ); Train->ggSandButton.UpdateValue( 0.0 );
Train->mvControlled->Sandbox( false ); Train->mvControlled->SandboxManual( false );
} }
} }
void TTrain::OnCommand_autosandboxtoggle(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if (false == Train->mvOccupied->SandDoseAutoAllow) {
// turn on
OnCommand_autosandboxactivate(Train, Command);
}
else {
//turn off
OnCommand_autosandboxdeactivate(Train, Command);
}
}
};
void TTrain::OnCommand_autosandboxactivate(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SandboxAutoAllow(true);
Train->ggAutoSandAllow.UpdateValue(1.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_autosandboxdeactivate(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SandboxAutoAllow(false);
Train->ggAutoSandAllow.UpdateValue(0.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {
@@ -2913,6 +3020,77 @@ void TTrain::OnCommand_compressortogglelocal( TTrain *Train, command_data const
} }
} }
void TTrain::OnCommand_compressorpresetactivatenext(TTrain *Train, command_data const &Command) {
if (Train->mvOccupied->CompressorListPosNo == 0) {
// lights are controlled by preset selector
return;
}
if (Command.action != GLFW_PRESS) {
// one change per key press
return;
}
if ((Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo)
|| (true == Train->mvOccupied->CompressorListWrap)) {
// active light preset is stored as value in range 1-LigthPosNo
Train->mvOccupied->CompressorListPos = (
Train->mvOccupied->CompressorListPos < Train->mvOccupied->CompressorListPosNo ?
Train->mvOccupied->CompressorListPos + 1 :
1); // wrap mode
// visual feedback
if (Train->ggCompressorListButton.SubModel != nullptr) {
Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch);
}
}
}
void TTrain::OnCommand_compressorpresetactivateprevious(TTrain *Train, command_data const &Command) {
if (Train->mvOccupied->CompressorListPosNo == 0) {
// lights are controlled by preset selector
return;
}
if (Command.action != GLFW_PRESS) {
// one change per key press
return;
}
if ((Train->mvOccupied->CompressorListPos > 1)
|| (true == Train->mvOccupied->CompressorListWrap)) {
// active light preset is stored as value in range 1-LigthPosNo
Train->mvOccupied->CompressorListPos = (
Train->mvOccupied->CompressorListPos > 1 ?
Train->mvOccupied->CompressorListPos - 1 :
Train->mvOccupied->CompressorListPosNo); // wrap mode
// visual feedback
if (Train->ggCompressorListButton.SubModel != nullptr) {
Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch);
}
}
}
void TTrain::OnCommand_compressorpresetactivatedefault(TTrain *Train, command_data const &Command) {
if (Train->mvOccupied->CompressorListPosNo == 0) {
// lights are controlled by preset selector
return;
}
if (Command.action != GLFW_PRESS) {
// one change per key press
return;
}
Train->mvOccupied->CompressorListPos = Train->mvOccupied->CompressorListDefPos;
// visual feedback
if (Train->ggCompressorListButton.SubModel != nullptr) {
Train->ggCompressorListButton.UpdateValue(Train->mvOccupied->CompressorListPos - 1, Train->dsbSwitch);
}
}
void TTrain::OnCommand_motorblowerstogglefront( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_motorblowerstogglefront( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_REPEAT ) { return; } if( Command.action == GLFW_REPEAT ) { return; }
@@ -4226,6 +4404,97 @@ void TTrain::OnCommand_generictoggle( TTrain *Train, command_data const &Command
} }
} }
void TTrain::OnCommand_springbraketoggle(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if (false == Train->mvOccupied->SpringBrake.Activate) {
// turn on
OnCommand_springbrakeenable(Train, Command);
}
else {
//turn off
OnCommand_springbrakedisable(Train, Command);
}
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggSpringBrakeOffButton.UpdateValue(0.0, Train->dsbSwitch);
Train->ggSpringBrakeOnButton.UpdateValue(0.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_springbrakeenable(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SpringBrakeActivate(true);
// visual feedback
Train->ggSpringBrakeOnButton.UpdateValue(1.0, Train->dsbSwitch);
Train->ggSpringBrakeToggleButton.UpdateValue(1.0, Train->dsbSwitch);
Train->ggSpringBrakeOffButton.UpdateValue(0.0, Train->dsbSwitch);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggSpringBrakeOnButton.UpdateValue(0.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_springbrakedisable(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SpringBrakeActivate(false);
// visual feedback
Train->ggSpringBrakeOffButton.UpdateValue(1.0, Train->dsbSwitch);
Train->ggSpringBrakeToggleButton.UpdateValue(0.0, Train->dsbSwitch);
Train->ggSpringBrakeOnButton.UpdateValue(0.0, Train->dsbSwitch);
}
else if (Command.action == GLFW_RELEASE) {
// release
// visual feedback
Train->ggSpringBrakeOffButton.UpdateValue(0.0, Train->dsbSwitch);
}
};
void TTrain::OnCommand_springbrakeshutofftoggle(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
if (false == Train->mvOccupied->SpringBrake.ShuttOff) {
// turn on
OnCommand_springbrakeshutoffenable(Train, Command);
}
else {
//turn off
OnCommand_springbrakeshutoffdisable(Train, Command);
}
}
};
void TTrain::OnCommand_springbrakeshutoffenable(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SpringBrakeShutOff(true);
}
};
void TTrain::OnCommand_springbrakeshutoffdisable(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
Train->mvOccupied->SpringBrakeShutOff(false);
}
};
void TTrain::OnCommand_springbrakerelease(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down
auto *vehicle{ Train->find_nearest_consist_vehicle() };
if (vehicle == nullptr) { return; }
Train->mvOccupied->SpringBrakeRelease();
}
};
void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_doorlocktoggle( TTrain *Train, command_data const &Command ) {
if( Train->ggDoorSignallingButton.SubModel == nullptr ) { if( Train->ggDoorSignallingButton.SubModel == nullptr ) {
@@ -5085,6 +5354,7 @@ void TTrain::OnCommand_cabchangebackward( TTrain *Train, command_data const &Com
1 : 1 :
-1 ) }; -1 ) };
if( false == Train->CabChange( movedirection ) ) { if( false == Train->CabChange( movedirection ) ) {
// current vehicle doesn't extend any farther in this direction, check if we there's one connected we can move to
auto const exitdirection { ( auto const exitdirection { (
movedirection > 0 ? movedirection > 0 ?
end::front : end::front :
@@ -5324,6 +5594,8 @@ bool TTrain::Update( double const Deltatime )
fPress[i][0] = p->MoverParameters->BrakePress; fPress[i][0] = p->MoverParameters->BrakePress;
fPress[i][1] = p->MoverParameters->PipePress; fPress[i][1] = p->MoverParameters->PipePress;
fPress[i][2] = p->MoverParameters->ScndPipePress; fPress[i][2] = p->MoverParameters->ScndPipePress;
bBrakes[i][0] = p->MoverParameters->SpringBrake.IsActive;
bBrakes[i][1] = p->MoverParameters->SpringBrake.ShuttOff;
bDoors[i][1] = ( p->MoverParameters->Doors.instances[ side::left ].position > 0.f ); bDoors[i][1] = ( p->MoverParameters->Doors.instances[ side::left ].position > 0.f );
bDoors[i][2] = ( p->MoverParameters->Doors.instances[ side::right ].position > 0.f ); bDoors[i][2] = ( p->MoverParameters->Doors.instances[ side::right ].position > 0.f );
bDoors[i][3] = ( p->MoverParameters->Doors.instances[ side::left ].step_position > 0.f ); bDoors[i][3] = ( p->MoverParameters->Doors.instances[ side::left ].step_position > 0.f );
@@ -5407,6 +5679,9 @@ bool TTrain::Update( double const Deltatime )
= bDoors[i][3] = bDoors[i][3]
= bDoors[i][4] = bDoors[i][4]
= false; = false;
bBrakes[i][0]
= bBrakes[i][1]
= false;
bSlip[i] = false; bSlip[i] = false;
iUnits[i] = 0; iUnits[i] = 0;
cCode[i] = 0; //'0'; cCode[i] = 0; //'0';
@@ -5656,7 +5931,7 @@ bool TTrain::Update( double const Deltatime )
} }
} }
// McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa
if( mvOccupied->SecuritySystem.Status > 0 ) { if( mvOccupied->SecuritySystem.Status != s_off ) {
if( fBlinkTimer > fCzuwakBlink ) if( fBlinkTimer > fCzuwakBlink )
fBlinkTimer = -fCzuwakBlink; fBlinkTimer = -fCzuwakBlink;
else else
@@ -5684,7 +5959,7 @@ bool TTrain::Update( double const Deltatime )
false ) ); false ) );
btLampkaWylSzybkiOff.Turn( btLampkaWylSzybkiOff.Turn(
( ( ( mvControlled->MainsInitTimeCountdown > 0.0 ) ( ( ( mvControlled->MainsInitTimeCountdown > 0.0 )
|| ( fHVoltage == 0.0 ) // || ( fHVoltage == 0.0 )
|| ( m_linebreakerstate == 2 ) || ( m_linebreakerstate == 2 )
|| ( true == mvControlled->Mains ) ) ? || ( true == mvControlled->Mains ) ) ?
false : false :
@@ -5814,6 +6089,8 @@ bool TTrain::Update( double const Deltatime )
btLampkaBrakeProfileG.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_G ) ); btLampkaBrakeProfileG.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_G ) );
btLampkaBrakeProfileP.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_P ) ); btLampkaBrakeProfileP.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_P ) );
btLampkaBrakeProfileR.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_R ) ); btLampkaBrakeProfileR.Turn( TestFlag( mvOccupied->BrakeDelayFlag, bdelay_R ) );
btLampkaSpringBrakeActive.Turn( mvOccupied->SpringBrake.IsActive );
btLampkaSpringBrakeInactive.Turn( !mvOccupied->SpringBrake.IsActive );
// light indicators // light indicators
// NOTE: sides are hardcoded to deal with setups where single cab is equipped with all indicators // NOTE: sides are hardcoded to deal with setups where single cab is equipped with all indicators
btLampkaUpperLight.Turn( ( mvOccupied->iLights[ end::front ] & light::headlight_upper ) != 0 ); btLampkaUpperLight.Turn( ( mvOccupied->iLights[ end::front ] & light::headlight_upper ) != 0 );
@@ -5862,6 +6139,8 @@ bool TTrain::Update( double const Deltatime )
btLampkaBrakeProfileG.Turn( false ); btLampkaBrakeProfileG.Turn( false );
btLampkaBrakeProfileP.Turn( false ); btLampkaBrakeProfileP.Turn( false );
btLampkaBrakeProfileR.Turn( false ); btLampkaBrakeProfileR.Turn( false );
btLampkaSpringBrakeActive.Turn( false );
btLampkaSpringBrakeInactive.Turn( false );
btLampkaMaxSila.Turn( false ); btLampkaMaxSila.Turn( false );
btLampkaPrzekrMaxSila.Turn( false ); btLampkaPrzekrMaxSila.Turn( false );
btLampkaRadio.Turn( false ); btLampkaRadio.Turn( false );
@@ -5917,7 +6196,10 @@ bool TTrain::Update( double const Deltatime )
auto const *mover { tmp->MoverParameters }; auto const *mover { tmp->MoverParameters };
btLampkaWylSzybkiB.Turn( mover->Mains ); btLampkaWylSzybkiB.Turn( mover->Mains );
btLampkaWylSzybkiBOff.Turn( ( false == mover->Mains ) && ( mover->MainsInitTimeCountdown <= 0.0 ) && ( fHVoltage != 0.0 ) ); btLampkaWylSzybkiBOff.Turn(
( false == mover->Mains )
&& ( mover->MainsInitTimeCountdown <= 0.0 )
/*&& ( fHVoltage != 0.0 )*/ );
btLampkaOporyB.Turn(mover->ResistorsFlagCheck()); btLampkaOporyB.Turn(mover->ResistorsFlagCheck());
btLampkaBezoporowaB.Turn( btLampkaBezoporowaB.Turn(
@@ -6128,6 +6410,7 @@ bool TTrain::Update( double const Deltatime )
// NBMX dzwignia sprezarki // NBMX dzwignia sprezarki
ggCompressorButton.Update(); ggCompressorButton.Update();
ggCompressorLocalButton.Update(); ggCompressorLocalButton.Update();
ggCompressorListButton.Update();
//--------- //---------
// hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy // hunter-080812: poprawka na ogrzewanie w elektrykach - usuniete uzaleznienie od przetwornicy
@@ -6161,6 +6444,12 @@ bool TTrain::Update( double const Deltatime )
ggMainButton.Update(); ggMainButton.Update();
ggSecurityResetButton.Update(); ggSecurityResetButton.Update();
ggReleaserButton.Update(); ggReleaserButton.Update();
ggSpringBrakeToggleButton.Update();
ggSpringBrakeOnButton.Update();
ggSpringBrakeOffButton.Update();
ggUniveralBrakeButton1.Update();
ggUniveralBrakeButton2.Update();
ggUniveralBrakeButton3.Update();
ggAntiSlipButton.Update(); ggAntiSlipButton.Update();
ggSandButton.Update(); ggSandButton.Update();
ggFuseButton.Update(); ggFuseButton.Update();
@@ -6517,7 +6806,7 @@ TTrain::update_sounds( double const Deltatime ) {
} }
// McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa // McZapkie-141102: SHP i czuwak, TODO: sygnalizacja kabinowa
if (mvOccupied->SecuritySystem.Status > 0) { if (mvOccupied->SecuritySystem.Status != s_off ) {
// hunter-091012: rozdzielenie alarmow // hunter-091012: rozdzielenie alarmow
if( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm ) if( TestFlag( mvOccupied->SecuritySystem.Status, s_CAalarm )
|| TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ) { || TestFlag( mvOccupied->SecuritySystem.Status, s_SHPalarm ) ) {
@@ -7362,6 +7651,12 @@ void TTrain::clear_cab_controls()
ggMainOnButton.Clear(); ggMainOnButton.Clear();
ggSecurityResetButton.Clear(); ggSecurityResetButton.Clear();
ggReleaserButton.Clear(); ggReleaserButton.Clear();
ggSpringBrakeToggleButton.Clear();
ggSpringBrakeOnButton.Clear();
ggSpringBrakeOffButton.Clear();
ggUniveralBrakeButton1.Clear();
ggUniveralBrakeButton2.Clear();
ggUniveralBrakeButton3.Clear();
ggSandButton.Clear(); ggSandButton.Clear();
ggAntiSlipButton.Clear(); ggAntiSlipButton.Clear();
ggHornButton.Clear(); ggHornButton.Clear();
@@ -7491,6 +7786,8 @@ void TTrain::clear_cab_controls()
btLampkaBrakeProfileG.Clear(); btLampkaBrakeProfileG.Clear();
btLampkaBrakeProfileP.Clear(); btLampkaBrakeProfileP.Clear();
btLampkaBrakeProfileR.Clear(); btLampkaBrakeProfileR.Clear();
btLampkaSpringBrakeActive.Clear();
btLampkaSpringBrakeInactive.Clear();
btLampkaSprezarka.Clear(); btLampkaSprezarka.Clear();
btLampkaSprezarkaB.Clear(); btLampkaSprezarkaB.Clear();
btLampkaSprezarkaOff.Clear(); btLampkaSprezarkaOff.Clear();
@@ -7643,6 +7940,7 @@ void TTrain::set_cab_controls( int const Cab ) {
mvControlled->CompressorAllowLocal ? mvControlled->CompressorAllowLocal ?
1.f : 1.f :
0.f ); 0.f );
ggCompressorListButton.PutValue(mvOccupied->CompressorListPos - 1);
// motor overload relay threshold / shunt mode // motor overload relay threshold / shunt mode
ggMaxCurrentCtrl.PutValue( ggMaxCurrentCtrl.PutValue(
( true == mvControlled->ShuntModeAllow ? ( true == mvControlled->ShuntModeAllow ?
@@ -7898,6 +8196,8 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
{ "i-brakeprofileg:", btLampkaBrakeProfileG }, { "i-brakeprofileg:", btLampkaBrakeProfileG },
{ "i-brakeprofilep:", btLampkaBrakeProfileP }, { "i-brakeprofilep:", btLampkaBrakeProfileP },
{ "i-brakeprofiler:", btLampkaBrakeProfileR }, { "i-brakeprofiler:", btLampkaBrakeProfileR },
{ "i-springbrakeactive:", btLampkaSpringBrakeActive },
{ "i-springbrakeinactive:", btLampkaSpringBrakeInactive },
{ "i-braking-ezt:", btLampkaHamowanie1zes }, { "i-braking-ezt:", btLampkaHamowanie1zes },
{ "i-braking-ezt2:", btLampkaHamowanie2zes }, { "i-braking-ezt2:", btLampkaHamowanie2zes },
{ "i-compressor:", btLampkaSprezarka }, { "i-compressor:", btLampkaSprezarka },
@@ -7946,7 +8246,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
} }
} }
// TODO: move viable dedicated lights to the automatic light array // TODO: move viable dedicated lights to the automatic light array
std::unordered_map<std::string, bool *> const autolights = { std::unordered_map<std::string, bool const *> const autolights = {
{ "i-doorpermit_left:", &mvOccupied->Doors.instances[ ( mvOccupied->ActiveCab == 1 ? side::left : side::right ) ].open_permit }, { "i-doorpermit_left:", &mvOccupied->Doors.instances[ ( mvOccupied->ActiveCab == 1 ? side::left : side::right ) ].open_permit },
{ "i-doorpermit_right:", &mvOccupied->Doors.instances[ ( mvOccupied->ActiveCab == 1 ? side::right : side::left ) ].open_permit }, { "i-doorpermit_right:", &mvOccupied->Doors.instances[ ( mvOccupied->ActiveCab == 1 ? side::right : side::left ) ].open_permit },
{ "i-doorstep:", &mvOccupied->Doors.step_enabled } { "i-doorstep:", &mvOccupied->Doors.step_enabled }
@@ -8019,7 +8319,14 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "main_on_bt:", ggMainOnButton }, { "main_on_bt:", ggMainOnButton },
{ "security_reset_bt:", ggSecurityResetButton }, { "security_reset_bt:", ggSecurityResetButton },
{ "releaser_bt:", ggReleaserButton }, { "releaser_bt:", ggReleaserButton },
{ "springbraketoggle_bt:", ggSpringBrakeToggleButton },
{ "springbrakeon_bt:", ggSpringBrakeOnButton },
{ "springbrakeoff_bt:", ggSpringBrakeOffButton },
{ "universalbrake1_bt:", ggUniveralBrakeButton1 },
{ "universalbrake2_bt:", ggUniveralBrakeButton2 },
{ "universalbrake3_bt:", ggUniveralBrakeButton3 },
{ "sand_bt:", ggSandButton }, { "sand_bt:", ggSandButton },
{ "autosandallow_sw:", ggAutoSandAllow },
{ "antislip_bt:", ggAntiSlipButton }, { "antislip_bt:", ggAntiSlipButton },
{ "horn_bt:", ggHornButton }, { "horn_bt:", ggHornButton },
{ "hornlow_bt:", ggHornLowButton }, { "hornlow_bt:", ggHornLowButton },
@@ -8055,6 +8362,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "rearrightend_sw:", ggRearRightEndLightButton }, { "rearrightend_sw:", ggRearRightEndLightButton },
{ "compressor_sw:", ggCompressorButton }, { "compressor_sw:", ggCompressorButton },
{ "compressorlocal_sw:", ggCompressorLocalButton }, { "compressorlocal_sw:", ggCompressorLocalButton },
{ "compressorlist_sw:", ggCompressorListButton },
{ "converter_sw:", ggConverterButton }, { "converter_sw:", ggConverterButton },
{ "converterlocal_sw:", ggConverterLocalButton }, { "converterlocal_sw:", ggConverterLocalButton },
{ "converteroff_sw:", ggConverterOffButton }, { "converteroff_sw:", ggConverterOffButton },
@@ -8253,6 +8561,13 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
gauge.Load(Parser, DynamicObject, 0.1); gauge.Load(Parser, DynamicObject, 0.1);
gauge.AssignDouble(&mvControlled->PantPress); gauge.AssignDouble(&mvControlled->PantPress);
} }
else if (Label == "springbrakepress:")
{
// manometr cylindra hamulca sprężynowego
auto &gauge = Cabine[Cabindex].Gauge(-1); // pierwsza wolna gałka
gauge.Load(Parser, DynamicObject, 0.1);
gauge.AssignDouble(&mvOccupied->SpringBrake.SBP);
}
else if ((Label == "compressor:") || (Label == "compressorb:")) else if ((Label == "compressor:") || (Label == "compressorb:"))
{ {
// manometr sprezarki/zbiornika glownego // manometr sprezarki/zbiornika glownego

27
Train.h
View File

@@ -182,6 +182,9 @@ class TTrain {
static void OnCommand_independentbrakedecreasefast( TTrain *Train, command_data const &Command ); static void OnCommand_independentbrakedecreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakeset( TTrain *Train, command_data const &Command ); static void OnCommand_independentbrakeset( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakebailoff( TTrain *Train, command_data const &Command ); static void OnCommand_independentbrakebailoff( TTrain *Train, command_data const &Command );
static void OnCommand_universalbrakebutton1(TTrain *Train, command_data const &Command);
static void OnCommand_universalbrakebutton2(TTrain *Train, command_data const &Command);
static void OnCommand_universalbrakebutton3(TTrain *Train, command_data const &Command);
static void OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command ); static void OnCommand_trainbrakeincrease( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakedecrease( TTrain *Train, command_data const &Command ); static void OnCommand_trainbrakedecrease( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakeset( TTrain *Train, command_data const &Command ); static void OnCommand_trainbrakeset( TTrain *Train, command_data const &Command );
@@ -201,6 +204,9 @@ class TTrain {
static void OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Command ); static void OnCommand_alarmchaintoggle( TTrain *Train, command_data const &Command );
static void OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command ); static void OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command );
static void OnCommand_sandboxactivate( TTrain *Train, command_data const &Command ); static void OnCommand_sandboxactivate( TTrain *Train, command_data const &Command );
static void OnCommand_autosandboxtoggle(TTrain *Train, command_data const &Command);
static void OnCommand_autosandboxactivate(TTrain *Train, command_data const &Command);
static void OnCommand_autosandboxdeactivate(TTrain *Train, command_data const &Command);
static void OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ); static void OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command );
static void OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_data const &Command); static void OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_data const &Command);
static void OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_data const &Command); static void OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_data const &Command);
@@ -264,6 +270,9 @@ class TTrain {
static void OnCommand_compressorenable( TTrain *Train, command_data const &Command ); static void OnCommand_compressorenable( TTrain *Train, command_data const &Command );
static void OnCommand_compressordisable( TTrain *Train, command_data const &Command ); static void OnCommand_compressordisable( TTrain *Train, command_data const &Command );
static void OnCommand_compressortogglelocal( TTrain *Train, command_data const &Command ); static void OnCommand_compressortogglelocal( TTrain *Train, command_data const &Command );
static void OnCommand_compressorpresetactivatenext( TTrain *Train, command_data const &Command );
static void OnCommand_compressorpresetactivateprevious( TTrain *Train, command_data const &Command );
static void OnCommand_compressorpresetactivatedefault(TTrain *Train, command_data const &Command);
static void OnCommand_motorblowerstogglefront( TTrain *Train, command_data const &Command ); static void OnCommand_motorblowerstogglefront( TTrain *Train, command_data const &Command );
static void OnCommand_motorblowersenablefront( TTrain *Train, command_data const &Command ); static void OnCommand_motorblowersenablefront( TTrain *Train, command_data const &Command );
static void OnCommand_motorblowersdisablefront( TTrain *Train, command_data const &Command ); static void OnCommand_motorblowersdisablefront( TTrain *Train, command_data const &Command );
@@ -350,6 +359,13 @@ class TTrain {
static void OnCommand_cabchangeforward( TTrain *Train, command_data const &Command ); static void OnCommand_cabchangeforward( TTrain *Train, command_data const &Command );
static void OnCommand_cabchangebackward( TTrain *Train, command_data const &Command ); static void OnCommand_cabchangebackward( TTrain *Train, command_data const &Command );
static void OnCommand_generictoggle( TTrain *Train, command_data const &Command ); static void OnCommand_generictoggle( TTrain *Train, command_data const &Command );
static void OnCommand_springbraketoggle(TTrain *Train, command_data const &Command);
static void OnCommand_springbrakeenable(TTrain *Train, command_data const &Command);
static void OnCommand_springbrakedisable(TTrain *Train, command_data const &Command);
static void OnCommand_springbrakeshutofftoggle(TTrain *Train, command_data const &Command);
static void OnCommand_springbrakeshutoffenable(TTrain *Train, command_data const &Command);
static void OnCommand_springbrakeshutoffdisable(TTrain *Train, command_data const &Command);
static void OnCommand_springbrakerelease(TTrain *Train, command_data const &Command);
// members // members
@@ -406,7 +422,14 @@ public: // reszta może by?publiczna
TGauge ggMainButton; // EZT TGauge ggMainButton; // EZT
TGauge ggSecurityResetButton; TGauge ggSecurityResetButton;
TGauge ggReleaserButton; TGauge ggReleaserButton;
TGauge ggSpringBrakeToggleButton;
TGauge ggSpringBrakeOnButton;
TGauge ggSpringBrakeOffButton;
TGauge ggUniveralBrakeButton1;
TGauge ggUniveralBrakeButton2;
TGauge ggUniveralBrakeButton3;
TGauge ggSandButton; // guzik piasecznicy TGauge ggSandButton; // guzik piasecznicy
TGauge ggAutoSandAllow; // przełącznik piasecznicy
TGauge ggAntiSlipButton; TGauge ggAntiSlipButton;
TGauge ggFuseButton; TGauge ggFuseButton;
TGauge ggConverterFuseButton; // hunter-261211: przycisk odblokowania nadmiarowego przetwornic i ogrzewania TGauge ggConverterFuseButton; // hunter-261211: przycisk odblokowania nadmiarowego przetwornic i ogrzewania
@@ -437,6 +460,7 @@ public: // reszta może by?publiczna
TGauge ggCompressorButton; TGauge ggCompressorButton;
TGauge ggCompressorLocalButton; // controls only compressor of its own unit (et42-specific) TGauge ggCompressorLocalButton; // controls only compressor of its own unit (et42-specific)
TGauge ggCompressorListButton; // controls compressors with various settings
TGauge ggConverterButton; TGauge ggConverterButton;
TGauge ggConverterLocalButton; // controls only converter of its own unit (et42-specific) TGauge ggConverterLocalButton; // controls only converter of its own unit (et42-specific)
TGauge ggConverterOffButton; TGauge ggConverterOffButton;
@@ -562,6 +586,8 @@ public: // reszta może by?publiczna
TButton btLampkaBrakeProfileG; // cargo train brake acting speed TButton btLampkaBrakeProfileG; // cargo train brake acting speed
TButton btLampkaBrakeProfileP; // passenger train brake acting speed TButton btLampkaBrakeProfileP; // passenger train brake acting speed
TButton btLampkaBrakeProfileR; // rapid brake acting speed TButton btLampkaBrakeProfileR; // rapid brake acting speed
TButton btLampkaSpringBrakeActive;
TButton btLampkaSpringBrakeInactive;
// KURS90 // KURS90
TButton btLampkaBoczniki; TButton btLampkaBoczniki;
TButton btLampkaMaxSila; TButton btLampkaMaxSila;
@@ -680,6 +706,7 @@ private:
public: public:
float fPress[20][3]; // cisnienia dla wszystkich czlonow float fPress[20][3]; // cisnienia dla wszystkich czlonow
float bBrakes[20][2]; // zalaczenie i dzialanie hamulcow
static std::vector<std::string> const fPress_labels; static std::vector<std::string> const fPress_labels;
float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych float fEIMParams[9][10]; // parametry dla silnikow asynchronicznych
float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych float fDieselParams[9][10]; // parametry dla silnikow asynchronicznych

View File

@@ -116,7 +116,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( false == ismoving ) { if( false == ismoving ) {
//McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi //McZapkie-140602: wyzwalanie zdarzenia gdy pojazd stoi
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
pCurrentTrack->QueueEvents( pCurrentTrack->m_events0, Owner ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events0, Owner );
} }
@@ -127,7 +127,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( SetFlag( iEventFlag, -1 ) ) { if( SetFlag( iEventFlag, -1 ) ) {
// zawsze zeruje flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona // zawsze zeruje flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
// McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada // McZapkie-280503: wyzwalanie event tylko dla pojazdow z obsada
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner );
@@ -143,7 +143,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
if( SetFlag( iEventFlag, -2 ) ) { if( SetFlag( iEventFlag, -2 ) ) {
// zawsze ustawia flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona // zawsze ustawia flagę sprawdzenia, jak mechanik dosiądzie, to się nie wykona
if( ( Owner->Mechanik != nullptr ) if( ( Owner->Mechanik != nullptr )
&& ( Owner->Mechanik->Primary() ) ) { && ( Owner->Mechanik->primary() ) ) {
// tylko dla jednego członu // tylko dla jednego członu
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner );
} }
@@ -244,7 +244,7 @@ bool TTrackFollower::Move(double fDistance, bool bPrimary)
{ // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru) { // gdy zostaje na tym samym torze (przesuwanie już nie zmienia toru)
if (bPrimary) if (bPrimary)
{ // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki { // tylko gdy początkowe ustawienie, dodajemy eventy stania do kolejki
if (Owner->MoverParameters->ActiveCab != 0) { if (Owner->MoverParameters->CabNo != 0) {
pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner, -1.0 ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events1, Owner, -1.0 );
pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner, -1.0 ); pCurrentTrack->QueueEvents( pCurrentTrack->m_events2, Owner, -1.0 );

View File

@@ -40,6 +40,9 @@ commanddescription_sequence Commands_descriptions = {
{ "independentbrakedecreasefast", command_target::vehicle, command_mode::oneoff }, { "independentbrakedecreasefast", command_target::vehicle, command_mode::oneoff },
{ "independentbrakeset", command_target::vehicle, command_mode::oneoff }, { "independentbrakeset", command_target::vehicle, command_mode::oneoff },
{ "independentbrakebailoff", command_target::vehicle, command_mode::oneoff }, { "independentbrakebailoff", command_target::vehicle, command_mode::oneoff },
{ "universalbrakebutton1", command_target::vehicle, command_mode::oneoff },
{ "universalbrakebutton2", command_target::vehicle, command_mode::oneoff },
{ "universalbrakebutton3", command_target::vehicle, command_mode::oneoff },
{ "trainbrakeincrease", command_target::vehicle, command_mode::continuous }, { "trainbrakeincrease", command_target::vehicle, command_mode::continuous },
{ "trainbrakedecrease", command_target::vehicle, command_mode::continuous }, { "trainbrakedecrease", command_target::vehicle, command_mode::continuous },
{ "trainbrakeset", command_target::vehicle, command_mode::oneoff }, { "trainbrakeset", command_target::vehicle, command_mode::oneoff },
@@ -59,6 +62,9 @@ commanddescription_sequence Commands_descriptions = {
{ "alarmchaintoggle", command_target::vehicle, command_mode::oneoff }, { "alarmchaintoggle", command_target::vehicle, command_mode::oneoff },
{ "wheelspinbrakeactivate", command_target::vehicle, command_mode::oneoff }, { "wheelspinbrakeactivate", command_target::vehicle, command_mode::oneoff },
{ "sandboxactivate", command_target::vehicle, command_mode::oneoff }, { "sandboxactivate", command_target::vehicle, command_mode::oneoff },
{ "autosandboxtoggle", command_target::vehicle, command_mode::oneoff },
{ "autosandboxactivate", command_target::vehicle, command_mode::oneoff },
{ "autosandboxdeactivate", command_target::vehicle, command_mode::oneoff },
{ "reverserincrease", command_target::vehicle, command_mode::oneoff }, { "reverserincrease", command_target::vehicle, command_mode::oneoff },
{ "reverserdecrease", command_target::vehicle, command_mode::oneoff }, { "reverserdecrease", command_target::vehicle, command_mode::oneoff },
{ "reverserforwardhigh", command_target::vehicle, command_mode::oneoff }, { "reverserforwardhigh", command_target::vehicle, command_mode::oneoff },
@@ -98,6 +104,9 @@ commanddescription_sequence Commands_descriptions = {
{ "compressorenable", command_target::vehicle, command_mode::oneoff }, { "compressorenable", command_target::vehicle, command_mode::oneoff },
{ "compressordisable", command_target::vehicle, command_mode::oneoff }, { "compressordisable", command_target::vehicle, command_mode::oneoff },
{ "compressortogglelocal", command_target::vehicle, command_mode::oneoff }, { "compressortogglelocal", command_target::vehicle, command_mode::oneoff },
{ "compressorpresetactivatenext", command_target::vehicle, command_mode::oneoff },
{ "compressorpresetactivateprevious", command_target::vehicle, command_mode::oneoff },
{ "compressorpresetactivatedefault", command_target::vehicle, command_mode::oneoff },
{ "motoroverloadrelaythresholdtoggle", command_target::vehicle, command_mode::oneoff }, { "motoroverloadrelaythresholdtoggle", command_target::vehicle, command_mode::oneoff },
{ "motoroverloadrelaythresholdsetlow", command_target::vehicle, command_mode::oneoff }, { "motoroverloadrelaythresholdsetlow", command_target::vehicle, command_mode::oneoff },
{ "motoroverloadrelaythresholdsethigh", command_target::vehicle, command_mode::oneoff }, { "motoroverloadrelaythresholdsethigh", command_target::vehicle, command_mode::oneoff },
@@ -229,6 +238,14 @@ commanddescription_sequence Commands_descriptions = {
{ "motorblowersdisableall", command_target::vehicle, command_mode::oneoff }, { "motorblowersdisableall", command_target::vehicle, command_mode::oneoff },
{ "coolingfanstoggle", command_target::vehicle, command_mode::oneoff }, { "coolingfanstoggle", command_target::vehicle, command_mode::oneoff },
{ "tempomattoggle", command_target::vehicle, command_mode::oneoff }, { "tempomattoggle", command_target::vehicle, command_mode::oneoff },
{ "springbraketoggle", command_target::vehicle, command_mode::oneoff },
{ "springbrakeenable", command_target::vehicle, command_mode::oneoff },
{ "springbrakedisable", command_target::vehicle, command_mode::oneoff },
{ "springbrakeshutofftoggle", command_target::vehicle, command_mode::oneoff },
{ "springbrakeshutoffenable", command_target::vehicle, command_mode::oneoff },
{ "springbrakeshutoffdisable", command_target::vehicle, command_mode::oneoff },
{ "springbrakerelease", command_target::vehicle, command_mode::oneoff }
}; };
} // simulation } // simulation

View File

@@ -35,6 +35,9 @@ enum class user_command {
independentbrakedecreasefast, independentbrakedecreasefast,
independentbrakeset, independentbrakeset,
independentbrakebailoff, independentbrakebailoff,
universalbrakebutton1,
universalbrakebutton2,
universalbrakebutton3,
trainbrakeincrease, trainbrakeincrease,
trainbrakedecrease, trainbrakedecrease,
trainbrakeset, trainbrakeset,
@@ -54,6 +57,9 @@ enum class user_command {
alarmchaintoggle, alarmchaintoggle,
wheelspinbrakeactivate, wheelspinbrakeactivate,
sandboxactivate, sandboxactivate,
autosandboxtoggle,
autosandboxactivate,
autosandboxdeactivate,
reverserincrease, reverserincrease,
reverserdecrease, reverserdecrease,
reverserforwardhigh, reverserforwardhigh,
@@ -93,6 +99,9 @@ enum class user_command {
compressorenable, compressorenable,
compressordisable, compressordisable,
compressortogglelocal, compressortogglelocal,
compressorpresetactivatenext,
compressorpresetactivateprevious,
compressorpresetactivatedefault,
motoroverloadrelaythresholdtoggle, motoroverloadrelaythresholdtoggle,
motoroverloadrelaythresholdsetlow, motoroverloadrelaythresholdsetlow,
motoroverloadrelaythresholdsethigh, motoroverloadrelaythresholdsethigh,
@@ -223,6 +232,13 @@ enum class user_command {
motorblowersdisableall, motorblowersdisableall,
coolingfanstoggle, coolingfanstoggle,
tempomattoggle, tempomattoggle,
springbraketoggle,
springbrakeenable,
springbrakedisable,
springbrakeshutofftoggle,
springbrakeshutoffenable,
springbrakeshutoffdisable,
springbrakerelease,
none = -1 none = -1
}; };

View File

@@ -231,6 +231,13 @@ driverkeyboard_input::default_bindings() {
{ user_command::motorblowersdisableall, GLFW_KEY_M | keymodifier::control } { user_command::motorblowersdisableall, GLFW_KEY_M | keymodifier::control }
// coolingfanstoggle // coolingfanstoggle
// tempomattoggle // tempomattoggle
// springbraketoggle
// springbrakeenable
// springbrakedisable
// springbrakeshutofftoggle
// springbrakeshutoffenable
// springbrakeshutoffdisable
// springbrakerelease
}; };
} }

View File

@@ -721,20 +721,36 @@ driver_mode::OnKeyDown(int cKey) {
if( tmp != nullptr ) { if( tmp != nullptr ) {
if( simulation::Train ) {// jeśli mielismy pojazd
if( simulation::Train->Dynamic()->Mechanik ) { // na skutek jakiegoś błędu może czasem zniknąć
simulation::Train->Dynamic()->Mechanik->TakeControl( true ); // oddajemy dotychczasowy AI
}
}
if( ( true == DebugModeFlag ) if( ( true == DebugModeFlag )
|| ( tmp->MoverParameters->Vel <= 5.0 ) ) { || ( tmp->MoverParameters->Vel <= 5.0 ) ) {
// works always in debug mode, or for stopped/slow moving vehicles otherwise // works always in debug mode, or for stopped/slow moving vehicles otherwise
if( simulation::Train ) { // jeśli mielismy pojazd
if( simulation::Train->Dynamic()->Mechanik ) { // na skutek jakiegoś błędu może czasem zniknąć
if( ( tmp->ctOwner == simulation::Train->Dynamic()->Mechanik )
&& ( true == Global.ctrlState ) ) {
// if the vehicle we left to the ai controlled the vehicle we're about to take over
// put the ai we left in charge of our old vehicle to sleep
// TODO: remove ctrl key mode once manual cab (de)activation is in place
simulation::Train->Dynamic()->Mechanik->primary( false );
simulation::Train->Dynamic()->Mechanik->action() = TAction::actSleep;
simulation::Train->Dynamic()->MoverParameters->CabDeactivisation();
}
simulation::Train->Dynamic()->Mechanik->TakeControl( true ); // oddajemy dotychczasowy AI
}
}
if( simulation::Train == nullptr ) { if( simulation::Train == nullptr ) {
simulation::Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy simulation::Train = new TTrain(); // jeśli niczym jeszcze nie jeździlismy
} }
if( simulation::Train->Init( tmp ) ) { // przejmujemy sterowanie if( simulation::Train->Init( tmp ) ) {
simulation::Train->Dynamic()->Mechanik->TakeControl( false ); // przejmujemy sterowanie
if( true == Global.ctrlState ) {
// make sure we can take over the consist
// TODO: remove ctrl key mode once manual cab (de)activation is in place
simulation::Train->Dynamic()->Mechanik->primary( true );
simulation::Train->Dynamic()->MoverParameters->CabActivisation();
}
simulation::Train->Dynamic()->Mechanik->TakeControl( false, true );
} }
else { else {
SafeDelete( simulation::Train ); // i nie ma czym sterować SafeDelete( simulation::Train ); // i nie ma czym sterować

View File

@@ -571,6 +571,24 @@ drivermouse_input::default_bindings() {
{ "releaser_bt:", { { "releaser_bt:", {
user_command::independentbrakebailoff, user_command::independentbrakebailoff,
user_command::none } }, user_command::none } },
{ "springbraketoggle_bt:",{
user_command::springbraketoggle,
user_command::none } },
{ "springbrakeon_bt:",{
user_command::springbrakeenable,
user_command::none } },
{ "springbrakeoff_bt:",{
user_command::springbrakedisable,
user_command::none } },
{ "universalbrake1_bt:",{
user_command::universalbrakebutton1,
user_command::none } },
{ "universalbrake2_bt:",{
user_command::universalbrakebutton2,
user_command::none } },
{ "universalbrake3_bt:",{
user_command::universalbrakebutton3,
user_command::none } },
{ "sand_bt:", { { "sand_bt:", {
user_command::sandboxactivate, user_command::sandboxactivate,
user_command::none } }, user_command::none } },
@@ -682,6 +700,9 @@ drivermouse_input::default_bindings() {
{ "compressorlocal_sw:", { { "compressorlocal_sw:", {
user_command::compressortogglelocal, user_command::compressortogglelocal,
user_command::none } }, user_command::none } },
{ "compressorlist_sw:", {
user_command::compressorpresetactivatenext,
user_command::compressorpresetactivateprevious } },
{ "converter_sw:", { { "converter_sw:", {
user_command::convertertoggle, user_command::convertertoggle,
user_command::none } }, user_command::none } },

View File

@@ -170,7 +170,7 @@ scenario_panel::update() {
std::get<TDynamicObject *>( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) ); // w trybie latania lokalizujemy wg mapy std::get<TDynamicObject *>( simulation::Region->find_vehicle( camera.Pos, 20, false, false ) ) ); // w trybie latania lokalizujemy wg mapy
if( m_nearest == nullptr ) { return; } if( m_nearest == nullptr ) { return; }
auto const *owner { ( auto const *owner { (
( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->Primary() ) ) ? ( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->primary() ) ) ?
m_nearest->Mechanik : m_nearest->Mechanik :
m_nearest->ctOwner ) }; m_nearest->ctOwner ) };
if( owner == nullptr ) { return; } if( owner == nullptr ) { return; }
@@ -208,7 +208,7 @@ scenario_panel::render() {
if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) { if( true == ImGui::Begin( panelname.c_str(), &is_open, flags ) ) {
// potential assignment section // potential assignment section
auto const *owner { ( auto const *owner { (
( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->Primary() ) ) ? ( ( m_nearest->Mechanik != nullptr ) && ( m_nearest->Mechanik->primary() ) ) ?
m_nearest->Mechanik : m_nearest->Mechanik :
m_nearest->ctOwner ) }; m_nearest->ctOwner ) };
if( owner != nullptr ) { if( owner != nullptr ) {
@@ -261,7 +261,7 @@ timetable_panel::update() {
if( vehicle == nullptr ) { return; } if( vehicle == nullptr ) { return; }
// if the nearest located vehicle doesn't have a direct driver, try to query its owner // if the nearest located vehicle doesn't have a direct driver, try to query its owner
auto const *owner = ( auto const *owner = (
( ( vehicle->Mechanik != nullptr ) && ( vehicle->Mechanik->Primary() ) ) ? ( ( vehicle->Mechanik != nullptr ) && ( vehicle->Mechanik->primary() ) ) ?
vehicle->Mechanik : vehicle->Mechanik :
vehicle->ctOwner ); vehicle->ctOwner );
if( owner == nullptr ) { return; } if( owner == nullptr ) { return; }
@@ -555,7 +555,7 @@ debug_panel::update_section_vehicle( std::vector<text_line> &Output ) {
auto const &vehicle { *m_input.vehicle }; auto const &vehicle { *m_input.vehicle };
auto const &mover { *m_input.mover }; auto const &mover { *m_input.mover };
auto const isowned { ( vehicle.Mechanik == nullptr ) && ( vehicle.ctOwner != nullptr ) }; auto const isowned { /* ( vehicle.Mechanik == nullptr ) && */ ( vehicle.ctOwner != nullptr ) && ( vehicle.ctOwner->Vehicle() != m_input.vehicle ) };
auto const isplayervehicle { ( m_input.train != nullptr ) && ( m_input.train->Dynamic() == m_input.vehicle ) }; auto const isplayervehicle { ( m_input.train != nullptr ) && ( m_input.train->Dynamic() == m_input.vehicle ) };
auto const isdieselenginepowered { ( mover.EngineType == TEngineType::DieselElectric ) || ( mover.EngineType == TEngineType::DieselEngine ) }; auto const isdieselenginepowered { ( mover.EngineType == TEngineType::DieselElectric ) || ( mover.EngineType == TEngineType::DieselEngine ) };
auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric }; auto const isdieselinshuntmode { mover.ShuntMode && mover.EngineType == TEngineType::DieselElectric };

View File

@@ -369,7 +369,7 @@ WyslijObsadzone()
r.fPar[ 16 * i + 4 ] = vehicle->GetPosition().x; r.fPar[ 16 * i + 4 ] = vehicle->GetPosition().x;
r.fPar[ 16 * i + 5 ] = vehicle->GetPosition().y; r.fPar[ 16 * i + 5 ] = vehicle->GetPosition().y;
r.fPar[ 16 * i + 6 ] = vehicle->GetPosition().z; r.fPar[ 16 * i + 6 ] = vehicle->GetPosition().z;
r.iPar[ 16 * i + 7 ] = static_cast<int>( vehicle->Mechanik->GetAction() ); r.iPar[ 16 * i + 7 ] = static_cast<int>( vehicle->Mechanik->action() );
strcpy( r.cString + 64 * i + 32, vehicle->GetTrack()->IsolatedName().c_str() ); strcpy( r.cString + 64 * i + 32, vehicle->GetTrack()->IsolatedName().c_str() );
strcpy( r.cString + 64 * i + 48, vehicle->Mechanik->TrainName().c_str() ); strcpy( r.cString + 64 * i + 48, vehicle->Mechanik->TrainName().c_str() );
i++; i++;

View File

@@ -179,16 +179,17 @@ opengl_particles::update( opengl_camera const &Camera ) {
if( m_buffercapacity < m_particlevertices.size() ) { if( m_buffercapacity < m_particlevertices.size() ) {
// allocate gpu side buffer big enough to hold the data // allocate gpu side buffer big enough to hold the data
m_buffercapacity = 0; m_buffercapacity = 0;
if( m_buffer != -1 ) { if( m_buffer != (GLuint)-1 ) {
// get rid of the old buffer // get rid of the old buffer
::glDeleteBuffers( 1, &m_buffer ); ::glDeleteBuffers( 1, &m_buffer );
m_buffer = (GLuint)-1;
} }
::glGenBuffers( 1, &m_buffer ); ::glGenBuffers( 1, &m_buffer );
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer ); if( ( m_buffer > 0 ) && ( m_buffer != (GLuint)-1 ) ) {
if( m_buffer > 0 ) {
// if we didn't get a buffer we'll try again during the next draw call // if we didn't get a buffer we'll try again during the next draw call
// NOTE: we match capacity instead of current size to reduce number of re-allocations // NOTE: we match capacity instead of current size to reduce number of re-allocations
auto const particlecount { m_particlevertices.capacity() }; auto const particlecount { m_particlevertices.capacity() };
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer );
::glBufferData( ::glBufferData(
GL_ARRAY_BUFFER, GL_ARRAY_BUFFER,
particlecount * sizeof( particle_vertex ), particlecount * sizeof( particle_vertex ),
@@ -198,7 +199,7 @@ opengl_particles::update( opengl_camera const &Camera ) {
// TBD: throw a bad_alloc? // TBD: throw a bad_alloc?
ErrorLog( "openGL error: out of memory; failed to create a geometry buffer" ); ErrorLog( "openGL error: out of memory; failed to create a geometry buffer" );
::glDeleteBuffers( 1, &m_buffer ); ::glDeleteBuffers( 1, &m_buffer );
m_buffer = -1; m_buffer = (GLuint)-1;
} }
else { else {
m_buffercapacity = particlecount; m_buffercapacity = particlecount;
@@ -206,7 +207,7 @@ opengl_particles::update( opengl_camera const &Camera ) {
} }
} }
// ...send the data... // ...send the data...
if( m_buffer > 0 ) { if( ( m_buffer > 0 ) && ( m_buffer != (GLuint)-1 ) ) {
// if the buffer exists at this point it's guaranteed to be big enough to hold our data // if the buffer exists at this point it's guaranteed to be big enough to hold our data
::glBindBuffer( GL_ARRAY_BUFFER, m_buffer ); ::glBindBuffer( GL_ARRAY_BUFFER, m_buffer );
::glBufferSubData( ::glBufferSubData(
@@ -225,6 +226,7 @@ opengl_particles::render( int const Textureunit ) {
if( false == Global.Smoke ) { return; } if( false == Global.Smoke ) { return; }
if( m_buffercapacity == 0 ) { return; } if( m_buffercapacity == 0 ) { return; }
if( m_particlevertices.empty() ) { return; } if( m_particlevertices.empty() ) { return; }
if( ( m_buffer == 0 ) || ( m_buffer == (GLuint)-1 ) ) { return; }
// setup... // setup...
::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT ); ::glPushClientAttrib( GL_CLIENT_VERTEX_ARRAY_BIT );
@@ -239,6 +241,8 @@ opengl_particles::render( int const Textureunit ) {
// ...draw... // ...draw...
::glDrawArrays( GL_QUADS, 0, m_particlevertices.size() ); ::glDrawArrays( GL_QUADS, 0, m_particlevertices.size() );
// ...and cleanup // ...and cleanup
::glBindBuffer( GL_ARRAY_BUFFER, 0 );
gfx::opengl_vbogeometrybank::reset();
::glPopClientAttrib(); ::glPopClientAttrib();
} }
@@ -963,12 +967,7 @@ opengl_renderer::Render_reflections() {
if( Global.ReflectionUpdatesPerSecond == 0 ) { return false; } if( Global.ReflectionUpdatesPerSecond == 0 ) { return false; }
auto const &time = simulation::Time.data(); auto const timestamp { static_cast<int>( Timer::GetTime() * 1000 ) };
auto const timestamp =
time.wMilliseconds
+ time.wSecond * 1000
+ time.wMinute * 1000 * 60
+ time.wHour * 1000 * 60 * 60;
if( ( timestamp - m_environmentupdatetime < Global.ReflectionUpdatesPerSecond ) if( ( timestamp - m_environmentupdatetime < Global.ReflectionUpdatesPerSecond )
&& ( glm::length( m_renderpass.camera.position() - m_environmentupdatelocation ) < 1000.0 ) ) { && ( glm::length( m_renderpass.camera.position() - m_environmentupdatelocation ) < 1000.0 ) ) {
// run update every 5+ mins of simulation time, or at least 1km from the last location // run update every 5+ mins of simulation time, or at least 1km from the last location
@@ -3187,7 +3186,6 @@ opengl_renderer::Render_particles() {
Bind_Texture( m_smoketexture ); Bind_Texture( m_smoketexture );
m_particlerenderer.render( m_diffusetextureunit ); m_particlerenderer.render( m_diffusetextureunit );
gfx::opengl_vbogeometrybank::reset();
::glDepthMask( GL_TRUE ); ::glDepthMask( GL_TRUE );
::glEnable( GL_LIGHTING ); ::glEnable( GL_LIGHTING );

View File

@@ -679,7 +679,7 @@ state_serializer::deserialize_endtrainset( cParser &Input, scene::scratch_data &
for( auto *vehicle : Scratchpad.trainset.vehicles ) { for( auto *vehicle : Scratchpad.trainset.vehicles ) {
// go through list of vehicles in the trainset, coupling them together and checking for potential driver // go through list of vehicles in the trainset, coupling them together and checking for potential driver
if( ( vehicle->Mechanik != nullptr ) if( ( vehicle->Mechanik != nullptr )
&& ( vehicle->Mechanik->Primary() ) ) { && ( vehicle->Mechanik->primary() ) ) {
// primary driver will receive the timetable for this trainset // primary driver will receive the timetable for this trainset
Scratchpad.trainset.driver = vehicle; Scratchpad.trainset.driver = vehicle;
// they'll also receive assignment data if there's any // they'll also receive assignment data if there's any

View File

@@ -1 +1 @@
#define VERSION_INFO "M7 12.09.2019" #define VERSION_INFO "M7 15.09.2019"

View File

@@ -5,6 +5,12 @@
#pragma warning (disable: 4091) #pragma warning (disable: 4091)
#include <dbghelp.h> #include <dbghelp.h>
extern "C"
{
__declspec(dllexport) DWORD NvOptimusEnablement = 0x00000001;
__declspec(dllexport) DWORD AmdPowerXpressRequestHighPerformance = 0x00000001;
}
LONG CALLBACK unhandled_handler(::EXCEPTION_POINTERS* e) LONG CALLBACK unhandled_handler(::EXCEPTION_POINTERS* e)
{ {
auto hDbgHelp = ::LoadLibraryA("dbghelp"); auto hDbgHelp = ::LoadLibraryA("dbghelp");