Skip to content

Commit 1f04be7

Browse files
authored
Merge pull request #110 from dss-extensions/dss_python-0.12.0
DSS Python 0.12.1
2 parents e8426ff + f4982d2 commit 1f04be7

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+2453
-8462
lines changed

.appveyor.yml

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,9 @@ build: false
55

66
environment:
77
matrix:
8+
- PYTHON_VERSION: 3.10
9+
TARGET_ARCH: "x64"
10+
MINICONDA: C:\Miniconda3-x64
811
- PYTHON_VERSION: 3.9
912
TARGET_ARCH: "x64"
1013
MINICONDA: C:\Miniconda3-x64
@@ -17,9 +20,9 @@ environment:
1720
- PYTHON_VERSION: 3.6
1821
TARGET_ARCH: "x64"
1922
MINICONDA: C:\Miniconda3-x64
20-
- PYTHON_VERSION: 3.5
21-
TARGET_ARCH: "x64"
22-
MINICONDA: C:\Miniconda3-x64
23+
- PYTHON_VERSION: 3.10
24+
TARGET_ARCH: "x86"
25+
MINICONDA: C:\Miniconda3
2326
- PYTHON_VERSION: 3.9
2427
TARGET_ARCH: "x86"
2528
MINICONDA: C:\Miniconda3
@@ -32,9 +35,6 @@ environment:
3235
- PYTHON_VERSION: 3.6
3336
TARGET_ARCH: "x86"
3437
MINICONDA: C:\Miniconda3
35-
- PYTHON_VERSION: 3.5
36-
TARGET_ARCH: "x86"
37-
MINICONDA: C:\Miniconda3
3838

3939
install:
4040
- "set PATH=%MINICONDA%;%MINICONDA%\\Scripts;%PATH%"

opendssdirect/ActiveClass.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import lib, codec, CheckForError, get_string, get_string_array
42

53

@@ -51,6 +49,20 @@ def ActiveClassParent():
5149
return get_string(CheckForError(lib.ActiveClass_Get_ActiveClassParent()))
5250

5351

52+
def ToJSON(options=0):
53+
"""
54+
Returns the data (as a list) of all elements from the active class as a JSON-encoded string.
55+
56+
The `options` parameter contains bit-flags to toggle specific features.
57+
See `Obj_ToJSON` (C-API) for more.
58+
59+
Additionally, the `ExcludeDisabled` flag can be used to excluded disabled elements from the output.
60+
61+
(API Extension)
62+
"""
63+
return get_string(CheckForError(lib.ActiveClass_ToJSON(options)))
64+
65+
5466
_columns = ["ActiveClassName", "Name", "NumElements", "ActiveClassParent"]
5567
__all__ = [
5668
"ActiveClassName",
@@ -61,4 +73,5 @@ def ActiveClassParent():
6173
"Next",
6274
"NumElements",
6375
"ActiveClassParent",
76+
"ToJSON",
6477
]

opendssdirect/Basic.py

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import lib, codec, CheckForError, get_string, get_string_array
42

53

@@ -124,10 +122,12 @@ def LegacyModels(*args):
124122
or contact the authors from DSS Extensions: https://github.com/dss-extensions/
125123
126124
After toggling LegacyModels, run a "clear" command and the models will be loaded accordingly.
127-
Defaults to False.
125+
Defaults to False.
128126
129127
This can also be enabled by setting the environment variable DSS_CAPI_LEGACY_MODELS to 1.
130128
129+
NOTE: this option will be removed in a future release.
130+
131131
(API Extension)
132132
"""
133133
# Getter
@@ -136,7 +136,31 @@ def LegacyModels(*args):
136136

137137
# Setter
138138
Value, = args
139-
return CheckForError(lib.DSS_Set_LegacyModels(Value))
139+
CheckForError(lib.DSS_Set_LegacyModels(Value))
140+
141+
142+
def AllowChangeDir(*args):
143+
"""
144+
If disabled, the engine will not change the active working directory during execution. E.g. a "compile"
145+
command will not "chdir" to the file path.
146+
147+
If you have issues with long paths, enabling this might help in some scenarios.
148+
149+
Defaults to True (allow changes, backwards compatible) in the 0.10.x versions of DSS C-API.
150+
This might change to False in future versions.
151+
152+
This can also be set through the environment variable DSS_CAPI_ALLOW_CHANGE_DIR. Set it to 0 to
153+
disallow changing the active working directory.
154+
155+
(API Extension)
156+
"""
157+
# Getter
158+
if len(args) == 0:
159+
return CheckForError(lib.DSS_Get_AllowChangeDir()) != 0
160+
161+
# Setter
162+
Value, = args
163+
CheckForError(lib.DSS_Set_AllowChangeDir(Value))
140164

141165

142166
_columns = [
@@ -167,4 +191,5 @@ def LegacyModels(*args):
167191
"NewCircuit",
168192
"AllowEditor",
169193
"LegacyModels",
194+
"AllowChangeDir",
170195
]

opendssdirect/Bus.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import (
42
lib,
53
CheckForError,
@@ -231,6 +229,8 @@ def AllPDEatBus():
231229
"PuVoltage",
232230
"X",
233231
"Y",
232+
"AllPCEatBus",
233+
"AllPDEatBus",
234234
]
235235
__all__ = [
236236
"AllPCEatBus",

opendssdirect/CNData.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import lib, codec, CheckForError, get_string, get_string_array
42

53

opendssdirect/CapControls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import lib, codec, CheckForError, get_string, get_string_array
42

53

opendssdirect/Capacitors.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import (
42
lib,
53
codec,

opendssdirect/Circuit.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import (
42
lib,
53
codec,
@@ -205,7 +203,7 @@ def SystemY():
205203

206204

207205
def TotalPower():
208-
"""(read-only) Total power, kw delivered to the circuit"""
206+
"""(read-only) Total power, kW delivered to the circuit"""
209207
return get_float64_array(lib.Circuit_Get_TotalPower)
210208

211209

opendssdirect/CktElement.py

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
import warnings
42
from ._utils import (
53
lib,
@@ -306,6 +304,23 @@ def IsIsolated():
306304
return CheckForError(lib.CktElement_Get_IsIsolated()) != 0
307305

308306

307+
def setVariableByIndex(Idx, Value):
308+
Code = ffi.new("int32_t*")
309+
CheckForError(lib.CktElement_Set_Variablei(Idx, Code, Value))
310+
return Code[0]
311+
312+
313+
def setVariableByName(Idx, Value):
314+
Code = ffi.new("int32_t*")
315+
CheckForError(lib.CktElement_Set_Variable(Idx, Code, Value))
316+
return Code[0]
317+
318+
319+
def NodeRef():
320+
"""Array of integers, a copy of the internal NodeRef of the CktElement."""
321+
return get_int32_array(lib.CktElement_Get_NodeRef)
322+
323+
309324
_columns = [
310325
"BusNames",
311326
"CplxSeqCurrents",
@@ -394,4 +409,7 @@ def IsIsolated():
394409
"VoltagesMagAng",
395410
"YPrim",
396411
"IsIsolated",
412+
"setVariableByIndex",
413+
"setVariableByName",
414+
"NodeRef",
397415
]

opendssdirect/CmathLib.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
# -*- coding: utf-8 -*-
2-
from __future__ import absolute_import
31
from ._utils import lib, get_float64_array
42

53

0 commit comments

Comments
 (0)