public static List <ModelCode> NadjiAtributeDMS(DMSType dmstip) { ModelResourcesDesc modResDes = new ModelResourcesDesc(); List <ModelCode> lista = modResDes.GetAllPropertyIds(dmstip); return(lista); }
public Delta SeparateDeltaForEMSType(DMSType emsType) { Delta newDelta = new Delta(); foreach (ResourceDescription rd_item in this.InsertOperations) { if (ModelCodeHelper.ExtractTypeFromGlobalId(rd_item.Id).Equals((short)emsType)) { newDelta.AddDeltaOperation(DeltaOpType.Insert, rd_item.Clone() as ResourceDescription, true); //break; } } foreach (ResourceDescription rd_item in this.UpdateOperations) { if (ModelCodeHelper.ExtractTypeFromGlobalId(rd_item.Id).Equals((short)emsType)) { newDelta.AddDeltaOperation(DeltaOpType.Update, rd_item.Clone() as ResourceDescription, true); //break; } } foreach (ResourceDescription rd_item in this.DeleteOperations) { if (ModelCodeHelper.ExtractTypeFromGlobalId(rd_item.Id).Equals((short)emsType)) { newDelta.AddDeltaOperation(DeltaOpType.Delete, rd_item.Clone() as ResourceDescription, true); //break; } } return(newDelta); }
public List <long> TestGetExtentValuesAllTypes() { string message = "Getting extent values for all DMS types started."; Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); List <ModelCode> properties = new List <ModelCode>(); List <long> ids = new List <long>(); int iteratorId = 0; int numberOfResources = 1000; DMSType currType = 0; try { foreach (DMSType type in Enum.GetValues(typeof(DMSType))) { currType = type; properties = modelResourcesDesc.GetAllPropertyIds(type); iteratorId = GdaQueryProxy.GetExtentValues(modelResourcesDesc.GetModelCodeFromType(type), properties); int count = GdaQueryProxy.IteratorResourcesLeft(iteratorId); while (count > 0) { List <ResourceDescription> rds = GdaQueryProxy.IteratorNext(numberOfResources, iteratorId); for (int i = 0; i < rds.Count; i++) { ids.Add(rds[i].Id); } count = GdaQueryProxy.IteratorResourcesLeft(iteratorId); } bool ok = GdaQueryProxy.IteratorClose(iteratorId); message = string.Format("Number of {0} in model {1}.", type, ids.Count); Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); } message = "Getting extent values for all DMS types successfully ended."; Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); } catch (Exception e) { message = string.Format("Getting extent values for all DMS types failed for type {0}.\n\t{1}", currType, e.Message); Console.WriteLine(message); CommonTrace.WriteTrace(CommonTrace.TraceInfo, message); throw; } return(ids); }
public NodeData(IdentifiedObject identified, bool isroot) { this.idenetifiedObj = identified; this.isRoot = isroot; this.energized = Energized.NotEnergized; this.type = DMSType.GEOGRAPHICALREGION; }
public EMSLoadFlowLoadViewModel(EMSLoadFlowLoadRecord reportRecord, bool tabularViewActive) { if (reportRecord == null) { DMSLogger.Log(DMSLogger.LogLevel.Error, "Parameter reportRecord passed to EMSLoadFlowLoadViewModel(), should not be null."); return; } this.reportRecord = reportRecord; recordType = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(reportRecord.Lid); DataGridTreeViewItemInfo = new HierarchicalReportRecord(); DataGridTreeViewItemInfo.Lid = reportRecord.Lid; DataGridTreeViewItemInfo.Level = reportRecord.Level; DataGridTreeViewItemInfo.ElementIsShownInTabularView = reportRecord.ElementIsShownInTabularView; if (String.IsNullOrEmpty(reportRecord.Title)) { DataGridTreeViewItemInfo.Title = DmsTypeToEntityNameMapper.GetAutomatedName((DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(reportRecord.Lid), reportRecord.Lid); } else { DataGridTreeViewItemInfo.Title = reportRecord.Title; } tabularViewIsActive = tabularViewActive; if (tabularViewActive && !this.reportRecord.ElementIsShownInTabularView) { rowIsNotVisible = true; } }
private List <long> GetReferencedElementsWithoutIgnorables(long gid) { List <long> refElements = new List <long>(); if (connections.TryGetValue(gid, out List <long> list)) { list = list.Where(e => !visited.Contains(e)).ToList(); foreach (var element in list) { DMSType elementType = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(element); if (TopologyHelper.Instance.GetElementTopologyStatus(element) == TopologyStatus.Ignorable) { visited.Add(element); refElements.AddRange(GetReferencedElementsWithoutIgnorables(element)); } else if (elementType != DMSType.DISCRETE && elementType != DMSType.ANALOG && elementType != DMSType.BASEVOLTAGE) { refElements.Add(element); } } } else { logger.LogDebug($"[GraphBuilder] Failed to get connected elements for element with GID 0x{gid.ToString("X16")}."); } return(refElements); }
/// <summary> /// Gets resource iterator that holds descriptions for all entities related to specified source. /// </summary> /// <param name="contextId">Context Id</param> /// <param name="properties">List of requested properties</param> /// <param name="association">Relation between source and entities that should be returned</param> /// <param name="source">Id of entity that is start for association search</param> /// <param name="typeOfQuery">Query type choice(global or local)</param> /// <returns>Resource iterator for the requested entities</returns> public ResourceIterator GetRelatedValues(long source, List <ModelCode> properties, Association association) { CommonTrace.WriteTrace(CommonTrace.TraceVerbose, String.Format("Getting related values for source = 0x{0:x16}.", source)); try { List <long> relatedGids = ApplyAssocioationOnSource(source, association); Dictionary <DMSType, List <ModelCode> > class2PropertyIDs = new Dictionary <DMSType, List <ModelCode> >(); foreach (long relatedGid in relatedGids) { DMSType entityDmsType = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(relatedGid); if (!class2PropertyIDs.ContainsKey(entityDmsType)) { class2PropertyIDs.Add(entityDmsType, properties); } } ResourceIterator ri = new ResourceIterator(relatedGids, class2PropertyIDs); CommonTrace.WriteTrace(CommonTrace.TraceVerbose, String.Format("Getting related values for source = 0x{0:x16} succeeded.", source)); return(ri); } catch (Exception ex) { string message = String.Format("Failed to get related values for source GID = 0x{0:x16}. {1}.", source, ex.Message); CommonTrace.WriteTrace(CommonTrace.TraceError, message); throw new Exception(message); } }
private void CreateAndInsertDeltaOperation(string mrid, ResourceDescription rd) { long negGid = 0; DeltaOpType deltaOp = DeltaOpType.Insert; DMSType type = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(rd.Id); if (ModelCodeHelper.ExtractEntityIdFromGlobalId(rd.Id) < 0 && !NegativeGidToMrid.ContainsKey(rd.Id)) { negGid = rd.Id; NegativeGidToMrid.Add(rd.Id, mrid); } if (MridToPositiveGidFromServer.ContainsKey(mrid)) { rd.Id = MridToPositiveGidFromServer[mrid]; deltaOp = DeltaOpType.Update; } delta.AddDeltaOperation(deltaOp, rd, true); if (!MridsFromConcreteModel.Contains(mrid)) { MridsFromConcreteModel.Add(mrid); } report.Report.Append("Operation: ").Append(deltaOp).Append(" ").Append(type) .Append(" mrid: ").Append(mrid) .Append(" ID: ").Append(string.Format("0x{0:X16}", negGid)) .Append(" after correction is GID: ").AppendLine($"0x{rd.Id:X16}"); }
public static long CreateGID(short systemId, DMSType type, int entityId) { unchecked { return((long)(uint)entityId | ((long)(ushort)type << 32) | ((long)(ushort)systemId << 48)); } }
private List <long> GetReferencedElementsWithoutIgnorables(long gid) { string verboseMessage = $"{baseLogString} GetReferencedElementsWithoutIgnorables method called for GID {gid:X16}."; Logger.LogVerbose(verboseMessage); List <long> refElements = new List <long>(); if (connections.TryGetValue(gid, out List <long> list)) { list = list.Where(e => !visited.Contains(e)).ToList(); foreach (var element in list) { DMSType elementType = (DMSType)ModelCodeHelper.ExtractTypeFromGlobalId(element); if (TopologyHelper.Instance.GetElementTopologyStatus(element) == TopologyStatus.Ignorable) { visited.Add(element); refElements.AddRange(GetReferencedElementsWithoutIgnorables(element)); } else if (elementType != DMSType.DISCRETE && elementType != DMSType.ANALOG && elementType != DMSType.BASEVOLTAGE) { refElements.Add(element); } } } else { Logger.LogWarning($"{baseLogString} GetReferencedElementsWithoutIgnorables => Failed to get connected elements for element with GID {gid:X16)}."); } return(refElements); }
public NodeData(IdentifiedObject identified, DMSType type, bool isroot) { this.idenetifiedObj = identified; this.isRoot = isroot; this.energized = Energized.NotEnergized; this.type = type; }
private List <long> GetAllReferencedElements(ResourceDescription element) { List <long> elements = new List <long>(); DMSType type = GetDMSTypeOfTopologyElement(element.Id); foreach (var property in GetAllReferenceProperties(type)) { if (property == ModelCode.POWERTRANSFORMER_TRANSFORMERWINDINGS || property == ModelCode.CONDUCTINGEQUIPMENT_TERMINALS || property == ModelCode.CONNECTIVITYNODE_TERMINALS || property == ModelCode.BASEVOLTAGE_CONDUCTINGEQUIPMENTS || property == ModelCode.TERMINAL_MEASUREMENTS) { elements.AddRange(element.GetProperty(property).AsReferences()); } else { var elementGid = element.GetProperty(property).AsReference(); if (elementGid != 0) { elements.Add(elementGid); } } } if (type == DMSType.TERMINAL) { TerminalToConnectedElementsMap.Add(element.Id, new List <long>(elements)); } return(elements); }
public void NotifySubscribers(DMSType dmsType) { List <Task <bool> > tasks = new List <Task <bool> >(); foreach (ISCADAForwarding client in subscribers.Keys) { if (!subscribers[client].Contains(dmsType)) { continue; } switch (dmsType) { case DMSType.ANALOGVALUE: List <AnalogValue> analogValues = SCADAModel.Instance.AnalogValues; try { client.GetAnalogScadaData(analogValues); } catch (Exception ex) { Console.WriteLine("ScadaSubscriber: {0}", ex.Message); } break; } } }
private void FindPropertyModelCode(ModelCode property) { string[] props = (property.ToString()).Split('_'); props[1] = props[1].TrimEnd('S'); DMSType propertyCode = ModelResourcesDesc.GetTypeFromModelCode(property); // DMSType propertyCode = ModelCodeHelper.GetDMSTypeFromString(property); ModelCode mc; ModelCodeHelper.GetModelCodeFromString(propertyCode.ToString(), out mc); foreach (ModelCode modelCode in Enum.GetValues(typeof(ModelCode))) { if ((String.Compare(modelCode.ToString(), mc.ToString()) != 0) && (String.Compare(property.ToString(), modelCode.ToString()) != 0) && (String.Compare(props[1], modelCode.ToString())) == 0) { DMSType type = ModelCodeHelper.GetTypeFromModelCode(modelCode); if (type == 0) { FindChildren(modelCode); } else { childrenType = new List <ModelCode>(); childrenType.Add(modelCode); } } } }
/// <summary> /// Generic method to import cim objects based on DMSType /// </summary> /// <typeparam name="T"></typeparam> /// <param name="dmsType"></param> /// <param name="typeName"></param> private void Import <T>(DMSType dmsType, string typeName) where T : IdentifiedObject { SortedDictionary <string, object> cimObjects = concreteModel.GetAllObjectsOfType(typeof(T).FullName); if (cimObjects == null) { return; } foreach (var kvp in cimObjects) { T cimObj = (T)kvp.Value; var rd = CreateResourceDescription(cimObj, dmsType); if (rd == null) { report.Report.Append($"{typeof(T).Name} ID = ").Append(cimObj.ID).AppendLine(" FAILED to be converted"); continue; } else { delta.AddDeltaOperation(DeltaOpType.Insert, rd, true); report.Report.Append($"{typeof(T).Name} ID = ").Append(cimObj.ID).Append(" SUCCESSFULLY converted to GID = ").AppendLine(rd.Id.ToString()); } report.Report.AppendLine(); } }
private async Task <ITopologyElement> CreateNoScadaMeasurementAsync(ITopologyElement element) { string verboseMessage = $"{baseLogString} entering CreateNoScadaMeasurement method."; Logger.LogVerbose(verboseMessage); DMSType dMSType = GetDMSTypeOfTopologyElement(element.Id); if (dMSType == DMSType.LOADBREAKSWITCH || dMSType == DMSType.BREAKER || dMSType == DMSType.FUSE || dMSType == DMSType.DISCONNECTOR) { ArtificalDiscreteMeasurement measurement = GetNoScadaDiscreteMeasurement(); element.Measurements.Add(measurement.Id, "SWITCH_STATUS"); measurement.ElementId = element.Id; var measurementProviderClient = MeasurementProviderClient.CreateClient(); await measurementProviderClient.AddDiscreteMeasurement(measurement); measurementProviderClient = MeasurementProviderClient.CreateClient(); await measurementProviderClient.AddMeasurementElementPair(measurement.Id, element.Id); } return(element); }
private async Task <List <long> > GetAllReferencedElements(ResourceDescription element) { string verboseMessage = $"{baseLogString} entering GetAllReferencedElements method."; Logger.LogVerbose(verboseMessage); List <long> elements = new List <long>(); DMSType type = GetDMSTypeOfTopologyElement(element.Id); foreach (var property in GetAllReferenceProperties(type)) { if (property == ModelCode.POWERTRANSFORMER_TRANSFORMERWINDINGS || property == ModelCode.CONDUCTINGEQUIPMENT_TERMINALS || property == ModelCode.CONNECTIVITYNODE_TERMINALS || property == ModelCode.BASEVOLTAGE_CONDUCTINGEQUIPMENTS || property == ModelCode.TERMINAL_MEASUREMENTS) { elements.AddRange(element.GetProperty(property).AsReferences()); } else { var elementGid = element.GetProperty(property).AsReference(); if (elementGid != 0) { elements.Add(elementGid); } } } if (type == DMSType.TERMINAL) { await TerminalToConnectedElementsMap.SetAsync(element.Id, new List <long>(elements)); } return(elements); }
/// <summary> /// Gets resource iterator that holds descriptions for all entities of the specified type. /// </summary> /// <param name="type">Type of entity that is requested</param> /// <param name="properties">List of requested properties</param> /// <returns>Resource iterator for the requested entities</returns> public ResourceIterator GetExtentValues(ModelCode entityType, List <ModelCode> properties) { CommonTrace.WriteTrace(CommonTrace.TraceVerbose, "Getting extent values for entity type = {0} .", entityType); try { List <long> globalIds = new List <long>(); Dictionary <DMSType, List <ModelCode> > class2PropertyIDs = new Dictionary <DMSType, List <ModelCode> >(); DMSType entityDmsType = ModelCodeHelper.GetTypeFromModelCode(entityType); if (ContainerExists(entityDmsType)) { Container container = GetContainer(entityDmsType); globalIds = container.GetEntitiesGlobalIds(); class2PropertyIDs.Add(entityDmsType, properties); } ResourceIterator ri = new ResourceIterator(globalIds, class2PropertyIDs); CommonTrace.WriteTrace(CommonTrace.TraceVerbose, "Getting extent values for entity type = {0} succedded.", entityType); return(ri); } catch (Exception ex) { string message = string.Format("Failed to get extent values for entity type = {0}. {1}", entityType, ex.Message); throw new Exception(message); } }
ElementView InitView() { DMSType type = ModelCodeHelper.GetTypeFromGID(GID); ModelCode mc = dmsTypeToModelCodeMap[type]; ElementView v; if (ModelCodeHelper.ModelCodeClassIsSubClassOf(mc, ModelCode.SWITCH)) { v = new SwitchView(GID, PubSub); } else if (ModelCodeHelper.ModelCodeClassIsSubClassOf(mc, ModelCode.POWERSYSTEMRESOURCE)) { v = new PowerSystemResourceView(GID, PubSub); } else if (type == DMSType.ConnectivityNode) { v = new ConnectivityNodeView(GID, PubSub); } else if (type == DMSType.Discrete || type == DMSType.Analog) { v = new MeasurementView(GID, PubSub); } else { v = new IdentifiedObjectView(GID, PubSub); } return(v); }
public GeographicalRegionTreeClass(string name, long gid, DMSType type, float min, float max) { _geographicalSubRegions = new List <GeographicalSubRegionTreeClass>(); _name = name; _gID = gid; _type = type; _minFlexibility = min; _maxFlexibility = max; }
public SubstationElementTreeClass(string name, long gid, DMSType type, float p, float min, float max) { _name = name; _gID = gid; _type = type; _p = p; _minFlexibility = min; _maxFlexibility = max; }
public DMSLogicModel(string userName, ProjectLogicModel projectLogicModel, DMSType dmsType = DMSType.PublishCooperationPlatform, string uid = "")//默认为DMS绑定Project,使用ProjectId作为Uid : base(userName, projectLogicModel) { m_dmsType = dmsType; m_uid = uid; LoadDMS(); }
public SubstationTreeClass(string name, long gid, DMSType type, float min, float max) { _substationElements = new List <SubstationElementTreeClass>(); _name = name; _gID = gid; _type = type; _minFlexibility = min; _maxFlexibility = max; }
/// <summary> /// Checks if container exists in model. /// </summary> /// <param name="type">Type of container.</param> /// <returns>True if container exists, otherwise FALSE.</returns> public bool ContainerExists(Dictionary <DMSType, Container> model, DMSType type) { if (model.ContainsKey(type)) { return(true); } return(false); }
/// <summary> /// Checks if container exists in model. /// </summary> /// <param name="type">Type of container.</param> /// <returns>True if container exists, otherwise FALSE.</returns> private bool ContainerExists(DMSType type) { if (networkDataModel.ContainsKey(type)) { return(true); } return(false); }
public DMS Create(DMSType dmsType) { var dms = new DMS(); dms.ProjectId = (int)dmsType; dms.Guid = System.Guid.NewGuid().ToString(); dms.RecordStatus = RecordStatus.Valid; dms.Id = (int)m_db.Insert(m_defaultTableName, m_defaultPrimaryKey, dms.GetTableObject()); return(dms); }
public IEnumerable <long> GetGIDsByType(DMSType type) { Dictionary <long, IdentifiedObject> container; if (!containers.TryGetValue(type, out container)) { return(null); } return(container.Keys); }
private List <ModelCode> GetAllReferenceProperties(DMSType type) { List <ModelCode> properties = new List <ModelCode>(); if (!ReferenceProperties.TryGetValue(type, out properties)) { logger.LogWarn($"[NMSManager] DMSType {type.ToString()} does not have declared reference properties."); } return(properties); }
private Container GetContainerCopy(DMSType type) { var container = new Container(); container.Entities = new Dictionary <long, IdentifiedObject>(); foreach (var item in networkDataModel[type].Entities) { container.AddEntity(item.Value); } return(container); }
private bool CheckMridExist(DMSType type, ResourceDescription rd) { if (networkDataModelCopy.ContainsKey(type)) { var typedCollection = networkDataModelCopy[type]; var objMrid = rd.Properties.Single(x => x.Id == ModelCode.IDOBJ_MRID); var result = typedCollection.Entities.Values.SingleOrDefault(x => x.MRID == objMrid.PropertyValue.StringValue); return(result != null); } return(false); }