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
.PowerSystemResource
import PowerSystemResource
19 class CommunicationLink(PowerSystemResource
):
20 """The connection to remote units is through one or more communication links. Reduntant links may exist. The CommunicationLink class inherit PowerSystemResource. The intention is to allow CommunicationLinks to have Measurements. These Measurements can be used to model link status as operational, out of service, unit failure etc.
23 def __init__(self
, RemoteUnits
=None, *args
, **kw_args
):
24 """Initialises a new 'CommunicationLink' instance.
26 @param RemoteUnits: RTUs may be attached to communication links.
28 self
._RemoteUnits
= []
29 self
.RemoteUnits
= [] if RemoteUnits
is None else RemoteUnits
31 super(CommunicationLink
, self
).__init
__(*args
, **kw_args
)
37 _refs
= ["RemoteUnits"]
38 _many_refs
= ["RemoteUnits"]
40 def getRemoteUnits(self
):
41 """RTUs may be attached to communication links.
43 return self
._RemoteUnits
45 def setRemoteUnits(self
, value
):
46 for p
in self
._RemoteUnits
:
47 filtered
= [q
for q
in p
.CommunicationLinks
if q
!= self
]
48 self
._RemoteUnits
._CommunicationLinks
= filtered
50 if self
not in r
._CommunicationLinks
:
51 r
._CommunicationLinks
.append(self
)
52 self
._RemoteUnits
= value
54 RemoteUnits
= property(getRemoteUnits
, setRemoteUnits
)
56 def addRemoteUnits(self
, *RemoteUnits
):
57 for obj
in RemoteUnits
:
58 if self
not in obj
._CommunicationLinks
:
59 obj
._CommunicationLinks
.append(self
)
60 self
._RemoteUnits
.append(obj
)
62 def removeRemoteUnits(self
, *RemoteUnits
):
63 for obj
in RemoteUnits
:
64 if self
in obj
._CommunicationLinks
:
65 obj
._CommunicationLinks
.remove(self
)
66 self
._RemoteUnits
.remove(obj
)