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 VBScript ASP example script not working, pt.3

More
13 Sep 2024 13:04 #13166 by support
For the fun of it, can you please modify your script - the one that does the Write but does not specify the WriteTypeCode and therefore fails - to Read the same item before writing it? Does it then do the Write without error (i.e. determines the correct type automatically), or does the error persist?

Regards

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

More
13 Sep 2024 06:45 #13164 by support
Hello.

Regarding the variables and their data types: In the end, what matters is what the server reports to the client. And, the WireShark capture is a clear proof that the server did it wrong. It is a manifestable server bug and I suggest that you report it to the server vendor and demand fixing. The fact that it had reported a better data type to UaClient is interesting, but in the end, irrelevant (it could be, for example, timing-dependent). The fact that under some circumstances the server behaves correctly does not disprove the existence of the bug.

I also maintain that my statement "...Note: None of the Write arguments you have in your script passes in the 32-bit float. For it, you would have to do e.g. "CSng(123)"..." is fully correct. In VBScript, literal 0.123456789 is *not* a 32-bit float. It is a 64-bit float. Here is a VBScript that proves this (see e.g. www.w3schools.com/asp/func_vartype.asp for VarType return values):


 
wscript.echo VarType(0.123456789) ' returns 5 (vbDouble)
wscript.echo VarType(0.123) ' returns 5 (vbDouble)
wscript.echo VarType(123) ' returns 2 (vbInteger)
wscript.echo VarType(CSng(0.123456789)) ' returns 4 (vbSingle)

 


For setting UAWriteValueArguments.ValueTypeCode, use the numeric values from learn.microsoft.com/en-us/dotnet/api/system.typecode . For almost all variable data types you listed, the correspondence is fairly obvious. I think the enumeration will be Int32, but if that does not work, please come back to me and we will sort it out.

Regards

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

More
13 Sep 2024 02:00 #13163 by Kyle.Oshima@caltrol.com
Your statement "...unfortunately you have mislead me. In your original report, and in the screenshots from UaExpert I asked you for, you indicated that you work with variables like 0:UM1/PARAM1.CV. And the server returns their data type as Float. However, in reality, the "problem" happens with different variables. They are like 0:EM1/PARAM1.CV (notice the letter E instead of U)..." is not accurate...

Granted, yes the highlighted "UM1" and "EM1" elements are different control modules, but the relevant variables on the parent control modules are the "PARAM1.CV" elements which are both float data type as discussed throughout this chain and shown by UaExpert (see screenshot below)



In order to provide you more test info at once, last test case in reply #13145 did write aforementioned PARAM1 float data type plus six added PARAM2-7 for six additional different data type variables that could be defined (QuickOPC documentation does note is more efficient to write multiple values at once with WriteMultipleValues() call rather than iteratively writing one value at time) -- was easier/faster to define the additional PARAMs on the EM1 module rather than the UM1 module; my apologies if that caused you confusion, assumed the inline comments in the code pasted and the screenshot of the seven PARAM1-7 {BadTypeMismatch} errors returned in reply #13145 would be understood.

Also, your statement "...Note: None of the Write arguments you have in your script passes in the 32-bit float. For it, you would have to do e.g. "CSng(123)"..." also is not accurate...

The first WriteValueArguments1 object does in fact write to "PARAM1" which as stated above is defined as float data type, and is trying to write 0.123456789 which you state in reply #13011 "...QuickOPC is supposed to do automatically..."

That said, if for whatever reason QuickOPC cannot write indefinite decimal values without explicitly passing appropriate target data type, in the long run that may not necessarily be show-stopper -- may be able to redesign ASP front-end to explicitly pass target data types, which if available on the ASP front-end may have separate benefit of facilitating added form entry validation otherwise difficult to accomplish.

Assuming so, what are the appropriate ValueTypeCode values needed for each of the ten possible different data type variables that could be defined noted in reply #13141 (PARAM1-7 data types outlined in reply #13145 plus three unsigned integer PARAM8-10 data type variables added) -- see screenshot below of data types shown by UaExpert
variable......data type
  • PARAM1 --> floating point
  • PARAM2 --> boolean (0 or 1)
  • PARAM3 --> discrete (integer 0 to 255)
  • PARAM4 --> 8-bit signed integer
  • PARAM5 --> 16-bit signed integer
  • PARAM6 --> 32-bit signed integer
  • PARAM7 --> enumeration (ordinal 0 to 255)
  • PARAM8 --> 8-bit unsigned integer
  • PARAM9 --> 16-bit unsigned integer
  • PARAM10 --> 32-bit unsigned integer


  • Attachments:

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

    More
    07 Sep 2024 07:11 - 08 Sep 2024 05:50 #13148 by support
    Hello.
    Thank you for the Wireshark capture and the script.

    It is clear what is happening. We could have saved ourselves some work, but unfortunately you have mislead me. In your original report, and in the screenshots from UaExpert I asked you for, you indicated that you work with variables like 0:UM1/PARAM1.CV. And the server returns their data type as Float.

    However, in reality, the "problem" happens with different variables. They are like 0:EM1/PARAM1.CV (notice the letter E instead of U). And, as apparent from the WireShark capture, the server returns their data type as BaseDataType (i=24); the screenshots of the decoded request/response for the data type are attached.

    BaseDataType means "any type". But as we have seen, in reality, the server only accepts Floats for them. So the server is letting the clients to somehow magically guess the proper data type. Of course this is not something QuickOPC can do for you. And that's why, with these variable, you either need to 1) already pass in the value in the data type the server expects, or 2) explicitly specify the ValueType or ValueTypeCode.



    Regards

    Note: None of the Write arguments you have in your script passes in the 32-bit float. For it, you would have to do e.g. "CSng(123)".
    Attachments:
    Last edit: 08 Sep 2024 05:50 by support.

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

    More
    06 Sep 2024 08:00 #13145 by Kyle.Oshima@caltrol.com
    See attached WireShark capture for re-revised "ReadAndDisplayValue_VBScript.asp" example file without explicitly specifying TypeCode and writing 7 values of 7 datatypes noted in reply #13141 (see code below) and returning {BadTypeMismatch} error -- see screenshot below

    <!--$$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:EM1/PARAM1.CV" 'float point datatype
    WriteValueArguments1.Value = 0.123456789

    Dim WriteValueArguments2: Set WriteValueArguments2 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
    WriteValueArguments2.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
    WriteValueArguments2.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:EM1/PARAM2.CV" 'boolean datatype
    WriteValueArguments2.Value = 1

    Dim WriteValueArguments3: Set WriteValueArguments3 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
    WriteValueArguments3.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
    WriteValueArguments3.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:EM1/PARAM3.CV" 'discrete datatype
    WriteValueArguments3.Value = 255

    Dim WriteValueArguments4: Set WriteValueArguments4 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
    WriteValueArguments4.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
    WriteValueArguments4.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:EM1/PARAM4.CV" '8-bit signed integer
    WriteValueArguments4.Value = 1234567890

    Dim WriteValueArguments5: Set WriteValueArguments5 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
    WriteValueArguments5.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
    WriteValueArguments5.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:EM1/PARAM5.CV" '16-bit signed integer
    WriteValueArguments5.Value = 1234567890

    Dim WriteValueArguments6: Set WriteValueArguments6 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
    WriteValueArguments6.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
    WriteValueArguments6.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:EM1/PARAM6.CV" '32-bit signed integer
    WriteValueArguments6.Value = 12345678901234567890

    Dim WriteValueArguments7: Set WriteValueArguments7 = CreateObject("OpcLabs.EasyOpc.UA.OperationModel.UAWriteValueArguments")
    WriteValueArguments7.EndpointDescriptor.UrlString = "opc.tcp://ILDDEV-PROPLUS:9409/DvOpcUaServer"
    WriteValueArguments7.NodeDescriptor.NodeId.ExpandedText = "ns=2;s=0:EM1/PARAM7.CV" 'enumeration datatype
    WriteValueArguments7.Value = 50

    Dim arguments(6)
    Set arguments(0) = WriteValueArguments1
    Set arguments(1) = WriteValueArguments2
    Set arguments(2) = WriteValueArguments3
    Set arguments(3) = WriteValueArguments4
    Set arguments(4) = WriteValueArguments5
    Set arguments(5) = WriteValueArguments6
    Set arguments(6) = WriteValueArguments7

    ' 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>




    File Attachment:

    File Name: ReadAndDis...2.pcapng
    File Size:59 KB
    Attachments:

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

    More
    06 Sep 2024 04:55 - 06 Sep 2024 04:56 #13142 by support
    Hello.

    I did not need the Wireshark capture for the problem where you thought the precision was lost. It was pretty clear that the node's data type is Float and 6 decimal digits is the max you can get out of it.

    But I needed the Wireshark capture for the problem where the Write would fail with BadTypeMismatch unless the type was explicitly set in the script. So if you want to further troubleshoot this, I still need the Wireshark capture of it.

    Regards
    Last edit: 06 Sep 2024 04:56 by support.

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

    More
    06 Sep 2024 03:00 #13141 by Kyle.Oshima@caltrol.com
    Apologies for delay replying...been awaiting open support call response from DCS vendor...

    re: question of decimal precision starting from reply #13010 based on DCS vendor feedback appears there is subtle difference in their interpretation of single-precision floating point format differing from IEEE Std 754 specification affecting display of floating points. Bottom line, WireShark analysis no longer appears to be needed.

    That said, I believe there is still open question from reply #13000 as to "...although in some cases, there is a necessity to explicitly define the data type for writing. We need to figure it all out."

    OPC UA target nodeID datatypes could be any of the following: 32-bit floating point; boolean (0 or 1); discrete (integer 0 to 255); 8-, 16-, or 32-bit signed or unsigned integer; enumeration (integer 0 to 255)

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

    More
    21 Aug 2024 13:37 #13038 by support
    Hello,

    the WireShark capture you have sent is for a successful test with the revised code. That is not what I asked for. I asked for - quote: "... WireShark capture when the ASP script that exhibits the problem is run".

    Regards

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

    More
    21 Aug 2024 08:00 #13036 by Kyle.Oshima@caltrol.com
    re: I think we can start with doing just WireShark capture when the ASP script that exhibits the problem is run. Can you please do that? -- see attached Wireshark capture for re-revised "ReadAndDisplayValue_VBScript.asp" example file from reply #13012

    File Attachment:

    File Name: ReadAndDis...p.pcapng
    File Size:138 KB
    Attachments:

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

    More
    16 Aug 2024 09:17 #13024 by support
    Thank you. Unfortunately, it works well from OpcCmd, so we cannot use the easier troubleshooting path.

    I think we can start with doing just WireShark capture when the ASP script that exhibits the problem is run. Can you please do that? Useful info:

    - Analyzing OPC UA Communications with Wireshark: opcconnect.opcfoundation.org/2017/02/analyzing-opc-ua-communications-with-wireshark/
    - OPC UA & Wireshark: www.prosysopc.com/blog/opc-ua-wireshark/

    Regards

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

    Moderators: support
    Time to create page: 0.097 seconds