Performance tips for E3.

Slow applications? Screens taking too long to open? Animations hanging? In this article, we will share some tips with you for better development that will help you avoid this kind of performance issues in your E3 applications.

WhileRunning Events

Avoid using cyclical scripts. Sometimes, these kind of scripts are used in order to perform a certain type of animation on screen, or to get the current value of a given property or equation. Instead of creating a cyclical event to perform these functions (which can make the application underperform), most of the times you can simply use links, which will play these exact same roles without damaging the system. This happens because links are only checked when the source’s value (or property) changes.

In case you cannot use links to implement the intended result, it is advisable to create a user-generated event that will only be executed when one of these conditions is met.

Accessing Server objects via Viewer

Every time the value of a Server’s tag or property is asked via scripts in the Viewer with Application.GetObject method, communication with the Server is established. Therefore, the more often this method is used, the more the Viewer will communicate with the Server, which leads to worse performance. However, there are some ways you can reduce the frequency of Application.GetObjects in your application. For example:

  • Replace script equations with links whenever possible
  • Use Viewer tags (demo, internal, chrono, timer) instead of Server tags
  • Create properties in the XControls to access properties from XObjects

Another suggestion to optimize this access to data is to use Set command to create a reference to the object, and then copy the property’s value to an internal variable of the script. See the examples below:

How not to do it:

     If Application.GetObject(“Data.InternalTag1”).Value <= 10 then
               Application.GetObject(“Data.InternalTag1”).Value =  Application.GetObject(“Data.InternalTag1”).Value +1
     Else
               Application.GetObject(“Data.InternalTag1”).Value = 0
     End if

How to do it:

     Set Tag1 = Application.GetObject(“Data.InternalTag1”)
     Dim Valor
     Value = Tag1.Value
     If Value <= 10 then
               Tag1.Value = Valor +1
     Else
               Tag1.Value = 0
     End if

Animations on screen

Never overlap several Figures to create animations. The right way to do it is to use just one Figure, and then create a link at FileName property. Also, whenever you need a demo tag to animate a certain screen object, you should use a tag from the Viewer, because then the Viewer will not need to constantly access the Server to search for this tag’s value.

Historical E3Chart

Configure the query to return only the fields that will be used in the Chart. Preferably, use E3Chart’s automatic query option, because it will return only the necessary data, given the time limits configured on the horizontal axes.

Complex figures

Some image files are highly complex. This is the case of WMF files, which can lead animations to underperform, especially regarding backgrounds and colors. It is better to simplify these objects, so that the animations will be lighter. It is also advisable to use small, compact image files (for example, PNG or JPG), because the larger the file, the longer it will take to be transferred to the remote Viewer. Lastly, use the transparency resource carefully, especially when dealing with large figures, because this resource takes up a lot of processing.

Scripts sizes

Avoid longer scripts, and prefer small, simpler ones. However, you should notice that the number of lines in a script do not always indicate better performance, because some single-line operations (such as a script that performs a synchronous write in an I/O tag, or access to the database, for example) can take a considerably long time to process.

Defragmentation

Use the defragmentation option for files belonging to the Domain, especially in very large applications. They can be significantly compacted, and this will enhance their performance.

Changing links between screen objects and Server objects at runtime

This task demands a lot of processing from the Viewer, because it will deactivate and reactivate links with Server objects. To change links between screen objects and Server objects, you should use the screens’ OnPreShow event, because this is where the screen objects’ links have not yet been activated.

Communication

Some points to ponder regarding communication settings:

  • EnableDeadBand: disable this property only when it is essential that E3 receive all reads performed by the driver (even when there is no change in value), such as when acquiring digital events.
  • Scan: when configuring the tags’ scan, you must take into consideration how important this information is to the application’s logic. That is, you must prioritize tags whose variation is larger, or whose usage is more important, by using smaller scan times. Another thing to consider is the type of physical quantity being handled; adequate scan to this quantity’s variation time (for example, when reading the room temperature).
  • Time-out: check for the occurrence of time-outs during communication. Time-outs are time intervals lost by the driver when trying to communicate without an answer; many times, this happens because of hardware problems, such as connection issues, cables, noise, etc. Retries are not always the best solution for this case, because this resource is not acting in the problem’s source.
  • Blocks: whenever possible, use Block tags to optimize the communication with the device. In addition, you must try to group blocks according to its use on screen. And whenever available in the driver, use superblocks (EnableReadGrouping property).
  • Synchronous Writes: only use them when really necessary. This type of write forces the script to wait for confirmation from the device before resuming its execution. E3 allows writes performed via scripts to be asynchronous, that is, write will be performed without waiting for confirmation from the device, by using WriteSyncMode property in the I/O driver and SyncWrite property in the OPC tag.
  • AdviseType: set this option as AlwaysInAdvise only when the tag’s value must be updated all the time. Otherwise, set is as AdviseWhenLinked, and E3 will activate the tag’s communication whenever necessary.
  • BlockMode: this property from OPC Tag Group controls how OPC tags are both activated and deactivated. When enabled, OPC tags are first grouped and then registered in the OPC Server (by the end of the group’s activation). When disabled, the tags are registered individually in the Server as soon as they are activated; this takes a considerably longer time. On deactivation, the same thing happens: when BlockMode is on, all tags are removed at the same time by the end of the OPC group’s deactivation. When it is off, the tags are removed individually, as soon as each tag is deactivated.
  • Pool of IOServer Processes: In applications with hundreds of Drivers, all resources needed to execute IOServer processes for each Driver may consume operating system’s capacity. In these cases, it may be necessary to enable a Pool of IOServer Processes on Properties tab of a Domain configuration.

Historic

When configuring the historic, set indexes to accelerate the speed of queries performed in the table. If the application has several historics, you can do one of the following to enhance its performance:

  • Create more than one DB server: split historics into different DB servers when the application has too many historics, and they execute a great deal of writes in the database.
  • Connect to pre-existing tables: create the historics’ struscture via E3, and then reconfigure the historic to connect to a pre-existing table. This will narrow down the number of operations performed by the historic to connect to the tabe, thus optimizing its initialization.

Queries

Viewer queries: whenever you need to use a query via scripts in the Viewer (by using GetADORecordset method), and the returned data is static, you should perform this query only once, and then store this data in Viewer tags. For example:

     Set Consulta = Application.GetObject(“Dadta.Query1”)
     Set Tag = Application.Item(“InternalTag1”)
     Tag.Value = Consulta.GetADORecordSet()

Asynchronous queries: to access the data from a Query via scripts (which can return too much data, or even several queries), you can use GetAsyncADORecordset method. This method, unlike GetADORecordSet, does not hang the script while the query’s result had not been loaded. Instead, script execution continues, and the query’s result is returned at OnAsyncQueryFinish event.

Stored Procedures

Sometimes, due to the complexity of the desired query, you may benefit from creating a stored procedure in the database, and leave E3 to just execute it. Therefore, all processing generated by this query will be distinct from E3.

Print Friendly, PDF & Email

Este artigo foi útil? Was this helpful?

Classificação média - Average rating 0 / 5. Count: 0

Leave a Reply

Your email address will not be published.Required fields are marked *