rev:opc读取float类型防呆优化
This commit is contained in:
@@ -158,7 +158,14 @@ public interface OpcDeviceDriver extends DeviceDriver {
|
||||
* @return
|
||||
*/
|
||||
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());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user