Bumping version for release.
[PyCIM.git] / CIM14 / IEC61968 / PaymentMetering / ConsumptionTariffInterval.py
blob2380960fdea3974104d38ca68cd83f86114193da
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 ConsumptionTariffInterval(Element):
20 """One of a sequence of intervals defined in terms of consumption quantity of a service such as electricity, water, gas, etc. It is typically used in association with TariffProfile to define the steps or blocks in a step tariff structure, where startValue simultaneously defines the entry value of this step and the closing value of the previous step. Where consumption is >= startValue it falls within this interval and where consumption is < startValue it falls within the previous interval.
21 """
23 def __init__(self, sequenceNumber=0, startValue=0.0, TariffProfiles=None, Charges=None, *args, **kw_args):
24 """Initialises a new 'ConsumptionTariffInterval' instance.
26 @param sequenceNumber: A sequential reference that defines the identity of this interval and its relative position with respect to other intervals in a sequence of intervals.
27 @param startValue: The lowest level of consumption that defines the starting point of this interval. The interval extends to the start of the next interval or until it is reset to the start of the first interval by TariffProfile.tariffCycle.
28 @param TariffProfiles: All tariff profiles defined by this consumption tariff interval.
29 @param Charges: All charges used to define this consumption tariff interval.
30 """
31 #: A sequential reference that defines the identity of this interval and its relative position with respect to other intervals in a sequence of intervals.
32 self.sequenceNumber = sequenceNumber
34 #: The lowest level of consumption that defines the starting point of this interval. The interval extends to the start of the next interval or until it is reset to the start of the first interval by TariffProfile.tariffCycle.
35 self.startValue = startValue
37 self._TariffProfiles = []
38 self.TariffProfiles = [] if TariffProfiles is None else TariffProfiles
40 self._Charges = []
41 self.Charges = [] if Charges is None else Charges
43 super(ConsumptionTariffInterval, self).__init__(*args, **kw_args)
45 _attrs = ["sequenceNumber", "startValue"]
46 _attr_types = {"sequenceNumber": int, "startValue": float}
47 _defaults = {"sequenceNumber": 0, "startValue": 0.0}
48 _enums = {}
49 _refs = ["TariffProfiles", "Charges"]
50 _many_refs = ["TariffProfiles", "Charges"]
52 def getTariffProfiles(self):
53 """All tariff profiles defined by this consumption tariff interval.
54 """
55 return self._TariffProfiles
57 def setTariffProfiles(self, value):
58 for p in self._TariffProfiles:
59 filtered = [q for q in p.ConsumptionTariffIntervals if q != self]
60 self._TariffProfiles._ConsumptionTariffIntervals = filtered
61 for r in value:
62 if self not in r._ConsumptionTariffIntervals:
63 r._ConsumptionTariffIntervals.append(self)
64 self._TariffProfiles = value
66 TariffProfiles = property(getTariffProfiles, setTariffProfiles)
68 def addTariffProfiles(self, *TariffProfiles):
69 for obj in TariffProfiles:
70 if self not in obj._ConsumptionTariffIntervals:
71 obj._ConsumptionTariffIntervals.append(self)
72 self._TariffProfiles.append(obj)
74 def removeTariffProfiles(self, *TariffProfiles):
75 for obj in TariffProfiles:
76 if self in obj._ConsumptionTariffIntervals:
77 obj._ConsumptionTariffIntervals.remove(self)
78 self._TariffProfiles.remove(obj)
80 def getCharges(self):
81 """All charges used to define this consumption tariff interval.
82 """
83 return self._Charges
85 def setCharges(self, value):
86 for p in self._Charges:
87 filtered = [q for q in p.ConsumptionTariffIntervals if q != self]
88 self._Charges._ConsumptionTariffIntervals = filtered
89 for r in value:
90 if self not in r._ConsumptionTariffIntervals:
91 r._ConsumptionTariffIntervals.append(self)
92 self._Charges = value
94 Charges = property(getCharges, setCharges)
96 def addCharges(self, *Charges):
97 for obj in Charges:
98 if self not in obj._ConsumptionTariffIntervals:
99 obj._ConsumptionTariffIntervals.append(self)
100 self._Charges.append(obj)
102 def removeCharges(self, *Charges):
103 for obj in Charges:
104 if self in obj._ConsumptionTariffIntervals:
105 obj._ConsumptionTariffIntervals.remove(self)
106 self._Charges.remove(obj)