rev 值不健康判断
This commit is contained in:
@@ -183,7 +183,8 @@ public class DeviceOpcProtocolRunable implements Runnable, DataCallback, ServerC
|
||||
|
||||
String itemId = item.getId();
|
||||
Object his = accessor_value.getValue(itemId);
|
||||
if (itemState.getQuality()==QualityTypeValue.OPC_QUALITY_GOOD && his != null) {
|
||||
if (!ObjectUtl.isEquals(itemState.getQuality(), QualityTypeValue.OPC_QUALITY_GOOD) && his != null) {
|
||||
// if (itemState.getQuality()==QualityTypeValue.OPC_QUALITY_GOOD && his != null) {
|
||||
log.warn("opc 值不健康 item: {}, 状态: {}", itemId, itemState.getQuality());
|
||||
valueAllNotNull = false;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.nl.acs.opc;
|
||||
|
||||
|
||||
import org.nl.exception.WDKException;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.Objects;
|
||||
|
||||
public class ObjectUtl {
|
||||
private ObjectUtl() {
|
||||
}
|
||||
|
||||
public static boolean isEquals(Object a, Object b) {
|
||||
if (a == null && b == null) {
|
||||
return true;
|
||||
} else if (a != null && b != null) {
|
||||
if (a.getClass().isArray()) {
|
||||
if (a instanceof boolean[]) {
|
||||
return Arrays.equals((boolean[]) ((boolean[]) a), (boolean[]) ((boolean[]) b));
|
||||
} else if (a instanceof byte[]) {
|
||||
return Arrays.equals((byte[]) ((byte[]) a), (byte[]) ((byte[]) b));
|
||||
} else if (a instanceof int[]) {
|
||||
return Arrays.equals((int[]) ((int[]) a), (int[]) ((int[]) b));
|
||||
} else if (a instanceof long[]) {
|
||||
return Arrays.equals((long[]) ((long[]) a), (long[]) ((long[]) b));
|
||||
} else if (a instanceof double[]) {
|
||||
return Arrays.equals((double[]) ((double[]) a), (double[]) ((double[]) b));
|
||||
} else if (a instanceof short[]) {
|
||||
return Arrays.equals((short[]) ((short[]) a), (short[]) ((short[]) b));
|
||||
} else if (a instanceof char[]) {
|
||||
return Arrays.equals((char[]) ((char[]) a), (char[]) ((char[]) b));
|
||||
} else if (a instanceof float[]) {
|
||||
return Arrays.equals((float[]) ((float[]) a), (float[]) ((float[]) b));
|
||||
} else if (a instanceof Object[]) {
|
||||
return Arrays.equals((Object[]) ((Object[]) a), (Object[]) ((Object[]) b));
|
||||
} else {
|
||||
throw new WDKException("未实现");
|
||||
}
|
||||
} else {
|
||||
return Objects.equals(a, b);
|
||||
}
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isTrue(Boolean boolean_) {
|
||||
return boolean_ != null && isEquals(boolean_, true);
|
||||
}
|
||||
|
||||
public static boolean isTrue(Boolean targetBoolean, boolean defaultBoolean) {
|
||||
return targetBoolean == null ? defaultBoolean : targetBoolean;
|
||||
}
|
||||
|
||||
public static boolean isFalse(Boolean boolean_) {
|
||||
return boolean_ != null && isEquals(boolean_, false);
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
public static boolean isObject(Class<?> clazz) {
|
||||
if (clazz == null) {
|
||||
return false;
|
||||
} else if (clazz.getClass().isArray()) {
|
||||
return false;
|
||||
} else {
|
||||
return Object.class.isAssignableFrom(clazz);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user