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

(commands) add epbrakecontrolenable and epbrakecontroldisable

This commit is contained in:
Marcin Nowak
2024-08-03 00:17:26 +02:00
parent 663ab0821c
commit 001ca76990
6 changed files with 44 additions and 0 deletions

View File

@@ -254,6 +254,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::autosandboxactivate, &TTrain::OnCommand_autosandboxactivate },
{ user_command::autosandboxdeactivate, &TTrain::OnCommand_autosandboxdeactivate },
{ user_command::epbrakecontroltoggle, &TTrain::OnCommand_epbrakecontroltoggle },
{ user_command::epbrakecontrolenable, &TTrain::OnCommand_epbrakecontrolenable },
{ user_command::epbrakecontroldisable, &TTrain::OnCommand_epbrakecontroldisable },
{ user_command::trainbrakeoperationmodeincrease, &TTrain::OnCommand_trainbrakeoperationmodeincrease },
{ user_command::trainbrakeoperationmodedecrease, &TTrain::OnCommand_trainbrakeoperationmodedecrease },
{ user_command::brakeactingspeedincrease, &TTrain::OnCommand_brakeactingspeedincrease },
@@ -1969,6 +1971,34 @@ void TTrain::OnCommand_autosandboxdeactivate(TTrain *Train, command_data const &
}
};
void TTrain::OnCommand_epbrakecontrolenable( TTrain *Train, command_data const &Command ) {
auto const istoggle{ ( static_cast<int>( Train->ggEPFuseButton.type() ) & static_cast<int>( TGaugeType::toggle ) ) != 0 };
if( Command.action == GLFW_PRESS ) {
// command only works for bistable switch
if(istoggle) {
if( Train->mvOccupied->EpFuseSwitch( true ) ) {
// audio feedback
if( Train->dsbPneumaticSwitch ) {
Train->dsbPneumaticSwitch->play();
}
Train->ggEPFuseButton.UpdateValue(1.0f, Train->dsbSwitch);
};
}
}
}
void TTrain::OnCommand_epbrakecontroldisable( TTrain *Train, command_data const &Command ) {
auto const istoggle{ ( static_cast<int>( Train->ggEPFuseButton.type() ) & static_cast<int>( TGaugeType::toggle ) ) != 0 };
if( Command.action == GLFW_PRESS ) {
// command only works for bistable switch
if(istoggle) {
if( Train->mvOccupied->EpFuseSwitch( false ) ) {
Train->ggEPFuseButton.UpdateValue(0.0f, Train->dsbSwitch);
};
}
}
}
void TTrain::OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_REPEAT ) { return; }