Implementing RDF/XML serialisation using meta-data attributes.
[PyCIM.git] / schemata / CIM14 / IEC61968 / Metering / IntervalReading.py
blob4645c82f9635e8f866d6c683d71c342d029e741d
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.MeasurementValue import MeasurementValue
19 class IntervalReading(MeasurementValue):
20 """Data captured at regular intervals of time. Interval data could be captured as incremental data, absolute data, or relative data. The source for the data is usually a tariff quantity or an engineering quantity. Data is typically captured in time-tagged, uniform, fixed-length intervals of 5 min, 10 min, 15 min, 30 min, or 60 min. Note: Interval Data is sometimes also called 'Interval Data Readings' (IDR).
21 """
23 def __init__(self, value=0.0, ReadingQualities=None, IntervalBlocks=None, *args, **kw_args):
24 """Initialises a new 'IntervalReading' instance.
26 @param value: Value of this interval reading.
27 @param ReadingQualities: Used only if quality of this interval reading value is different than 'Good'.
28 @param IntervalBlocks: All blocks containing this interval reading.
29 """
30 #: Value of this interval reading.
31 self.value = value
33 self._ReadingQualities = []
34 self.ReadingQualities = [] if ReadingQualities is None else ReadingQualities
36 self._IntervalBlocks = []
37 self.IntervalBlocks = [] if IntervalBlocks is None else IntervalBlocks
39 super(IntervalReading, self).__init__(*args, **kw_args)
41 _attrs = ["value"]
42 _attr_types = {"value": float}
43 _defaults = {"value": 0.0}
44 _enums = {}
45 _refs = ["ReadingQualities", "IntervalBlocks"]
46 _many_refs = ["ReadingQualities", "IntervalBlocks"]
48 def getReadingQualities(self):
49 """Used only if quality of this interval reading value is different than 'Good'.
50 """
51 return self._ReadingQualities
53 def setReadingQualities(self, value):
54 for x in self._ReadingQualities:
55 x._IntervalReading = None
56 for y in value:
57 y._IntervalReading = self
58 self._ReadingQualities = value
60 ReadingQualities = property(getReadingQualities, setReadingQualities)
62 def addReadingQualities(self, *ReadingQualities):
63 for obj in ReadingQualities:
64 obj._IntervalReading = self
65 self._ReadingQualities.append(obj)
67 def removeReadingQualities(self, *ReadingQualities):
68 for obj in ReadingQualities:
69 obj._IntervalReading = None
70 self._ReadingQualities.remove(obj)
72 def getIntervalBlocks(self):
73 """All blocks containing this interval reading.
74 """
75 return self._IntervalBlocks
77 def setIntervalBlocks(self, value):
78 for p in self._IntervalBlocks:
79 filtered = [q for q in p.IntervalReadings if q != self]
80 self._IntervalBlocks._IntervalReadings = filtered
81 for r in value:
82 if self not in r._IntervalReadings:
83 r._IntervalReadings.append(self)
84 self._IntervalBlocks = value
86 IntervalBlocks = property(getIntervalBlocks, setIntervalBlocks)
88 def addIntervalBlocks(self, *IntervalBlocks):
89 for obj in IntervalBlocks:
90 if self not in obj._IntervalReadings:
91 obj._IntervalReadings.append(self)
92 self._IntervalBlocks.append(obj)
94 def removeIntervalBlocks(self, *IntervalBlocks):
95 for obj in IntervalBlocks:
96 if self in obj._IntervalReadings:
97 obj._IntervalReadings.remove(self)
98 self._IntervalBlocks.remove(obj)