mirror of
https://github.com/MaSzyna-EU07/maszyna.git
synced 2026-07-22 13:59:19 +02:00
Poprawnie ładują się charakterstyki.
This commit is contained in:
@@ -1041,9 +1041,9 @@ public:
|
|||||||
|
|
||||||
/*funkcje ladujace pliki opisujace pojazd*/
|
/*funkcje ladujace pliki opisujace pojazd*/
|
||||||
bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath);
|
bool LoadFIZ(std::string chkpath); //Q 20160717 bool LoadChkFile(std::string chkpath);
|
||||||
bool readMPT(int ln, std::string xline); //Q 20160717
|
bool readMPT(int ln, std::string line); //Q 20160717
|
||||||
bool readRLIST(int ln, std::string xline); //Q 20160718
|
bool readRLIST(int ln, std::string line); //Q 20160718
|
||||||
bool readBPT(int ln, std::string xline); //Q 20160721
|
bool readBPT(int ln, std::string line); //Q 20160721
|
||||||
void BrakeValveDecode(std::string s); //Q 20160719
|
void BrakeValveDecode(std::string s); //Q 20160719
|
||||||
void BrakeSubsystemDecode(); //Q 20160719
|
void BrakeSubsystemDecode(); //Q 20160719
|
||||||
void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719
|
void PowerParamDecode(std::string lines, std::string prefix, TPowerParameters &PowerParamDecode); //Q 20160719
|
||||||
|
|||||||
@@ -5438,7 +5438,7 @@ std::string tS(std::string val)
|
|||||||
int Pos(std::string str_find, std::string in)
|
int Pos(std::string str_find, std::string in)
|
||||||
{
|
{
|
||||||
size_t pos = in.find(str_find);
|
size_t pos = in.find(str_find);
|
||||||
return (pos ? pos : 0);
|
return (pos != string::npos ? pos+1 : 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
@@ -5505,12 +5505,12 @@ int MARKERROR(int code, std::string type, std::string msg)
|
|||||||
|
|
||||||
int s2NPW(string s)
|
int s2NPW(string s)
|
||||||
{ // wylicza ilosc osi napednych z opisu ukladu osi
|
{ // wylicza ilosc osi napednych z opisu ukladu osi
|
||||||
const char A = (char)"A" - (char)1;
|
const char A = 64;
|
||||||
int k;
|
int k;
|
||||||
int NPW = 0;
|
int NPW = 0;
|
||||||
for (k = 0; k < s.length(); k++)
|
for (k = 0; k < s.length(); k++)
|
||||||
{
|
{
|
||||||
if (s[k] >= (char)"A" && s[k] <= (char)"Z")
|
if (s[k] >= (char)65 && s[k] <= (char)90)
|
||||||
NPW += s[k] - A;
|
NPW += s[k] - A;
|
||||||
}
|
}
|
||||||
return NPW;
|
return NPW;
|
||||||
@@ -5518,12 +5518,12 @@ int s2NPW(string s)
|
|||||||
|
|
||||||
int s2NNW(string s)
|
int s2NNW(string s)
|
||||||
{ // wylicza ilosc osi nienapedzanych z opisu ukladu osi
|
{ // wylicza ilosc osi nienapedzanych z opisu ukladu osi
|
||||||
const char Zero = (char)"0";
|
const char Zero = 48;
|
||||||
int k;
|
int k;
|
||||||
int NNW = 0;
|
int NNW = 0;
|
||||||
for (k = 0; k < s.length(); k++)
|
for (k = 0; k < s.length(); k++)
|
||||||
{
|
{
|
||||||
if (s[k] >= (char)"1" && s[k] <= (char)"9")
|
if (s[k] >= (char)49 && s[k] <= (char)57)
|
||||||
NNW += s[k] - Zero;
|
NNW += s[k] - Zero;
|
||||||
}
|
}
|
||||||
return NNW;
|
return NNW;
|
||||||
@@ -5533,7 +5533,7 @@ int s2NNW(string s)
|
|||||||
// Q: 20160717
|
// Q: 20160717
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
// parsowanie Motor Param Table
|
// parsowanie Motor Param Table
|
||||||
bool TMoverParameters::readMPT(int ln, std::string xline)
|
bool TMoverParameters::readMPT(int ln, std::string line)
|
||||||
{
|
{
|
||||||
// bl, mfi, mIsat, mfi0, fi, Isat, fi0
|
// bl, mfi, mIsat, mfi0, fi, Isat, fi0
|
||||||
bool as;
|
bool as;
|
||||||
@@ -5543,7 +5543,14 @@ bool TMoverParameters::readMPT(int ln, std::string xline)
|
|||||||
if (ln > 0) // 0 to nazwa sekcji - MotorParamTable0:
|
if (ln > 0) // 0 to nazwa sekcji - MotorParamTable0:
|
||||||
{
|
{
|
||||||
//--WriteLog("MPT: " + xline);
|
//--WriteLog("MPT: " + xline);
|
||||||
x = Split(xline, ' ');
|
x = Split(line);
|
||||||
|
|
||||||
|
if (x.size() != 7)
|
||||||
|
{
|
||||||
|
WriteLog("Read MPT: wrong argument number of arguments in line " + to_string(ln -1));
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
p0 = TrimSpace(x[0]);
|
p0 = TrimSpace(x[0]);
|
||||||
p1 = TrimSpace(x[1]);
|
p1 = TrimSpace(x[1]);
|
||||||
@@ -5576,7 +5583,7 @@ bool TMoverParameters::readMPT(int ln, std::string xline)
|
|||||||
// Q: 20160718
|
// Q: 20160718
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
// parsowanie RList
|
// parsowanie RList
|
||||||
bool TMoverParameters::readRLIST(int ln, std::string xline)
|
bool TMoverParameters::readRLIST(int ln, std::string line)
|
||||||
{
|
{
|
||||||
char *xxx;
|
char *xxx;
|
||||||
startRLIST = true;
|
startRLIST = true;
|
||||||
@@ -5584,20 +5591,26 @@ bool TMoverParameters::readRLIST(int ln, std::string xline)
|
|||||||
if (ln > 0) // 0 to nazwa sekcji - RList:
|
if (ln > 0) // 0 to nazwa sekcji - RList:
|
||||||
{
|
{
|
||||||
// WriteLog("RLIST: " + xline);
|
// WriteLog("RLIST: " + xline);
|
||||||
xline = Tab2Sp(xline); // zamieniamy taby na spacje (ile tabow tyle spacji bedzie)
|
line = Tab2Sp(line); // zamieniamy taby na spacje (ile tabow tyle spacji bedzie)
|
||||||
|
|
||||||
xxx = TrimAndReduceSpaces(xline.c_str()); // konwertujemy na *char i
|
xxx = TrimAndReduceSpaces(line.c_str()); // konwertujemy na *char i
|
||||||
// ograniczamy spacje pomiedzy
|
// ograniczamy spacje pomiedzy
|
||||||
// parametrami do jednej
|
// parametrami do jednej
|
||||||
|
|
||||||
x = Split(xxx, ' '); // split je wskaznik na char jak i std::string
|
x = Split(xxx); // split je wskaznik na char jak i std::string
|
||||||
|
|
||||||
|
if (x.size() != 5)
|
||||||
|
{
|
||||||
|
WriteLog("Read RLIST: wrong argument number of arguments in line " + to_string(ln - 1));
|
||||||
|
delete[] xxx;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
p0 = TrimSpace(x[0]);
|
p0 = TrimSpace(x[0]);
|
||||||
p1 = TrimSpace(x[1]);
|
p1 = TrimSpace(x[1]);
|
||||||
p2 = TrimSpace(x[2]);
|
p2 = TrimSpace(x[2]);
|
||||||
p3 = TrimSpace(x[3]);
|
p3 = TrimSpace(x[3]);
|
||||||
p4 = TrimSpace(x[4]);
|
p4 = TrimSpace(x[4]);
|
||||||
p5 = TrimSpace(x[5]);
|
|
||||||
|
|
||||||
int k = ln - 1;
|
int k = ln - 1;
|
||||||
|
|
||||||
@@ -5613,6 +5626,7 @@ bool TMoverParameters::readRLIST(int ln, std::string xline)
|
|||||||
|
|
||||||
//--WriteLog("RLIST: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4);
|
//--WriteLog("RLIST: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4);
|
||||||
}
|
}
|
||||||
|
delete[] xxx;
|
||||||
RLISTLINE++;
|
RLISTLINE++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5621,7 +5635,7 @@ bool TMoverParameters::readRLIST(int ln, std::string xline)
|
|||||||
// Q: 20160721
|
// Q: 20160721
|
||||||
// *************************************************************************************************
|
// *************************************************************************************************
|
||||||
// parsowanie Brake Param Table
|
// parsowanie Brake Param Table
|
||||||
bool TMoverParameters::readBPT(int ln, std::string xline)
|
bool TMoverParameters::readBPT(int ln, std::string line)
|
||||||
{
|
{
|
||||||
char *xxx;
|
char *xxx;
|
||||||
startBPT = true;
|
startBPT = true;
|
||||||
@@ -5630,9 +5644,16 @@ bool TMoverParameters::readBPT(int ln, std::string xline)
|
|||||||
if (ln > 0) // 0 to nazwa sekcji - Cntrl. - po niej jest tablica hamulcow
|
if (ln > 0) // 0 to nazwa sekcji - Cntrl. - po niej jest tablica hamulcow
|
||||||
{
|
{
|
||||||
// WriteLog("BPT: " + xline);
|
// WriteLog("BPT: " + xline);
|
||||||
xline = Tab2Sp(xline);
|
line = Tab2Sp(line);
|
||||||
xxx = TrimAndReduceSpaces(xline.c_str());
|
xxx = TrimAndReduceSpaces(line.c_str());
|
||||||
x = Split(xxx, ' ');
|
x = Split(xxx);
|
||||||
|
|
||||||
|
if (x.size() != 5)
|
||||||
|
{
|
||||||
|
WriteLog("Read BPT: wrong argument number of arguments in line " + to_string(ln - 1));
|
||||||
|
delete[] xxx;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
p0 = TrimSpace(x[0]);
|
p0 = TrimSpace(x[0]);
|
||||||
p1 = TrimSpace(x[1]);
|
p1 = TrimSpace(x[1]);
|
||||||
@@ -5653,7 +5674,7 @@ bool TMoverParameters::readBPT(int ln, std::string xline)
|
|||||||
|
|
||||||
//-- WriteLog("BPT: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4);
|
//-- WriteLog("BPT: " + p0 + "," + p1 + "," + p2 + "," + p3 + "," + p4);
|
||||||
}
|
}
|
||||||
|
delete[] xxx;
|
||||||
BPTLINE++;
|
BPTLINE++;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -5935,9 +5956,11 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool secBPT, secMotorParamTable0, secPower, secEngine, secParam, secLoad, secDimensions,
|
bool secBPT = false, secMotorParamTable0 = false, secPower = false, secEngine = false,
|
||||||
secWheels, secBrake, secBuffCoupl, secCntrl, secSecurity, secLight, secCircuit, secRList,
|
secParam = false, secLoad = false, secDimensions = false,
|
||||||
secDList, secWWList, secffList, secTurboPos;
|
secWheels = false, secBrake = false, secBuffCoupl = false, secCntrl = false,
|
||||||
|
secSecurity = false, secLight = false, secCircuit = false, secRList = false,
|
||||||
|
secDList = false, secWWList = false, secffList = false, secTurboPos = false;
|
||||||
|
|
||||||
ConversionError = 0;
|
ConversionError = 0;
|
||||||
|
|
||||||
@@ -5947,9 +5970,9 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
|||||||
{
|
{
|
||||||
// wers.find('#');
|
// wers.find('#');
|
||||||
xline = wers.c_str();
|
xline = wers.c_str();
|
||||||
ishash = Pos("#", xline);
|
ishash = xline.find("#");
|
||||||
// if ((ishash == 1)) WriteLog("zakomentowane " + xline);
|
// if ((ishash == 1)) WriteLog("zakomentowane " + xline);
|
||||||
if ((ishash == 0))
|
if ((ishash == string::npos))
|
||||||
{
|
{
|
||||||
|
|
||||||
if (xline.length() == 0)
|
if (xline.length() == 0)
|
||||||
@@ -6205,7 +6228,7 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
|||||||
}
|
}
|
||||||
} // is hash
|
} // is hash
|
||||||
} // while line
|
} // while line
|
||||||
|
in.close();
|
||||||
// Sprawdzenie poprawnosci wczytanych parametrow
|
// Sprawdzenie poprawnosci wczytanych parametrow
|
||||||
// WriteLog("DATA TEST: " + aCategory + ", " + aType + ", " + bLoadQ + ", " + bLoadAccepted + ",
|
// WriteLog("DATA TEST: " + aCategory + ", " + aType + ", " + bLoadQ + ", " + bLoadAccepted + ",
|
||||||
// " + dAxle + ", " + dBearingType + ", " + eBrakeValve + ", " + eBM + ", " + jEnginePower + ",
|
// " + dAxle + ", " + dBearingType + ", " + eBrakeValve + ", " + eBM + ", " + jEnginePower + ",
|
||||||
@@ -6749,6 +6772,12 @@ bool TMoverParameters::LoadFIZ(std::string chkpath)
|
|||||||
|
|
||||||
x = Split(kTrans, ':'); // 18:79
|
x = Split(kTrans, ':'); // 18:79
|
||||||
|
|
||||||
|
if (x.size() != 2)
|
||||||
|
{
|
||||||
|
WriteLog("Wrong transmition definition: " + kTrans);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
p0 = TrimSpace(x[0]);
|
p0 = TrimSpace(x[0]);
|
||||||
p1 = TrimSpace(x[1]);
|
p1 = TrimSpace(x[1]);
|
||||||
|
|
||||||
@@ -7874,3 +7903,5 @@ int TMoverParameters::ShowCurrentP(int AmpN)
|
|||||||
if (Couplers[b].Connected->Power > 0.01)
|
if (Couplers[b].Connected->Power > 0.01)
|
||||||
return Couplers[b].Connected->ShowCurrent(AmpN);
|
return Couplers[b].Connected->ShowCurrent(AmpN);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -148,9 +148,9 @@ std::string ReadWord(std::ifstream& infile)
|
|||||||
return s;
|
return s;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string TrimSpace(std::string s, int Just)
|
std::string TrimSpace(std::string &s, int Just)
|
||||||
{
|
{
|
||||||
int ii;
|
/*int ii;
|
||||||
|
|
||||||
switch (Just)
|
switch (Just)
|
||||||
{
|
{
|
||||||
@@ -174,7 +174,15 @@ std::string TrimSpace(std::string s, int Just)
|
|||||||
s = TrimSpace(s, CutRight);
|
s = TrimSpace(s, CutRight);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return s;
|
return s;*/
|
||||||
|
|
||||||
|
if (s.empty())
|
||||||
|
return "";
|
||||||
|
size_t first = s.find_first_not_of(' ');
|
||||||
|
if (first == string::npos)
|
||||||
|
return "";
|
||||||
|
size_t last = s.find_last_not_of(' ');
|
||||||
|
return s.substr(first, (last - first + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
char* TrimAndReduceSpaces(const char* s)
|
char* TrimAndReduceSpaces(const char* s)
|
||||||
@@ -183,7 +191,7 @@ char* TrimAndReduceSpaces(const char* s)
|
|||||||
if (s)
|
if (s)
|
||||||
{
|
{
|
||||||
|
|
||||||
strcpy(tmp, s);
|
tmp = strdup(s);
|
||||||
char* from = tmp + strspn(tmp, " ");
|
char* from = tmp + strspn(tmp, " ");
|
||||||
char* to = tmp;
|
char* to = tmp;
|
||||||
|
|
||||||
@@ -248,21 +256,21 @@ std::string Ld2Sp(std::string s) /*Low dash to Space sign*/
|
|||||||
|
|
||||||
std::string Tab2Sp(std::string s) /*Tab to Space sign*/
|
std::string Tab2Sp(std::string s) /*Tab to Space sign*/
|
||||||
{
|
{
|
||||||
//std::string s2 = "";
|
std::string s2 = "";
|
||||||
char tmp[] = { (char)9, (char)" " };
|
char tmp = (char)9;
|
||||||
for (int b = 0; b < s.length(); ++b)
|
for (int b = 0; b < s.length(); ++b)
|
||||||
{
|
|
||||||
if (s[b] == tmp[0])
|
|
||||||
s[b] = tmp[0];
|
|
||||||
}
|
|
||||||
return s;
|
|
||||||
//{
|
//{
|
||||||
// if (s[b] == tmp[0])
|
// if (s[b] == tmp[0])
|
||||||
// s2 = s2 + " ";
|
// s[b] = tmp[1];
|
||||||
// else
|
|
||||||
// s2 = s2 + s[b];
|
|
||||||
//}
|
//}
|
||||||
//return s2;
|
//return s;
|
||||||
|
{
|
||||||
|
if (s[b] == tmp)
|
||||||
|
s2 = s2 + " ";
|
||||||
|
else
|
||||||
|
s2 = s2 + s[b];
|
||||||
|
}
|
||||||
|
return s2;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::string ExchangeCharInString(string s, const char &aim, const char &target)
|
std::string ExchangeCharInString(string s, const char &aim, const char &target)
|
||||||
@@ -283,6 +291,7 @@ std::string ExchangeCharInString(string s, const char &aim, const char &target)
|
|||||||
|
|
||||||
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems)
|
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems)
|
||||||
{ // dzieli tekst na wektor tekstow
|
{ // dzieli tekst na wektor tekstow
|
||||||
|
|
||||||
std::stringstream ss(s);
|
std::stringstream ss(s);
|
||||||
std::string item;
|
std::string item;
|
||||||
while (std::getline(ss, item, delim))
|
while (std::getline(ss, item, delim))
|
||||||
@@ -299,6 +308,18 @@ std::vector<std::string> Split(const std::string &s, char delim)
|
|||||||
return elems;
|
return elems;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
std::vector<std::string> Split(const std::string &s)
|
||||||
|
{ // dzieli tekst na wektor tekstow po bia³ych znakach
|
||||||
|
std::vector<std::string> elems;
|
||||||
|
std::stringstream ss(s);
|
||||||
|
std::string item;
|
||||||
|
while (ss >> item)
|
||||||
|
{
|
||||||
|
elems.push_back(item);
|
||||||
|
}
|
||||||
|
return elems;
|
||||||
|
}
|
||||||
|
|
||||||
std::string to_string(int _Val)
|
std::string to_string(int _Val)
|
||||||
{
|
{
|
||||||
std::ostringstream o;
|
std::ostringstream o;
|
||||||
@@ -502,3 +523,4 @@ void ClearPendingExceptions()
|
|||||||
}
|
}
|
||||||
|
|
||||||
// END
|
// END
|
||||||
|
|
||||||
|
|||||||
@@ -110,7 +110,7 @@ bool FuzzyLogicAI(double Test, double Threshold, double Probability);
|
|||||||
/*operacje na stringach*/
|
/*operacje na stringach*/
|
||||||
std::string ReadWord( std::ifstream& infile); /*czyta slowo z wiersza pliku tekstowego*/
|
std::string ReadWord( std::ifstream& infile); /*czyta slowo z wiersza pliku tekstowego*/
|
||||||
//std::string Ups(std::string s);
|
//std::string Ups(std::string s);
|
||||||
std::string TrimSpace(std::string s, int Just = CutBoth);
|
std::string TrimSpace(std::string &s, int Just = CutBoth);
|
||||||
char* TrimAndReduceSpaces(const char* s);
|
char* TrimAndReduceSpaces(const char* s);
|
||||||
std::string ExtractKeyWord(std::string InS, std::string KeyWord); /*wyciaga slowo kluczowe i lancuch do pierwszej spacji*/
|
std::string ExtractKeyWord(std::string InS, std::string KeyWord); /*wyciaga slowo kluczowe i lancuch do pierwszej spacji*/
|
||||||
std::string DUE(std::string s); /*Delete Until Equal sign*/
|
std::string DUE(std::string s); /*Delete Until Equal sign*/
|
||||||
@@ -120,6 +120,7 @@ std::string Tab2Sp(std::string s); /*Tab to Space sign*/
|
|||||||
std::string ExchangeCharInString(string s, const char &aim, const char &target); // zamienia jeden znak na drugi
|
std::string ExchangeCharInString(string s, const char &aim, const char &target); // zamienia jeden znak na drugi
|
||||||
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems);
|
std::vector<std::string> &Split(const std::string &s, char delim, std::vector<std::string> &elems);
|
||||||
std::vector<std::string> Split(const std::string &s, char delim);
|
std::vector<std::string> Split(const std::string &s, char delim);
|
||||||
|
std::vector<std::string> Split(const std::string &s);
|
||||||
|
|
||||||
std::string to_string(int _Val);
|
std::string to_string(int _Val);
|
||||||
std::string to_string(unsigned int _Val);
|
std::string to_string(unsigned int _Val);
|
||||||
@@ -131,7 +132,7 @@ std::string to_string(double _Val, int precision, int width);
|
|||||||
std::string to_hex_str(double _Val, int precision = 0, int width = 0);
|
std::string to_hex_str(double _Val, int precision = 0, int width = 0);
|
||||||
inline std::string to_string(bool _Val)
|
inline std::string to_string(bool _Val)
|
||||||
{
|
{
|
||||||
to_string((int)_Val);
|
return to_string((int)_Val);
|
||||||
}
|
}
|
||||||
|
|
||||||
int stol_def(const std::string & str, const int & DefaultValue);
|
int stol_def(const std::string & str, const int & DefaultValue);
|
||||||
|
|||||||
Reference in New Issue
Block a user