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 MetaBlock(IdentifiedObject
):
24 """A block is a meta-data representation of a control block. It has an external interface and an optinal internal interface. Blocks internals can be ommitted if the block is well understood by both exchange parties. When well understood by both partice the block can be treated as a primitive block. All dynamic models must be defined to the level of primtive blocks in order for the model to be consumed and used for dynamic simulation. Examples of primitive blocks include a well known IEEE exciter model, a summation block, or an integrator block.
27 def __init__(self
, blockKind
="powerSystemStabilizer", internal
=False, proprietary
=False, primitive
=False, MetaBlockReference
=None, MetaBlockOutput
=None, MetaBlockState
=None, MetaBlockSignal
=None, blockType0
=None, MetaBlockInput
=None, blockConstant0
=None, Block
=None, MetaBlockParameter
=None, *args
, **kw_args
):
28 """Initialises a new 'MetaBlock' instance.
30 @param blockKind: Enumeration type: StandardControlBlock, Excitation System, ... Name used to distinguish which standard control block (Integration, Summation, ...)? Values are: "powerSystemStabilizer", "automaticVoltageControl", "turbine", "govenor", "dotDotDot", "energySource", "exciter"
31 @param internal: This block is intended to be used only internally within other blocks. An example would be a summation or integrator block. Such bocks are typically also primitive, though more complex internal blocks made up of other primitive controls could be built.
32 @param proprietary: This block is a proprietary block. Only inputs, outputs and parameters are exchanged.
33 @param primitive: Iindicates this type is treated as a primitive type and therefore the internal block model can be ignored and is not typically defined in the model. Primitive blocks include such basic things as summation and standard IEEEexciter models. The exchange parties must agree on the meaning of primitive blocks according to their identification.
34 @param MetaBlockReference:
35 @param MetaBlockOutput: Outputs that belong to the block.
36 @param MetaBlockState:
37 @param MetaBlockSignal:
39 @param MetaBlockInput: Inputs belong to a block.
40 @param blockConstant0:
42 @param MetaBlockParameter: Paramters belong to a block.
44 #: Enumeration type: StandardControlBlock, Excitation System, ... Name used to distinguish which standard control block (Integration, Summation, ...)? Values are: "powerSystemStabilizer", "automaticVoltageControl", "turbine", "govenor", "dotDotDot", "energySource", "exciter"
45 self
.blockKind
= blockKind
47 #: This block is intended to be used only internally within other blocks. An example would be a summation or integrator block. Such bocks are typically also primitive, though more complex internal blocks made up of other primitive controls could be built.
48 self
.internal
= internal
50 #: This block is a proprietary block. Only inputs, outputs and parameters are exchanged.
51 self
.proprietary
= proprietary
53 #: Iindicates this type is treated as a primitive type and therefore the internal block model can be ignored and is not typically defined in the model. Primitive blocks include such basic things as summation and standard IEEEexciter models. The exchange parties must agree on the meaning of primitive blocks according to their identification.
54 self
.primitive
= primitive
56 self
._MetaBlockReference
= []
57 self
.MetaBlockReference
= [] if MetaBlockReference
is None else MetaBlockReference
59 self
._MetaBlockOutput
= []
60 self
.MetaBlockOutput
= [] if MetaBlockOutput
is None else MetaBlockOutput
62 self
._MetaBlockState
= []
63 self
.MetaBlockState
= [] if MetaBlockState
is None else MetaBlockState
65 self
._MetaBlockSignal
= []
66 self
.MetaBlockSignal
= [] if MetaBlockSignal
is None else MetaBlockSignal
68 self
._blockType
0 = None
69 self
.blockType0
= blockType0
71 self
._MetaBlockInput
= []
72 self
.MetaBlockInput
= [] if MetaBlockInput
is None else MetaBlockInput
74 self
._blockConstant
0 = []
75 self
.blockConstant0
= [] if blockConstant0
is None else blockConstant0
78 self
.Block
= [] if Block
is None else Block
80 self
._MetaBlockParameter
= []
81 self
.MetaBlockParameter
= [] if MetaBlockParameter
is None else MetaBlockParameter
83 super(MetaBlock
, self
).__init
__(*args
, **kw_args
)
85 _attrs
= ["blockKind", "internal", "proprietary", "primitive"]
86 _attr_types
= {"blockKind": str, "internal": bool, "proprietary": bool, "primitive": bool}
87 _defaults
= {"blockKind": "powerSystemStabilizer", "internal": False, "proprietary": False, "primitive": False}
88 _enums
= {"blockKind": "BlockKind"}
89 _refs
= ["MetaBlockReference", "MetaBlockOutput", "MetaBlockState", "MetaBlockSignal", "blockType0", "MetaBlockInput", "blockConstant0", "Block", "MetaBlockParameter"]
90 _many_refs
= ["MetaBlockReference", "MetaBlockOutput", "MetaBlockState", "MetaBlockSignal", "MetaBlockInput", "blockConstant0", "Block", "MetaBlockParameter"]
92 def getMetaBlockReference(self
):
94 return self
._MetaBlockReference
96 def setMetaBlockReference(self
, value
):
97 for x
in self
._MetaBlockReference
:
98 x
.MemberOf_MetaBlock
= None
100 y
._MemberOf
_MetaBlock
= self
101 self
._MetaBlockReference
= value
103 MetaBlockReference
= property(getMetaBlockReference
, setMetaBlockReference
)
105 def addMetaBlockReference(self
, *MetaBlockReference
):
106 for obj
in MetaBlockReference
:
107 obj
.MemberOf_MetaBlock
= self
109 def removeMetaBlockReference(self
, *MetaBlockReference
):
110 for obj
in MetaBlockReference
:
111 obj
.MemberOf_MetaBlock
= None
113 def getMetaBlockOutput(self
):
114 """Outputs that belong to the block.
116 return self
._MetaBlockOutput
118 def setMetaBlockOutput(self
, value
):
119 for x
in self
._MetaBlockOutput
:
120 x
.MemberOf_MetaBlock
= None
122 y
._MemberOf
_MetaBlock
= self
123 self
._MetaBlockOutput
= value
125 MetaBlockOutput
= property(getMetaBlockOutput
, setMetaBlockOutput
)
127 def addMetaBlockOutput(self
, *MetaBlockOutput
):
128 for obj
in MetaBlockOutput
:
129 obj
.MemberOf_MetaBlock
= self
131 def removeMetaBlockOutput(self
, *MetaBlockOutput
):
132 for obj
in MetaBlockOutput
:
133 obj
.MemberOf_MetaBlock
= None
135 def getMetaBlockState(self
):
137 return self
._MetaBlockState
139 def setMetaBlockState(self
, value
):
140 for x
in self
._MetaBlockState
:
141 x
.MemberOf_MetaBlock
= None
143 y
._MemberOf
_MetaBlock
= self
144 self
._MetaBlockState
= value
146 MetaBlockState
= property(getMetaBlockState
, setMetaBlockState
)
148 def addMetaBlockState(self
, *MetaBlockState
):
149 for obj
in MetaBlockState
:
150 obj
.MemberOf_MetaBlock
= self
152 def removeMetaBlockState(self
, *MetaBlockState
):
153 for obj
in MetaBlockState
:
154 obj
.MemberOf_MetaBlock
= None
156 def getMetaBlockSignal(self
):
158 return self
._MetaBlockSignal
160 def setMetaBlockSignal(self
, value
):
161 for x
in self
._MetaBlockSignal
:
162 x
.MemberOf_MetaBlock
= None
164 y
._MemberOf
_MetaBlock
= self
165 self
._MetaBlockSignal
= value
167 MetaBlockSignal
= property(getMetaBlockSignal
, setMetaBlockSignal
)
169 def addMetaBlockSignal(self
, *MetaBlockSignal
):
170 for obj
in MetaBlockSignal
:
171 obj
.MemberOf_MetaBlock
= self
173 def removeMetaBlockSignal(self
, *MetaBlockSignal
):
174 for obj
in MetaBlockSignal
:
175 obj
.MemberOf_MetaBlock
= None
177 def getblockType0(self
):
179 return self
._blockType
0
181 def setblockType0(self
, value
):
182 if self
._blockType
0 is not None:
183 filtered
= [x
for x
in self
.blockType0
.metaBlock0
if x
!= self
]
184 self
._blockType
0._metaBlock
0 = filtered
186 self
._blockType
0 = value
187 if self
._blockType
0 is not None:
188 if self
not in self
._blockType
0._metaBlock
0:
189 self
._blockType
0._metaBlock
0.append(self
)
191 blockType0
= property(getblockType0
, setblockType0
)
193 def getMetaBlockInput(self
):
194 """Inputs belong to a block.
196 return self
._MetaBlockInput
198 def setMetaBlockInput(self
, value
):
199 for x
in self
._MetaBlockInput
:
200 x
.MemberOf_MetaBlock
= None
202 y
._MemberOf
_MetaBlock
= self
203 self
._MetaBlockInput
= value
205 MetaBlockInput
= property(getMetaBlockInput
, setMetaBlockInput
)
207 def addMetaBlockInput(self
, *MetaBlockInput
):
208 for obj
in MetaBlockInput
:
209 obj
.MemberOf_MetaBlock
= self
211 def removeMetaBlockInput(self
, *MetaBlockInput
):
212 for obj
in MetaBlockInput
:
213 obj
.MemberOf_MetaBlock
= None
215 def getblockConstant0(self
):
217 return self
._blockConstant
0
219 def setblockConstant0(self
, value
):
220 for x
in self
._blockConstant
0:
224 self
._blockConstant
0 = value
226 blockConstant0
= property(getblockConstant0
, setblockConstant0
)
228 def addblockConstant0(self
, *blockConstant0
):
229 for obj
in blockConstant0
:
230 obj
.metaBlock0
= self
232 def removeblockConstant0(self
, *blockConstant0
):
233 for obj
in blockConstant0
:
234 obj
.metaBlock0
= None
240 def setBlock(self
, value
):
241 for x
in self
._Block
:
247 Block
= property(getBlock
, setBlock
)
249 def addBlock(self
, *Block
):
253 def removeBlock(self
, *Block
):
257 def getMetaBlockParameter(self
):
258 """Paramters belong to a block.
260 return self
._MetaBlockParameter
262 def setMetaBlockParameter(self
, value
):
263 for x
in self
._MetaBlockParameter
:
264 x
.MemberOf_MetaBlock
= None
266 y
._MemberOf
_MetaBlock
= self
267 self
._MetaBlockParameter
= value
269 MetaBlockParameter
= property(getMetaBlockParameter
, setMetaBlockParameter
)
271 def addMetaBlockParameter(self
, *MetaBlockParameter
):
272 for obj
in MetaBlockParameter
:
273 obj
.MemberOf_MetaBlock
= self
275 def removeMetaBlockParameter(self
, *MetaBlockParameter
):
276 for obj
in MetaBlockParameter
:
277 obj
.MemberOf_MetaBlock
= None