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.

the value of tag doesn't change

More
20 Apr 2023 09:57 #11696 by support
Hello,
thank you for letting me know, and I am glad the issue is resolved. I assume that setting the MaximumAge to 0 was what has fixed it.

If you had let me know that you have problems converting to FoxPro. I would have a workaround for you: We have ReadItemList method that does the same thing, but instead of arrays it uses a list object (and we have ElasticVector class for it).It was introduced for another language (PowerScript) which also had problem dealing with COM arrays.

Example PowerScript code with the list (for OPC DA, not OPC UA, and without the MaximumAge setting, but the principles are the same):

 
// This example shows how to read 4 items at once, and display their values, timestamps and qualities.
 
mle_outputtext.Text = ""
 
// Instantiate the client object
OLEObject client
client = CREATE OLEObject
client.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")
 
// Prepare arguments.
 
OLEObject readItemArguments1
readItemArguments1 = CREATE OLEObject
readItemArguments1.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments1.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments1.ItemDescriptor.ItemID = "Simulation.Random"
 
OLEObject readItemArguments2
readItemArguments2 = CREATE OLEObject
readItemArguments2.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments2.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments2.ItemDescriptor.ItemID = "Trends.Ramp (1 min)"
 
OLEObject readItemArguments3
readItemArguments3 = CREATE OLEObject
readItemArguments3.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments3.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments3.ItemDescriptor.ItemID = "Trends.Sine (1 min)"
 
OLEObject readItemArguments4
readItemArguments4 = CREATE OLEObject
readItemArguments4.ConnectToNewObject("OpcLabs.EasyOpc.DataAccess.OperationModel.DAReadItemArguments")
readItemArguments4.ServerDescriptor.ServerClass = "OPCLabs.KitServer.2"
readItemArguments4.ItemDescriptor.ItemID = "Simulation.Register_I4"
 
OLEObject readItemArgumentsList
readItemArgumentsList = CREATE OLEObject
readItemArgumentsList.ConnectToNewObject("OpcLabs.BaseLib.Collections.ElasticVector")
readItemArgumentsList.Add(readItemArguments1)
readItemArgumentsList.Add(readItemArguments2)
readItemArgumentsList.Add(readItemArguments3)
readItemArgumentsList.Add(readItemArguments4)
 
// Obtain values/timestamps/qualities.
OLEObject vtqResultList
vtqResultList = client.ReadItemList(readItemArgumentsList)
 
// Display results
Int i
FOR i = 0 TO vtqResultList.Count - 1
OLEObject vtqResult
vtqResult = vtqResultList.Item
IF vtqResult.Succeeded THEN
mle_outputtext.Text = mle_outputtext.Text + "vtqResult[" + String(i) + "].Vtq: " + String(vtqResult.Vtq) + "~r~n"
ELSE
mle_outputtext.Text = mle_outputtext.Text + "vtqResult[" + String(i) + "] *** Failure: " + vtqResult.ErrorMessageBrief + "~r~n"
END IF
NEXT
 
 

Best regards

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

More
20 Apr 2023 09:41 #11695 by balleri
Hy,
we were unable to convert the code to visual foxpro as this language treats arrays of objects differently.
We created an ocx in viusal basic and use it from visual foxpro and that fixed the problem.
This way the value is read correctly.
I leave this comment so that others can benefit from it.
Thank you.
Best regard.

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

More
12 Apr 2023 09:24 #11683 by support
Please read my post again. It is explained there why not.

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

More
12 Apr 2023 09:23 #11682 by balleri
Hy,
please, It is possible to have one example with ReadValue instead ReadMultipleValue?
Best regard.

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

More
11 Apr 2023 16:34 #11678 by support
Thank you.

There should not be much difference between what you are doing from the Prosys client, and what QuickOPC does. The only significant difference I can think of is the MaximumAge parameter for the read. Our default is 1000 milliseconds; it Prosys client might be using 0 ("read from the data source"). It would be worth trying that.

I do not have FoxPro example, but I have a VBScript which you should be able to adapt. Note that (in COM), we do not have a function that reads just single value in this way, so you will need to use the method that reads "multiple" values - even though you can shrink the number down to 1 if you like.

What matters is the assignment of zero to the .MaximumAge in the code below:

 
Rem This example shows how to read 3 values (without status or timestamps) at once, from the device (data source).
 
Option Explicit
 
' Instantiate the client object
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
 
Dim ReadArguments1: Set ReadArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments1.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments1.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10845"
ReadArguments1.ReadParameters.MaximumAge = 0.0
 
Dim ReadArguments2: Set ReadArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments2.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments2.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10853"
ReadArguments2.ReadParameters.MaximumAge = 0.0
 
Dim ReadArguments3: Set ReadArguments3 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAReadArguments")
ReadArguments3.EndpointDescriptor.UrlString = "opc.tcp://opcua.demo-this.com:51210/UA/SampleServer"
ReadArguments3.NodeDescriptor.NodeId.ExpandedText = "nsu=http://test.org/UA/Data/ ;i=10855"
ReadArguments3.ReadParameters.MaximumAge = 0.0
 
Dim arguments(2)
Set arguments(0) = ReadArguments1
Set arguments(1) = ReadArguments2
Set arguments(2) = ReadArguments3
 
' Obtain values. By default, the Value attributes of the nodes will be read.
Dim results: results = Client.ReadMultipleValues(arguments)
 
' Display results
Dim i: For i = LBound(results) To UBound(results)
    Dim ValueResult: Set ValueResult = results(i)
    If ValueResult.Succeeded Then
WScript.Echo "Value: " & ValueResult.Value
    Else
WScript.Echo "*** Failure: " & ValueResult.ErrorMessageBrief
    End If
Next
 
' Example output:
'
'Value: 8
'Value: -8.06803E+21
'Value: Strawberry Pig Banana Snake Mango Purple Grape Monkey Purple? Blueberry Lemon^

 


If this does not help, we may have to resort to Wireshark analysis of the communication.

Best regards

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

More
11 Apr 2023 14:12 #11677 by balleri
Hy,
I look at the value of the Value attribute after selecting the node from the treelook at the value with Prosys OPCUA Client.
Best regard.

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

More
11 Apr 2023 13:05 #11676 by support
Hello,
do you mean the "Prosys OPC UA Browser" client? (if not, and you are using something else, please point me to the precise location/information).

If you are using Prosys OPC UA Browser: Do you simply look at the value of the Value attribute after selecting the node from the tree, OR are you doing "Monitor Data" and then watching the value changes in the "Data View" tab?

Regards

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

More
11 Apr 2023 08:12 #11675 by balleri
Hy,
1) I wanted to clarify that if I write it, I have no problems getting the visible value even with other programs, while if they write it from the plc, the value available on the other programs (Prosys) and what I get with reading are different.
2) WeintekUAServer
3) Visual Foxpro
No subscriptions
oClient = CREATEOBJECT("OpcLabs.EasyOpc.UA.EasyUAClient")
rit_val = oClient.ReadValue(indi_OPCUA, mio_nr_varia)
Best regards

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

More
08 Apr 2023 14:53 #11666 by support
Hello.
No, there should be no need to "refresh" the value.

I have some additional questions:

1)I do not quite understand how the following two statements fit together:
- "the value of tag doesn't change when I read with my program...."
- "If I write the same tag the value is written correctly and I read it without problems."
Are you saying that the difference is that in the first case, the values is changed "from within" the server?

2) Which OPC UA server are you connecting to?

3) You talk about "reads" - please just confirm that you are *not* using subscriptions (in this case).

Best regards

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

More
06 Apr 2023 12:05 #11659 by balleri
Hy,
the value of tag doesn't change when I read with my program with OpcLabs.EasyOpc library (Visual Foxpro) but the value was effectly changed if I look it with third part program.
After I have looked it with third part program (Prosys OPCUA Client) then I obtain the right value also on my program .
If I write the same tag the value is written correctly and I read it without problems.
It looks like the third part program force same kind of refresh of the tag.
What can I do to obtain the refresh of the value of the tag using OpcLabs.EasyOpc ?
Thanks.

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

Moderators: support
Time to create page: 0.106 seconds