1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 from CIM14
.IEC61970
.Meas
.Measurement
import Measurement
23 class Analog(Measurement
):
24 """Analog represents an analog Measurement.
27 def __init__(self
, positiveFlowIn
=False, minValue
=0.0, maxValue
=0.0, normalValue
=0.0, LimitSets
=None, SetPoint
=None, AnalogValues
=None, *args
, **kw_args
):
28 """Initialises a new 'Analog' instance.
30 @param positiveFlowIn: If true then this measurement is an active power, reactive power or current with the convention that a positive value measured at the Terminal means power is flowing into the related PowerSystemResource.
31 @param minValue: Normal value range minimum for any of the MeasurementValue.values. Used for scaling, e.g. in bar graphs or of telemetered raw values
32 @param maxValue: Normal value range maximum for any of the MeasurementValue.values. Used for scaling, e.g. in bar graphs or of telemetered raw values.
33 @param normalValue: Normal measurement value, e.g., used for percentage calculations.
34 @param LimitSets: A measurement may have zero or more limit ranges defined for it.
35 @param SetPoint: The Control variable associated with the Measurement
36 @param AnalogValues: The values connected to this measurement.
38 #: If true then this measurement is an active power, reactive power or current with the convention that a positive value measured at the Terminal means power is flowing into the related PowerSystemResource.
39 self
.positiveFlowIn
= positiveFlowIn
41 #: Normal value range minimum for any of the MeasurementValue.values. Used for scaling, e.g. in bar graphs or of telemetered raw values
42 self
.minValue
= minValue
44 #: Normal value range maximum for any of the MeasurementValue.values. Used for scaling, e.g. in bar graphs or of telemetered raw values.
45 self
.maxValue
= maxValue
47 #: Normal measurement value, e.g., used for percentage calculations.
48 self
.normalValue
= normalValue
51 self
.LimitSets
= [] if LimitSets
is None else LimitSets
54 self
.SetPoint
= SetPoint
56 self
._AnalogValues
= []
57 self
.AnalogValues
= [] if AnalogValues
is None else AnalogValues
59 super(Analog
, self
).__init
__(*args
, **kw_args
)
61 _attrs
= ["positiveFlowIn", "minValue", "maxValue", "normalValue"]
62 _attr_types
= {"positiveFlowIn": bool, "minValue": float, "maxValue": float, "normalValue": float}
63 _defaults
= {"positiveFlowIn": False, "minValue": 0.0, "maxValue": 0.0, "normalValue": 0.0}
65 _refs
= ["LimitSets", "SetPoint", "AnalogValues"]
66 _many_refs
= ["LimitSets", "AnalogValues"]
68 def getLimitSets(self
):
69 """A measurement may have zero or more limit ranges defined for it.
71 return self
._LimitSets
73 def setLimitSets(self
, value
):
74 for p
in self
._LimitSets
:
75 filtered
= [q
for q
in p
.Measurements
if q
!= self
]
76 self
._LimitSets
._Measurements
= filtered
78 if self
not in r
._Measurements
:
79 r
._Measurements
.append(self
)
80 self
._LimitSets
= value
82 LimitSets
= property(getLimitSets
, setLimitSets
)
84 def addLimitSets(self
, *LimitSets
):
86 if self
not in obj
._Measurements
:
87 obj
._Measurements
.append(self
)
88 self
._LimitSets
.append(obj
)
90 def removeLimitSets(self
, *LimitSets
):
92 if self
in obj
._Measurements
:
93 obj
._Measurements
.remove(self
)
94 self
._LimitSets
.remove(obj
)
96 def getSetPoint(self
):
97 """The Control variable associated with the Measurement
101 def setSetPoint(self
, value
):
102 if self
._SetPoint
is not None:
103 self
._SetPoint
._Analog
= None
105 self
._SetPoint
= value
106 if self
._SetPoint
is not None:
107 self
._SetPoint
.Analog
= None
108 self
._SetPoint
._Analog
= self
110 SetPoint
= property(getSetPoint
, setSetPoint
)
112 def getAnalogValues(self
):
113 """The values connected to this measurement.
115 return self
._AnalogValues
117 def setAnalogValues(self
, value
):
118 for x
in self
._AnalogValues
:
122 self
._AnalogValues
= value
124 AnalogValues
= property(getAnalogValues
, setAnalogValues
)
126 def addAnalogValues(self
, *AnalogValues
):
127 for obj
in AnalogValues
:
130 def removeAnalogValues(self
, *AnalogValues
):
131 for obj
in AnalogValues
: