HOW TO USE ARCHESTRA WIZARDS PART 2
In the last tutorial we created a simple valve symbol that contained a vertical and horizontal orientation selection using the layering wizard. We didn;t have any scripts and the single value custom property was associated with both so layering wasn’t required for that element. In this tutorial we will add 2 new public custom properties two private custom properties and a few scripts to control the valve status color.
The new complex valve will support a four color status using two inputs one for open and one for close with a status integer set in a script based on input conditions. In addition to open and closed status we will also be able to detect if the valve is traveling between positions or having a trouble condition such as a blocked valve or power outage.
Step 1 is to rename the existing graphic element groups from grpHoriz and grpVert to grpSHoriz and grpSVert for “simple” and the orientation layers from Horizontal and Vertical to SHorizontal and SVertical as illustrated below.
Step 2 add new custom properties for the complex valve status indication as follows:
Type| Boolean | Name| CloseSW | Default Value | me.CloseSW | Visibility | Public
Type| Boolean | Name| OpenSW | Default Value | me.OpenSW | Visibility | Public
Type| Integer | Name| Status | Default Value | 0 | Visibility | Private
Type| Integer | Name| UpdateStatus | Default Value | False | Visibility | Private
Step 3 create two new layers CHorizontal and CVertical for “complex” and then make a duplicate of the simple horizontal group which will be modified by adding a truth table to the valve color control as seen below. Create a vertical and horizontal group using this table.
Center all of the valve elements placing the two new complex element groups in the appropriate complex layer.
The final step is to create the scripting necessary to control the color based on the OpenSW and CloseSW inputs.
First, create a DataChange script for each of the valve switches OpenSW and CloseSW that will set the UpdateStatus Boolean to true any time the state of the input changes.
This will provide an event triggered method to continuously monitor the state of those two switches.
Each time the UpdateStatus is set to true the Update script executes to test for switches for operational conditions setting the Status integer controlling color of the valve accordingly. Valve state is controlled according to the following truth table
Line 1 of the script is tests to see if the OpenSW is true and the CloseSW is false, if true the status integer is set to 1 otherwise the next if statement evaluates to see if the valve is closed making the status integer a 2 if that condition is met. The logic continues to flow testing every state of the two inputs until the valve state is known and the status integer set to the correct value.
If you are interested in doing a complete walk through with me you can watch the video of this tutorial here.
If you haven't taken the FREE online course you can do that here.
To pe-order the digital version of Step By Step Archestra Scripting go here. (Scheduled for release in October)
Please leave me a comment if you found this useful, I am always looking for new ideas for tutorials feel free to share any frustrations you may be having that you would like to see a tutorial for.
How To Use Archestra Graphic Wizards
A very powerful and useful feature added in later versions of Archestra is the layering wizard. The layering wizard feature allows you to make versatile graphic symbols fitting multiple scenarios.
Some ways I have seen wizards used is to represent several types of motors in a single symbol, or analog displays with options to change display format when the symbol is dropped on a screen or into another symbol.
The layers can be combined to create some very complex configurations although I would caution you to keep it as simple as possible. I have also witnessed first hand the pain of trying to modify or make updates to these rather complex creations only to find myself playing the “mole game” making a change in one thing only to discover it broke something in the layering that was seemingly unrelated. Keep it simple.
For this tutorial I have chosen a simple dual orientation valve graphic, it’s a commonly used symbol and perfect for wizard layering. In the older versions of Archestra if you wanted a valve symbol to indicate both in a vertical and a horizontal position you had two choices, either place visibility on the elements activated by some external, or build two separate symbols.
Layering solves this problem by giving your symbol intelligent configuration available at design time.
Step 1 to create a simple dual orientation valve symbol is to create your symbol with the necessary elements and properties. In this example I chose to make a valve that would display green if on or dark gray if off.
A public Boolean custom property is added to the valve symbol and default object reference provided that will coincide later with an object attribute. Note: Using a custom property allows you to choose an attribute other than “me.valve” later when the graphic is dropped into a screen or symbol.
Each valve is represented by two groups of triangle polygons grouped by orientation, vertical or horizontal, then centered on each other.
Each polygon is animated in exactly the same way using the “Value” custom property to manipulate the Fill Style between either green or dark gray.
Step 2 after completing the element animation configuration, is to establish and configure wizard layers.
In the Options pane of the Valve graphic editor select the new folders icon and create an option folder named “orientation”. This will become a configurable property available in the symbol property window at design time.Now, select the Orientation folder you just created clicking the Add Choice icon making two choices one named “Horizontal” the other named “Vertical” this will appear in the Orientation property as drop down items at design time.
Now when switching to the Layers menu you will find that a layer has been created for each of the choices associated with your Orientation choice group.
Each layer has a folder for associated Custom Properties, Graphic Elements, and Named Scripts.
In this example we will need to associate our two symbol groups with appropriate layer folder, since we are not using any scripts that folder is left empty and since our custom property is global to both layers it will associate with both by default. (Note: Once a script, element, or property has been associated with a layer it will only be available to the layer its associated with.)
To associate the two valve element groups all we need to do is drag and drop the group from the Elements pane to the Layers pane.
Now that the two groups are associated properly the valve symbol is complete.
One other thing I wanted to mention is that the small “eyeball” icon is used to make the layer visible or not while you are working in the symbol. If I want to know how the graphic will appear for each choice I only need to click the eyeball next to the group and toggle its visibility state. The eyeball on the Layer bar toggles visibility for all layers .This feature is only used at design time with no effect on the symbol at runtime.
When in use the valve graphic orientation is selected from the choice group drop down.
I hope this tutorial has helped you, please leave a comment. If you would like to learn more about this tutorial you can find the video version of it on my YouTube channel here.
My Free Online training course is here.
I am getting ready to launch the book Step By Step Archestra Scripting in October, I am offering a couple of one time bonuses to anyone pre-ordering the book. If you pre-order now you will get access to the companion online course at no additional charge and one year access to the online support forum I am launching at the same time.
You can pre-order the book Step By Step Archestra Scripting here.
How To Use Archestra Template Toolbox
The Template Toolbox allows you to manage template structures with ease. The goal of System Platform is to allow modeling of object structure after the process, machine or device. In this example I’m going to keep it simple so let’s take a look at how we can model a valve as a template structure.
A typical motorized valve like the one pictured here can be commanded to open or close with switch feedback to tell you if the valve has completed its travel to either limit.
One possibility for object structure in the Archestra galaxy to accommodate this model would be to create a container object for the valve itself then create individual objects for command output and switch feedback as shown below.
While the advantage of this method of representation is a clearly defined structure the presence of hundreds of these objects presents problems of maintaining and creation of new structures that can be time consuming or error prone.
This is where using the Template Toolbox to manage the structure becomes invaluable. The structure can easily be created inside a template tool set as shown below to create a template structure that can be maintained as a group. To create a new instance all that is required it right clicking the $Valve template and selecting “Create New Instance”.
When the new instance of the $Valve template is created it is created as a group, each template and sub template has a new instance created in the correct order.
In the derivation view we see that each of the sub templates assigned to $Valve master template are now represented as a dotfield such that $Valve.ClosedCmd, $Valve.ClosedSW, $Valve.OpenCmd, and $ValveOpenSW become elements of the master template.
As each new instance of the master $Valve template are created each of the sub element instances are also added. In this way each sub template can be located quickly from the galaxy derivation view by right clicking the template and selecting “Synchronize Views”.
Synchronize view only works between the Template Toolbox view and the Derivation view.
Once the view has been synchronized simply change to the deployment view tab to see the total object structure as it exists on the target platform.
Using Alarm Client Filters
One of my subscribers asked me to take a look at an issue he was having with the Alarm Client object in Archestra. He wanted to have multiple queries for narrowing down the alarms visible in the alarm history based on the area structure in the alarm model view.
He mentioned that he had read the Alarm Client guide and believed he was following it correctly yet he was unable to filter that alarms like he wanted to.
I know the alarm guide uses examples with the radio button component to switch queries at run time, but please allow me to show you another method which can be just as effective and I believe a bit easier to implement.
The method I’m going to show you is the favorite alarm query established at design time. In this example I configure r area filters and one “All” areas filter triggered with a radio button and data change script.
The key element in this strategy is to pre-configure the queries you want use for narrowing the alarm summary/history. In this case I created 4 area queries matching the areas defined in the model view each one representing a different generator set and another named “All” to show all alarms. The figure below shows the Query Filter dialog.
Once the alarm client query filters are configured you're ready to configure the radio button selector and associated scripting. The figure below shows the configuration for the radio button group. Create a string property on the host symbol named “FavoriteString” which becomes the reference for setting the filter favorite. As each radio button is selected the corresponding filter name is loaded into the “FavoriteString” property which in turn triggers a data change script.
The Data Change script executes the AlarmClient.Favorite method which is the secret sauce to this strategy for alarm filtering. As the filter name is presented the alarm client switches to use the indicated pre-configured alarm filter delivering the desired result.
Another script is placed in the show graphic area to set defaults when the alarm client first presents to the user. The next two figures below show the scripting configuration.
Once these steps have been completed the alarm client is ready for connection to the A2ALMDB.
For a more detailed look at how this method of alarm filtering is implemented you can head over to my you tube channel and watch this video for a complete demonstration.
If you are interested in learning more I offer a free online Archestra training course here.