mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-23 16:49:18 +02:00
Battery button impulse behavior
This commit is contained in:
@@ -1138,6 +1138,9 @@ class TMoverParameters
|
|||||||
int UniversalBrakeButtonFlag[3] = {0, 0, 0}; /* mozliwe działania przycisków hamulcowych */
|
int UniversalBrakeButtonFlag[3] = {0, 0, 0}; /* mozliwe działania przycisków hamulcowych */
|
||||||
int UniversalResetButtonFlag[3] = {0, 0, 0}; // customizable reset buttons assignments
|
int UniversalResetButtonFlag[3] = {0, 0, 0}; // customizable reset buttons assignments
|
||||||
int TurboTest = 0;
|
int TurboTest = 0;
|
||||||
|
bool isBatteryButtonImpulse = false; // czy przelacznik baterii traktowac jako pojedynczy przycisk
|
||||||
|
bool shouldHoldBatteryButton = false; // czy nalezy przytrzymac przycisk baterii aby wlaczyc/wylaczyc baterie
|
||||||
|
float BatteryButtonHoldTime = 1.f; // minimalny czas przytrzymania przycisku baterii
|
||||||
double MaxBrakeForce = 0.0; /*maksymalna sila nacisku hamulca*/
|
double MaxBrakeForce = 0.0; /*maksymalna sila nacisku hamulca*/
|
||||||
double MaxBrakePress[5]; // pomocniczy, proz, sred, lad, pp
|
double MaxBrakePress[5]; // pomocniczy, proz, sred, lad, pp
|
||||||
double P2FTrans = 0.0;
|
double P2FTrans = 0.0;
|
||||||
|
|||||||
@@ -10628,6 +10628,9 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
|
|||||||
extract_value(isDoubleClickForMeasureNeeded, "DCMB", line, "");
|
extract_value(isDoubleClickForMeasureNeeded, "DCMB", line, "");
|
||||||
extract_value(DistanceCounterDoublePressPeriod, "DCDPP", line, "");
|
extract_value(DistanceCounterDoublePressPeriod, "DCDPP", line, "");
|
||||||
|
|
||||||
|
extract_value(isBatteryButtonImpulse, "IBTB", line, "");
|
||||||
|
extract_value(shouldHoldBatteryButton, "SBBBH", line, "");
|
||||||
|
extract_value(BatteryButtonHoldTime, "BBHT", line, "");
|
||||||
|
|
||||||
std::map<std::string, start_t> starts {
|
std::map<std::string, start_t> starts {
|
||||||
{ "Disabled", start_t::disabled },
|
{ "Disabled", start_t::disabled },
|
||||||
|
|||||||
166
Train.cpp
166
Train.cpp
@@ -2398,7 +2398,8 @@ void TTrain::OnCommand_cabsignalacknowledge( TTrain *Train, command_data const &
|
|||||||
|
|
||||||
void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command )
|
void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command )
|
||||||
{
|
{
|
||||||
if( Command.action != GLFW_REPEAT ) {
|
if (Train->allowBatteryToggle || Command.action != GLFW_REPEAT)
|
||||||
|
{
|
||||||
// keep the switch from flipping back and forth if key is held down
|
// keep the switch from flipping back and forth if key is held down
|
||||||
if( false == Train->mvOccupied->Power24vIsAvailable ) {
|
if( false == Train->mvOccupied->Power24vIsAvailable ) {
|
||||||
// turn on
|
// turn on
|
||||||
@@ -2412,43 +2413,159 @@ void TTrain::OnCommand_batterytoggle( TTrain *Train, command_data const &Command
|
|||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_batteryenable( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_batteryenable( TTrain *Train, command_data const &Command ) {
|
||||||
|
if (!Train->mvOccupied->isBatteryButtonImpulse)
|
||||||
if( Command.action == GLFW_PRESS ) {
|
{ // regular button behavior
|
||||||
|
if (Command.action == GLFW_PRESS)
|
||||||
|
{
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggBatteryButton.UpdateValue( 1.0f, Train->dsbSwitch );
|
Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
Train->ggBatteryOnButton.UpdateValue( 1.0f, Train->dsbSwitch );
|
Train->ggBatteryOnButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
|
||||||
Train->mvOccupied->BatterySwitch( true );
|
|
||||||
|
|
||||||
|
Train->mvOccupied->BatterySwitch(true);
|
||||||
|
Train->allowBatteryToggle = false;
|
||||||
// side-effects
|
// side-effects
|
||||||
if( Train->mvOccupied->LightsPosNo > 0 ) {
|
if (Train->mvOccupied->LightsPosNo > 0)
|
||||||
|
{
|
||||||
Train->Dynamic()->SetLights();
|
Train->Dynamic()->SetLights();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
else if (Command.action == GLFW_RELEASE)
|
||||||
if( Train->ggBatteryButton.type() == TGaugeType::push ) {
|
{
|
||||||
|
if (Train->ggBatteryButton.type() == TGaugeType::push)
|
||||||
|
{
|
||||||
// return the switch to neutral position
|
// return the switch to neutral position
|
||||||
Train->ggBatteryButton.UpdateValue( 0.5f );
|
Train->ggBatteryButton.UpdateValue(0.5f);
|
||||||
|
}
|
||||||
|
Train->ggBatteryOnButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
Train->allowBatteryToggle = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // impulse button behavior
|
||||||
|
{
|
||||||
|
if (Command.action == GLFW_PRESS)
|
||||||
|
{
|
||||||
|
if (Train->mvOccupied->shouldHoldBatteryButton)
|
||||||
|
{
|
||||||
|
// jesli przycisk trzeba przytrzymac
|
||||||
|
Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
Train->ggBatteryOnButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
Train->fBatteryTimer = Train->mvOccupied->BatteryButtonHoldTime; // start timer
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// jesli przycisk dziala od razu
|
||||||
|
Train->mvOccupied->BatterySwitch(true);
|
||||||
|
Train->allowBatteryToggle = false;
|
||||||
|
// side-effects
|
||||||
|
if (Train->mvOccupied->LightsPosNo > 0)
|
||||||
|
{
|
||||||
|
Train->Dynamic()->SetLights();
|
||||||
|
}
|
||||||
|
|
||||||
|
// visual feedback
|
||||||
|
Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
Train->ggBatteryOnButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
// visual feedback
|
||||||
|
Train->ggBatteryButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
Train->ggBatteryOnButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
Train->fBatteryTimer = -1.f; //
|
||||||
|
Train->allowBatteryToggle = true;
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_REPEAT && Train->mvOccupied->shouldHoldBatteryButton)
|
||||||
|
{
|
||||||
|
// trzymamy przycisk
|
||||||
|
if (Train->fBatteryTimer <= 0.0 && Train->mvOccupied->Battery == false) {
|
||||||
|
Train->mvOccupied->BatterySwitch(true);
|
||||||
|
// side-effects
|
||||||
|
if (Train->mvOccupied->LightsPosNo > 0)
|
||||||
|
{
|
||||||
|
Train->Dynamic()->SetLights();
|
||||||
|
}
|
||||||
|
Train->allowBatteryToggle = false;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
Train->ggBatteryOnButton.UpdateValue( 0.0f, Train->dsbSwitch );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void TTrain::OnCommand_batterydisable( TTrain *Train, command_data const &Command ) {
|
void TTrain::OnCommand_batterydisable( TTrain *Train, command_data const &Command ) {
|
||||||
// TBD, TODO: ewentualnie zablokować z FIZ, np. w samochodach się nie odłącza akumulatora
|
if (!Train->mvOccupied->isBatteryButtonImpulse)
|
||||||
if( Command.action == GLFW_PRESS ) {
|
{ // regular button behavior
|
||||||
|
if (Command.action == GLFW_PRESS)
|
||||||
|
{
|
||||||
// visual feedback
|
// visual feedback
|
||||||
Train->ggBatteryButton.UpdateValue( 0.0f, Train->dsbSwitch );
|
Train->ggBatteryButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
Train->ggBatteryOffButton.UpdateValue( 1.0f, Train->dsbSwitch );
|
Train->ggBatteryOffButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
|
||||||
Train->mvOccupied->BatterySwitch( false );
|
Train->mvOccupied->BatterySwitch(false);
|
||||||
|
|
||||||
|
// side-effects
|
||||||
|
if (Train->mvOccupied->LightsPosNo > 0)
|
||||||
|
{
|
||||||
|
Train->Dynamic()->SetLights();
|
||||||
}
|
}
|
||||||
else if( Command.action == GLFW_RELEASE ) {
|
}
|
||||||
if( Train->ggBatteryButton.type() == TGaugeType::push ) {
|
else if (Command.action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
if (Train->ggBatteryButton.type() == TGaugeType::push)
|
||||||
|
{
|
||||||
// return the switch to neutral position
|
// return the switch to neutral position
|
||||||
Train->ggBatteryButton.UpdateValue( 0.5f );
|
Train->ggBatteryButton.UpdateValue(0.5f);
|
||||||
|
}
|
||||||
|
Train->ggBatteryOffButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else // impulse button behavior
|
||||||
|
{
|
||||||
|
if (Command.action == GLFW_PRESS)
|
||||||
|
{
|
||||||
|
if (Train->mvOccupied->shouldHoldBatteryButton)
|
||||||
|
{
|
||||||
|
// jesli przycisk trzeba przytrzymac
|
||||||
|
Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
Train->ggBatteryOffButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
Train->fBatteryTimer = Train->mvOccupied->BatteryButtonHoldTime; // start timer
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// jesli przycisk dziala od razu
|
||||||
|
Train->mvOccupied->BatterySwitch(false);
|
||||||
|
Train->allowBatteryToggle = false;
|
||||||
|
|
||||||
|
// side-effects
|
||||||
|
if (Train->mvOccupied->LightsPosNo > 0)
|
||||||
|
{
|
||||||
|
Train->Dynamic()->SetLights();
|
||||||
|
}
|
||||||
|
// visual feedback
|
||||||
|
Train->ggBatteryButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
Train->ggBatteryOffButton.UpdateValue(1.0f, Train->dsbSwitch);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_RELEASE)
|
||||||
|
{
|
||||||
|
// visual feedback
|
||||||
|
Train->ggBatteryButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
Train->ggBatteryOffButton.UpdateValue(0.0f, Train->dsbSwitch);
|
||||||
|
Train->allowBatteryToggle = true;
|
||||||
|
}
|
||||||
|
else if (Command.action == GLFW_REPEAT && Train->mvOccupied->shouldHoldBatteryButton)
|
||||||
|
{
|
||||||
|
// trzymamy przycisk
|
||||||
|
if (Train->fBatteryTimer <= 0.0 && Train->mvOccupied->Battery == true) {
|
||||||
|
Train->mvOccupied->BatterySwitch(false);
|
||||||
|
Train->allowBatteryToggle = false;
|
||||||
|
// side-effects
|
||||||
|
if (Train->mvOccupied->LightsPosNo > 0)
|
||||||
|
{
|
||||||
|
Train->Dynamic()->SetLights();
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Train->ggBatteryOffButton.UpdateValue( 0.0f, Train->dsbSwitch );
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -6967,9 +7084,14 @@ bool TTrain::Update( double const Deltatime )
|
|||||||
if (trainLenghtMeasureTimer >= 0.f) {
|
if (trainLenghtMeasureTimer >= 0.f) {
|
||||||
trainLenghtMeasureTimer -= Deltatime;
|
trainLenghtMeasureTimer -= Deltatime;
|
||||||
if (trainLenghtMeasureTimer < 0.f)
|
if (trainLenghtMeasureTimer < 0.f)
|
||||||
{
|
|
||||||
trainLenghtMeasureTimer = -1.f;
|
trainLenghtMeasureTimer = -1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// battery timer
|
||||||
|
if (fBatteryTimer >= 0.f) {
|
||||||
|
fBatteryTimer -= Deltatime;
|
||||||
|
if (fBatteryTimer < 0.f)
|
||||||
|
fBatteryTimer = -1.f;
|
||||||
}
|
}
|
||||||
|
|
||||||
// helper variables
|
// helper variables
|
||||||
|
|||||||
2
Train.h
2
Train.h
@@ -843,6 +843,8 @@ private:
|
|||||||
float fHaslerTimer;
|
float fHaslerTimer;
|
||||||
float fConverterTimer; // hunter-261211: dla przekaznika
|
float fConverterTimer; // hunter-261211: dla przekaznika
|
||||||
float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem
|
float fMainRelayTimer; // hunter-141211: zalaczanie WSa z opoznieniem
|
||||||
|
float fBatteryTimer = {-1.f}; // Hirek: zalaczanie baterii z opoznieniem (tylko gdy zdefiniowano takie zachowanie w fiz)
|
||||||
|
bool allowBatteryToggle = true; // Hirek: zabezpieczenie przed przelaczaniem bateri on/off
|
||||||
int ScreenUpdateRate { 0 }; // vehicle specific python screen update rate override
|
int ScreenUpdateRate { 0 }; // vehicle specific python screen update rate override
|
||||||
|
|
||||||
// McZapkie-240302 - przyda sie do tachometru
|
// McZapkie-240302 - przyda sie do tachometru
|
||||||
|
|||||||
Reference in New Issue
Block a user