The ability to use VBA and scripting throughout DeltaV Operate opens the system for almost limitless uses. VBA can be used to significantly customize and extend the functionality of DeltaV Operate. As with all good tools, you need to develop a sound strategy for implementing VBA in your applications. It is important to remember that you should use VBA to leverage additional functionality, rather than using it to replace the existing, built-in DeltaV Operate functionality.
While addressing the fundamentals of how to write solid VBA code is beyond the scope of this document, this chapter does contain some suggestions for effectively using VBA in your DeltaV Operate process.
You can adjust a setting in the FixUserPreferences.ini file to fine tune your script's performance. In the [Scripting] section of the FixUserPreferences.ini, which is located in your DeltaV\iFIX\Local directory, the ScriptIdleTimeProcessingDelayCount is set to -1, by default. At this default setting, your script performance will take precedence over your graphic's performance. You can change this setting to 0 or 1 to improve the performance of your graphics.
One strategy you may want to use is to maintain the setting at -1 for faster processing of scripts on your ProfessionalPLUS workstation and to change the setting to 0 or 1 for faster loading of your graphics on your Operator Stations.
Do not change the setting to a number larger than 1. A larger number will not improve performance.
In the course of developing your displays, you may place some objects into VBA. As your displays develop, you may realize that you do not need VBA functionality on all of these objects.
Your system's performance will improve if you reduce the number of VBA objects and VBA procedures to only those that you truly need. As part of a clean up process before putting your pictures into run time, remove all unused event procedures and remove empty VBA scripts. When there are no scripts configured for an object and the object is not referenced by other scripts, it will be omitted from the VBA processing queue.
Large amounts of code in the Initialize and Activate events will impact when you can first interact with the picture when it is opened. For example, a picture with a button on it may open almost immediately, and you can click on that button, but you will not be able to trigger any event tied to that button until all the scripts in the Initialize and Activate events have run to completion.
Also, avoid adding tags to the DataSystem OCX in the picture initialize. Move this action to the FixGlobals_Initialize event of the User Project, design it to load the tags on demand, or initialize it in a global script.
DeltaV Operate includes several subroutines that can help simplify scripts that are intended to perform common tasks, such as acknowledging alarms or replacing pictures. Since these subroutines are stored in the FactoryGlobals project, they can be automatically accessed directly through the Visual Basic Editor.
In addition to providing the code necessary to perform the task at hand, subroutines offer several "extras" that you would normally have to code yourself, including:
Generic error handling.
Posting of operator messages to alarm areas.
Conformance to VBA naming conventions.
Do not reference other pictures or global pages in VBA unless they will already be opened in your run-time environment. Referenced pictures that are not already open will need to be opened, which will impact your system's performance.
Place scripts that will be referenced by many pictures in the User Globals page. The User page is the location where you can put your own objects, methods, forms, and variables that you want to use globally.
If made public, the objects, methods, forms, and variable objects contained in the User page can be accessed from anywhere within your system. Since the items that you define as public in the User page can be accessed from anywhere in the system, make sure that what you enter is really what you want to expose. If you create a global public variable, remember that it can be changed from any script at anytime.