Fixing website and API documentation links
[PyCIM.git] / CIM15 / IEC61968 / Metering / IntervalBlock.py
blob1acaca636ed6addff659c7419e6499fd86d31fbb
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 CIM15.Element import Element
23 class IntervalBlock(Element):
24 """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.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.
25 """
27 def __init__(self, ReadingType=None, IntervalReadings=None, MeterReading=None, PendingCalculation=None, *args, **kw_args):
28 """Initialises a new 'IntervalBlock' instance.
30 @param ReadingType: Type information for interval reading values contained in this block.
31 @param IntervalReadings: Interval reading contained in this block.
32 @param MeterReading: Meter reading containing this interval block.
33 @param PendingCalculation: 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).
34 """
35 self._ReadingType = None
36 self.ReadingType = ReadingType
38 self._IntervalReadings = []
39 self.IntervalReadings = [] if IntervalReadings is None else IntervalReadings
41 self._MeterReading = None
42 self.MeterReading = MeterReading
44 self._PendingCalculation = None
45 self.PendingCalculation = PendingCalculation
47 super(IntervalBlock, self).__init__(*args, **kw_args)
49 _attrs = []
50 _attr_types = {}
51 _defaults = {}
52 _enums = {}
53 _refs = ["ReadingType", "IntervalReadings", "MeterReading", "PendingCalculation"]
54 _many_refs = ["IntervalReadings"]
56 def getReadingType(self):
57 """Type information for interval reading values contained in this block.
58 """
59 return self._ReadingType
61 def setReadingType(self, value):
62 if self._ReadingType is not None:
63 filtered = [x for x in self.ReadingType.IntervalBlocks if x != self]
64 self._ReadingType._IntervalBlocks = filtered
66 self._ReadingType = value
67 if self._ReadingType is not None:
68 if self not in self._ReadingType._IntervalBlocks:
69 self._ReadingType._IntervalBlocks.append(self)
71 ReadingType = property(getReadingType, setReadingType)
73 def getIntervalReadings(self):
74 """Interval reading contained in this block.
75 """
76 return self._IntervalReadings
78 def setIntervalReadings(self, value):
79 for p in self._IntervalReadings:
80 filtered = [q for q in p.IntervalBlocks if q != self]
81 self._IntervalReadings._IntervalBlocks = filtered
82 for r in value:
83 if self not in r._IntervalBlocks:
84 r._IntervalBlocks.append(self)
85 self._IntervalReadings = value
87 IntervalReadings = property(getIntervalReadings, setIntervalReadings)
89 def addIntervalReadings(self, *IntervalReadings):
90 for obj in IntervalReadings:
91 if self not in obj._IntervalBlocks:
92 obj._IntervalBlocks.append(self)
93 self._IntervalReadings.append(obj)
95 def removeIntervalReadings(self, *IntervalReadings):
96 for obj in IntervalReadings:
97 if self in obj._IntervalBlocks:
98 obj._IntervalBlocks.remove(self)
99 self._IntervalReadings.remove(obj)
101 def getMeterReading(self):
102 """Meter reading containing this interval block.
104 return self._MeterReading
106 def setMeterReading(self, value):
107 if self._MeterReading is not None:
108 filtered = [x for x in self.MeterReading.IntervalBlocks if x != self]
109 self._MeterReading._IntervalBlocks = filtered
111 self._MeterReading = value
112 if self._MeterReading is not None:
113 if self not in self._MeterReading._IntervalBlocks:
114 self._MeterReading._IntervalBlocks.append(self)
116 MeterReading = property(getMeterReading, setMeterReading)
118 def getPendingCalculation(self):
119 """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).
121 return self._PendingCalculation
123 def setPendingCalculation(self, value):
124 if self._PendingCalculation is not None:
125 filtered = [x for x in self.PendingCalculation.IntervalBlocks if x != self]
126 self._PendingCalculation._IntervalBlocks = filtered
128 self._PendingCalculation = value
129 if self._PendingCalculation is not None:
130 if self not in self._PendingCalculation._IntervalBlocks:
131 self._PendingCalculation._IntervalBlocks.append(self)
133 PendingCalculation = property(getPendingCalculation, setPendingCalculation)