Professional OPC
Development Tools

logos

Online Forums

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

Please read Rules for forum posts before reporting your issue or asking a question. OPC Labs team is actively monitoring the forums, and replies as soon as possible. Various technical information can also be found in our Knowledge Base. For your convenience, we have also assembled a Frequently Asked Questions page.

Do not use the Contact page for technical issues.

QuickOPC-COM and PHP [ReadMultipleItems]

More
28 Jul 2010 16:56 #42 by reel
Replied by reel on topic Re: QuickOPC-COM and PHP
Thank you, I appreciate!

Please Log in or Create an account to join the conversation.

More
28 Jul 2010 16:24 #41 by support
Replied by support on topic Re: QuickOPC-COM and PHP
Here is an example that works out of the box (with our simulation server):

$EasyDAClient = new COM("OPCLabs.EasyDAClient.5.0"); $ItemIds = new VARIANT(array("Simulation.Random", "Trends.Ramp (1 min)", "Trends.Sine (1 min)", "Simulation.Register_I4")); $Results = $EasyDAClient->ReadMultipleItems("", "OPCLabs.KitServer", $ItemIds); foreach ($Results as $X) print $X->Vtq->ToString()."";
It produces following output (e.g.):

1.25125888851588E-03 {VARTYPE(5)} @7/28/2010 6:13:40 PM; OPCQUALITY(192)
0.667287677526474 {VARTYPE(5)} @7/28/2010 6:13:40 PM; OPCQUALITY(192)
-0.867969703914737 {VARTYPE(5)} @7/28/2010 6:13:40 PM; OPCQUALITY(192)
0 {VARTYPE(3)} @7/28/2010 6:13:40 PM; OPCQUALITY(192)

This is with QuickOPC-COM 5.01.274.1, and PHP 5.2.12. There may be no one-line way to convert the resulting VT_ARRAY back to normal PHP array, but accessing the elements, and the use of 'foreach', is possible, so you can always convert it to anything you like, in a loop. I have searched the Web a little and assembled a list of related links, just in case:
www.mail-archive.com/php-bugs@...
www.colorpilot.com/blog/com-ar...
bugs.php.net/bug.php?id=39596
www.phpwelt.net/handbuecher/cz...
www.nme.at/download/phpcon02_m...
osdir.com/ml/php-windows/2010-...
<a href="forums.devnetwork.net/viewtopic.php?f=14&t=3599" target="_blank" rel="nofollow">forums.devnetwork.net/viewtopi...
www.colorpilot.com/pdfcreatorp...

Please Log in or Create an account to join the conversation.

More
28 Jul 2010 15:13 #40 by reel
Replied by reel on topic Re: QuickOPC-COM and PHP
This is the creation of the array... There is not much doc about the array type needed. Also, PHP support for the VARIANT type is kind of harshe...
$MultiTank = array();
foreach ($TankList as $Tank) {
$MultiTank[] = "\"R" . $Tank . "M_NIVEAU_OMRON\"";
$MultiTank[] = "\"IndMon_10_R" . $Tank . "\"";
}
$Results = OPC_TagReadMultiple($Server, 0, $MultiTank, 1);
function OPC_TagReadMultiple($OPCServer, $Source, $Tag, $ifLevel)
{
$Node = OPC_GetServer($Source);
$OPCResult = $OPCServer->ReadMultipleItemValues($Node[0], $Node[1], $Tag);

$StrResult = $OPCResult->ToString;

$ArrResult = explode(" ", $StrResult);
$ArrCount = sizeof($ArrResult);
if ($ArrCount > 3)

Please Log in or Create an account to join the conversation.

More
28 Jul 2010 12:21 #39 by support
Replied by support on topic Re: QuickOPC-COM and PHP
Technically speaking, the variant on input, for arrays, should be VT_ARRAY | VT_xxxx, where VT_xxxx is an element type - the type that is accepted by a ReadItem for the same argument, or anything that can be converetd to that type. So, for example, for an input array of OPC Item IDs, the type on input should be VT_ARRAY | VT_BSTR, or convertible to it.
On ReadMultipleItems output, the type is VT_ARRAY | VT_VARIANT. The individual elements then hold interface pointers to DAVtq objects.
Each tool or language then has its own way of expressing the arrays, composing them or accessing their elements, so the above information may not be of direct use. And yes, arrays do not "per se" convert to strings. We currently do not have a specific example of how to work with arrays in PHP, but I will try to create it for you; for start, please send me (post here) your current code, so that I can investiage what is happening in there.

Please Log in or Create an account to join the conversation.

More
27 Jul 2010 22:11 #38 by reel
I would like to know which type of variant does ReadMultipleItems returns to PHP?
Or it might not take the array (common) that i am sending.
Seems like I am not able to .ToString it than explode it (the same way that I use with ReadItems)

Please Log in or Create an account to join the conversation.

Moderators: support
Time to create page: 0.050 seconds