Create load report

View on GitHub

Create a simple electric distribution report that displays the count of customers and total load per phase by tracing downstream from a given point.

Image of create load report

Use case

You can use a load report to display the customers per phase as well as the load per phase based on a chosen starting point in a utility network. Load reports are used for electric load restoration and balancing.

How to use the sample

Choose phases to be included in the report. Tap "Run" to initiate a downstream trace on the network and create a load report.

How it works

  1. Create and load a UtilityNetwork with a feature service URL, then get an asset type, tier, network attributes, and category by their names.
  2. Create a UtilityElement from the asset type to use as the starting location for the trace.
  3. Get a base condition by calling the utility tier's makeDefaultTraceConfiguration method.
  4. Create UtilityTraceParameters passing in downstream trace type and the default starting location. Set its traceConfiguration property with the trace configuration above, and set includesBarriers to false.
  5. Create a UtilityCategoryComparison where "ServicePoint" category exists.
  6. Reset the functions property of the trace configuration with a new UtilityTraceFunction adding a "Service Load" network attribute where this category comparison applies. This will limit the function results.
  7. Set outputCondition with this category comparison to limit the element results.
  8. Populate the choice list for phases using the network attribute's codedValues property.
  9. When the "Add" button is tapped, add the selected phase to a phases list.
  10. When the "Run" button is tapped, run a trace for every CodedValue in the phases list. Do this by creating an UtilityTraceOrCondition with the base condition and an UtilityNetworkAttributeComparison where the "Phases Current" network attribute does not include the coded value.
  11. Display the count of "Total Customers" using the elements property of the result, and the result of "Total Load" using the first and only output in functionOutputs property.

Relevant API

  • UtilityAssetType
  • UtilityCategoryComparison
  • UtilityDomainNetwork
  • UtilityElement
  • UtilityElementTraceResult
  • UtilityNetwork
  • UtilityNetworkAttribute
  • UtilityNetworkAttributeComparison
  • UtilityNetworkDefinition
  • UtilityNetworkSource
  • UtilityTerminal
  • UtilityTier
  • UtilityTraceConfiguration
  • UtilityTraceFunction
  • UtilityTraceParameters
  • UtilityTraceResult
  • UtilityTraceType
  • UtilityTraversability

Tags

condition barriers, downstream trace, network analysis, subnetwork trace, trace configuration, traversability, upstream trace, utility network, validate consistency

Sample Code

CreateLoadReportView.swiftCreateLoadReportView.swiftCreateLoadReportView.Model.swiftCreateLoadReportView.Views.swift
Use dark colors for code blocksCopy
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
// Copyright 2023 Esri
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//   https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

import ArcGIS
import SwiftUI

struct CreateLoadReportView: View {
    /// The view model for the sample.
    @StateObject private var model = Model()

    var body: some View {
        LoadReportView(model: model)
            .task {
                await model.setup()
            }
            .errorAlert(presentingError: $model.error)
            .toolbar {
                ToolbarItem(placement: .bottomBar) {
                    Button("Run") {
                        Task {
                            await model.createLoadReport()
                        }
                    }
                    .disabled(!model.allowsCreateLoadReport)
                }
            }
            .overlay(alignment: .center) {
                if let status = model.statusText {
                    ZStack {
                        Color.clear.background(.ultraThinMaterial)
                        VStack {
                            Text(status)
                            ProgressView()
                                .progressViewStyle(.circular)
                        }
                        .padding()
                        .background(.ultraThickMaterial)
                        .cornerRadius(10)
                        .shadow(radius: 50)
                    }
                }
            }
    }
}

#Preview {
    NavigationView {
        CreateLoadReportView()
    }
}

Your browser is no longer supported. Please upgrade your browser for the best experience. See our browser deprecation post for more details.