Using parfeval to read values from OPC-UA server?
Show older comments
Hi!
I am trying to read data from an OPC-UA server in background using parfeval. I have a local OPC-UA simulation server running and the connection and reading values in the main thread works nicely. However, upon executing the readValue function in backgroundPool using parfeval with the needed input arguments (i.e. a connected uaClient and list of nodes), the FevalFuture results in an error "OPC UA Client must be connected to perform this operation".
You can find minimum working code example below:
uaClient = opcua('localhost',53530); % Local OPC-UA simulation server
connect(uaClient);
namespace = browseNamespace(uaClient); % Browse for OPC-UA server namespace
nodes = getAllChildren(namespace); % Get a list of data nodes
values = readValue(nodes); % Test reading values from the data nodes using readValue --> Works well
% Test reading the values in background using parfeval:
readFuture = parfeval(backgroundPool, @readValue, 1, uaClient, nodes) % --> Error, "OPC UA Client must be connected to perform this operation"
It seems that the connection to OPC-UA server is not maintained when providing the uaClient as an input to parfeval. Is there a way to solve this?
Accepted Answer
More Answers (0)
Categories
Find more on Unified Architecture in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!