Recursive Variables

About this task

CIMPLICITY's ability to evaluate variables that are used in expressions that are contained in screens include the following.

  • Overview
  • Parent Variables

Overview

Procedure

  1. When evaluating an expression, there will now be up to 100 passes over the expression until there are no more variable references in that expression. ??

    Note: A variable reference is indicated by enclosing a variable name in {}.

  2. Because it is common for a variable value to be used as both a label in a text object's display expression and as part of a point ID, in some animations a new mechanism to allow a variable to have its value substituted into an expression but still be double quoted at the final pass of variable substitution in an expression is now available. The new mechanism is using a pipe character | in the expression at the location where the double quote would be used.
    Note: The pipe substitution only occurs if variables were used in the expression. However, pipes can still be contained in double quoted strings.

    Example: Pipes in Recursive Variables

  3. A linked object has a public variable that contains 2 objects.

    The display expression is as follows.

    Note: These are the configured expressions of the inner most linked objects.

    Expression 1 {unit}.pv
    Expression 2 |{unit}|
  4. This linked object is contained inside another linked object with its own public variable area.
  5. The public variable unit is assigned the following value.
    unit {area}.vlt
  6. The variable area is given the value as indicated below.
    area Bay12
  7. The objects indicated in the inner most linked object would evaluate with the following expressions.
    Final Expression 1 Bay12.vlt.pv
    Final Expression 2 "Bay12.vlt"

    No lines of code are needed to accomplish the recursive variable evaluation when the pipe is used.

    Parent Variables

    When recursive variables are used, they frequently will have a common variable that communicates some part of the system configuration. The common variable could occur in several layers in a deeply nested hierarchy. For example, a group of objects might have a variable OBJECTNAME at more than one level to represent the object instance that will be used.

    If the parent object has the same name as one of the variables in the hierarchy, a direct reference must be made to the parent???s definition of the variable, not the lower variable's definition. If the referenced definition is not the parent, issues, such as circular references (e.g. VAR1=VAR1+3) can occur.

    Note: The most common use case where these issues can occur is with linked objects. With other objects you have complete control over the configuration, including variables, variable names and expressions that include variables. With linked objects you do not have complete control.

    A relative notation is available to automatically, skip over one or more definitions in the object grouping's hierarchy to find the desired variable definition with the given name.

    Begin the variable name with ..\., or ..\..\, or ..\..\..\, etc.

    Example

    In an expression:

    Enter: ??{..\variable}

    Example

    An OBJECTNAME (object ID) variable represents the object instance that will be used.

    OBJECTNAME will occur at more than one level in a group of nested variables that are set up for a conveyor line section.

    Setup

    Conveyor Line Section

    The conveyor line section, which is the top of its hierarchy:

    • Is identified using the OBJECTNAME variable.
    • Has the name: Conveyor South.
    • Has two motors: Motor1 and Motor2.

    Motors

    The two motors are linked objects that

    • Have the same variables to provide identification.
    • OBJECTNAME variable out of the parent's variable
    • Motorn variable suffix that identifies the specific motor.
    • Have unique names: one is Motor1; the other is Motor2.
    Motor Variable ID
    Motor 1 {..\OBJECTNAME}.{Motorn}
    Motor 2 {..\OBJECTNAME}.{Motorn}

    Parts

    Each motor has two parts, which can be identified using a .suffix.

    The parts are identified as a continuation of the variable concatenation.

    Part Variable ID
    Part 1 {..\OBJECTNAME}.{..\Motorn}.Part1
    Part 2 {..\OBJECTNAME}.{..\Motorn}.Part2

    Results

    Conveyor South is identified for each motor that is in its hierarchy.

    Motors

    Motor Identification
    Motor 1 Conveyor South.Motor1
    Motor 2 Conveyor South.Motor2

    Parts

    Conveyor South is identified for each motor part that is in its hierarchy.

    The correct motor (Motor1 or Motor2) is identified for the parts that are in its group

    Motor1 Parts

    Part Variable ID
    Part 1 Conveyor South.Motor1.Part1
    Part 2 Conveyor South.Motor1.Part2

    Motor 2 Parts

    Part Variable ID
    Part 1 Conveyor South.Motor2.Part1
    Part 2 Conveyor South.Motor2.Part2