Skip to content

Commit 8a24edd

Browse files
committed
Storages/COM-like: Expose in Python
The port from COM was already available in DSS C-API
1 parent 743eb88 commit 8a24edd

File tree

4 files changed

+119
-2
lines changed

4 files changed

+119
-2
lines changed

dss/dss_capi_gr/ICircuit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from .IReactors import IReactors
4646
from .IParallel import IParallel
4747
from .IReduceCkt import IReduceCkt
48+
from .IStorages import IStorages
4849

4950
class ICircuit(Base):
5051
__slots__ = [
@@ -89,7 +90,8 @@ class ICircuit(Base):
8990
'TSData',
9091
'Reactors',
9192
'Parallel',
92-
'ReduceCkt'
93+
'ReduceCkt',
94+
'Storages'
9395
]
9496

9597
_columns = [
@@ -162,6 +164,7 @@ def __init__(self, api_util):
162164
self.TSData = ITSData(api_util)
163165
self.Reactors = IReactors(api_util)
164166
self.ReduceCkt = IReduceCkt(api_util) #: Circuit Reduction Interface
167+
self.Storages = IStorages(api_util)
165168

166169
if hasattr(api_util.lib, 'Parallel_CreateActor'):
167170
self.Parallel = IParallel(api_util)

dss/dss_capi_gr/IStorages.py

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
'''
2+
A compatibility layer for DSS C-API that mimics the official OpenDSS COM interface.
3+
4+
Copyright (c) 2022 Paulo Meira
5+
Copyright (c) 2022 DSS Extensions contributors
6+
'''
7+
from .._cffi_api_util import Iterable
8+
9+
class IStorages(Iterable):
10+
'''Storage objects'''
11+
12+
__slots__ = []
13+
14+
_columns = [
15+
'Name',
16+
'idx',
17+
'RegisterNames',
18+
'RegisterValues',
19+
'puSOC',
20+
'State',
21+
]
22+
23+
24+
@property
25+
def puSOC(self):
26+
'''Per unit state of charge'''
27+
return self.CheckForError(self._lib.Storages_Get_puSOC())
28+
29+
@puSOC.setter
30+
def puSOC(self, Value):
31+
self.CheckForError(self._lib.Storages_Set_puSOC(Value))
32+
33+
@property
34+
def State(self):
35+
'''
36+
Get/set state: 0=Idling; 1=Discharging; -1=Charging;
37+
38+
Related enumeration: StorageStates
39+
'''
40+
return self.CheckForError(self._lib.Storages_Get_State())
41+
42+
@State.setter
43+
def State(self, Value):
44+
self.CheckForError(self._lib.Storages_Set_State(Value))
45+
46+
@property
47+
def RegisterNames(self):
48+
'''Array of Names of all Storage energy meter registers'''
49+
return self.CheckForError(self._get_string_array(self._lib.Storages_Get_RegisterNames))
50+
51+
@property
52+
def RegisterValues(self):
53+
'''Array of values in Storage registers.'''
54+
self.CheckForError(self._lib.Storages_Get_RegisterValues_GR())
55+
return self._get_float64_gr_array()
56+

dss/dss_capi_ir/ICircuit.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@
4545
from .IReactors import IReactors
4646
from .IParallel import IParallel
4747
from .IReduceCkt import IReduceCkt
48+
from .IStorages import IStorages
4849

4950
class ICircuit(Base):
5051
__slots__ = [
@@ -89,7 +90,8 @@ class ICircuit(Base):
8990
'TSData',
9091
'Reactors',
9192
'Parallel',
92-
'ReduceCkt'
93+
'ReduceCkt',
94+
'Storages'
9395
]
9496

9597
_columns = [
@@ -162,6 +164,7 @@ def __init__(self, api_util):
162164
self.TSData = ITSData(api_util)
163165
self.Reactors = IReactors(api_util)
164166
self.ReduceCkt = IReduceCkt(api_util) #: Circuit Reduction Interface
167+
self.Storages = IStorages(api_util)
165168

166169
if hasattr(api_util.lib, 'Parallel_CreateActor'):
167170
self.Parallel = IParallel(api_util)

dss/dss_capi_ir/IStorages.py

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
'''
2+
A compatibility layer for DSS C-API that mimics the official OpenDSS COM interface.
3+
4+
Copyright (c) 2022 Paulo Meira
5+
Copyright (c) 2022 DSS Extensions contributors
6+
'''
7+
from .._cffi_api_util import Iterable
8+
9+
class IStorages(Iterable):
10+
'''Storage objects'''
11+
12+
__slots__ = []
13+
14+
_columns = [
15+
'Name',
16+
'idx',
17+
'RegisterNames',
18+
'RegisterValues',
19+
'puSOC',
20+
'State',
21+
]
22+
23+
24+
@property
25+
def puSOC(self):
26+
'''Per unit state of charge'''
27+
return self.CheckForError(self._lib.Storages_Get_puSOC())
28+
29+
@puSOC.setter
30+
def puSOC(self, Value):
31+
self.CheckForError(self._lib.Storages_Set_puSOC(Value))
32+
33+
@property
34+
def State(self):
35+
'''
36+
Get/set state: 0=Idling; 1=Discharging; -1=Charging;
37+
38+
Related enumeration: StorageStates
39+
'''
40+
return self.CheckForError(self._lib.Storages_Get_State())
41+
42+
@State.setter
43+
def State(self, Value):
44+
self.CheckForError(self._lib.Storages_Set_State(Value))
45+
46+
@property
47+
def RegisterNames(self):
48+
'''Array of Names of all Storage energy meter registers'''
49+
return self.CheckForError(self._get_string_array(self._lib.Storages_Get_RegisterNames))
50+
51+
@property
52+
def RegisterValues(self):
53+
'''Array of values in Storage registers.'''
54+
return self._get_float64_array(self._lib.Storages_Get_RegisterValues)
55+

0 commit comments

Comments
 (0)