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 TimeSchedule(Document
):
24 """Description of anything that changes through time. Time schedule is used to perform a single-valued function of time. Use inherited 'category' attribute to give additional information on this schedule, such as: periodic (hourly, daily, weekly, monthly, etc.), day of the month, by date, calendar (specific times and dates).Description of anything that changes through time. Time schedule is used to perform a single-valued function of time. Use inherited 'category' attribute to give additional information on this schedule, such as: periodic (hourly, daily, weekly, monthly, etc.), day of the month, by date, calendar (specific times and dates).
27 def __init__(self
, recurrencePeriod
=0.0, disabled
=False, offset
=0.0, recurrencePattern
='', TimePoints
=None, scheduleInterval
=None, *args
, **kw_args
):
28 """Initialises a new 'TimeSchedule' instance.
30 @param recurrencePeriod: Duration between time points, from the beginning of one period to the beginning of the next period. Note that a device like a meter may have multiple interval periods (e.g., 1 min, 5 min, 15 min, 30 min, or 60 min).
31 @param disabled: True if this schedule is deactivated (disabled).
32 @param offset: The offset from midnight (i.e., 0 h, 0 min, 0 s) for the periodic time points to begin. For example, for an interval meter that is set up for five minute intervals ('recurrencePeriod'=300=5 min), setting 'offset'=120=2 min would result in scheduled events to read the meter executing at 2 min, 7 min, 12 min, 17 min, 22 min, 27 min, 32 min, 37 min, 42 min, 47 min, 52 min, and 57 min past each hour.
33 @param recurrencePattern: Interval at which the scheduled action repeats (e.g., first Monday of every month, last day of the month, etc.).
34 @param TimePoints: Sequence of time points belonging to this time schedule.
35 @param scheduleInterval: Schedule date and time interval.
37 #: Duration between time points, from the beginning of one period to the beginning of the next period. Note that a device like a meter may have multiple interval periods (e.g., 1 min, 5 min, 15 min, 30 min, or 60 min).
38 self
.recurrencePeriod
= recurrencePeriod
40 #: True if this schedule is deactivated (disabled).
41 self
.disabled
= disabled
43 #: The offset from midnight (i.e., 0 h, 0 min, 0 s) for the periodic time points to begin. For example, for an interval meter that is set up for five minute intervals ('recurrencePeriod'=300=5 min), setting 'offset'=120=2 min would result in scheduled events to read the meter executing at 2 min, 7 min, 12 min, 17 min, 22 min, 27 min, 32 min, 37 min, 42 min, 47 min, 52 min, and 57 min past each hour.
46 #: Interval at which the scheduled action repeats (e.g., first Monday of every month, last day of the month, etc.).
47 self
.recurrencePattern
= recurrencePattern
50 self
.TimePoints
= [] if TimePoints
is None else TimePoints
52 self
.scheduleInterval
= scheduleInterval
54 super(TimeSchedule
, self
).__init
__(*args
, **kw_args
)
56 _attrs
= ["recurrencePeriod", "disabled", "offset", "recurrencePattern"]
57 _attr_types
= {"recurrencePeriod": float, "disabled": bool, "offset": float, "recurrencePattern": str}
58 _defaults
= {"recurrencePeriod": 0.0, "disabled": False, "offset": 0.0, "recurrencePattern": ''}
60 _refs
= ["TimePoints", "scheduleInterval"]
61 _many_refs
= ["TimePoints"]
63 def getTimePoints(self
):
64 """Sequence of time points belonging to this time schedule.
66 return self
._TimePoints
68 def setTimePoints(self
, value
):
69 for x
in self
._TimePoints
:
72 y
._TimeSchedule
= self
73 self
._TimePoints
= value
75 TimePoints
= property(getTimePoints
, setTimePoints
)
77 def addTimePoints(self
, *TimePoints
):
78 for obj
in TimePoints
:
79 obj
.TimeSchedule
= self
81 def removeTimePoints(self
, *TimePoints
):
82 for obj
in TimePoints
:
83 obj
.TimeSchedule
= None
85 # Schedule date and time interval.
86 scheduleInterval
= None