Skip to content

Commit dcbe4bc

Browse files
committed
- The enum34 module was added as a dependency for Python < 3.5.
- The `Options` enumeration was split into several new enumerations and marked as deprecated.
1 parent 6b21718 commit dcbe4bc

File tree

3 files changed

+125
-86
lines changed

3 files changed

+125
-86
lines changed

docs/changelog.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
(not released)
44

55
- `CtrlQueue`: Add the missing function `Push`.
6-
6+
- The `enum34` module was added as a dependency for Python < 3.5.
7+
- The `Options` enumeration was split into several new enumerations (`AutoAddTypes`, `CktModels`, `ControlModes`, `SolutionLoadModels`, `SolutionAlgorithms`, `RandomModes`). It is now marked as deprecated for future removal.
78

89
# 0.10.1
910

dss/enums.py

Lines changed: 116 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -1,94 +1,126 @@
11
import sys
2-
if (sys.version_info.major, sys.version_info.minor) >= (3, 4):
3-
import enum
4-
Base = enum.IntEnum
5-
else:
6-
Base = object
2+
from enum import IntEnum
73

8-
class MonitorModes(Base):
9-
VI = 0x00000000
10-
Power = 0x00000001
11-
Sequence = 0x00000010
12-
Magnitude = 0x00000020
13-
PosOnly = 0x00000040
14-
Taps = 0x00000002
15-
States = 0x00000003
4+
class MonitorModes(IntEnum):
5+
VI = 0x00 # Monitor records Voltage and Current at the terminal (Default)
6+
Power = 0x01 # Monitor records kW, kvar or kVA, angle values, etc. at the terminal to which it is connected.
7+
Taps = 0x02 # For monitoring Regulator and Transformer taps
8+
States = 0x03 # For monitoring State Variables (for PC Elements only)
9+
Sequence = 0x10 # Reports the monitored quantities as sequence quantities
10+
Magnitude = 0x20 # Reports the monitored quantities in Magnitude Only
11+
PosOnly = 0x40 # Reports the Positive Seq only or avg of all phases
1612

17-
class SolveModes(Base):
18-
SnapShot = 0x00000000
19-
DutyCycle = 0x00000006
20-
Direct = 0x00000007
21-
Daily = 0x00000001
22-
Monte1 = 0x00000003
23-
Monte2 = 0x0000000A
24-
Monte3 = 0x0000000B
25-
FaultStudy = 0x00000009
26-
Yearly = 0x00000002
27-
MonteFault = 0x00000008
28-
PeakDay = 0x00000005
29-
LD1 = 0x00000004
30-
LD2 = 0x0000000C
31-
AutoAdd = 0x0000000D
32-
Harmonic = 0x0000000F
33-
Dynamic = 0x0000000E
13+
class SolveModes(IntEnum):
14+
SnapShot = 0 # Solve a single snapshot power flow
15+
Daily = 1 # Solve following Daily load shapes
16+
Yearly = 2 # Solve following Yearly load shapes
17+
Monte1 = 3 # Monte Carlo Mode 1
18+
LD1 = 4 # Load-duration Mode 1
19+
PeakDay = 5 # Solves for Peak Day using Daily load curve
20+
DutyCycle = 6 # Solve following Duty Cycle load shapes
21+
Direct = 7 # Solve direct (forced admittance model)
22+
MonteFault = 8 # Monte carlo Fault Study
23+
FaultStudy = 9 # Fault study at all buses
24+
Monte2 = 10 # Monte Carlo Mode 2
25+
Monte3 = 11 # Monte Carlo Mode 3
26+
LD2 = 12 # Load-Duration Mode 2
27+
AutoAdd = 13 # Auto add generators or capacitors
28+
Dynamic = 14 # Solve for dynamics
29+
Harmonic = 15 # Harmonic solution mode
3430

35-
class Options(Base):
36-
PowerFlow = 0x00000001
37-
Admittance = 0x00000002
38-
NormalSolve = 0x00000000
39-
NewtonSolve = 0x00000001
40-
Static = 0x00000000
41-
Event = 0x00000001
42-
Time = 0x00000002
43-
Multiphase = 0x00000000
44-
PositiveSeq = 0x00000001
45-
Gaussian = 0x00000001
46-
Uniform = 0x00000002
47-
LogNormal = 0x00000003
48-
AddGen = 0x00000001
49-
AddCap = 0x00000002
50-
ControlOFF = 0xFFFFFFFF
31+
class Options(IntEnum):
32+
'''Deprecated. Please use instead:
33+
- AutoAddTypes
34+
- CktModels
35+
- ControlModes
36+
- SolutionLoadModels
37+
- SolutionAlgorithms
38+
- RandomModes
39+
'''
40+
41+
PowerFlow = 1
42+
Admittance = 2
43+
NormalSolve = 0
44+
NewtonSolve = 1
45+
Static = 0
46+
Event = 1
47+
Time = 2
48+
Multiphase = 0
49+
PositiveSeq = 1
50+
Gaussian = 1
51+
Uniform = 2
52+
LogNormal = 3
53+
AddGen = 1
54+
AddCap = 2
55+
ControlOFF = -1
56+
57+
class SolutionLoadModels(IntEnum):
58+
PowerFlow = 1 # Power Flow load model option
59+
Admittance = 2 # Admittance load model option
5160

52-
class CapControlModes(Base):
53-
Voltage = 0x00000001
54-
KVAR = 0x00000002
55-
Current = 0x00000000
56-
PF = 0x00000004
57-
Time = 0x00000003
61+
class SolutionAlgorithms(IntEnum):
62+
NormalSolve = 0 # Solution algorithm option - Normal solution
63+
NewtonSolve = 1 # Solution algorithm option - Newton solution
64+
65+
class ControlModes(IntEnum):
66+
Static = 0 # Control Mode option - Static
67+
Event = 1 # Control Mode Option - Event driven solution mode
68+
Time = 2 # Control mode option - Time driven mode
69+
Multirate = 3 # Control mode option - Multirate mode
70+
Off = -1 # Control Mode OFF
71+
72+
class CktModels(IntEnum):
73+
Multiphase = 0 # Circuit model is multiphase (default)
74+
PositiveSeq = 1 # Circuit model is positive sequence model only
75+
76+
class RandomModes(IntEnum):
77+
Gaussian = 1 # Gaussian
78+
Uniform = 2 # Uniform
79+
LogNormal = 3 # Log normal
80+
81+
class AutoAddTypes(IntEnum):
82+
AddGen = 1 # Add generators in AutoAdd mode
83+
AddCap = 2 # Add capacitors in AutoAdd mode
84+
85+
class CapControlModes(IntEnum):
86+
Current = 0 # Current control, ON and OFF settings on CT secondary
87+
Voltage = 1 # Voltage control, ON and OFF settings on the PT secondary base
88+
KVAR = 2 # kVAR control, ON and OFF settings on PT / CT base
89+
Time = 3 # Time control, ON and OFF settings are seconds from midnight
90+
PF = 4 # ON and OFF settings are power factor, negative for leading
5891

5992
class ActionCodes:
60-
none = 0x00000000
61-
Open = 0x00000001
62-
Close = 0x00000002
63-
Reset = 0x00000003
64-
Lock = 0x00000004
65-
Unlock = 0x00000005
66-
TapUp = 0x00000006
67-
TapDown = 0x00000007
93+
none = 0 # No action
94+
Open = 1 # Open a switch
95+
Close = 2 # Close a switch
96+
Reset = 3 # Reset to the shelf state (unlocked, closed for a switch)
97+
Lock = 4 # Lock a switch, prventing both manual and automatic operation
98+
Unlock = 5 # Unlock a switch, permitting both manual and automatic operation
99+
TapUp = 6 # Move a regulator tap up
100+
TapDown = 7 # Move a regulator tap down
68101

69-
class LoadStatus(Base):
70-
Variable = 0x00000000
71-
Fixed = 0x00000001
72-
Exempt = 0x00000002
102+
class LoadStatus(IntEnum):
103+
Variable = 0
104+
Fixed = 1
105+
Exempt = 2
73106

74-
class LoadModels(Base):
75-
ConstPQ = 0x00000001
76-
ConstZ = 0x00000002
77-
Motor = 0x00000003
78-
CVR = 0x00000004
79-
ConstI = 0x00000005
80-
ConstPFixedQ = 0x00000006
81-
ConstPFixedX = 0x00000007
82-
ZIPV = 0x00000008
107+
class LoadModels(IntEnum):
108+
ConstPQ = 1
109+
ConstZ = 2
110+
Motor = 3
111+
CVR = 4
112+
ConstI = 5
113+
ConstPFixedQ = 6
114+
ConstPFixedX = 7
115+
ZIPV = 8
83116

84-
class LineUnits(Base):
85-
none = 0x00000000
86-
Miles = 0x00000001
87-
kFt = 0x00000002
88-
km = 0x00000003
89-
meter = 0x00000004
90-
ft = 0x00000005
91-
inch = 0x00000006
92-
cm = 0x00000007
93-
mm = 0x00000008
94-
Maxnum = 0x00000009
117+
class LineUnits(IntEnum):
118+
none = 0 # No line length unit
119+
Miles = 1 # Line length units in miles
120+
kFt = 2 # Line length units are in thousand feet
121+
km = 3 # Line length units are km
122+
meter = 4 # Line length units are meters
123+
ft = 5 # Line units in feet
124+
inch = 6 # Line length units are inches
125+
cm = 7 # Line units are cm
126+
mm = 8 # Line length units are mm

setup.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@
5555
})
5656

5757

58+
# (2019-02-24) PEP 496 didn't work, using a workaround
59+
if (sys.version_info.major, sys.version_info.minor) < (3, 5):
60+
compat_requires = ['enum34']
61+
else:
62+
compat_requires = []
63+
5864
setup(
5965
name="dss_python",
6066
description="OpenDSS bindings and tools based on the DSS C-API project",
@@ -75,7 +81,7 @@
7581
'dss_build.py:ffi_builder_CapUserControl'
7682
],
7783
ext_package="dss",
78-
install_requires=["cffi>=1.11.2", "numpy>=1.0"],
84+
install_requires=["cffi>=1.11.2", "numpy>=1.0"] + compat_requires,
7985
zip_safe=False,
8086
classifiers=[
8187
'Intended Audience :: Science/Research',

0 commit comments

Comments
 (0)