private ITopologyElement GetPopulatedElement(ResourceDescription rs) { string errorMessage = $"[NMSManager] Failed to populate element with GID 0x{rs.Id:X16}. "; 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(); if (BaseVoltages.TryGetValue(baseVoltageGid, out float voltage)) { topologyElement.NominalVoltage = voltage; } else if (baseVoltageGid == 0) { logger.LogError($"{errorMessage} BaseVoltage with GID 0x{baseVoltageGid.ToString("X16")} does not exist in baseVoltages collection."); } } else { topologyElement.NominalVoltage = 0; } if (rs.ContainsProperty(ModelCode.BREAKER_NORECLOSING) && !rs.GetProperty(ModelCode.BREAKER_NORECLOSING).AsBool()) { Reclosers.Add(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 ex) { logger.LogError($"{errorMessage} Could not get all properties.Excepiton message: {ex.Message}"); } return(topologyElement); }