Exemplo n.º 1
0
    /// <summary>
    /// OnAfterRenderAsync 方法
    /// </summary>
    /// <param name="firstRender"></param>
    /// <returns></returns>
    protected override async Task OnAfterRenderAsync(bool firstRender)
    {
        if (firstRender)
        {
            Interop = new JSInterop <Topologies>(JSRuntime);
            await Interop.InvokeVoidAsync(this, null, "bb_topology_demo", nameof(ToggleFan));

            // 推送数据
            var data = DataService.GetDatas();
            await TopologyElement.PushData(data);

            // 数据订阅
            DataService.OnDataChange = async datas => await TopologyElement.PushData(datas);
        }
    }
Exemplo n.º 2
0
        public void FindClosestElement()
        {
            using (Geodatabase geodatabase = new Geodatabase(new FileGeodatabaseConnectionPath(new Uri(@"C:\TestData\GrandTeton.gdb"))))
                using (Topology topology = geodatabase.OpenDataset <Topology>("Backcountry_Topology"))
                {
                    // Build a topology graph using the extent of the topology dataset.

                    topology.BuildGraph(topology.GetExtent(), (topologyGraph) =>
                    {
                        MapPoint queryPointViaCampsites12 = null;

                        using (Feature campsites12 = GetFeature(geodatabase, "Campsites", 12))
                        {
                            queryPointViaCampsites12 = campsites12.GetShape() as MapPoint;
                        }

                        double searchRadius = 1.0;

                        TopologyElement topologyElementViaCampsites12 = topologyGraph.FindClosestElement <TopologyElement>(queryPointViaCampsites12, searchRadius);

                        System.Diagnostics.Debug.Assert(topologyElementViaCampsites12 != null, "There should be a topology element corresponding to 'queryPointViaCampsites12' within the 'searchRadius' units.");

                        IReadOnlyList <FeatureInfo> parentFeatures = topologyElementViaCampsites12.GetParentFeatures();

                        Console.WriteLine("The parent features that spawn 'topologyElementViaCampsites12' are:");
                        foreach (FeatureInfo parentFeature in parentFeatures)
                        {
                            Console.WriteLine($"\t{parentFeature.FeatureClassName}; OID: {parentFeature.ObjectID}");
                        }

                        TopologyNode topologyNodeViaCampsites12 = topologyGraph.FindClosestElement <TopologyNode>(queryPointViaCampsites12, searchRadius);

                        if (topologyNodeViaCampsites12 != null)
                        {
                            // There exists a TopologyNode nearest to the query point within searchRadius units.
                        }

                        TopologyEdge topologyEdgeViaCampsites12 = topologyGraph.FindClosestElement <TopologyEdge>(queryPointViaCampsites12, searchRadius);

                        if (topologyEdgeViaCampsites12 != null)
                        {
                            // There exists a TopologyEdge nearest to the query point within searchRadius units.
                        }
                    });
                }
        }
        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);
        }
        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);
        }