Adding class meta-data attributes.
[PyCIM.git] / schemata / CIM14 / IEC61968 / Common / TimeSchedule.py
blob8111dbd753ee69d59202d8ed2582648e3e319951
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 TimeSchedule(Document):
20 """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).
21 """
23 def __init__(self, recurrencePeriod=0.0, disabled=False, offset=0.0, recurrencePattern='', TimePoints=None, scheduleInterval=None, *args, **kw_args):
24 """Initialises a new 'TimeSchedule' instance.
26 @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).
27 @param disabled: True if this schedule is deactivated (disabled).
28 @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.
29 @param recurrencePattern: Interval at which the scheduled action repeats (e.g., first Monday of every month, last day of the month, etc.).
30 @param TimePoints: Sequence of time points belonging to this time schedule.
31 @param scheduleInterval: Schedule date and time interval.
32 """
33 #: 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).
34 self.recurrencePeriod = recurrencePeriod
36 #: True if this schedule is deactivated (disabled).
37 self.disabled = disabled
39 #: 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.
40 self.offset = offset
42 #: Interval at which the scheduled action repeats (e.g., first Monday of every month, last day of the month, etc.).
43 self.recurrencePattern = recurrencePattern
45 self._TimePoints = []
46 self.TimePoints = [] if TimePoints is None else TimePoints
48 self.scheduleInterval = scheduleInterval
50 super(TimeSchedule, self).__init__(*args, **kw_args)
52 _attrs = ["recurrencePeriod", "disabled", "offset", "recurrencePattern"]
53 _attr_types = {"recurrencePeriod": float, "disabled": bool, "offset": float, "recurrencePattern": str}
54 _defaults = {"recurrencePeriod": 0.0, "disabled": False, "offset": 0.0, "recurrencePattern": ''}
55 _enums = {}
56 _refs = ["TimePoints", "scheduleInterval"]
57 _many_refs = ["TimePoints"]
59 def getTimePoints(self):
60 """Sequence of time points belonging to this time schedule.
61 """
62 return self._TimePoints
64 def setTimePoints(self, value):
65 for x in self._TimePoints:
66 x._TimeSchedule = None
67 for y in value:
68 y._TimeSchedule = self
69 self._TimePoints = value
71 TimePoints = property(getTimePoints, setTimePoints)
73 def addTimePoints(self, *TimePoints):
74 for obj in TimePoints:
75 obj._TimeSchedule = self
76 self._TimePoints.append(obj)
78 def removeTimePoints(self, *TimePoints):
79 for obj in TimePoints:
80 obj._TimeSchedule = None
81 self._TimePoints.remove(obj)
83 # Schedule date and time interval.
84 scheduleInterval = None