Adding class meta-data attributes.
[PyCIM.git] / schemata / CIM14 / IEC61970 / Meas / Analog.py
bloba248e99ad18973e2065c5ad2ec8150ba0cdc361c
1 # Copyright (C) 2010 Richard Lincoln
3 # This library is free software; you can redistribute it and/or
4 # modify it under the terms of the GNU Lesser General Public
5 # License as published by the Free Software Foundation; either
6 # version 2.1 of the License, or (at your option) any later version.
8 # This library is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11 # Lesser General Public License for more details.
13 # You should have received a copy of the GNU Lesser General Public
14 # License along with this library; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA, USA
17 from CIM14.IEC61970.Meas.Measurement import Measurement
19 class Analog(Measurement):
20 """Analog represents an analog Measurement.
21 """
23 def __init__(self, positiveFlowIn=False, minValue=0.0, maxValue=0.0, normalValue=0.0, LimitSets=None, SetPoint=None, AnalogValues=None, *args, **kw_args):
24 """Initialises a new 'Analog' instance.
26 @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.
27 @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
28 @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.
29 @param normalValue: Normal measurement value, e.g., used for percentage calculations.
30 @param LimitSets: A measurement may have zero or more limit ranges defined for it.
31 @param SetPoint: The Control variable associated with the Measurement
32 @param AnalogValues: The values connected to this measurement.
33 """
34 #: 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.
35 self.positiveFlowIn = positiveFlowIn
37 #: Normal value range minimum for any of the MeasurementValue.values. Used for scaling, e.g. in bar graphs or of telemetered raw values
38 self.minValue = minValue
40 #: Normal value range maximum for any of the MeasurementValue.values. Used for scaling, e.g. in bar graphs or of telemetered raw values.
41 self.maxValue = maxValue
43 #: Normal measurement value, e.g., used for percentage calculations.
44 self.normalValue = normalValue
46 self._LimitSets = []
47 self.LimitSets = [] if LimitSets is None else LimitSets
49 self._SetPoint = None
50 self.SetPoint = SetPoint
52 self._AnalogValues = []
53 self.AnalogValues = [] if AnalogValues is None else AnalogValues
55 super(Analog, self).__init__(*args, **kw_args)
57 _attrs = ["positiveFlowIn", "minValue", "maxValue", "normalValue"]
58 _attr_types = {"positiveFlowIn": bool, "minValue": float, "maxValue": float, "normalValue": float}
59 _defaults = {"positiveFlowIn": False, "minValue": 0.0, "maxValue": 0.0, "normalValue": 0.0}
60 _enums = {}
61 _refs = ["LimitSets", "SetPoint", "AnalogValues"]
62 _many_refs = ["LimitSets", "AnalogValues"]
64 def getLimitSets(self):
65 """A measurement may have zero or more limit ranges defined for it.
66 """
67 return self._LimitSets
69 def setLimitSets(self, value):
70 for p in self._LimitSets:
71 filtered = [q for q in p.Measurements if q != self]
72 self._LimitSets._Measurements = filtered
73 for r in value:
74 if self not in r._Measurements:
75 r._Measurements.append(self)
76 self._LimitSets = value
78 LimitSets = property(getLimitSets, setLimitSets)
80 def addLimitSets(self, *LimitSets):
81 for obj in LimitSets:
82 if self not in obj._Measurements:
83 obj._Measurements.append(self)
84 self._LimitSets.append(obj)
86 def removeLimitSets(self, *LimitSets):
87 for obj in LimitSets:
88 if self in obj._Measurements:
89 obj._Measurements.remove(self)
90 self._LimitSets.remove(obj)
92 def getSetPoint(self):
93 """The Control variable associated with the Measurement
94 """
95 return self._SetPoint
97 def setSetPoint(self, value):
98 if self._SetPoint is not None:
99 self._SetPoint._Analog = None
101 self._SetPoint = value
102 if self._SetPoint is not None:
103 self._SetPoint._Analog = self
105 SetPoint = property(getSetPoint, setSetPoint)
107 def getAnalogValues(self):
108 """The values connected to this measurement.
110 return self._AnalogValues
112 def setAnalogValues(self, value):
113 for x in self._AnalogValues:
114 x._Analog = None
115 for y in value:
116 y._Analog = self
117 self._AnalogValues = value
119 AnalogValues = property(getAnalogValues, setAnalogValues)
121 def addAnalogValues(self, *AnalogValues):
122 for obj in AnalogValues:
123 obj._Analog = self
124 self._AnalogValues.append(obj)
126 def removeAnalogValues(self, *AnalogValues):
127 for obj in AnalogValues:
128 obj._Analog = None
129 self._AnalogValues.remove(obj)