Permalink
Browse files

multiple locomotive controller views; fix null ptr exceptions; code c…

…leanup
  • Loading branch information...
cbries committed Sep 7, 2017
1 parent 042ad01 commit 2571d71b4127767ada3980c95cf6698fb8a87404
View
@@ -2,6 +2,7 @@
------------------
Release Candidate 3 (RC3)
- multiview of tracks, distributable to different monitors, free dockable
- multiviews of locomotive controls
2017 September 5th
------------------
View
@@ -90,9 +90,7 @@ public bool InitializeWeaving(TrackPlanParser.Track track, string weaveFilepath)
{
case WeaveItemT.S88:
{
var s88Item = _dataProvider.GetObjectBy(item.ObjectId) as S88;
if (s88Item != null)
if (_dataProvider.GetObjectBy(item.ObjectId) is S88 s88Item)
{
var trackObject = _track.Get(item.VisuX, item.VisuY);
@@ -111,9 +109,7 @@ public bool InitializeWeaving(TrackPlanParser.Track track, string weaveFilepath)
case WeaveItemT.Switch:
{
var switchItem = _dataProvider.GetObjectBy(item.ObjectId) as Switch;
if (switchItem != null)
if (_dataProvider.GetObjectBy(item.ObjectId) is Switch switchItem)
{
var trackObject = _track.Get(item.VisuX, item.VisuY);
@@ -211,7 +207,7 @@ private async Task UnloadViews()
await _communication.SendCommands(initialCommands);
}
private void CommunicationOnCommunicationStarted(object sender, EventArgs args)
private async void CommunicationOnCommunicationStarted(object sender, EventArgs args)
{
// send initial commands
List<ICommand> initialCommands = new List<ICommand>()
@@ -227,7 +223,7 @@ private void CommunicationOnCommunicationStarted(object sender, EventArgs args)
CommandFactory.Create("request(1, view)")
};
_communication.SendCommands(initialCommands);
await _communication.SendCommands(initialCommands);
if (Model != null)
{
@@ -236,8 +232,7 @@ private void CommunicationOnCommunicationStarted(object sender, EventArgs args)
Model.TriggerPropertyChanged("TogglePowerCaption");
}
if(ReadyToPlay != null)
ReadyToPlay(this, EventArgs.Empty);
ReadyToPlay?.Invoke(this, EventArgs.Empty);
}
private void CommunicationOnCommunicationStopped(object sender, EventArgs eventArgs)
@@ -252,8 +247,7 @@ private void CommunicationOnCommunicationStopped(object sender, EventArgs eventA
private void CommunicationOnCommunicationFailed(object sender, EventArgs eventArgs)
{
var c = sender as Communication;
if (c != null && c.HasError)
if (sender is Communication c && c.HasError)
{
Logger?.Log($"<Dispatcher> Communication failed: {c.ErrorMessage}\r\n");
Logger?.LogError($"Connection to ECoS2 failed: {c.ErrorMessage}");
@@ -286,8 +280,7 @@ private void CommunicationOnBlocksReceived(object sender, IReadOnlyList<IBlock>
_dataProvider.Add(blk);
}
if (UpdateUi != null)
UpdateUi(this, _trackWeaver);
UpdateUi?.Invoke(this, _trackWeaver);
}
}
}
View
@@ -7,8 +7,6 @@
[A] handle S88 event as state-machine, that unexpected triggers do not start/stop trains when route is still busy
[B] redesign locomotive control
[B] allow individual actions on events, e.g. buttons should start something, or locomotives should switch on/off lights in specific moments
[C] "Fast Edit"-Tabelle f�r alle Objekte, TrackInformationen, etc. um schnell einen Plan editieren zu k�nnen
View
@@ -210,8 +210,8 @@ Global
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.Debug|x64.ActiveCfg = Debug|Any CPU
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.Debug|x64.Build.0 = Debug|Any CPU
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.Debug|x86.ActiveCfg = Debug|Any CPU
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.Debug|x86.Build.0 = Debug|Any CPU
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.Debug|x86.ActiveCfg = Debug|x86
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.Debug|x86.Build.0 = Debug|x86
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.DebugAppVeyor|Any CPU.ActiveCfg = DebugAppVeyor|Any CPU
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.DebugAppVeyor|Any CPU.Build.0 = DebugAppVeyor|Any CPU
{F7751558-8D8B-4AE2-A1EE-22D80889D73D}.DebugAppVeyor|x64.ActiveCfg = DebugAppVeyor|Any CPU
@@ -228,8 +228,8 @@ Global
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.Debug|Any CPU.Build.0 = Debug|Any CPU
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.Debug|x64.ActiveCfg = Debug|Any CPU
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.Debug|x64.Build.0 = Debug|Any CPU
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.Debug|x86.ActiveCfg = Debug|Any CPU
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.Debug|x86.Build.0 = Debug|Any CPU
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.Debug|x86.ActiveCfg = Debug|x86
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.Debug|x86.Build.0 = Debug|x86
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.DebugAppVeyor|Any CPU.ActiveCfg = DebugAppVeyor|Any CPU
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.DebugAppVeyor|Any CPU.Build.0 = DebugAppVeyor|Any CPU
{533F3598-DD73-423A-9959-B2CC2C69B9DD}.DebugAppVeyor|x64.ActiveCfg = DebugAppVeyor|Any CPU
@@ -246,8 +246,8 @@ Global
{B839732A-5C4A-4501-8B5E-990D12627C56}.Debug|Any CPU.Build.0 = Debug|Any CPU
{B839732A-5C4A-4501-8B5E-990D12627C56}.Debug|x64.ActiveCfg = Debug|Any CPU
{B839732A-5C4A-4501-8B5E-990D12627C56}.Debug|x64.Build.0 = Debug|Any CPU
{B839732A-5C4A-4501-8B5E-990D12627C56}.Debug|x86.ActiveCfg = Debug|Any CPU
{B839732A-5C4A-4501-8B5E-990D12627C56}.Debug|x86.Build.0 = Debug|Any CPU
{B839732A-5C4A-4501-8B5E-990D12627C56}.Debug|x86.ActiveCfg = Debug|x86
{B839732A-5C4A-4501-8B5E-990D12627C56}.Debug|x86.Build.0 = Debug|x86
{B839732A-5C4A-4501-8B5E-990D12627C56}.DebugAppVeyor|Any CPU.ActiveCfg = DebugAppVeyor|Any CPU
{B839732A-5C4A-4501-8B5E-990D12627C56}.DebugAppVeyor|Any CPU.Build.0 = DebugAppVeyor|Any CPU
{B839732A-5C4A-4501-8B5E-990D12627C56}.DebugAppVeyor|x64.ActiveCfg = DebugAppVeyor|Any CPU
@@ -264,8 +264,8 @@ Global
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.Debug|x64.ActiveCfg = Debug|Any CPU
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.Debug|x64.Build.0 = Debug|Any CPU
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.Debug|x86.ActiveCfg = Debug|Any CPU
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.Debug|x86.Build.0 = Debug|Any CPU
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.Debug|x86.ActiveCfg = Debug|x86
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.Debug|x86.Build.0 = Debug|x86
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.DebugAppVeyor|Any CPU.ActiveCfg = DebugAppVeyor|Any CPU
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.DebugAppVeyor|Any CPU.Build.0 = DebugAppVeyor|Any CPU
{BC3EAEFC-CD4D-4A9E-870E-918685C49C3D}.DebugAppVeyor|x64.ActiveCfg = DebugAppVeyor|Any CPU
@@ -282,8 +282,8 @@ Global
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.Debug|Any CPU.Build.0 = Debug|Any CPU
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.Debug|x64.ActiveCfg = Debug|Any CPU
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.Debug|x64.Build.0 = Debug|Any CPU
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.Debug|x86.ActiveCfg = Debug|Any CPU
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.Debug|x86.Build.0 = Debug|Any CPU
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.Debug|x86.ActiveCfg = Debug|x86
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.Debug|x86.Build.0 = Debug|x86
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.DebugAppVeyor|Any CPU.ActiveCfg = DebugAppVeyor|Any CPU
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.DebugAppVeyor|Any CPU.Build.0 = DebugAppVeyor|Any CPU
{F4CAD622-048A-4BC3-9B60-06BDFE0D6EE6}.DebugAppVeyor|x64.ActiveCfg = DebugAppVeyor|Any CPU
@@ -300,8 +300,8 @@ Global
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.Debug|x64.ActiveCfg = Debug|Any CPU
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.Debug|x64.Build.0 = Debug|Any CPU
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.Debug|x86.ActiveCfg = Debug|Any CPU
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.Debug|x86.Build.0 = Debug|Any CPU
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.Debug|x86.ActiveCfg = Debug|x86
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.Debug|x86.Build.0 = Debug|x86
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.DebugAppVeyor|Any CPU.ActiveCfg = DebugAppVeyor|Any CPU
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.DebugAppVeyor|Any CPU.Build.0 = DebugAppVeyor|Any CPU
{88DCD3BE-BC41-4342-9AFD-FC71A65B9470}.DebugAppVeyor|x64.ActiveCfg = DebugAppVeyor|Any CPU
Binary file not shown.
@@ -32,7 +32,7 @@ namespace RailwayEssentialMdi.Analyze
{
public class MapItem
{
private static int _instanceId = 0;
private static int _instanceId;
private int _localId;
private TrackInfo _info;
private readonly Map _ctx;
@@ -51,10 +51,12 @@ public TrackInfo Info
public MapItem ShallowCopy()
{
var item = new MapItem(_model, _ctx);
item._localId = _localId;
item._info = _info;
item.HasTurn = HasTurn;
var item = new MapItem(_model, _ctx)
{
_localId = _localId,
_info = _info,
HasTurn = HasTurn
};
return item;
}
@@ -87,7 +89,7 @@ public List<string> BlockIdentifiers
private bool _dimensionInitialized;
private int _orientationIndex;
private Theme.ThemeItem _themeInfo;
private ThemeItem _themeInfo;
private ThemeItemDimension _dim;
private void InitializeDimension()
@@ -553,8 +555,7 @@ public List<TrackInfo> GetReachableNeighbours(out bool wasConnected, TrackInfo i
if (targetItem != null)
{
wasConnected = true;
bool __dummy;
return targetItem.GetReachableNeighbours(out __dummy, source);
return targetItem.GetReachableNeighbours(out _, source);
}
}
}
@@ -568,7 +569,9 @@ public List<TrackInfo> GetReachableNeighbours(out bool wasConnected, TrackInfo i
var itemInfo = item.Info;
if (ignore != null && ignore.Equals(itemInfo))
; // ignore
{
// ignore
}
else if (itemInfo != null)
neighbours.Add(itemInfo);
}
@@ -588,7 +591,9 @@ public List<TrackInfo> GetReachableNeighbours(out bool wasConnected, TrackInfo i
}
if (ignore != null && ignore.Equals(itemInfo))
; // ignore
{
// ignore
}
else if (itemInfo != null)
neighbours.Add(itemInfo);
}
@@ -608,7 +613,9 @@ public List<TrackInfo> GetReachableNeighbours(out bool wasConnected, TrackInfo i
}
if (ignore != null && ignore.Equals(itemInfo))
; // ignore
{
// ignore
}
else if (itemInfo != null)
neighbours.Add(itemInfo);
}
@@ -619,7 +626,9 @@ public List<TrackInfo> GetReachableNeighbours(out bool wasConnected, TrackInfo i
var item = _ctx.Get(xx, y);
TrackInfo itemInfo = item.Info;
if (ignore != null && ignore.Equals(itemInfo))
; // ignore
{
// ignore
}
else if (itemInfo != null)
neighbours.Add(itemInfo);
}
@@ -629,8 +638,7 @@ public List<TrackInfo> GetReachableNeighbours(out bool wasConnected, TrackInfo i
public List<int> GetReachableNeighbourIds()
{
List<int> indeces = new List<int>();
bool wasConnected;
var neighbours = GetReachableNeighbours(out wasConnected);
var neighbours = GetReachableNeighbours(out _);
foreach (var n in neighbours)
{
MapItem nItem = _ctx.Get(n.X, n.Y);
@@ -646,8 +654,7 @@ public List<int> GetReachableNeighbourIds()
public bool CanGoFromLeftToBottom()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -665,8 +672,7 @@ public bool CanGoFromLeftToBottom()
public bool CanGoFromLeftToTop()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -684,8 +690,7 @@ public bool CanGoFromLeftToTop()
public bool CanGoFromLeftToRight()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -703,8 +708,7 @@ public bool CanGoFromLeftToRight()
public bool CanGoFromRightToBottom()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -722,8 +726,7 @@ public bool CanGoFromRightToBottom()
public bool CanGoFromRightToTop()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -741,8 +744,7 @@ public bool CanGoFromRightToTop()
public bool CanGoFromRightToLeft()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -760,8 +762,7 @@ public bool CanGoFromRightToLeft()
public bool CanGoFromTopToBottom()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -779,8 +780,7 @@ public bool CanGoFromTopToBottom()
public bool CanGoFromTopToRight()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -798,8 +798,7 @@ public bool CanGoFromTopToRight()
public bool CanGoFromTopToLeft()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -817,8 +816,7 @@ public bool CanGoFromTopToLeft()
public bool CanGoFromBottomToTop()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -836,8 +834,7 @@ public bool CanGoFromBottomToTop()
public bool CanGoFromBottomToRight()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
@@ -855,8 +852,7 @@ public bool CanGoFromBottomToRight()
public bool CanGoFromBottomToLeft()
{
bool wasConnected;
var nbs = GetReachableNeighbours(out wasConnected);
var nbs = GetReachableNeighbours(out _);
if (nbs == null || nbs.Count <= 0)
return false;
Oops, something went wrong.

0 comments on commit 2571d71

Please sign in to comment.