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 IrregularTimePoint(Element
):
20 """TimePoints for a schedule where the time between the points varies.
23 def __init__(self
, time
=0.0, value2
=0.0, value1
=0.0, IntervalSchedule
=None, *args
, **kw_args
):
24 """Initialises a new 'IrregularTimePoint' instance.
26 @param time: The time is relative the BasicTimeSchedule.startTime.
27 @param value2: The second value at the time. The meaning of the value is defined by the class inhering the IrregularIntervalSchedule.
28 @param value1: The first value at the time. The meaning of the value is defined by the class inhering the IrregularIntervalSchedule.
29 @param IntervalSchedule: An IrregularTimePoint belongs to an IrregularIntervalSchedule.
31 #: The time is relative the BasicTimeSchedule.startTime.
34 #: The second value at the time. The meaning of the value is defined by the class inhering the IrregularIntervalSchedule.
37 #: The first value at the time. The meaning of the value is defined by the class inhering the IrregularIntervalSchedule.
40 self
._IntervalSchedule
= None
41 self
.IntervalSchedule
= IntervalSchedule
43 super(IrregularTimePoint
, self
).__init
__(*args
, **kw_args
)
45 _attrs
= ["time", "value2", "value1"]
46 _attr_types
= {"time": float, "value2": float, "value1": float}
47 _defaults
= {"time": 0.0, "value2": 0.0, "value1": 0.0}
49 _refs
= ["IntervalSchedule"]
52 def getIntervalSchedule(self
):
53 """An IrregularTimePoint belongs to an IrregularIntervalSchedule.
55 return self
._IntervalSchedule
57 def setIntervalSchedule(self
, value
):
58 if self
._IntervalSchedule
is not None:
59 filtered
= [x
for x
in self
.IntervalSchedule
.TimePoints
if x
!= self
]
60 self
._IntervalSchedule
._TimePoints
= filtered
62 self
._IntervalSchedule
= value
63 if self
._IntervalSchedule
is not None:
64 self
._IntervalSchedule
._TimePoints
.append(self
)
66 IntervalSchedule
= property(getIntervalSchedule
, setIntervalSchedule
)