rev:opc读取float类型防呆优化

This commit is contained in:
miguannan
2026-07-31 08:58:40 +07:00
parent 1a97e4425c
commit 5d2ba4d87f

View File

@@ -158,7 +158,14 @@ public interface OpcDeviceDriver extends DeviceDriver {
* @return * @return
*/ */
default Float getFloatValue(String protocol) { default Float getFloatValue(String protocol) {
return (Float) this.getOpcValueAccessor().getValue(this.getItem(protocol)); Object value = this.getOpcValueAccessor().getValue(this.getItem(protocol));
if (ObjectUtil.isEmpty(value)) {
return null;
}
if (value instanceof Number) {
return ((Number) value).floatValue();
}
return Float.valueOf(value.toString());
} }
/** /**