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

Merge remote-tracking branch 'youby/master' into sim

This commit is contained in:
milek7
2020-11-16 23:17:37 +01:00
11 changed files with 364 additions and 44 deletions

View File

@@ -779,6 +779,16 @@ struct speed_control {
double PowerDownSpeed = 1000;
};
struct inverter {
double Freal = 0.0;
double Request = 0.0;
bool IsActive = true;
bool Activate = true;
bool Error = false;
bool Failure_Drive = false;
bool Failure_Const = false;
};
class TMoverParameters
{ // Ra: wrapper na kod pascalowy, przejmujący jego funkcje Q: 20160824 - juz nie wrapper a klasa bazowa :)
private:
@@ -1121,6 +1131,11 @@ public:
double Spg = 0.0;
double MinCompressor = 0.0;
double MaxCompressor = 0.0;
double MinCompressor_cabA = 0.0;
double MaxCompressor_cabA = 0.0;
double MinCompressor_cabB = 0.0;
double MaxCompressor_cabB = 0.0;
bool CabDependentCompressor = false;
double CompressorSpeed = 0.0;
int CompressorList[4][9]; // pozycje świateł, przód - tył, 1 .. 16
double EmergencyValveOn = 0.0;
@@ -1149,6 +1164,9 @@ public:
bool MBrake = false; /*Czy jest hamulec reczny*/
double StopBrakeDecc = 0.0;
bool ReleaseParkingBySpringBrake { false };
bool ReleaseParkingBySpringBrakeWhenDoorIsOpen{ false };
bool SpringBrakeCutsOffDrive { true };
double SpringBrakeDriveEmergencyVel { -1 };
TSecuritySystem SecuritySystem;
int EmergencyBrakeWarningSignal{ 0 }; // combined with basic WarningSignal when manual emergency brake is active
TUniversalCtrlTable UniCtrlList; /*lista pozycji uniwersalnego nastawnika*/
@@ -1279,6 +1297,9 @@ public:
bool EIMCLogForce = false; //
static std::vector<std::string> const eimc_labels;
double InverterFrequency { 0.0 }; // current frequency of power inverters
int InvertersNo = 0; // number of inverters
double InvertersRatio = 0.0;
std::vector<inverter> Inverters; //all inverters
/* -dla pojazdów z blendingiem EP/ED (MED) */
double MED_Vmax = 0; // predkosc maksymalna dla obliczen chwilowej sily hamowania EP w MED
double MED_Vmin = 0; // predkosc minimalna dla obliczen chwilowej sily hamowania EP w MED

View File

@@ -3891,7 +3891,7 @@ bool TMoverParameters::SwitchEPBrake(int state)
if ((BrakeHandle == TBrakeHandle::St113) && (CabOccupied != 0))
{
if (state > 0)
temp = Handle->GetCP(); // TODO: przetlumaczyc
temp = Handle->GetEP(); // TODO: przetlumaczyc
else
temp = 0;
Hamulec->SetEPS(temp);
@@ -4060,6 +4060,20 @@ void TMoverParameters::CompressorCheck(double dt) {
return;
}
if (CabDependentCompressor)
{
if (CabActive > 0)
{
MinCompressor = MinCompressor_cabA;
MaxCompressor = MaxCompressor_cabA;
}
if (CabActive < 0)
{
MinCompressor = MinCompressor_cabB;
MaxCompressor = MaxCompressor_cabB;
}
}
//EmergencyValve
EmergencyValveOpen = (Compressor > (EmergencyValveOpen ? EmergencyValveOff : EmergencyValveOn));
if (EmergencyValveOpen) {
@@ -4300,7 +4314,10 @@ void TMoverParameters::UpdatePipePressure(double dt)
|| ( true == AlarmChainFlag )
|| (( true == EIMCtrlEmergency)
&& (LocalBrakePosA >= 1.0))
|| SecuritySystem.is_braking()))
|| SecuritySystem.is_braking())
|| ( ( SpringBrakeDriveEmergencyVel >= 0 )
&& ( Vel > SpringBrakeDriveEmergencyVel )
&& ( SpringBrake.IsActive ) ) )
/*
// NOTE: disabled because 32 is 'load destroyed' flag, what does this have to do with emergency brake?
// (if it's supposed to be broken coupler, such event sets alarmchainflag instead when appropriate)
@@ -4431,7 +4448,7 @@ void TMoverParameters::UpdatePipePressure(double dt)
&& (DirActive != 0)
&& (EpFuse)) // tu powinien byc jeszcze bezpiecznik EP i baterie -
// temp = (Handle as TFVel6).GetCP
temp = Handle->GetCP();
temp = Handle->GetEP();
else
temp = 0.0;
@@ -4756,7 +4773,7 @@ void TMoverParameters::ComputeTotalForce(double dt) {
if( false == PhysicActivation ) { return; }
// juz zoptymalizowane:
FStand = FrictionForce(); // siła oporów ruchu
FStand = FrictionForce(); // siła oporów ruchu
if( true == TestFlag( DamageFlag, dtrain_out ) ) {
// HACK: crude way to reduce speed after derailment
// TBD, TODO: more accurate approach?
@@ -4807,6 +4824,11 @@ void TMoverParameters::ComputeTotalForce(double dt) {
Power > 0 ?
TractionForce( dt ) :
0 );
double FT_factor = 1.0;
if (EngineType == TEngineType::ElectricInductionMotor && InvertersRatio > 0.0) {
FT_factor = 1.0 / InvertersRatio;
FTrain *= FT_factor;
}
Fb = BrakeForce(RunningTrack);
// poslizg
@@ -4861,6 +4883,7 @@ void TMoverParameters::ComputeTotalForce(double dt) {
FStand += Fb;
// doliczenie składowej stycznej grawitacji
FTrain /= FT_factor;
FTrain += TotalMassxg * RunningShape.dHtrack;
//!niejawne przypisanie zmiennej!
FTotal = FTrain - Sign(V) * FStand;
@@ -5924,7 +5947,13 @@ double TMoverParameters::TractionForce( double dt ) {
case TEngineType::ElectricInductionMotor:
{
if( true == Mains && !SecuritySystem.is_engine_blocked() ) {
if( true == Mains && !SecuritySystem.is_engine_blocked() ) {
double ActiveInverters = 0.0;
for (auto &inv : Inverters) {
if (inv.IsActive)
ActiveInverters += 1.0;
}
InvertersRatio = ActiveInverters / (double)InvertersNo;
//tempomat
if (ScndCtrlPosNo == 4 && SpeedCtrlTypeTime)
{
@@ -6020,7 +6049,7 @@ double TMoverParameters::TractionForce( double dt ) {
PosRatio *= 0.9;
Hamulec->SetED(Max0R(0.0, std::min(PosRatio, 1.0))); //ustalenie stopnia zmniejszenia ciśnienia
// ustalanie siły hamowania ED
if ((Hamulec->GetEDBCP() > 0.25) && (eimc[eimc_p_abed] < 0.001)) //jeśli PN wyłącza ED
if ((Hamulec->GetEDBCP() > 0.25) && (eimc[eimc_p_abed] < 0.001) || (ActiveInverters < InvertersNo)) //jeśli PN wyłącza ED
{
PosRatio = 0;
eimv[eimv_Fzad] = 0;
@@ -6066,6 +6095,11 @@ double TMoverParameters::TractionForce( double dt ) {
// switch sandbox off
SandboxAuto( false, range_t::unit );
}
if (ActiveInverters == 0.0)
{
PosRatio = 0;
eimv_pr = 0;
}
eimv_pr += Max0R(Min0R(PosRatio - eimv_pr, 0.02), -0.02) * 12 *
(tmp /*2{+4*byte(PosRatio<eimv_pr)*/) *
@@ -6116,6 +6150,8 @@ double TMoverParameters::TractionForce( double dt ) {
-Sign(V) * (DirAbsolute)*std::min(
eimc[eimc_p_Ph] * 3.6 / (Vel != 0.0 ? Vel : 0.001),
std::min(-eimc[eimc_p_Fh] * pr, eimv[eimv_FMAXMAX]));
if (InvertersRatio < 1.0)
eimv[eimv_Fful] = 0;
//*Min0R(1,(Vel-eimc[eimc_p_Vh0])/(eimc[eimc_p_Vh1]-eimc[eimc_p_Vh0]))
}
else
@@ -6132,7 +6168,11 @@ double TMoverParameters::TractionForce( double dt ) {
pr = log(1 + 4 * pr) / log(5);
eimv[eimv_Fr] = eimv[eimv_Fful] * pr;
}
for (auto &inv : Inverters) {
inv.Request = inv.IsActive ? eimv_pr : 0.0;
inv.Error = inv.Failure_Const || (inv.Failure_Drive && inv.Request != 0);
inv.IsActive = inv.Activate && !inv.Error;
}
eimv[eimv_ks] = eimv[eimv_Fr] / eimv[eimv_FMAXMAX];
eimv[eimv_df] = eimv[eimv_ks] * eimc[eimc_s_dfmax];
eimv[eimv_fp] = DirAbsolute * enrot * eimc[eimc_s_p] + eimv[eimv_df]; // do przemyslenia dzialanie pp z tmpV
@@ -6146,8 +6186,8 @@ double TMoverParameters::TractionForce( double dt ) {
eimv[eimv_Ic] = (eimv[eimv_fp] - DirAbsolute * enrot * eimc[eimc_s_p]) * eimc[eimc_s_dfic] * eimv[eimv_pole];
eimv[eimv_If] = eimv[eimv_Ic] * eimc[eimc_s_icif];
eimv[eimv_M] = eimv[eimv_pole] * eimv[eimv_Ic] * eimc[eimc_s_cim];
eimv[eimv_Ipoj] = (eimv[eimv_Ic] * NPoweredAxles * eimv[eimv_U]) / (EngineVoltage - eimc[eimc_f_DU]) + eimc[eimc_f_I0];
eimv[eimv_Pm] = DirActive * eimv[eimv_M] * NPoweredAxles * enrot * Pirazy2 / 1000;
eimv[eimv_Ipoj] = (eimv[eimv_Ic] * NPoweredAxles * InvertersRatio * eimv[eimv_U]) / (EngineVoltage - eimc[eimc_f_DU]) + eimc[eimc_f_I0];
eimv[eimv_Pm] = DirActive * eimv[eimv_M] * NPoweredAxles * InvertersRatio * enrot * Pirazy2 / 1000;
eimv[eimv_Pe] = eimv[eimv_Ipoj] * EngineVoltage / 1000;
eimv[eimv_eta] = eimv[eimv_Pm] / eimv[eimv_Pe];
@@ -6188,11 +6228,15 @@ double TMoverParameters::TractionForce( double dt ) {
Mm = eimv[eimv_M] * DirAbsolute;
Mw = Mm * Transmision.Ratio * Transmision.Efficiency;
Fw = Mw * 2.0 / WheelDiameter;
Ft = Fw * NPoweredAxles;
Ft = Fw * NPoweredAxles * InvertersRatio;
eimv[eimv_Fr] = DirAbsolute * Ft / 1000;
} // mains
else
{
for (auto &inv : Inverters) {
inv.Freal = 0.0;
inv.IsActive = false;
}
Im = 0.0;
Mm = 0.0;
Mw = 0.0;
@@ -7080,11 +7124,27 @@ void TMoverParameters::CheckEIMIC(double dt)
auto const eimicpowerenabled {
( ( true == Mains ) || ( Power == 0.0 ) )
&& ( ( Doors.instances[ side::left ].open_permit == false )
&& ( Doors.instances[ side::right ].open_permit == false ) )
&& ( !SpringBrake.IsActive )
&& ( !SpringBrake.IsActive || !SpringBrakeCutsOffDrive )
&& ( !LockPipe ) };
eimic = clamp(eimic, -1.0, eimicpowerenabled ? 1.0 : 0.0);
auto const eimicdoorenabled {
(SpringBrake.IsActive && ReleaseParkingBySpringBrakeWhenDoorIsOpen)
};
double eimic_max = 0.0;
if ((Doors.instances[side::left].open_permit == false)
&& (Doors.instances[side::right].open_permit == false)) {
if (eimicpowerenabled) {
eimic_max = 1.0;
}
else {
eimic_max = 0.001;
}
}
else {
if (eimicdoorenabled) {
eimic_max = 0.001;
}
}
eimic = clamp(eimic, -1.0, eimicpowerenabled ? eimic_max : 0.0);
}
void TMoverParameters::CheckSpeedCtrl(double dt)
@@ -9769,6 +9829,8 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
*/
extract_value( MinCompressor, "MinCP", line, "" );
extract_value( MaxCompressor, "MaxCP", line, "" );
extract_value( MinCompressor, "MinCP_B", line, "" );
extract_value( MaxCompressor, "MaxCP_B", line, "" );
extract_value( CompressorTankValve, "CompressorTankValve", line, "" );
extract_value( CompressorSpeed, "CompressorSpeed", line, "" );
extract_value( EmergencyValveOff, "MinEVP", line, "" );
@@ -9805,6 +9867,22 @@ void TMoverParameters::LoadFIZ_Brake( std::string const &line ) {
extract_value(
ReleaserEnabledOnlyAtNoPowerPos, "ReleaserPowerPosLock", line,
( ( EngineType == TEngineType::DieselEngine ) || ( EngineType == TEngineType::DieselElectric ) ) ? "yes" : "no" );
if (MinCompressor_cabB > 0.0) {
MinCompressor_cabA = MinCompressor;
CabDependentCompressor = true;
}
else {
MinCompressor_cabB = MinCompressor;
}
if (MaxCompressor_cabB > 0.0)
{
MaxCompressor_cabA = MaxCompressor;
CabDependentCompressor = true;
}
else {
MaxCompressor_cabB = MaxCompressor;
}
}
void TMoverParameters::LoadFIZ_Doors( std::string const &line ) {
@@ -10038,6 +10116,7 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
{
std::map<std::string, int> brakeopmodes{
{ "PN", bom_PS + bom_PN },
{ "PNEP", bom_PS + bom_PN + bom_EP },
{ "PNEPMED", bom_PS + bom_PN + bom_EP + bom_MED }
};
auto lookup = brakeopmodes.find( extract_value( "BrakeOpModes", line ) );
@@ -10173,6 +10252,9 @@ void TMoverParameters::LoadFIZ_Cntrl( std::string const &line ) {
extract_value( StopBrakeDecc, "SBD", line, "" );
extract_value( ReleaseParkingBySpringBrake, "ReleaseParkingBySpringBrake", line, "" );
extract_value( ReleaseParkingBySpringBrakeWhenDoorIsOpen, "ReleaseParkingBySpringBrakeWhenDoorIsOpen", line, "" );
extract_value( SpringBrakeCutsOffDrive, "SpringBrakeCutsOffDrive", line, "");
extract_value( SpringBrakeDriveEmergencyVel, "SpringBrakeDriveEmergencyVel", line, "");
std::map<std::string, start_t> starts {
{ "Disabled", start_t::disabled },
@@ -10595,8 +10677,19 @@ void TMoverParameters::LoadFIZ_Engine( std::string const &Input ) {
extract_value( eimc[ eimc_p_abed ], "abed", Input, "" );
extract_value( eimc[ eimc_p_eped ], "edep", Input, "" );
extract_value( EIMCLogForce, "eimclf", Input, "" );
extract_value( InvertersNo, "InvNo", Input, "");
extract_value( Flat, "Flat", Input, "");
if (eimc[eimc_p_Pmax] > 0 && Power > 0 && InvertersNo == 0) {
InvertersNo = 1;
}
Inverters.resize(InvertersNo);
/*for (int i = 0; i > InvertersNo; i++)
{
inverter x;
Inverters.emplace_back(x);
}*/
break;
}
default: {

View File

@@ -2282,6 +2282,11 @@ double TDriverHandle::GetCP()
return 0;
}
double TDriverHandle::GetEP()
{
return 0;
}
double TDriverHandle::GetSound(int i)
{
return 0;
@@ -2814,8 +2819,8 @@ double TMHZ_K5P::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
void TMHZ_K5P::Init(double Press)
{
CP = Press;
Time = true;
TimeEP = true;
Time = true;
TimeEP = true;
}
void TMHZ_K5P::SetReductor(double nAdj)
@@ -3133,6 +3138,8 @@ double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double ActFlowSpeed;
int BCP;
CP = PP;
BCP = lround(i_bcp);
EPS = BEP_K[BCP];
@@ -3169,7 +3176,12 @@ double TSt113::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double TSt113::GetCP()
{
return EPS;
return CP;
}
double TSt113::GetEP()
{
return EPS;
}
double TSt113::GetPos(int i)
@@ -3301,6 +3313,8 @@ double TFVel6::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double dpMainValve;
double ActFlowSpeed;
CP = PP;
LimPP = Min0R(5 * int(i_bcp < 3.5), HP);
if ((i_bcp >= 3.5) && ((i_bcp < 4.3) || (i_bcp > 5.5)))
ActFlowSpeed = 0;
@@ -3334,7 +3348,12 @@ double TFVel6::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double TFVel6::GetCP()
{
return EPS;
return CP;
}
double TFVel6::GetEP()
{
return EPS;
}
double TFVel6::GetPos(int i)
@@ -3366,6 +3385,8 @@ double TFVE408::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
double dpMainValve;
double ActFlowSpeed;
CP = PP;
LimPP = Min0R(5 * int(i_bcp < 6.5), HP);
if ((i_bcp >= 6.5) && ((i_bcp < 7.5) || (i_bcp > 9.5)))
ActFlowSpeed = 0;
@@ -3398,6 +3419,11 @@ double TFVE408::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
}
double TFVE408::GetCP()
{
return CP;
}
double TFVE408::GetEP()
{
return EPS;
}

View File

@@ -541,6 +541,7 @@ class TDriverHandle {
virtual double GetPF(double i_bcp, double PP, double HP, double dt, double ep);
virtual void Init(double Press);
virtual double GetCP();
virtual double GetEP();
virtual void SetReductor(double nAdj); //korekcja pozycji reduktora cisnienia
virtual double GetSound(int i); //pobranie glosnosci wybranego dzwieku
virtual double GetPos(int i); //pobranie numeru pozycji o zadanym kodzie (funkcji)
@@ -617,7 +618,7 @@ class TMHZ_EN57 : public TDriverHandle {
double GetSound(int i)/*override*/;
double GetPos(int i)/*override*/;
double GetCP()/*override*/;
double GetEP(double pos);
double GetEP(double pos);
void SetParams(bool AO, bool MO, double OverP, double, double OMP, double OPD);
inline TMHZ_EN57(void) :
TDriverHandle()
@@ -762,10 +763,11 @@ class TSt113 : public TH14K1 {
static double const BPT_K[/*?*/ /*-1..4*/ (4) - (-1) + 1][2];
static double const BEP_K[/*?*/ /*-1..5*/ (5) - (-1) + 1];
static double const pos_table[11]; // = {-1, 5, -1, 0, 2, 3, 4, 5, 0, 0, 1};
double CP = 0;
public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
double GetCP()/*override*/;
double GetEP()/*override*/;
double GetPos(int i)/*override*/;
void Init(double Press)/*override*/;
@@ -830,10 +832,12 @@ class TFVel6 : public TDriverHandle {
private:
double EPS = 0.0;
static double const pos_table[ 11 ]; // = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1};
double CP = 0.0;
public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
double GetCP()/*override*/;
double GetEP()/*override*/;
double GetPos(int i)/*override*/;
double GetSound(int i)/*override*/;
void Init(double Press)/*override*/;
@@ -848,10 +852,12 @@ class TFVE408 : public TDriverHandle {
private:
double EPS = 0.0;
static double const pos_table[11]; // = {-1, 6, -1, 0, 6, 4, 4.7, 5, -1, 0, 1};
double CP = 0.0;
public:
double GetPF(double i_bcp, double PP, double HP, double dt, double ep)/*override*/;
double GetCP()/*override*/;
double GetEP()/*override*/;
double GetPos(int i)/*override*/;
double GetSound(int i)/*override*/;
void Init(double Press)/*override*/;