Update README.rst
[PyCIM.git] / CIM14 / IEC61970 / Core / Substation.py
blob1c400ded776e891dffc01de25e92db74f075460f
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
19 # IN THE SOFTWARE.
21 from CIM14.IEC61970.Core.EquipmentContainer import EquipmentContainer
23 class Substation(EquipmentContainer):
24 """A collection of equipment for purposes other than generation or utilization, through which electric energy in bulk is passed for the purposes of switching or modifying its characteristics.
25 """
27 def __init__(self, VoltageLevels=None, Bays=None, Region=None, *args, **kw_args):
28 """Initialises a new 'Substation' instance.
30 @param VoltageLevels: The association is used in the naming hierarchy.
31 @param Bays: The association is used in the naming hierarchy.
32 @param Region: The association is used in the naming hierarchy.
33 """
34 self._VoltageLevels = []
35 self.VoltageLevels = [] if VoltageLevels is None else VoltageLevels
37 self._Bays = []
38 self.Bays = [] if Bays is None else Bays
40 self._Region = None
41 self.Region = Region
43 super(Substation, self).__init__(*args, **kw_args)
45 _attrs = []
46 _attr_types = {}
47 _defaults = {}
48 _enums = {}
49 _refs = ["VoltageLevels", "Bays", "Region"]
50 _many_refs = ["VoltageLevels", "Bays"]
52 def getVoltageLevels(self):
53 """The association is used in the naming hierarchy.
54 """
55 return self._VoltageLevels
57 def setVoltageLevels(self, value):
58 for x in self._VoltageLevels:
59 x.Substation = None
60 for y in value:
61 y._Substation = self
62 self._VoltageLevels = value
64 VoltageLevels = property(getVoltageLevels, setVoltageLevels)
66 def addVoltageLevels(self, *VoltageLevels):
67 for obj in VoltageLevels:
68 obj.Substation = self
70 def removeVoltageLevels(self, *VoltageLevels):
71 for obj in VoltageLevels:
72 obj.Substation = None
74 def getBays(self):
75 """The association is used in the naming hierarchy.
76 """
77 return self._Bays
79 def setBays(self, value):
80 for x in self._Bays:
81 x.Substation = None
82 for y in value:
83 y._Substation = self
84 self._Bays = value
86 Bays = property(getBays, setBays)
88 def addBays(self, *Bays):
89 for obj in Bays:
90 obj.Substation = self
92 def removeBays(self, *Bays):
93 for obj in Bays:
94 obj.Substation = None
96 def getRegion(self):
97 """The association is used in the naming hierarchy.
98 """
99 return self._Region
101 def setRegion(self, value):
102 if self._Region is not None:
103 filtered = [x for x in self.Region.Substations if x != self]
104 self._Region._Substations = filtered
106 self._Region = value
107 if self._Region is not None:
108 if self not in self._Region._Substations:
109 self._Region._Substations.append(self)
111 Region = property(getRegion, setRegion)