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
.Core
.IdentifiedObject
import IdentifiedObject
19 class MeterReading(IdentifiedObject
):
20 """Set of values obtained from the meter.
23 def __init__(self
, IntervalBlocks
=None, CustomerAgreement
=None, MeterAsset
=None, EndDeviceEvents
=None, Readings
=None, ServiceDeliveryPoint
=None, valuesInterval
=None, *args
, **kw_args
):
24 """Initialises a new 'MeterReading' instance.
26 @param IntervalBlocks: All interval blocks contained in this meter reading.
27 @param CustomerAgreement: (could be deprecated in the future) Customer agreement for this meter reading.
28 @param MeterAsset: Meter asset providing this meter reading.
29 @param EndDeviceEvents: All end device events associated with this set of measured values.
30 @param Readings: All reading values contained within this meter reading.
31 @param ServiceDeliveryPoint: Service delivery point from which this meter reading (set of values) has been obtained.
32 @param valuesInterval: Date and time interval of the data items contained within this meter reading.
34 self
._IntervalBlocks
= []
35 self
.IntervalBlocks
= [] if IntervalBlocks
is None else IntervalBlocks
37 self
._CustomerAgreement
= None
38 self
.CustomerAgreement
= CustomerAgreement
40 self
._MeterAsset
= None
41 self
.MeterAsset
= MeterAsset
43 self
._EndDeviceEvents
= []
44 self
.EndDeviceEvents
= [] if EndDeviceEvents
is None else EndDeviceEvents
47 self
.Readings
= [] if Readings
is None else Readings
49 self
._ServiceDeliveryPoint
= None
50 self
.ServiceDeliveryPoint
= ServiceDeliveryPoint
52 self
.valuesInterval
= valuesInterval
54 super(MeterReading
, self
).__init
__(*args
, **kw_args
)
60 _refs
= ["IntervalBlocks", "CustomerAgreement", "MeterAsset", "EndDeviceEvents", "Readings", "ServiceDeliveryPoint", "valuesInterval"]
61 _many_refs
= ["IntervalBlocks", "EndDeviceEvents", "Readings"]
63 def getIntervalBlocks(self
):
64 """All interval blocks contained in this meter reading.
66 return self
._IntervalBlocks
68 def setIntervalBlocks(self
, value
):
69 for x
in self
._IntervalBlocks
:
70 x
._MeterReading
= None
72 y
._MeterReading
= self
73 self
._IntervalBlocks
= value
75 IntervalBlocks
= property(getIntervalBlocks
, setIntervalBlocks
)
77 def addIntervalBlocks(self
, *IntervalBlocks
):
78 for obj
in IntervalBlocks
:
79 obj
._MeterReading
= self
80 self
._IntervalBlocks
.append(obj
)
82 def removeIntervalBlocks(self
, *IntervalBlocks
):
83 for obj
in IntervalBlocks
:
84 obj
._MeterReading
= None
85 self
._IntervalBlocks
.remove(obj
)
87 def getCustomerAgreement(self
):
88 """(could be deprecated in the future) Customer agreement for this meter reading.
90 return self
._CustomerAgreement
92 def setCustomerAgreement(self
, value
):
93 if self
._CustomerAgreement
is not None:
94 filtered
= [x
for x
in self
.CustomerAgreement
.MeterReadings
if x
!= self
]
95 self
._CustomerAgreement
._MeterReadings
= filtered
97 self
._CustomerAgreement
= value
98 if self
._CustomerAgreement
is not None:
99 self
._CustomerAgreement
._MeterReadings
.append(self
)
101 CustomerAgreement
= property(getCustomerAgreement
, setCustomerAgreement
)
103 def getMeterAsset(self
):
104 """Meter asset providing this meter reading.
106 return self
._MeterAsset
108 def setMeterAsset(self
, value
):
109 if self
._MeterAsset
is not None:
110 filtered
= [x
for x
in self
.MeterAsset
.MeterReadings
if x
!= self
]
111 self
._MeterAsset
._MeterReadings
= filtered
113 self
._MeterAsset
= value
114 if self
._MeterAsset
is not None:
115 self
._MeterAsset
._MeterReadings
.append(self
)
117 MeterAsset
= property(getMeterAsset
, setMeterAsset
)
119 def getEndDeviceEvents(self
):
120 """All end device events associated with this set of measured values.
122 return self
._EndDeviceEvents
124 def setEndDeviceEvents(self
, value
):
125 for x
in self
._EndDeviceEvents
:
126 x
._MeterReading
= None
128 y
._MeterReading
= self
129 self
._EndDeviceEvents
= value
131 EndDeviceEvents
= property(getEndDeviceEvents
, setEndDeviceEvents
)
133 def addEndDeviceEvents(self
, *EndDeviceEvents
):
134 for obj
in EndDeviceEvents
:
135 obj
._MeterReading
= self
136 self
._EndDeviceEvents
.append(obj
)
138 def removeEndDeviceEvents(self
, *EndDeviceEvents
):
139 for obj
in EndDeviceEvents
:
140 obj
._MeterReading
= None
141 self
._EndDeviceEvents
.remove(obj
)
143 def getReadings(self
):
144 """All reading values contained within this meter reading.
146 return self
._Readings
148 def setReadings(self
, value
):
149 for p
in self
._Readings
:
150 filtered
= [q
for q
in p
.MeterReadings
if q
!= self
]
151 self
._Readings
._MeterReadings
= filtered
153 if self
not in r
._MeterReadings
:
154 r
._MeterReadings
.append(self
)
155 self
._Readings
= value
157 Readings
= property(getReadings
, setReadings
)
159 def addReadings(self
, *Readings
):
161 if self
not in obj
._MeterReadings
:
162 obj
._MeterReadings
.append(self
)
163 self
._Readings
.append(obj
)
165 def removeReadings(self
, *Readings
):
167 if self
in obj
._MeterReadings
:
168 obj
._MeterReadings
.remove(self
)
169 self
._Readings
.remove(obj
)
171 def getServiceDeliveryPoint(self
):
172 """Service delivery point from which this meter reading (set of values) has been obtained.
174 return self
._ServiceDeliveryPoint
176 def setServiceDeliveryPoint(self
, value
):
177 if self
._ServiceDeliveryPoint
is not None:
178 filtered
= [x
for x
in self
.ServiceDeliveryPoint
.MeterReadings
if x
!= self
]
179 self
._ServiceDeliveryPoint
._MeterReadings
= filtered
181 self
._ServiceDeliveryPoint
= value
182 if self
._ServiceDeliveryPoint
is not None:
183 self
._ServiceDeliveryPoint
._MeterReadings
.append(self
)
185 ServiceDeliveryPoint
= property(getServiceDeliveryPoint
, setServiceDeliveryPoint
)
187 # Date and time interval of the data items contained within this meter reading.
188 valuesInterval
= None