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

Merge with TMJ

This commit is contained in:
Królik Uszasty
2019-03-21 08:03:36 +01:00
17 changed files with 315 additions and 147 deletions

View File

@@ -1765,15 +1765,10 @@ void TController::Activation()
if (iDirection) if (iDirection)
{ // jeśli jest ustalony kierunek { // jeśli jest ustalony kierunek
TDynamicObject *old = pVehicle, *d = pVehicle; // w tym siedzi AI TDynamicObject *old = pVehicle, *d = pVehicle; // w tym siedzi AI
TController *drugi; // jakby były dwa, to zamienić miejscami, a nie robić wycieku pamięci TController *drugi; // jakby były dwa, to zamienić miejscami, a nie robić wycieku pamięci poprzez nadpisanie
// poprzez nadpisanie
auto const localbrakelevel { mvOccupied->LocalBrakePosA }; auto const localbrakelevel { mvOccupied->LocalBrakePosA };
while (mvControlling->MainCtrlPos) // samo zapętlenie DecSpeed() nie wystarcza :/ ZeroSpeed();
DecSpeed(true); // wymuszenie zerowania nastawnika jazdy ZeroDirection();
while (mvOccupied->ActiveDir < 0)
mvOccupied->DirectionForward(); // kierunek na 0
while (mvOccupied->ActiveDir > 0)
mvOccupied->DirectionBackward();
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
@@ -2396,7 +2391,7 @@ void TController::SetDriverPsyche()
} }
if (mvControlling && mvOccupied) if (mvControlling && mvOccupied)
{ // with Controlling do { // with Controlling do
if (mvControlling->MainCtrlPos < 3) if (mvControlling->MainCtrlPowerPos() < 3)
ReactionTime = mvControlling->InitialCtrlDelay + ReactionTime; ReactionTime = mvControlling->InitialCtrlDelay + ReactionTime;
if (mvOccupied->BrakeCtrlPos > 1) if (mvOccupied->BrakeCtrlPos > 1)
ReactionTime = 0.5 * ReactionTime; ReactionTime = 0.5 * ReactionTime;
@@ -2493,17 +2488,16 @@ bool TController::PrepareEngine()
{ // część wykonawcza dla sterowania przez komputer { // część wykonawcza dla sterowania przez komputer
if (mvControlling->ConvOvldFlag) if (mvControlling->ConvOvldFlag)
{ // wywalił bezpiecznik nadmiarowy przetwornicy { // wywalił bezpiecznik nadmiarowy przetwornicy
while (DecSpeed(true)) ZeroSpeed();
; // zerowanie napędu
mvControlling->ConvOvldFlag = false; // reset nadmiarowego mvControlling->ConvOvldFlag = false; // reset nadmiarowego
} }
else if (false == IsLineBreakerClosed) { else if (false == IsLineBreakerClosed) {
while (DecSpeed(true)) ZeroSpeed();
; // zerowanie napędu
if( mvOccupied->TrainType == dt_SN61 ) { if( mvOccupied->TrainType == dt_SN61 ) {
// specjalnie dla SN61 żeby nie zgasł // specjalnie dla SN61 żeby nie zgasł
if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) { while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 )
mvControlling->IncMainCtrl( 1 ); && ( mvControlling->IncMainCtrl( 1 ) ) ) {
;
} }
} }
if( ( mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector ) if( ( mvControlling->EnginePowerSource.SourceType != TPowerSource::CurrentCollector )
@@ -2521,6 +2515,10 @@ bool TController::PrepareEngine()
mvOccupied->MotorBlowersSwitch( true, end::front ); mvOccupied->MotorBlowersSwitch( true, end::front );
mvOccupied->MotorBlowersSwitchOff( false, end::rear ); mvOccupied->MotorBlowersSwitchOff( false, end::rear );
mvOccupied->MotorBlowersSwitch( true, end::rear ); mvOccupied->MotorBlowersSwitch( true, end::rear );
// enable train brake if it's off
if( mvOccupied->fBrakeCtrlPos == mvOccupied->Handle->GetPos( bh_NP ) ) {
mvOccupied->BrakeLevelSet( mvOccupied->Handle->GetPos( bh_RP ) );
}
} }
} }
else else
@@ -2558,9 +2556,7 @@ bool TController::ReleaseEngine() {
VelDesired = 0.0; VelDesired = 0.0;
AccDesired = std::min( AccDesired, -1.25 ); // hamuj solidnie AccDesired = std::min( AccDesired, -1.25 ); // hamuj solidnie
ReactionTime = 0.1; ReactionTime = 0.1;
while( DecSpeed( true ) ) { ZeroSpeed();
; // zerowanie nastawników
}
IncBrake(); IncBrake();
// don't bother with the rest until we're standing still // don't bother with the rest until we're standing still
return false; return false;
@@ -2597,12 +2593,8 @@ bool TController::ReleaseEngine() {
; ;
} }
} }
while( DecSpeed( true ) ) { ZeroSpeed();
; // zerowanie nastawników ZeroDirection();
}
// set direction to neutral
while( ( mvOccupied->ActiveDir > 0 ) && ( mvOccupied->DirectionBackward() ) ) { ; }
while( ( mvOccupied->ActiveDir < 0 ) && ( mvOccupied->DirectionForward() ) ) { ; }
// zamykanie drzwi // zamykanie drzwi
mvOccupied->OperateDoors( side::right, false ); mvOccupied->OperateDoors( side::right, false );
@@ -2714,9 +2706,17 @@ bool TController::IncBrake()
} }
} }
} }
standalone = standalone && ( mvControlling->EIMCtrlType == 0 );
if( true == standalone ) { if( true == standalone ) {
OK = mvOccupied->IncLocalBrakeLevel( if( mvControlling->EIMCtrlType > 0 ) {
1 + static_cast<int>( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); // hamowanie lokalnym bo luzem jedzie OK = IncBrakeEIM();
}
else {
OK = mvOccupied->IncLocalBrakeLevel(
1 + static_cast<int>( std::floor( 0.5 + std::fabs( AccDesired ) ) ) ); // hamowanie lokalnym bo luzem jedzie
}
} }
else { else {
if( mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo ) { if( mvOccupied->BrakeCtrlPos + 1 == mvOccupied->BrakeCtrlPosNo ) {
@@ -2854,8 +2854,10 @@ bool TController::DecBrake()
mvOccupied->BrakeLevelSet(0.0); mvOccupied->BrakeLevelSet(0.0);
} }
} }
if (!OK) if( !OK ) {
OK = mvOccupied->DecLocalBrakeLevel(2); OK = DecBrakeEIM();
// OK = mvOccupied->DecLocalBrakeLevel(2);
}
if (mvOccupied->PipePress < 3.0) if (mvOccupied->PipePress < 3.0)
Need_BrakeRelease = true; Need_BrakeRelease = true;
break; break;
@@ -2944,7 +2946,7 @@ bool TController::IncSpeed()
return false; // to nici z ruszania return false; // to nici z ruszania
} }
if (!mvControlling->FuseFlag) //&&mvControlling->StLinFlag) //yBARC if (!mvControlling->FuseFlag) //&&mvControlling->StLinFlag) //yBARC
if ((mvControlling->MainCtrlPos == 0) || if ((mvControlling->IsMainCtrlNoPowerPos()) ||
(mvControlling->StLinFlag)) // youBy polecił dodać 2012-09-08 v367 (mvControlling->StLinFlag)) // youBy polecił dodać 2012-09-08 v367
// na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag) // na pozycji 0 przejdzie, a na pozostałych będzie czekać, aż się załączą liniowe (zgaśnie DelayCtrlFlag)
if (Ready || (iDrivigFlags & movePress)) { if (Ready || (iDrivigFlags & movePress)) {
@@ -3026,7 +3028,7 @@ bool TController::IncSpeed()
} }
if( ( mvControlling->Im == 0 ) if( ( mvControlling->Im == 0 )
&& ( mvControlling->MainCtrlPos > 2 ) ) { && ( mvControlling->MainCtrlPowerPos() > 1 ) ) {
// brak prądu na dalszych pozycjach // brak prądu na dalszych pozycjach
// nie załączona lokomotywa albo wywalił nadmiarowy // nie załączona lokomotywa albo wywalił nadmiarowy
Need_TryAgain = true; Need_TryAgain = true;
@@ -3094,6 +3096,13 @@ bool TController::IncSpeed()
return OK; return OK;
} }
void TController::ZeroSpeed( bool const Enforce ) {
while( DecSpeed( Enforce ) ) {
;
}
}
bool TController::DecSpeed(bool force) bool TController::DecSpeed(bool force)
{ // zmniejszenie prędkości (ale nie hamowanie) { // zmniejszenie prędkości (ale nie hamowanie)
bool OK = false; // domyślnie false, aby wyszło z pętli while bool OK = false; // domyślnie false, aby wyszło z pętli while
@@ -3103,20 +3112,20 @@ bool TController::DecSpeed(bool force)
iDrivigFlags &= ~moveIncSpeed; // usunięcie flagi jazdy iDrivigFlags &= ~moveIncSpeed; // usunięcie flagi jazdy
if (force) // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania if (force) // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania
if (mvControlling->MainCtrlPosNo > 0) // McZapkie-041003: wagon sterowniczy, np. EZT if (mvControlling->MainCtrlPosNo > 0) // McZapkie-041003: wagon sterowniczy, np. EZT
mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0)); mvControlling->DecMainCtrl((mvControlling->MainCtrlPowerPos() > 1 ? 2 : 1));
mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania
return false; return false;
case TEngineType::ElectricSeriesMotor: case TEngineType::ElectricSeriesMotor:
OK = mvControlling->DecScndCtrl(2); // najpierw bocznik na zero OK = mvControlling->DecScndCtrl(2); // najpierw bocznik na zero
if (!OK) if (!OK)
OK = mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0)); OK = mvControlling->DecMainCtrl((mvControlling->MainCtrlPowerPos() > 1 ? 2 : 1));
mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania mvControlling->AutoRelayCheck(); // sprawdzenie logiki sterowania
break; break;
case TEngineType::Dumb: case TEngineType::Dumb:
case TEngineType::DieselElectric: case TEngineType::DieselElectric:
OK = mvControlling->DecScndCtrl(2); OK = mvControlling->DecScndCtrl(2);
if (!OK) if (!OK)
OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPos / 2)); OK = mvControlling->DecMainCtrl(2 + (mvControlling->MainCtrlPowerPos() / 2));
break; break;
case TEngineType::ElectricInductionMotor: case TEngineType::ElectricInductionMotor:
OK = DecSpeedEIM(); OK = DecSpeedEIM();
@@ -3135,12 +3144,14 @@ bool TController::DecSpeed(bool force)
if (mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0) if (mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0)
OK = mvControlling->DecMainCtrl(1); OK = mvControlling->DecMainCtrl(1);
} }
else else {
while ((mvControlling->RList[mvControlling->MainCtrlPos].Mn > 0) && while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 )
(mvControlling->MainCtrlPos > 1)) && ( mvControlling->MainCtrlPowerPos() > 1 ) ) {
OK = mvControlling->DecMainCtrl(1); OK = mvControlling->DecMainCtrl( 1 );
}
}
if (force) // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania if (force) // przy aktywacji kabiny jest potrzeba natychmiastowego wyzerowania
OK = mvControlling->DecMainCtrl(1 + (mvControlling->MainCtrlPos > 2 ? 1 : 0)); OK = mvControlling->DecMainCtrl((mvControlling->MainCtrlPowerPos() > 2 ? 2 : 1));
break; break;
} }
return OK; return OK;
@@ -3240,8 +3251,7 @@ void TController::SpeedSet()
if( ( false == mvControlling->StLinFlag ) if( ( false == mvControlling->StLinFlag )
&& ( false == mvControlling->DelayCtrlFlag ) ) { && ( false == mvControlling->DelayCtrlFlag ) ) {
// styczniki liniowe rozłączone yBARC // styczniki liniowe rozłączone yBARC
while( DecSpeed() ) ZeroSpeed();
; // zerowanie napędu
} }
else if (Ready || (iDrivigFlags & movePress)) // o ile może jechać else if (Ready || (iDrivigFlags & movePress)) // o ile może jechać
if (fAccGravity < -0.10) // i jedzie pod górę większą niż 10 promil if (fAccGravity < -0.10) // i jedzie pod górę większą niż 10 promil
@@ -4104,9 +4114,14 @@ TController::UpdateSituation(double dt) {
// TODO: check if this situation still happens and the hack is still needed // TODO: check if this situation still happens and the hack is still needed
if( ( false == AIControllFlag ) if( ( false == AIControllFlag )
&& ( iDrivigFlags & moveDoorOpened ) && ( iDrivigFlags & moveDoorOpened )
&& ( mvOccupied->Doors.close_control != control_t::driver ) && ( mvOccupied->Doors.close_control != control_t::driver ) ) {
&& ( mvControlling->MainCtrlPos > ( mvControlling->EngineType != TEngineType::DieselEngine ? 0 : 1 ) ) ) { // for diesel 1st position is effectively 0 // for diesel engines react when engine is put past idle revolutions
Doors( false ); // for others straightforward master controller check
if( ( mvControlling->EngineType == TEngineType::DieselEngine ?
mvControlling->RList[ mvControlling->MainCtrlPos ].Mn > 0 :
mvControlling->MainCtrlPowerPos() > 0 ) ) {
Doors( false );
}
} }
// basic situational ai operations // basic situational ai operations
@@ -4167,7 +4182,7 @@ TController::UpdateSituation(double dt) {
// is moving // is moving
if( ( fOverhead2 >= 0.0 ) || iOverheadZero ) { if( ( fOverhead2 >= 0.0 ) || iOverheadZero ) {
// jeśli jazda bezprądowa albo z opuszczonym pantografem // jeśli jazda bezprądowa albo z opuszczonym pantografem
while( DecSpeed( true ) ) { ; } // zerowanie napędu ZeroSpeed();
} }
if( ( fOverhead2 > 0.0 ) || iOverheadDown ) { if( ( fOverhead2 > 0.0 ) || iOverheadDown ) {
// jazda z opuszczonymi pantografami // jazda z opuszczonymi pantografami
@@ -4263,7 +4278,7 @@ TController::UpdateSituation(double dt) {
if( ( true == TestFlag( iDrivigFlags, moveStartHornNow ) ) if( ( true == TestFlag( iDrivigFlags, moveStartHornNow ) )
&& ( true == Ready ) && ( true == Ready )
&& ( iEngineActive != 0 ) && ( iEngineActive != 0 )
&& ( mvControlling->MainCtrlPos > 0 ) ) { && ( mvControlling->MainCtrlPowerPos() > 0 ) ) {
// uruchomienie trąbienia przed ruszeniem // uruchomienie trąbienia przed ruszeniem
fWarningDuration = 0.3; // czas trąbienia fWarningDuration = 0.3; // czas trąbienia
mvOccupied->WarningSignal = pVehicle->iHornWarning; // wysokość tonu (2=wysoki) mvOccupied->WarningSignal = pVehicle->iHornWarning; // wysokość tonu (2=wysoki)
@@ -4783,7 +4798,7 @@ TController::UpdateSituation(double dt) {
// jeśli dociskanie w celu odczepienia // jeśli dociskanie w celu odczepienia
// 3. faza odczepiania. // 3. faza odczepiania.
SetVelocity(2, 0); // jazda w ustawionym kierunku z prędkością 2 SetVelocity(2, 0); // jazda w ustawionym kierunku z prędkością 2
if( ( mvControlling->MainCtrlPos > 0 ) if( ( mvControlling->MainCtrlPowerPos() > 0 )
|| ( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) { || ( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) {
// jeśli jazda // jeśli jazda
WriteLog(mvOccupied->Name + " odczepianie w kierunku " + std::to_string(mvOccupied->DirAbsolute)); WriteLog(mvOccupied->Name + " odczepianie w kierunku " + std::to_string(mvOccupied->DirAbsolute));
@@ -4874,16 +4889,15 @@ TController::UpdateSituation(double dt) {
if (iDrivigFlags & movePress) if (iDrivigFlags & movePress)
{ // 4. faza odczepiania: zwolnij i zmień kierunek { // 4. faza odczepiania: zwolnij i zmień kierunek
SetVelocity(0, 0, stopJoin); // wyłączyć przyspieszanie SetVelocity(0, 0, stopJoin); // wyłączyć przyspieszanie
if (!DecSpeed()) // jeśli już bardziej wyłączyć się nie da ZeroSpeed();
{ // ponowna zmiana kierunku // ponowna zmiana kierunku
WriteLog( mvOccupied->Name + " ponowna zmiana kierunku" ); WriteLog( mvOccupied->Name + " ponowna zmiana kierunku" );
DirectionForward(mvOccupied->ActiveDir < 0); // zmiana kierunku jazdy na właściwy DirectionForward(mvOccupied->ActiveDir < 0); // zmiana kierunku jazdy na właściwy
iDrivigFlags &= ~movePress; // koniec dociskania iDrivigFlags &= ~movePress; // koniec dociskania
JumpToNextOrder(); // zmieni światła JumpToNextOrder(); // zmieni światła
TableClear(); // skanowanie od nowa TableClear(); // skanowanie od nowa
iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem iDrivigFlags &= ~moveStartHorn; // bez trąbienia przed ruszeniem
SetVelocity(fShuntVelocity, fShuntVelocity); // ustawienie prędkości jazdy SetVelocity(fShuntVelocity, fShuntVelocity); // ustawienie prędkości jazdy
}
} }
} }
@@ -5449,7 +5463,7 @@ TController::UpdateSituation(double dt) {
if( ( true == mvOccupied->RadioStopFlag ) // radio-stop if( ( true == mvOccupied->RadioStopFlag ) // radio-stop
&& ( mvOccupied->Vel > 0.0 ) ) { // and still moving && ( mvOccupied->Vel > 0.0 ) ) { // and still moving
// if the radio-stop was issued don't waste effort trying to fight it // if the radio-stop was issued don't waste effort trying to fight it
while( true == DecSpeed() ) { ; } // just throttle down... ZeroSpeed(); // just throttle down...
return; // ...and don't touch any other controls return; // ...and don't touch any other controls
} }
@@ -5613,7 +5627,7 @@ TController::UpdateSituation(double dt) {
if( false == TestFlag( iDrivigFlags, movePress ) ) { if( false == TestFlag( iDrivigFlags, movePress ) ) {
// jeśli nie dociskanie // jeśli nie dociskanie
if( AccDesired < -0.05 ) { if( AccDesired < -0.05 ) {
while( true == DecSpeed() ) { ; } // jeśli hamujemy, to nie przyspieszamy ZeroSpeed();
} }
else if( ( vel > VelDesired ) else if( ( vel > VelDesired )
|| ( fAccGravity < -0.01 ? || ( fAccGravity < -0.01 ?
@@ -6402,21 +6416,35 @@ void TController::TakeControl(bool yes)
void TController::DirectionForward(bool forward) void TController::DirectionForward(bool forward)
{ // ustawienie jazdy do przodu dla true i do tyłu dla false (zależy od kabiny) { // ustawienie jazdy do przodu dla true i do tyłu dla false (zależy od kabiny)
while (mvControlling->MainCtrlPos) // samo zapętlenie DecSpeed() nie wystarcza ZeroSpeed( true ); // TODO: check if force switch is needed anymore here
DecSpeed(true); // wymuszenie zerowania nastawnika jazdy, inaczej się może zawiesić if( forward ) {
if (forward) // do przodu w obecnej kabinie
while (mvOccupied->ActiveDir <= 0) while( ( mvOccupied->ActiveDir <= 0 )
mvOccupied->DirectionForward(); // do przodu w obecnej kabinie && ( mvOccupied->DirectionForward() ) ) {
else ; // all work is done in the header
while (mvOccupied->ActiveDir >= 0)
mvOccupied->DirectionBackward(); // do tyłu w obecnej kabinie
if( mvOccupied->TrainType == dt_SN61 ) {
// specjalnie dla SN61 żeby nie zgasł
if( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 ) {
mvControlling->IncMainCtrl( 1 );
} }
} }
}; else {
// do tyłu w obecnej kabinie
while( ( mvOccupied->ActiveDir >= 0 )
&& ( mvOccupied->DirectionBackward() ) ) {
; // all work is done in the header
}
}
if( mvOccupied->TrainType == dt_SN61 ) {
// specjalnie dla SN61 żeby nie zgasł
while( ( mvControlling->RList[ mvControlling->MainCtrlPos ].Mn == 0 )
&& ( mvControlling->IncMainCtrl( 1 ) ) ) {
; // all work is done in the header
}
}
}
void TController::ZeroDirection() {
while( ( mvOccupied->ActiveDir > 0 ) && ( mvOccupied->DirectionBackward() ) ) { ; }
while( ( mvOccupied->ActiveDir < 0 ) && ( mvOccupied->DirectionForward() ) ) { ; }
}
Mtable::TTrainParameters const * Mtable::TTrainParameters const *
TController::TrainTimetable() const { TController::TrainTimetable() const {

View File

@@ -211,6 +211,7 @@ private:
bool DecBrake(); bool DecBrake();
bool IncSpeed(); bool IncSpeed();
bool DecSpeed(bool force = false); bool DecSpeed(bool force = false);
void ZeroSpeed( bool const Enforce = false );
bool IncBrakeEIM(); bool IncBrakeEIM();
bool DecBrakeEIM(); bool DecBrakeEIM();
bool IncSpeedEIM(); bool IncSpeedEIM();
@@ -224,6 +225,7 @@ private:
int CheckDirection(); int CheckDirection();
void WaitingSet(double Seconds); void WaitingSet(double Seconds);
void DirectionForward(bool forward); void DirectionForward(bool forward);
void ZeroDirection();
int OrderDirectionChange(int newdir, TMoverParameters *Vehicle); int OrderDirectionChange(int newdir, TMoverParameters *Vehicle);
void Lights(int head, int rear); void Lights(int head, int rear);
std::string StopReasonText() const; std::string StopReasonText() const;

View File

@@ -1591,6 +1591,8 @@ TDynamicObject::Init(std::string Name, // nazwa pojazdu, np. "EU07-424"
Error("Parameters mismatch: dynamic object " + asName + " from \"" + BaseDir + "/" + Type_Name + "\"" ); Error("Parameters mismatch: dynamic object " + asName + " from \"" + BaseDir + "/" + Type_Name + "\"" );
return 0.0; // zerowa długość to brak pojazdu return 0.0; // zerowa długość to brak pojazdu
} }
// controller position
MoverParameters->MainCtrlPos = MoverParameters->MainCtrlNoPowerPos();
// ustawienie pozycji hamulca // ustawienie pozycji hamulca
MoverParameters->LocalBrakePosA = 0.0; MoverParameters->LocalBrakePosA = 0.0;
if (driveractive) if (driveractive)
@@ -2298,6 +2300,8 @@ void TDynamicObject::LoadExchange( int const Disembark, int const Embark, int co
} }
} }
*/ */
if( Platform == 0 ) { return; } // edge case, if there's no accessible platforms discard the request
m_exchange.unload_count += Disembark; m_exchange.unload_count += Disembark;
m_exchange.load_count += Embark; m_exchange.load_count += Embark;
m_exchange.platforms = Platform; m_exchange.platforms = Platform;
@@ -2967,7 +2971,7 @@ bool TDynamicObject::Update(double dt, double dt1)
} }
MEDLogTime += dt1; MEDLogTime += dt1;
if ((MoverParameters->Vel < 0.1) || (MoverParameters->MainCtrlPos > 0)) if ((MoverParameters->Vel < 0.1) || (MoverParameters->MainCtrlPowerPos() > 0))
{ {
MEDLogInactiveTime += dt1; MEDLogInactiveTime += dt1;
} }
@@ -4067,7 +4071,7 @@ void TDynamicObject::RenderSounds() {
else { else {
// basic clash // basic clash
couplersounds.dsbBufferClamp couplersounds.dsbBufferClamp
.gain( 0.65f ) .gain( 1.f )
.play( sound_flags::exclusive ); .play( sound_flags::exclusive );
} }
} }
@@ -4092,7 +4096,7 @@ void TDynamicObject::RenderSounds() {
else { else {
// basic clash // basic clash
couplersounds.dsbCouplerStretch couplersounds.dsbCouplerStretch
.gain( 0.65f ) .gain( 1.f )
.play( sound_flags::exclusive ); .play( sound_flags::exclusive );
} }
} }

View File

@@ -980,12 +980,13 @@ public:
double TUHEX_Sum2 = 750; /*nastawa2 sterownika hamowania ED*/ double TUHEX_Sum2 = 750; /*nastawa2 sterownika hamowania ED*/
double TUHEX_Sum3 = 750; /*nastawa3 sterownika hamowania ED*/ double TUHEX_Sum3 = 750; /*nastawa3 sterownika hamowania ED*/
int TUHEX_Stages = 0; /*liczba stopni hamowania ED*/ int TUHEX_Stages = 0; /*liczba stopni hamowania ED*/
// TODO: wrap resistor fans variables and state into a device
int RVentType = 0; /*0 - brak, 1 - jest, 2 - automatycznie wlaczany*/ int RVentType = 0; /*0 - brak, 1 - jest, 2 - automatycznie wlaczany*/
double RVentnmax = 1.0; /*maks. obroty wentylatorow oporow rozruchowych*/ double RVentnmax = 1.0; /*maks. obroty wentylatorow oporow rozruchowych*/
double RVentCutOff = 0.0; /*rezystancja wylaczania wentylatorow dla RVentType=2*/ double RVentCutOff = 0.0; /*rezystancja wylaczania wentylatorow dla RVentType=2*/
double RVentSpeed { 0.5 }; //rozpedzanie sie wentylatora obr/s^2} double RVentSpeed { 0.5 }; //rozpedzanie sie wentylatora obr/s^2}
double RVentMinI { 50.0 }; //przy jakim pradzie sie wylaczaja} double RVentMinI { 50.0 }; //przy jakim pradzie sie wylaczaja}
bool RVentForceOn { false }; // forced activation switch
int CompressorPower = 1; // 0: main circuit, 1: z przetwornicy, reczne, 2: w przetwornicy, stale, 3: diesel engine, 4: converter of unit in front, 5: converter of unit behind int CompressorPower = 1; // 0: main circuit, 1: z przetwornicy, reczne, 2: w przetwornicy, stale, 3: diesel engine, 4: converter of unit in front, 5: converter of unit behind
int SmallCompressorPower = 0; /*Winger ZROBIC*/ int SmallCompressorPower = 0; /*Winger ZROBIC*/
bool Trafo = false; /*pojazd wyposażony w transformator*/ bool Trafo = false; /*pojazd wyposażony w transformator*/
@@ -1207,6 +1208,7 @@ public:
int LightsPos = 0; int LightsPos = 0;
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 CabNo = 0; //numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad int CabNo = 0; //numer kabiny, z której jest sterowanie: 1 lub -1; w przeciwnym razie brak sterowania - rozrzad
int DirAbsolute = 0; //zadany kierunek jazdy względem sprzęgów (1=w strone 0,-1=w stronę 1) int DirAbsolute = 0; //zadany kierunek jazdy względem sprzęgów (1=w strone 0,-1=w stronę 1)
int ActiveCab = 0; //numer kabiny, w ktorej jest obsada (zwykle jedna na skład) int ActiveCab = 0; //numer kabiny, w ktorej jest obsada (zwykle jedna na skład)
@@ -1355,6 +1357,7 @@ public:
int DettachStatus(int ConnectNo); int DettachStatus(int ConnectNo);
bool Dettach(int ConnectNo); bool Dettach(int ConnectNo);
bool DirectionForward(); bool DirectionForward();
bool DirectionBackward( void );/*! kierunek ruchu*/
void BrakeLevelSet(double b); void BrakeLevelSet(double b);
bool BrakeLevelAdd(double b); bool BrakeLevelAdd(double b);
bool IncBrakeLevel(); // wersja na użytek AI bool IncBrakeLevel(); // wersja na użytek AI
@@ -1391,6 +1394,9 @@ public:
/*! glowny nastawnik:*/ /*! glowny nastawnik:*/
bool IncMainCtrl(int CtrlSpeed); bool IncMainCtrl(int CtrlSpeed);
bool DecMainCtrl(int CtrlSpeed); bool DecMainCtrl(int CtrlSpeed);
bool IsMainCtrlNoPowerPos() const; // whether the master controller is set to position which won't generate any extra power
int MainCtrlNoPowerPos() const; // highest setting of master controller which won't cause engine to generate extra power
int MainCtrlPowerPos() const; // current setting of master controller, relative to the highest setting not generating extra power
/*! pomocniczy nastawnik:*/ /*! pomocniczy nastawnik:*/
bool IncScndCtrl(int CtrlSpeed); bool IncScndCtrl(int CtrlSpeed);
bool DecScndCtrl(int CtrlSpeed); bool DecScndCtrl(int CtrlSpeed);
@@ -1454,7 +1460,6 @@ public:
double ComputeRotatingWheel(double WForce, double dt, double n) const; double ComputeRotatingWheel(double WForce, double dt, double n) const;
/*--funkcje dla lokomotyw*/ /*--funkcje dla lokomotyw*/
bool DirectionBackward(void);/*! kierunek ruchu*/
bool WaterPumpBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water pump breaker state toggle bool WaterPumpBreakerSwitch( bool State, range_t const Notify = range_t::consist ); // water pump breaker state toggle
bool WaterPumpSwitch( bool State, range_t const Notify = range_t::consist ); // water pump state toggle bool WaterPumpSwitch( bool State, range_t const Notify = range_t::consist ); // water pump state toggle
bool WaterPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // water pump state toggle bool WaterPumpSwitchOff( bool State, range_t const Notify = range_t::consist ); // water pump state toggle
@@ -1578,6 +1583,7 @@ private:
bool readLightsList( std::string const &Input ); bool readLightsList( 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 );
}; };
//double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2); //double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);

View File

@@ -502,7 +502,7 @@ bool TMoverParameters::Dettach(int ConnectNo)
bool TMoverParameters::DirectionForward() bool TMoverParameters::DirectionForward()
{ {
if ((MainCtrlPosNo > 0) && (ActiveDir < 1) && (MainCtrlPos == 0)) if ((MainCtrlPosNo > 0) && (ActiveDir < 1) && (MainCtrlPos <= MaxMainCtrlPosNoDirChange) && (EIMDirectionChangeAllow()))
{ {
++ActiveDir; ++ActiveDir;
DirAbsolute = ActiveDir * CabNo; DirAbsolute = ActiveDir * CabNo;
@@ -512,7 +512,7 @@ bool TMoverParameters::DirectionForward()
SendCtrlToNext("Direction", ActiveDir, CabNo); SendCtrlToNext("Direction", ActiveDir, CabNo);
return true; return true;
} }
else if ((ActiveDir == 1) && (MainCtrlPos == 0) && (TrainType == dt_EZT) && (EngineType != TEngineType::ElectricInductionMotor)) else if ((ActiveDir == 1) && (IsMainCtrlNoPowerPos()) && (TrainType == dt_EZT) && (EngineType != TEngineType::ElectricInductionMotor))
return MinCurrentSwitch(true); //"wysoki rozruch" EN57 return MinCurrentSwitch(true); //"wysoki rozruch" EN57
return false; return false;
}; };
@@ -641,7 +641,7 @@ TMoverParameters::CurrentSwitch(bool const State) {
// for SM42/SP42 // for SM42/SP42
if( ( EngineType == TEngineType::DieselElectric ) if( ( EngineType == TEngineType::DieselElectric )
&& ( true == ShuntModeAllow ) && ( true == ShuntModeAllow )
&& ( MainCtrlPos == 0 ) ) { && ( IsMainCtrlNoPowerPos() ) ) {
ShuntMode = State; ShuntMode = State;
return true; return true;
} }
@@ -1732,17 +1732,17 @@ bool TMoverParameters::IncMainCtrl(int CtrlSpeed)
case TEngineType::DieselEngine: case TEngineType::DieselEngine:
{ {
if( CtrlSpeed > 1 ) { if( CtrlSpeed > 1 ) {
while( MainCtrlPos < MainCtrlPosNo ) { while( ( MainCtrlPos < MainCtrlPosNo )
IncMainCtrl( 1 ); && ( IncMainCtrl( 1 ) ) ) {
;
}
} }
else {
++MainCtrlPos;
} }
else { CompressorAllow = ( MainCtrlPowerPos() > 0 );
++MainCtrlPos; OK = true;
if( MainCtrlPos > 0 ) { CompressorAllow = true; }
else { CompressorAllow = false; }
}
OK = true;
break; break;
} }
@@ -1805,6 +1805,7 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
} }
else else
{ {
// TBD, TODO: replace with mainctrlpowerpos() check?
if (MainCtrlPos > 0) if (MainCtrlPos > 0)
{ {
if ((TrainType != dt_ET22) || if ((TrainType != dt_ET22) ||
@@ -1903,6 +1904,25 @@ bool TMoverParameters::DecMainCtrl(int CtrlSpeed)
return OK; return OK;
} }
bool TMoverParameters::IsMainCtrlNoPowerPos() const {
// TODO: wrap controller pieces into a class for potential specializations, similar to brake subsystems
return MainCtrlPos <= MainCtrlNoPowerPos();
}
int TMoverParameters::MainCtrlNoPowerPos() const {
switch( EIMCtrlType ) {
case 1: { return 3; }
case 2: { return 3; }
default: { return 0; }
}
}
int TMoverParameters::MainCtrlPowerPos() const {
return MainCtrlPos - MainCtrlNoPowerPos();
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160710 // Q: 20160710
// zwiększenie bocznika // zwiększenie bocznika
@@ -1911,14 +1931,13 @@ bool TMoverParameters::IncScndCtrl(int CtrlSpeed)
{ {
bool OK = false; bool OK = false;
if ((MainCtrlPos == 0) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) && if ((IsMainCtrlNoPowerPos()) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) && (DynamicBrakeFlag))
(DynamicBrakeFlag))
{ {
OK = DynamicBrakeSwitch(false); OK = DynamicBrakeSwitch(false);
} }
else if ((ScndCtrlPosNo > 0) && (CabNo != 0) && else if ((ScndCtrlPosNo > 0) && (CabNo != 0) &&
!((TrainType == dt_ET42) && !((TrainType == dt_ET42) &&
((Imax == ImaxHi) || ((DynamicBrakeFlag) && (MainCtrlPos > 0))))) ((Imax == ImaxHi) || ((DynamicBrakeFlag) && (MainCtrlPowerPos() > 0)))))
{ {
// if (RList[MainCtrlPos].R=0) and (MainCtrlPos>0) and (ScndCtrlPos<ScndCtrlPosNo) and // if (RList[MainCtrlPos].R=0) and (MainCtrlPos>0) and (ScndCtrlPos<ScndCtrlPosNo) and
// (not CoupledCtrl) then // (not CoupledCtrl) then
@@ -1973,7 +1992,7 @@ bool TMoverParameters::DecScndCtrl(int CtrlSpeed)
{ {
bool OK = false; bool OK = false;
if ((MainCtrlPos == 0) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) && if ((IsMainCtrlNoPowerPos()) && (CabNo != 0) && (TrainType == dt_ET42) && (ScndCtrlPos == 0) &&
!(DynamicBrakeFlag) && (CtrlSpeed == 1)) !(DynamicBrakeFlag) && (CtrlSpeed == 1))
{ {
// Ra: AI wywołuje z CtrlSpeed=2 albo gdy ScndCtrlPos>0 // Ra: AI wywołuje z CtrlSpeed=2 albo gdy ScndCtrlPos>0
@@ -2326,7 +2345,7 @@ bool TMoverParameters::DirectionBackward(void)
DB = true; // DB = true; //
return DB; // exit; TODO: czy dobrze przetlumaczone? return DB; // exit; TODO: czy dobrze przetlumaczone?
} }
if ((MainCtrlPosNo > 0) && (ActiveDir > -1) && (MainCtrlPos == 0)) if ((MainCtrlPosNo > 0) && (ActiveDir > -1) && (MainCtrlPos <= MaxMainCtrlPosNoDirChange) && (EIMDirectionChangeAllow()))
{ {
if (EngineType == TEngineType::WheelsDriven) if (EngineType == TEngineType::WheelsDriven)
CabNo--; CabNo--;
@@ -2344,6 +2363,13 @@ bool TMoverParameters::DirectionBackward(void)
return DB; return DB;
} }
bool TMoverParameters::EIMDirectionChangeAllow(void)
{
bool OK = false;
OK = (EngineType != TEngineType::ElectricInductionMotor || ((eimic <= 0) && (eimic_real <= 0) && (Vel < 0.1)));
return OK;
}
// ************************************************************************************************* // *************************************************************************************************
// Q: 20160710 // Q: 20160710
// załączenie przycisku przeciwpoślizgowego // załączenie przycisku przeciwpoślizgowego
@@ -2946,7 +2972,7 @@ bool TMoverParameters::DynamicBrakeSwitch(bool Switch)
{ {
bool DBS; bool DBS;
if ((DynamicBrakeType == dbrake_switch) && (MainCtrlPos == 0)) if ((DynamicBrakeType == dbrake_switch) && (IsMainCtrlNoPowerPos()))
{ {
DynamicBrakeFlag = Switch; DynamicBrakeFlag = Switch;
DBS = true; DBS = true;
@@ -3240,7 +3266,7 @@ void TMoverParameters::CompressorCheck(double dt)
if( ( true == CompressorAllow ) if( ( true == CompressorAllow )
&& ( true == CompressorAllowLocal ) && ( true == CompressorAllowLocal )
&& ( true == Mains ) && ( true == Mains )
&& ( MainCtrlPos > 0 ) ) { && ( MainCtrlPowerPos() > 0 ) ) {
if( Compressor < MaxCompressor ) { if( Compressor < MaxCompressor ) {
if( ( EngineType == TEngineType::DieselElectric ) if( ( EngineType == TEngineType::DieselElectric )
&& ( CompressorPower > 0 ) ) { && ( CompressorPower > 0 ) ) {
@@ -4400,8 +4426,9 @@ double TMoverParameters::TractionForce( double dt ) {
switch( RVentType ) { switch( RVentType ) {
case 1: { // manual case 1: { // manual
if( ( ActiveDir != 0 ) if( ( true == RVentForceOn )
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) { || ( ( ActiveDir != 0 )
&& ( RList[ MainCtrlActualPos ].R > RVentCutOff ) ) ) {
RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt; RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt;
} }
else { else {
@@ -4423,9 +4450,12 @@ double TMoverParameters::TractionForce( double dt ) {
* RVentSpeed * dt; * RVentSpeed * dt;
} }
else if( ( DynamicBrakeType == dbrake_automatic ) else if( ( DynamicBrakeType == dbrake_automatic )
&& ( true == DynamicBrakeFlag ) ) { && ( true == DynamicBrakeFlag ) ) {
RventRot += ( RVentnmax * motorcurrent / ImaxLo - RventRot ) * RVentSpeed * dt; RventRot += ( RVentnmax * motorcurrent / ImaxLo - RventRot ) * RVentSpeed * dt;
} }
else if( RVentForceOn ) {
RventRot += ( RVentnmax - RventRot ) * RVentSpeed * dt;
}
else { else {
RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt ); RventRot *= std::max( 0.0, 1.0 - RVentSpeed * dt );
} }
@@ -4485,7 +4515,7 @@ double TMoverParameters::TractionForce( double dt ) {
} }
case TEngineType::DieselEngine: { case TEngineType::DieselEngine: {
EnginePower = ( 2 * dizel_Mstand + dmoment ) * enrot * ( 2.0 * M_PI / 1000.0 ); EnginePower = ( 2 * dizel_Mstand + dmoment ) * enrot * ( 2.0 * M_PI / 1000.0 );
if( MainCtrlPos > 1 ) { if( MainCtrlPowerPos() > 1 ) {
// dodatkowe opory z powodu sprezarki} // dodatkowe opory z powodu sprezarki}
dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax ); dmoment -= dizel_Mstand * ( 0.2 * enrot / dizel_nmax );
} }
@@ -4682,7 +4712,7 @@ double TMoverParameters::TractionForce( double dt ) {
auto const tmpV { nrot * Pirazy2 * 0.5 * WheelDiameter * DirAbsolute }; //*CabNo*ActiveDir; auto const tmpV { nrot * Pirazy2 * 0.5 * WheelDiameter * DirAbsolute }; //*CabNo*ActiveDir;
// jazda manewrowa // jazda manewrowa
if( true == ShuntMode ) { if( true == ShuntMode ) {
if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) { if( ( true == Mains ) && ( MainCtrlPowerPos() > 0 ) ) {
Voltage = ( SST[ MainCtrlPos ].Umax * AnPos ) + ( SST[ MainCtrlPos ].Umin * ( 1.0 - AnPos ) ); Voltage = ( SST[ MainCtrlPos ].Umax * AnPos ) + ( SST[ MainCtrlPos ].Umin * ( 1.0 - AnPos ) );
// NOTE: very crude way to approximate power generated at current rpm instead of instant top output // NOTE: very crude way to approximate power generated at current rpm instead of instant top output
// NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it // NOTE, TODO: doesn't take into account potentially increased revolutions if heating is on, fix it
@@ -4713,7 +4743,7 @@ double TMoverParameters::TractionForce( double dt ) {
PosRatio = currentgenpower / DElist[MainCtrlPosNo].GenPower; PosRatio = currentgenpower / DElist[MainCtrlPosNo].GenPower;
// stosunek mocy teraz do mocy max // stosunek mocy teraz do mocy max
// NOTE: Mains in this context is working diesel engine // NOTE: Mains in this context is working diesel engine
if( ( true == Mains ) && ( MainCtrlPos > 0 ) ) { if( ( true == Mains ) && ( MainCtrlPowerPos() > 0 ) ) {
if( tmpV < ( Vhyp * power / DElist[ MainCtrlPosNo ].GenPower ) ) { if( tmpV < ( Vhyp * power / DElist[ MainCtrlPosNo ].GenPower ) ) {
// czy na czesci prostej, czy na hiperboli // czy na czesci prostej, czy na hiperboli
@@ -4815,7 +4845,7 @@ double TMoverParameters::TractionForce( double dt ) {
Voltage = 0; Voltage = 0;
// przekazniki bocznikowania, kazdy inny dla kazdej pozycji // przekazniki bocznikowania, kazdy inny dla kazdej pozycji
if ((MainCtrlPos == 0) || (ShuntMode) || (false==Mains)) if ((IsMainCtrlNoPowerPos()) || (ShuntMode) || (false==Mains))
ScndCtrlPos = 0; ScndCtrlPos = 0;
else { else {
@@ -5298,7 +5328,7 @@ bool TMoverParameters::FuseFlagCheck(void) const
bool TMoverParameters::FuseOn(void) bool TMoverParameters::FuseOn(void)
{ {
bool FO = false; bool FO = false;
if ((MainCtrlPos == 0) && (ScndCtrlPos == 0) && (TrainType != dt_ET40) && if ((IsMainCtrlNoPowerPos()) && (ScndCtrlPos == 0) && (TrainType != dt_ET40) &&
((Mains) || (TrainType != dt_EZT)) && (!TestFlag(EngDmgFlag, 1))) ((Mains) || (TrainType != dt_EZT)) && (!TestFlag(EngDmgFlag, 1)))
{ // w ET40 jest blokada nastawnika, ale czy działa dobrze? { // w ET40 jest blokada nastawnika, ale czy działa dobrze?
SendCtrlToNext("FuseSwitch", 1, CabNo); SendCtrlToNext("FuseSwitch", 1, CabNo);
@@ -5786,7 +5816,7 @@ bool TMoverParameters::MotorConnectorsCheck() {
( false == Mains ) ( false == Mains )
|| ( true == FuseFlag ) || ( true == FuseFlag )
|| ( true == StLinSwitchOff ) || ( true == StLinSwitchOff )
|| ( MainCtrlPos == 0 ) || ( IsMainCtrlNoPowerPos() )
|| ( ActiveDir == 0 ) }; || ( ActiveDir == 0 ) };
if( connectorsoff ) { return false; } if( connectorsoff ) { return false; }
@@ -5794,8 +5824,9 @@ bool TMoverParameters::MotorConnectorsCheck() {
auto const connectorson { auto const connectorson {
( true == StLinFlag ) ( true == StLinFlag )
|| ( ( MainCtrlActualPos == 0 ) || ( ( MainCtrlActualPos == 0 )
&& ( ( MainCtrlPos == 1 ) && ( ( TrainType != dt_EZT ?
|| ( ( TrainType == dt_EZT ) && ( MainCtrlPos > 0 ) ) ) ) }; MainCtrlPowerPos() == 1 :
MainCtrlPowerPos() > 0 ) ) ) };
return connectorson; return connectorson;
} }
@@ -6043,7 +6074,7 @@ bool TMoverParameters::dizel_AutoGearCheck(void)
{ {
if (dizel_engagestate > 0) if (dizel_engagestate > 0)
dizel_EngageSwitch(0); dizel_EngageSwitch(0);
if ((MainCtrlPos == 0) && (ScndCtrlActualPos > 0)) if ((IsMainCtrlNoPowerPos()) && (ScndCtrlActualPos > 0))
dizel_automaticgearstatus = -1; dizel_automaticgearstatus = -1;
} }
else else
@@ -6131,12 +6162,13 @@ bool TMoverParameters::dizel_StartupCheck() {
// test the fuel pump // test the fuel pump
// TODO: add fuel pressure check // TODO: add fuel pressure check
if( false == FuelPump.is_active ) { if( ( false == FuelPump.is_active )
|| ( ( EngineType == TEngineType::DieselEngine ) && ( RList[ MainCtrlPos ].R == 0.0 ) ) ) {
engineisready = false; engineisready = false;
if( FuelPump.start_type == start_t::manual ) { // if( FuelPump.start_type == start_t::manual ) {
// with manual pump control startup procedure is done only once per starter switch press // with manual pump control startup procedure is done only once per starter switch press
dizel_startup = false; dizel_startup = false;
} // }
} }
// test the oil pump // test the oil pump
if( ( false == OilPump.is_active ) if( ( false == OilPump.is_active )
@@ -6326,10 +6358,10 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
if (hydro_TC) //jesli przetwornik momentu if (hydro_TC) //jesli przetwornik momentu
{ {
//napelnianie przetwornika //napelnianie przetwornika
if ((MainCtrlPos > 0) && (Mains) && (enrot>dizel_nmin*0.9)) if ((MainCtrlPowerPos() > 0) && (Mains) && (enrot>dizel_nmin*0.9))
hydro_TC_Fill += hydro_TC_FillRateInc * dt; hydro_TC_Fill += hydro_TC_FillRateInc * dt;
//oproznianie przetwornika //oproznianie przetwornika
if (((MainCtrlPos == 0) && (Vel<3)) if (((IsMainCtrlNoPowerPos()) && (Vel<3))
|| (!Mains) || (!Mains)
|| (enrot<dizel_nmin*0.8)) || (enrot<dizel_nmin*0.8))
hydro_TC_Fill -= hydro_TC_FillRateDec * dt; hydro_TC_Fill -= hydro_TC_FillRateDec * dt;
@@ -6337,10 +6369,10 @@ double TMoverParameters::dizel_Momentum(double dizel_fill, double n, double dt)
hydro_TC_Fill = clamp(hydro_TC_Fill, 0.0, 1.0); hydro_TC_Fill = clamp(hydro_TC_Fill, 0.0, 1.0);
//blokowanie sprzegla blokującego //blokowanie sprzegla blokującego
if ((Vel > hydro_TC_LockupSpeed) && (Mains) && (enrot > 0.9 * dizel_nmin) && (MainCtrlPos>0)) if ((Vel > hydro_TC_LockupSpeed) && (Mains) && (enrot > 0.9 * dizel_nmin) && (MainCtrlPowerPos() > 0))
hydro_TC_LockupRate += hydro_TC_FillRateInc*dt; hydro_TC_LockupRate += hydro_TC_FillRateInc*dt;
//luzowanie sprzegla blokujacego //luzowanie sprzegla blokujacego
if ((Vel < (MainCtrlPos>0 ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed)) || (!Mains) || (enrot < 0.8 * dizel_nmin)) if ((Vel < (MainCtrlPowerPos() > 0 ? hydro_TC_LockupSpeed : hydro_TC_UnlockSpeed)) || (!Mains) || (enrot < 0.8 * dizel_nmin))
hydro_TC_LockupRate -= hydro_TC_FillRateDec*dt; hydro_TC_LockupRate -= hydro_TC_FillRateDec*dt;
//obcinanie zakresu //obcinanie zakresu
hydro_TC_LockupRate = clamp(hydro_TC_LockupRate, 0.0, 1.0); hydro_TC_LockupRate = clamp(hydro_TC_LockupRate, 0.0, 1.0);
@@ -8495,6 +8527,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
extract_value( MainCtrlPosNo, "MCPN", line, "" ); extract_value( MainCtrlPosNo, "MCPN", line, "" );
extract_value( ScndCtrlPosNo, "SCPN", line, "" ); extract_value( ScndCtrlPosNo, "SCPN", line, "" );
extract_value( ScndInMain, "SCIM", line, "" ); extract_value( ScndInMain, "SCIM", line, "" );
extract_value( MaxMainCtrlPosNoDirChange, "DirChangeMaxPos", line, "" );
std::string autorelay; std::string autorelay;
extract_value( autorelay, "AutoRelay", line, "" ); extract_value( autorelay, "AutoRelay", line, "" );

View File

@@ -170,6 +170,7 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::secondcontrollerdecreasefast, &TTrain::OnCommand_secondcontrollerdecreasefast }, { user_command::secondcontrollerdecreasefast, &TTrain::OnCommand_secondcontrollerdecreasefast },
{ user_command::secondcontrollerset, &TTrain::OnCommand_secondcontrollerset }, { user_command::secondcontrollerset, &TTrain::OnCommand_secondcontrollerset },
{ user_command::notchingrelaytoggle, &TTrain::OnCommand_notchingrelaytoggle }, { user_command::notchingrelaytoggle, &TTrain::OnCommand_notchingrelaytoggle },
{ user_command::tempomattoggle, &TTrain::OnCommand_tempomattoggle },
{ user_command::mucurrentindicatorothersourceactivate, &TTrain::OnCommand_mucurrentindicatorothersourceactivate }, { user_command::mucurrentindicatorothersourceactivate, &TTrain::OnCommand_mucurrentindicatorothersourceactivate },
{ user_command::independentbrakeincrease, &TTrain::OnCommand_independentbrakeincrease }, { user_command::independentbrakeincrease, &TTrain::OnCommand_independentbrakeincrease },
{ user_command::independentbrakeincreasefast, &TTrain::OnCommand_independentbrakeincreasefast }, { user_command::independentbrakeincreasefast, &TTrain::OnCommand_independentbrakeincreasefast },
@@ -262,6 +263,7 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ 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 },
{ user_command::coolingfanstoggle, &TTrain::OnCommand_coolingfanstoggle },
{ user_command::motorconnectorsopen, &TTrain::OnCommand_motorconnectorsopen }, { user_command::motorconnectorsopen, &TTrain::OnCommand_motorconnectorsopen },
{ user_command::motorconnectorsclose, &TTrain::OnCommand_motorconnectorsclose }, { user_command::motorconnectorsclose, &TTrain::OnCommand_motorconnectorsclose },
{ user_command::motordisconnect, &TTrain::OnCommand_motordisconnect }, { user_command::motordisconnect, &TTrain::OnCommand_motordisconnect },
@@ -780,8 +782,8 @@ void TTrain::OnCommand_jointcontrollerset( TTrain *Train, command_data const &Co
clamp( clamp(
1.0 - ( Command.param1 * 2 ), 1.0 - ( Command.param1 * 2 ),
0.0, 1.0 ) ); 0.0, 1.0 ) );
if( Train->mvControlled->MainCtrlPos > 0 ) { if( Train->mvControlled->MainCtrlPowerPos() > 0 ) {
Train->set_master_controller( 0 ); Train->set_master_controller( Train->mvControlled->MainCtrlNoPowerPos() );
} }
} }
} }
@@ -837,7 +839,7 @@ void TTrain::OnCommand_mastercontrollerdecrease( TTrain *Train, command_data con
if( Command.action != GLFW_RELEASE ) { if( Command.action != GLFW_RELEASE ) {
// on press or hold // on press or hold
if( ( Train->ggJointCtrl.SubModel != nullptr ) if( ( Train->ggJointCtrl.SubModel != nullptr )
&& ( Train->mvControlled->MainCtrlPos == 0 ) ) { && ( Train->mvControlled->IsMainCtrlNoPowerPos() ) ) {
OnCommand_independentbrakeincrease( Train, Command ); OnCommand_independentbrakeincrease( Train, Command );
} }
else { else {
@@ -857,7 +859,7 @@ void TTrain::OnCommand_mastercontrollerdecreasefast( TTrain *Train, command_data
if( Command.action != GLFW_RELEASE ) { if( Command.action != GLFW_RELEASE ) {
// on press or hold // on press or hold
if( ( Train->ggJointCtrl.SubModel != nullptr ) if( ( Train->ggJointCtrl.SubModel != nullptr )
&& ( Train->mvControlled->MainCtrlPos == 0 ) ) { && ( Train->mvControlled->IsMainCtrlNoPowerPos() ) ) {
OnCommand_independentbrakeincreasefast( Train, Command ); OnCommand_independentbrakeincreasefast( Train, Command );
} }
else { else {
@@ -931,6 +933,45 @@ void TTrain::OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &C
} }
} }
void TTrain::OnCommand_tempomattoggle( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_REPEAT ) { return; }
if( Train->ggScndCtrlButton.type() == TGaugeType::push ) {
// impulse switch
if( Command.action == GLFW_RELEASE ) {
// just move the button back to default position
// visual feedback
Train->ggScndCtrlButton.UpdateValue( 0.0, Train->dsbSwitch );
return;
}
// glfw_press
if( Train->mvControlled->ScndCtrlPos == 0 ) {
// turn on if needed
Train->mvControlled->IncScndCtrl( 1 );
}
// visual feedback
Train->ggScndCtrlButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
// two-state switch
if( Command.action == GLFW_RELEASE ) { return; }
if( Train->mvControlled->ScndCtrlPos == 0 ) {
// turn on
Train->mvControlled->IncScndCtrl( 1 );
// visual feedback
Train->ggScndCtrlButton.UpdateValue( 1.0, Train->dsbSwitch );
}
else {
//turn off
Train->mvControlled->DecScndCtrl( 2 );
// visual feedback
Train->ggScndCtrlButton.UpdateValue( 0.0, Train->dsbSwitch );
}
}
}
void TTrain::OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command ) {
if( Train->ggNextCurrentButton.SubModel == nullptr ) { if( Train->ggNextCurrentButton.SubModel == nullptr ) {
@@ -3059,6 +3100,13 @@ void TTrain::OnCommand_motorblowersdisableall( TTrain *Train, command_data const
} }
} }
void TTrain::OnCommand_coolingfanstoggle( TTrain *Train, command_data const &Command ) {
if( Command.action != GLFW_PRESS ) { return; }
Train->mvControlled->RVentForceOn = ( !Train->mvControlled->RVentForceOn );
}
void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command ) {
// TODO: don't rely on presense of 3d model to determine presence of the switch // TODO: don't rely on presense of 3d model to determine presence of the switch
@@ -5189,10 +5237,10 @@ 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;
bDoors[i][1] = ( false == p->MoverParameters->Doors.instances[ side::left ].is_closed ); bDoors[i][1] = ( p->MoverParameters->Doors.instances[ side::left ].position > 0.f );
bDoors[i][2] = ( false == p->MoverParameters->Doors.instances[ side::right ].is_closed ); bDoors[i][2] = ( p->MoverParameters->Doors.instances[ side::right ].position > 0.f );
bDoors[i][3] = ( p->MoverParameters->Doors.instances[ side::left ].step_position > 0.0 ); bDoors[i][3] = ( p->MoverParameters->Doors.instances[ side::left ].step_position > 0.f );
bDoors[i][4] = ( p->MoverParameters->Doors.instances[ side::right ].step_position > 0.0 ); bDoors[i][4] = ( p->MoverParameters->Doors.instances[ side::right ].step_position > 0.f );
bDoors[i][0] = ( bDoors[i][1] || bDoors[i][2] ); bDoors[i][0] = ( bDoors[i][1] || bDoors[i][2] );
iDoorNo[i] = p->iAnimType[ANIM_DOORS]; iDoorNo[i] = p->iAnimType[ANIM_DOORS];
iUnits[i] = iUnitNo; iUnits[i] = iUnitNo;
@@ -5459,7 +5507,12 @@ bool TTrain::Update( double const Deltatime )
} }
if (ggIgnitionKey.SubModel) if (ggIgnitionKey.SubModel)
{ {
ggIgnitionKey.UpdateValue(mvControlled->dizel_startup); ggIgnitionKey.UpdateValue(
( mvControlled->Mains )
|| ( mvControlled->dizel_startup )
|| ( fMainRelayTimer > 0.f )
|| ( ggMainButton.GetDesiredValue() > 0.95 )
|| ( ggMainOnButton.GetDesiredValue() > 0.95 ) );
ggIgnitionKey.Update(); ggIgnitionKey.Update();
} }
} }
@@ -5670,6 +5723,7 @@ bool TTrain::Update( double const Deltatime )
// others // others
btLampkaMalfunction.Turn( mvControlled->dizel_heat.PA ); btLampkaMalfunction.Turn( mvControlled->dizel_heat.PA );
btLampkaMotorBlowers.Turn( ( mvControlled->MotorBlowers[ end::front ].is_active ) && ( mvControlled->MotorBlowers[ end::rear ].is_active ) ); btLampkaMotorBlowers.Turn( ( mvControlled->MotorBlowers[ end::front ].is_active ) && ( mvControlled->MotorBlowers[ end::rear ].is_active ) );
btLampkaCoolingFans.Turn( mvControlled->RventRot > 1.0 );
// universal devices state indicators // universal devices state indicators
for( auto idx = 0; idx < btUniversals.size(); ++idx ) { for( auto idx = 0; idx < btUniversals.size(); ++idx ) {
btUniversals[ idx ].Turn( ggUniversals[ idx ].GetValue() > 0.5 ); btUniversals[ idx ].Turn( ggUniversals[ idx ].GetValue() > 0.5 );
@@ -5730,6 +5784,7 @@ bool TTrain::Update( double const Deltatime )
// others // others
btLampkaMalfunction.Turn( false ); btLampkaMalfunction.Turn( false );
btLampkaMotorBlowers.Turn( false ); btLampkaMotorBlowers.Turn( false );
btLampkaCoolingFans.Turn( false );
// universal devices state indicators // universal devices state indicators
for( auto &universal : btUniversals ) { for( auto &universal : btUniversals ) {
universal.Turn( false ); universal.Turn( false );
@@ -5868,6 +5923,7 @@ bool TTrain::Update( double const Deltatime )
dsbNastawnikBocz ); dsbNastawnikBocz );
ggScndCtrl.Update(); ggScndCtrl.Update();
} }
ggScndCtrlButton.Update();
if (ggDirKey.SubModel) { if (ggDirKey.SubModel) {
if (mvControlled->TrainType != dt_EZT) if (mvControlled->TrainType != dt_EZT)
ggDirKey.UpdateValue( ggDirKey.UpdateValue(
@@ -7193,6 +7249,7 @@ void TTrain::clear_cab_controls()
ggMainCtrl.Clear(); ggMainCtrl.Clear();
ggMainCtrlAct.Clear(); ggMainCtrlAct.Clear();
ggScndCtrl.Clear(); ggScndCtrl.Clear();
ggScndCtrlButton.Clear();
ggDirKey.Clear(); ggDirKey.Clear();
ggBrakeCtrl.Clear(); ggBrakeCtrl.Clear();
ggLocalBrake.Clear(); ggLocalBrake.Clear();
@@ -7365,6 +7422,7 @@ void TTrain::clear_cab_controls()
btLampkaMalfunction.Clear(); btLampkaMalfunction.Clear();
btLampkaMalfunctionB.Clear(); btLampkaMalfunctionB.Clear();
btLampkaMotorBlowers.Clear(); btLampkaMotorBlowers.Clear();
btLampkaCoolingFans.Clear();
ggLeftLightButton.Clear(); ggLeftLightButton.Clear();
ggRightLightButton.Clear(); ggRightLightButton.Clear();
@@ -7661,6 +7719,13 @@ void TTrain::set_cab_controls( int const Cab ) {
1.f : 1.f :
0.f ); 0.f );
} }
// tempomat
if( ggScndCtrlButton.type() != TGaugeType::push ) {
ggScndCtrlButton.PutValue(
( mvControlled->ScndCtrlPos > 0 ) ?
1.f :
0.f );
}
// we reset all indicators, as they're set during the update pass // we reset all indicators, as they're set during the update pass
// TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it // TODO: when cleaning up break setting indicator state into a separate function, so we can reuse it
@@ -7702,6 +7767,7 @@ bool TTrain::initialize_button(cParser &Parser, std::string const &Label, int co
{ "i-highcurrent:", btLampkaWysRozr }, { "i-highcurrent:", btLampkaWysRozr },
{ "i-vent_trim:", btLampkaWentZaluzje }, { "i-vent_trim:", btLampkaWentZaluzje },
{ "i-motorblowers:", btLampkaMotorBlowers }, { "i-motorblowers:", btLampkaMotorBlowers },
{ "i-coolingfans:", btLampkaCoolingFans },
{ "i-trainheating:", btLampkaOgrzewanieSkladu }, { "i-trainheating:", btLampkaOgrzewanieSkladu },
{ "i-security_aware:", btLampkaCzuwaka }, { "i-security_aware:", btLampkaCzuwaka },
{ "i-security_cabsignal:", btLampkaSHP }, { "i-security_cabsignal:", btLampkaSHP },
@@ -7919,6 +7985,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
{ "cablight_sw:", ggCabLightButton }, { "cablight_sw:", ggCabLightButton },
{ "cablightdim_sw:", ggCabLightDimButton }, { "cablightdim_sw:", ggCabLightDimButton },
{ "battery_sw:", ggBatteryButton }, { "battery_sw:", ggBatteryButton },
{ "tempomat_sw:", ggScndCtrlButton },
{ "universal0:", ggUniversals[ 0 ] }, { "universal0:", ggUniversals[ 0 ] },
{ "universal1:", ggUniversals[ 1 ] }, { "universal1:", ggUniversals[ 1 ] },
{ "universal2:", ggUniversals[ 2 ] }, { "universal2:", ggUniversals[ 2 ] },
@@ -7940,7 +8007,8 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
} }
// TODO: move viable dedicated gauges to the automatic array // TODO: move viable dedicated gauges to the automatic array
std::unordered_map<std::string, bool *> const autoboolgauges = { std::unordered_map<std::string, bool *> const autoboolgauges = {
{ "doorstep_sw:", &mvOccupied->Doors.step_enabled } { "doorstep_sw:", &mvOccupied->Doors.step_enabled },
{ "coolingfans_sw:", &mvControlled->RVentForceOn }
}; };
{ {
auto lookup = autoboolgauges.find( Label ); auto lookup = autoboolgauges.find( Label );

View File

@@ -169,6 +169,7 @@ class TTrain
static void OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command ); static void OnCommand_secondcontrollerdecreasefast( TTrain *Train, command_data const &Command );
static void OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command ); static void OnCommand_secondcontrollerset( TTrain *Train, command_data const &Command );
static void OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &Command ); static void OnCommand_notchingrelaytoggle( TTrain *Train, command_data const &Command );
static void OnCommand_tempomattoggle( TTrain *Train, command_data const &Command );
static void OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command ); static void OnCommand_mucurrentindicatorothersourceactivate( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakeincrease( TTrain *Train, command_data const &Command ); static void OnCommand_independentbrakeincrease( TTrain *Train, command_data const &Command );
static void OnCommand_independentbrakeincreasefast( TTrain *Train, command_data const &Command ); static void OnCommand_independentbrakeincreasefast( TTrain *Train, command_data const &Command );
@@ -265,6 +266,7 @@ class TTrain
static void OnCommand_motorblowersenablerear( TTrain *Train, command_data const &Command ); static void OnCommand_motorblowersenablerear( TTrain *Train, command_data const &Command );
static void OnCommand_motorblowersdisablerear( TTrain *Train, command_data const &Command ); static void OnCommand_motorblowersdisablerear( TTrain *Train, command_data const &Command );
static void OnCommand_motorblowersdisableall( TTrain *Train, command_data const &Command ); static void OnCommand_motorblowersdisableall( TTrain *Train, command_data const &Command );
static void OnCommand_coolingfanstoggle( TTrain *Train, command_data const &Command );
static void OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command ); static void OnCommand_motorconnectorsopen( TTrain *Train, command_data const &Command );
static void OnCommand_motorconnectorsclose( TTrain *Train, command_data const &Command ); static void OnCommand_motorconnectorsclose( TTrain *Train, command_data const &Command );
static void OnCommand_motordisconnect( TTrain *Train, command_data const &Command ); static void OnCommand_motordisconnect( TTrain *Train, command_data const &Command );
@@ -379,7 +381,7 @@ public: // reszta może by?publiczna
TGauge ggMainCtrl; TGauge ggMainCtrl;
TGauge ggMainCtrlAct; TGauge ggMainCtrlAct;
TGauge ggScndCtrl; TGauge ggScndCtrl;
TGauge ggScndCtrlButton; // NOTE: not used? TGauge ggScndCtrlButton;
TGauge ggDirKey; TGauge ggDirKey;
TGauge ggBrakeCtrl; TGauge ggBrakeCtrl;
TGauge ggLocalBrake; TGauge ggLocalBrake;
@@ -580,6 +582,7 @@ public: // reszta może by?publiczna
TButton btLampkaMalfunction; TButton btLampkaMalfunction;
TButton btLampkaMalfunctionB; TButton btLampkaMalfunctionB;
TButton btLampkaMotorBlowers; TButton btLampkaMotorBlowers;
TButton btLampkaCoolingFans;
TButton btCabLight; // hunter-171012: lampa oswietlajaca kabine TButton btCabLight; // hunter-171012: lampa oswietlajaca kabine
// Ra 2013-12: wirtualne "lampki" do odbijania na haslerze w PoKeys // Ra 2013-12: wirtualne "lampki" do odbijania na haslerze w PoKeys

View File

@@ -224,7 +224,9 @@ commanddescription_sequence Commands_descriptions = {
{ "batterydisable", command_target::vehicle }, { "batterydisable", command_target::vehicle },
{ "motorblowerstogglefront", command_target::vehicle }, { "motorblowerstogglefront", command_target::vehicle },
{ "motorblowerstogglerear", command_target::vehicle }, { "motorblowerstogglerear", command_target::vehicle },
{ "motorblowersdisableall", command_target::vehicle } { "motorblowersdisableall", command_target::vehicle },
{ "coolingfanstoggle", command_target::vehicle },
{ "tempomattoggle", command_target::vehicle }
}; };

View File

@@ -218,6 +218,8 @@ enum class user_command {
motorblowerstogglefront, motorblowerstogglefront,
motorblowerstogglerear, motorblowerstogglerear,
motorblowersdisableall, motorblowersdisableall,
coolingfanstoggle,
tempomattoggle,
none = -1 none = -1
}; };

View File

@@ -227,7 +227,8 @@ driverkeyboard_input::default_bindings() {
{ user_command::motorblowerstogglefront, GLFW_KEY_N | keymodifier::shift }, { user_command::motorblowerstogglefront, GLFW_KEY_N | keymodifier::shift },
{ user_command::motorblowerstogglerear, GLFW_KEY_M | keymodifier::shift }, { user_command::motorblowerstogglerear, GLFW_KEY_M | keymodifier::shift },
{ user_command::motorblowersdisableall, GLFW_KEY_M | keymodifier::control } { user_command::motorblowersdisableall, GLFW_KEY_M | keymodifier::control }
// coolingfanstoggle
// tempomattoggle
}; };
} }

View File

@@ -494,6 +494,9 @@ drivermouse_input::default_bindings() {
{ "shuntmodepower:", { { "shuntmodepower:", {
user_command::secondcontrollerincrease, user_command::secondcontrollerincrease,
user_command::secondcontrollerdecrease } }, user_command::secondcontrollerdecrease } },
{ "tempomat_sw:", {
user_command::tempomattoggle,
user_command::none } },
{ "dirkey:", { { "dirkey:", {
user_command::reverserincrease, user_command::reverserincrease,
user_command::reverserdecrease } }, user_command::reverserdecrease } },
@@ -552,6 +555,9 @@ drivermouse_input::default_bindings() {
{ "motorblowersalloff_sw:", { { "motorblowersalloff_sw:", {
user_command::motorblowersdisableall, user_command::motorblowersdisableall,
user_command::none } }, user_command::none } },
{ "coolingfans_sw:", {
user_command::coolingfanstoggle,
user_command::none } },
{ "main_off_bt:", { { "main_off_bt:", {
user_command::linebreakeropen, user_command::linebreakeropen,
user_command::none } }, user_command::none } },

View File

@@ -238,12 +238,14 @@ timetable_panel::update() {
{ // current time { // current time
std::snprintf( std::snprintf(
m_buffer.data(), m_buffer.size(), m_buffer.data(), m_buffer.size(),
locale::strings[ locale::string::driver_timetable_time ].c_str(), locale::strings[ locale::string::driver_timetable_header ].c_str(),
40, 40,
locale::strings[ locale::string::driver_timetable_name ].c_str(),
time.wHour, time.wHour,
time.wMinute, time.wMinute,
time.wSecond ); time.wSecond );
text_lines.emplace_back( m_buffer.data(), Global.UITextColor ); title = m_buffer.data();
} }
auto *vehicle { ( auto *vehicle { (

View File

@@ -121,7 +121,7 @@ scenario_time::update( double const Deltatime ) {
} }
m_time.wHour -= 24; m_time.wHour -= 24;
} }
int leap { ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 ) }; int leap { is_leap( m_time.wYear ) };
while( m_time.wDay > m_monthdaycounts[ leap ][ m_time.wMonth ] ) { while( m_time.wDay > m_monthdaycounts[ leap ][ m_time.wMonth ] ) {
m_time.wDay -= m_monthdaycounts[ leap ][ m_time.wMonth ]; m_time.wDay -= m_monthdaycounts[ leap ][ m_time.wMonth ];
@@ -130,7 +130,7 @@ scenario_time::update( double const Deltatime ) {
if( m_time.wMonth > 12 ) { if( m_time.wMonth > 12 ) {
++m_time.wYear; ++m_time.wYear;
leap = ( m_time.wYear % 4 == 0 ) && ( m_time.wYear % 100 != 0 ) || ( m_time.wYear % 400 == 0 ); leap = is_leap( m_time.wYear );
m_time.wMonth -= 12; m_time.wMonth -= 12;
} }
} }
@@ -144,7 +144,7 @@ scenario_time::year_day( int Day, const int Month, const int Year ) const {
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
}; };
int const leap { ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ) }; int const leap { is_leap( Year ) };
for( int i = 1; i < Month; ++i ) for( int i = 1; i < Month; ++i )
Day += daytab[ leap ][ i ]; Day += daytab[ leap ][ i ];
@@ -159,7 +159,7 @@ scenario_time::daymonth( WORD &Day, WORD &Month, WORD const Year, WORD const Yea
{ 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 } { 0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366 }
}; };
int const leap { ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ) }; int const leap { is_leap( Year ) };
WORD idx = 1; WORD idx = 1;
while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) { while( ( idx < 13 ) && ( Yearday >= daytab[ leap ][ idx ] ) ) {
@@ -222,7 +222,7 @@ scenario_time::day_of_month( int const Week, int const Weekday, int const Month,
{ 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }, { 0, 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 },
{ 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 } { 0, 31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31 }
}; };
int const leap { ( Year % 4 == 0 ) && ( Year % 100 != 0 ) || ( Year % 400 == 0 ) }; int const leap { is_leap( Year ) };
while( day > daytab[ leap ][ Month ] ) { while( day > daytab[ leap ][ Month ] ) {
day -= 7; day -= 7;
@@ -248,4 +248,10 @@ scenario_time::convert_transition_time( SYSTEMTIME &Time ) const {
Time.wDay = day_of_month( Time.wDay, Time.wDayOfWeek + 1, Time.wMonth, m_time.wYear ); Time.wDay = day_of_month( Time.wDay, Time.wDayOfWeek + 1, Time.wMonth, m_time.wYear );
} }
bool
scenario_time::is_leap( int const Year ) const {
return ( ( Year % 4 == 0 ) && ( ( Year % 100 != 0 ) || ( Year % 400 == 0 ) ) );
}
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------

View File

@@ -61,6 +61,9 @@ private:
// returns number of days between specified days of week // returns number of days between specified days of week
int int
weekdays( int const First, int const Second ) const; weekdays( int const First, int const Second ) const;
// returns true if specified year is a leap year, false otherwise
bool
is_leap( int const Year ) const;
SYSTEMTIME m_time; SYSTEMTIME m_time;
double m_milliseconds{ 0.0 }; double m_milliseconds{ 0.0 };

14
sun.cpp
View File

@@ -185,17 +185,11 @@ void cSun::move() {
m_body.rascen = clamp_circular( radtodeg * std::atan2( top, bottom ) ); m_body.rascen = clamp_circular( radtodeg * std::atan2( top, bottom ) );
// Greenwich mean sidereal time // Greenwich mean sidereal time (hours)
m_observer.gmst = 6.697375 + 0.0657098242 * daynumber + m_observer.utime; m_observer.gmst = clamp_circular( 6.697375 + 0.0657098242 * daynumber + m_observer.utime, 24.0 );
m_observer.gmst -= 24.0 * (int)( m_observer.gmst / 24.0 ); // local mean sidereal time (deg)
if( m_observer.gmst < 0.0 ) m_observer.gmst += 24.0; m_observer.lmst = clamp_circular( m_observer.gmst * 15.0 + m_observer.longitude );
// local mean sidereal time
m_observer.lmst = m_observer.gmst * 15.0 + m_observer.longitude;
m_observer.lmst -= 360.0 * (int)( m_observer.lmst / 360.0 );
if( m_observer.lmst < 0.0 ) m_observer.lmst += 360.0;
// hour angle // hour angle
m_body.hrang = m_observer.lmst - m_body.rascen; m_body.hrang = m_observer.lmst - m_body.rascen;

View File

@@ -56,8 +56,8 @@ init() {
"Drive according to signals and timetable", "Drive according to signals and timetable",
"Bank consist ahead", "Bank consist ahead",
"%-*.*s Time: %d:%02d:%02d", // HACK: some manual padding to account for longer 'time' equivalent in polish version
"Timetable", "Timetable",
"Time: %d:%02d:%02d",
"(no timetable)", "(no timetable)",
"Consist weight: %d t (specified) %d t (actual)\nConsist length: %d m", "Consist weight: %d t (specified) %d t (actual)\nConsist length: %d m",
@@ -84,6 +84,7 @@ init() {
"master controller", "master controller",
"second controller", "second controller",
"shunt mode power", "shunt mode power",
"tempomat",
"reverser", "reverser",
"train brake", "train brake",
"independent brake", "independent brake",
@@ -104,6 +105,7 @@ init() {
"motor blowers A", "motor blowers A",
"motor blowers B", "motor blowers B",
"all motor blowers", "all motor blowers",
"cooling fans",
"line breaker", "line breaker",
"line breaker", "line breaker",
"alerter", "alerter",
@@ -219,8 +221,8 @@ init() {
"Prowadzic sklad wedlug sygnalow i rozkladu", "Prowadzic sklad wedlug sygnalow i rozkladu",
"Popychac sklad z przodu", "Popychac sklad z przodu",
"%-*.*s Godzina: %d:%02d:%02d",
"Rozklad jazdy", "Rozklad jazdy",
"Godzina: %d:%02d:%02d",
"(brak rozkladu)", "(brak rozkladu)",
"Brutto: %d t (rozkladowe) %d t (rzeczywiste)\nDlugosc pociagu: %d m", "Brutto: %d t (rozkladowe) %d t (rzeczywiste)\nDlugosc pociagu: %d m",
@@ -247,6 +249,7 @@ init() {
"nastawnik jazdy", "nastawnik jazdy",
"nastawnik dodatkowy", "nastawnik dodatkowy",
"sterowanie analogowe", "sterowanie analogowe",
"tempomat",
"nastawnik kierunku", "nastawnik kierunku",
"hamulec zespolony", "hamulec zespolony",
"hamulec pomocniczy", "hamulec pomocniczy",
@@ -267,6 +270,7 @@ init() {
"wentylatory silnikow trakcyjnych A", "wentylatory silnikow trakcyjnych A",
"wentylatory silnikow trakcyjnych B", "wentylatory silnikow trakcyjnych B",
"wszystkie wentylatory silnikow trakcyjnych", "wszystkie wentylatory silnikow trakcyjnych",
"wentylatory oporow rozruchowych",
"wylacznik szybki", "wylacznik szybki",
"wylacznik szybki", "wylacznik szybki",
"czuwak", "czuwak",
@@ -363,6 +367,7 @@ init() {
"jointctrl:", "jointctrl:",
"scndctrl:", "scndctrl:",
"shuntmodepower:", "shuntmodepower:",
"tempomat_sw:",
"dirkey:", "dirkey:",
"brakectrl:", "brakectrl:",
"localbrake:", "localbrake:",
@@ -383,6 +388,7 @@ init() {
"motorblowersfront_sw:", "motorblowersfront_sw:",
"motorblowersrear_sw:", "motorblowersrear_sw:",
"motorblowersalloff_sw:", "motorblowersalloff_sw:",
"coolingfans_sw:",
"main_off_bt:", "main_off_bt:",
"main_on_bt:", "main_on_bt:",
"security_reset_bt:", "security_reset_bt:",

View File

@@ -46,7 +46,7 @@ enum string {
driver_scenario_bank, driver_scenario_bank,
driver_timetable_header, driver_timetable_header,
driver_timetable_time, driver_timetable_name,
driver_timetable_notimetable, driver_timetable_notimetable,
driver_timetable_consistdata, driver_timetable_consistdata,
@@ -73,6 +73,7 @@ enum string {
cab_jointctrl, cab_jointctrl,
cab_scndctrl, cab_scndctrl,
cab_shuntmodepower, cab_shuntmodepower,
cab_tempomat,
cab_dirkey, cab_dirkey,
cab_brakectrl, cab_brakectrl,
cab_localbrake, cab_localbrake,
@@ -93,6 +94,7 @@ enum string {
cab_motorblowersfront_sw, cab_motorblowersfront_sw,
cab_motorblowersrear_sw, cab_motorblowersrear_sw,
cab_motorblowersalloff_sw, cab_motorblowersalloff_sw,
cab_coolingfans_sw,
cab_main_off_bt, cab_main_off_bt,
cab_main_on_bt, cab_main_on_bt,
cab_security_reset_bt, cab_security_reset_bt,