Model Hierarchy and Parameter Scoping
Learn how Super Blocks, Contexts, and scoping enable hierarchy in model diagrams.
Twin Activate models are hierarchical, thanks to the use of Super Blocks. A Super Block, seen and manipulated like a block, contains a diagram made of blocks, links and possibly other Super Blocks. The use of Super Blocks results in a hierarchical model containing multiple diagrams.
Each diagram has a Context: a script to define new model parameters. Parameters defined in the diagram Context of the Super block and the Contexts of its parent diagrams and the model Initialization script are available for use in the diagram. Variables can be redefined in Super Block Contexts; in that case, the parameter available in a diagram corresponds to the variable defined in the closest parent diagram Context. So, a parameter defined in a diagram is available for use in child diagrams until the name is shadowed by the definition of a new parameter with the same name. This mechanism is called semi-global scoping.
Thanks to this scoping mechanism, a diagram inside a Super Block is not necessarily self-contained: some of its parameters may be defined in terms of parameters defined outside the Super Block. The minimal set of parameters required inside the Super Block and defined outside, is uniquely defined, and can be determined automatically. By providing these parameters within the Super Block, the diagram becomes self-contained. A way to obtain the values of these parameters from the outside, and define them inside the Super Block, is to use a mask.