import Circuit from "@arcgis/core/networks/support/Circuit.js";const Circuit = await $arcgis.import("@arcgis/core/networks/support/Circuit.js");- Inheritance:
- Circuit→
Accessor
- Since
- ArcGIS Maps SDK for JavaScript 4.34
Represents a circuit in a telecom domain network.
Creating a Circuit
Circuits may be created in one of three ways: with start location and stop location, with sections, or with neither.
Keep in mind that name must always be specified when instantiating a Circuit, and the following may be optionally specified: attributes, circuitManager, circuitType, globalId, and subcircuits.
Read More
With start and stop location
If created with start and stop locations, isSectioned is false.
const startLocation = new CircuitLocation({ sourceId: 20, globalId: "{665803BB-258E-4BAE-A5B2-27DBD8A83C30}", firstUnit: 1, lastUnit: 1,});
const stopLocation = new CircuitLocation({ sourceId: 20, globalId: "{58CB492A-1992-4518-A60F-6119B1317E89}", firstUnit: 1, lastUnit: 1,});
const circuit = new Circuit({ name: "FIRSTCIRCUIT", circuitType: "physical", startLocation, stopLocation,});With sections
If created with sections, isSectioned is true.
const sectionOne = new CircuitSection({ sectionId: 1, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE1" }),});
const sectionTwo = new CircuitSection({ sectionId: 2, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE2" }),});
const sectionThree = new CircuitSection({ sectionId: 3, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE3" }),});
const sectionFour = new CircuitSection({ sectionId: 4, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE4" }),});
const sections = new Map([ [sectionOne, [sectionTwo, sectionThree]], [sectionTwo, [sectionFour]], [sectionThree, [sectionFour]], [sectionFour, []],]);
const circuit = new Circuit({ name: "TESTCIRCUIT", sections,});As an empty circuit
It is possible to create an empty Circuit, without start locations, stop locations, or sections. In this scenario, isSectioned will be false until locations or sections are added to the Circuit.
const circuit = new Circuit({ name: "TESTCIRCUIT" });To create an empty sectioned Circuit, specify an empty Map for the sections property.
const circuit = new Circuit({ name: "TESTCIRCUIT", sections: new Map(),});Constructors
Constructor
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| circuitProperties | | |
Properties
| Property | Type | Class |
|---|---|---|
| | ||
| | ||
| | ||
declaredClass readonly inherited | ||
| | ||
isDeleted readonly | | |
isSectioned readonly | | |
lastExportedTime readonly | | |
lastVerifiedTime readonly | | |
| | ||
Map<CircuitSection, CircuitSection[]> | null | undefined | | |
| | ||
status readonly | | |
| | ||
| |
circuitManager
- Type
- CircuitManager | null | undefined
An instance of CircuitManager associated with the circuit.
This is updated when a circuit is successfully created or altered with
CircuitManager.create() or CircuitManager.alter().
circuitType
- Type
- CircuitType
Indicates the type of the circuit.
A virtual circuit does not require traversability between its start and stop locations. If a virtual circuit is also a sectioned circuit, the circuit must have at least one virtual section.
- Default value
- "physical"
sections
- Type
- Map<CircuitSection, CircuitSection[]> | null | undefined
A map representing the logical connectivity between circuit sections as a directed adjacency list. Each key is a CircuitSection that connects to the other CircuitSection instances indicated by the key's value.
For example, consider the following keys and values, where each number is a section ID:
{ "1": [2, 3], "2": [4], "3": [4], "4": [],}In this example, section 1 connects to 2 and 3 (where sections 2 and 3 are in parallel), 2 connects to 4, 3 connects to 4, and 4 connects to nothing (is the end of the circuit).
This connectivity between sections is graphically represented as:
1 / \2 3 \ / 4Example
const sectionOne = new CircuitSection({ sectionId: 1, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE1" }),});
const sectionTwo = new CircuitSection({ sectionId: 2, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE2" }),});
const sectionThree = new CircuitSection({ sectionId: 3, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE3" }),});
const sectionFour = new CircuitSection({ sectionId: 4, subcircuit: new Subcircuit({ name: "SUBCIRCUITVALUE4" }),});
const sections = new Map([ [sectionOne, [sectionTwo, sectionThree]], [sectionTwo, [sectionFour]], [sectionThree, [sectionFour]], [sectionFour, []],]);
const circuit = new Circuit({ name: "TESTCIRCUIT", sections,}); startLocation
- Type
- CircuitLocation | null | undefined
The feature or object associated with the start location of the circuit. This property is null if the circuit is sectioned.
status
- Type
- CircuitStatus
Indicates the status of the circuit.
The circuit status is initially "dirty" and remains dirty until the circuit is validated. The circuit status is "clean" when the circuit has been successfully validated. The circuit status returns to "dirty" if any circuit components are modified.
stopLocation
- Type
- CircuitLocation | null | undefined
The feature or object associated with the stop location of the circuit. This property is null if the circuit is sectioned.
subcircuits
- Type
- Subcircuit[]
The subcircuits that the circuit is subdivided into.
Methods
| Method | Signature | Class |
|---|---|---|
fromJSON inherited static | fromJSON(json: any): any | |
emit inherited | emit<Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean | |
getAttribute<T = any>(name: string): T | | |
getSectionById(sectionId: number): CircuitSection | null | | |
hasEventListener inherited | hasEventListener<Type extends EventNames<this>>(type: Type): boolean | |
on inherited | on<Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle | |
setAttribute(name: string, newValue: any): void | | |
setSections(sections: Map<CircuitSection, CircuitSection[]>): void | | |
setStartStopLocations(startLocation: CircuitLocation, stopLocation: CircuitLocation): void | | |
toJSON inherited | toJSON(): any |
fromJSON
- Signature
-
fromJSON (json: any): any
Creates a new instance of this class and initializes it with values from a JSON object
generated from an ArcGIS product. The object passed into the input json
parameter often comes from a response to a query operation in the REST API or a
toJSON()
method from another ArcGIS product. See the Using fromJSON()
topic in the Guide for details and examples of when and how to use this function.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| json | A JSON representation of the instance in the ArcGIS format. See the ArcGIS REST API documentation for examples of the structure of various input JSON objects. | |
- Returns
- any
Returns a new instance of this class.
emit
- Signature
-
emit <Type extends EventNames<this>>(type: Type, event?: this["@eventTypes"][Type]): boolean
- Type parameters
- <Type extends EventNames<this>>
Emits an event on the instance. This method should only be used when creating subclasses of this class.
getAttribute
- Signature
-
getAttribute <T = any>(name: string): T
- Type parameters
- <T = any>
Returns the value of the specified user-defined attribute.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| name | The name of the attribute. | |
- Returns
- T
Returns the value of the attribute specified by
name.
getSectionById
- Signature
-
getSectionById (sectionId: number): CircuitSection | null
Returns the CircuitSection instance with a specified section ID
from the circuit's sections.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| sectionId | The section ID of the section to retrieve. | |
- Returns
- CircuitSection | null
The circuit section with the specified ID, if one exists in the circuit.
hasEventListener
- Signature
-
hasEventListener <Type extends EventNames<this>>(type: Type): boolean
- Type parameters
- <Type extends EventNames<this>>
Indicates whether there is an event listener on the instance that matches the provided event name.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | The name of the event. | |
- Returns
- boolean
Returns true if the class supports the input event.
on
- Signature
-
on <Type extends EventNames<this>>(type: Type, listener: EventedCallback<this["@eventTypes"][Type]>): ResourceHandle
- Type parameters
- <Type extends EventNames<this>>
Registers an event handler on the instance. Call this method to hook an event with a listener.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| type | Type | An event or an array of events to listen for. | |
| listener | EventedCallback<this["@eventTypes"][Type]> | The function to call when the event fires. | |
- Returns
- ResourceHandle
Returns an event handler with a
remove()method that should be called to stop listening for the event(s).Property Type Description remove Function When called, removes the listener from the event.
Example
view.on("click", function(event){ // event is the event handle returned after the event fires. console.log(event.mapPoint);}); setSections
- Signature
-
setSections (sections: Map<CircuitSection, CircuitSection[]>): void
Sets the sections of the circuit.
This method sets the circuit's startLocation and stopLocation to null, making this a sectioned circuit.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| sections | The circuit's sections. | |
- Returns
- void
setStartStopLocations
- Signature
-
setStartStopLocations (startLocation: CircuitLocation, stopLocation: CircuitLocation): void
Sets the start and stop locations of the circuit.
This method sets the circuit's sections to null, making this a non-sectioned circuit.
Parameters
| Parameter | Type | Description | Required |
|---|---|---|---|
| startLocation | The start location of the circuit. | | |
| stopLocation | The stop location of the circuit. | |
- Returns
- void
toJSON
- Signature
-
toJSON (): any
Converts an instance of this class to its ArcGIS portal JSON representation. See the Using fromJSON() guide topic for more information.
- Returns
- any
The ArcGIS portal JSON representation of an instance of this class.
Type definitions
NonSectionedCircuitProperties
- Supertypes
- CommonProperties
startLocation
- Type
- CircuitLocation
stopLocation
- Type
- CircuitLocation
SectionedCircuitProperties
- Supertypes
- CommonProperties
sections
- Type
- Map<CircuitSection, CircuitSection[]>