How to write values to arrays with OPC UA client?
Hi,
I'm trying to make OPC UA client to write a value in an array in OPC UA server, with no success. Below the test code I'm using. For non-array values it works fine
Code:
QString nodename
= "ns=6;s=::ExValues:sensors.speed.sensorArray[0]";
//QString nodename = "ns=6;s=::ExValues:sensors.speed.sensorAverage"; //for non-array values it works fine
const auto type
= QVariant::nameToType(nodeType.
toLatin1().
constData());
qCritical() << "Invalid node type";
return;
}
qDebug() << value << " with nodeValue: " << nodeValue;
if(!value.convert(type)) {
qCritical() << "Value cannot be presented as given type " << nodeType;
return;
}
const auto node = std::unique_ptr<QOpcUaNode>(mClient->node(nodename));
if(!node) {
qCritical() << "No such node";
return;
}
QObject::connect(node.
get(),
&QOpcUaNode
::attributeWritten,
[&loop
](QOpcUa
::NodeAttributes) { loop.quit();
});
node->writeValueAttribute(value);
loop.exec();
I have also tried to make nodeValue as a QStringList or QOpcUaMultiDimensionalArray, and used different combinations of QVariant and OPC UA node types, but the values just won't change.
Could anyone help me?
I'm using Qt5.15 MSVC2019 64bit
with Qt OPC UA Open62541 Plugin
OS: Windows 10