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
.Dynamics
.MetaBlockConnectable
import MetaBlockConnectable
23 class MetaBlockParameter(MetaBlockConnectable
):
24 """An identified parameter of a block. This is meta dynamics model and does not contain specific parameter values. When using a block one would need to supply specific parameter values. These are typically time constants, but are not restricted to this. Sometimes, for standard blocks, the block paramter may come directly from the attributes of an associated PowerSystemResource object, but such parameters may be specified to enable user defined models to alter the behavior of a standard block.
27 def __init__(self
, BlockParameter
=None, MemberOf_MetaBlock
=None, *args
, **kw_args
):
28 """Initialises a new 'MetaBlockParameter' instance.
30 @param BlockParameter:
31 @param MemberOf_MetaBlock: Paramters belong to a block.
33 self
._BlockParameter
= []
34 self
.BlockParameter
= [] if BlockParameter
is None else BlockParameter
36 self
._MemberOf
_MetaBlock
= None
37 self
.MemberOf_MetaBlock
= MemberOf_MetaBlock
39 super(MetaBlockParameter
, self
).__init
__(*args
, **kw_args
)
45 _refs
= ["BlockParameter", "MemberOf_MetaBlock"]
46 _many_refs
= ["BlockParameter"]
48 def getBlockParameter(self
):
50 return self
._BlockParameter
52 def setBlockParameter(self
, value
):
53 for x
in self
._BlockParameter
:
54 x
.MetaBlockParameter
= None
56 y
._MetaBlockParameter
= self
57 self
._BlockParameter
= value
59 BlockParameter
= property(getBlockParameter
, setBlockParameter
)
61 def addBlockParameter(self
, *BlockParameter
):
62 for obj
in BlockParameter
:
63 obj
.MetaBlockParameter
= self
65 def removeBlockParameter(self
, *BlockParameter
):
66 for obj
in BlockParameter
:
67 obj
.MetaBlockParameter
= None
69 def getMemberOf_MetaBlock(self
):
70 """Paramters belong to a block.
72 return self
._MemberOf
_MetaBlock
74 def setMemberOf_MetaBlock(self
, value
):
75 if self
._MemberOf
_MetaBlock
is not None:
76 filtered
= [x
for x
in self
.MemberOf_MetaBlock
.MetaBlockParameter
if x
!= self
]
77 self
._MemberOf
_MetaBlock
._MetaBlockParameter
= filtered
79 self
._MemberOf
_MetaBlock
= value
80 if self
._MemberOf
_MetaBlock
is not None:
81 if self
not in self
._MemberOf
_MetaBlock
._MetaBlockParameter
:
82 self
._MemberOf
_MetaBlock
._MetaBlockParameter
.append(self
)
84 MemberOf_MetaBlock
= property(getMemberOf_MetaBlock
, setMemberOf_MetaBlock
)