Adding CDPSM package.
[PyCIM.git] / CIM14 / IEC61968 / Metering / DeviceFunction.py
blobd6c36095421223c573b46c1f5281eb90560ee123
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.Assets.AssetFunction import AssetFunction
19 class DeviceFunction(AssetFunction):
20 """Function performed by a device such as a meter, communication equipment, controllers, etc.
21 """
23 def __init__(self, disabled=False, EndDeviceAsset=None, Registers=None, EndDeviceEvents=None, *args, **kw_args):
24 """Initialises a new 'DeviceFunction' instance.
26 @param disabled: True if the device function is disabled (deactivated). Default is false (i.e., function is enabled).
27 @param EndDeviceAsset: End device asset that performs this function.
28 @param Registers: All registers for quantities metered by this device function.
29 @param EndDeviceEvents: All events reported by this device function.
30 """
31 #: True if the device function is disabled (deactivated). Default is false (i.e., function is enabled).
32 self.disabled = disabled
34 self._EndDeviceAsset = None
35 self.EndDeviceAsset = EndDeviceAsset
37 self._Registers = []
38 self.Registers = [] if Registers is None else Registers
40 self._EndDeviceEvents = []
41 self.EndDeviceEvents = [] if EndDeviceEvents is None else EndDeviceEvents
43 super(DeviceFunction, self).__init__(*args, **kw_args)
45 _attrs = ["disabled"]
46 _attr_types = {"disabled": bool}
47 _defaults = {"disabled": False}
48 _enums = {}
49 _refs = ["EndDeviceAsset", "Registers", "EndDeviceEvents"]
50 _many_refs = ["Registers", "EndDeviceEvents"]
52 def getEndDeviceAsset(self):
53 """End device asset that performs this function.
54 """
55 return self._EndDeviceAsset
57 def setEndDeviceAsset(self, value):
58 if self._EndDeviceAsset is not None:
59 filtered = [x for x in self.EndDeviceAsset.DeviceFunctions if x != self]
60 self._EndDeviceAsset._DeviceFunctions = filtered
62 self._EndDeviceAsset = value
63 if self._EndDeviceAsset is not None:
64 if self not in self._EndDeviceAsset._DeviceFunctions:
65 self._EndDeviceAsset._DeviceFunctions.append(self)
67 EndDeviceAsset = property(getEndDeviceAsset, setEndDeviceAsset)
69 def getRegisters(self):
70 """All registers for quantities metered by this device function.
71 """
72 return self._Registers
74 def setRegisters(self, value):
75 for x in self._Registers:
76 x.DeviceFunction = None
77 for y in value:
78 y._DeviceFunction = self
79 self._Registers = value
81 Registers = property(getRegisters, setRegisters)
83 def addRegisters(self, *Registers):
84 for obj in Registers:
85 obj.DeviceFunction = self
87 def removeRegisters(self, *Registers):
88 for obj in Registers:
89 obj.DeviceFunction = None
91 def getEndDeviceEvents(self):
92 """All events reported by this device function.
93 """
94 return self._EndDeviceEvents
96 def setEndDeviceEvents(self, value):
97 for x in self._EndDeviceEvents:
98 x.DeviceFunction = None
99 for y in value:
100 y._DeviceFunction = self
101 self._EndDeviceEvents = value
103 EndDeviceEvents = property(getEndDeviceEvents, setEndDeviceEvents)
105 def addEndDeviceEvents(self, *EndDeviceEvents):
106 for obj in EndDeviceEvents:
107 obj.DeviceFunction = self
109 def removeEndDeviceEvents(self, *EndDeviceEvents):
110 for obj in EndDeviceEvents:
111 obj.DeviceFunction = None