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

compressor start method, minor ai vehicle preparation logic tweaks, minor refactoring

This commit is contained in:
tmj-fstate
2018-04-18 22:14:16 +02:00
parent fc1f57a5d4
commit 430ab99f8e
9 changed files with 86 additions and 72 deletions

View File

@@ -2237,8 +2237,8 @@ bool TController::PrepareEngine()
} }
if (mvControlling->EnginePowerSource.SourceType == CurrentCollector) if (mvControlling->EnginePowerSource.SourceType == CurrentCollector)
{ // jeśli silnikowy jest pantografującym { // jeśli silnikowy jest pantografującym
mvControlling->PantFront( true ); mvOccupied->PantFront( true );
mvControlling->PantRear( true ); mvOccupied->PantRear( true );
if (mvControlling->PantPress < 4.2) { if (mvControlling->PantPress < 4.2) {
// załączenie małej sprężarki // załączenie małej sprężarki
if( mvControlling->TrainType != dt_EZT ) { if( mvControlling->TrainType != dt_EZT ) {
@@ -2266,11 +2266,11 @@ bool TController::PrepareEngine()
if( !iDirection ) { if( !iDirection ) {
// jeśli nie ma ustalonego kierunku // jeśli nie ma ustalonego kierunku
if( ( mvControlling->PantFrontVolt != 0.0 ) || ( mvControlling->PantRearVolt != 0.0 ) || voltfront || voltrear ) { if( ( mvControlling->PantFrontVolt != 0.0 ) || ( mvControlling->PantRearVolt != 0.0 ) || voltfront || voltrear ) {
if( mvOccupied->Couplers[ 1 ].CouplingFlag == ctrain_virtual ) { if( mvOccupied->Couplers[ 1 ].CouplingFlag == coupling::faux ) {
// jeśli z tyłu nie ma nic // jeśli z tyłu nie ma nic
iDirection = -1; // jazda w kierunku sprzęgu 1 iDirection = -1; // jazda w kierunku sprzęgu 1
} }
if( mvOccupied->Couplers[ 0 ].CouplingFlag == ctrain_virtual ) { if( mvOccupied->Couplers[ 0 ].CouplingFlag == coupling::faux ) {
// jeśli z przodu nie ma nic // jeśli z przodu nie ma nic
iDirection = 1; // jazda w kierunku sprzęgu 0 iDirection = 1; // jazda w kierunku sprzęgu 0
} }
@@ -2332,7 +2332,7 @@ bool TController::PrepareEngine()
OK = ( OrderDirectionChange( iDirection, mvOccupied ) == -1 ); OK = ( OrderDirectionChange( iDirection, mvOccupied ) == -1 );
mvOccupied->ConverterSwitch( true ); mvOccupied->ConverterSwitch( true );
// w EN57 sprężarka w ra jest zasilana z silnikowego // w EN57 sprężarka w ra jest zasilana z silnikowego
mvControlling->CompressorSwitch( true ); mvOccupied->CompressorSwitch( true );
} }
} }
else else
@@ -2341,7 +2341,7 @@ bool TController::PrepareEngine()
else else
OK = false; OK = false;
OK = OK && (mvOccupied->ActiveDir != 0) && (mvControlling->CompressorAllow) && (workingtemperature); OK = OK && ( mvOccupied->ActiveDir != 0 ) && ( mvControlling->ScndPipePress > 4.5 ) && ( workingtemperature );
if (OK) if (OK)
{ {
if (eStopReason == stopSleep) // jeśli dotychczas spał if (eStopReason == stopSleep) // jeśli dotychczas spał

View File

@@ -860,7 +860,7 @@ public:
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}
int CompressorPower = 1; /*0: bezp. z obwodow silnika, 1: z przetwornicy, reczne, 2: w przetwornicy, stale, 5: z silnikowego*/ 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*/
@@ -993,6 +993,7 @@ public:
bool CompressorAllow = false; /*! zezwolenie na uruchomienie sprezarki NBMX*/ bool CompressorAllow = false; /*! zezwolenie na uruchomienie sprezarki NBMX*/
bool CompressorAllowLocal{ true }; // local device state override (most units don't have this fitted so it's set to true not to intefere) 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 bool CompressorGovernorLock{ false }; // indicates whether compressor pressure switch was activated due to reaching cut-out pressure
start CompressorStart{ start::manual }; // whether the compressor is started manually, or another way
// TODO converter parameters, for when we start cleaning up mover parameters // TODO converter parameters, for when we start cleaning up mover parameters
start ConverterStart{ start::manual }; // whether converter is started manually, or by other means start ConverterStart{ start::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 float ConverterStartDelay{ 0.0f }; // delay (in seconds) before the converter is started, once its activation conditions are met
@@ -1269,7 +1270,7 @@ public:
bool IncBrakePress(double &brake, double PressLimit, double dp); bool IncBrakePress(double &brake, double PressLimit, double dp);
bool DecBrakePress(double &brake, double PressLimit, double dp); bool DecBrakePress(double &brake, double PressLimit, double dp);
bool BrakeDelaySwitch(int BDS);/*! przelaczanie nastawy opoznienia*/ bool BrakeDelaySwitch(int BDS);/*! przelaczanie nastawy opoznienia*/
bool IncBrakeMult(void);/*przelaczanie prozny/ladowny*/ bool IncBrakeMult(void);/*przelaczanie prozny/ladowny*/
bool DecBrakeMult(void); bool DecBrakeMult(void);
/*pomocnicze funkcje dla ukladow pneumatycznych*/ /*pomocnicze funkcje dla ukladow pneumatycznych*/
void UpdateBrakePressure(double dt); void UpdateBrakePressure(double dt);

View File

@@ -2679,7 +2679,7 @@ bool TMoverParameters::ConverterSwitch( bool State, int const Notify )
// ************************************************************************************************* // *************************************************************************************************
bool TMoverParameters::CompressorSwitch( bool State, int const Notify ) bool TMoverParameters::CompressorSwitch( bool State, int const Notify )
{ {
if( CompressorPower > 1 ) { if( CompressorStart != start::manual ) {
// only pay attention if the compressor can be controlled manually // only pay attention if the compressor can be controlled manually
return false; return false;
} }
@@ -3323,35 +3323,38 @@ void TMoverParameters::CompressorCheck(double dt)
else { else {
if( CompressorPower == 3 ) { if( CompressorPower == 3 ) {
// experimental: make sure compressor coupled with diesel engine is always ready for work // experimental: make sure compressor coupled with diesel engine is always ready for work
CompressorAllow = true; CompressorStart = start::automatic;
} }
if (CompressorFlag) // jeśli sprężarka załączona if (CompressorFlag) // jeśli sprężarka załączona
{ // sprawdzić możliwe warunki wyłączenia sprężarki { // sprawdzić możliwe warunki wyłączenia sprężarki
if (CompressorPower == 5) // jeśli zasilanie z sąsiedniego członu if (CompressorPower == 5) // jeśli zasilanie z sąsiedniego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if (Couplers[1].Connected != NULL) if( Couplers[ side::rear ].Connected != NULL ) {
CompressorFlag = CompressorFlag = (
( Couplers[ 1 ].Connected->CompressorAllow ( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
&& Couplers[ 1 ].Connected->CompressorAllowLocal && ( CompressorAllowLocal )
&& Couplers[ 1 ].Connected->Mains && ( Couplers[ side::rear ].Connected->ConverterFlag ) );
&& Couplers[ 1 ].Connected->ConverterFlag ); }
else else {
CompressorFlag = false; // bez tamtego członu nie zadziała // bez tamtego członu nie zadziała
CompressorFlag = false;
}
} }
else if (CompressorPower == 4) // jeśli zasilanie z poprzedniego członu else if (CompressorPower == 4) // jeśli zasilanie z poprzedniego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if (Couplers[0].Connected != NULL) if( Couplers[ side::front ].Connected != NULL ) {
CompressorFlag = CompressorFlag = (
( Couplers[ 0 ].Connected->CompressorAllow ( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
&& Couplers[ 0 ].Connected->CompressorAllowLocal && ( CompressorAllowLocal )
&& Couplers[ 0 ].Connected->Mains && ( Couplers[ side::front ].Connected->ConverterFlag ) );
&& Couplers[ 0 ].Connected->ConverterFlag ); }
else else {
CompressorFlag = false; // bez tamtego członu nie zadziała CompressorFlag = false; // bez tamtego członu nie zadziała
}
} }
else else
CompressorFlag = CompressorFlag = (
( ( CompressorAllow ) ( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
&& ( CompressorAllowLocal ) && ( CompressorAllowLocal )
&& ( Mains ) && ( Mains )
&& ( ( ConverterFlag ) && ( ( ConverterFlag )
@@ -3402,38 +3405,37 @@ void TMoverParameters::CompressorCheck(double dt)
// or if the switch is on and the pressure isn't maxed // or if the switch is on and the pressure isn't maxed
if( CompressorPower == 5 ) // jeśli zasilanie z następnego członu if( CompressorPower == 5 ) // jeśli zasilanie z następnego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if( Couplers[ 1 ].Connected != nullptr ) { if( Couplers[ side::rear ].Connected != NULL ) {
CompressorFlag = CompressorFlag = (
( Couplers[ 1 ].Connected->CompressorAllow ( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
&& Couplers[ 1 ].Connected->CompressorAllowLocal && ( CompressorAllowLocal )
&& Couplers[ 1 ].Connected->Mains && ( Couplers[ side::rear ].Connected->ConverterFlag ) );
&& Couplers[ 1 ].Connected->ConverterFlag ); }
}
else { else {
CompressorFlag = false; // bez tamtego członu nie zadziała // bez tamtego członu nie zadziała
CompressorFlag = false;
} }
} }
else if( CompressorPower == 4 ) // jeśli zasilanie z poprzedniego członu else if( CompressorPower == 4 ) // jeśli zasilanie z poprzedniego członu
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1) { // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
if( Couplers[ 0 ].Connected != nullptr ) { if( Couplers[ side::front ].Connected != NULL ) {
CompressorFlag = CompressorFlag = (
( Couplers[ 0 ].Connected->CompressorAllow ( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
&& Couplers[ 0 ].Connected->CompressorAllowLocal && ( CompressorAllowLocal )
&& Couplers[ 0 ].Connected->Mains && ( Couplers[ side::front ].Connected->ConverterFlag ) );
&& Couplers[ 0 ].Connected->ConverterFlag );
} }
else { else {
CompressorFlag = false; // bez tamtego członu nie zadziała CompressorFlag = false; // bez tamtego członu nie zadziała
} }
} }
else { else {
CompressorFlag = CompressorFlag = (
( ( CompressorAllow ) ( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
&& ( CompressorAllowLocal ) && ( CompressorAllowLocal )
&& ( Mains ) && ( Mains )
&& ( ( ConverterFlag ) && ( ( ConverterFlag )
|| ( CompressorPower == 0 ) || ( CompressorPower == 0 )
|| ( CompressorPower == 3 ) ) ); || ( CompressorPower == 3 ) ) );
} }
// NOTE: crude way to enforce simultaneous activation of compressors in multi-unit setups // NOTE: crude way to enforce simultaneous activation of compressors in multi-unit setups
@@ -8143,6 +8145,19 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
} }
extract_value( ConverterStartDelay, "ConverterStartDelay", line, "" ); extract_value( ConverterStartDelay, "ConverterStartDelay", line, "" );
// compressor
{
std::map<std::string, start> starts {
{ "Manual", start::manual },
{ "Automatic", start::automatic }
};
auto lookup = starts.find( extract_value( "CompressorStart", line ) );
CompressorStart =
lookup != starts.end() ?
lookup->second :
start::manual;
}
// fuel pump // fuel pump
{ {
std::map<std::string, start> starts { std::map<std::string, start> starts {
@@ -9256,7 +9271,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
// end // end
else if (Command == "CompressorSwitch") /*NBMX*/ else if (Command == "CompressorSwitch") /*NBMX*/
{ {
if( CompressorPower < 2 ) { if( CompressorStart == start::manual ) {
CompressorAllow = ( CValue1 == 1 ); CompressorAllow = ( CValue1 == 1 );
} }
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype ); OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );

View File

@@ -193,8 +193,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
{ user_command::wheelspinbrakeactivate, &TTrain::OnCommand_wheelspinbrakeactivate }, { user_command::wheelspinbrakeactivate, &TTrain::OnCommand_wheelspinbrakeactivate },
{ user_command::sandboxactivate, &TTrain::OnCommand_sandboxactivate }, { user_command::sandboxactivate, &TTrain::OnCommand_sandboxactivate },
{ user_command::epbrakecontroltoggle, &TTrain::OnCommand_epbrakecontroltoggle }, { user_command::epbrakecontroltoggle, &TTrain::OnCommand_epbrakecontroltoggle },
{ user_command::brakeoperationmodeincrease, &TTrain::OnCommand_brakeoperationmodeincrease }, { user_command::trainbrakeoperationmodeincrease, &TTrain::OnCommand_trainbrakeoperationmodeincrease },
{ user_command::brakeoperationmodedecrease, &TTrain::OnCommand_brakeoperationmodedecrease }, { user_command::trainbrakeoperationmodedecrease, &TTrain::OnCommand_trainbrakeoperationmodedecrease },
{ user_command::brakeactingspeedincrease, &TTrain::OnCommand_brakeactingspeedincrease }, { user_command::brakeactingspeedincrease, &TTrain::OnCommand_brakeactingspeedincrease },
{ user_command::brakeactingspeeddecrease, &TTrain::OnCommand_brakeactingspeeddecrease }, { user_command::brakeactingspeeddecrease, &TTrain::OnCommand_brakeactingspeeddecrease },
{ user_command::brakeactingspeedsetcargo, &TTrain::OnCommand_brakeactingspeedsetcargo }, { user_command::brakeactingspeedsetcargo, &TTrain::OnCommand_brakeactingspeedsetcargo },
@@ -1266,14 +1266,14 @@ void TTrain::OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &
} }
} }
void TTrain::OnCommand_brakeoperationmodeincrease(TTrain *Train, command_data const &Command) { void TTrain::OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) { if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down // only reacting to press, so the switch doesn't flip back and forth if key is held down
if (0 < (Train->mvOccupied->BrakeOpModeFlag * 2) & Train->mvOccupied->BrakeOpModes) { if( ( ( Train->mvOccupied->BrakeOpModeFlag << 1 ) & Train->mvOccupied->BrakeOpModes ) != 0 ) {
// next mode // next mode
Train->mvOccupied->BrakeOpModeFlag *= 2; Train->mvOccupied->BrakeOpModeFlag <<= 1;
// audio feedback // audio feedback
Train->dsbPneumaticSwitch.play(); Train->dsbPneumaticSwitch.play();
// visual feedback // visual feedback
// NOTE: there's no button for brake operation mode switch // NOTE: there's no button for brake operation mode switch
@@ -1282,13 +1282,13 @@ void TTrain::OnCommand_brakeoperationmodeincrease(TTrain *Train, command_data co
} }
} }
void TTrain::OnCommand_brakeoperationmodedecrease(TTrain *Train, command_data const &Command) { void TTrain::OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_data const &Command) {
if (Command.action == GLFW_PRESS) { if (Command.action == GLFW_PRESS) {
// only reacting to press, so the switch doesn't flip back and forth if key is held down // only reacting to press, so the switch doesn't flip back and forth if key is held down
if (0 < (Train->mvOccupied->BrakeOpModeFlag / 2) & Train->mvOccupied->BrakeOpModes) { if( ( ( Train->mvOccupied->BrakeOpModeFlag >> 1 ) & Train->mvOccupied->BrakeOpModes ) != 0 ) {
// previous mode // previous mode
Train->mvOccupied->BrakeOpModeFlag /= 2; Train->mvOccupied->BrakeOpModeFlag >>= 1;
// audio feedback // audio feedback
Train->dsbPneumaticSwitch.play(); Train->dsbPneumaticSwitch.play();
// visual feedback // visual feedback
@@ -1298,8 +1298,6 @@ void TTrain::OnCommand_brakeoperationmodedecrease(TTrain *Train, command_data co
} }
} }
void TTrain::OnCommand_brakeactingspeedincrease( TTrain *Train, command_data const &Command ) { void TTrain::OnCommand_brakeactingspeedincrease( TTrain *Train, command_data const &Command ) {
if( Command.action == GLFW_PRESS ) { if( Command.action == GLFW_PRESS ) {

View File

@@ -184,8 +184,8 @@ class TTrain
static void OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command ); static void OnCommand_wheelspinbrakeactivate( TTrain *Train, command_data const &Command );
static void OnCommand_sandboxactivate( TTrain *Train, command_data const &Command ); static void OnCommand_sandboxactivate( TTrain *Train, command_data const &Command );
static void OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command ); static void OnCommand_epbrakecontroltoggle( TTrain *Train, command_data const &Command );
static void OnCommand_brakeoperationmodeincrease(TTrain *Train, command_data const &Command); static void OnCommand_trainbrakeoperationmodeincrease(TTrain *Train, command_data const &Command);
static void OnCommand_brakeoperationmodedecrease(TTrain *Train, command_data const &Command); static void OnCommand_trainbrakeoperationmodedecrease(TTrain *Train, command_data const &Command);
static void OnCommand_brakeactingspeedincrease( TTrain *Train, command_data const &Command ); static void OnCommand_brakeactingspeedincrease( TTrain *Train, command_data const &Command );
static void OnCommand_brakeactingspeeddecrease( TTrain *Train, command_data const &Command ); static void OnCommand_brakeactingspeeddecrease( TTrain *Train, command_data const &Command );
static void OnCommand_brakeactingspeedsetcargo( TTrain *Train, command_data const &Command ); static void OnCommand_brakeactingspeedsetcargo( TTrain *Train, command_data const &Command );

View File

@@ -102,8 +102,8 @@ commanddescription_sequence Commands_descriptions = {
{ "motoroverloadrelayreset", command_target::vehicle }, { "motoroverloadrelayreset", command_target::vehicle },
{ "notchingrelaytoggle", command_target::vehicle }, { "notchingrelaytoggle", command_target::vehicle },
{ "epbrakecontroltoggle", command_target::vehicle }, { "epbrakecontroltoggle", command_target::vehicle },
{ "brakeoperationmodeincrease", command_target::vehicle }, { "trainbrakeoperationmodeincrease", command_target::vehicle },
{ "brakeoperationmodedecrease", command_target::vehicle }, { "trainbrakeoperationmodedecrease", command_target::vehicle },
{ "brakeactingspeedincrease", command_target::vehicle }, { "brakeactingspeedincrease", command_target::vehicle },
{ "brakeactingspeeddecrease", command_target::vehicle }, { "brakeactingspeeddecrease", command_target::vehicle },
{ "brakeactingspeedsetcargo", command_target::vehicle }, { "brakeactingspeedsetcargo", command_target::vehicle },

View File

@@ -96,8 +96,8 @@ enum class user_command {
motoroverloadrelayreset, motoroverloadrelayreset,
notchingrelaytoggle, notchingrelaytoggle,
epbrakecontroltoggle, epbrakecontroltoggle,
brakeoperationmodeincrease, trainbrakeoperationmodeincrease,
brakeoperationmodedecrease, trainbrakeoperationmodedecrease,
brakeactingspeedincrease, brakeactingspeedincrease,
brakeactingspeeddecrease, brakeactingspeeddecrease,
brakeactingspeedsetcargo, brakeactingspeedsetcargo,

View File

@@ -333,10 +333,10 @@ keyboard_input::default_bindings() {
{ GLFW_KEY_G }, { GLFW_KEY_G },
// epbrakecontroltoggle // epbrakecontroltoggle
{ GLFW_KEY_Z | keymodifier::control }, { GLFW_KEY_Z | keymodifier::control },
// brakeoperationmodeincrease // trainbrakeoperationmodeincrease
{ GLFW_KEY_L | keymodifier::shift }, { GLFW_KEY_KP_3 | keymodifier::shift | keymodifier::control },
// brakeoperationmodedecrease // trainbrakeoperationmodedecrease
{ GLFW_KEY_L}, { GLFW_KEY_KP_9 | keymodifier::shift | keymodifier::control },
// brakeactingspeedincrease // brakeactingspeedincrease
{ GLFW_KEY_B | keymodifier::shift }, { GLFW_KEY_B | keymodifier::shift },
// brakeactingspeeddecrease // brakeactingspeeddecrease

View File

@@ -1,5 +1,5 @@
#pragma once #pragma once
#define VERSION_MAJOR 18 #define VERSION_MAJOR 18
#define VERSION_MINOR 411 #define VERSION_MINOR 418
#define VERSION_REVISION 0 #define VERSION_REVISION 0