Adding CDPSM package.
[PyCIM.git] / CIM14 / IEC61968 / Metering / IntervalBlock.py
blob79d11cfda3bceb2137ed0e27aa5a02798ce462dd
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.Element import Element
19 class IntervalBlock(Element):
20 """Time sequence of Readings of the same ReadingType. Contained IntervalReadings may need conversion through the application of an offset and a scalar defined in associated Pending.
21 """
23 def __init__(self, MeterReading=None, Pending=None, ReadingType=None, IntervalReadings=None, *args, **kw_args):
24 """Initialises a new 'IntervalBlock' instance.
26 @param MeterReading: Meter reading containing this interval block.
27 @param Pending: Pending conversion to apply to interval reading values contained by this block (after which the resulting reading type is different than the original because it reflects the conversion result).
28 @param ReadingType: Type information for interval reading values contained in this block.
29 @param IntervalReadings: Interval reading contained in this block.
30 """
31 self._MeterReading = None
32 self.MeterReading = MeterReading
34 self._Pending = None
35 self.Pending = Pending
37 self._ReadingType = None
38 self.ReadingType = ReadingType
40 self._IntervalReadings = []
41 self.IntervalReadings = [] if IntervalReadings is None else IntervalReadings
43 super(IntervalBlock, self).__init__(*args, **kw_args)
45 _attrs = []
46 _attr_types = {}
47 _defaults = {}
48 _enums = {}
49 _refs = ["MeterReading", "Pending", "ReadingType", "IntervalReadings"]
50 _many_refs = ["IntervalReadings"]
52 def getMeterReading(self):
53 """Meter reading containing this interval block.
54 """
55 return self._MeterReading
57 def setMeterReading(self, value):
58 if self._MeterReading is not None:
59 filtered = [x for x in self.MeterReading.IntervalBlocks if x != self]
60 self._MeterReading._IntervalBlocks = filtered
62 self._MeterReading = value
63 if self._MeterReading is not None:
64 if self not in self._MeterReading._IntervalBlocks:
65 self._MeterReading._IntervalBlocks.append(self)
67 MeterReading = property(getMeterReading, setMeterReading)
69 def getPending(self):
70 """Pending conversion to apply to interval reading values contained by this block (after which the resulting reading type is different than the original because it reflects the conversion result).
71 """
72 return self._Pending
74 def setPending(self, value):
75 if self._Pending is not None:
76 filtered = [x for x in self.Pending.IntervalBlocks if x != self]
77 self._Pending._IntervalBlocks = filtered
79 self._Pending = value
80 if self._Pending is not None:
81 if self not in self._Pending._IntervalBlocks:
82 self._Pending._IntervalBlocks.append(self)
84 Pending = property(getPending, setPending)
86 def getReadingType(self):
87 """Type information for interval reading values contained in this block.
88 """
89 return self._ReadingType
91 def setReadingType(self, value):
92 if self._ReadingType is not None:
93 filtered = [x for x in self.ReadingType.IntervalBlocks if x != self]
94 self._ReadingType._IntervalBlocks = filtered
96 self._ReadingType = value
97 if self._ReadingType is not None:
98 if self not in self._ReadingType._IntervalBlocks:
99 self._ReadingType._IntervalBlocks.append(self)
101 ReadingType = property(getReadingType, setReadingType)
103 def getIntervalReadings(self):
104 """Interval reading contained in this block.
106 return self._IntervalReadings
108 def setIntervalReadings(self, value):
109 for p in self._IntervalReadings:
110 filtered = [q for q in p.IntervalBlocks if q != self]
111 self._IntervalReadings._IntervalBlocks = filtered
112 for r in value:
113 if self not in r._IntervalBlocks:
114 r._IntervalBlocks.append(self)
115 self._IntervalReadings = value
117 IntervalReadings = property(getIntervalReadings, setIntervalReadings)
119 def addIntervalReadings(self, *IntervalReadings):
120 for obj in IntervalReadings:
121 if self not in obj._IntervalBlocks:
122 obj._IntervalBlocks.append(self)
123 self._IntervalReadings.append(obj)
125 def removeIntervalReadings(self, *IntervalReadings):
126 for obj in IntervalReadings:
127 if self in obj._IntervalBlocks:
128 obj._IntervalBlocks.remove(self)
129 self._IntervalReadings.remove(obj)