Browse Source

rev 更新信号写入

master
汪菘 2 months ago
parent
commit
09f0cc17bc
  1. 8
      acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java

8
acs/nladmin-system/nlsso-server/src/main/java/org/nl/acs/utils/ReadUtil.java

@ -110,16 +110,16 @@ public class ReadUtil {
NodeId nodeId = new NodeId(2, key);
//创建数据对象,此处的数据对象一定要定义类型,不然会出现类型错误,导致无法写入
DataValue nowValue = null;
if(NumberUtil.isNumber(String.valueOf(o))){
nowValue = new DataValue(new Variant(Integer.valueOf(o.toString())), null, null);
} else if (NumberUtil.isNumber(String.valueOf(o))) {
if(NumberUtil.isDouble(String.valueOf(o))){
nowValue = new DataValue(new Variant(Double.valueOf(o.toString())), null, null);
} else if (NumberUtil.isNumber(String.valueOf(o))) {
nowValue = new DataValue(new Variant(Integer.valueOf(o.toString())), null, null);
} else {
nowValue = new DataValue(new Variant(String.valueOf(o)), null, null);
}
//写入节点数据
StatusCode statusCode = client.writeValue(nodeId, nowValue).join();
System.out.println("结果:" + statusCode.isGood());
System.out.println( key +" 信号写入结果:" + statusCode.isGood());
}
client.disconnect();
}catch (Exception e) {

Loading…
Cancel
Save