Skip to content

Commit

Permalink
Merge pull request #110 from dss-extensions/dss_python-0.12.0
Browse files Browse the repository at this point in the history
DSS Python 0.12.1
  • Loading branch information
PMeira committed Jul 16, 2022
2 parents e8426ff + f4982d2 commit 1f04be7
Show file tree
Hide file tree
Showing 62 changed files with 2,453 additions and 8,462 deletions.
12 changes: 6 additions & 6 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ build: false

environment:
matrix:
- PYTHON_VERSION: 3.10
TARGET_ARCH: "x64"
MINICONDA: C:\Miniconda3-x64
- PYTHON_VERSION: 3.9
TARGET_ARCH: "x64"
MINICONDA: C:\Miniconda3-x64
Expand All @@ -17,9 +20,9 @@ environment:
- PYTHON_VERSION: 3.6
TARGET_ARCH: "x64"
MINICONDA: C:\Miniconda3-x64
- PYTHON_VERSION: 3.5
TARGET_ARCH: "x64"
MINICONDA: C:\Miniconda3-x64
- PYTHON_VERSION: 3.10
TARGET_ARCH: "x86"
MINICONDA: C:\Miniconda3
- PYTHON_VERSION: 3.9
TARGET_ARCH: "x86"
MINICONDA: C:\Miniconda3
Expand All @@ -32,9 +35,6 @@ environment:
- PYTHON_VERSION: 3.6
TARGET_ARCH: "x86"
MINICONDA: C:\Miniconda3
- PYTHON_VERSION: 3.5
TARGET_ARCH: "x86"
MINICONDA: C:\Miniconda3

install:
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"
Expand Down
17 changes: 15 additions & 2 deletions opendssdirect/ActiveClass.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, codec, CheckForError, get_string, get_string_array


Expand Down Expand Up @@ -51,6 +49,20 @@ def ActiveClassParent():
return get_string(CheckForError(lib.ActiveClass_Get_ActiveClassParent()))


def ToJSON(options=0):
"""
Returns the data (as a list) of all elements from the active class as a JSON-encoded string.
The `options` parameter contains bit-flags to toggle specific features.
See `Obj_ToJSON` (C-API) for more.
Additionally, the `ExcludeDisabled` flag can be used to excluded disabled elements from the output.
(API Extension)
"""
return get_string(CheckForError(lib.ActiveClass_ToJSON(options)))


_columns = ["ActiveClassName", "Name", "NumElements", "ActiveClassParent"]
__all__ = [
"ActiveClassName",
Expand All @@ -61,4 +73,5 @@ def ActiveClassParent():
"Next",
"NumElements",
"ActiveClassParent",
"ToJSON",
]
33 changes: 29 additions & 4 deletions opendssdirect/Basic.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, codec, CheckForError, get_string, get_string_array


Expand Down Expand Up @@ -124,10 +122,12 @@ def LegacyModels(*args):
or contact the authors from DSS Extensions: https://github.com/dss-extensions/
After toggling LegacyModels, run a "clear" command and the models will be loaded accordingly.
Defaults to False.
Defaults to False.
This can also be enabled by setting the environment variable DSS_CAPI_LEGACY_MODELS to 1.
NOTE: this option will be removed in a future release.
(API Extension)
"""
# Getter
Expand All @@ -136,7 +136,31 @@ def LegacyModels(*args):

# Setter
Value, = args
return CheckForError(lib.DSS_Set_LegacyModels(Value))
CheckForError(lib.DSS_Set_LegacyModels(Value))


def AllowChangeDir(*args):
"""
If disabled, the engine will not change the active working directory during execution. E.g. a "compile"
command will not "chdir" to the file path.
If you have issues with long paths, enabling this might help in some scenarios.
Defaults to True (allow changes, backwards compatible) in the 0.10.x versions of DSS C-API.
This might change to False in future versions.
This can also be set through the environment variable DSS_CAPI_ALLOW_CHANGE_DIR. Set it to 0 to
disallow changing the active working directory.
(API Extension)
"""
# Getter
if len(args) == 0:
return CheckForError(lib.DSS_Get_AllowChangeDir()) != 0

# Setter
Value, = args
CheckForError(lib.DSS_Set_AllowChangeDir(Value))


_columns = [
Expand Down Expand Up @@ -167,4 +191,5 @@ def LegacyModels(*args):
"NewCircuit",
"AllowEditor",
"LegacyModels",
"AllowChangeDir",
]
4 changes: 2 additions & 2 deletions opendssdirect/Bus.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import (
lib,
CheckForError,
Expand Down Expand Up @@ -231,6 +229,8 @@ def AllPDEatBus():
"PuVoltage",
"X",
"Y",
"AllPCEatBus",
"AllPDEatBus",
]
__all__ = [
"AllPCEatBus",
Expand Down
2 changes: 0 additions & 2 deletions opendssdirect/CNData.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, codec, CheckForError, get_string, get_string_array


Expand Down
2 changes: 0 additions & 2 deletions opendssdirect/CapControls.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, codec, CheckForError, get_string, get_string_array


Expand Down
2 changes: 0 additions & 2 deletions opendssdirect/Capacitors.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import (
lib,
codec,
Expand Down
4 changes: 1 addition & 3 deletions opendssdirect/Circuit.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import (
lib,
codec,
Expand Down Expand Up @@ -205,7 +203,7 @@ def SystemY():


def TotalPower():
"""(read-only) Total power, kw delivered to the circuit"""
"""(read-only) Total power, kW delivered to the circuit"""
return get_float64_array(lib.Circuit_Get_TotalPower)


Expand Down
22 changes: 20 additions & 2 deletions opendssdirect/CktElement.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
import warnings
from ._utils import (
lib,
Expand Down Expand Up @@ -306,6 +304,23 @@ def IsIsolated():
return CheckForError(lib.CktElement_Get_IsIsolated()) != 0


def setVariableByIndex(Idx, Value):
Code = ffi.new("int32_t*")
CheckForError(lib.CktElement_Set_Variablei(Idx, Code, Value))
return Code[0]


def setVariableByName(Idx, Value):
Code = ffi.new("int32_t*")
CheckForError(lib.CktElement_Set_Variable(Idx, Code, Value))
return Code[0]


def NodeRef():
"""Array of integers, a copy of the internal NodeRef of the CktElement."""
return get_int32_array(lib.CktElement_Get_NodeRef)


_columns = [
"BusNames",
"CplxSeqCurrents",
Expand Down Expand Up @@ -394,4 +409,7 @@ def IsIsolated():
"VoltagesMagAng",
"YPrim",
"IsIsolated",
"setVariableByIndex",
"setVariableByName",
"NodeRef",
]
2 changes: 0 additions & 2 deletions opendssdirect/CmathLib.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, get_float64_array


Expand Down
2 changes: 0 additions & 2 deletions opendssdirect/CtrlQueue.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, CheckForError, get_string_array


Expand Down
1 change: 0 additions & 1 deletion opendssdirect/DSSCore.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
from __future__ import absolute_import
# For OpenDSSDirect.jl, import YMatrix and exposed it as DSSCore
from .YMatrix import *
3 changes: 0 additions & 3 deletions opendssdirect/DSSEvents.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import


_columns = []
__all__ = []
2 changes: 0 additions & 2 deletions opendssdirect/DSSimComs.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, CheckForError, get_float64_array


Expand Down
16 changes: 13 additions & 3 deletions opendssdirect/Element.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, CheckForError, get_string, get_string_array


Expand All @@ -18,5 +16,17 @@ def NumProperties():
return CheckForError(lib.DSSElement_Get_NumProperties())


def ToJSON(options=0):
"""
Returns the properties of the active DSS object as a JSON-encoded string.
The `options` parameter contains bit-flags to toggle specific features.
See `Obj_ToJSON` (C-API) for more.
(API Extension)
"""
return get_string(CheckForError(lib.DSSElement_ToJSON(options)))


_columns = ["Name", "NumProperties", "AllPropertyNames"]
__all__ = ["AllPropertyNames", "Name", "NumProperties"]
__all__ = ["AllPropertyNames", "Name", "NumProperties", "ToJSON"]
2 changes: 0 additions & 2 deletions opendssdirect/Error.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, get_string


Expand Down
2 changes: 0 additions & 2 deletions opendssdirect/Executive.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, CheckForError, get_string


Expand Down
2 changes: 0 additions & 2 deletions opendssdirect/Fuses.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
from __future__ import absolute_import
from ._utils import lib, codec, CheckForError, get_string, get_string_array


Expand Down
Loading

0 comments on commit 1f04be7

Please sign in to comment.