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
.LoadModel
.EnergyArea
import EnergyArea
19 class SubLoadArea(EnergyArea
):
20 """The class is the second level in a hierarchical structure for grouping of loads for the purpose of load flow load scaling.
23 def __init__(self
, LoadGroups
=None, LoadArea
=None, *args
, **kw_args
):
24 """Initialises a new 'SubLoadArea' instance.
26 @param LoadGroups: The Loadgroups in the SubLoadArea.
27 @param LoadArea: The LoadArea where the SubLoadArea belongs.
30 self
.LoadGroups
= [] if LoadGroups
is None else LoadGroups
33 self
.LoadArea
= LoadArea
35 super(SubLoadArea
, self
).__init
__(*args
, **kw_args
)
41 _refs
= ["LoadGroups", "LoadArea"]
42 _many_refs
= ["LoadGroups"]
44 def getLoadGroups(self
):
45 """The Loadgroups in the SubLoadArea.
47 return self
._LoadGroups
49 def setLoadGroups(self
, value
):
50 for x
in self
._LoadGroups
:
54 self
._LoadGroups
= value
56 LoadGroups
= property(getLoadGroups
, setLoadGroups
)
58 def addLoadGroups(self
, *LoadGroups
):
59 for obj
in LoadGroups
:
60 obj
._SubLoadArea
= self
61 self
._LoadGroups
.append(obj
)
63 def removeLoadGroups(self
, *LoadGroups
):
64 for obj
in LoadGroups
:
65 obj
._SubLoadArea
= None
66 self
._LoadGroups
.remove(obj
)
68 def getLoadArea(self
):
69 """The LoadArea where the SubLoadArea belongs.
73 def setLoadArea(self
, value
):
74 if self
._LoadArea
is not None:
75 filtered
= [x
for x
in self
.LoadArea
.SubLoadAreas
if x
!= self
]
76 self
._LoadArea
._SubLoadAreas
= filtered
78 self
._LoadArea
= value
79 if self
._LoadArea
is not None:
80 self
._LoadArea
._SubLoadAreas
.append(self
)
82 LoadArea
= property(getLoadArea
, setLoadArea
)