private bool AddS88(IBlock block) { if (block == null) { return(false); } foreach (var e in block.ListEntries) { if (e == null) { continue; } string sid = $"{e.ObjectId}"; if (sid.StartsWith("10", StringComparison.OrdinalIgnoreCase)) { int n = _objects.Count(x => x is S88); var s88 = GetObjectBy(e.ObjectId) as S88; if (s88 == null) { s88 = new S88 { ObjectId = e.ObjectId, Index = n }; s88.Parse(e.Arguments); s88.CommandsReady += CommandsReady; _objects.Add(s88); DataChanged?.Invoke(this); s88.EnableView(); } else { s88.Parse(e.Arguments); s88.CommandsReady -= CommandsReady; s88.CommandsReady += CommandsReady; if (!s88.HasView) { s88.EnableView(); } DataChanged?.Invoke(this); } } } return(true); }
private bool HandleEvent(IBlock block) { if (block == null) { return(false); } RegisterS88.S88Info s88Info; if (RegisterS88.IsRegisterS88(block, out s88Info)) { if (s88Info != null && !s88Info.Appended) { RemoveObjectWithId((uint)s88Info.ObjectId); return(true); } else if (s88Info != null) { if (DoesObjectIdExist((uint)s88Info.ObjectId)) { RemoveObjectWithId((uint)s88Info.ObjectId); } int n = _objects.Count(x => x is S88); if (n + 1 != s88Info.NewSize) { Trace.WriteLine("<Error> S88 BusSize Mismatch"); return(false); } var s88 = new S88 { ObjectId = s88Info.ObjectId, Index = n }; s88.CommandsReady += CommandsReady; _objects.Add(s88); DataChanged?.Invoke(this); s88.EnableView(); return(true); } } foreach (var e in block.ListEntries) { if (e == null) { continue; } IItem item = GetObjectBy(e.ObjectId); if (HandleEventS88(item, e)) { continue; } if (HandleEventSwitch(item, e)) { continue; } if (HandleEventLocomotive(item, e)) { continue; } } return(true); }