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.

typecodes: array of string

More
16 May 2024 16:08 #12796 by support
Replied by support on topic typecodes: array of string
Thank you too - I am glad this works!

Best regards

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

More
16 May 2024 15:13 #12795 by ulix86
Replied by ulix86 on topic typecodes: array of string
Yestarday I tried something similar with CallArguments1.SetInputFullTypeNames but I was far from your solution.

Anyway...it works!!

You solved a big problem for me.
Thank you, I really appreciated your help.
The following user(s) said Thank You: support

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

More
16 May 2024 11:54 #12793 by support
Replied by support on topic typecodes: array of string
Hello.
I know what is happening. I will try to navigate you to the right solution (which is somewhat complicated), because we do not have a ready-made example for that.

The type for these 3 arguments needs to be specified as array of strings, but with TypeCode-s, only scalars can be specified. As method overloads are not available in COM, we do not have a method overload to directly pass in what you need. But it still can be done.

You need to:

1. Use CallMultipleMethods method instead (even though you are calling just one method - you will therefore specify just one, this is fine). For a VB6 example with CallMultipleMethods, see opclabs.doc-that.com/files/onlinedocs/OPCLabs-OpcStudio/Late...Call%20multiple%20methods.html .

2. Instead of using array of TypeCode (variable typeCodes1(10) in the example), using will use an array of strings, specifying the full .NET types. It will look something like this:
    Dim typeFullNames(13)
 
    typeFullNames(0) = "System.String": inputs(0) = "LAV1" 'nome lavoro
    typeFullNames(1) = "System.String": inputs(1) = "LAVORO 1" 'descrizione lavoro
    typeFullNames(2) = "System.String": inputs(2) = "CLIENTE UNO" 'ragione Sociale cliente
    typeFullNames(3) = "System.String": inputs(3) = "forchetta_5" 'production dataset name: !!!deve essere lo stesso nome del programma sulla pressa
    typeFullNames(4) = "System.String": inputs(4) = "FORCHETTA" 'ProductionDatasetDescription
    typeFullNames(5) = "System.String[]": inputs(5) = materiale 'Materiale
    typeFullNames(6) = "System.String[]": inputs(6) = articolo 'Articolo
    typeFullNames(7) = "System.String[]": inputs(7) = descart 'descrizione articolo
    typeFullNames(8) = "System.Boolean": inputs(8) = False 'continua a lavoro conluso
    typeFullNames(9) = "System.UInt64": inputs(9) = 10000 'pezzi da fare
    typeFullNames(10) = "System.UInt64": inputs(10) = 10000 'box pezzi da fare
    typeFullNames(11) = "System.Double": inputs(11) = 0 'expected cycle time
    typeFullNames(12) = "System.String": inputs(12) = "Mould1" 'MouldID: Codice Stampo
    typeFullNames(13) = "System.UInt32": inputs(13) = 8 'num.cavities

3. You will remove the type codes from the example, and modify the example to use
CallArguments1.SetInputFullTypeNames typeFullNames
to specify the types before calling the method

Regards

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

More
16 May 2024 11:09 #12792 by ulix86
Replied by ulix86 on topic typecodes: array of string
Thank you for your quick response.

I try to change the code with your tips but unfortunately I recive this error now:
*** Failure: mscorlib: L'oggetto deve implementare IConvertible.
 
+ Attempting to change an object of type "System.String[]" to type "System.String".
+ The client method called was 'CallMultipleMethods'.

it seems that the code stops before write. I attached the wireshark readresponse.
(it seems as if it doesn't accept typecode 18 for string arrays)

Any more ideas?
Attachments:

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

More
16 May 2024 10:25 #12791 by support
Replied by support on topic typecodes: array of string
Hello.

This may require more changes, but if the right type for arguments 5,6,7 is indeed an array of strings, then when are you doing this?
    typeCodes(5) = 18: inputs(5) = materiale(0) 'Materiale
    typeCodes(6) = 18: inputs(6) = articolo(0) 'Articolo
    typeCodes(7) = 18: inputs(7) = descart(0) 'descrizione articolo
It seems to me that it should be
    typeCodes(5) = 18: inputs(5) = materiale 'Materiale
    typeCodes(6) = 18: inputs(6) = articolo 'Articolo
    typeCodes(7) = 18: inputs(7) = descart 'descrizione articolo

I am not saying this is the whole problem, but it is at least a part of the problem. If changing it does not help, please capture the Wireshark with this new code again, so that I can closer to the cause.

Best regards

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

More
16 May 2024 10:05 #12790 by ulix86
Hi,
I have a problem with a CallMethod in OpcUA COM (Visual Basic 6.0)
When I call the method I recive the error below (BadInvalidArgument).
*** Failure: OpcLabs.EasyOpcUA: OPC-UA service result - An error specific to OPC-UA service occurred (status code: BadInvalidArgument). Details follow.
---- SERVICE RESULT ----
Status Code: {BadInvalidArgument} = 0x80AB0000 (2158690304)
 
+ The client method called was 'CallMultipleMethods'.

I checked with WireShark the difference between UaExpert method call (it works properly) and my call in VB6 (not working) and I found a difference in input(5), input(6), input(7) . (code below)
In the UAExpert method they are 3 Array of String.
In my VB6 method I assigned 3 String (Typecode=18).

I guess that's the problem. Do you know the correct TypeCode of an array of String?

Thank you.

(I also attached the correct wireshark call in UaExpert)

OutputText = ""
 
    Dim inputs(13)
    Dim typeCodes(13)
 
 
    Dim materiale(0) As String
    Dim articolo(0) As String
    Dim descart(0) As String
    materiale(0) = "m1"
    articolo(0) = "m2"
    descart(0) = "m3"
 
    typeCodes(0) = 18: inputs(0) = "LAV1" 'nome lavoro
    typeCodes(1) = 18: inputs(1) = "LAVORO 1" 'descrizione lavoro
    typeCodes(2) = 18: inputs(2) = "CLIENTE UNO" 'ragione Sociale cliente
    typeCodes(3) = 18: inputs(3) = "forchetta_5" 'production dataset name: !!!deve essere lo stesso nome del programma sulla pressa
    typeCodes(4) = 18: inputs(4) = "FORCHETTA" 'ProductionDatasetDescription
    typeCodes(5) = 18: inputs(5) = materiale(0) 'Materiale
    typeCodes(6) = 18: inputs(6) = articolo(0) 'Articolo
    typeCodes(7) = 18: inputs(7) = descart(0) 'descrizione articolo
    typeCodes(8) = 3: inputs(8) = False 'continua a lavoro conluso
    typeCodes(9) = 12: inputs(9) = 10000 'pezzi da fare
    typeCodes(10) = 12: inputs(10) = 10000 'box pezzi da fare
    typeCodes(11) = 14: inputs(11) = 0 'expected cycle time
    typeCodes(12) = 18: inputs(12) = "Mould1" 'MouldID: Codice Stampo
    typeCodes(13) = 10: inputs(13) = 8 'num.cavities
 
 
    'typeCodes1(0) = 3    ' TypeCode.Boolean
    'typeCodes1(1) = 5    ' TypeCode.SByte
    'typeCodes1(2) = 6    ' TypeCode.Byte
    'typeCodes1(3) = 7    ' TypeCode.Int16
    'typeCodes1(4) = 8    ' TypeCode.UInt16
    'typeCodes1(5) = 9    ' TypeCode.Int32
    'typeCodes1(6) = 10   ' TypeCode.UInt32
    'typeCodes1(7) = 11   ' TypeCode.Int64
    'typeCodes1(8) = 12   ' TypeCode.UInt64
    'typeCodes1(9) = 13   ' TypeCode.Single
    'typeCodes1(10) = 14  ' TypeCode.Double
    'typeCodes1(11) = 18  ' TypeCode.String
 
 
' Instantiate the client object
    Dim Client As New EasyUAClient
 
    ' Perform the operation
    On Error Resume Next
    Dim outputs As Variant
    outputs = Client.CallMethod( _
        Server, _
        "ns=8;i=5015", _
        "ns=8;i=7006", _
        inputs, _
        typeCodes)
    If Err.Number <> 0 Then
        OutputText = OutputText & "*** Failure: " & Err.Source & ": " & Err.Description & vbCrLf
        Exit Sub
    End If
    On Error GoTo 0
 
    ' Display results
    Dim i: For i = LBound(outputs) To UBound(outputs)
        On Error Resume Next
        OutputText = OutputText & "outputs(" & i & "): " & outputs(i) & vbCrLf
        If Err <> 0 Then OutputText = OutputText & "*** Error" & vbCrLf ' occurrs with types not recognized by VB6
        On Error GoTo 0
    Next
Attachments:

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

Moderators: support
Time to create page: 0.100 seconds