mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 22:09:19 +02:00
compressor start method, minor ai vehicle preparation logic tweaks, minor refactoring
This commit is contained in:
12
Driver.cpp
12
Driver.cpp
@@ -2237,8 +2237,8 @@ bool TController::PrepareEngine()
|
||||
}
|
||||
if (mvControlling->EnginePowerSource.SourceType == CurrentCollector)
|
||||
{ // jeśli silnikowy jest pantografującym
|
||||
mvControlling->PantFront( true );
|
||||
mvControlling->PantRear( true );
|
||||
mvOccupied->PantFront( true );
|
||||
mvOccupied->PantRear( true );
|
||||
if (mvControlling->PantPress < 4.2) {
|
||||
// załączenie małej sprężarki
|
||||
if( mvControlling->TrainType != dt_EZT ) {
|
||||
@@ -2266,11 +2266,11 @@ bool TController::PrepareEngine()
|
||||
if( !iDirection ) {
|
||||
// jeśli nie ma ustalonego kierunku
|
||||
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
|
||||
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
|
||||
iDirection = 1; // jazda w kierunku sprzęgu 0
|
||||
}
|
||||
@@ -2332,7 +2332,7 @@ bool TController::PrepareEngine()
|
||||
OK = ( OrderDirectionChange( iDirection, mvOccupied ) == -1 );
|
||||
mvOccupied->ConverterSwitch( true );
|
||||
// w EN57 sprężarka w ra jest zasilana z silnikowego
|
||||
mvControlling->CompressorSwitch( true );
|
||||
mvOccupied->CompressorSwitch( true );
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -2341,7 +2341,7 @@ bool TController::PrepareEngine()
|
||||
else
|
||||
OK = false;
|
||||
|
||||
OK = OK && (mvOccupied->ActiveDir != 0) && (mvControlling->CompressorAllow) && (workingtemperature);
|
||||
OK = OK && ( mvOccupied->ActiveDir != 0 ) && ( mvControlling->ScndPipePress > 4.5 ) && ( workingtemperature );
|
||||
if (OK)
|
||||
{
|
||||
if (eStopReason == stopSleep) // jeśli dotychczas spał
|
||||
|
||||
@@ -860,7 +860,7 @@ public:
|
||||
double RVentCutOff = 0.0; /*rezystancja wylaczania wentylatorow dla RVentType=2*/
|
||||
double RVentSpeed { 0.5 }; //rozpedzanie sie wentylatora obr/s^2}
|
||||
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*/
|
||||
bool Trafo = false; /*pojazd wyposażony w transformator*/
|
||||
|
||||
@@ -993,6 +993,7 @@ public:
|
||||
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 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
|
||||
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
|
||||
@@ -1269,7 +1270,7 @@ public:
|
||||
bool IncBrakePress(double &brake, double PressLimit, double dp);
|
||||
bool DecBrakePress(double &brake, double PressLimit, double dp);
|
||||
bool BrakeDelaySwitch(int BDS);/*! przelaczanie nastawy opoznienia*/
|
||||
bool IncBrakeMult(void);/*przelaczanie prozny/ladowny*/
|
||||
bool IncBrakeMult(void);/*przelaczanie prozny/ladowny*/
|
||||
bool DecBrakeMult(void);
|
||||
/*pomocnicze funkcje dla ukladow pneumatycznych*/
|
||||
void UpdateBrakePressure(double dt);
|
||||
|
||||
@@ -2679,7 +2679,7 @@ bool TMoverParameters::ConverterSwitch( 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
|
||||
return false;
|
||||
}
|
||||
@@ -3323,35 +3323,38 @@ void TMoverParameters::CompressorCheck(double dt)
|
||||
else {
|
||||
if( CompressorPower == 3 ) {
|
||||
// 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
|
||||
{ // sprawdzić możliwe warunki wyłączenia sprężarki
|
||||
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)
|
||||
if (Couplers[1].Connected != NULL)
|
||||
CompressorFlag =
|
||||
( Couplers[ 1 ].Connected->CompressorAllow
|
||||
&& Couplers[ 1 ].Connected->CompressorAllowLocal
|
||||
&& Couplers[ 1 ].Connected->Mains
|
||||
&& Couplers[ 1 ].Connected->ConverterFlag );
|
||||
else
|
||||
CompressorFlag = false; // bez tamtego członu nie zadziała
|
||||
if( Couplers[ side::rear ].Connected != NULL ) {
|
||||
CompressorFlag = (
|
||||
( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
|
||||
&& ( CompressorAllowLocal )
|
||||
&& ( Couplers[ side::rear ].Connected->ConverterFlag ) );
|
||||
}
|
||||
else {
|
||||
// bez tamtego członu nie zadziała
|
||||
CompressorFlag = false;
|
||||
}
|
||||
}
|
||||
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)
|
||||
if (Couplers[0].Connected != NULL)
|
||||
CompressorFlag =
|
||||
( Couplers[ 0 ].Connected->CompressorAllow
|
||||
&& Couplers[ 0 ].Connected->CompressorAllowLocal
|
||||
&& Couplers[ 0 ].Connected->Mains
|
||||
&& Couplers[ 0 ].Connected->ConverterFlag );
|
||||
else
|
||||
if( Couplers[ side::front ].Connected != NULL ) {
|
||||
CompressorFlag = (
|
||||
( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
|
||||
&& ( CompressorAllowLocal )
|
||||
&& ( Couplers[ side::front ].Connected->ConverterFlag ) );
|
||||
}
|
||||
else {
|
||||
CompressorFlag = false; // bez tamtego członu nie zadziała
|
||||
}
|
||||
}
|
||||
else
|
||||
CompressorFlag =
|
||||
( ( CompressorAllow )
|
||||
CompressorFlag = (
|
||||
( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
|
||||
&& ( CompressorAllowLocal )
|
||||
&& ( Mains )
|
||||
&& ( ( ConverterFlag )
|
||||
@@ -3402,38 +3405,37 @@ void TMoverParameters::CompressorCheck(double dt)
|
||||
// or if the switch is on and the pressure isn't maxed
|
||||
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)
|
||||
if( Couplers[ 1 ].Connected != nullptr ) {
|
||||
CompressorFlag =
|
||||
( Couplers[ 1 ].Connected->CompressorAllow
|
||||
&& Couplers[ 1 ].Connected->CompressorAllowLocal
|
||||
&& Couplers[ 1 ].Connected->Mains
|
||||
&& Couplers[ 1 ].Connected->ConverterFlag );
|
||||
}
|
||||
if( Couplers[ side::rear ].Connected != NULL ) {
|
||||
CompressorFlag = (
|
||||
( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
|
||||
&& ( CompressorAllowLocal )
|
||||
&& ( Couplers[ side::rear ].Connected->ConverterFlag ) );
|
||||
}
|
||||
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
|
||||
{ // zasilanie sprężarki w członie ra z członu silnikowego (sprzęg 1)
|
||||
if( Couplers[ 0 ].Connected != nullptr ) {
|
||||
CompressorFlag =
|
||||
( Couplers[ 0 ].Connected->CompressorAllow
|
||||
&& Couplers[ 0 ].Connected->CompressorAllowLocal
|
||||
&& Couplers[ 0 ].Connected->Mains
|
||||
&& Couplers[ 0 ].Connected->ConverterFlag );
|
||||
if( Couplers[ side::front ].Connected != NULL ) {
|
||||
CompressorFlag = (
|
||||
( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
|
||||
&& ( CompressorAllowLocal )
|
||||
&& ( Couplers[ side::front ].Connected->ConverterFlag ) );
|
||||
}
|
||||
else {
|
||||
CompressorFlag = false; // bez tamtego członu nie zadziała
|
||||
}
|
||||
}
|
||||
else {
|
||||
CompressorFlag =
|
||||
( ( CompressorAllow )
|
||||
&& ( CompressorAllowLocal )
|
||||
&& ( Mains )
|
||||
&& ( ( ConverterFlag )
|
||||
|| ( CompressorPower == 0 )
|
||||
|| ( CompressorPower == 3 ) ) );
|
||||
CompressorFlag = (
|
||||
( ( CompressorAllow ) || ( CompressorStart == start::automatic ) )
|
||||
&& ( CompressorAllowLocal )
|
||||
&& ( Mains )
|
||||
&& ( ( ConverterFlag )
|
||||
|| ( CompressorPower == 0 )
|
||||
|| ( CompressorPower == 3 ) ) );
|
||||
}
|
||||
|
||||
// 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, "" );
|
||||
|
||||
// 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
|
||||
{
|
||||
std::map<std::string, start> starts {
|
||||
@@ -9256,7 +9271,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
|
||||
// end
|
||||
else if (Command == "CompressorSwitch") /*NBMX*/
|
||||
{
|
||||
if( CompressorPower < 2 ) {
|
||||
if( CompressorStart == start::manual ) {
|
||||
CompressorAllow = ( CValue1 == 1 );
|
||||
}
|
||||
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
|
||||
|
||||
22
Train.cpp
22
Train.cpp
@@ -193,8 +193,8 @@ TTrain::commandhandler_map const TTrain::m_commandhandlers = {
|
||||
{ user_command::wheelspinbrakeactivate, &TTrain::OnCommand_wheelspinbrakeactivate },
|
||||
{ user_command::sandboxactivate, &TTrain::OnCommand_sandboxactivate },
|
||||
{ user_command::epbrakecontroltoggle, &TTrain::OnCommand_epbrakecontroltoggle },
|
||||
{ user_command::brakeoperationmodeincrease, &TTrain::OnCommand_brakeoperationmodeincrease },
|
||||
{ user_command::brakeoperationmodedecrease, &TTrain::OnCommand_brakeoperationmodedecrease },
|
||||
{ user_command::trainbrakeoperationmodeincrease, &TTrain::OnCommand_trainbrakeoperationmodeincrease },
|
||||
{ user_command::trainbrakeoperationmodedecrease, &TTrain::OnCommand_trainbrakeoperationmodedecrease },
|
||||
{ user_command::brakeactingspeedincrease, &TTrain::OnCommand_brakeactingspeedincrease },
|
||||
{ user_command::brakeactingspeeddecrease, &TTrain::OnCommand_brakeactingspeeddecrease },
|
||||
{ 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) {
|
||||
// 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) {
|
||||
// next mode
|
||||
Train->mvOccupied->BrakeOpModeFlag *= 2;
|
||||
// audio feedback
|
||||
if( ( ( Train->mvOccupied->BrakeOpModeFlag << 1 ) & Train->mvOccupied->BrakeOpModes ) != 0 ) {
|
||||
// next mode
|
||||
Train->mvOccupied->BrakeOpModeFlag <<= 1;
|
||||
// audio feedback
|
||||
Train->dsbPneumaticSwitch.play();
|
||||
// visual feedback
|
||||
// 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) {
|
||||
// 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
|
||||
Train->mvOccupied->BrakeOpModeFlag /= 2;
|
||||
Train->mvOccupied->BrakeOpModeFlag >>= 1;
|
||||
// audio feedback
|
||||
Train->dsbPneumaticSwitch.play();
|
||||
// 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 ) {
|
||||
|
||||
if( Command.action == GLFW_PRESS ) {
|
||||
|
||||
4
Train.h
4
Train.h
@@ -184,8 +184,8 @@ class TTrain
|
||||
static void OnCommand_wheelspinbrakeactivate( 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_brakeoperationmodeincrease(TTrain *Train, command_data const &Command);
|
||||
static void OnCommand_brakeoperationmodedecrease(TTrain *Train, command_data const &Command);
|
||||
static void OnCommand_trainbrakeoperationmodeincrease(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_brakeactingspeeddecrease( TTrain *Train, command_data const &Command );
|
||||
static void OnCommand_brakeactingspeedsetcargo( TTrain *Train, command_data const &Command );
|
||||
|
||||
@@ -102,8 +102,8 @@ commanddescription_sequence Commands_descriptions = {
|
||||
{ "motoroverloadrelayreset", command_target::vehicle },
|
||||
{ "notchingrelaytoggle", command_target::vehicle },
|
||||
{ "epbrakecontroltoggle", command_target::vehicle },
|
||||
{ "brakeoperationmodeincrease", command_target::vehicle },
|
||||
{ "brakeoperationmodedecrease", command_target::vehicle },
|
||||
{ "trainbrakeoperationmodeincrease", command_target::vehicle },
|
||||
{ "trainbrakeoperationmodedecrease", command_target::vehicle },
|
||||
{ "brakeactingspeedincrease", command_target::vehicle },
|
||||
{ "brakeactingspeeddecrease", command_target::vehicle },
|
||||
{ "brakeactingspeedsetcargo", command_target::vehicle },
|
||||
|
||||
@@ -96,8 +96,8 @@ enum class user_command {
|
||||
motoroverloadrelayreset,
|
||||
notchingrelaytoggle,
|
||||
epbrakecontroltoggle,
|
||||
brakeoperationmodeincrease,
|
||||
brakeoperationmodedecrease,
|
||||
trainbrakeoperationmodeincrease,
|
||||
trainbrakeoperationmodedecrease,
|
||||
brakeactingspeedincrease,
|
||||
brakeactingspeeddecrease,
|
||||
brakeactingspeedsetcargo,
|
||||
|
||||
@@ -333,10 +333,10 @@ keyboard_input::default_bindings() {
|
||||
{ GLFW_KEY_G },
|
||||
// epbrakecontroltoggle
|
||||
{ GLFW_KEY_Z | keymodifier::control },
|
||||
// brakeoperationmodeincrease
|
||||
{ GLFW_KEY_L | keymodifier::shift },
|
||||
// brakeoperationmodedecrease
|
||||
{ GLFW_KEY_L},
|
||||
// trainbrakeoperationmodeincrease
|
||||
{ GLFW_KEY_KP_3 | keymodifier::shift | keymodifier::control },
|
||||
// trainbrakeoperationmodedecrease
|
||||
{ GLFW_KEY_KP_9 | keymodifier::shift | keymodifier::control },
|
||||
// brakeactingspeedincrease
|
||||
{ GLFW_KEY_B | keymodifier::shift },
|
||||
// brakeactingspeeddecrease
|
||||
|
||||
Reference in New Issue
Block a user