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
.IEC61968
.Common
.Document
import Document
19 class TariffProfile(Document
):
20 """A schedule of charges; structure associated with Tariff that allows the definition of complex tarif structures such as step and time of use when used in conjunction with TimeTariffInterval and Charge. Inherited 'status.value' is defined in the context of the utility's business rules, for example: active, inactive, etc.
23 def __init__(self
, tariffCycle
='', ConsumptionTariffIntervals
=None, TimeTariffIntervals
=None, Tariffs
=None, *args
, **kw_args
):
24 """Initialises a new 'TariffProfile' instance.
26 @param tariffCycle: The frequency at which the tariff charge schedule is repeated Examples are: once off on a specified date and time; hourly; daily; weekly; monthly; 3-monthly; 6-monthly; 12-monthly; etc. At the end of each cycle, the business rules are reset to start from the beginning again.
27 @param ConsumptionTariffIntervals: All consumption tariff intervals used to define this tariff profile.
28 @param TimeTariffIntervals: All time tariff intervals used to define this tariff profile.
29 @param Tariffs: All tariffs defined by this tariff profile.
31 #: The frequency at which the tariff charge schedule is repeated Examples are: once off on a specified date and time; hourly; daily; weekly; monthly; 3-monthly; 6-monthly; 12-monthly; etc. At the end of each cycle, the business rules are reset to start from the beginning again.
32 self
.tariffCycle
= tariffCycle
34 self
._ConsumptionTariffIntervals
= []
35 self
.ConsumptionTariffIntervals
= [] if ConsumptionTariffIntervals
is None else ConsumptionTariffIntervals
37 self
._TimeTariffIntervals
= []
38 self
.TimeTariffIntervals
= [] if TimeTariffIntervals
is None else TimeTariffIntervals
41 self
.Tariffs
= [] if Tariffs
is None else Tariffs
43 super(TariffProfile
, self
).__init
__(*args
, **kw_args
)
45 _attrs
= ["tariffCycle"]
46 _attr_types
= {"tariffCycle": str}
47 _defaults
= {"tariffCycle": ''}
49 _refs
= ["ConsumptionTariffIntervals", "TimeTariffIntervals", "Tariffs"]
50 _many_refs
= ["ConsumptionTariffIntervals", "TimeTariffIntervals", "Tariffs"]
52 def getConsumptionTariffIntervals(self
):
53 """All consumption tariff intervals used to define this tariff profile.
55 return self
._ConsumptionTariffIntervals
57 def setConsumptionTariffIntervals(self
, value
):
58 for p
in self
._ConsumptionTariffIntervals
:
59 filtered
= [q
for q
in p
.TariffProfiles
if q
!= self
]
60 self
._ConsumptionTariffIntervals
._TariffProfiles
= filtered
62 if self
not in r
._TariffProfiles
:
63 r
._TariffProfiles
.append(self
)
64 self
._ConsumptionTariffIntervals
= value
66 ConsumptionTariffIntervals
= property(getConsumptionTariffIntervals
, setConsumptionTariffIntervals
)
68 def addConsumptionTariffIntervals(self
, *ConsumptionTariffIntervals
):
69 for obj
in ConsumptionTariffIntervals
:
70 if self
not in obj
._TariffProfiles
:
71 obj
._TariffProfiles
.append(self
)
72 self
._ConsumptionTariffIntervals
.append(obj
)
74 def removeConsumptionTariffIntervals(self
, *ConsumptionTariffIntervals
):
75 for obj
in ConsumptionTariffIntervals
:
76 if self
in obj
._TariffProfiles
:
77 obj
._TariffProfiles
.remove(self
)
78 self
._ConsumptionTariffIntervals
.remove(obj
)
80 def getTimeTariffIntervals(self
):
81 """All time tariff intervals used to define this tariff profile.
83 return self
._TimeTariffIntervals
85 def setTimeTariffIntervals(self
, value
):
86 for p
in self
._TimeTariffIntervals
:
87 filtered
= [q
for q
in p
.TariffProfiles
if q
!= self
]
88 self
._TimeTariffIntervals
._TariffProfiles
= filtered
90 if self
not in r
._TariffProfiles
:
91 r
._TariffProfiles
.append(self
)
92 self
._TimeTariffIntervals
= value
94 TimeTariffIntervals
= property(getTimeTariffIntervals
, setTimeTariffIntervals
)
96 def addTimeTariffIntervals(self
, *TimeTariffIntervals
):
97 for obj
in TimeTariffIntervals
:
98 if self
not in obj
._TariffProfiles
:
99 obj
._TariffProfiles
.append(self
)
100 self
._TimeTariffIntervals
.append(obj
)
102 def removeTimeTariffIntervals(self
, *TimeTariffIntervals
):
103 for obj
in TimeTariffIntervals
:
104 if self
in obj
._TariffProfiles
:
105 obj
._TariffProfiles
.remove(self
)
106 self
._TimeTariffIntervals
.remove(obj
)
108 def getTariffs(self
):
109 """All tariffs defined by this tariff profile.
113 def setTariffs(self
, value
):
114 for p
in self
._Tariffs
:
115 filtered
= [q
for q
in p
.TariffProfiles
if q
!= self
]
116 self
._Tariffs
._TariffProfiles
= filtered
118 if self
not in r
._TariffProfiles
:
119 r
._TariffProfiles
.append(self
)
120 self
._Tariffs
= value
122 Tariffs
= property(getTariffs
, setTariffs
)
124 def addTariffs(self
, *Tariffs
):
126 if self
not in obj
._TariffProfiles
:
127 obj
._TariffProfiles
.append(self
)
128 self
._Tariffs
.append(obj
)
130 def removeTariffs(self
, *Tariffs
):
132 if self
in obj
._TariffProfiles
:
133 obj
._TariffProfiles
.remove(self
)
134 self
._Tariffs
.remove(obj
)