Search code examples
scalaopc-uaopcmilo

Milo OPC UA UaException: status=Bad_UnexpectedError


I am trying to call a method "Multiply" from a FolderType that has the method "Multiply" and multiply e.g. 2 * 5 and get the result.

But I get the following error message when executing the program:

UaException: status=Bad_UnexpectedError, message=java.util.concurrent.ExecutionException: org.eclipse.milo.opcua.stack.core.UaSerializationException: unknown builtin type: -1

I have absolutely no idea why.

This is my code

val loadedConfig   : Config        = ConfigFactory.parseFile ( new File ( path ) )
val namespaceIndex : Int           = loadedConfig.getInt ( "namespaceIndex" )
val nodeID         : String        = loadedConfig.getString ( "nodeId" )
val readMethodId   : QualifiedName = new QualifiedName ( QualifiedNameIndex, Read )
val Read           : String        = loadedConfig.getString ( "readMethodId" )

val client : Option [ OpcUaClient ] = new OpcConnector ( config = loadedConfig ).createOpcClients ( )

read ( nodeId = nodeId,
       readMethodId = readMethodId,
       multiply = 5 )

private def read ( nodeId : NodeId, readMethodId : QualifiedName, multiply : Int ) : Unit = {


  val method : UaMethod = client
    .get
    .getAddressSpace.getObjectNode ( nodeId )
    .getMethod ( readMethodId )

  val inputs : Array [ Variant ] = Array ( new Variant ( multiply , 2 ) )

  val outputs : AnyRef = method.call ( inputs ) 

  println ( "result: " + outputs )
}
            

Both the OPC address and the node are correct.

Milo OPC 0.6.8


Solution

  • val inputs : Array [ Variant ] = Array ( new Variant ( multiply , 2 ) )

    What is this line supposed to be doing? There is no Variant constructor that takes 2 args.