"On Show" script substitute for ArchestrA graphics

While developing a control screen using ArchestrA graphics, I found that the "On Show" script provided for graphics is flaky at best. This is especially apparent when referencing dynamically referenced objects in the script. In this case, the graphic can be used by several different objects. In order to allow it to get it's bearings on startup, it is embedded in another graphic. That graphic has a "while showing" script with a statement something like this:

MyGraphic.OwningObject = InTouch:MemoryNodeID + "some other text to dynamically build the object name";

This allows me to use "Me.WhateverUDA" type references in my graphic to interact with the object assigned as "OwningObject" above. The problem is that any "Me.WhateverUDA"-type statements I put in the "On Show" script don't work because of timing issues. The "On Show script apparently fires before the "OwningObject" statement above. The result is that "Me.WhateverUDA" means nothing & anything I do with it fails. Simply, it doesn't YET know what "Me" is referencing.

So, as with most things done in Wonderware products, I had to find a workaround. Here's what I came up with: I created a private custom property called "Reset" with a default value of true. I then created a named script for the graphic and set it's expression to "Reset" and it's trigger to "WhileTrue" with a Period of 500ms. This 500ms delay essentially waits a half second after the graphic loads to fire the script. This allows the owningobject to be set so the "Me" expressions will reference the correct object.

In the script, I simply set Reset to 0 (false), and did what I needed to with my "Me.WhateverUDA" statements.

Comments

Popular posts from this blog

Fixing Conan Lock Issues

Dynamic Object Oriented programming in ArchestrA

Initialize With Care