|
Please use our Code Center to obtain source-code and example projects/solutions:
http://codecenter.softwaretoolbox.com
|
|
|

|
|
|
|
|

|
|
 Web Based Applications using the OPC Web Client Web Service
Auto Polling Tags, a.k.a Subscriptions
What is Auto Polling?
Auto-polling is a means in which the OPC Server will poll the tag(s) you specify at an interval you
specify. Instead of your application using a Timer to periodically request the value of a tag or tags, you instead receive notifications when a tags value has changed. Your application essentially will
process an "Event" upon the change of a Tags value. This can be a highly efficient way of reducing overhead on your system.
What this program will do
This program will notify the OPC Web Client to make asynchronous callbacks to this application whenever a tags value changes. What this means is: When the Tag(s) value changes value an
event will be raised where your code will process the new tag value.
JavaScript:
<HTML> <SCRIPT LANGUAGE="JScript"> function fnInit() { provider.init();
provider.subscribe({ServerClass: "OPCLabs.KitServer.2", ItemID: "Simulation.Random"}, "editRandom"); provider.subscribe({ServerClass: "OPCLabs.KitServer.2", ItemID: "Trends.Ramp (1 min)"}, "editRamp"); provider.subscribe({ServerClass: "OPCLabs.KitServer.2", ItemID: "Trends.Sine (1 min)"}, "editSine"); provider.subscribe({ServerClass: "OPCLabs.KitServer.2", ItemID: "Simulation.Register_I4"}, "editRegister"); }
function fnRefreshResult() { var value = event.error ? "Err: " + event.errorMessage : event.outputs.Value;
document.getElementById(event.info).value = value; }
</SCRIPT> <BODY onload="fnInit()"> <DIV id="service"
style="behavior:url(webservice.htc)"></DIV> <!--ADD A URL ATTRIBUTE BELOW TO CONNECT TO A SPECIFIC MACHINE--> <DIV id="provider"
style="behavior:url(easyaccess.htc)" webService="service" onRefreshResult="fnRefreshResult()"></DIV>
<INPUT type="text" readonly="readonly" id="editRandom"/> <INPUT type="text" readonly="readonly" id="editRamp"/>
<INPUT type="text" readonly="readonly" id="editSine"/> <INPUT type="text" readonly="readonly" id="editRegister"/>
</BODY> </HTML> |
|

|
|
|
|

|
|
|