예제 #1
0
    public bool IsConnectedToNetworks(ICollection <UtilityNetwork> networks)
    {
        int            cell           = Grid.PosToCell(base.transform.GetPosition());
        UtilityNetwork networkForCell = Game.Instance.logicCircuitSystem.GetNetworkForCell(cell);

        return(networks.Contains(networkForCell));
    }
예제 #2
0
        public static Row FetchRowFromElement(UtilityNetwork utilityNetwork, Element element)
        {
            // Get the table from the element
            using (Table table = utilityNetwork.GetTable(element.NetworkSource))
            {
                // Create a query filter to fetch the appropriate row
                QueryFilter queryFilter = new QueryFilter()
                {
                    ObjectIDs = new List <long>()
                    {
                        element.ObjectID
                    }
                };

                // Fetch and return the row
                using (RowCursor rowCursor = table.Search(queryFilter))
                {
                    if (rowCursor.MoveNext())
                    {
                        return(rowCursor.Current);
                    }
                    return(null);
                }
            }
        }
예제 #3
0
        // ValidateDataModel - This sample is hard-wired to a particular version of the Naperville data model.
        // This routine checks to make sure we are using the correct one
        private bool ValidateDataModel(UtilityNetwork utilityNetwork)
        {
            bool dataModelIsValid = false;

            try
            {
                using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition())

                    using (NetworkSource transformerBankNetworkSource = GetNetworkSource(utilityNetworkDefinition, AssemblyNetworkSourceName))
                        using (AssetGroup transformerBankAssetGroup = transformerBankNetworkSource.GetAssetGroup(TransformerBankAssetGroupName))
                            using (AssetType transformerBankAssetType = transformerBankAssetGroup.GetAssetType(TransformerBankAssetTypeName))

                                // Transformer
                                using (NetworkSource deviceNetworkSource = GetNetworkSource(utilityNetworkDefinition, DeviceNetworkSourceName))
                                    using (AssetGroup transformerAssetGroup = deviceNetworkSource.GetAssetGroup(TransformerAssetGroupName))
                                        using (AssetType transformerAssetType = transformerAssetGroup.GetAssetType(TransformerAssetTypeName))

                                            // Arrester
                                            using (AssetGroup arresterAssetGroup = deviceNetworkSource.GetAssetGroup(ArresterAssetGroupName))
                                                using (AssetType arresterAssetType = arresterAssetGroup.GetAssetType(ArresterAssetTypeName))

                                                    // Fuse
                                                    using (AssetGroup fuseAssetGroup = deviceNetworkSource.GetAssetGroup(FuseAssetGroupName))
                                                        using (AssetType fuseAssetType = fuseAssetGroup.GetAssetType(FuseAssetTypeName))
                                                        {
                                                            // Find the upstream terminal on the transformer
                                                            TerminalConfiguration terminalConfiguration = transformerAssetType.GetTerminalConfiguration();
                                                            Terminal upstreamTerminal = null;
                                                            foreach (Terminal terminal in terminalConfiguration.Terminals)
                                                            {
                                                                if (terminal.IsUpstreamTerminal)
                                                                {
                                                                    upstreamTerminal = terminal;
                                                                    break;
                                                                }
                                                            }

                                                            // Find the terminal on the fuse
                                                            Terminal fuseTerminal = fuseAssetType.GetTerminalConfiguration().Terminals[0];

                                                            // Find the terminal on the arrester
                                                            Terminal arresterTerminal = arresterAssetType.GetTerminalConfiguration().Terminals[0];

                                                            // All of our asset groups and asset types exist.  Now we have to check for rules.

                                                            IReadOnlyList <Rule> rules = utilityNetworkDefinition.GetRules();
                                                            if (ContainmentRuleExists(rules, transformerBankAssetType, transformerAssetType) &&
                                                                ContainmentRuleExists(rules, transformerBankAssetType, fuseAssetType) &&
                                                                ContainmentRuleExists(rules, transformerBankAssetType, arresterAssetType) &&
                                                                ConnectivityRuleExists(rules, transformerAssetType, upstreamTerminal, fuseAssetType, fuseTerminal) &&
                                                                ConnectivityRuleExists(rules, fuseAssetType, fuseTerminal, arresterAssetType, arresterTerminal))
                                                            {
                                                                dataModelIsValid = true;
                                                            }
                                                        }
            }
            catch { }

            return(dataModelIsValid);
        }
예제 #4
0
        public void EditOperation(UtilityNetwork utilityNetwork, AssetType poleAssetType, Guid poleGlobalID, AssetType transformerBankAssetType, Guid transformerBankGlobalID)
        {
            #region Create a utility network association

            // Create edit operation

            EditOperation editOperation = new EditOperation();
            editOperation.Name = "Create structural attachment association";

            // Create a RowHandle for the pole

            Element   poleElement   = utilityNetwork.CreateElement(poleAssetType, poleGlobalID);
            RowHandle poleRowHandle = new RowHandle(poleElement, utilityNetwork);

            // Create a RowHandle for the transformer bank

            Element   transformerBankElement   = utilityNetwork.CreateElement(transformerBankAssetType, transformerBankGlobalID);
            RowHandle transformerBankRowHandle = new RowHandle(transformerBankElement, utilityNetwork);

            // Attach the transformer bank to the pole

            StructuralAttachmentAssociationDescription structuralAttachmentAssociationDescription = new StructuralAttachmentAssociationDescription(poleRowHandle, transformerBankRowHandle);
            editOperation.Create(structuralAttachmentAssociationDescription);
            editOperation.Execute();

            #endregion
        }
예제 #5
0
        public List <NetworkDiagram> GetInconsistentDiagrams(UtilityNetwork utilityNetwork)
        {
            // Get the DiagramManager from the utility network

            using (DiagramManager diagramManager = utilityNetwork.GetDiagramManager())
            {
                List <NetworkDiagram> myList = new List <NetworkDiagram>();

                // Loop through the network diagrams in the diagram manager

                foreach (NetworkDiagram diagram in diagramManager.GetNetworkDiagrams())
                {
                    NetworkDiagramInfo diagramInfo = diagram.GetDiagramInfo();

                    // If the diagram is not a system diagram and is in an inconsistent state, add it to our list

                    if (!diagramInfo.IsSystem && diagram.GetConsistencyState() != NetworkDiagramConsistencyState.DiagramIsConsistent)
                    {
                        myList.Add(diagram);
                    }
                    else
                    {
                        diagram.Dispose(); // If we are not returning it we need to Dispose it
                    }
                }

                return(myList);
            }
        }
        /// <summary>
        /// Get the UtilityNetwork from active Map
        /// </summary>
        /// <returns>UtilityNetwork</returns>
        internal static UtilityNetwork GetUtilityNetworkFromActiveMap()
        {
            var unLayers = MapView.Active?.Map?.GetLayersAsFlattenedList().OfType <UtilityNetworkLayer>();

            if (unLayers == null || !unLayers.Any())
            {
                var dlLayers = MapView.Active?.Map?.GetLayersAsFlattenedList().OfType <DiagramLayer>();
                if (dlLayers == null)
                {
                    return(null);
                }

                foreach (var dlLayer in dlLayers)
                {
                    NetworkDiagram diagram = dlLayer.GetNetworkDiagram();
                    DiagramManager dm      = diagram.DiagramManager;
                    UtilityNetwork un      = dm.GetNetwork <UtilityNetwork>();
                    if (un != null)
                    {
                        return(un);
                    }
                }
            }

            foreach (var unLayer in unLayers)
            {
                UtilityNetwork un = unLayer.GetUtilityNetwork();
                if (un != null)
                {
                    return(un);
                }
            }

            return(null);
        }
        /// <summary>
        /// Set Enclosure flag
        /// </summary>
        /// <param name="obj">ActiveMapViewChangedEventArgs</param>
        private void OnActiveMapViewChanged(ActiveMapViewChangedEventArgs obj)
        {
            if (obj == null || obj.IncomingView == null || obj.IncomingView.Map == null)
            {
                FrameworkApplication.State.Deactivate(EnableEnclosure);
                return;
            }

            QueuedTask.Run(() =>
            {
                using UtilityNetwork un = GetUtilityNetworkFromActiveMap();
                using DiagramManager dm = un?.GetDiagramManager();
                try
                {
                    DiagramTemplate dt = dm?.GetDiagramTemplate(csTemplateName);
                    if (dt == null)
                    {
                        FrameworkApplication.State.Deactivate(EnableEnclosure);
                    }
                    else
                    {
                        FrameworkApplication.State.Activate(EnableEnclosure);
                    }
                }
                catch
                {
                    FrameworkApplication.State.Deactivate(EnableEnclosure);
                }
            });
        }
    public bool IsConnectedToNetworks(ICollection <UtilityNetwork> networks)
    {
        GetCells(out int linked_cell, out int _);
        IUtilityNetworkMgr networkManager = GetNetworkManager();
        UtilityNetwork     networkForCell = networkManager.GetNetworkForCell(linked_cell);

        return(networks.Contains(networkForCell));
    }
예제 #9
0
        private int GetConnectedNetworkID()
        {
            GameObject     gameObject     = Grid.Objects[this.utilityCell, 20];
            SolidConduit   solidConduit   = (UnityEngine.Object)gameObject != (UnityEngine.Object)null ? gameObject.GetComponent <SolidConduit>() : (SolidConduit)null;
            UtilityNetwork utilityNetwork = (UnityEngine.Object)solidConduit != (UnityEngine.Object)null ? solidConduit.GetNetwork() : (UtilityNetwork)null;

            return(utilityNetwork == null ? -1 : utilityNetwork.id);
        }
        private async void Initialize()
        {
            try
            {
                _progressBar.Visibility = Android.Views.ViewStates.Visible;
                _status.Text = "Loading Utility Network...";

                // Create a map.
                _myMapView.Map = new Map(new Basemap(new Uri("https://www.arcgis.com/home/item.html?id=1970c1995b8f44749f4b9b6e81b5ba45")))
                {
                    InitialViewpoint = _startingViewpoint
                };

                // Add the layer with electric distribution lines.
                FeatureLayer lineLayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/115"));
                UniqueValue mediumVoltageValue = new UniqueValue("N/A", "Medium Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Solid, System.Drawing.Color.DarkCyan, 3), 5);
                UniqueValue lowVoltageValue = new UniqueValue("N/A", "Low Voltage", new SimpleLineSymbol(SimpleLineSymbolStyle.Dash, System.Drawing.Color.DarkCyan, 3), 3);
                lineLayer.Renderer = new UniqueValueRenderer(new List<string>() { "ASSETGROUP" }, new List<UniqueValue>() { mediumVoltageValue, lowVoltageValue }, "", new SimpleLineSymbol());
                _myMapView.Map.OperationalLayers.Add(lineLayer);

                // Add the layer with electric devices.
                FeatureLayer electricDevicelayer = new FeatureLayer(new Uri($"{FeatureServiceUrl}/100"));
                _myMapView.Map.OperationalLayers.Add(electricDevicelayer);

                // Set the selection color for features in the map view.
                _myMapView.SelectionProperties = new SelectionProperties(System.Drawing.Color.Yellow);

                // Create and load the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl), _myMapView.Map);

                // Get the utility tier used for traces in this network. For this data set, the "Medium Voltage Radial" tier from the "ElectricDistribution" domain network is used.
                UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork("ElectricDistribution");
                _mediumVoltageTier = domainNetwork.GetTier("Medium Voltage Radial");

                // More complex datasets may require using utility trace configurations from different tiers. The following LINQ expression gets all tiers present in the utility network.
                //IEnumerable<UtilityTier> tiers = _utilityNetwork.Definition.DomainNetworks.Select(domain => domain.Tiers).SelectMany(tier => tier);

                // Create symbols for starting locations and barriers.
                _startingPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.Cross, System.Drawing.Color.LightGreen, 25d);
                _barrierPointSymbol = new SimpleMarkerSymbol(SimpleMarkerSymbolStyle.X, System.Drawing.Color.OrangeRed, 25d);

                // Create a graphics overlay.
                GraphicsOverlay graphicsOverlay = new GraphicsOverlay();
                _myMapView.GraphicsOverlays.Add(graphicsOverlay);

                // Set the instruction text.
                _status.Text = "Tap on the network lines or points to add a utility element.";
            }
            catch (Exception ex)
            {
                _status.Text = "Loading Utility Network failed...";
                CreateDialog(ex.Message, title: ex.GetType().Name);
            }
            finally
            {
                _progressBar.Visibility = Android.Views.ViewStates.Invisible;
            }
        }
예제 #11
0
        /// <summary>
        /// Get the Un Schema version
        /// </summary>
        /// <param name="diagram">NetworkDiagram</param>
        /// <returns>string</returns>
        /// <remarks>UN Version 3 and earlier use only Subnetwork name
        /// UN Version 4 and later use Supported subnetwork name for container
        /// UN Version 5 and later use Supporting subnetwork name for structure</remarks>
        internal static int GetSchemaVersion(NetworkDiagram diagram)
        {
            DiagramManager diagramManager = diagram.DiagramManager;
            UtilityNetwork utilityNetwork = diagramManager.GetNetwork <UtilityNetwork>();

            UtilityNetworkDefinition unDefinition = utilityNetwork.GetDefinition();

            return(Convert.ToInt32(unDefinition.GetSchemaVersion()));
        }
예제 #12
0
    public void AddNetworks(ICollection <UtilityNetwork> networks)
    {
        UtilityNetwork networkForCell = GetNetworkManager().GetNetworkForCell(Grid.PosToCell(this));

        if (networkForCell != null)
        {
            networks.Add(networkForCell);
        }
    }
예제 #13
0
 // we have to expand the `wireGroups` array out to be big enough
 private static void Postfix(UtilityNetwork __instance)
 {
     Debug.Log(__instance.GetType().FullName);
     if (__instance is LogicCircuitNetwork)
     {
         Debug.LogFormat("Updating logic circuit network wireGroups to length of {0} (via ctor)", Mod.MAX_WIRE_TYPES);
         Traverse.Create(__instance).Field("wireGroups").SetValue(new List <LogicWire> [Mod.MAX_WIRE_TYPES]);
     }
 }
예제 #14
0
        /// <summary>
        /// GetUtilityNetworkFromFeatureClass - gets a utility network from a layer
        /// </summary>
        /// <param name="layer"></param>
        /// <returns>a UtilityNetwork object, or null if the layer does not reference a utility network</returns>
        public static UtilityNetwork GetUtilityNetworkFromLayer(Layer layer)
        {
            UtilityNetwork utilityNetwork = null;

            if (layer is UtilityNetworkLayer)
            {
                UtilityNetworkLayer utilityNetworkLayer = layer as UtilityNetworkLayer;
                utilityNetwork = utilityNetworkLayer.GetUtilityNetwork();
            }

            else if (layer is SubtypeGroupLayer)
            {
                CompositeLayer compositeLayer = layer as CompositeLayer;
                utilityNetwork = GetUtilityNetworkFromLayer(compositeLayer.Layers.First());
            }

            else if (layer is FeatureLayer)
            {
                FeatureLayer featureLayer = layer as FeatureLayer;
                using (FeatureClass featureClass = featureLayer.GetFeatureClass())
                {
                    if (featureClass.IsControllerDatasetSupported())
                    {
                        IReadOnlyList <Dataset> controllerDatasets = new List <Dataset>();
                        controllerDatasets = featureClass.GetControllerDatasets();
                        foreach (Dataset controllerDataset in controllerDatasets)
                        {
                            if (controllerDataset is UtilityNetwork)
                            {
                                utilityNetwork = controllerDataset as UtilityNetwork;
                            }
                            else
                            {
                                controllerDataset.Dispose();
                            }
                        }
                    }
                }
            }

            else if (layer is GroupLayer)
            {
                CompositeLayer compositeLayer = layer as CompositeLayer;
                foreach (Layer childLayer in compositeLayer.Layers)
                {
                    utilityNetwork = GetUtilityNetworkFromLayer(childLayer);
                    // Break at the first layer inside a group layer that belongs to a utility network
                    if (utilityNetwork != null)
                    {
                        break;
                    }
                }
            }

            return(utilityNetwork);
        }
예제 #15
0
    public void AddNetworks(ICollection <UtilityNetwork> networks)
    {
        int            cell           = Grid.PosToCell(base.transform.GetPosition());
        UtilityNetwork networkForCell = Game.Instance.logicCircuitSystem.GetNetworkForCell(cell);

        if (networkForCell != null)
        {
            networks.Add(networkForCell);
        }
    }
예제 #16
0
        /// <summary>
        /// Get the active geodatabase fom the active map
        /// </summary>
        /// <returns>Geodatabase</returns>
        private static Geodatabase GetGeodatabaseFromActiveMap()
        {
            UtilityNetwork un = GetUtilityNetworkFromActiveMap();

            if (un != null)
            {
                return(un.GetDatastore() as Geodatabase);
            }

            return(null);
        }
    public void AddNetworks(ICollection <UtilityNetwork> networks)
    {
        GetCells(out int linked_cell, out int _);
        IUtilityNetworkMgr networkManager = GetNetworkManager();
        UtilityNetwork     networkForCell = networkManager.GetNetworkForCell(linked_cell);

        if (networkForCell != null)
        {
            networks.Add(networkForCell);
        }
    }
        /// <summary>
        /// This method makes sure
        /// 1. The Mapview is Active
        /// 2. There is at least one layer selected
        /// 3. That layer is either
        ///   a. A utility network layer
        ///   b. A feature layer whose feature class belongs to a utility network
        ///   c. A subtype group layer whose feature class belongs to a utility network
        ///
        /// If all of these hold true, we populate the combo box with the list of categories that are registered with this utility network
        /// </summary>
        private async void UpdateCategoryList(MapViewEventArgs mapViewEventArgs)
        {
            // Verify that the map view is active and at least one layer is selected
            if (MapView.Active == null ||
                mapViewEventArgs.MapView.GetSelectedLayers().Count < 1)
            {
                Enabled = false;
                return;
            }

            // Verify that we have the correct kind of layer
            Layer selectedLayer = mapViewEventArgs.MapView.GetSelectedLayers()[0];

            if (!(selectedLayer is UtilityNetworkLayer) && !(selectedLayer is FeatureLayer) && !(selectedLayer is SubtypeGroupLayer))
            {
                Enabled = false;
                return;
            }

            // Switch to the MCT to access the geodatabase
            await QueuedTask.Run(() =>
            {
                // Get the utility network from the layer.
                // It's possible that the layer is a FeatureLayer or SubtypeGroupLayer that doesn't refer to a utility network at all.
                using (UtilityNetwork utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(selectedLayer))
                {
                    if (utilityNetwork == null)
                    {
                        Enabled = false;
                        return;
                    }

                    // Enable the combo box and clear out its contents
                    Enabled = true;
                    Clear();

                    // Fill the combo box with all of the categories in the utility network
                    using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition())
                    {
                        IReadOnlyList <string> categories = utilityNetworkDefinition.GetAvailableCategories();
                        foreach (string category in categories)
                        {
                            Add(new ComboBoxItem(category));
                        }
                    }
                }
            });

            // Store the layer
            if (Enabled)
            {
                myLayer = selectedLayer;
            }
        }
        protected override async void OnClick()
        {
            try
            {
                string unLayerName = "Electric Utility Network";
                Layer  unLayer     = await GetLayerByName(MapView.Active.Map, unLayerName);

                UtilityNetwork utilityNetwork = await GetUNByLayer(unLayer);

                QueuedTask.Run(() =>
                {
                    UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition();

                    /* Uncomment to print out the network attributes in the utlity network
                     * IReadOnlyList<NetworkAttribute> networkAttributes = utilityNetworkDefinition.GetNetworkAttributes();
                     * string attributesMessage = "Network attributes: " + Environment.NewLine;
                     * foreach (var networkAttribute in networkAttributes)
                     * {
                     *  attributesMessage += networkAttribute.Name + Environment.NewLine;
                     * }
                     * MessageBox.Show(attributesMessage);
                     */

                    /* Uncomment to print out the categories in the utlity network
                     * IReadOnlyList<string> categories = utilityNetworkDefinition.GetAvailableCategories();
                     * string categoriesMsg = "Categories: " + Environment.NewLine;
                     * foreach (var category in categories)
                     * {
                     *  categoriesMsg += category + Environment.NewLine;
                     * }
                     * MessageBox.Show(categoriesMsg);
                     */

                    string result = $"Domain Networks: {Environment.NewLine}";
                    IReadOnlyList <DomainNetwork> domainNetworks = utilityNetworkDefinition.GetDomainNetworks();
                    if (domainNetworks != null)
                    {
                        foreach (DomainNetwork domainNetwork in domainNetworks)
                        {
                            result += $"{domainNetwork.Name}{Environment.NewLine}";
                        }
                    }
                    else
                    {
                        result += "No domain networks found";
                    }
                    MessageBox.Show(result);
                }).Wait();
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An exception occurred: {ex.Message}");
            }
        }
        private async void Initialize()
        {
            try
            {
                Configuration.IsEnabled = false;

                // Create and load the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl));

                // Build the choice lists for network attribute comparison.
                Attributes.ItemsSource = _utilityNetwork.Definition.NetworkAttributes.Where(netattr => !netattr.IsSystemDefined);
                Operators.ItemsSource  = Enum.GetValues(typeof(UtilityAttributeComparisonOperator));

                // Create a default starting location.
                UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName);
                UtilityAssetGroup    assetGroup    = networkSource.GetAssetGroup(AssetGroupName);
                UtilityAssetType     assetType     = assetGroup.GetAssetType(AssetTypeName);
                Guid globalId = Guid.Parse(GlobalId);
                _startingLocation = _utilityNetwork.CreateElement(assetType, globalId);

                // Set the terminal for this location. (For our case, we use the 'Load' terminal.)
                _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load");

                // Get a default trace configuration from a tier to update the UI.
                UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName);
                UtilityTier          sourceTier    = domainNetwork.GetTier(TierName);

                // Set the trace configuration.
                _configuration = sourceTier.TraceConfiguration;

                // Set the default expression (if provided).
                if (sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression)
                {
                    ConditionBarrierExpression.Text = ExpressionToString(expression);
                    _initialExpression = expression;
                }

                // Setting DataContext will resolve the data-binding in XAML.
                Configuration.DataContext = _configuration;

                // Set the traversability scope.
                sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, ex.Message.GetType().Name, MessageBoxButton.OK, MessageBoxImage.Error);
            }
            finally
            {
                Configuration.IsEnabled = true;
            }
        }
예제 #21
0
        /// <summary>
        /// Retrieve the Utility Network from a map
        /// </summary>
        /// <param name="SearchMap">Map</param>
        /// <param name="SearchConnection">Connection to the database</param>
        /// <param name="UN">The utility Network found</param>
        /// <param name="SubnetLayers">Subnetwork layer list</param>
        /// <param name="NameFieldSubNet">Subnetwork field name</param>
        /// <returns>true if found</returns>
        internal static bool GetUNFromMap(Map SearchMap, string SearchConnection, ref UtilityNetwork UN, ref List <FeatureLayer> SubnetLayers, ref string NameFieldSubNet)
        {
            UtilityNetwork unSearch = GetUtilityNetworkFromActiveMap(SearchMap);

            if (unSearch == null)
            {
                return(false);
            }

            bool bFound = false;

            string unConnect = ((Geodatabase)unSearch.GetDatastore()).GetConnectionString();

            bFound = (unConnect == SearchConnection);

            if (bFound)
            {
                if (UN == null)
                {
                    UN = unSearch;
                }

                Table subnetTable = UN.GetSystemTable(SystemTableType.Subnetworks);

                IReadOnlyList <Field> listField;

                if (String.IsNullOrEmpty(NameFieldSubNet))
                {
                    listField = subnetTable.GetDefinition().GetFields();

                    Field FieldSubNetName = listField.FirstOrDefault(a => a.Name.ToLower() == "subnetworkname");
                    NameFieldSubNet = FieldSubNetName?.Name;
                }

                IReadOnlyList <Layer> listLayers = SearchMap.GetLayersAsFlattenedList();
                foreach (Layer l in listLayers)
                {
                    if (l is FeatureLayer fl && fl.ShapeType == esriGeometryType.esriGeometryPolyline)
                    {
                        listField = fl.GetTable().GetDefinition().GetFields();

                        Field field = listField.FirstOrDefault(a => a.Name.ToLower() == "subnetworkcontrollernames"); // only subnetwork table contains tiername
                        if (field != null)
                        {
                            SubnetLayers.Add(fl);
                        }
                    }
                }
            }

            return(bFound && SubnetLayers.Count > 0);
        }
예제 #22
0
        void FindATierFromDomainNetworkNameAndTierName(UtilityNetwork utilityNetwork, string domainNetworkName, string tierName)
        {
            #region Find a Tier given a Domain Network name and Tier name

            using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition())
            {
                DomainNetwork domainNetwork = utilityNetworkDefinition.GetDomainNetwork(domainNetworkName);
                Tier          tier          = domainNetwork.GetTier(tierName);
            }


            #endregion
        }
예제 #23
0
        // Get the Utility Network from the currently active layer
        private UtilityNetwork GetUtilityNetwork()
        {
            UtilityNetwork utilityNetwork = null;

            if (MapView.Active != null)
            {
                IReadOnlyList <Layer> selectedLayers = MapView.Active.GetSelectedLayers();
                if (selectedLayers.Count > 0)
                {
                    utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(selectedLayers[0]);
                }
            }
            return(utilityNetwork);
        }
예제 #24
0
        void CreateADownstreamTracerObject(UtilityNetwork utilityNetwork)

        {
            #region Create a DownstreamTracer

            using (TraceManager traceManager = utilityNetwork.GetTraceManager())
            {
                DownstreamTracer downstreamTracer = traceManager.GetTracer <DownstreamTracer>();
            }



            #endregion
        }
        protected override async void OnClick()
        {
            try
            {
                string unLayerName = "Electric Utility Network";
                Layer  unLayer     = await GetLayerByName(MapView.Active.Map, unLayerName);

                UtilityNetwork utilityNetwork = await GetUNByLayer(unLayer);
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An exception occurred: {ex.Message}");
            }
        }
예제 #26
0
        private async void Initialize()
        {
            try
            {
                // Disable interaction until the data is loaded.
                _mainView.Visibility = ViewStates.Gone;

                // Create and load the utility network.
                _utilityNetwork = await UtilityNetwork.CreateAsync(new Uri(FeatureServiceUrl));

                // Getthe attributes in the utility network.
                _attributes = _utilityNetwork.Definition.NetworkAttributes.Where(netattr => !netattr.IsSystemDefined);

                // Create a default starting location.
                UtilityNetworkSource networkSource = _utilityNetwork.Definition.GetNetworkSource(DeviceTableName);
                UtilityAssetGroup    assetGroup    = networkSource.GetAssetGroup(AssetGroupName);
                UtilityAssetType     assetType     = assetGroup.GetAssetType(AssetTypeName);
                Guid globalId = Guid.Parse(GlobalId);
                _startingLocation = _utilityNetwork.CreateElement(assetType, globalId);

                // Set the terminal for this location. (For our case, we use the 'Load' terminal.)
                _startingLocation.Terminal = _startingLocation.AssetType.TerminalConfiguration?.Terminals.FirstOrDefault(term => term.Name == "Load");

                // Get a default trace configuration from a tier to update the UI.
                UtilityDomainNetwork domainNetwork = _utilityNetwork.Definition.GetDomainNetwork(DomainNetworkName);
                _sourceTier = domainNetwork.GetTier(TierName);

                // Set the trace configuration.
                _configuration = _sourceTier.TraceConfiguration;

                // Set the default expression (if provided).
                if (_sourceTier.TraceConfiguration.Traversability.Barriers is UtilityTraceConditionalExpression expression)
                {
                    _initialExpression    = expression;
                    _expressionLabel.Text = ExpressionToString(_initialExpression);
                }

                // Set the traversability scope.
                _sourceTier.TraceConfiguration.Traversability.Scope = UtilityTraversabilityScope.Junctions;
            }
            catch (Exception ex)
            {
                new AlertDialog.Builder(this).SetMessage(ex.Message).SetTitle(ex.GetType().Name).Show();
            }
            finally
            {
                _mainView.Visibility = ViewStates.Visible;
            }
        }
예제 #27
0
        void UpdateAllDirtySubnetworks(UtilityNetwork utilityNetwork, Tier tier, MapView mapView)
        {
            #region Update all dirty subnetworks in a tier

            using (SubnetworkManager subnetworkManager = utilityNetwork.GetSubnetworkManager())
            {
                subnetworkManager.UpdateAllSubnetworks(tier, true);

                mapView.Redraw(true);
            }



            #endregion
        }
예제 #28
0
    public void AddNetworks(ICollection <UtilityNetwork> networks)
    {
        IUtilityNetworkMgr networkManager = Conduit.GetNetworkManager(type);
        UtilityNetwork     networkForCell = networkManager.GetNetworkForCell(inputCell);

        if (networkForCell != null)
        {
            networks.Add(networkForCell);
        }
        networkForCell = networkManager.GetNetworkForCell(outputCell);
        if (networkForCell != null)
        {
            networks.Add(networkForCell);
        }
    }
예제 #29
0
        // Get the Utility Network from the currently active layer
        private UtilityNetwork GetUtilityNetwork()
        {
            UtilityNetwork utilityNetwork = null;

            if (MapView.Active != null)
            {
                MapViewEventArgs      mapViewEventArgs = new MapViewEventArgs(MapView.Active);
                IReadOnlyList <Layer> selectedLayers   = mapViewEventArgs.MapView.GetSelectedLayers();
                if (selectedLayers.Count > 0)
                {
                    utilityNetwork = UtilityNetworkUtils.GetUtilityNetworkFromLayer(selectedLayers[0]);
                }
            }
            return(utilityNetwork);
        }
예제 #30
0
        protected override async void OnClick()
        {
            try
            {
                string unLayerName       = "Electric Utility Network";
                string domainNetworkName = "ElectricTransmission";
                string tierName          = "AC High Voltage";
                Layer  unLayer           = await GetLayerByName(MapView.Active.Map, unLayerName);

                UtilityNetwork utilityNetwork = await GetUNByLayer(unLayer);

                await QueuedTask.Run(() =>
                {
                    using (UtilityNetworkDefinition utilityNetworkDefinition = utilityNetwork.GetDefinition())
                    {
                        DomainNetwork domainNetwork = utilityNetworkDefinition.GetDomainNetwork(domainNetworkName);
                        Tier tier = domainNetwork.GetTier(tierName);

                        using (SubnetworkManager subnetworkManager = utilityNetwork.GetSubnetworkManager())
                        {
                            Subnetwork dirtySubnetwork = subnetworkManager.GetSubnetworks(tier, SubnetworkStates.Dirty).FirstOrDefault();
                            try
                            {
                                if (dirtySubnetwork != null)
                                {
                                    SubnetworkController subnetworkController = dirtySubnetwork.GetControllers().First();
                                    subnetworkManager.DisableControllerInEditOperation(subnetworkController.Element);
                                    utilityNetwork.ValidateNetworkTopologyInEditOperation();
                                    dirtySubnetwork.Update();

                                    // Redraw map and clear cache
                                    MapView.Active.Redraw(true);
                                }
                            }
                            catch (Exception ex)
                            {
                                MessageBox.Show(ex.Message);
                            }
                        }
                    }
                    // utilityNetwork.ValidateNetworkTopology();
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show($"An exception occurred: {ex.Message}");
            }
        }