Adding CDPSM package.
[PyCIM.git] / CIM14 / IEC61968 / Metering / ReadingQuality.py
blob810471faa778d2ce0be5bb33ee97a1a33ebee8d0
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 ReadingQuality(Element):
20 """Quality of a specific reading value or interval reading value. Note that more than one Quality may be applicable to a given Reading. Typically not used unless problems or unusual conditions occur (i.e., quality for each Reading is assumed to be 'Good' unless stated otherwise in associated ReadingQuality).
21 """
23 def __init__(self, quality='', IntervalReading=None, Reading=None, *args, **kw_args):
24 """Initialises a new 'ReadingQuality' instance.
26 @param quality: Quality, to be specified if different than 'Good'.
27 @param IntervalReading: Interval reading value to which this quality applies.
28 @param Reading: Reading value to which this quality applies.
29 """
30 #: Quality, to be specified if different than 'Good'.
31 self.quality = quality
33 self._IntervalReading = None
34 self.IntervalReading = IntervalReading
36 self._Reading = None
37 self.Reading = Reading
39 super(ReadingQuality, self).__init__(*args, **kw_args)
41 _attrs = ["quality"]
42 _attr_types = {"quality": str}
43 _defaults = {"quality": ''}
44 _enums = {}
45 _refs = ["IntervalReading", "Reading"]
46 _many_refs = []
48 def getIntervalReading(self):
49 """Interval reading value to which this quality applies.
50 """
51 return self._IntervalReading
53 def setIntervalReading(self, value):
54 if self._IntervalReading is not None:
55 filtered = [x for x in self.IntervalReading.ReadingQualities if x != self]
56 self._IntervalReading._ReadingQualities = filtered
58 self._IntervalReading = value
59 if self._IntervalReading is not None:
60 if self not in self._IntervalReading._ReadingQualities:
61 self._IntervalReading._ReadingQualities.append(self)
63 IntervalReading = property(getIntervalReading, setIntervalReading)
65 def getReading(self):
66 """Reading value to which this quality applies.
67 """
68 return self._Reading
70 def setReading(self, value):
71 if self._Reading is not None:
72 filtered = [x for x in self.Reading.ReadingQualities if x != self]
73 self._Reading._ReadingQualities = filtered
75 self._Reading = value
76 if self._Reading is not None:
77 if self not in self._Reading._ReadingQualities:
78 self._Reading._ReadingQualities.append(self)
80 Reading = property(getReading, setReading)