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 CIM14
.IEC61970
.Core
.IdentifiedObject
import IdentifiedObject
23 class SwitchingOperation(IdentifiedObject
):
24 """A SwitchingOperation is used to define individual switch operations for an OutageSchedule. This OutageSchedule may be associated with another item of Substation such as a Transformer, Line, or Generator; or with the Switch itself as a PowerSystemResource. A Switch may be referenced by many OutageSchedules.
27 def __init__(self
, newState
="open", operationTime
='', Switches
=None, OutageSchedule
=None, *args
, **kw_args
):
28 """Initialises a new 'SwitchingOperation' instance.
30 @param newState: The switch position that shall result from this SwitchingOperation Values are: "open", "close"
31 @param operationTime: Time of operation in same units as OutageSchedule.xAxixUnits.
32 @param Switches: A switch may be operated by many schedules.
33 @param OutageSchedule: An OutageSchedule may operate many switches.
35 #: The switch position that shall result from this SwitchingOperation Values are: "open", "close"
36 self
.newState
= newState
38 #: Time of operation in same units as OutageSchedule.xAxixUnits.
39 self
.operationTime
= operationTime
42 self
.Switches
= [] if Switches
is None else Switches
44 self
._OutageSchedule
= None
45 self
.OutageSchedule
= OutageSchedule
47 super(SwitchingOperation
, self
).__init
__(*args
, **kw_args
)
49 _attrs
= ["newState", "operationTime"]
50 _attr_types
= {"newState": str, "operationTime": str}
51 _defaults
= {"newState": "open", "operationTime": ''}
52 _enums
= {"newState": "SwitchState"}
53 _refs
= ["Switches", "OutageSchedule"]
54 _many_refs
= ["Switches"]
56 def getSwitches(self
):
57 """A switch may be operated by many schedules.
61 def setSwitches(self
, value
):
62 for p
in self
._Switches
:
63 filtered
= [q
for q
in p
.SwitchingOperations
if q
!= self
]
64 self
._Switches
._SwitchingOperations
= filtered
66 if self
not in r
._SwitchingOperations
:
67 r
._SwitchingOperations
.append(self
)
68 self
._Switches
= value
70 Switches
= property(getSwitches
, setSwitches
)
72 def addSwitches(self
, *Switches
):
74 if self
not in obj
._SwitchingOperations
:
75 obj
._SwitchingOperations
.append(self
)
76 self
._Switches
.append(obj
)
78 def removeSwitches(self
, *Switches
):
80 if self
in obj
._SwitchingOperations
:
81 obj
._SwitchingOperations
.remove(self
)
82 self
._Switches
.remove(obj
)
84 def getOutageSchedule(self
):
85 """An OutageSchedule may operate many switches.
87 return self
._OutageSchedule
89 def setOutageSchedule(self
, value
):
90 if self
._OutageSchedule
is not None:
91 filtered
= [x
for x
in self
.OutageSchedule
.SwitchingOperations
if x
!= self
]
92 self
._OutageSchedule
._SwitchingOperations
= filtered
94 self
._OutageSchedule
= value
95 if self
._OutageSchedule
is not None:
96 if self
not in self
._OutageSchedule
._SwitchingOperations
:
97 self
._OutageSchedule
._SwitchingOperations
.append(self
)
99 OutageSchedule
= property(getOutageSchedule
, setOutageSchedule
)