Adding CDPSM package.
[PyCIM.git] / CIM14 / IEC61968 / Common / ActivityRecord.py
blob0365d7ae2ec0c21207cf0ee0629d948101945029
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.IEC61970.Core.IdentifiedObject import IdentifiedObject
19 class ActivityRecord(IdentifiedObject):
20 """Records activity for an entity at a point in time; activity may be for an event that has already occurred or for a planned activity.
21 """
23 def __init__(self, reason='', createdDateTime='', severity='', category='', Documents=None, Assets=None, status=None, *args, **kw_args):
24 """Initialises a new 'ActivityRecord' instance.
26 @param reason: Reason for event resulting in this activity record, typically supplied when user initiated.
27 @param createdDateTime: Date and time this activity record has been created (different from the 'status.dateTime', which is the time of a status change of the associated object, if applicable).
28 @param severity: Severity level of event resulting in this activity record.
29 @param category: Category of event resulting in this activity record.
30 @param Documents: All documents for which this activity record has been created.
31 @param Assets: All assets for which this activity record has been created.
32 @param status: Information on consequence of event resulting in this activity record.
33 """
34 #: Reason for event resulting in this activity record, typically supplied when user initiated.
35 self.reason = reason
37 #: Date and time this activity record has been created (different from the 'status.dateTime', which is the time of a status change of the associated object, if applicable).
38 self.createdDateTime = createdDateTime
40 #: Severity level of event resulting in this activity record.
41 self.severity = severity
43 #: Category of event resulting in this activity record.
44 self.category = category
46 self._Documents = []
47 self.Documents = [] if Documents is None else Documents
49 self._Assets = []
50 self.Assets = [] if Assets is None else Assets
52 self.status = status
54 super(ActivityRecord, self).__init__(*args, **kw_args)
56 _attrs = ["reason", "createdDateTime", "severity", "category"]
57 _attr_types = {"reason": str, "createdDateTime": str, "severity": str, "category": str}
58 _defaults = {"reason": '', "createdDateTime": '', "severity": '', "category": ''}
59 _enums = {}
60 _refs = ["Documents", "Assets", "status"]
61 _many_refs = ["Documents", "Assets"]
63 def getDocuments(self):
64 """All documents for which this activity record has been created.
65 """
66 return self._Documents
68 def setDocuments(self, value):
69 for p in self._Documents:
70 filtered = [q for q in p.ActivityRecords if q != self]
71 self._Documents._ActivityRecords = filtered
72 for r in value:
73 if self not in r._ActivityRecords:
74 r._ActivityRecords.append(self)
75 self._Documents = value
77 Documents = property(getDocuments, setDocuments)
79 def addDocuments(self, *Documents):
80 for obj in Documents:
81 if self not in obj._ActivityRecords:
82 obj._ActivityRecords.append(self)
83 self._Documents.append(obj)
85 def removeDocuments(self, *Documents):
86 for obj in Documents:
87 if self in obj._ActivityRecords:
88 obj._ActivityRecords.remove(self)
89 self._Documents.remove(obj)
91 def getAssets(self):
92 """All assets for which this activity record has been created.
93 """
94 return self._Assets
96 def setAssets(self, value):
97 for p in self._Assets:
98 filtered = [q for q in p.ActivityRecords if q != self]
99 self._Assets._ActivityRecords = filtered
100 for r in value:
101 if self not in r._ActivityRecords:
102 r._ActivityRecords.append(self)
103 self._Assets = value
105 Assets = property(getAssets, setAssets)
107 def addAssets(self, *Assets):
108 for obj in Assets:
109 if self not in obj._ActivityRecords:
110 obj._ActivityRecords.append(self)
111 self._Assets.append(obj)
113 def removeAssets(self, *Assets):
114 for obj in Assets:
115 if self in obj._ActivityRecords:
116 obj._ActivityRecords.remove(self)
117 self._Assets.remove(obj)
119 # Information on consequence of event resulting in this activity record.
120 status = None