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

completed .fiz file loader; minor parser enhancement, wheel slip and schedule loader bug fixes.

This commit is contained in:
tmj-fstate
2017-02-08 03:13:04 +01:00
parent fdb95d3b63
commit adeaa5fc79
9 changed files with 1460 additions and 1651 deletions

View File

@@ -543,8 +543,6 @@ struct TTransmision
enum TCouplerType { NoCoupler, Articulated, Bare, Chain, Screw, Automatic };
//class TMoverParameters; // wyforwardowanie klasy coby typ byl widoczny w ponizszej strukturze
struct TCoupling {
/*parametry*/
double SpringKB = 1.0; /*stala sprezystosci zderzaka/sprzegu, %tlumiennosci */
@@ -673,7 +671,7 @@ public:
int MainCtrlPosNo = 0; /*ilosc pozycji nastawnika*/
int ScndCtrlPosNo = 0;
int LightsPosNo = 0; // NOTE: values higher than 0 seem to break the current code for light switches
int LightsDefPos = 0;
int LightsDefPos = 1;
bool LightsWrap = false;
int Lights[2][17]; // pozycje świateł, przód - tył, 1 .. 16
bool ScndInMain = false; /*zaleznosc bocznika od nastawnika*/
@@ -748,7 +746,7 @@ public:
/*- dla lokomotyw z silnikami indukcyjnymi -*/
double eimc[26];
/*-dla wagonow*/
long MaxLoad = 0.0; /*masa w T lub ilosc w sztukach - ladownosc*/
double MaxLoad = 0.0; /*masa w T lub ilosc w sztukach - ladownosc*/
std::string LoadAccepted; std::string LoadQuantity; /*co moze byc zaladowane, jednostki miary*/
double OverLoadFactor = 0.0; /*ile razy moze byc przekroczona ladownosc*/
double LoadSpeed = 0.0; double UnLoadSpeed = 0.0;/*szybkosc na- i rozladunku jednostki/s*/
@@ -907,7 +905,7 @@ public:
double eAngle = 1.5;
/*-dla wagonow*/
long Load = 0.0; /*masa w T lub ilosc w sztukach - zaladowane*/
double Load = 0.0; /*masa w T lub ilosc w sztukach - zaladowane*/
std::string LoadType; /*co jest zaladowane*/
int LoadStatus = 0; //+1=trwa rozladunek,+2=trwa zaladunek,+4=zakończono,0=zaktualizowany model
double LastLoadChangeTime = 0.0; //raz (roz)ładowania
@@ -1066,8 +1064,8 @@ public:
bool FuseOn(void); //bezpiecznik nadamiary
bool FuseFlagCheck(void); // sprawdzanie flagi nadmiarowego
void FuseOff(void); // wylaczenie nadmiarowego
int ShowCurrent(int AmpN); //pokazuje bezwgl. wartosc pradu na wybranym amperomierzu
int ShowCurrentP(int AmpN); //pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722
double ShowCurrent( int AmpN ); //pokazuje bezwgl. wartosc pradu na wybranym amperomierzu
double ShowCurrentP(int AmpN); //pokazuje bezwgl. wartosc pradu w wybranym pojezdzie //Q 20160722
/*!o pokazuje bezwgl. wartosc obrotow na obrotomierzu jednego z 3 pojazdow*/
/*function ShowEngineRotation(VehN:int): integer; //Ra 2014-06: przeniesione do C++*/
@@ -1107,28 +1105,46 @@ public:
/*funkcje ladujace pliki opisujace pojazd*/
bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath);
bool CheckLocomotiveParameters( bool ReadyFlag, int Dir );
std::string EngineDescription( int what );
private:
void LoadFIZ_Param( std::string const &line );
void LoadFIZ_Load( std::string const &line );
void LoadFIZ_Dimensions( std::string const &line );
void LoadFIZ_Wheels( std::string const &line );
void LoadFIZ_Brake( std::string const &line );
void LoadFIZ_BuffCoupl( std::string const &line, int const Index );
void LoadFIZ_Doors( std::string const &line );
void LoadFIZ_BuffCoupl( std::string const &line, int const Index );
void LoadFIZ_TurboPos( std::string const &line );
void LoadFIZ_Cntrl( std::string const &line );
void LoadFIZ_Light( std::string const &line );
void LoadFIZ_Security( std::string const &line );
void LoadFIZ_Clima( std::string const &line );
void LoadFIZ_Power( std::string const &Line );
void LoadFIZ_Engine( std::string const &Input );
void LoadFIZ_Switches( std::string const &Input );
void LoadFIZ_MotorParamTable( std::string const &Input );
void LoadFIZ_Circuit( std::string const &Input );
void LoadFIZ_RList( std::string const &Input );
void LoadFIZ_DList( std::string const &Input );
void LoadFIZ_LightsList( std::string const &Input );
void LoadFIZ_PowerParamsDecode( TPowerParameters &Powerparameters, std::string const Prefix, std::string const &Input );
TPowerType LoadFIZ_PowerDecode( std::string const &Power );
TPowerSource LoadFIZ_SourceDecode( std::string const &Source );
TEngineTypes LoadFIZ_EngineDecode( std::string const &Engine );
bool readMPT0( std::string const &line );
bool readMPT( std::string const &line ); //Q 20160717
bool readMPTElectricSeries( std::string const &line );
bool readMPTDieselElectric( std::string const &line );
bool readMPTDieselEngine( std::string const &line );
bool readRList(int const ln, std::string const &line); //Q 20160718
bool readBPT(/*int const ln,*/ std::string const &line); //Q 20160721
bool readRList( std::string const &Input );
bool readDList( std::string const &line );
bool readFFList( std::string const &line );
bool readWWList( std::string const &line );
bool readLightsList( std::string const &Input );
void BrakeValveDecode( std::string const &s ); //Q 20160719
void BrakeSubsystemDecode(); //Q 20160719
void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719
TPowerSource PowerSourceDecode(std::string s); //Q 20160719
TPowerType PowerDecode(std::string s); //Q 20160719
TEngineTypes EngineDecode(std::string s); //Q 20160721
bool CheckLocomotiveParameters(bool ReadyFlag, int Dir);
std::string EngineDescription(int what);
};
extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimension Dim2);
@@ -1136,16 +1152,7 @@ extern double Distance(TLocation Loc1, TLocation Loc2, TDimension Dim1, TDimensi
template <typename _Type>
bool getkeyval( _Type &Variable, std::string const &Key, std::string const &Input, std::string const &Default ) {
std::string value;
auto lookup = Input.find( Key + "=" );
if( lookup != std::string::npos ) {
value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
lookup = value.find( ' ' );
if( lookup != std::string::npos ) {
// trim everything past the value
value.erase( lookup );
}
}
auto value = extract_value( Key, Input );
if( false == value.empty() ) {
// set the specified variable to retrieved value
std::stringstream converter;
@@ -1162,4 +1169,21 @@ bool getkeyval( _Type &Variable, std::string const &Key, std::string const &Inpu
}
return false; // supplied the default
}
}
inline
std::string
extract_value( std::string const &Key, std::string const &Input ) {
std::string value;
auto lookup = Input.find( Key + "=" );
if( lookup != std::string::npos ) {
value = Input.substr( Input.find_first_not_of( ' ', lookup + Key.size() + 1 ) );
lookup = value.find( ' ' );
if( lookup != std::string::npos ) {
// trim everything past the value
value.erase( lookup );
}
}
return value;
}

File diff suppressed because it is too large Load Diff

View File

@@ -51,16 +51,16 @@ double PF_old(double P1, double P2, double S)
double PF(double P1, double P2, double S, double DP)
{
double PH = Max0R(P1, P2) + 1; // wyzsze cisnienie absolutne
double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne
double sg = PL / PH; // bezwymiarowy stosunek cisnien
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
if ((PH - PL) < DP) // niewielka roznica cisnien
return (1 - sg) / DPL * FM * 2 * sqrt((DP) * (PH - DP));
return (1 - sg) / DPL * FM * 2 * std::sqrt((DP) * (PH - DP));
// return 1/DPL*(PH-PL)*fm*2*SQRT((sg)*(1-sg));
else
return FM * 2 * sqrt((sg) * (1 - sg));
return FM * 2 * std::sqrt((sg) * (1 - sg));
else // powyzej stosunku krytycznego
return FM;
}
@@ -69,15 +69,15 @@ double PF1(double P1, double P2, double S)
{
static double const DPS = 0.001;
double PH = Max0R(P1, P2) + 1; // wyzsze cisnienie absolutne
double PH = std::max(P1, P2) + 1; // wyzsze cisnienie absolutne
double PL = P1 + P2 - PH + 2; // nizsze cisnienie absolutne
double sg = PL / PH; // bezwymiarowy stosunek cisnien
double FM = PH * 197 * S * Sign(P2 - P1); // najwyzszy mozliwy przeplyw, wraz z kierunkiem
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
if ((sg < DPS)) // niewielka roznica cisnien
return (1 - sg) / DPS * FM * 2 * sqrt((DPS) * (1 - DPS));
return (1 - sg) / DPS * FM * 2 * std::sqrt((DPS) * (1 - DPS));
else
return FM * 2 * sqrt((sg) * (1 - sg));
return FM * 2 * std::sqrt((sg) * (1 - sg));
else // powyzej stosunku krytycznego
return FM;
}
@@ -96,9 +96,9 @@ double PFVa(double PH, double PL, double S, double LIM,
FM = FM * (LIM - PL) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
if ((PH - PL) < DPL) // niewielka roznica cisnien
return (PH - PL) / DPL * FM * 2 * sqrt((sg) * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
return (PH - PL) / DPL * FM * 2 * std::sqrt((sg) * (1 - sg)); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
else
return FM * 2 * sqrt( (sg) * ( 1 - sg ) ); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
return FM * 2 * std::sqrt( (sg) * ( 1 - sg ) ); // BUG: (1-sg) can be < 0, leading to sqrt(-x)
else // powyzej stosunku krytycznego
return FM;
}
@@ -120,9 +120,9 @@ double PFVd(double PH, double PL, double S, double LIM,
FM = FM * (PH - LIM) / DP; // jesli jestesmy przy nastawieniu, to zawor sie przymyka
if ((sg > 0.5)) // jesli ponizej stosunku krytycznego
if ((PH - PL) < DPL) // niewielka roznica cisnien
return (PH - PL) / DPL * FM * 2 * sqrt((sg) * (1 - sg));
return (PH - PL) / DPL * FM * 2 * std::sqrt((sg) * (1 - sg));
else
return FM * 2 * sqrt((sg) * (1 - sg));
return FM * 2 * std::sqrt((sg) * (1 - sg));
else // powyzej stosunku krytycznego
return FM;
}
@@ -2749,8 +2749,8 @@ double TFD1::GetPF(double i_bcp, double PP, double HP, double dt, double ep)
// MaxBP:=4;
// temp:=Min0R(i_bcp*MaxBP,Min0R(5.0,HP));
temp = Min0R(i_bcp * MaxBP, HP); // 0011
DP = 10 * Min0R(abs(temp - BP), 0.1) * PF(temp, BP, 0.0006 * (2 + int(temp > BP))) * dt * Speed;
temp = std::min(i_bcp * MaxBP, HP); // 0011
DP = 10.0 * std::min(std::abs(temp - BP), 0.1) * PF(temp, BP, 0.0006 * (temp > BP ? 3.0 : 2.0) ) * dt * Speed;
BP = BP - DP;
return -DP;
}