{ "cells": [ { "cell_type": "markdown", "metadata": {}, "source": [ "# OpenDSS COM/classic APIs\n", "\n", "*Main concepts of the classic OpenDSS APIs*\n", "\n", "This document is intended to expose some concepts that are typically overlook by many users when using the classic OpenDSS API.\n", "\n", "Traditionally, all OpenDSS interfaces and bindings use the same concepts of interaction with the DSS engine. That includes most of the projects developed under DSS-Extensions, \n", "\n", "On DSS-Extensions, an alternative API is being developed to complement and/or provide a difference experience. Currently, the main results are represented in the [AltDSS-Python](https://dss-extensions.org/AltDSS-Python/) project.\n", "\n", "To avoid generating confusion, we will use the term \"classic API\" to indicate a set of APIs that follow the concepts developed in the official OpenDSS COM implementation, and \"Alt\" or alternative API for whatever is being developed in AltDSS-Python and similar projects, such as `dss.hpp`.\n", "\n", "OpenDSS has models for many electric components and controllers, plus general data classes. Besides those, there are several interfaces to interact with specific aspects of the engine. The [official documentation](https://opendss.epri.com/opendss_documentation.html) and other training material usually covers those in detail.\n", "\n", "## API Hierarchy\n", "\n", "The API tree as seen from walking from the main interface class `IDSS`, which is exposed from `OpenDSSengine.DSS` in the COM interface, is as follows. \n", "\n", "For EPRI's OpenDSS implementation, the API materialize in the `OpenDSSengine.DSS` COM object exposes the OpenDSS engine, which is a global singleton in the engine side. That means that the same engine is exposed even if you create another COM object. On DSS-Extensions, the default instance is also created by default for compatibility with the global singleton, but users can create multiple engines by using the `dss.NewContext()` method.\n", "\n", "Items marked with \"API Extension\" are not present in the COM API, but available as extras on DSS-Extensions.\n", "\n", "- dss (`IDSS`)\n", " - (dss.)ActiveClass (`IActiveClass`): Manipulate DSS classes directly. For example, if a class doesn't have a dedicated API, this can be used to access the element properties. This is the same as \"dss.ActiveCircuit.ActiveClass\".\n", " - (dss.)DSSProgress (`IDSSProgress`): Manipulate the progress status, GUI etc. *Using this is uncommon.* Not fully supported on DSS-Extensions without custom callbacks.\n", " - (dss.)DSSim_Coms (`IDSSimComs`): Using this is uncommon. Also exposed as \"dss.ActiveCircuit.DSSim_Coms\".\n", " - (dss.)Error (`IError`): The error interface lists error numbers and descriptions. On the official OpenDSS, users need to check this manually if `AllowForms` is disabled. On DSS-Extensions, most errors are directly mapped to errors or exceptions, depending on the programming language.\n", " - (dss.)Events (`IDSSEvents`): The event interface allows using event callbacks that are triggered in certain points of the solution process. *Using this is uncommon.*\n", " - (dss.)Executive (`IDSS_Executive`): Lists the available commands and options, help strings. Allow manipulating options. *Using this is uncommon.*\n", " - (dss.)Parser (`IParser`): Parsing utilities. Using this is uncommon.\n", " - (dss.)Text (`IText`): Pass DSS commands and get results from the DSS engine.\n", " - (dss.)ZIP (`IZIP`) (**API Extension**): Allow loading circuits from ZIP files, without extracting files to the disk.\n", " - (dss.)ActiveCircuit (`ICircuit`): this is effectively the same as `Circuits` (omitted). Contains many properties and methods to access the circuit state, plus the interfaces below.\n", " - ***General engine and circuit operations***\n", " - (dss.ActiveCircuit.)CtrlQueue (`ICtrlQueue`): Inspect or manipulate the control event queue.\n", " - (dss.ActiveCircuit.)Parallel (`IParallel`): OpenDSS Parallel-machine features. *Using this is uncommon.* On DSS-Extensions, prefer native multithreading couple with `dss.NewContext()` instead.\n", " - (dss.ActiveCircuit.)ReduceCkt (`IReduceCkt`): Circuit reduction operations.\n", " - (dss.ActiveCircuit.)Topology (`ITopology`): Get general information like loops and isolated elements; iterate over the circuit graph. Requires an EnergyMeter.\n", " - (dss.ActiveCircuit.)Settings (`ISettings`): Exposes some of the settings for the circuit, some for the whole engine. Some more options/settings are also directly in the main `IDSS` class.\n", " - (dss.ActiveCircuit.)Solution (`ISolution`): Solution manipulation, including settings and general state.\n", " - ***Bus operations***\n", " - (dss.ActiveCircuit.)ActiveBus (`IBus`): Manipulate a specific bus. This is effectively the same as `Buses` (omitted).\n", " - ***Base element operations***\n", " - (dss.ActiveCircuit.)ActiveCktElement (`ICktElement`): This is effectively the same as `ActiveElement` and `CktElements` (omitted).\n", " - (dss.ActiveCircuit.ActiveCktElement.)Properties (`IDSSProperty`): Manipulate the DSS properties of the active element.\n", " - (dss.ActiveCircuit.)ActiveClass (`IActiveClass`): Same as \"dss.ActiveClass\".\n", " - (dss.ActiveCircuit.)ActiveDSSElement (`IDSSElement`)\n", " - (dss.ActiveCircuit.ActiveDSSElement.)Properties (`IDSSProperty`)\n", " - (dss.ActiveCircuit.)PDElements (`IPDElements`)\n", " - ***Dedicated interfaces for specific elements***\n", " - (dss.ActiveCircuit.)CNData (`ICNData`) (**API Extension**)\n", " - (dss.ActiveCircuit.)CapControls (`ICapControls`)\n", " - (dss.ActiveCircuit.)Capacitors (`ICapacitors`)\n", " - (dss.ActiveCircuit.)Fuses (`IFuses`)\n", " - (dss.ActiveCircuit.)GICSources (`IGICSources`)\n", " - (dss.ActiveCircuit.)Generators (`IGenerators`)\n", " - (dss.ActiveCircuit.)Isources (`IISources`)\n", " - (dss.ActiveCircuit.)LineCodes (`ILineCodes`)\n", " - (dss.ActiveCircuit.)LineGeometries (`ILineGeometries`) (**API Extension**) \n", " - (dss.ActiveCircuit.)LineSpacings (`ILineSpacings`) (**API Extension**)\n", " - (dss.ActiveCircuit.)Lines (`ILines`)\n", " - (dss.ActiveCircuit.)LoadShapes (`ILoadShapes`)\n", " - (dss.ActiveCircuit.)Loads (`ILoads`)\n", " - (dss.ActiveCircuit.)Meters (`IMeters`)\n", " - (dss.ActiveCircuit.)Monitors (`IMonitors`)\n", " - (dss.ActiveCircuit.)PVSystems (`IPVSystems`)\n", " - (dss.ActiveCircuit.)Reactors (`IReactors`) (**API Extension**)\n", " - (dss.ActiveCircuit.)Reclosers (`IReclosers`)\n", " - (dss.ActiveCircuit.)RegControls (`IRegControls`)\n", " - (dss.ActiveCircuit.)Relays (`IRelays`)\n", " - (dss.ActiveCircuit.)Sensors (`ISensors`)\n", " - (dss.ActiveCircuit.)Storages (`IStorages`) (**API Extension**)\n", " - (dss.ActiveCircuit.)SwtControls (`ISwtControls`)\n", " - (dss.ActiveCircuit.)TSData (`ITSData`) (**API Extension**)\n", " - (dss.ActiveCircuit.)Transformers (`ITransformers`)\n", " - (dss.ActiveCircuit.)Vsources (`IVsources`)\n", " - (dss.ActiveCircuit.)WireData (`IWireData`) (**API Extension**)\n", " - (dss.ActiveCircuit.)XYCurves (`IXYCurves`)\n", "\n", "*The projects [OpenDSSDirect.jl](https://dss-extensions.org/OpenDSSDirect.jl/) and [OpenDSSDirect.py](https://dss-extensions.org/OpenDSSDirect.py/) follow a slightly different organization (see also [Python APIs](https://dss-extensions.org/python_apis)), but the concepts listed below still apply.*" ] }, { "cell_type": "markdown", "metadata": {}, "source": [ "## General layout\n", "\n", "Internally, OpenDSS uses object-oriented concepts and, in the API, different classes in the inheritance tree are exposed by different interface classes.\n", "\n", "For a more complete view of the classes, as implemented in AltDSS/DSS C-API, see [this class diagram](_static/GVClasses.svg), generated from the Pascal code.\n", "\n", "A simplified diagram for the Load object follows. In the actual source code, there is `TLoad` and `TLoadObj`. The first one is the container/manager class, while the second is the actual individual object.\n", "\n", "