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
.IEC61970
.Core
.IdentifiedObject
import IdentifiedObject
23 class EndDeviceGroup(IdentifiedObject
):
24 """Abstraction for management of group communications within a two-way AMR system or the data for a group of related meters. Commands can be issued to all of the meters that belong to a meter group using a defined group address and the underlying AMR communication infrastructure.Abstraction for management of group communications within a two-way AMR system or the data for a group of related meters. Commands can be issued to all of the meters that belong to a meter group using a defined group address and the underlying AMR communication infrastructure.
27 def __init__(self
, groupAddress
=0, EndDeviceControls
=None, EndDevices
=None, DemandResponseProgram
=None, *args
, **kw_args
):
28 """Initialises a new 'EndDeviceGroup' instance.
30 @param groupAddress: Address of this end device group.
31 @param EndDeviceControls: All end device controls sending commands to this end device group.
32 @param EndDevices: All end devices this end device group refers to.
33 @param DemandResponseProgram: Demand response program for this group of end devices.
35 #: Address of this end device group.
36 self
.groupAddress
= groupAddress
38 self
._EndDeviceControls
= []
39 self
.EndDeviceControls
= [] if EndDeviceControls
is None else EndDeviceControls
42 self
.EndDevices
= [] if EndDevices
is None else EndDevices
44 self
._DemandResponseProgram
= None
45 self
.DemandResponseProgram
= DemandResponseProgram
47 super(EndDeviceGroup
, self
).__init
__(*args
, **kw_args
)
49 _attrs
= ["groupAddress"]
50 _attr_types
= {"groupAddress": int}
51 _defaults
= {"groupAddress": 0}
53 _refs
= ["EndDeviceControls", "EndDevices", "DemandResponseProgram"]
54 _many_refs
= ["EndDeviceControls", "EndDevices"]
56 def getEndDeviceControls(self
):
57 """All end device controls sending commands to this end device group.
59 return self
._EndDeviceControls
61 def setEndDeviceControls(self
, value
):
62 for x
in self
._EndDeviceControls
:
63 x
.EndDeviceGroup
= None
65 y
._EndDeviceGroup
= self
66 self
._EndDeviceControls
= value
68 EndDeviceControls
= property(getEndDeviceControls
, setEndDeviceControls
)
70 def addEndDeviceControls(self
, *EndDeviceControls
):
71 for obj
in EndDeviceControls
:
72 obj
.EndDeviceGroup
= self
74 def removeEndDeviceControls(self
, *EndDeviceControls
):
75 for obj
in EndDeviceControls
:
76 obj
.EndDeviceGroup
= None
78 def getEndDevices(self
):
79 """All end devices this end device group refers to.
81 return self
._EndDevices
83 def setEndDevices(self
, value
):
84 for p
in self
._EndDevices
:
85 filtered
= [q
for q
in p
.EndDeviceGroups
if q
!= self
]
86 self
._EndDevices
._EndDeviceGroups
= filtered
88 if self
not in r
._EndDeviceGroups
:
89 r
._EndDeviceGroups
.append(self
)
90 self
._EndDevices
= value
92 EndDevices
= property(getEndDevices
, setEndDevices
)
94 def addEndDevices(self
, *EndDevices
):
95 for obj
in EndDevices
:
96 if self
not in obj
._EndDeviceGroups
:
97 obj
._EndDeviceGroups
.append(self
)
98 self
._EndDevices
.append(obj
)
100 def removeEndDevices(self
, *EndDevices
):
101 for obj
in EndDevices
:
102 if self
in obj
._EndDeviceGroups
:
103 obj
._EndDeviceGroups
.remove(self
)
104 self
._EndDevices
.remove(obj
)
106 def getDemandResponseProgram(self
):
107 """Demand response program for this group of end devices.
109 return self
._DemandResponseProgram
111 def setDemandResponseProgram(self
, value
):
112 if self
._DemandResponseProgram
is not None:
113 filtered
= [x
for x
in self
.DemandResponseProgram
.EndDeviceGroups
if x
!= self
]
114 self
._DemandResponseProgram
._EndDeviceGroups
= filtered
116 self
._DemandResponseProgram
= value
117 if self
._DemandResponseProgram
is not None:
118 if self
not in self
._DemandResponseProgram
._EndDeviceGroups
:
119 self
._DemandResponseProgram
._EndDeviceGroups
.append(self
)
121 DemandResponseProgram
= property(getDemandResponseProgram
, setDemandResponseProgram
)