Register    Login
 
Professional OPC Development Tools
And Services
 
 
SupportOnline Forums
 
Links: Related Pages
 
Links: Related Services
 
Links: Related Support
 
Links: Related Resources
 
Online Forums

Technical support is provided through Support Forums below. Anybody can view them; you need to Register/Login to our site (see link in upper right corner) in order to Post questions. You do not have to be a licensed user.

OPC Labs team is actively monitoring the forums, and provides answers as soon as possible. For your convenience, we have also assembled a Frequently Asked Questions page.

Please do not use the Contact page for technical support.

HINT: You may use the Search feature (magnifier icon below) in the forums to locate the information you need. You can also search our entire Web site (the search box in the upper right corner of every page).

 
 
SupportSupportKnowledge Base ...Knowledge Base ...QuickOPC-ClassicQuickOPC-ClassicQuickOPC-COMQuickOPC-COMQOC-KB-5. Simple PHP example using subscriptionsQOC-KB-5. Simple PHP example using subscriptions
Previous Previous
 
Next Next
New Post
 9/30/2010 7:52 AM
 
 Modified By OPC Labs Technical Support  on 9/30/2010 5:27:35 PM

Below is an example showing how you can subscribe to OPC item/value changes in PHP. QuickOPC-COM 5.01.404.1 or later is required.

IEasyDAClient.SubscribeItem.Main.zip (649 Bytes)

// $Header: $
// Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved.
//+++
// This example shows how subscribe to changes of a single item and display the value of the item with each change.
class DEasyDAClientEvents {
function ItemChanged($varSender, $varE)
{
print $varE->Vtq->ToString();
print "\n";
}
}
$EasyDAClient = new COM("OPCLabs.EasyDAClient.5.0");
$Events = new DEasyDAClientEvents();
com_event_sink($EasyDAClient, $Events, "DEasyDAClientEvents");
$EasyDAClient->SubscribeItem("", "OPCLabs.KitServer.2", "Simulation.Random", 1000);
print "Processing item changed events for 1 minute...\n";
for ($time = 0; $time < 60; $time++) com_message_pump(1000);
?>

Some related documentation: http://php.net/manual/en/function.com... .

Pay attention to the comment that says "Be careful how you use this feature; if you are doing something similar to the example below, then it doesn't really make sense to run it in a web server context.". What they are trying to say is that processing a web request should be a short-lived code, which does not fit well with the idea of being subscribed to events and received them over longer time. It is possible to write such code, but it is only useful when processing the request is allowed to take relatively long. Or, when you are using PHP from command-line, or otherwise - not to serve a web page directly.

Subscribing to QuickOPC-COM events in the context of PHP Web application, while not imposing the limitations to the request processing time, has to be "worked around", and will possibly be covered in a separate post.

Previous Previous
 
Next Next
SupportSupportKnowledge Base ...Knowledge Base ...QuickOPC-ClassicQuickOPC-ClassicQuickOPC-COMQuickOPC-COMQOC-KB-5. Simple PHP example using subscriptionsQOC-KB-5. Simple PHP example using subscriptions

 
 
 
 
 

 
 
 
 
Home|Services|Products|Purchase|Downloads|Support|Resources|Company|Contact
Copyright 2007-2012 by OPC Labs Terms Of Use Privacy Statement May 20, 2012