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
.IEC61970
.Core
.IdentifiedObject
import IdentifiedObject
23 class TimePoint(IdentifiedObject
):
24 """A point in time within a sequence of points in time relative to a TimeSchedule.A point in time within a sequence of points in time relative to a TimeSchedule.
27 def __init__(self
, dateTime
='', sequenceNumber
=0, relativeTimeInterval
=0.0, status
=None, window
=None, TimeSchedule
=None, ScheduledEvents
=None, *args
, **kw_args
):
28 """Initialises a new 'TimePoint' instance.
30 @param dateTime: Absolute date and time for this time point. For calendar-based time point, it is typically manually entered, while for interval-based or sequence-based time point it is derived.
31 @param sequenceNumber: (if sequence-based) Relative sequence number for this time point.
32 @param relativeTimeInterval: (if interval-based) A point in time relative to scheduled start time in 'TimeSchedule.scheduleInterval.start'.
33 @param status: Status of this time point.
34 @param window: Interval defining the window of time that this time point is valid (for example, seasonal, only on weekends, not on weekends, only 8:00 to 5:00, etc.).
35 @param TimeSchedule: Time schedule owning this time point.
36 @param ScheduledEvents:
38 #: Absolute date and time for this time point. For calendar-based time point, it is typically manually entered, while for interval-based or sequence-based time point it is derived.
39 self
.dateTime
= dateTime
41 #: (if sequence-based) Relative sequence number for this time point.
42 self
.sequenceNumber
= sequenceNumber
44 #: (if interval-based) A point in time relative to scheduled start time in 'TimeSchedule.scheduleInterval.start'.
45 self
.relativeTimeInterval
= relativeTimeInterval
51 self
._TimeSchedule
= None
52 self
.TimeSchedule
= TimeSchedule
54 self
._ScheduledEvents
= []
55 self
.ScheduledEvents
= [] if ScheduledEvents
is None else ScheduledEvents
57 super(TimePoint
, self
).__init
__(*args
, **kw_args
)
59 _attrs
= ["dateTime", "sequenceNumber", "relativeTimeInterval"]
60 _attr_types
= {"dateTime": str, "sequenceNumber": int, "relativeTimeInterval": float}
61 _defaults
= {"dateTime": '', "sequenceNumber": 0, "relativeTimeInterval": 0.0}
63 _refs
= ["status", "window", "TimeSchedule", "ScheduledEvents"]
64 _many_refs
= ["ScheduledEvents"]
66 # Status of this time point.
69 # Interval defining the window of time that this time point is valid (for example, seasonal, only on weekends, not on weekends, only 8:00 to 5:00, etc.).
72 def getTimeSchedule(self
):
73 """Time schedule owning this time point.
75 return self
._TimeSchedule
77 def setTimeSchedule(self
, value
):
78 if self
._TimeSchedule
is not None:
79 filtered
= [x
for x
in self
.TimeSchedule
.TimePoints
if x
!= self
]
80 self
._TimeSchedule
._TimePoints
= filtered
82 self
._TimeSchedule
= value
83 if self
._TimeSchedule
is not None:
84 if self
not in self
._TimeSchedule
._TimePoints
:
85 self
._TimeSchedule
._TimePoints
.append(self
)
87 TimeSchedule
= property(getTimeSchedule
, setTimeSchedule
)
89 def getScheduledEvents(self
):
91 return self
._ScheduledEvents
93 def setScheduledEvents(self
, value
):
94 for x
in self
._ScheduledEvents
:
98 self
._ScheduledEvents
= value
100 ScheduledEvents
= property(getScheduledEvents
, setScheduledEvents
)
102 def addScheduledEvents(self
, *ScheduledEvents
):
103 for obj
in ScheduledEvents
:
106 def removeScheduledEvents(self
, *ScheduledEvents
):
107 for obj
in ScheduledEvents
: