- Posts: 35
- Thank you received: 1
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.
- Forum
- Discussions
- QuickOPC-UA in COM
- Reading, Writing, Subscriptions
- QuickOPC VBScript ASP example script not working, pt.3
QuickOPC VBScript ASP example script not working, pt.3
- Kyle.Oshima@caltrol.com
- Topic Author
- Offline
- Platinum Member
Attachments:
Please Log in or Create an account to join the conversation.
as agreed over email, options 1 and 2 do not look realistic at the moment.
Can we please start with option 3. I propose a simple test first - try the same Write operation with our OpcCmd utility (which uses the same underlying QuickOPC libraries). The thinking is as follows: If the problem shows up with the OpcCmd utility as well (and is not limited to VBScript coding only), it would make the troubleshooting easier. The OpcCmd utility already contains some built-in tracing features that I can instruct you to turn on; or even if they need to be enhanced, we can do it on our side; sending you an updated OpcCmd would be easier that requiring you to rebuild your program and even make changes to it.
I assume you have installed QuickOPC using the Setup program. In such case there is an icon in the Launcher app to start the OpcCmd utility in the interactive mode
Choose "Interoperability" (A) mode when starting the OpcCmd for the first time.
Note that certificate trust may need to be established, if OPC UA secure communication is used. There will be prompts to trust the server certificate in OpcCmd; plus the server side needs to trust the client.
Can you please do so, and then enter the following three commands, and report the results here?
uaClient write opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer ns=2;s=0:UM1/PARAM1.CV [Int16]1111
uaClient write opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer ns=2;s=0:UM1/PARAM1.CV [Single]2222
uaClient write opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer ns=2;s=0:UM1/PARAM1.CV [Double]3333
Best regards
Please Log in or Create an account to join the conversation.
The OPC UA Type of the node you are writing to is Float: reference.opcfoundation.org/Core/Part3/v104/docs/8.15 . This can guarantee a precision of 6 decimal digits. So you are not dealing with QuickOPC limitation. The limitation is in the server, or its configuration, or the choice of the node.
I will send you some info about options 1) and 2) via email. If doing them turns up to be not realistic, I will provide instructions for option 3).
Best regards
Please Log in or Create an account to join the conversation.
- Kyle.Oshima@caltrol.com
- Topic Author
- Offline
- Platinum Member
- Posts: 35
- Thank you received: 1
re: "Please explain why you think so. I do not see why the precision should be lost", re-revising "ReadAndDisplayValue_VBScript.asp" example file changing WriteValueArguments1.Value object property to decimal value "12345.67890" out to 5 decimal places (see code below) returns success result however the target OPC UA value written is "12345.7" rounded to 1 decimal place (see screenshot below) Note our application is designed to handle decimal values up to 15 significant figures, and OPC UA interface would need to be able to pass such values unchanged -- short of that we need details of QuickOPC's limitations.
<!--$$Header: $-->
<!-- Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved. -->
<!---->
<!--Find all latest examples here : opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .-->
<%@ LANGUAGE="VBSCRIPT" %>
<html><head><t-itle>ReadAndDisplayValue_VBScript.asp</title></head>
<body>
<%
' Create EasyOPC-DA component
<!-- Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")-->
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
Dim WriteValueArguments1: Set WriteValueArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
WriteValueArguments1.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
WriteValueArguments1.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:UM1/PARAM1.CV"
WriteValueArguments1.Value = 12345.67890
WriteValueArguments1.ValueTypeCode = 13 ' TypeCode_Single
Dim arguments(0)
Set arguments(0) = WriteValueArguments1
' Modify values of nodes
Dim results: results = Client.WriteMultipleValues(arguments)
' Display results
Dim i: For i = LBound(results) To UBound(results)
Dim WriteResult: Set WriteResult = results(i)
If WriteResult.Succeeded Then
Response.Write "Result " & i & " success"
Else
Response.Write "Result " & i & ": " & WriteResult.Exception.GetBaseException().Message
End If
Next
%>
</body>
</html>
Attachments:
Please Log in or Create an account to join the conversation.
In OPC UA protocol, the value being written must precisely match the data type of the node. What you are asking about (...method of dynamically determining appropriate TypeCode ...) is what QuickOPC is supposed to do automatically, in order to relieve developers from passing in the precise type (which in some cases is not even doable because the type model in the language is not the same as the type model as in OPC UA, so the corresponding types may not even exist, but there might be something "close enough" available). This expected behavior somehow is not happening in your case, which was the case of the original BadTypeMismatch error. So if you want that behavior, we need to go the detailed troubleshooting path. That will require, in order of preference, either 1) us reproduce the problem here - i.e. get a copy of the server and the configuration that exhibits the problem, or 2) us getting remote access to connect via OPC UA to the server, or 3) you obtaining WireShark captures and other trace information (per our further instructions, and possibly multiple iterations). Let me know if you are willing/able to help with some of these options.
Regarding " the specified TypeCode does cause written value to lose decimal precision if value is not whole number": Please explain why you think so. I do not see why the precision should be lost.
Regards
Please Log in or Create an account to join the conversation.
- Kyle.Oshima@caltrol.com
- Topic Author
- Offline
- Platinum Member
- Posts: 35
- Thank you received: 1
Is there method of dynamically determining appropriate TypeCode from the target nodeID's datatype? -- e.g., first read target nodeID to determine returned datatype, then specify corresponding TypeCode object property to be written to target nodeID.
Valid target nodeID datatypes can be real, integer, or enumeration.
<!--$$Header: $-->
<!-- Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved. -->
<!---->
<!--Find all latest examples here : opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .-->
<%@ LANGUAGE="VBSCRIPT" %>
<html><head><t-itle>ReadAndDisplayValue_VBScript.asp</title></head>
<body>
<%
' Create EasyOPC-DA component
<!-- Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")-->
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
Dim WriteValueArguments1: Set WriteValueArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
WriteValueArguments1.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
WriteValueArguments1.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:UM1/PARAM1.CV"
WriteValueArguments1.Value = 23456
WriteValueArguments1.ValueTypeCode = 13 ' TypeCode_Single
Dim arguments(0)
Set arguments(0) = WriteValueArguments1
' Modify values of nodes
Dim results: results = Client.WriteMultipleValues(arguments)
' Display results
Dim i: For i = LBound(results) To UBound(results)
Dim WriteResult: Set WriteResult = results(i)
If WriteResult.Succeeded Then
Response.Write "Result " & i & " success"
Else
Response.Write "Result " & i & ": " & WriteResult.Exception.GetBaseException().Message
End If
Next
%>
</body>
</html>
Attachments:
Please Log in or Create an account to join the conversation.
Everything looks OK on your side, I do not quite understand why the Write does not work. It looks like that QuickOPC has determined the node's value data type as Int16, whereas the server says it is OPC UA Float. Ideally I would like to get to the bottom of it, but for now, please add following line, and retest:
WriteValueArguments1.ValueTypeCode = 13 ' TypeCode_Single
Please Log in or Create an account to join the conversation.
- Kyle.Oshima@caltrol.com
- Topic Author
- Offline
- Platinum Member
- Posts: 35
- Thank you received: 1
Attachments:
Please Log in or Create an account to join the conversation.
What you are doing looks good in principle - although in some cases, there is a necessity to explicitly define the data type for writing. We need to figure it all out.
Questions:
- Are you able to write to the very same node using UaExpert?
- Can you please send a screenshot of UaExpert when this node is selected in the "Address Space" pane - either the whole UaExpert screen, or the Attributes and References panes at least.
Thank you
Please Log in or Create an account to join the conversation.
- Kyle.Oshima@caltrol.com
- Topic Author
- Offline
- Platinum Member
- Posts: 35
- Thank you received: 1
Following QuickOPC COM programming examples, QuickOPC OPC UA object call is returning {BadTypeMismatch} error, and am having difficulty finding how proper datatyping is to be specified.
From Examples - OPC Unified Architecture - Write and specify data type Example 1 states "...If you are calling from a COM language or tool, use the WriteMultipleValues method instead..." Following Examples - OPC Unified Architecture - Write multiple values as template, re-revised "ReadAndDisplayValue_VBScript.asp" example file (see code below) returns following error message: "Result 0: OPC UA service result - {BadTypeMismatch}. The value supplied for the attribute is not of the same type as the attribute's value. + The type of the value provided to the Write service was "System.Int16". + The type of the value passed to the operation was "System.Int16". + The attribute Id used was 'Value'. + The node descriptor used was: NodeId="ns=2;s=0:UM1/PARAM1.CV". + The client method called (or event/callback invoked) was 'WriteMultiple[1]'." (see screenshot below)
Please advise.
<!--$$Header: $-->
<!-- Copyright (c) CODE Consulting and Development, s.r.o., Plzen. All rights reserved. -->
<!---->
<!--Find all latest examples here : opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Latest/examples.html .-->
<%@ LANGUAGE="VBSCRIPT" %>
<html><head><t-itle>ReadAndDisplayValue_VBScript.asp</title></head>
<body>
<%
' Create EasyOPC-DA component
<!-- Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.DataAccess.EasyDAClient")-->
Dim Client: Set Client = CreateObject("OpcLabs.EasyOpc.UA.EasyUAClient")
Dim WriteValueArguments1: Set WriteValueArguments1 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
WriteValueArguments1.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
WriteValueArguments1.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:UM1/PARAM1.CV"
WriteValueArguments1.Value = 23456
Dim arguments(0)
Set arguments(0) = WriteValueArguments1
' Modify values of nodes
Dim results: results = Client.WriteMultipleValues(arguments)
' Display results
Dim i: For i = LBound(results) To UBound(results)
Dim WriteResult: Set WriteResult = results(i)
If WriteResult.Succeeded Then
Response.Write "Result " & i & " success"
Else
Response.Write "Result " & i & ": " & WriteResult.Exception.GetBaseException().Message
End If
Next
%>
</body>
</html>
Attachments:
Please Log in or Create an account to join the conversation.
- Forum
- Discussions
- QuickOPC-UA in COM
- Reading, Writing, Subscriptions
- QuickOPC VBScript ASP example script not working, pt.3