private async Task <ITopologyElement> GetPopulatedElement(ResourceDescription rs) { string verboseMessage = $"{baseLogString} entering GetPopulatedElement method."; Logger.LogVerbose(verboseMessage); ITopologyElement topologyElement = new TopologyElement(rs.Id); try { DMSType type = GetDMSTypeOfTopologyElement(rs.Id); topologyElement.Mrid = rs.GetProperty(ModelCode.IDOBJ_MRID).AsString(); topologyElement.Name = rs.GetProperty(ModelCode.IDOBJ_NAME).AsString(); topologyElement.Description = rs.GetProperty(ModelCode.IDOBJ_DESCRIPTION).AsString(); topologyElement.DmsType = type.ToString(); if (rs.ContainsProperty(ModelCode.CONDUCTINGEQUIPMENT_ISREMOTE)) { topologyElement.IsRemote = rs.GetProperty(ModelCode.CONDUCTINGEQUIPMENT_ISREMOTE).AsBool(); } else { topologyElement.IsRemote = false; } if (rs.ContainsProperty(ModelCode.BREAKER_NORECLOSING)) { topologyElement.NoReclosing = rs.GetProperty(ModelCode.BREAKER_NORECLOSING).AsBool(); if (!topologyElement.NoReclosing) { topologyElement = new Recloser(topologyElement); } } else { topologyElement.NoReclosing = true; } if (rs.ContainsProperty(ModelCode.CONDUCTINGEQUIPMENT_BASEVOLTAGE)) { long baseVoltageGid = rs.GetProperty(ModelCode.CONDUCTINGEQUIPMENT_BASEVOLTAGE).AsLong(); var voltageResult = await BaseVoltages.TryGetValueAsync(baseVoltageGid); if (voltageResult.HasValue) { topologyElement.NominalVoltage = voltageResult.Value; } else if (baseVoltageGid == 0) { Logger.LogError($"{baseLogString} GetPopulatedElement => BaseVoltage with GID {baseVoltageGid:X16} does not exist in baseVoltages collection."); } } else { topologyElement.NominalVoltage = 0; } if (rs.ContainsProperty(ModelCode.BREAKER_NORECLOSING) && !rs.GetProperty(ModelCode.BREAKER_NORECLOSING).AsBool()) { var reclosersResult = await Reclosers.TryGetValueAsync(ReliableDictionaryNames.Reclosers); if (reclosersResult.HasValue) { var reclosers = reclosersResult.Value; reclosers.Add(topologyElement.Id); await Reclosers.SetAsync(ReliableDictionaryNames.Reclosers, reclosers); } else { Logger.LogWarning($"{baseLogString} Reliable collection '{ReliableDictionaryNames.Reclosers}' was not defined yet. Handling..."); await Reclosers.SetAsync(ReliableDictionaryNames.Reclosers, new HashSet <long>() { topologyElement.Id }); } } if (rs.ContainsProperty(ModelCode.ENERGYCONSUMER_TYPE)) { topologyElement = new EnergyConsumer(topologyElement) { Type = (EnergyConsumerType)rs.GetProperty(ModelCode.ENERGYCONSUMER_TYPE).AsEnum() }; } if (type == DMSType.SYNCHRONOUSMACHINE) { topologyElement = new SynchronousMachine(topologyElement); if (rs.ContainsProperty(ModelCode.SYNCHRONOUSMACHINE_CAPACITY)) { ((SynchronousMachine)topologyElement).Capacity = rs.GetProperty(ModelCode.SYNCHRONOUSMACHINE_CAPACITY).AsFloat(); } if (rs.ContainsProperty(ModelCode.SYNCHRONOUSMACHINE_CURRENTREGIME)) { ((SynchronousMachine)topologyElement).CurrentRegime = rs.GetProperty(ModelCode.SYNCHRONOUSMACHINE_CURRENTREGIME).AsFloat(); } } } catch (Exception e) { Logger.LogError($"{baseLogString} GetPopulatedElement => Could not get all properties." + $"{Environment.NewLine}Excepiton message: {e.Message}" + $"{Environment.NewLine} Stack trace: {e.StackTrace}"); } return(topologyElement); }
void PopulateRecloserProperties(Recloser x, ResourceDescription rd) { PopulateProtectedSwitchProperties(x, rd); }