ArcGIS Pro 3.3 API Reference Guide
ArcGIS.Core.Data.UtilityNetwork Namespace / UtilityNetworkExtensions Class / EnableControllerInEditOperation Method
The SubnetworkManager instance used to add a controller to an existing or newly-created subnetwork.
The Tier to which the Subnetwork is created.
Corresponds to the feature to be enabled as a SubnetworkController. This Element must specify a terminal, and this terminal must be specified as a Controller Terminal in the terminal definition.
Name of the subnetwork.
Name of the subnetwork controller.
A description for the subnetwork controller.
Additional notes for the subnetwork controller.
Example

In This Topic
    EnableControllerInEditOperation Method
    In This Topic
    Enables a feature corresponding to device to be a SubnetworkController and adds it to an existing Subnetwork corresponding to subnetworkName. If the specified subnetwork does not exist, a new one will be created. This method must be called on the MCT. Use QueuedTask.Run.
    Syntax
    Public Shared Function EnableControllerInEditOperation( _
       ByVal subnetworkManager As SubnetworkManager, _
       ByVal tier As Tier, _
       ByVal device As Element, _
       ByVal subnetworkName As String, _
       ByVal controllerName As String, _
       ByVal description As String, _
       ByVal notes As String _
    ) As Subnetwork

    Parameters

    subnetworkManager
    The SubnetworkManager instance used to add a controller to an existing or newly-created subnetwork.
    tier
    The Tier to which the Subnetwork is created.
    device
    Corresponds to the feature to be enabled as a SubnetworkController. This Element must specify a terminal, and this terminal must be specified as a Controller Terminal in the terminal definition.
    subnetworkName
    Name of the subnetwork.
    controllerName
    Name of the subnetwork controller.
    description
    A description for the subnetwork controller.
    notes
    Additional notes for the subnetwork controller.

    Return Value

    The newly-created or modified subnetwork.
    Exceptions
    ExceptionDescription

    The active ArcGIS.Desktop.Mapping.MapView is unavailable.

    -or-

    The ArcGIS.Desktop.Mapping.UtilityNetworkLayer is unavailable.

    -or-

    If the Terminal in device is null and the associated TerminalConfiguration has multiple terminals.

    This method or property must be called within the lambda passed to QueuedTask.Run.
    A geodatabase-related exception has occurred.
    Remarks
    • This routine creates its own edit operation, and can therefore not be called within an existing transaction.
    • If this operation is successful, it will create an edit operation on the Pro undo/redo stack, invalidate the affected layers and cause the ArcGIS.Desktop.Mapping.MapView to redraw. When writing a CoreHost application, use SubnetworkManager.EnableController.
    If this operation is successful, it will invalidate the affected layers and cause the ArcGIS.Desktop.Mapping.MapView to redraw.
    Example
    Life cycle for a simple radial subnetwork with one controller
    // Create a subnetwork named "Radial1" with a single controller
    // elementR1 represents the device that serves as the subnetwork controller (e.g., circuit breaker)
    Subnetwork subnetworkRadial1 = subnetworkManager.EnableControllerInEditOperation(mediumVoltageTier, elementR1, "Radial1", "R1", "my description", "my notes");
    
    // ...
    
    // Update the subnetwork and refresh the map
    subnetworkRadial1.Update();
    MapView.Active.Redraw(true);
    
    // ...
    
    // At some point, a subnetwork will need to be deleted.
    
    // First step is to disable the controller
    subnetworkManager.DisableControllerInEditOperation(elementR1);
    
    // At this point, the subnetwork is deleted, but all of the rows that have been labeled with the subnetwork ID need to be updated
    subnetworkRadial1.Update();
    MapView.Active.Redraw(true);
    
    // The final step is to notify external systems (if any) by exporting the subnetwork
    SubnetworkExportOptions subnetworkExportOptions = new SubnetworkExportOptions()
    {
      SetAcknowledged = true,
      IncludeDomainDescriptions = true,
      IncludeGeometry = true,
      ServiceSynchronizationType = ServiceSynchronizationType.Asynchronous,
    
      SubnetworkExportResultTypes = new List<SubnetworkExportResultType>()
      {
        SubnetworkExportResultType.Features
      }
      
      // Set networks attributes and attribute fields to export
      //ResultNetworkAttributes = new List<NetworkAttribute>(networkAttributes),
    
      //ResultFieldsByNetworkSourceID = new Dictionary<int, List<string>>()
      //  { { electricDevice.ID, new List<string>() { "AssetID" } } }
    
    };
    subnetworkRadial1.Export(new Uri($"{Path.GetTempPath()}SubnetworkExportResult.json"), subnetworkExportOptions);
    Life cycle for a multifeed radial subnetwork with two controllers
    // Create a subnetwork named "R2, R3" from two controllers
    // elementR2 and elementR3 represent the devices that serve as subnetwork controllers (e.g., circuit breakers)
    subnetworkManager.EnableControllerInEditOperation(mediumVoltageTier, elementR2, "R2, R3", "R2", "my description", "my notes");
    subnetworkManager.EnableControllerInEditOperation(mediumVoltageTier, elementR3, "R2, R3", "R3", "my description", "my notes");
    
    // If the tie switch between them is opened, the original subnetwork controllers must be disabled and re-enabled with different names
    // This will create two new subnetworks, named "R2" and "R3"
    subnetworkManager.DisableControllerInEditOperation(elementR2);
    subnetworkManager.DisableControllerInEditOperation(elementR3);
    
    Subnetwork subnetworkR2 = subnetworkManager.EnableControllerInEditOperation(mediumVoltageTier, elementR2, "R2", "R2", "my description", "my notes");
    Subnetwork subnetworkR3 = subnetworkManager.EnableControllerInEditOperation(mediumVoltageTier, elementR3, "R3", "R3", "my description", "my notes");
    
    subnetworkR2.Update();
    subnetworkR3.Update();
    MapView.Active.Redraw(true);
    
    Requirements

    Target Platforms: Windows 11, Windows 10

    ArcGIS Pro version: 3 or higher.
    See Also