OPCReconnect.g — disconnects and reconnects an OPC server.
The code for this and other example scripts can be found in the DataHub distribution archive, typically at one of these locations: C:\Program Files\Cogent\OPC DataHub\scripts\ C:\Program Files\Cogent\Cascade DataHub\scripts\ Please refer to Section 3.1, “How to Run a Script” for more information on using scripts. |
/* Sample script that disables the OPC connection labeled "OPC000", waits 2 * seconds, then re-enables the connection. The result will be that the * OPC DataHub disconnects from the server for 2 seconds and then reconnects. */ require ("Application"); require ("OPCSupport"); class OPCReconnect Application { } /* Create an object that references an existing OPC connection that we have * configured through the user interface. Its label is the first argument to * setServer below. Once we have the OPC connection object, we can call * enable() with t or nil in the argument to enable or disable this connection. */ method OPCReconnect.enable(enabled) { local opcclient = new OPCConnection(); opcclient.setVerbose(t); opcclient.setServer("OPC000"); opcclient.enable(enabled); } method OPCReconnect.constructor () { .enable(nil); .TimerAfter(2, `(@self).enable(t)); } ApplicationSingleton (OPCReconnect);
Copyright © 1995-2010 by Cogent Real-Time Systems, Inc. All rights reserved.