OPC UA

More
2 years 11 months ago #285928 by bkt
Replied by bkt on topic OPC UA
Hey ...I integrate with succes opcua server to my qt c++ code .... and linuxcnc and opcua server start at same time ... like classicladder do ..... not so difficult you can integrate qtopcuaserver.h / .cpp to the code .... I suspect was quite easy to do with python or qtvcp too .... plus you can chose what pin can shared over opcua and what not. That is more safe than shared complete pin of lcnc to lan over opcua.

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

More
2 years 11 months ago - 2 years 11 months ago #286082 by TheRoslyak
Replied by TheRoslyak on topic OPC UA
I don't quite understand what is ultimately needed. And where to find qtopcuaserver.h. If the goal is to reduce the number of variables in the OPC UA server, I had an option. Output only Signals. (There are fewer of them, and you write the name yourself). I thought this could be done with some argument when launching opcuaserver, but it's easier to just comment out the lines.
Code:
/*   UA_NodeId pinsFolderId = createFolder("Pins");     hal_pin_t *currentPin;           for (currentPin = SHMPTR(hal_data->pin_list_ptr);                currentPin;                currentPin = SHMPTR(currentPin->next_ptr)) {         addVariableWithDataSource(currentPin->name,                                   currentPin->type,                                   currentPin->signal ? static_cast<void*>;(SHMPTR(SHMPTR(currentPin->signal)->data_ptr))                                                      : static_cast<void*>;(&;(currentPin->dummysig)),                                   pinsFolderId);     }*/     UA_NodeId signalsFolderId = createFolder("Signals");     hal_sig_t *currentSig;           for (currentSig = SHMPTR(hal_data->sig_list_ptr);                currentSig; currentSig = SHMPTR(currentSig->next_ptr)) {     addVariableWithDataSource(currentSig->name,                               currentSig->type,                        SHMPTR(currentSig->data_ptr),                               signalsFolderId);     }    /* UA_NodeId parametersFolderId = createFolder("Parameters");     hal_param_t *currentParam;             for (currentParam = SHMPTR(hal_data->param_list_ptr);                  currentParam;                  currentParam = SHMPTR(currentParam->next_ptr)) {      addVariableWithDataSource(currentParam->name,                                currentParam->type,                         SHMPTR(currentParam->data_ptr),                                parametersFolderId);     }*/
Last edit: 2 years 11 months ago by TheRoslyak.

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

More
2 years 11 months ago - 2 years 11 months ago #286223 by TheRoslyak
Replied by TheRoslyak on topic OPC UA
I'm currently developing an OPC UA client. It will work on the following principle. There will be a YAML file in which you'll need to specify the connection parameters to the OPC UA server you want to connect to. There will be an option to create separate threads in case you don't want to use the servo base traj threads. This is necessary to set the update interval you want. You will need to write a list with the name of the variable, its type, and nodeId. And accordingly, in the HAL environment, you will have a variable that retrieves values from the OPC UA server. If everything works as I plan, then by the same principle, a Modbus client can be made. It seems someone has done something similar, but I think I can do it better :)
Code:
opcua:   serverURL: "opc.tcp://localhost:4840"   securityPolicy: "None"   securityMode: "None" variables:   - name: "variable1"     type: "float"     nodeId: "ns=1;s=J1:pos-fb"     - name: "variable2"     type: "float"     nodeId: "ns=1;s=J2:pos-fb" threads:    - name: "OpcUaClient-thread"      threadPeriod: 1000000      fp: 1
Last edit: 2 years 11 months ago by TheRoslyak.
The following user(s) said Thank You: Aciera

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

More
2 years 11 months ago #286396 by TheRoslyak
Replied by TheRoslyak on topic OPC UA
In general, I've succeeded. Now it's possible to connect to any OPC UA server through HAL. Unfortunately, I can't get it to go faster than 50 milliseconds. That's a feature of regular OPC UA. (Or maybe it's blocked by the library). It can be faster if it's connected to OPC UA TSN. For now, I'll post a video for demonstration. Later, I'll make it publicly available after tidying up the code. So, what's happening in the video: I start linuxcnc, launch my OPC UA server, then add the OpcUaClient component. I attach the value of the stream. The speed is set to 50 milliseconds. It doesn't work any faster. The same principle can be applied to Modbus. Is there anything similar? But quite possibly mine will work better)) Just in case, I'll also post another video for those who don't understand what OPC UA is.





 
The following user(s) said Thank You: panming

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

More
2 years 11 months ago #286645 by bkt
Replied by bkt on topic OPC UA
qtopcuaserver.h is on qtopcua/test folder .... is an example...

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

More
2 years 10 months ago #287181 by TheRoslyak
Replied by TheRoslyak on topic OPC UA
So, I'm releasing a more or less working version. The hardest part I had to deal with was making the logs and reconnect work. There is one drawback that I don't know how to deal with. When the connection is lost, a latency error occurs. After the connection is restored, everything returns to normal. Since everything operates in a separate thread, it seems to have no effect on all other functionalities.
github.com/TheRoslyak/OpcUaHalClient
The following user(s) said Thank You: Aciera

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

Time to create page: 0.099 seconds
Powered by Kunena Forum