Skip to content

Commit

Permalink
Merge pull request #250 from jannikbecker/estw/nrw/ehg
Browse files Browse the repository at this point in the history
Implement EHG
  • Loading branch information
jannikbecker authored May 15, 2024
2 parents 74ff433 + 3c728f6 commit 4e150ba
Show file tree
Hide file tree
Showing 13 changed files with 578 additions and 30 deletions.
31 changes: 20 additions & 11 deletions Leibit.BLL/LiveDataBLL.cs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ private void __RefreshTrainInformation(TrainInformation Train, Block Block, ESTW
if (Block != null)
{
// Dummy track for stations without platforms (e.g. Üst)
if (!Estw.SchedulesLoaded || Block.Track.Name.IsNullOrEmpty())
if (!Estw.SchedulesLoaded || Block.Track.Name == null)
{
Train.Block = Block;
}
Expand All @@ -629,22 +629,31 @@ private void __RefreshTrainInformation(TrainInformation Train, Block Block, ESTW
{
Track LiveTrack = null;

// Too difficult to explain -> LTA...
if (CurrentSchedule.Schedule.Track == null
|| !CurrentSchedule.Schedule.Track.IsPlatform
|| CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase)
|| (CurrentSchedule.Schedule.Track.Alternatives.Count == 0 && CurrentSchedule.Schedule.Track.Parent.Alternatives.Count == 0)
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase)))
/** Imagine this station layout for the following examples
*
* -----<|-----1A-----<|>-----1B-----|>-----
* -----<|-----2A-----<|>-----2B-----|>-----
* -----<|-------------3-------------|>-----
* -----<|-------------4-------------|>-----
*
*/

if (CurrentSchedule.Schedule.Track == null // special or misdirected trains
|| !CurrentSchedule.Schedule.Track.IsPlatform // Abzw/Üst
|| CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase) // Normal case
|| (CurrentSchedule.Schedule.Track.Alternatives.Count == 0 && CurrentSchedule.Schedule.Track.Parent.Alternatives.Count == 0) // No alternatives defined
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Name, StringComparison.InvariantCultureIgnoreCase))) // Schedule = 3, Block = 4 => LiveTrack = 4
{
LiveTrack = Block.Track;
}
else if (CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)))
else if (CurrentSchedule.Schedule.Track.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase) // Schedule = 1, Block = 1A => LiveTrack = 1
|| CurrentSchedule.Schedule.Track.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase))) // Schedule = 1, Block = 2A => LiveTrack = 2
{
LiveTrack = Block.Track.Parent;
}
else if (CurrentSchedule.Schedule.Track.Parent.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)
|| CurrentSchedule.Schedule.Track.Parent.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase)))
// These conditions must be evaluated after the second block, otherwise those case won't work.
else if (/*CurrentSchedule.Schedule.Track.Parent.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase) || */ // Schedule = 1A, Block = 1B, => LiveTrack = 1B ==> That seems wrong
CurrentSchedule.Schedule.Track.Parent.Alternatives.Any(a => a.Name.Equals(Block.Track.Parent.Name, StringComparison.InvariantCultureIgnoreCase))) // Schedule = 1A, Block = 2A => LiveTrack = 2A -OR- Schedule = 1A, Block = 2B => LiveTrack = 2B
{
LiveTrack = Block.Track;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -635,16 +635,7 @@ private TrainStationViewModel __BuildEntry(Schedule schedule, LiveSchedule liveS
// Determine state
var currentSchedule = liveSchedule.Train.Schedules.LastOrDefault(s => s.IsArrived && s.Schedule.Station.ShortSymbol == liveSchedule.Train.Block.Track.Station.ShortSymbol);

var isFirstStation = liveSchedule.Train.BlockHistory.Select(b => b.Track.Station).Distinct().Count() == 1
&& liveSchedule.Train.Block.Track.CalculateDelay
&& liveSchedule.Train.Block.Track.IsPlatform;

if (currentSchedule?.Schedule.Departure == null)
isFirstStation = false;
else if (currentSchedule?.Schedule.Handling == eHandling.Start)
isFirstStation = true;
else if (liveSchedule.Train.CreatedOn == liveSchedule.Train.Block.Track.Station.ESTW.StartTime)
isFirstStation = false;
var isFirstStation = currentSchedule?.Schedule.Handling == eHandling.Start;

if (liveSchedule.IsDeparted)
currentVm.State = "beendet";
Expand All @@ -659,7 +650,7 @@ private TrainStationViewModel __BuildEntry(Schedule schedule, LiveSchedule liveS
}
else if (currentSchedule.IsDeparted)
currentVm.State = "ab";
else if (isFirstStation && currentSchedule.Schedule.Handling == eHandling.Start && __IsReady(currentSchedule, settings))
else if (isFirstStation && __IsReady(currentSchedule, settings))
currentVm.State = "fertig";
else if (currentSchedule.IsPrepared)
currentVm.State = "vorbereitet";
Expand Down
1 change: 1 addition & 0 deletions Leibit.Core/Data/Areas.xml
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@
<estw id="KSO" name="Solingen" dataFile="leibit_SOLINGEN-OL.dat" infrastructureManager="DB" />
<estw id="KW" name="Wuppertal Hbf" dataFile="leibit_WUPPERTAL HBF.dat" infrastructureManager="DB" productName="Wuppertal" />
<estw id="KWO" name="Wuppertal-Oberbarmen" dataFile="leibit_W-OBERBARMEN.dat" infrastructureManager="DB" productName="Wuppertal" />
<estw id="EHG" name="Hagen Hbf" dataFile="leibit_HAGEN HBF.dat" infrastructureManager="DB"/>
</area>

<area id="berlin" name="Berlin">
Expand Down
Loading

0 comments on commit 4e150ba

Please sign in to comment.