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

departure/arrival time in timetable can be a fraction of minute

This commit is contained in:
Królik Uszasty
2019-05-12 23:38:40 +02:00
parent c021ac12a9
commit b4210f8094
4 changed files with 16 additions and 16 deletions

View File

@@ -1024,7 +1024,7 @@ TCommandType TController::TableUpdate(double &fVelDes, double &fDist, double &fN
if (TrainParams->StationIndex < TrainParams->StationCount) { if (TrainParams->StationIndex < TrainParams->StationCount) {
// jeśli są dalsze stacje, czekamy do godziny odjazdu // jeśli są dalsze stacje, czekamy do godziny odjazdu
if (TrainParams->IsTimeToGo(simulation::Time.data().wHour, simulation::Time.data().wMinute)) { if (TrainParams->IsTimeToGo(simulation::Time.data().wHour, simulation::Time.data().wMinute + simulation::Time.data().wSecond*0.0167 )) {
// z dalszą akcją czekamy do godziny odjazdu // z dalszą akcją czekamy do godziny odjazdu
IsAtPassengerStop = false; IsAtPassengerStop = false;
// przy jakim dystansie (stanie licznika) ma przesunąć na następny postój // przy jakim dystansie (stanie licznika) ma przesunąć na następny postój

View File

@@ -353,7 +353,7 @@ timetable_panel::update() {
( owner->iStationStart < table->StationIndex ) ( owner->iStationStart < table->StationIndex )
&& ( i < table->StationIndex ) && ( i < table->StationIndex )
&& ( ( tableline->Ah < 0 ) // pass-through, always valid && ( ( tableline->Ah < 0 ) // pass-through, always valid
|| ( time.wHour * 60 + time.wMinute >= tableline->Dh * 60 + tableline->Dm ) ) ); || ( time.wHour * 60 + time.wMinute + time.wSecond * 0.0167 >= tableline->Dh * 60 + tableline->Dm ) ) );
auto traveltime = auto traveltime =
" " " "
+ ( i < 2 ? "" : + ( i < 2 ? "" :

View File

@@ -52,7 +52,7 @@ bool TTrainParameters::IsStop() const
bool TTrainParameters::UpdateMTable( scenario_time const &Time, std::string const &NewName ) { bool TTrainParameters::UpdateMTable( scenario_time const &Time, std::string const &NewName ) {
return UpdateMTable( Time.data().wHour, Time.data().wMinute, NewName ); return UpdateMTable( Time.data().wHour, Time.data().wMinute + Time.data().wSecond * 0.0167, NewName );
} }
bool TTrainParameters::UpdateMTable(double hh, double mm, std::string const &NewName) bool TTrainParameters::UpdateMTable(double hh, double mm, std::string const &NewName)
@@ -358,12 +358,12 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
if (s.find(hrsd) != std::string::npos) if (s.find(hrsd) != std::string::npos)
{ {
record->Ah = atoi( s.substr(0, s.find(hrsd)).c_str()); // godzina 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 record->Am = atof(s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta przyjazdu
} }
else else
{ {
record->Ah = TimeTable[StationCount - 1].Ah; // godzina z poprzedniej pozycji record->Ah = TimeTable[StationCount - 1].Ah; // godzina z poprzedniej pozycji
record->Am = atoi(s.c_str()); // bo tylko minuty podane record->Am = atof(s.c_str()); // bo tylko minuty podane
} }
} }
do do
@@ -408,12 +408,12 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
if (s.find(hrsd) != std::string::npos) if (s.find(hrsd) != std::string::npos)
{ {
record->Dh = atoi(s.substr(0, s.find(hrsd)).c_str()); // godzina 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 record->Dm = atof(s.substr(s.find(hrsd) + 1, s.length()).c_str()); // minuta odjazdu
} }
else else
{ {
record->Dh = TimeTable[StationCount - 1].Dh; // godzina z poprzedniej pozycji record->Dh = TimeTable[StationCount - 1].Dh; // godzina z poprzedniej pozycji
record->Dm = atoi(s.c_str()); // bo tylko minuty podane record->Dm = atof(s.c_str()); // bo tylko minuty podane
} }
} }
else else
@@ -475,20 +475,20 @@ bool TTrainParameters::LoadTTfile(std::string scnpath, int iPlus, double vmax)
if( timeoffset != 0 ) // jeżeli jest przesunięcie rozkładu if( timeoffset != 0 ) // jeżeli jest przesunięcie rozkładu
{ {
long i_end = StationCount + 1; long i_end = StationCount + 1;
int adjustedtime; // do zwiększania czasu float adjustedtime; // do zwiększania czasu
for (auto i = 1; i < i_end; ++i) // bez with, bo ciężko się przenosi na C++ for (auto i = 1; i < i_end; ++i) // bez with, bo ciężko się przenosi na C++
{ {
if ((TimeTable[i].Ah >= 0)) if ((TimeTable[i].Ah >= 0))
{ {
adjustedtime = clamp_circular( TimeTable[i].Ah * 60 + TimeTable[i].Am + timeoffset, 24 * 60 ); // nowe minuty adjustedtime = clamp_circular( TimeTable[i].Ah * 60 + TimeTable[i].Am + timeoffset, 24.0 * 60.0 ); // nowe minuty
TimeTable[i].Am = adjustedtime % 60; TimeTable[i].Am = (int(60 * adjustedtime) % 3600) / 60.0;
TimeTable[i].Ah = (adjustedtime / 60) % 24; TimeTable[i].Ah = int((adjustedtime) / 60) % 24;
} }
if ((TimeTable[i].Dh >= 0)) if ((TimeTable[i].Dh >= 0))
{ {
adjustedtime = clamp_circular( TimeTable[i].Dh * 60 + TimeTable[i].Dm + timeoffset, 24 * 60 ); // nowe minuty adjustedtime = clamp_circular( TimeTable[i].Dh * 60 + TimeTable[i].Dm + timeoffset, 24.0 * 60.0 ); // nowe minuty
TimeTable[i].Dm = adjustedtime % 60; TimeTable[i].Dm = (int(60 * adjustedtime) % 3600) / 60.0;
TimeTable[i].Dh = (adjustedtime / 60) % 24; TimeTable[i].Dh = int((adjustedtime) / 60) % 24;
} }
} }
} }

View File

@@ -32,9 +32,9 @@ struct TMTableLine
std::string StationWare; // typ i wyposazenie stacji, oddz. przecinkami} std::string StationWare; // typ i wyposazenie stacji, oddz. przecinkami}
int TrackNo; // ilosc torow szlakowych int TrackNo; // ilosc torow szlakowych
int Ah; int Ah;
int Am; // godz. i min. przyjazdu, -1 gdy bez postoju double Am; // godz. i min. przyjazdu, -1 gdy bez postoju
int Dh; int Dh;
int Dm; // godz. i min. odjazdu double Dm; // godz. i min. odjazdu
double tm; // czas jazdy do tej stacji w min. (z kolumny) double tm; // czas jazdy do tej stacji w min. (z kolumny)
TMTableLine() TMTableLine()
{ {