/// <summary> /// QueryObjects reply. /// </summary> protected override void OnQueryObjects(Reply reply) { foreach (var row in reply.Rows) { var raw = new RawSwitch(Client, row.Id); var protocol = raw.GetProtocol(); AddressType addressType; if (!EcosUtility.TryGetAddressType(protocol, out addressType)) { continue; } var addr = raw.GetAddress(); int addressNr; if (!int.TryParse(addr, out addressNr)) { continue; } var junction = railwayState.JunctionStates.FirstOrDefault(x => Matches(x, addressType, addressNr)); if (junction != null) { var sw = new Switch(Client, row.Id, (ISwitchState)junction); junctionIds[junction] = sw; sw.RequestView(); } } }
/// <summary> /// QueryObjects reply. /// </summary> protected override void OnQueryObjects(Reply reply) { foreach (var row in reply.Rows) { var raw = new RawLoc(Client, row.Id); var protocol = raw.GetProtocol(); AddressType addressType; if (!EcosUtility.TryGetAddressType(protocol, out addressType)) { continue; } var addr = raw.GetAddress(); int addressNr; if (!int.TryParse(addr, out addressNr)) { continue; } var name = raw.GetName(); // Try get by address var loc = railwayState.LocStates.FirstOrDefault(x => (x.Address.ValueAsInt == addressNr) && (x.Address.Type == addressType)); // Try get by name loc = loc ?? railwayState.LocStates.FirstOrDefault(x => x.Description == name); if (loc != null) { // We found a match locIds[loc] = new Loc(Client, row.Id, loc); } } }