Creating a Direct Connection to an Object

The following example connects an AI tag to the Horizontal Fill Percentage of a rectangle when you click it in the run-time environment.

To connect an AI tag to the Horizontal Fill Percentage of a rectangle when you click it:

  1. Draw a rectangle on your screen.
  2. Create an AI database Tag with RA as the I/O address (using the SIM driver).
  3. Right-click the rectangle and select Edit Script from the pop-up menu.
  4. Enter the following code in the rectangle's Click event:
  5. Dim lstatus as Long

    Rect1.Connect "HorizontalFillPercentage", _    "Fix32.Thisnode.AI.F_CV", lstatus

  1. Switch to Run and Click the rectangle.

Before you click the rectangle, it is solid. After you click it, the rectangle starts to fill based on the AI tag's value. You have dynamically connected the rectangle's fill level to the database tag.

Example: Changing the Data Source of an Animation Connected to an Object

As we discussed in the Working with iFIX Objects chapter, there are three different types of animation objects — Lookup, Linear, and Format. The example below shows you how to set an object, and change the source of the animation object that is connected to it while you are in the run-time environment.

To set an object and change the source of the animation object that is connected to it:

  1. Create an AI block (AI1) with RA as the I/O address, and another AI block (AI2) with RG as the I/O address.
  2. Create two Data links. Connect one Data link to AI1, and connect the other to AI2.
  3. Add a rectangle, and animate its Foreground Color (a Lookup object) using AI1 as the data source.
  4. Now animate the fill of the rectangle (a Linear object), and use AI1as the data source.
  5. Edit the rectangle's Click event.
  6. Enter the following code:
  7. Dim AllObj As Object

    Dim SingleObj As Object

    Dim Count As Integer

    Dim ObjCount as Integer

     

    'Set AllObj equal to the collection of contained objects

    'in the picture.

    Set AllObj = _

    Application.ActiveDocument.Page.ContainedObjects

     

    'Check how many objects are in the picture.

    For Each SingleObj In AllObj

         Count = AllObj.Count

         'Look through all of the objects in the picture.

         While Count > 0

              'If the current object (shape) has contained objects,

              'check the number of objects (animations) it contains.

              If SingleObj.ContainedObjects.Count > 0 Then

                   ObjCount = SingleObj.ContainedObjects.Count

                   'For each object contained in the current object,

                   'check its class name.

                   While ObjCount > 0

                        Select Case _

                        SingleObj.ContainedObjects._

                        Item(ObjCount).ClassName

                        'If the contained object is a Lookup

                        '(table), change the data source to

                        'FIX32.THISNODE.AI2.F_CV

     

                        Case "Lookup"

                        SingleObj.ContainedObjects._

                        Item(ObjCount).Source = _

                        "Fix32.Thisnode.AI2.F_CV"

                        'If the contained object is a Linear object,

                        'change the data source to

                        'FIX32.THISNODE.AI2.F_CV

     

                        Case "Linear"

                        SingleObj.ContainedObjects._

                        Item(ObjCount).Source = _
                        "Fix32.Thisnode.AI2.F_CV"

                        End Select

     

                         ObjCount = ObjCount - 1

                    Wend

              End If

         Count = Count - 1

         Wend

    Next SingleObj

  1. Switch to the run-time environment and click the rectangle.

    Both the Fill and Color animations change from the current value of AI1 to the current value of AI2.

See Also

How Do I...

Important Notice

You do not have the latest version of iFIX! You are missing out on the newest capabilities and enhanced security.

For information on all the latest features, see the iFIX product page.

For more information on upgrades, contact your GE Digital sales agent or e-mail [email protected].

For the most up-to-date documentation, go here.