Top  | Previous | Next

Parameterized Windows

It is often useful to create a parameterized window that can be re-used for multiple purposes, depending on the values that were passed into it when it was opened. For example, suppose you have 10 compressors, and the tags that represent them are predictable based upon the compressor number.

 

 

Compressors/

 

 

C1/

 

 

 

HOA

 

 

 

Amps

 

 

C2/

 

 

 

HOA

 

 

 

Amps

 

 

...

 

 

C10

 

 

 

HOA

 

 

 

Amps

 

You could make a single compressor status & control screen, and simply pass the relevant compressor number to it when you open it.

Passing Parameters

Any custom property on the root container of a window can be used as a window parameter. Simply specify the names of the custom properties to set in the call to openWindow to use them as parameters. Then, use the custom property to create indirect property bindings that bind to the appropriate spot.

 

For example, let's suppose that you had a window called CompressorPopup that you wanted to use to control all 10 compressors. You'd put a custom property on your compressor control window called compNum. You would use compNum in your tag bindings for the controls on your screen using indirect tag bindings. For example, you might bind the control and indicator properties of a Multi-State Button to an indirect tag binding like:

Compressors/C{1}/HOA

where the {1} paremeter is bound to the property path:

Root Container.compNum

You could use a similar indirect binding to display the amperage in an analog Meter component.

 

Now, when opening the window, you could use a script like this to open it to control compressor #6. Of course, you probably wouldn't write this script by hand, you'd use the navigation script builder. But it is useful to know what the script would look like.

 

system.nav.openWindow("CompressorPopup", {"compNum":6})

 

Opening Many Copies

By default, opening a window will only ever open one copy of any given window. If the window is already open, it simply brings it to the front. Normally this is the desired behavior. For example, if you opened the compressor popup window for compressor #6, and then opened it for compressor #4, the window that had been controlling #6 will switch to controlling #4.

 

Sometimes you may want to open a separate popup, one for #6, and one for #4, both at the same time. If this is the case, use the system.nav.openWindowInstance function call to open your window.