mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-03-22 15:05:03 +01:00
build 190504. pantograph compressor start method, door control mode support, impulse type battery switch support, disconnect ai logic tweak
This commit is contained in:
91
Driver.cpp
91
Driver.cpp
@@ -4176,6 +4176,7 @@ TController::UpdateSituation(double dt) {
|
||||
// HACK: activate route scanning if an idling vehicle is activated by a human user
|
||||
if( ( OrderCurrentGet() == Wait_for_orders )
|
||||
&& ( false == AIControllFlag )
|
||||
&& ( false == iEngineActive )
|
||||
&& ( true == mvControlling->Battery ) ) {
|
||||
OrderNext( Prepare_engine );
|
||||
}
|
||||
@@ -5004,54 +5005,50 @@ TController::UpdateSituation(double dt) {
|
||||
// jeśli dociskanie w celu odczepienia
|
||||
// 3. faza odczepiania.
|
||||
SetVelocity(2, 0); // jazda w ustawionym kierunku z prędkością 2
|
||||
if( ( mvControlling->MainCtrlPowerPos() > 0 )
|
||||
|| ( mvOccupied->BrakeSystem == TBrakeSystem::ElectroPneumatic ) ) {
|
||||
// jeśli jazda
|
||||
WriteLog(mvOccupied->Name + " odczepianie w kierunku " + std::to_string(mvOccupied->DirAbsolute));
|
||||
TDynamicObject *p = pVehicle; // pojazd do odczepienia, w (pVehicle) siedzi AI
|
||||
int d; // numer sprzęgu, który sprawdzamy albo odczepiamy
|
||||
int n = iVehicleCount; // ile wagonów ma zostać
|
||||
do
|
||||
{ // szukanie pojazdu do odczepienia
|
||||
d = p->DirectionGet() > 0 ?
|
||||
end::front :
|
||||
end::rear; // numer sprzęgu od strony czoła składu
|
||||
// if (p->MoverParameters->Couplers[d].CouplerType==Articulated)
|
||||
// //jeśli sprzęg typu wózek (za mało)
|
||||
if (p->MoverParameters->Couplers[d].CouplingFlag & ctrain_depot) // jeżeli sprzęg zablokowany
|
||||
// if (p->GetTrack()->) //a nie stoi na torze warsztatowym
|
||||
// (ustalić po czym poznać taki tor)
|
||||
++n; // to liczymy człony jako jeden
|
||||
p->MoverParameters->BrakeReleaser(1); // wyluzuj pojazd, aby dało się dopychać
|
||||
// GBH p->MoverParameters->BrakeLevelSet(0); // hamulec na zero, aby nie hamował
|
||||
BrakeLevelSet(gbh_RP);
|
||||
if (n)
|
||||
{ // jeśli jeszcze nie koniec
|
||||
p = p->Prev(); // kolejny w stronę czoła składu (licząc od tyłu), bo dociskamy
|
||||
if (!p)
|
||||
iVehicleCount = -2,
|
||||
n = 0; // nie ma co dalej sprawdzać, doczepianie zakończone
|
||||
}
|
||||
} while (n--);
|
||||
if( ( p == nullptr )
|
||||
|| ( p->MoverParameters->Couplers[ d ].Connected == nullptr ) ) {
|
||||
// no target, or already just virtual coupling
|
||||
WriteLog( mvOccupied->Name + " didn't find anything to disconnect." );
|
||||
iVehicleCount = -2; // odczepiono, co było do odczepienia
|
||||
} else if ( p->Dettach(d) == coupling::faux ) {
|
||||
// tylko jeśli odepnie
|
||||
WriteLog( mvOccupied->Name + " odczepiony." );
|
||||
iVehicleCount = -2;
|
||||
} // a jak nie, to dociskać dalej
|
||||
}
|
||||
if (iVehicleCount >= 0) // zmieni się po odczepieniu
|
||||
if (!mvOccupied->DecLocalBrakeLevel(1))
|
||||
{ // dociśnij sklad
|
||||
WriteLog( mvOccupied->Name + " dociskanie..." );
|
||||
// mvOccupied->BrakeReleaser(); //wyluzuj lokomotywę
|
||||
// Ready=true; //zamiast sprawdzenia odhamowania całego składu
|
||||
IncSpeed(); // dla (Ready)==false nie ruszy
|
||||
if( iVehicleCount >= 0 ) {
|
||||
// zmieni się po odczepieniu
|
||||
WriteLog( mvOccupied->Name + " dociskanie..." );
|
||||
while( mvOccupied->DecLocalBrakeLevel( 1 ) ) { // dociśnij sklad
|
||||
;
|
||||
}
|
||||
IncSpeed();
|
||||
}
|
||||
WriteLog(mvOccupied->Name + " odczepianie w kierunku " + std::to_string(mvOccupied->DirAbsolute));
|
||||
TDynamicObject *p = pVehicle; // pojazd do odczepienia, w (pVehicle) siedzi AI
|
||||
int d; // numer sprzęgu, który sprawdzamy albo odczepiamy
|
||||
int n = iVehicleCount; // ile wagonów ma zostać
|
||||
do
|
||||
{ // szukanie pojazdu do odczepienia
|
||||
d = p->DirectionGet() > 0 ?
|
||||
end::front :
|
||||
end::rear; // numer sprzęgu od strony czoła składu
|
||||
// if (p->MoverParameters->Couplers[d].CouplerType==Articulated)
|
||||
// //jeśli sprzęg typu wózek (za mało)
|
||||
if (p->MoverParameters->Couplers[d].CouplingFlag & ctrain_depot) // jeżeli sprzęg zablokowany
|
||||
// if (p->GetTrack()->) //a nie stoi na torze warsztatowym
|
||||
// (ustalić po czym poznać taki tor)
|
||||
++n; // to liczymy człony jako jeden
|
||||
p->MoverParameters->BrakeReleaser(1); // wyluzuj pojazd, aby dało się dopychać
|
||||
// GBH p->MoverParameters->BrakeLevelSet(0); // hamulec na zero, aby nie hamował
|
||||
BrakeLevelSet(gbh_RP);
|
||||
if (n)
|
||||
{ // jeśli jeszcze nie koniec
|
||||
p = p->Prev(); // kolejny w stronę czoła składu (licząc od tyłu), bo dociskamy
|
||||
if (!p)
|
||||
iVehicleCount = -2,
|
||||
n = 0; // nie ma co dalej sprawdzać, doczepianie zakończone
|
||||
}
|
||||
} while (n--);
|
||||
if( ( p == nullptr )
|
||||
|| ( p->MoverParameters->Couplers[ d ].Connected == nullptr ) ) {
|
||||
// no target, or already just virtual coupling
|
||||
WriteLog( mvOccupied->Name + " didn't find anything to disconnect." );
|
||||
iVehicleCount = -2; // odczepiono, co było do odczepienia
|
||||
} else if ( p->Dettach(d) == coupling::faux ) {
|
||||
// tylko jeśli odepnie
|
||||
WriteLog( mvOccupied->Name + " odczepiony." );
|
||||
iVehicleCount = -2;
|
||||
} // a jak nie, to dociskać dalej
|
||||
}
|
||||
if ((mvOccupied->Vel < 0.01) && !(iDrivigFlags & movePress))
|
||||
{ // 2. faza odczepiania: zmień kierunek na przeciwny i dociśnij
|
||||
|
||||
@@ -766,6 +766,7 @@ private:
|
||||
// ld inputs
|
||||
bool lock_enabled { true };
|
||||
bool step_enabled { true };
|
||||
bool remote_only { false }; // door ignores local control signals
|
||||
// internal data
|
||||
int permit_preset { -1 }; // curent position of preset selection switch
|
||||
// vehicle parts
|
||||
@@ -1162,6 +1163,7 @@ public:
|
||||
bool CompressorAllowLocal{ true }; // local device state override (most units don't have this fitted so it's set to true not to intefere)
|
||||
bool CompressorGovernorLock{ false }; // indicates whether compressor pressure switch was activated due to reaching cut-out pressure
|
||||
start_t CompressorStart{ start_t::manual }; // whether the compressor is started manually, or another way
|
||||
start_t PantographCompressorStart{ start_t::manual };
|
||||
// TODO converter parameters, for when we start cleaning up mover parameters
|
||||
start_t ConverterStart{ start_t::manual }; // whether converter is started manually, or by other means
|
||||
float ConverterStartDelay{ 0.0f }; // delay (in seconds) before the converter is started, once its activation conditions are met
|
||||
@@ -1344,8 +1346,6 @@ public:
|
||||
bool PantRearUp = false;
|
||||
bool PantFrontSP = true; //dzwiek patykow 'Winger 010304
|
||||
bool PantRearSP = true;
|
||||
int PantFrontStart = 0; //stan patykow 'Winger 160204
|
||||
int PantRearStart = 0;
|
||||
double PantFrontVolt = 0.0; //pantograf pod napieciem? 'Winger 160404
|
||||
double PantRearVolt = 0.0;
|
||||
// TODO: move these switch types where they belong, cabin definition
|
||||
@@ -1553,6 +1553,7 @@ public:
|
||||
bool PermitDoors( side const Door, bool const State = true, range_t const Notify = range_t::consist );
|
||||
bool ChangeDoorPermitPreset( int const Change, range_t const Notify = range_t::consist );
|
||||
bool PermitDoorStep( bool const State, range_t const Notify = range_t::consist );
|
||||
bool ChangeDoorControlMode( bool const State, range_t const Notify = range_t::consist );
|
||||
bool OperateDoors( side const Door, bool const State, range_t const Notify = range_t::consist );
|
||||
bool LockDoors( bool const State, range_t const Notify = range_t::consist );
|
||||
bool signal_departure( bool const State, range_t const Notify = range_t::consist ); // toggles departure warning
|
||||
|
||||
@@ -653,11 +653,18 @@ void TMoverParameters::UpdatePantVolume(double dt)
|
||||
{ // KURS90 - sprężarka pantografów; Ra 2014-07: teraz jest to zbiornik rozrządu, chociaż to jeszcze nie tak
|
||||
|
||||
// check the pantograph compressor while at it
|
||||
if( PantCompFlag ) {
|
||||
if( ( false == Battery )
|
||||
&& ( false == ConverterFlag ) ) {
|
||||
PantCompFlag = false;
|
||||
}
|
||||
if( ( PantPress < 4.2 )
|
||||
&& ( ( PantographCompressorStart == start_t::automatic )
|
||||
|| ( PantographCompressorStart == start_t::manualwithautofallback ) )
|
||||
&& ( ( true == PantRearUp )
|
||||
|| ( true == PantFrontUp ) ) ) {
|
||||
// automatic start if the pressure is too low
|
||||
PantCompFlag = true;
|
||||
}
|
||||
if( ( true == PantCompFlag )
|
||||
&& ( false == Battery )
|
||||
&& ( false == ConverterFlag ) ) {
|
||||
PantCompFlag = false;
|
||||
}
|
||||
|
||||
if (EnginePowerSource.SourceType == TPowerSource::CurrentCollector) // tylko jeśli pantografujący
|
||||
@@ -5916,7 +5923,6 @@ bool TMoverParameters::PantFront( bool const State, range_t const Notify )
|
||||
if( PantFrontUp != State ) {
|
||||
PantFrontUp = State;
|
||||
if( State == true ) {
|
||||
PantFrontStart = 0;
|
||||
if( Notify != range_t::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
@@ -5927,7 +5933,6 @@ bool TMoverParameters::PantFront( bool const State, range_t const Notify )
|
||||
}
|
||||
}
|
||||
else {
|
||||
PantFrontStart = 1;
|
||||
if( Notify != range_t::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
@@ -5969,7 +5974,6 @@ bool TMoverParameters::PantRear( bool const State, range_t const Notify )
|
||||
if( PantRearUp != State ) {
|
||||
PantRearUp = State;
|
||||
if( State == true ) {
|
||||
PantRearStart = 0;
|
||||
if( Notify != range_t::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
@@ -5980,7 +5984,6 @@ bool TMoverParameters::PantRear( bool const State, range_t const Notify )
|
||||
}
|
||||
}
|
||||
else {
|
||||
PantRearStart = 1;
|
||||
if( Notify != range_t::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
@@ -6913,12 +6916,7 @@ bool TMoverParameters::PermitDoors( side const Door, bool const State, range_t c
|
||||
|
||||
bool const initialstate { Doors.instances[Door].open_permit };
|
||||
|
||||
if( ( false == Doors.permit_presets.empty() ) // HACK: for cases where preset switch is used before battery
|
||||
|| ( ( true == Battery )
|
||||
&& ( false == Doors.is_locked ) ) ) {
|
||||
|
||||
Doors.instances[ Door ].open_permit = State;
|
||||
}
|
||||
Doors.instances[ Door ].open_permit = State;
|
||||
|
||||
if( Notify != range_t::local ) {
|
||||
|
||||
@@ -6937,6 +6935,34 @@ bool TMoverParameters::PermitDoors( side const Door, bool const State, range_t c
|
||||
return ( Doors.instances[ Door ].open_permit != initialstate );
|
||||
}
|
||||
|
||||
bool TMoverParameters::ChangeDoorControlMode( bool const State, range_t const Notify ) {
|
||||
|
||||
auto const initialstate { Doors.remote_only };
|
||||
|
||||
Doors.remote_only = State;
|
||||
if( Notify != range_t::local ) {
|
||||
// wysłanie wyłączenia do pozostałych?
|
||||
SendCtrlToNext(
|
||||
"DoorMode",
|
||||
( State == true ?
|
||||
1 :
|
||||
0 ),
|
||||
CabNo,
|
||||
( Notify == range_t::unit ?
|
||||
coupling::control | coupling::permanent :
|
||||
coupling::control ) );
|
||||
}
|
||||
|
||||
if( true == State ) {
|
||||
// when door are put in remote control mode they're automatically open
|
||||
// TBD, TODO: make it dependant on config switch?
|
||||
OperateDoors( side::left, true );
|
||||
OperateDoors( side::right, true );
|
||||
}
|
||||
|
||||
return ( Doors.step_enabled != initialstate );
|
||||
}
|
||||
|
||||
bool TMoverParameters::OperateDoors( side const Door, bool const State, range_t const Notify ) {
|
||||
|
||||
auto &door { Doors.instances[ Door ] };
|
||||
@@ -7044,15 +7070,17 @@ TMoverParameters::update_doors( double const Deltatime ) {
|
||||
|
||||
// NBMX Obsluga drzwi, MC: zuniwersalnione
|
||||
auto const localopencontrol {
|
||||
( Doors.open_control == control_t::passenger )
|
||||
|| ( Doors.open_control == control_t::mixed ) };
|
||||
( false == Doors.remote_only )
|
||||
&& ( ( Doors.open_control == control_t::passenger )
|
||||
|| ( Doors.open_control == control_t::mixed ) ) };
|
||||
auto const remoteopencontrol {
|
||||
( Doors.open_control == control_t::driver )
|
||||
|| ( Doors.open_control == control_t::conductor )
|
||||
|| ( Doors.open_control == control_t::mixed ) };
|
||||
auto const localclosecontrol {
|
||||
( Doors.close_control == control_t::passenger )
|
||||
|| ( Doors.close_control == control_t::mixed ) };
|
||||
( false == Doors.remote_only )
|
||||
&& ( ( Doors.close_control == control_t::passenger )
|
||||
|| ( Doors.close_control == control_t::mixed ) ) };
|
||||
auto const remoteclosecontrol {
|
||||
( Doors.close_control == control_t::driver )
|
||||
|| ( Doors.close_control == control_t::conductor )
|
||||
@@ -7080,7 +7108,7 @@ TMoverParameters::update_doors( double const Deltatime ) {
|
||||
&& ( door.step_position <= 0.f );
|
||||
|
||||
door.local_open = door.local_open && ( false == door.is_open ) && ( ( false == Doors.permit_needed ) || door.open_permit );
|
||||
door.remote_open = door.remote_open && ( false == door.is_open ) && ( ( false == Doors.permit_needed ) || door.open_permit );
|
||||
door.remote_open = ( door.remote_open || Doors.remote_only ) && ( false == door.is_open ) && ( ( false == Doors.permit_needed ) || door.open_permit );
|
||||
door.local_close = door.local_close && ( false == door.is_closed );
|
||||
door.remote_close = door.remote_close && ( false == door.is_closed );
|
||||
|
||||
@@ -8732,6 +8760,14 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
||||
lookup->second :
|
||||
start_t::manual;
|
||||
}
|
||||
// pantograph compressor
|
||||
{
|
||||
auto lookup = starts.find( extract_value( "PantCompressorStart", line ) );
|
||||
PantographCompressorStart =
|
||||
lookup != starts.end() ?
|
||||
lookup->second :
|
||||
start_t::manual;
|
||||
}
|
||||
// fuel pump
|
||||
{
|
||||
auto lookup = starts.find( extract_value( "FuelStart", line ) );
|
||||
@@ -10046,6 +10082,13 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
false );
|
||||
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
||||
}
|
||||
else if( Command == "DoorMode" ) {
|
||||
Doors.remote_only = (
|
||||
CValue1 == 1 ?
|
||||
true :
|
||||
false );
|
||||
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
||||
}
|
||||
else if( Command == "DepartureSignal" ) {
|
||||
DepartureSignal = (
|
||||
CValue1 == 1 ?
|
||||
@@ -10062,12 +10105,10 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
if ((CValue1 == 1))
|
||||
{
|
||||
PantFrontUp = true;
|
||||
PantFrontStart = 0;
|
||||
}
|
||||
else if ((CValue1 == 0))
|
||||
{
|
||||
PantFrontUp = false;
|
||||
PantFrontStart = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -10077,24 +10118,20 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
(TestFlag(Couplers[0].CouplingFlag, ctrain_controll) && (CValue2 == -1)))
|
||||
{
|
||||
PantFrontUp = true;
|
||||
PantFrontStart = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PantRearUp = true;
|
||||
PantRearStart = 0;
|
||||
}
|
||||
else if ((CValue1 == 0))
|
||||
if ((TestFlag(Couplers[1].CouplingFlag, ctrain_controll) && (CValue2 == 1)) ||
|
||||
(TestFlag(Couplers[0].CouplingFlag, ctrain_controll) && (CValue2 == -1)))
|
||||
{
|
||||
PantFrontUp = false;
|
||||
PantFrontStart = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PantRearUp = false;
|
||||
PantRearStart = 1;
|
||||
}
|
||||
}
|
||||
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
||||
@@ -10107,12 +10144,10 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
if ((CValue1 == 1))
|
||||
{
|
||||
PantRearUp = true;
|
||||
PantRearStart = 0;
|
||||
}
|
||||
else if ((CValue1 == 0))
|
||||
{
|
||||
PantRearUp = false;
|
||||
PantRearStart = 1;
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -10123,24 +10158,20 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
(TestFlag(Couplers[0].CouplingFlag, ctrain_controll) && (CValue2 == -1)))
|
||||
{
|
||||
PantRearUp = true;
|
||||
PantRearStart = 0;
|
||||
}
|
||||
else
|
||||
{
|
||||
PantFrontUp = true;
|
||||
PantFrontStart = 0;
|
||||
}
|
||||
else if ((CValue1 == 0))
|
||||
if ((TestFlag(Couplers[1].CouplingFlag, ctrain_controll) && (CValue2 == 1)) ||
|
||||
(TestFlag(Couplers[0].CouplingFlag, ctrain_controll) && (CValue2 == -1)))
|
||||
{
|
||||
PantRearUp = false;
|
||||
PantRearStart = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
PantFrontUp = false;
|
||||
PantFrontStart = 1;
|
||||
}
|
||||
}
|
||||
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
||||
|
||||
64
Train.cpp
64
Train.cpp
@@ -327,6 +327,7 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
||||
{ user_command::dooropenall, &TTrain::OnCommand_dooropenall },
|
||||
{ user_command::doorcloseall, &TTrain::OnCommand_doorcloseall },
|
||||
{ user_command::doorsteptoggle, &TTrain::OnCommand_doorsteptoggle },
|
||||
{ user_command::doormodetoggle, &TTrain::OnCommand_doormodetoggle },
|
||||
{ user_command::carcouplingincrease, &TTrain::OnCommand_carcouplingincrease },
|
||||
{ user_command::carcouplingdisconnect, &TTrain::OnCommand_carcouplingdisconnect },
|
||||
{ user_command::departureannounce, &TTrain::OnCommand_departureannounce },
|
||||
@@ -778,7 +779,7 @@ void TTrain::OnCommand_mastercontrollerincrease( TTrain *Train, command_data con
|
||||
if( Command.action != GLFW_RELEASE ) {
|
||||
// on press or hold
|
||||
if( ( Train->ggJointCtrl.SubModel != nullptr )
|
||||
&& ( Train->mvControlled->LocalBrakePosA > 0.0 ) ) {
|
||||
&& ( Train->mvOccupied->LocalBrakePosA > 0.0 ) ) {
|
||||
OnCommand_independentbrakedecrease( Train, Command );
|
||||
}
|
||||
else {
|
||||
@@ -798,7 +799,7 @@ void TTrain::OnCommand_mastercontrollerincreasefast( TTrain *Train, command_data
|
||||
if( Command.action != GLFW_RELEASE ) {
|
||||
// on press or hold
|
||||
if( ( Train->ggJointCtrl.SubModel != nullptr )
|
||||
&& ( Train->mvControlled->LocalBrakePosA > 0.0 ) ) {
|
||||
&& ( Train->mvOccupied->LocalBrakePosA > 0.0 ) ) {
|
||||
OnCommand_independentbrakedecreasefast( Train, Command );
|
||||
}
|
||||
else {
|
||||
@@ -1722,10 +1723,11 @@ void TTrain::OnCommand_alerteracknowledge( TTrain *Train, command_data const &Co
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: replace battery with a two-state device, update switch code accordingly
|
||||
void TTrain::OnCommand_batterytoggle( 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( Command.action != GLFW_REPEAT ) {
|
||||
// keep the switch from flipping back and forth if key is held down
|
||||
if( false == Train->mvOccupied->Battery ) {
|
||||
// turn on
|
||||
OnCommand_batteryenable( Train, Command );
|
||||
@@ -1739,16 +1741,13 @@ void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command
|
||||
|
||||
void TTrain::OnCommand_batteryenable( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( true == Train->mvOccupied->Battery ) { return; } // already on
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// ignore repeats
|
||||
// wyłącznik jest też w SN61, ewentualnie załączać prąd na stałe z poziomu FIZ
|
||||
// visual feedback
|
||||
Train->ggBatteryButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||
|
||||
if( true == Train->mvOccupied->Battery ) { return; } // already on
|
||||
|
||||
if( Train->mvOccupied->BatterySwitch( true ) ) {
|
||||
// bateria potrzebna np. do zapalenia świateł
|
||||
if( Train->ggBatteryButton.SubModel ) {
|
||||
Train->ggBatteryButton.UpdateValue( 1.0, Train->dsbSwitch );
|
||||
}
|
||||
// side-effects
|
||||
if( Train->mvOccupied->LightsPosNo > 0 ) {
|
||||
Train->SetLights();
|
||||
@@ -1760,19 +1759,23 @@ void TTrain::OnCommand_batteryenable( TTrain *Train, command_data const &Command
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
if( Train->ggBatteryButton.type() == TGaugeType::push ) {
|
||||
// return the switch to neutral position
|
||||
Train->ggBatteryButton.UpdateValue( 0.5f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_batterydisable( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( false == Train->mvOccupied->Battery ) { return; } // already off
|
||||
|
||||
// TBD, TODO: ewentualnie zablokować z FIZ, np. w samochodach się nie odłącza akumulatora
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
// ignore repeats
|
||||
// visual feedback
|
||||
Train->ggBatteryButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
|
||||
if( false == Train->mvOccupied->Battery ) { return; } // already off
|
||||
|
||||
if( Train->mvOccupied->BatterySwitch( false ) ) {
|
||||
// ewentualnie zablokować z FIZ, np. w samochodach się nie odłącza akumulatora
|
||||
if( Train->ggBatteryButton.SubModel ) {
|
||||
Train->ggBatteryButton.UpdateValue( 0.0, Train->dsbSwitch );
|
||||
}
|
||||
// side-effects
|
||||
if( false == Train->mvControlled->ConverterFlag ) {
|
||||
// if there's no (low voltage) power source left, drop pantographs
|
||||
@@ -1781,6 +1784,12 @@ void TTrain::OnCommand_batterydisable( TTrain *Train, command_data const &Comman
|
||||
}
|
||||
}
|
||||
}
|
||||
else if( Command.action == GLFW_RELEASE ) {
|
||||
if( Train->ggBatteryButton.type() == TGaugeType::push ) {
|
||||
// return the switch to neutral position
|
||||
Train->ggBatteryButton.UpdateValue( 0.5f );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_pantographtogglefront( TTrain *Train, command_data const &Command ) {
|
||||
@@ -4725,6 +4734,13 @@ void TTrain::OnCommand_doorsteptoggle( TTrain *Train, command_data const &Comman
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_doormodetoggle( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
Train->mvOccupied->ChangeDoorControlMode( false == Train->mvOccupied->Doors.remote_only );
|
||||
}
|
||||
}
|
||||
|
||||
void TTrain::OnCommand_carcouplingincrease( TTrain *Train, command_data const &Command ) {
|
||||
|
||||
if( ( true == FreeFlyModeFlag )
|
||||
@@ -7456,9 +7472,10 @@ void TTrain::clear_cab_controls()
|
||||
void TTrain::set_cab_controls( int const Cab ) {
|
||||
// switches
|
||||
// battery
|
||||
if( true == mvOccupied->Battery ) {
|
||||
ggBatteryButton.PutValue( 1.f );
|
||||
}
|
||||
ggBatteryButton.PutValue(
|
||||
( ggBatteryButton.type() == TGaugeType::push ? 0.5f :
|
||||
mvOccupied->Battery ? 1.f :
|
||||
0.f ) );
|
||||
// motor connectors
|
||||
ggStLinOffButton.PutValue(
|
||||
( mvControlled->StLinSwitchOff ?
|
||||
@@ -8026,6 +8043,7 @@ bool TTrain::initialize_gauge(cParser &Parser, std::string const &Label, int con
|
||||
}
|
||||
// TODO: move viable dedicated gauges to the automatic array
|
||||
std::unordered_map<std::string, bool *> const autoboolgauges = {
|
||||
{ "doormode_sw:", &mvOccupied->Doors.remote_only },
|
||||
{ "doorstep_sw:", &mvOccupied->Doors.step_enabled },
|
||||
{ "coolingfans_sw:", &mvControlled->RVentForceOn }
|
||||
};
|
||||
|
||||
1
Train.h
1
Train.h
@@ -329,6 +329,7 @@ class TTrain
|
||||
static void OnCommand_dooropenall( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_doorcloseall( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_doorsteptoggle( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_doormodetoggle( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_carcouplingincrease( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_carcouplingdisconnect( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_departureannounce( TTrain *Train, command_data const &Command );
|
||||
|
||||
@@ -154,6 +154,7 @@ commanddescription_sequence Commands_descriptions = {
|
||||
{ "doorcloseright", command_target::vehicle },
|
||||
{ "doorcloseall", command_target::vehicle },
|
||||
{ "doorsteptoggle", command_target::vehicle },
|
||||
{ "doormodetoggle", command_target::vehicle },
|
||||
{ "departureannounce", command_target::vehicle },
|
||||
{ "doorlocktoggle", command_target::vehicle },
|
||||
{ "pantographcompressorvalvetoggle", command_target::vehicle },
|
||||
|
||||
@@ -147,6 +147,7 @@ enum class user_command {
|
||||
doorcloseright,
|
||||
doorcloseall,
|
||||
doorsteptoggle,
|
||||
doormodetoggle,
|
||||
departureannounce,
|
||||
doorlocktoggle,
|
||||
pantographcompressorvalvetoggle,
|
||||
|
||||
@@ -156,6 +156,7 @@ driverkeyboard_input::default_bindings() {
|
||||
// doorcloseright,
|
||||
{ user_command::doorcloseall, GLFW_KEY_SLASH | keymodifier::control },
|
||||
// doorsteptoggle,
|
||||
{ user_command::doormodetoggle, GLFW_KEY_SLASH | keymodifier::shift | keymodifier::control },
|
||||
{ user_command::departureannounce, GLFW_KEY_SLASH },
|
||||
{ user_command::doorlocktoggle, GLFW_KEY_S | keymodifier::control },
|
||||
{ user_command::pantographcompressorvalvetoggle, GLFW_KEY_V | keymodifier::control },
|
||||
|
||||
@@ -633,6 +633,9 @@ drivermouse_input::default_bindings() {
|
||||
{ "doorstep_sw:", {
|
||||
user_command::doorsteptoggle,
|
||||
user_command::none } },
|
||||
{ "doormode_sw:", {
|
||||
user_command::doormodetoggle,
|
||||
user_command::none } },
|
||||
{ "departure_signal_bt:", {
|
||||
user_command::departureannounce,
|
||||
user_command::none } },
|
||||
|
||||
@@ -131,6 +131,7 @@ init() {
|
||||
"all doors (open)",
|
||||
"all doors (close)",
|
||||
"doorstep",
|
||||
"door control mode",
|
||||
"departure signal",
|
||||
"upper headlight",
|
||||
"left headlight",
|
||||
@@ -296,6 +297,7 @@ init() {
|
||||
"drzwi (otworz)",
|
||||
"drzwi (zamknij)",
|
||||
"stopien drzwi",
|
||||
"tryb sterowania drzwiami",
|
||||
"sygnal odjazdu",
|
||||
"reflektor gorny",
|
||||
"reflektor lewy",
|
||||
@@ -414,6 +416,7 @@ init() {
|
||||
"doorallon_sw:",
|
||||
"dooralloff_sw:",
|
||||
"doorstep_sw:",
|
||||
"doormode_sw:",
|
||||
"departure_signal_bt:",
|
||||
"upperlight_sw:",
|
||||
"leftlight_sw:",
|
||||
|
||||
@@ -120,6 +120,7 @@ enum string {
|
||||
cab_doorallon_sw,
|
||||
cab_dooralloff_sw,
|
||||
cab_doorstep_sw,
|
||||
cab_doormode_sw,
|
||||
cab_departure_signal_bt,
|
||||
cab_upperlight_sw,
|
||||
cab_leftlight_sw,
|
||||
|
||||
Reference in New Issue
Block a user