Fixing website and API documentation links
[PyCIM.git] / CIM14 / IEC61970 / Meas / Accumulator.py
blob11b8b0c12b27eb23c0d407201947723aad684610
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
19 # IN THE SOFTWARE.
21 from CIM14.IEC61970.Meas.Measurement import Measurement
23 class Accumulator(Measurement):
24 """Accumulator represents a accumulated (counted) Measurement, e.g. an energy value.
25 """
27 def __init__(self, maxValue=0, LimitSets=None, AccumulatorValues=None, *args, **kw_args):
28 """Initialises a new 'Accumulator' instance.
30 @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.
31 @param LimitSets: A measurement may have zero or more limit ranges defined for it.
32 @param AccumulatorValues: The values connected to this measurement.
33 """
34 #: Normal value range maximum for any of the MeasurementValue.values. Used for scaling, e.g. in bar graphs or of telemetered raw values.
35 self.maxValue = maxValue
37 self._LimitSets = []
38 self.LimitSets = [] if LimitSets is None else LimitSets
40 self._AccumulatorValues = []
41 self.AccumulatorValues = [] if AccumulatorValues is None else AccumulatorValues
43 super(Accumulator, self).__init__(*args, **kw_args)
45 _attrs = ["maxValue"]
46 _attr_types = {"maxValue": int}
47 _defaults = {"maxValue": 0}
48 _enums = {}
49 _refs = ["LimitSets", "AccumulatorValues"]
50 _many_refs = ["LimitSets", "AccumulatorValues"]
52 def getLimitSets(self):
53 """A measurement may have zero or more limit ranges defined for it.
54 """
55 return self._LimitSets
57 def setLimitSets(self, value):
58 for p in self._LimitSets:
59 filtered = [q for q in p.Measurements if q != self]
60 self._LimitSets._Measurements = filtered
61 for r in value:
62 if self not in r._Measurements:
63 r._Measurements.append(self)
64 self._LimitSets = value
66 LimitSets = property(getLimitSets, setLimitSets)
68 def addLimitSets(self, *LimitSets):
69 for obj in LimitSets:
70 if self not in obj._Measurements:
71 obj._Measurements.append(self)
72 self._LimitSets.append(obj)
74 def removeLimitSets(self, *LimitSets):
75 for obj in LimitSets:
76 if self in obj._Measurements:
77 obj._Measurements.remove(self)
78 self._LimitSets.remove(obj)
80 def getAccumulatorValues(self):
81 """The values connected to this measurement.
82 """
83 return self._AccumulatorValues
85 def setAccumulatorValues(self, value):
86 for x in self._AccumulatorValues:
87 x.Accumulator = None
88 for y in value:
89 y._Accumulator = self
90 self._AccumulatorValues = value
92 AccumulatorValues = property(getAccumulatorValues, setAccumulatorValues)
94 def addAccumulatorValues(self, *AccumulatorValues):
95 for obj in AccumulatorValues:
96 obj.Accumulator = self
98 def removeAccumulatorValues(self, *AccumulatorValues):
99 for obj in AccumulatorValues:
100 obj.Accumulator = None