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

audio device list, customizable relay reset cab controls, pantograph control ai hint, minor vehicle initialization tweaks, minor ai logic tweaks

This commit is contained in:
tmj-fstate
2020-04-02 01:08:35 +02:00
parent c22f4c900f
commit c417f388b1
13 changed files with 292 additions and 76 deletions

View File

@@ -245,6 +245,18 @@ enum sound {
removeadapter = 1 << 15,
};
// customizable reset button
enum relay_t {
maincircuitground = 1 << 0,
auxiliarycircuitground = 1 << 1,
tractionnmotoroverload = 1 << 2,
primaryconverteroverload = 1 << 3,
secondaryconverteroverload = 1 << 4,
ventillatoroverload = 1 << 5,
heatingoverload = 1 << 6,
electrodynamicbrakesoverload = 1 << 7,
};
//szczególne typy pojazdów (inna obsługa) dla zmiennej TrainType
//zamienione na flagi bitowe, aby szybko wybierać grupę (np. EZT+SZT)
// TODO: convert to enums, they're used as specific checks anyway
@@ -1042,6 +1054,7 @@ public:
TBrakePressure BrakePressureActual; //wartości ważone dla aktualnej pozycji kranu
int ASBType = 0; /*0: brak hamulca przeciwposlizgowego, 1: reczny, 2: automat*/
int UniversalBrakeButtonFlag[3] = { 0, 0, 0 }; /* mozliwe działania przycisków hamulcowych */
int UniversalResetButtonFlag[3] = { 0, 0, 0 }; // customizable reset buttons assignments
int TurboTest = 0;
double MaxBrakeForce = 0.0; /*maksymalna sila nacisku hamulca*/
double MaxBrakePress[5]; //pomocniczy, proz, sred, lad, pp
@@ -1453,6 +1466,7 @@ public:
bool AutoRelayFlag = false; /*mozna zmieniac jesli AutoRelayType=2*/
bool FuseFlag = false; /*!o bezpiecznik nadmiarowy*/
bool ConvOvldFlag = false; /*! nadmiarowy przetwornicy i ogrzewania*/
bool GroundRelay { true }; // switches off to protect against damage from earths
bool StLinFlag = false; /*!o styczniki liniowe*/
bool StLinSwitchOff{ false }; // state of the button forcing motor connectors open
bool ResistorsFlag = false; /*!o jazda rezystorowa*/
@@ -1560,6 +1574,7 @@ public:
int iLights[2]; // bity zapalonych świateł tutaj, żeby dało się liczyć pobór prądu
int AIHintPantstate{ 0 }; // suggested pantograph setup
bool AIHintPantUpIfIdle{ true }; // whether raise both pantographs if idling for a while
double AIHintLocalBrakeAccFactor{ 1.05 }; // suggested acceleration weight for local brake operation
public:
@@ -1706,11 +1721,13 @@ public:
bool CompartmentLightsSwitchOff( bool State, range_t const Notify = range_t::consist ); // compartment lights state toggle
bool MainSwitch( bool const State, range_t const Notify = range_t::consist );/*! wylacznik glowny*/
void MainSwitch_( bool const State );
bool MainSwitchCheck() const; // checks conditions for closing the line breaker
bool ConverterSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl przetwornicy*/
bool CompressorSwitch( bool State, range_t const Notify = range_t::consist );/*! wl/wyl sprezarki*/
bool ChangeCompressorPreset( int const Change, range_t const Notify = range_t::consist );
/*-funkcje typowe dla lokomotywy elektrycznej*/
void LowVoltagePowerCheck( double const Deltatime );
void MainsCheck( double const Deltatime );
void PowerCouplersCheck( double const Deltatime );
void ConverterCheck( double const Timestep ); // przetwornica
@@ -1722,9 +1739,11 @@ public:
void MotorBlowersCheck( double const Timestep );
void PantographsCheck( double const Timestep );
void LightsCheck( double const Timestep );
bool FuseOn(void); //bezpiecznik nadamiary
bool FuseOn( range_t const Notify = range_t::consist ); //bezpiecznik nadamiary
bool FuseFlagCheck(void) const; // sprawdzanie flagi nadmiarowego
void FuseOff(void); // wylaczenie nadmiarowego
bool UniversalResetButton( int const Button, range_t const Notify = range_t::consist );
bool RelayReset( int const Relays ); // resets specified relays
double ShowCurrent( int AmpN ) const; //pokazuje bezwgl. wartosc pradu na wybranym amperomierzu
double ShowCurrentP(int AmpN) const; //pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722

View File

@@ -1414,6 +1414,8 @@ void TMoverParameters::compute_movement_( double const Deltatime ) {
// TODO: gather and move current calculations to dedicated method
TotalCurrent = 0;
// low voltage power sources
LowVoltagePowerCheck( Deltatime );
// power sources
PantographsCheck( Deltatime );
// main circuit
@@ -1497,6 +1499,21 @@ void TMoverParameters::MainsCheck( double const Deltatime ) {
}
}
void TMoverParameters::LowVoltagePowerCheck( double const Deltatime ) {
auto const lowvoltagepower { Battery | ConverterFlag };
switch( EngineType ) {
case TEngineType::ElectricSeriesMotor: {
GroundRelay &= lowvoltagepower;
break;
}
default: {
break;
}
}
}
void TMoverParameters::PowerCouplersCheck( double const Deltatime ) {
// TODO: add support for other power sources
auto localvoltage { 0.0 };
@@ -3272,15 +3289,7 @@ void TMoverParameters::MainSwitch_( bool const State ) {
bool const initialstate { Mains || dizel_startup };
if( ( false == State )
|| ( ( ( ScndCtrlPos == 0 ) || ( EngineType == TEngineType::ElectricInductionMotor ) )
&& ( ( ConvOvldFlag == false ) || ( TrainType == dt_EZT ) )
&& ( MainsInitTimeCountdown <= 0.0 )
&& ( true == NoVoltRelay )
&& ( true == OvervoltageRelay )
&& ( LastSwitchingTime > CtrlDelay )
&& ( HasCamshaft ? IsMainCtrlActualNoPowerPos() : ( LineBreakerClosesAtNoPowerPosOnly ? IsMainCtrlNoPowerPos() : true ) )
&& ( false == TestFlag( DamageFlag, dtrain_out ) )
&& ( false == TestFlag( EngDmgFlag, 1 ) ) ) ) {
|| ( true == MainSwitchCheck() ) ) {
if( true == State ) {
// switch on
@@ -3312,6 +3321,21 @@ void TMoverParameters::MainSwitch_( bool const State ) {
}
}
bool TMoverParameters::MainSwitchCheck() const {
return (
( ( ScndCtrlPos == 0 ) || ( EngineType == TEngineType::ElectricInductionMotor ) )
&& ( MainsInitTimeCountdown <= 0.0 )
&& ( ( ConvOvldFlag == false ) || ( TrainType == dt_EZT ) )
&& ( true == GroundRelay )
&& ( true == NoVoltRelay )
&& ( true == OvervoltageRelay )
&& ( LastSwitchingTime > CtrlDelay )
&& ( HasCamshaft ? IsMainCtrlActualNoPowerPos() : ( LineBreakerClosesAtNoPowerPosOnly ? IsMainCtrlNoPowerPos() : true ) )
&& ( false == TestFlag( DamageFlag, dtrain_out ) )
&& ( false == TestFlag( EngDmgFlag, 1 ) ) );
}
// *************************************************************************************************
// Q: 20160713
// włączenie / wyłączenie przetwornicy
@@ -6021,21 +6045,21 @@ bool TMoverParameters::FuseFlagCheck(void) const
// Q: 20160713
// Załączenie bezpiecznika nadmiarowego
// *************************************************************************************************
bool TMoverParameters::FuseOn(void)
bool TMoverParameters::FuseOn( range_t const Notify )
{
bool FO = false;
if ((IsMainCtrlNoPowerPos()) && (ScndCtrlPos == 0) && (TrainType != dt_ET40) &&
((Mains) || (TrainType != dt_EZT)) && (!TestFlag(EngDmgFlag, 1)))
{ // w ET40 jest blokada nastawnika, ale czy działa dobrze?
SendCtrlToNext("FuseSwitch", 1, CabActive);
if (((EngineType == TEngineType::ElectricSeriesMotor) || ((EngineType == TEngineType::DieselElectric))) && FuseFlag)
{
FuseFlag = false; // wlaczenie ponowne obwodu
FO = true;
SetFlag(SoundFlag, sound::relay | sound::loud);
}
bool const result { RelayReset( relay_t::maincircuitground | relay_t::tractionnmotoroverload ) };
if( Notify != range_t::local ) {
SendCtrlToNext(
"FuseSwitch",
1,
CabActive,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
}
return FO;
return result;
}
// *************************************************************************************************
@@ -6052,6 +6076,81 @@ void TMoverParameters::FuseOff(void)
}
}
// resets relays assigned to specified customizable reset button
bool TMoverParameters::UniversalResetButton( int const Button, range_t const Notify ) {
auto const lowvoltagepower { Battery || ConverterFlag };
if( false == lowvoltagepower ) { return false; }
auto const relays { UniversalResetButtonFlag[ Button ] };
if( relays == 0 ) { return false; }
auto const result { RelayReset( relays ) };
if( Notify != range_t::local ) {
SendCtrlToNext(
"RelayReset",
relays,
CabActive,
( Notify == range_t::unit ?
coupling::control | coupling::permanent :
coupling::control ) );
}
return result;
}
// resets state of specified relays
bool TMoverParameters::RelayReset( int const Relays ) {
auto const lowvoltagepower { Battery || ConverterFlag };
bool reset { false };
if( TestFlag( Relays, relay_t::maincircuitground ) ) {
if( ( ( EngineType == TEngineType::ElectricSeriesMotor ) || ( EngineType == TEngineType::DieselElectric ) )
&& ( IsMainCtrlNoPowerPos() )
&& ( ScndCtrlPos == 0 )
&& ( DirActive != 0 )
&& ( !TestFlag( EngDmgFlag, 1 ) ) ) {
// NOTE: true means the relay is operational
reset |= ( !GroundRelay && lowvoltagepower );
GroundRelay |= lowvoltagepower;
}
}
if( TestFlag( Relays, relay_t::tractionnmotoroverload ) ) {
if( ( ( EngineType == TEngineType::ElectricSeriesMotor ) || ( EngineType == TEngineType::DieselElectric ) )
&& ( IsMainCtrlNoPowerPos() )
&& ( ScndCtrlPos == 0 )
&& ( DirActive != 0 )
&& ( !TestFlag( EngDmgFlag, 1 ) ) ) {
// NOTE: false means the relay is operational
// TODO: cleanup, flip the FuseFlag code to match other relays
// TODO: check whether the power is required, TBD, TODO: make it configurable?
reset |= ( FuseFlag && lowvoltagepower );
FuseFlag &= !lowvoltagepower;
}
}
if( TestFlag( Relays, relay_t::primaryconverteroverload ) ) {
if( ( false == Mains )
&& ( false == ConverterAllow )
&& ( TrainType != dt_EZT ) ) { // for EMUs the relay is reset automatically when converter switches off
// NOTE: false means the relay is operational
// TODO: cleanup, flip the FuseFlag code to match other relays
// TODO: check whether the power is required, TBD, TODO: make it configurable?
reset |= ( ConvOvldFlag && lowvoltagepower );
ConvOvldFlag &= !lowvoltagepower;
}
}
if( reset ) {
SetFlag( SoundFlag, sound::relay | sound::loud );
}
return reset;
}
// *************************************************************************************************
// Q: 20160713
// Przeliczenie prędkości liniowej na obrotową
@@ -9854,7 +9953,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
CompartmentLights.start_type =
lookup != starts.end() ?
lookup->second :
start_t::automatic;
start_t::automatic; // legacy behaviour
}
}
@@ -10217,6 +10316,10 @@ void TMoverParameters::LoadFIZ_Switches( std::string const &Input ) {
PantSwitchType = ToLower( PantSwitchType );
ConvSwitchType = ToLower( ConvSwitchType );
StLinSwitchType = ToLower( StLinSwitchType );
// universal reset buttons assignments
extract_value( UniversalResetButtonFlag[ 0 ], "RelayResetButton1", Input, "" );
extract_value( UniversalResetButtonFlag[ 1 ], "RelayResetButton2", Input, "" );
extract_value( UniversalResetButtonFlag[ 2 ], "RelayResetButton3", Input, "" );
}
void TMoverParameters::LoadFIZ_MotorParamTable( std::string const &Input ) {
@@ -10260,6 +10363,7 @@ void TMoverParameters::LoadFIZ_Circuit( std::string const &Input ) {
void TMoverParameters::LoadFIZ_AI( std::string const &Input ) {
extract_value( AIHintPantstate, "Pantstate", Input, "" );
extract_value( AIHintPantUpIfIdle, "IdlePantUp", Input, "" );
extract_value( AIHintLocalBrakeAccFactor, "LocalBrakeAccFactor", Input, "" );
}
@@ -10751,6 +10855,8 @@ bool TMoverParameters::CheckLocomotiveParameters(bool ReadyFlag, int Dir)
DirActive = 0; // Dir; //nastawnik kierunkowy - musi być ustawiane osobno!
DirAbsolute = DirActive * CabActive; // kierunek jazdy względem sprzęgów
LimPipePress = CntrlPipePress;
Battery = true;
}
else { // zahamowany}
WriteLog( "Braked" );
@@ -11208,14 +11314,7 @@ bool TMoverParameters::RunCommand( std::string Command, double CValue1, double C
}
else if (Command == "FuseSwitch")
{
if (((EngineType == TEngineType::ElectricSeriesMotor) || (EngineType == TEngineType::DieselElectric)) && FuseFlag &&
(CValue1 == 1) && (MainCtrlActualPos == 0) && (ScndCtrlActualPos == 0) && Mains)
/* if (EngineType=ElectricSeriesMotor) and (CValue1=1) and
(MainCtrlActualPos=0) and (ScndCtrlActualPos=0) and Mains then*/
FuseFlag = false; /*wlaczenie ponowne obwodu*/
// if ((EngineType=ElectricSeriesMotor)or(EngineType=DieselElectric)) and not FuseFlag and
// (CValue1=0) and Mains then
// FuseFlag:=true;
FuseOn( range_t::local );
OK = SendCtrlToNext( Command, CValue1, CValue2, Couplertype );
}
else if (Command == "ConverterSwitch") /*NBMX*/