16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-21 04:39:18 +02:00

Poprawka na parsowanie wpisu hamulca. Formatowanie plików.

This commit is contained in:
firleju
2017-01-13 18:48:37 +01:00
parent 7df7c8b76e
commit cb63982266
10 changed files with 2799 additions and 2613 deletions

4
.gitignore vendored
View File

@@ -64,3 +64,7 @@ MaSzyna.sln
MaSzyna.vcxproj
MaSzyna.vcxproj.filters
*.suo
EU07.tds
MaSzyna.VC.VC.opendb
MaSzyna.VC.db
.vs/

View File

@@ -1763,10 +1763,10 @@ TDynamicObject::Init(string Name, // nazwa pojazdu, np. "EU07-424"
// kropkę na koniec
int kropka = MoreParams.find("."); // znajdź kropke
string ActPar; // na parametry
while (kropka > 0) // jesli sa kropki jeszcze
while (kropka != std::string::npos) // jesli sa kropki jeszcze
{
int dlugosc = MoreParams.length();
ActPar = ToUpper(MoreParams.substr(0, kropka - 1)); // pierwszy parametr;
ActPar = ToUpper(MoreParams.substr(0, kropka)); // pierwszy parametr;
MoreParams = MoreParams.substr(kropka + 1, dlugosc - kropka); // reszta do dalszej
// obrobki
kropka = MoreParams.find(".");

View File

@@ -41,8 +41,7 @@
<OPTIONS>
<IDLCFLAGS value="-src_suffix cpp -DGLEW_STATIC -D_DEBUG -IConsole -Iopengl -IMcZapkie
-I$(BCB)\include -I$(BCB)\include\vcl -Ipython\include -boa"/>
<CFLAG1 value="-Od -H=$(BCB)\lib\vcl50.csm -Hc -w- -Vx -Ve -X- -r- -a1 -6 -b- -k -y -v
-vi- -c -tW -tWM"/>
<CFLAG1 value="-Od -w- -Vx -Ve -X- -r- -a1 -6 -b- -k -y -v -vi- -c -tW -tWM"/>
<PFLAGS value="-$Y+ -$W -$O- -v -JPHNE -M"/>
<RFLAGS value=""/>
<AFLAGS value="/mx /w2 /zi"/>
@@ -58,9 +57,9 @@
IncludeVerInfo=1
AutoIncBuild=0
MajorVer=16
MinorVer=0
Release=1173
Build=481
MinorVer=1
Release=1174
Build=483
Debug=1
PreRelease=0
Special=0
@@ -72,13 +71,13 @@ CodePage=1250
[Version Info Keys]
CompanyName=EU07 Team
FileDescription=MaSzyna EU07-424
FileVersion=16.0.1173.481
FileVersion=16.1.1174.483
InternalName=DP+SPKS+asynch+python
LegalCopyright=
LegalTrademarks=
OriginalFilename=eu07.exe
ProductName=MaSzyna EU07-424
ProductVersion=16.0
ProductVersion=16.1
Comments=
[Excluded Packages]

View File

@@ -54,9 +54,9 @@ double Global::fLuminance = 1.0; // jasno
int Global::iReCompile = 0; // zwiêkszany, gdy trzeba odœwie¿yæ siatki
HWND Global::hWnd = NULL; // uchwyt okna
int Global::iCameraLast = -1;
std::string Global::asRelease = "16.0.1172.481";
std::string Global::asRelease = "16.1.1174.483";
std::string Global::asVersion =
"Compilation 2016-08-24, release " + Global::asRelease + "."; // tutaj, bo wysy³any
"Compilation 2017-01-13, release " + Global::asRelease + "."; // tutaj, bo wysy³any
int Global::iViewMode = 0; // co aktualnie widaæ: 0-kabina, 1-latanie, 2-sprzêgi, 3-dokumenty
int Global::iTextMode = 0; // tryb pracy wyœwietlacza tekstowego
int Global::iScreenMode[12] = {0, 0, 0, 0, 0, 0,

View File

@@ -1809,7 +1809,7 @@ TGroundNode * TGround::AddGroundNode(cParser *parser)
if (int2 != string::npos) // yB: jesli znalazl kropke, to ja przetwarza jako parametry
{
int dlugosc = str4.length();
int1 = atoi(str4.substr(0, int2 - 1).c_str()); // niech sprzegiem bedzie do kropki cos
int1 = atoi(str4.substr(0, int2).c_str()); // niech sprzegiem bedzie do kropki cos
str4 = str4.substr(int2 + 1, dlugosc - int2);
}
else

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,5 +1,5 @@
/** @file
@brief
/** @file
@brief
*/
/*
@@ -14,7 +14,7 @@ http://mozilla.org/MPL/2.0/.
#include "mtable.h"
#include <fstream>
//using namespace Mtable;
// using namespace Mtable;
TMTableTime *Mtable::GlobalTime;
double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica czasu w minutach*/
@@ -39,14 +39,14 @@ double CompareTime(double t1h, double t1m, double t2h, double t2m) /*roznica cza
double TTrainParameters::CheckTrainLatency()
{
if ((LastStationLatency > 1.0) || (LastStationLatency < 0))
return LastStationLatency; /*spoznienie + lub do przodu - z tolerancja 1 min*/
if ((LastStationLatency > 1.0) || (LastStationLatency < 0))
return LastStationLatency; /*spoznienie + lub do przodu - z tolerancja 1 min*/
else
return 0;
}
double TTrainParameters::WatchMTable(double DistCounter)
{ //zwraca odlegloϾ do najblizszej stacji z zatrzymaniem
{ // zwraca odlegloϾ do najblizszej stacji z zatrzymaniem
double dist;
if (Direction == 1)
@@ -81,7 +81,8 @@ bool TTrainParameters::UpdateMTable(double hh, double mm, std::string NewName)
{
if (NewName == NextStationName) // jeœli dojechane do nastêpnego
{ // Ra: wywo³anie mo¿e byæ powtarzane, jak stoi na W4
if (TimeTable[StationIndex + 1].km - TimeTable[StationIndex].km < 0) // to jest bez sensu
if (TimeTable[StationIndex + 1].km - TimeTable[StationIndex].km <
0) // to jest bez sensu
Direction = -1;
else
Direction = 1; // prowizorka bo moze byc zmiana kilometrazu
@@ -187,7 +188,7 @@ void TTrainParameters::UpdateVelocity(int StationCount, double vActual)
}
}
//bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
// bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
//{
// return false;
//}
@@ -216,10 +217,10 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
s = scnpath + TrainName + ".txt";
// Ra 2014-09: ustaliæ zasady wyznaczenia pierwotnego pliku przy przesuniêtych rozk³adach
// (kolejny poci¹g dostaje numer +2)
fin.open(s.c_str()); //otwieranie pliku
if (!fin.is_open())
{ //jeœli nie ma pliku
fin.open(s.c_str()); // otwieranie pliku
if (!fin.is_open())
{ // jeœli nie ma pliku
vmax = atoi(TrainName.c_str()); // nie ma pliku ale jest liczba
if ((vmax > 10) && (vmax < 200))
{
@@ -235,91 +236,91 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
ConversionError = 0;
while (fin.good() && !((ConversionError != 0) || EndTable))
{
std::getline(fin,lines); /*wczytanie linii*/
if (lines.find("___________________") != std::string::npos) /*linia pozioma górna*/
{
fin >> s;
if (s == "[") /*lewy pion*/
{
fin >> s;
if (s == "Rodzaj") /*"Rodzaj i numer pociagu"*/
do
{
fin >> s;
} while (!(s == "|") || (fin.eof())); /*œrodkowy pion*/
}
}
else if (lines == "")
{
fin.close();
break;
}
fin >> s; /*nazwa poci¹gu*/
std::getline(fin, lines); /*wczytanie linii*/
if (lines.find("___________________") != std::string::npos) /*linia pozioma górna*/
{
fin >> s;
if (s == "[") /*lewy pion*/
{
fin >> s;
if (s == "Rodzaj") /*"Rodzaj i numer pociagu"*/
do
{
fin >> s;
} while (!(s == "|") || (fin.eof())); /*œrodkowy pion*/
}
}
else if (lines == "")
{
fin.close();
break;
}
fin >> s; /*nazwa poci¹gu*/
// if LowerCase(s)<>ExtractFileName(TrainName) then {musi byæ taka sama, jak nazwa
// pliku}
// ConversionError:=-7 {b³¹d niezgodnoœci}
TrainName = s; // nadanie nazwy z pliku TXT (bez œcie¿ki do pliku)
// else
{ /*czytaj naglowek*/
while(fin >> s || !fin.bad())
while (fin >> s || !fin.bad())
{
if (s.find("_______|") != std::string::npos)
break;
//fin >> s;
} //while (!(s.find("_______|") != std::string::npos) || fin.eof());
while (fin >> s || !fin.bad())
if (s.find("_______|") != std::string::npos)
break;
// fin >> s;
} // while (!(s.find("_______|") != std::string::npos) || fin.eof());
while (fin >> s || !fin.bad())
{
if (s == "[")
break;
} //while (!() || (fin.eof())); /*pierwsza linia z relacj¹*/
while(fin >> s || !fin.bad())
if (s == "[")
break;
} // while (!() || (fin.eof())); /*pierwsza linia z relacj¹*/
while (fin >> s || !fin.bad())
{
if (s != "|")
break;
} //while (!(() || fin.eof()));
if (s != "|")
break;
} // while (!(() || fin.eof()));
if (s != "|")
Relation1 = s;
else
ConversionError = -5;
while(fin >> s || !fin.bad())
{
if (s == "Relacja")
break;
} //while (
// !( || (fin.eof()))); /*druga linia z relacj¹*/
while (fin >> s || !fin.bad())
{
if (s == "|")
break;
} //while (!( || (fin.eof())));
if (s == "Relacja")
break;
} // while (
// !( || (fin.eof()))); /*druga linia z relacj¹*/
while (fin >> s || !fin.bad())
{
if (s == "|")
break;
} // while (!( || (fin.eof())));
fin >> Relation2;
while (fin >> s || !fin.bad())
{
if (s == "Wymagany")
break;
}// while (!();
if (s == "Wymagany")
break;
} // while (!();
while (fin >> s || !fin.bad())
{
if ((s == "|") || (s == "\n"))
break;
} //while (!());
if ((s == "|") || (s == "\n"))
break;
} // while (!());
fin >> s;
s = s.substr(0, s.find("%"));
BrakeRatio = atof(s.c_str());
while (fin >> s || fin.bad())
{
if (s == "Seria")
break;
} //while (!(s == "Seria"));
if (s == "Seria")
break;
} // while (!(s == "Seria"));
do
{
fin >> s;
fin >> s;
} while (!((s == "|") || (fin.bad())));
fin >> LocSeries;
fin >> LocLoad;// = s2rE(ReadWord(fin));
fin >> LocLoad; // = s2rE(ReadWord(fin));
do
{
fin >> s;
fin >> s;
} while (!(s.find("[______________") != std::string::npos || fin.bad()));
while (!fin.bad() && !EndTable)
{
@@ -328,7 +329,7 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
{
fin >> s;
} while (!((s == "[") || (fin.bad())));
TMTableLine *record = &TimeTable[StationCount];
TMTableLine *record = &TimeTable[StationCount];
{
if (s == "[")
fin >> s;
@@ -336,10 +337,11 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
ConversionError = -4;
if (s.find("|") == std::string::npos)
{
record->km = atof(s.c_str());
record->km = atof(s.c_str());
fin >> s;
}
if (s.find("|_____|") != std::string::npos) /*zmiana predkosci szlakowej*/
if (s.find("|_____|") !=
std::string::npos) /*zmiana predkosci szlakowej*/
UpdateVelocity(StationCount, vActual);
else
{
@@ -360,14 +362,15 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
{
if (s.find(hrsd) != std::string::npos)
{
record->Ah = atoi(s.substr(0, s.find(hrsd)).c_str()); // godzina przyjazdu
record->Am = atoi(
s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta przyjazdu
record->Ah = atoi(
s.substr(0, s.find(hrsd)).c_str()); // godzina przyjazdu
record->Am = atoi(s.substr(s.find(hrsd) + 1, s.length())
.c_str()); // minuta przyjazdu
}
else
{
record->Ah = TimeTable[StationCount - 1]
.Ah; // godzina z poprzedniej pozycji
.Ah; // godzina z poprzedniej pozycji
record->Am = atoi(s.c_str()); // bo tylko minuty podane
}
}
@@ -387,7 +390,8 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
/*tu s moze byc miejscem zmiany predkosci szlakowej*/
fin >> s;
}
if (s.find("|_____|") != std::string::npos) /*zmiana predkosci szlakowej*/
if (s.find("|_____|") !=
std::string::npos) /*zmiana predkosci szlakowej*/
UpdateVelocity(StationCount, vActual);
else
{
@@ -408,24 +412,29 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
{
if (s.find(hrsd) != std::string::npos)
{
record->Dh = atoi(s.substr(0, s.find(hrsd)).c_str()); // godzina odjazdu
record->Dm = atoi(
s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta odjazdu
record->Dh =
atoi(s.substr(0, s.find(hrsd)).c_str()); // godzina odjazdu
record->Dm = atoi(s.substr(s.find(hrsd) + 1, s.length())
.c_str()); // minuta odjazdu
}
else
{
record->Dh = TimeTable[StationCount - 1]
.Dh; // godzina z poprzedniej pozycji
.Dh; // godzina z poprzedniej pozycji
record->Dm = atoi(s.c_str()); // bo tylko minuty podane
}
}
else
{
record->Dh = record->Ah; // odjazd o tej samej, co przyjazd (dla ostatniego te¿)
record->Dm = record->Am; // bo s¹ u¿ywane do wyliczenia opóŸnienia po dojechaniu
record->Dh = record->Ah; // odjazd o tej samej, co przyjazd (dla
// ostatniego te¿)
record->Dm = record->Am; // bo s¹ u¿ywane do wyliczenia opóŸnienia
// po dojechaniu
}
if ((record->Ah >= 0))
record->WaitTime = (int)(CompareTime(record->Ah, record->Am, record->Dh, record->Dm) + 0.1);
record->WaitTime = (int)(CompareTime(record->Ah, record->Am,
record->Dh, record->Dm) +
0.1);
do
{
fin >> s;
@@ -443,7 +452,8 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
/*tu s moze byc miejscem zmiany predkosci szlakowej*/
fin >> s;
}
if (s.find("|_____|") != std::string::npos) /*zmiana predkosci szlakowej*/
if (s.find("|_____|") !=
std::string::npos) /*zmiana predkosci szlakowej*/
UpdateVelocity(StationCount, vActual);
else
{
@@ -536,12 +546,7 @@ bool TTrainParameters::DirectionChange()
// sprawdzenie, czy po zatrzymaniu wykonaæ kolejne komendy
{
if ((StationIndex > 0) && (StationIndex < StationCount)) // dla ostatniej stacji nie
if (TimeTable[StationIndex].StationWare.find("@") != std::string::npos)
if (TimeTable[StationIndex].StationWare.find("@") != std::string::npos)
return true;
return false;
}

156
mtable.h
View File

@@ -18,92 +18,92 @@ http://mozilla.org/MPL/2.0/.
namespace Mtable
{
static int const MaxTTableSize = 100; // mo¿na by to robiæ dynamicznie
static char const *hrsd = ".";
static int const MaxTTableSize = 100; // mo¿na by to robiæ dynamicznie
static char const *hrsd = ".";
// Ra: pozycja zerowa rozk³adu chyba nie ma sensu
// Ra: numeracja przystanków jest 1..StationCount
// Ra: pozycja zerowa rozk³adu chyba nie ma sensu
// Ra: numeracja przystanków jest 1..StationCount
struct TMTableLine
{
double km; // kilometraz linii
double vmax; // predkosc rozkladowa przed przystankiem
// StationName:string[32]; //nazwa stacji ('_' zamiast spacji)
// StationWare:string[32]; //typ i wyposazenie stacji, oddz. przecinkami}
std::string StationName; // nazwa stacji ('_' zamiast spacji)
std::string StationWare; // typ i wyposazenie stacji, oddz. przecinkami}
int TrackNo; // ilosc torow szlakowych
int Ah;
int Am; // godz. i min. przyjazdu, -1 gdy bez postoju
int Dh;
int Dm; // godz. i min. odjazdu
double tm; // czas jazdy do tej stacji w min. (z kolumny)
int WaitTime; // czas postoju (liczony plus 6 sekund)
TMTableLine()
{
km = 0;
vmax = -1;
StationName = "nowhere", StationWare = "";
TrackNo = 1;
Ah, Am, Dh, Dm = -1;
WaitTime, tm = 0;
}
};
struct TMTableLine
{
double km; // kilometraz linii
double vmax; // predkosc rozkladowa przed przystankiem
// StationName:string[32]; //nazwa stacji ('_' zamiast spacji)
// StationWare:string[32]; //typ i wyposazenie stacji, oddz. przecinkami}
std::string StationName; // nazwa stacji ('_' zamiast spacji)
std::string StationWare; // typ i wyposazenie stacji, oddz. przecinkami}
int TrackNo; // ilosc torow szlakowych
int Ah;
int Am; // godz. i min. przyjazdu, -1 gdy bez postoju
int Dh;
int Dm; // godz. i min. odjazdu
double tm; // czas jazdy do tej stacji w min. (z kolumny)
int WaitTime; // czas postoju (liczony plus 6 sekund)
TMTableLine()
{
km = 0;
vmax = -1;
StationName = "nowhere", StationWare = "";
TrackNo = 1;
Ah, Am, Dh, Dm = -1;
WaitTime, tm = 0;
}
};
typedef TMTableLine TMTable[MaxTTableSize + 1];
typedef TMTableLine TMTable[MaxTTableSize + 1];
//typedef TTrainParameters *PTrainParameters;
// typedef TTrainParameters *PTrainParameters;
class TTrainParameters
{
public:
std::string TrainName;
double TTVmax;
std::string Relation1;
std::string Relation2; // nazwy stacji danego odcinka
double BrakeRatio;
std::string LocSeries; // seria (typ) pojazdu
double LocLoad;
TMTable TimeTable;
int StationCount; // iloœæ przystanków (0-techniczny)
int StationIndex; // numer najbli¿szego (aktualnego) przystanku
std::string NextStationName;
double LastStationLatency;
int Direction; /*kierunek jazdy w/g kilometrazu*/
double CheckTrainLatency();
/*todo: str hh:mm to int i z powrotem*/
std::string ShowRelation();
double WatchMTable(double DistCounter);
std::string NextStop();
bool IsStop();
bool IsTimeToGo(double hh, double mm);
bool UpdateMTable(double hh, double mm, std::string NewName);
TTrainParameters(std::string NewTrainName);
void NewName(std::string NewTrainName);
void UpdateVelocity(int StationCount, double vActual);
bool LoadTTfile(std::string scnpath, int iPlus, double vmax);
bool DirectionChange();
void StationIndexInc();
};
class TTrainParameters
{
public:
std::string TrainName;
double TTVmax;
std::string Relation1;
std::string Relation2; // nazwy stacji danego odcinka
double BrakeRatio;
std::string LocSeries; // seria (typ) pojazdu
double LocLoad;
TMTable TimeTable;
int StationCount; // iloœæ przystanków (0-techniczny)
int StationIndex; // numer najbli¿szego (aktualnego) przystanku
std::string NextStationName;
double LastStationLatency;
int Direction; /*kierunek jazdy w/g kilometrazu*/
double CheckTrainLatency();
/*todo: str hh:mm to int i z powrotem*/
std::string ShowRelation();
double WatchMTable(double DistCounter);
std::string NextStop();
bool IsStop();
bool IsTimeToGo(double hh, double mm);
bool UpdateMTable(double hh, double mm, std::string NewName);
TTrainParameters(std::string NewTrainName);
void NewName(std::string NewTrainName);
void UpdateVelocity(int StationCount, double vActual);
bool LoadTTfile(std::string scnpath, int iPlus, double vmax);
bool DirectionChange();
void StationIndexInc();
};
class TMTableTime
class TMTableTime
{
public:
double GameTime;
int dd;
int hh;
int mm;
int srh;
int srm; /*wschod slonca*/
int ssh;
int ssm; /*zachod slonca*/
double mr;
void UpdateMTableTime(double deltaT);
TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM);
};
{
public:
double GameTime;
int dd;
int hh;
int mm;
int srh;
int srm; /*wschod slonca*/
int ssh;
int ssm; /*zachod slonca*/
double mr;
void UpdateMTableTime(double deltaT);
TMTableTime(int InitH, int InitM, int InitSRH, int InitSRM, int InitSSH, int InitSSM);
};
extern TMTableTime *GlobalTime;
extern TMTableTime *GlobalTime;
}
#if !defined(NO_IMPLICIT_NAMESPACE_USE)