Adding Auto Reconnect Functionality to Device Integration Objects
Notice: Undefined variable: post in /var/www/dev.industrial-software.com/wp-content/themes/node-child/framework/modules/blog/templates/single/post-formats/standard.php on line 9
Notice: Trying to get property 'ID' of non-object in /var/www/dev.industrial-software.com/wp-content/themes/node-child/framework/modules/blog/templates/single/post-formats/standard.php on line 9
Notice: Undefined variable: post in /var/www/dev.industrial-software.com/wp-content/themes/node-child/framework/modules/blog/templates/single/post-formats/standard.php on line 31
Notice: Trying to get property 'ID' of non-object in /var/www/dev.industrial-software.com/wp-content/themes/node-child/framework/modules/blog/templates/single/post-formats/standard.php on line 31
AVEVA Communication Drivers, AVEVA System Platform & OMI
Notice: Trying to access array offset on value of type null in /var/www/dev.industrial-software.com/wp-content/plugins/js_composer/include/autoload/vc-shortcode-autoloader.php on line 64
Notice: Trying to access array offset on value of type null in /var/www/dev.industrial-software.com/wp-content/plugins/js_composer/include/autoload/vc-shortcode-autoloader.php on line 64
Notice: Trying to access array offset on value of type null in /var/www/dev.industrial-software.com/wp-content/plugins/js_composer/include/autoload/vc-shortcode-autoloader.php on line 64
Notice: Trying to access array offset on value of type null in /var/www/dev.industrial-software.com/wp-content/plugins/js_composer/include/autoload/vc-shortcode-autoloader.php on line 64
SUMMARY
When a Device Integration object gets disconnected from its data source (e.g. an AVEVA OI Server), it must be manually triggered to reconnect when the source becomes available again. By using some basic scripting, you can configure the DI Object to automatically reconnect to the data source when the connection is lost. This tech note will instruct you on how to set up an auto reconnect feature and add additional diagnostic information that will indicate the number of disconnects the object has experienced since it last went on scan.
APPLIES TO
- Application Server
PROCEDURE
Section 1 – Add the Auto Reconnect Functionality
First, you will create a script that will automatically reconnect to the data source when the connection is lost.
- In the IDE, create a derived template from the DI Object base template you will be using (in this example, we are using the $DDESuiteLinkClient). Open the derived template in the configuration editor.
- On the Scripts tab, click the Add Script button.
- Name the new script Reconnect and press Enter.
- Configure the Reconnect script as follows:
Aliases: locked
Declarations: locked
Execution type: Execute and locked
Basics: locked
Expression: Me.ConnectionStatus <> 2
Trigger type: WhileTrue
Trigger Period: 00:00:05.0000000
Script body: Me.Reconnect = true;
This script will attempt to reconnect every 5 seconds, when not connected to the data source. You can adjust how often the object attempts to reconnect by modifying the Trigger Period setting.
Section 2 – Add an Attribute to Count the Disconnections
- On the Attributes tab, create and configure a new attribute as follows:
Name: Disconnect.Cnt
Data type: Integer
Writeability: Calculated
- On the Scripts tab, add a script named Disconnect.Monitor.
- Configure the Disconnect.Monitor script as follows:
Execution type: Execute and locked
Basics: locked
Expression: Me.ConnectionStatus <> 2
Trigger type: OnTrue
Script body: Me.Disconnect.Cnt = Me.Disconnect.Cnt + 1;
This script will increase a counter by one every time the condition is true.
Now you will add code within the same script under a different execution type that will run when the object goes on scan.
- While still in the Disconnect.Monitor script, change the Execution type to OnScan.
- In the script body, enter:
Me.Disconnect.Cnt = 0;
This script will reset the counter to zero every time the object goes on scan.
- Save and Close the object.
You can now create instances of this derived template for use in runtime. If the ConnectionStatus of the object is anything other than “2” (Connected), the script will trigger a reconnect attempt every 5 seconds until the connection has bee re-established. The Disconnect.Cnt attribute will count the number of times this object has disconnected since it was put On Scan.
All Industrial Software Solutions Tech Notes are provided "as is" without warranty of any kind.