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.
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.
34 #: Reason for event resulting in this activity record, typically supplied when user initiated.
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
47 self
.Documents
= [] if Documents
is None else Documents
50 self
.Assets
= [] if Assets
is None else Assets
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": ''}
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.
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
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
):
81 if self
not in obj
._ActivityRecords
:
82 obj
._ActivityRecords
.append(self
)
83 self
._Documents
.append(obj
)
85 def removeDocuments(self
, *Documents
):
87 if self
in obj
._ActivityRecords
:
88 obj
._ActivityRecords
.remove(self
)
89 self
._Documents
.remove(obj
)
92 """All assets for which this activity record has been created.
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
101 if self
not in r
._ActivityRecords
:
102 r
._ActivityRecords
.append(self
)
105 Assets
= property(getAssets
, setAssets
)
107 def addAssets(self
, *Assets
):
109 if self
not in obj
._ActivityRecords
:
110 obj
._ActivityRecords
.append(self
)
111 self
._Assets
.append(obj
)
113 def removeAssets(self
, *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.