4.2.2. Symbol Binding

Procedure 4.4. Change a Light Switch Symbol Binding to Simulate On and Off
  1. Using the same page as above, add a Symbol control.

  2. In the Symbol Selection for the Symbol Set, select Symbol Factory, for the Category, select Operator Interface, and for the Symbol, select Light switch (on).

  3. Select the ShiningLight control, and in the Basic Properties, right mouse click on Is Light On to copy the reference.

  4. Select the Symbol (light switch) and in Custom Events, for OnChecked Event, enter:

    SETP("ShiningLight1@IsLightOn", true);

    Then press the Apply button.

  5. In Custom Events, for OnUnChecked Event, enter:

    SETP("ShiningLight1@IsLightOn", false);
  6. Switch to Run mode and click the light switch symbol to turn the Shining Light on and off.

    This works OK, but it looks strange to have the light go off when the light switch is still in the ON position. We'll fix that next.

  7. Select the Symbol (light switch) and in Custom Events, for OnChecked Event, add one more line:

    SETP("ShiningLight1@IsLightOn", true);
    SETP("@SymbolID", 955272870);

    [Note]

    For this and the next step, the string @SymbolID refers to the symbol itself.

  8. In Custom Events, for OnUnChecked Event, add one more line:

    SETP("ShiningLight1@IsLightOn", false);
    SETP("@SymbolID", 1685125442);
  9. Switch to Run mode and click the light switch symbol to turn the Shining Light on and off.

    Now the symbol changes from Light switch (on) to Light switch (off) as the light goes on and off.