1 # Copyright (C) 2010-2011 Richard Lincoln
3 # Permission is hereby granted, free of charge, to any person obtaining a copy
4 # of this software and associated documentation files (the "Software"), to
5 # deal in the Software without restriction, including without limitation the
6 # rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
7 # sell copies of the Software, and to permit persons to whom the Software is
8 # furnished to do so, subject to the following conditions:
10 # The above copyright notice and this permission notice shall be included in
11 # all copies or substantial portions of the Software.
13 # THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 # IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 # FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 # AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 # LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
18 # FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21 from CIM15
.IEC61968
.Common
.Document
import Document
23 class TariffProfile(Document
):
24 """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.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.
27 def __init__(self
, tariffCycle
='', Tariffs
=None, ConsumptionTariffIntervals
=None, TimeTariffIntervals
=None, *args
, **kw_args
):
28 """Initialises a new 'TariffProfile' instance.
30 @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.
31 @param Tariffs: All tariffs defined by this tariff profile.
32 @param ConsumptionTariffIntervals: All consumption tariff intervals used to define this tariff profile.
33 @param TimeTariffIntervals: All time tariff intervals used to define this tariff profile.
35 #: 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.
36 self
.tariffCycle
= tariffCycle
39 self
.Tariffs
= [] if Tariffs
is None else Tariffs
41 self
._ConsumptionTariffIntervals
= []
42 self
.ConsumptionTariffIntervals
= [] if ConsumptionTariffIntervals
is None else ConsumptionTariffIntervals
44 self
._TimeTariffIntervals
= []
45 self
.TimeTariffIntervals
= [] if TimeTariffIntervals
is None else TimeTariffIntervals
47 super(TariffProfile
, self
).__init
__(*args
, **kw_args
)
49 _attrs
= ["tariffCycle"]
50 _attr_types
= {"tariffCycle": str}
51 _defaults
= {"tariffCycle": ''}
53 _refs
= ["Tariffs", "ConsumptionTariffIntervals", "TimeTariffIntervals"]
54 _many_refs
= ["Tariffs", "ConsumptionTariffIntervals", "TimeTariffIntervals"]
57 """All tariffs defined by this tariff profile.
61 def setTariffs(self
, value
):
62 for p
in self
._Tariffs
:
63 filtered
= [q
for q
in p
.TariffProfiles
if q
!= self
]
64 self
._Tariffs
._TariffProfiles
= filtered
66 if self
not in r
._TariffProfiles
:
67 r
._TariffProfiles
.append(self
)
70 Tariffs
= property(getTariffs
, setTariffs
)
72 def addTariffs(self
, *Tariffs
):
74 if self
not in obj
._TariffProfiles
:
75 obj
._TariffProfiles
.append(self
)
76 self
._Tariffs
.append(obj
)
78 def removeTariffs(self
, *Tariffs
):
80 if self
in obj
._TariffProfiles
:
81 obj
._TariffProfiles
.remove(self
)
82 self
._Tariffs
.remove(obj
)
84 def getConsumptionTariffIntervals(self
):
85 """All consumption tariff intervals used to define this tariff profile.
87 return self
._ConsumptionTariffIntervals
89 def setConsumptionTariffIntervals(self
, value
):
90 for p
in self
._ConsumptionTariffIntervals
:
91 filtered
= [q
for q
in p
.TariffProfiles
if q
!= self
]
92 self
._ConsumptionTariffIntervals
._TariffProfiles
= filtered
94 if self
not in r
._TariffProfiles
:
95 r
._TariffProfiles
.append(self
)
96 self
._ConsumptionTariffIntervals
= value
98 ConsumptionTariffIntervals
= property(getConsumptionTariffIntervals
, setConsumptionTariffIntervals
)
100 def addConsumptionTariffIntervals(self
, *ConsumptionTariffIntervals
):
101 for obj
in ConsumptionTariffIntervals
:
102 if self
not in obj
._TariffProfiles
:
103 obj
._TariffProfiles
.append(self
)
104 self
._ConsumptionTariffIntervals
.append(obj
)
106 def removeConsumptionTariffIntervals(self
, *ConsumptionTariffIntervals
):
107 for obj
in ConsumptionTariffIntervals
:
108 if self
in obj
._TariffProfiles
:
109 obj
._TariffProfiles
.remove(self
)
110 self
._ConsumptionTariffIntervals
.remove(obj
)
112 def getTimeTariffIntervals(self
):
113 """All time tariff intervals used to define this tariff profile.
115 return self
._TimeTariffIntervals
117 def setTimeTariffIntervals(self
, value
):
118 for p
in self
._TimeTariffIntervals
:
119 filtered
= [q
for q
in p
.TariffProfiles
if q
!= self
]
120 self
._TimeTariffIntervals
._TariffProfiles
= filtered
122 if self
not in r
._TariffProfiles
:
123 r
._TariffProfiles
.append(self
)
124 self
._TimeTariffIntervals
= value
126 TimeTariffIntervals
= property(getTimeTariffIntervals
, setTimeTariffIntervals
)
128 def addTimeTariffIntervals(self
, *TimeTariffIntervals
):
129 for obj
in TimeTariffIntervals
:
130 if self
not in obj
._TariffProfiles
:
131 obj
._TariffProfiles
.append(self
)
132 self
._TimeTariffIntervals
.append(obj
)
134 def removeTimeTariffIntervals(self
, *TimeTariffIntervals
):
135 for obj
in TimeTariffIntervals
:
136 if self
in obj
._TariffProfiles
:
137 obj
._TariffProfiles
.remove(self
)
138 self
._TimeTariffIntervals
.remove(obj
)