Get a server-defined trace configuration for a given tier and modify its traversability scope, add new condition barriers and control what is included in the subnetwork trace result.
Use case
While some traces are built from an ad-hoc group of parameters, many are based on a variation of the trace configuration taken from the subnetwork definition. For example, an electrical trace will be based on the trace configuration of the subnetwork, but may add additional clauses to constrain the trace along a single phase. Similarly, a trace in a gas or electric design application may include features with a status of "In Design" that are normally excluded from trace results.
How to use the sample
The sample loads with a server-defined trace configuration from a tier. Check or uncheck which options to include in the trace - such as containers or barriers. Use the selection boxes to define a new condition network attribute comparison, and then use 'Add' to add the it to the trace configuration. Click 'Trace' to run a subnetwork trace with this modified configuration from a default starting location.
Example barrier conditions for the default dataset:
- 'Transformer Load' Equal '15'
- 'Phases Current' DoesNotIncludeTheValues 'A'
- 'Generation KW' LessThan '50'
How it works
- Create and load a
UtilityNetwork
with a feature service URL, then get an asset type and a tier by their names. - Populate the choice list for the comparison source with the non-system defined
Definition.NetworkAttributes
. Populate the choice list for the comparison operator with the enum values fromUtilityAttributeComparisonOperator
. - Create a
UtilityElement
from this asset type to use as the starting location for the trace. - Update the selected barrier expression and the checked options in the UI using this tier's
TraceConfiguration
. - When 'Network Attribute' is selected, if its
Domain
is aCodedValueDomain
, populate the choice list for the comparison value with itsCodedValues
. Otherwise, display a free-form textbox for entering an attribute value. - When 'Add' is clicked, create a new
UtilityNetworkAttributeComparison
using the selected comparison source, operator, and selected or typed value. Use the selected source'sNetworkAttribute.DataType
to convert the comparison value to the correct data type. - If the Traversability's list of
Barriers
is not empty, create aUtilityTraceOrCondition
with the existingBarriers
and the new comparison from Step 6. - When 'Trace' is clicked, create
UtilityTraceParameters
passing inUtilityTraceType.Subnetwork
and the default starting location. Set itsTraceConfiguration
with the modified options, selections, and expression; then run aUtilityNetwork.TraceAsync
. - When
Reset
is clicked, set the trace configurations expression back to its original value. - Display the count of returned
UtilityElementTraceResult.Elements
.
Relevant API
- CodedValueDomain
- UtilityAssetType
- UtilityAttributeComparisonOperator
- UtilityCategory
- UtilityCategoryComparison
- UtilityCategoryComparisonOperator
- UtilityDomainNetwork
- UtilityElement
- UtilityElementTraceResult
- UtilityNetwork
- UtilityNetworkAttribute
- UtilityNetworkAttributeComparison
- UtilityNetworkDefinition
- UtilityTerminal
- UtilityTier
- UtilityTraceAndCondition
- UtilityTraceConfiguration
- UtilityTraceOrCondition
- UtilityTraceParameters
- UtilityTraceResult
- UtilityTraceType
- UtilityTraversability
About the data
The Naperville electrical network feature service, hosted on ArcGIS Online, contains a utility network used to run the subnetwork-based trace shown in this sample.
Additional information
Using utility network on ArcGIS Enterprise 10.8 requires an ArcGIS Enterprise member account licensed with the Utility Network user type extension. Please refer to the utility network services documentation.
Tags
category comparison, condition barriers, network analysis, network attribute comparison, subnetwork trace, trace configuration, traversability, utility network, validate consistency
Sample Code
<UserControl x:Class="ArcGISRuntime.WinUI.Samples.ConfigureSubnetworkTrace.ConfigureSubnetworkTrace"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid x:Name="Configuration" Background="LightGray">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<!-- Row 1 -->
<TextBlock Grid.Row="0"
Grid.Column="0"
Margin="5"
HorizontalAlignment="Right"
FontSize="15"
FontWeight="SemiBold"
Text="Trace options:" />
<!-- NOTE that There are also: IncludeContent, IncludeStructures, IgnoreBarriersAtStartingPoints, ValidateConsistency -->
<CheckBox Grid.Column="1"
Margin="5"
Content="Include Barriers"
FontSize="15"
IsChecked="{Binding IncludeBarriers}" />
<CheckBox Grid.Column="2"
Margin="5"
Content="Include Containers"
FontSize="15"
IsChecked="{Binding IncludeContainers}" />
<!-- Row 2 -->
<TextBlock Grid.Row="1"
Grid.ColumnSpan="4"
HorizontalAlignment="Center"
FontSize="15"
Text="Example barrier condition for this data: 'Transformer Load' Equal '15'" />
<!-- Row 3 -->
<TextBlock Grid.Row="2"
Grid.Column="0"
Margin="5"
HorizontalAlignment="Right"
FontSize="15"
FontWeight="SemiBold"
Text="Define new condition:" />
<ComboBox x:Name="Attributes"
Grid.Row="2"
Grid.Column="1"
Width="175"
Margin="5"
SelectionChanged="OnAttributeChanged">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<ComboBox x:Name="Operators"
Grid.Row="2"
Grid.Column="2"
Width="150"
Margin="5" />
<ComboBox x:Name="ValueSelection"
Grid.Row="2"
Grid.Column="3"
Width="125"
Margin="5"
Visibility="Collapsed">
<ComboBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Name}" />
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
<TextBox x:Name="ValueEntry"
Grid.Row="2"
Grid.Column="3"
Width="125"
Margin="5"
Visibility="Visible" />
<Button Grid.Row="2"
Grid.Column="4"
Margin="5"
HorizontalAlignment="Stretch"
Click="OnAddCondition"
Content="Add"
FontSize="15" />
<!-- Row 4 -->
<TextBlock Grid.Row="3"
Grid.Column="0"
Margin="5"
HorizontalAlignment="Right"
FontSize="15"
FontWeight="SemiBold"
Text="Barrier conditions:" />
<Grid Grid.Row="3"
Grid.Column="1"
Grid.ColumnSpan="4"
Margin="5"
Background="White">
<TextBlock x:Name="ConditionBarrierExpression"
Margin="5"
FontSize="15"
TextTrimming="WordEllipsis"
TextWrapping="WrapWholeWords" />
</Grid>
<!-- Row 5 -->
<Button Grid.Row="4"
Grid.ColumnSpan="3"
Margin="5"
HorizontalAlignment="Stretch"
Click="OnTrace"
Content="Trace"
FontSize="15" />
<Button Grid.Row="4"
Grid.Column="3"
Grid.ColumnSpan="2"
Margin="5"
HorizontalAlignment="Stretch"
Click="OnReset"
Content="Reset"
FontSize="15" />
</Grid>
</UserControl>