OPC UA Server

Hi all,

I wonder have anyone of you connect VC to a custom-made OPC UA Server. I’ve tried to connect it with a dummy OPC UA server but the connection failed. I made sure the server is up and running, and the server can be connected using UaExpert. Is this approach a dead end or anyone has some experiences with it?

Thank you for your time and I am looking forward to hearing your idea.

Is it a secure connection?

Regards
Feature

The OPC UA client in Connectivity feature of VC requires the connected server to be standard-compliant. This includes that it has to support certain basic services and must have certain valid data model for the “Server” object.

Some OPC UA server libraries will just create and “empty” server by default, which is not standard compliant and thus connecting to it is not supported.

Check the VC application log file for any more detailed errors, or ask VC customer support for more info.

Hi,

Thank you very much for your input. I wonder if VC has a model OPC UA server or any documentations or templates lying around? It would really helpful for me and my learning curve.

BR,
Duc Pham

You can get full data model and address space specifications from the OPC Foundation’s GitHub:

Does your OPC UA server library have capability to load those NodesSet2 files?

The Schema folder seems to contain the full OPC UA standardized model and the others are additions by different companion specifications. The full model is very large and VC doesn’t make use of anything in the Types hierarchy, for example.

I think the free edition of Prosys simulation server has the full model which you can then browse with the Server’s GUI directly to understand it better.

Hello
I have been looking trough the thread that you posted as well as the git pages.
Being a novice in this area it is hard for me to really see what a server needs to have in terms of lines of code to be standard-compliant. The link to OPC-foundation git contains a lot of information and before i stat reading trough this im wondering:
Do you know anyone that more in detail can define what is needed for the server to be standard-compliant?

Im using this library in github where i rewrite the code to fit my purpose and has worked pretty well for me thus far.

What would be missing to make this example standard compliant?

// David

Hi @Dauken

The connection test may fail in VC but you can still connect to your server.

Here’s a simple example, tested and works on Python3

import time
from opcua import ua, Server

if __name__ == "__main__":
    # setup server
    server = Server()
    server.set_endpoint("opc.tcp://localhost:4840")

    '''
    server.set_security_policy([
      ua.SecurityPolicyType.NoSecurity,
      ua.SecurityPolicyType.Basic256Sha256_SignAndEncrypt,
      ua.SecurityPolicyType.Basic256Sha256_Sign
    ])
    '''

    # setup our own namespace, not really necessary but should as spec
    uri = "http://localhost"
    idx = server.register_namespace(uri)

    # get Objects node, this is where we should put our nodes
    objects = server.get_objects_node()
    print(objects)

    # populating our address space
    myobj = objects.add_object(idx, "MyObject")
    myvar = myobj.add_variable(idx, "MyVariable", 6.7)
    myvar.set_writable()    # Set MyVariable to be writable by clients

    print(server.get_namespace_array())

    # starting!
    server.start()

    try:
        # count = 0
        # while True:
        #     time.sleep(1)
        #     count += 0.1
        #     myvar.set_value(count)
        input("Press Enter to shutdown server...\n")
    finally:
        #close connection, remove subcsriptions, etc
        server.stop()

Shows up in VC like this after connecting:
image

1 Like

Thanks @jouha

I tested the example you provided, and I had a few problems. Luckily I managed to overcome these issues, and the connection to VC works!

To get the connection working, I had to do the following:

  1. Change the server port to 4841 in the script and in the connection plugin
  2. Cannot test the connection. It always fails
  3. Click the Apply button in the bottom right corner despite the test failing
  4. Activate the connection
  5. Refresh the server variable list


Thanks a lot!

Thanks for all the help guys!
So in conclusion, the only thing that i needed to do was to comment away
‘’’

server.set_security_policy([

  ua.SecurityPolicyType.NoSecurity,

  ua.SecurityPolicyType.Basic256Sha256_SignAndEncrypt,

  ua.SecurityPolicyType.Basic256Sha256_Sign

])

'''

just out of curiosity, is it possible to use uamethods in VC somehow ? i have yet to come up with any examples on exactly how to construct an experiment where uamethods are used in conjunction with VC but i have some ideas.

I will probably start a new thread if i run into problems here anyway

//David

uamethods cannot be used with the OPC UA connection plugin in VC. for example, it does not have the functionality that UAExpert has to execute methods.