Skip to content

DSS Sharp v0.12.1

Compare
Choose a tag to compare
@PMeira PMeira released this 19 Jul 18:42
· 18 commits to master since this release
db2361b

A new, rewritten DSS Sharp has been published. This released is based on the new DSS C-API, which itself had parts rewritten to achieve our goals. We plan to release a v1.0 package when all remaining features (notably diakoptics) are ported to DSS C-API.

The main changes include:

  • NuGet package is now available: https://www.nuget.org/packages/dss_sharp
  • Initial (WIP) HTML docs at https://dss-extensions.org/dss_sharp/
  • Multi-platform support -- while still pending more testing (especially in the packaging aspects), besides Windows, Linux and macOS are also supported, including ARM.
  • Use the new DSS Context API, available in DSS C-API 0.12. This enables users to create multiple DSS instances in the same process. For backwards compatibility, the static method dss_sharp.DSS.NewContext() is used to create new instances, while the default constructor is bound to the default/prime DSS instance.
  • Allow using .NET std 2.1 (#if NETSTANDARD2_1_OR_GREATER) to use UTF8 conversion strings; default build is still .NET 4.5 -- users should restrict inputs to ASCII on that.
  • Implement GR usage (less memory allocations). See https://github.com/dss-extensions/dss_capi/blob/0.12.1/docs/usage.md#global-result-gr-new-in-v0100
  • Check for OpenDSS errors for most API calls, mapping them to DSSException.
  • Add support for most of the API extensions (properties, toggles and full classes). https://github.com/dss-extensions/dss_capi/blob/0.12.1/docs/known_differences.md
  • Update project file
  • Drop CmathLib -- not really required in .NET.
  • Several new classes, including support for the Parallel features of the official OpenDSS (we still recommend user-threads in C#), ZIP file support, extended error messages both in the API and when running scripts, and more.
  • Include enums matching the COM implementation. Some of the annoyances were kept for compatibility only.

Pending potential bugs, the main objective of DSS Sharp (good compatibility with the official COM implementation) has been achieved.
We are considering a cleaner and more modern alternative. If you have comments or feature requests, please feel free to post a new issue or reach me via email (pmeira at ieee.org).

Since the amount of changes in DSS C-API was significant, we reproduce its release announcement below.

DSS C-API 0.12.1

Incremental release to address a bug found right after v0.12.0 was released.

  • Fixes handling of Voltexceptionreport option
  • DSS_ExtractSchema: include property descriptions, if loaded.
  • Examples: add a simple OpenMP example in C using DSSContexts

Original announcement for v0.12.0 follows.


DSS C-API is a library that exposes a plain C API for an unofficial implementation of OpenDSS, the Distribution System Simulator from EPRI (the Electric Power Research Institute), aiming for full COM compatibility and beyond. It allows using OpenDSS on Windows, Linux and macOS with compatible behavior across multiple processor architectures. It is the lower level API used by the other projects in DSS Extensions: DSS Python, OpenDSSDirect.py, OpenDSSDirect.jl (Julia language), DSS# (.NET/C# bindings) and DSS MATLAB.

See the changelog for a complete list of changes since 0.10.0.
See also the updated "Known Differences" document, which lists the main differences between the DSS C-API codebase and the main/official OpenDSS.

The downstream projects will be updated following this release, and a new repository for general documentation and collaboration was created at https://github.com/dss-extensions/dss-extensions

This is a long-delayed upgrade that enhances several aspects of this implementation of the OpenDSS engine. Users can now expect more regular and prompt updates.

Changes since 0.10.7

Includes porting of most official OpenDSS features up to revision 3460. Check the OpenDSS SVN commits for details.

This version still maintains basic compatibility with the 0.10.x series of releases, but there are many important changes. Version 0.13 will break API and ABI compatibility since function signatures and datatypes will be extensively adjusted. Still, if you use DSS C-API through one of the projects from DSS Extensions, we expect that your code will require few or no changes.

  • The binary releases now use Free Pascal 3.2.2.

  • The library name was changed from dss_capi_v7 to dss_capi. The codebase was cleaned up and reorganized.

  • The code was finally unified, merging remaining features from OpenDSS v8+ (with few exceptions). Most of the DSS PM commands and functions were enabled. To achieve this, most of the global variables from the OpenDSS engine were encapsulated in a new class, a DSS Context class. Multi-threaded features are based on DSSContexts, both the original OpenDSS PM features and new extensions.

  • Using DSS Contexts, user threads are now possible.

  • Initial ARM64/AARCH64 support added. ARM32 building scripts were also added. Support includes Apple M1 support, including parallel/multi-threading features.

  • Finally use KLUSolveX (our KLUSolve fork, rewritten and extended), enabling incremental Y updates for transformers and capacitor banks. Documentation including usage notes and limitations still not written. This was planned for version v0.13, but moved back to v0.12 to enable ARM32 (armv7l) support and better results in ARM64 (aarch64).

  • Experimental callbacks for plotting and message output. Expect initial support in Python soon after DSS C-API v0.12 is released.

  • Introduce AllowChangeDir mechanism: defaults to enabled state for backwards compatibility. When disabled, the engine will not change the current working directory in any situation. This is exposed through a new pair of functions
    DSS_Set_AllowChangeDir and DSS_Get_AllowChangeDir, besides the environment variable DSS_CAPI_ALLOW_CHANGE_DIR.

  • New setting to toggle DOScmd command. Can be controlled through the environment variable DSS_CAPI_ALLOW_DOSCMD or functions DSS_Get_AllowDOScmd/DSS_Set_AllowDOScmd.

  • Use OutputDirectory more. OutputDirectory is set to the current DataPath if DataPath is writable. If not, it's set to a general location (%LOCALAPPDATA%/dss-extensions and /tmp/dss-extensions since this release). This should make life easier for a user running files from a read-only location. Note that this is only an issue when running a compile command. If the user only uses redirect commands, the DataPath and OutputDirectory are left empty, meaning the files are written to the current working directory (CWD), which the user can control through the programming language driving DSS C-API. Note that the official OpenDSS COM behavior is different, since it loads the DataPath saved in the registry and modifies the CWD accordingly when OpenDSS is initialized.

  • File IO rewritten to drop deprecated Pascal functions and features. This removes some limitations related to long paths due to the legacy implementation being limited to 255 chars.

  • Reworked TPowerTerminal to achieve better memory layout. This makes simulations running LoadsTerminalCheck=false and LoadsTerminalCheck=true closer in performance, yet disabling the check is still faster.

  • Use TFPHashList where possible (replacing the custom, original THashList implementation from OpenDSS).

  • New LoadShape functions and internals:

    • Port memory-mapped files from the official OpenDSS, used when MemoryMapping=Yes from a DSS script while creating a LoadShape object.
    • Release the LoadShape_Set_Points function, which can be used for faster LoadShape input, memory-mapping externally, shared memory, chunked input, etc.
  • Some new functions:

    • Circuit_Get_ElementLosses
    • CktElement_Get_NodeRef
  • DSS_Get_COMErrorResults/DSS_Set_COMErrorResults: New compatibility setting for error/empty result. If enabled, in case of errors or empty arrays, the API returns arrays with values compatible with the official OpenDSS COM interface.

    For example, consider the function Loads_Get_ZIPV. If there is no active circuit or active load element:

    • In the disabled state (COMErrorResults=False), the function will return "[]", an array with 0 elements.
    • In the enabled state (COMErrorResults=True), the function will return "[0.0]" instead. This should
      be compatible with the return value of the official COM interface.

    Defaults to True/1 (enabled state) in the v0.12.x series. This will change to false in future series.

    This can also be set through the environment variable DSS_CAPI_COM_DEFAULTS. Setting it to 0 disables
    the legacy/COM behavior. The value can be toggled through the API at any time.

  • Drop function aliases: previously deprecated function aliases (LoadShapes_Set_Sinterval and LoadShapes_Get_sInterval) were removed to simplify the build process. Use LoadShapes_Set_SInterval and LoadShapes_Get_SInterval instead.

  • Monitor headers: From the official OpenDSS, since May 2021, the monitor binary stream doesn't include the header anymore. When porting the change to DSS Extensions, we took the opportunity to rewrite the related code, simplifying it. As such, the implementation in DSS Extensions deviates from the official one. Extra blank chars are not included, and fields should be more consistent. As a recommendation, if your code needs to be compatible with both implementations, trimming the fields should be enough.

  • Error messages: most messages are now more specific and, if running a DSS script from files, include the file names and line numbers.

  • Spectrum: To reduce overhead during object edits, now required to exist before the object that uses it. This is consistent with most of the other types in OpenDSS.

  • New object and batch APIs for direct manipulation of DSS objects and batches of objects

  • New experimental API for loading scripts/data from ZIP files

  • New convenience functions to bulk load commands from the API

  • User-models: headers updated, and removed support for user-models in LegacyModels mode. LegacyModels will be removed in v0.13.

  • New functions to export the DSS properties of objects as JSON-encoded strings

  • The C headers for our library were updated to include the const modifier for various of the parameters. A few function declarations were fixed.

  • Initial batch of i18n changes. The property and command descriptions are now provided in an external gettext catalog, allowing us to easily replace them (initial file contained in messages.zip)

Due to the high number of IO changes, we recommend checking the performance before and after the upgrade to ensure your use case is not affected negatively. If issues are found, please do report.

The changelog for version 0.12.0 will be updated if we notice missing items.

See also dss-extensions/dss_capi#109

Full DSS C-API Git Changelog: dss-extensions/dss_capi@0.10.7-1...0.12.1