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.

PHP opc retrieving signals

More
27 Jul 2018 11:44 #6553 by support
Replied by support on topic PHP opc retrieving signals
Hello.

I must say that I do not understand what is actually your problem. There are many things unclear in your reports.

1. You talk about "browsing" but the supplied code has nothing to do with browsing - it does subscriptions.

2. You talk about >= 20 signals but the supplied code uses just one node.

3. The DataChangeNotification handler does not contain proper error handling. You should test whether $E->Exception is not null, and if it isn't there is an error (in which case, $E->AttributeData is always null, which is probably the case you are referring to). So, in order to figure out what the error is, in case of non-null $E->Exception, you need to examine (display, print out, log..., whatever) its properties, such as (primarily) $E->Exception->Message .

4. I do not understand what you are trying to achieve with the use of threads. Please explain. If the problem is with the capacity of the communication link, using more threads is not going to magically make the link able to transfer more data.

5. In addition, all that you threads do is that they initiating the subscriptions, on the non-isolated EasyUAClient object. The OPC UA calls will get serialized anyway, so the end effect would be the same as calling making the two subscriptions sequentially, from the main thread- which is much easier.

Regards

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

More
27 Jul 2018 10:28 - 27 Jul 2018 11:33 #6552 by alr1976
Replied by alr1976 on topic PHP opc retrieving signals
This is with your servers with threads same thing:
<?php
 
class ClientEvents
{
    function DataChangeNotification($Sender, $E)
    {
        printf("%s\n", $E->AttributeData);
    }
}
 
class OPCWorker extends Thread
{
    public function __construct($client, $clientEvents, $signal)
    {
        $client->SubscribeDataChange(
            'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
            'nsu=http://test.org/UA/Data/;ns=2;i='.$signal,
            1000
        );
    }
 
    public function run()
    {
        while (true) {
            com_message_pump(1000);
        }
    }
}
 
$client = new \COM('OpcLabs.EasyOpc.UA.EasyUAClient');
$clientEvents = new ClientEvents();
 
com_event_sink($client, $clientEvents, 'DEasyUAClientEvents');
 
$test1 = new OPCWorker($client, $clientEvents, '10853');
$test1->start();
$test2 = new OPCWorker($client, $clientEvents, '10844');
$test2->start();
while (true) {
    sleep(1);
}
Last edit: 27 Jul 2018 11:33 by support.

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

More
27 Jul 2018 09:25 - 27 Jul 2018 11:33 #6551 by alr1976
Replied by alr1976 on topic PHP opc retrieving signals
okay so we discover that using a satellite link if we broswe more than 20 signals I will get all NULL so we are trying to split in blocks of 20-30 load per block and we want to use thread so if we don't use hreads works this is the code:
<?php
 
class ClientEvents
{
    function DataChangeNotification($Sender, $E)
    {
        printf("%s\n", $E->AttributeData);
    }
}
 
$client = new \COM('OpcLabs.EasyOpc.UA.EasyUAClient');
$clientEvents = new ClientEvents();
com_event_sink($client, $clientEvents, 'DEasyUAClientEvents');
$client->SubscribeDataChange(
    'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
    'nsu=http://test.org/UA/Data/;ns=2;i=10853',
    1000
);
 
while (true) {
    com_message_pump(1000);
}
so instead we want to use threads and in this case COM don't return anything this is the code
<?php
 
class ClientEvents
{
    function DataChangeNotification($Sender, $E)
    {
        printf("%s\n", $E->AttributeData);
    }
}
 
class OPCWorker extends Thread
{
    public function __construct($signal)
    {
        $client = new \COM('OpcLabs.EasyOpc.UA.EasyUAClient');
        $clientEvents = new ClientEvents();
        com_event_sink($client, $clientEvents, 'DEasyUAClientEvents');
        $client->SubscribeDataChange(
            'opc.tcp://opcua.demo-this.com:51210/UA/SampleServer',
            'nsu=http://test.org/UA/Data/;ns=2;i='.$signal,
            1000
        );
    }
 
    public function run()
    {
        while (true) {
            com_message_pump(1000);
        }
    }
}
 
$test1 = new OPCWorker('10853');
$test1->start();
$test2 = new OPCWorker('10844');
$test2->start();
while (true) {
    sleep(1);
}

let me know thanks
Last edit: 27 Jul 2018 11:33 by support.

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

More
24 Jul 2018 12:21 #6543 by support
Replied by support on topic PHP opc retrieving signals
As I wrote earlier in the other topic, post the (pieces of) code that retrieve the values and print the NULLs you are complaining about. Only then I can tell more.

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

More
24 Jul 2018 12:14 #6542 by alr1976
Replied by alr1976 on topic PHP opc retrieving signals
I have no message as far as I know but if Ir etrieve it around 20-30 I can read signals without problem but if I 've read 150 then I will have all null consider that the latency is around 1 seconds because there is a satellite link... what other spec do you kbow ? how do I set the log to check if therei is error ? I don't have error I just receive all the nodes with NULL instead of the value

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

More
24 Jul 2018 11:02 #6541 by support
Replied by support on topic PHP opc retrieving signals
I need to know the details. How do you know about the timeout? What is the error message?

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

More
24 Jul 2018 09:48 #6540 by alr1976
Replied by alr1976 on topic PHP opc retrieving signals
Seem that if I search for all nodes UA Server goes in timeout and give yo uall NULL so is there a workaround for this ?

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

More
23 Jul 2018 15:55 #6537 by support
Replied by support on topic PHP opc retrieving signals
Good - thanks for update.

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

More
23 Jul 2018 15:55 #6536 by support
Replied by support on topic PHP opc retrieving signals
@EvenChu: I have approved your post because it does not qualify as a spam, - so that you get access to the forums. However, as far as I can tell, your answer does not relate to the problem in question at all. Make sure your posts are to the point in the future.

Regards
The following user(s) said Thank You: EvenChu

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

More
23 Jul 2018 15:50 - 21 Aug 2018 16:00 #6535 by EvenChu
Replied by EvenChu on topic PHP opc retrieving signals
Hi...as per my knowledge The DataType Attribute defines the data type for the Value Attribute. Similarly like you can Read the Value Attribute, you can Read the DataType Attribute, with UaClient.readAttribute. AttributeIds are defined in the specification, however easiest is the use the org.opcfoundation.ua.core.Attributes.DataType constant. The returned DataValue.getValue().getValue() is a NodeId that points to a DataType node under Types/DataTypes. Usually you compare the returned NodeId to org.opcfoundation.ua.core.Identifiers constants for the standard namespace.

prototype pcb assembly china
Last edit: 21 Aug 2018 16:00 by EvenChu.

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

Moderators: support
Time to create page: 0.075 seconds