增加UI配置项
This commit is contained in:
@@ -196,22 +196,25 @@ bool OpcUaManager::writeNodeValue(const QString &nodeId,
|
||||
int maxRetry /*= 3*/,
|
||||
int retryIntervalMs /*= 200*/)
|
||||
{
|
||||
QString mNodeID = nodeId;
|
||||
if(!mNodeID.contains("ns=6;s=::AsGlobalPV:"))
|
||||
mNodeID = "ns=6;s=::AsGlobalPV:"+mNodeID;
|
||||
if (!mClient || mClient->state() != QOpcUaClient::Connected) {
|
||||
qWarning().noquote() << "[OPC] 客户端未连接,写入" << nodeId << "失败";
|
||||
qWarning().noquote() << "[OPC] 客户端未连接,写入" << mNodeID << "失败";
|
||||
return false;
|
||||
}
|
||||
|
||||
QOpcUaNode *node = mClient->node(nodeId);
|
||||
QOpcUaNode *node = mClient->node(mNodeID);
|
||||
if (!node) {
|
||||
qWarning().noquote() << "[OPC] 无法写入节点:" << nodeId;
|
||||
qWarning().noquote() << "[OPC] 无法写入节点:" << mNodeID;
|
||||
return false;
|
||||
}
|
||||
|
||||
for (int attempt = 1; attempt <= maxRetry; ++attempt) {
|
||||
/* ---------- 1. 先读当前值 ---------- */
|
||||
QVariant cur = gOPC_NodeValue[nodeId];
|
||||
QVariant cur = gOPC_NodeValue[mNodeID];
|
||||
if (!cur.isValid()) {
|
||||
//qWarning().noquote() << "读到无效值:" << nodeId<<gOPC_NodeValue[nodeId];
|
||||
//qWarning().noquote() << "读到无效值:" << mNodeID<<gOPC_NodeValue[mNodeID];
|
||||
}
|
||||
|
||||
/* ---------- 2. 类型转换 ---------- */
|
||||
@@ -247,12 +250,12 @@ bool OpcUaManager::writeNodeValue(const QString &nodeId,
|
||||
|
||||
/* ---------- 4. 失败日志 & 重试 ---------- */
|
||||
// qWarning().noquote() << "[OPC] 第" << attempt << "/" << maxRetry
|
||||
// << "次写入失败:" << nodeId << " 等待重试 ...";
|
||||
// << "次写入失败:" << mNodeID << " 等待重试 ...";
|
||||
if (attempt < maxRetry)
|
||||
QThread::msleep(retryIntervalMs);
|
||||
}
|
||||
|
||||
qCritical().noquote() << "[OPC] 最终写入失败:" << nodeId;
|
||||
qCritical().noquote() << "[OPC] 最终写入失败:" << mNodeID;
|
||||
return false;
|
||||
}
|
||||
QOpcUaClient::ClientState OpcUaManager::connectionState() const
|
||||
|
||||
Reference in New Issue
Block a user