diff --git a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/Utilities.java b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/Utilities.java
index 5819977cc2..a52d791440 100644
--- a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/Utilities.java
+++ b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/Utilities.java
@@ -31,7 +31,6 @@
import org.epics.util.array.ArrayULong;
import org.epics.util.array.ArrayUShort;
import org.epics.util.array.ListBoolean;
-import org.epics.util.array.ListInteger;
import org.epics.util.array.ListLong;
import org.epics.util.array.ListNumber;
import org.epics.util.array.ListUInteger;
@@ -100,13 +99,11 @@
import java.util.stream.Collectors;
/**
- *
* Utilities
provides common methods to transform between different data types used by the save and
* restore. This class also provides methods to transform the timestamps into human readable formats. All methods are
* thread safe.
*
* @author Jaka Bobnar
- *
*/
public final class Utilities {
@@ -117,12 +114,12 @@ public final class Utilities {
* (-1). This only applies to scalar values. In case of array values the comparison can only result in 0 or 1.
*
* @author Jaka Bobnar
- *
*/
public static class VTypeComparison {
private final String string;
private final int valuesEqual;
private final boolean withinThreshold;
+ private double absoluteDelta = 0.0;
VTypeComparison(String string, int equal, boolean withinThreshold) {
this.string = string;
@@ -130,6 +127,13 @@ public static class VTypeComparison {
this.withinThreshold = withinThreshold;
}
+ VTypeComparison(String string, int equal, boolean withinThreshold, double absoluteDelta) {
+ this.string = string;
+ this.valuesEqual = equal;
+ this.withinThreshold = withinThreshold;
+ this.absoluteDelta = absoluteDelta;
+ }
+
/**
* Returns the string representation of the comparison result.
*
@@ -156,9 +160,15 @@ public int getValuesEqual() {
public boolean isWithinThreshold() {
return withinThreshold;
}
+
+ public double getAbsoluteDelta() {
+ return absoluteDelta;
+ }
}
- /** The character code for the greek delta letter */
+ /**
+ * The character code for the greek delta letter
+ */
public static final char DELTA_CHAR = '\u0394';
private static final char SEMI_COLON = ';';
private static final char COMMA = ',';
@@ -171,16 +181,16 @@ public boolean isWithinThreshold() {
});
private static final ThreadLocal LE_TIMESTAMP_FORMATTER = ThreadLocal
- .withInitial(() -> new SimpleDateFormat("HH:mm:ss.SSS MMM dd"));
+ .withInitial(() -> new SimpleDateFormat("HH:mm:ss.SSS MMM dd"));
private static final ThreadLocal SLE_TIMESTAMP_FORMATTER = ThreadLocal
- .withInitial(() -> new SimpleDateFormat("HH:mm:ss.SSS MMM dd yyyy"));
+ .withInitial(() -> new SimpleDateFormat("HH:mm:ss.SSS MMM dd yyyy"));
private static final ThreadLocal BE_TIMESTAMP_FORMATTER = ThreadLocal
- .withInitial(() -> new SimpleDateFormat("MMM dd HH:mm:ss"));
+ .withInitial(() -> new SimpleDateFormat("MMM dd HH:mm:ss"));
private static final ThreadLocal SBE_TIMESTAMP_FORMATTER = ThreadLocal
- .withInitial(() -> new SimpleDateFormat("yyyy MMM dd HH:mm:ss"));
+ .withInitial(() -> new SimpleDateFormat("yyyy MMM dd HH:mm:ss"));
private static final Pattern COMMA_PATTERN = Pattern.compile("\\,");
private static final ThreadLocal NANO_FORMATTER = ThreadLocal
- .withInitial(() -> new DecimalFormat("000000000"));
+ .withInitial(() -> new DecimalFormat("000000000"));
/**
* Private constructor to prevent instantiation of this class.
@@ -197,7 +207,7 @@ private Utilities() {
* {@link #valueToString(VType)}.
*
* @param indata the data to parse and transform into VType
- * @param type the type of the destination object
+ * @param type the type of the destination object
* @return VType representing the data#
* @throws IllegalArgumentException if the numbers of array elements do not match
*/
@@ -284,24 +294,21 @@ public static VType valueFromString(String indata, VType type) throws IllegalArg
}
return VNumberArray.of(list, alarm, time, Display.none());
- }
- else if(type instanceof VStringArray){
+ } else if (type instanceof VStringArray) {
String[] elements = data.split("\\,");
List list = Arrays.asList(elements).stream().map(String::trim).collect(Collectors.toList());
list = list.stream().map(s -> s.substring(1, s.length() - 1)).collect(Collectors.toList());
return VStringArray.of(list, alarm, time);
- }
- else if(type instanceof VBooleanArray){
+ } else if (type instanceof VBooleanArray) {
String[] elements = data.split("\\,");
List list = Arrays.asList(elements).stream().map(String::trim).collect(Collectors.toList());
boolean[] booleans = new boolean[list.size()];
- for(int i = 0; i < list.size(); i++){
+ for (int i = 0; i < list.size(); i++) {
booleans[i] = Integer.parseInt(list.get(i)) > 0 ? true : false;
}
ListBoolean listBoolean = ArrayBoolean.of(booleans);
return VBooleanArray.of(listBoolean, alarm, time);
- }
- else if (type instanceof VDouble) {
+ } else if (type instanceof VDouble) {
return VDouble.of(Double.parseDouble(data), alarm, time, Display.none());
} else if (type instanceof VFloat) {
return VFloat.of(Float.parseFloat(data), alarm, time, Display.none());
@@ -328,7 +335,7 @@ else if (type instanceof VDouble) {
try {
idx = Integer.parseInt(data);
} catch (NumberFormatException e) {
- throw new IllegalArgumentException(String.format("'%s' is not a valid enum value.",data));
+ throw new IllegalArgumentException(String.format("'%s' is not a valid enum value.", data));
}
}
return VEnum.of(idx, EnumDisplay.of(labels), alarm, time);
@@ -366,22 +373,17 @@ public static Object toRawValue(VType type) {
return null;
}
if (type instanceof VNumberArray) {
- if(type instanceof VIntArray || type instanceof VUIntArray){
+ if (type instanceof VIntArray || type instanceof VUIntArray) {
return VTypeHelper.toIntegers(type);
- }
- else if(type instanceof VDoubleArray){
+ } else if (type instanceof VDoubleArray) {
return VTypeHelper.toDoubles(type);
- }
- else if(type instanceof VFloatArray){
+ } else if (type instanceof VFloatArray) {
return VTypeHelper.toFloats(type);
- }
- else if(type instanceof VLongArray || type instanceof VULongArray){
+ } else if (type instanceof VLongArray || type instanceof VULongArray) {
return VTypeHelper.toLongs(type);
- }
- else if(type instanceof VShortArray || type instanceof VUShortArray){
+ } else if (type instanceof VShortArray || type instanceof VUShortArray) {
return VTypeHelper.toShorts(type);
- }
- else if(type instanceof VByteArray || type instanceof VUByteArray){
+ } else if (type instanceof VByteArray || type instanceof VUByteArray) {
return VTypeHelper.toBytes(type);
}
} else if (type instanceof VEnumArray) {
@@ -434,7 +436,7 @@ public static String valueToString(VType type) {
* given by the arrayLimi
parameter. This method should only be used for presentation of the value on
* the screen.
*
- * @param type the data to transform
+ * @param type the data to transform
* @param arrayLimit the maximum number of array elements to include
* @return string representation of the data
*/
@@ -447,16 +449,16 @@ public static String valueToString(VType type, int arrayLimit) {
StringBuilder sb = new StringBuilder(size * 15 + 2);
sb.append('[');
Pattern pattern = Pattern.compile("\\,");
- NumberFormat formatter = ((SimpleValueFormat)FORMAT.get()).getNumberFormat();
+ NumberFormat formatter = ((SimpleValueFormat) FORMAT.get()).getNumberFormat();
if (type instanceof VDoubleArray) {
for (int i = 0; i < size; i++) {
sb.append(pattern.matcher(formatter.format(list.getDouble(i))).replaceAll("\\.")).append(COMMA)
- .append(' ');
+ .append(' ');
}
} else if (type instanceof VFloatArray) {
for (int i = 0; i < size; i++) {
sb.append(pattern.matcher(formatter.format(list.getFloat(i))).replaceAll("\\.")).append(COMMA)
- .append(' ');
+ .append(' ');
}
} else if (type instanceof VULongArray) {
for (int i = 0; i < size; i++) {
@@ -500,8 +502,7 @@ public static String valueToString(VType type, int arrayLimit) {
sb.setCharAt(sb.length() - 2, ']');
}
return sb.toString().trim();
- }
- else if(type instanceof VStringArray){
+ } else if (type instanceof VStringArray) {
List list = ((VStringArray) type).getData();
int size = Math.min(arrayLimit, list.size());
StringBuilder sb = new StringBuilder(size * 15 + 2);
@@ -518,12 +519,11 @@ else if(type instanceof VStringArray){
sb.setCharAt(sb.length() - 2, ']');
}
return sb.toString().trim();
- }
- else if (type instanceof VNumber) {
+ } else if (type instanceof VNumber) {
if (type instanceof VDouble) {
- return ((SimpleValueFormat)FORMAT.get()).format(((VDouble) type).getValue());
+ return ((SimpleValueFormat) FORMAT.get()).format(((VDouble) type).getValue());
} else if (type instanceof VFloat) {
- return ((SimpleValueFormat)FORMAT.get()).format(((VFloat) type).getValue());
+ return ((SimpleValueFormat) FORMAT.get()).format(((VFloat) type).getValue());
} else {
return String.valueOf(((VNumber) type).getValue());
}
@@ -557,35 +557,37 @@ else if (type instanceof VNumber) {
* If the base value and the transformed value are both of a {@link VNumber} type, the difference of the transformed
* value to the base value is added to the returned string.
*
- * @param value the value to compare
+ * @param value the value to compare
* @param baseValue the base value to compare the value to
* @param threshold the threshold values to use for comparing the values, if defined and difference is within
- * threshold limits the values are equal
+ * threshold limits the values are equal
* @return string representing the value and the difference from the base value together with the flag indicating
- * the comparison result
+ * the comparison result
*/
@SuppressWarnings("unchecked")
public static VTypeComparison valueToCompareString(VType value, VType baseValue, Optional> threshold) {
if (value == null && baseValue == null
- || value == VDisconnectedData.INSTANCE && baseValue == VDisconnectedData.INSTANCE) {
+ || value == VDisconnectedData.INSTANCE && baseValue == VDisconnectedData.INSTANCE) {
return new VTypeComparison(VDisconnectedData.INSTANCE.toString(), 0, true);
} else if (value == null || baseValue == null) {
return value == null ? new VTypeComparison(VDisconnectedData.INSTANCE.toString(), -1, false)
- : new VTypeComparison(valueToString(value), 1, false);
+ : new VTypeComparison(valueToString(value), 1, false);
} else if (value == VDisconnectedData.INSTANCE || baseValue == VDisconnectedData.INSTANCE) {
return value == VDisconnectedData.INSTANCE
- ? new VTypeComparison(VDisconnectedData.INSTANCE.toString(), -1, false)
- : new VTypeComparison(valueToString(value), 1, false);
+ ? new VTypeComparison(VDisconnectedData.INSTANCE.toString(), -1, false)
+ : new VTypeComparison(valueToString(value), 1, false);
}
if (value instanceof VNumber && baseValue instanceof VNumber) {
StringBuilder sb = new StringBuilder(20);
int diff = 0;
+ double absoluteDelta = 0.0;
boolean withinThreshold = threshold.isPresent();
- sb.append(((SimpleValueFormat)FORMAT.get()).format(value));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(value));
if (value instanceof VDouble) {
double data = ((VDouble) value).getValue();
double base = ((VNumber) baseValue).getValue().doubleValue();
double newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Double.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -596,11 +598,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VFloat) {
float data = ((VFloat) value).getValue();
float base = ((VNumber) baseValue).getValue().floatValue();
float newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Float.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -611,11 +614,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VULong) {
BigInteger data = ((VULong) value).getValue().bigIntegerValue();
BigInteger base = ((VULong) baseValue).getValue().bigIntegerValue();
BigInteger newd = data.subtract(base);
+ absoluteDelta = Math.abs(newd.doubleValue());
diff = data.compareTo(base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -626,11 +630,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd.compareTo(BigInteger.ZERO) > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VLong) {
long data = ((VLong) value).getValue();
long base = ((VNumber) baseValue).getValue().longValue();
long newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Long.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -641,11 +646,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VUInt) {
long data = ((VUInt) value).getValue().longValue();
long base = ((VUInt) baseValue).getValue().longValue();
long newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Long.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -656,11 +662,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VInt) {
int data = ((VInt) value).getValue();
int base = ((VNumber) baseValue).getValue().intValue();
int newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Integer.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -671,11 +678,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VUShort) {
int data = ((VUShort) value).getValue().intValue();
int base = ((VUShort) baseValue).getValue().intValue();
int newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Integer.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -686,11 +694,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VShort) {
short data = ((VShort) value).getValue();
short base = ((VNumber) baseValue).getValue().shortValue();
short newd = (short) (data - base);
+ absoluteDelta = Math.abs(newd);
diff = Short.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -701,11 +710,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VUByte) {
int data = ((VUByte) value).getValue().intValue();
int base = ((VUByte) baseValue).getValue().intValue();
int newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Integer.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -716,11 +726,12 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VByte) {
byte data = ((VByte) value).getValue();
byte base = ((VNumber) baseValue).getValue().byteValue();
byte newd = (byte) (data - base);
+ absoluteDelta = Math.abs(newd);
diff = Byte.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -731,9 +742,9 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
}
- return new VTypeComparison(sb.toString(), diff, withinThreshold);
+ return new VTypeComparison(sb.toString(), diff, withinThreshold, absoluteDelta);
} else if (value instanceof VBoolean && baseValue instanceof VBoolean) {
String str = valueToString(value);
boolean b = ((VBoolean) value).getValue();
@@ -767,35 +778,37 @@ public static VTypeComparison valueToCompareString(VType value, VType baseValue,
* If the base value and the transformed value are both of a {@link VNumber} type, the difference of the transformed
* value to the base value is returned as string.
*
- * @param value the value to compare
+ * @param value the value to compare
* @param baseValue the base value to compare the value to
* @param threshold the threshold values to use for comparing the values, if defined and difference is within
- * threshold limits the values are equal
+ * threshold limits the values are equal
* @return string representing the difference from the base value together with the flag indicating
- * the comparison result
+ * the comparison result
*/
@SuppressWarnings("unchecked")
public static VTypeComparison deltaValueToString(VType value, VType baseValue, Optional> threshold) {
if (value == null && baseValue == null
- || value == VDisconnectedData.INSTANCE && baseValue == VDisconnectedData.INSTANCE) {
+ || value == VDisconnectedData.INSTANCE && baseValue == VDisconnectedData.INSTANCE) {
return new VTypeComparison(VDisconnectedData.INSTANCE.toString(), 0, true);
} else if (value == null || baseValue == null) {
return value == null ? new VTypeComparison(VDisconnectedData.INSTANCE.toString(), -1, false)
- : new VTypeComparison(valueToString(value), 1, false);
+ : new VTypeComparison(valueToString(value), 1, false);
} else if (value == VDisconnectedData.INSTANCE || baseValue == VDisconnectedData.INSTANCE) {
return value == VDisconnectedData.INSTANCE
- ? new VTypeComparison(VDisconnectedData.INSTANCE.toString(), -1, false)
- : new VTypeComparison(valueToString(value), 1, false);
+ ? new VTypeComparison(VDisconnectedData.INSTANCE.toString(), -1, false)
+ : new VTypeComparison(valueToString(value), 1, false);
}
if (value instanceof VNumber && baseValue instanceof VNumber) {
StringBuilder sb = new StringBuilder(20);
int diff = 0;
+ double absoluteDelta = 0.0;
boolean withinThreshold = threshold.isPresent();
if (value instanceof VDouble) {
double data = ((VDouble) value).getValue();
double base = ((VNumber) baseValue).getValue().doubleValue();
double newd = data - base;
diff = Double.compare(data, base);
+ absoluteDelta = Math.abs(newd);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
} else {
@@ -804,12 +817,13 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VFloat) {
float data = ((VFloat) value).getValue();
float base = ((VNumber) baseValue).getValue().floatValue();
float newd = data - base;
diff = Float.compare(data, base);
+ absoluteDelta = Math.abs(newd);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
} else {
@@ -818,12 +832,13 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VULong) {
BigInteger data = ((VULong) value).getValue().bigIntegerValue();
BigInteger base = ((VULong) baseValue).getValue().bigIntegerValue();
BigInteger newd = data.subtract(base);
diff = data.compareTo(base);
+ absoluteDelta = Math.abs(newd.doubleValue());
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
} else {
@@ -832,11 +847,12 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd.compareTo(BigInteger.ZERO) > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VLong) {
long data = ((VLong) value).getValue();
long base = ((VNumber) baseValue).getValue().longValue();
long newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Long.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -846,11 +862,12 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VUInt) {
long data = ((VUInt) value).getValue().longValue();
long base = ((VUInt) baseValue).getValue().longValue();
long newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Long.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -860,11 +877,12 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VInt) {
int data = ((VInt) value).getValue();
int base = ((VNumber) baseValue).getValue().intValue();
int newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Integer.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -874,11 +892,12 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VUShort) {
int data = ((VUShort) value).getValue().intValue();
int base = ((VUShort) baseValue).getValue().intValue();
int newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Integer.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -888,11 +907,12 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VShort) {
short data = ((VShort) value).getValue();
short base = ((VNumber) baseValue).getValue().shortValue();
short newd = (short) (data - base);
+ absoluteDelta = Math.abs(newd);
diff = Short.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -902,11 +922,12 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VUByte) {
int data = ((VUByte) value).getValue().intValue();
int base = ((VUByte) baseValue).getValue().intValue();
int newd = data - base;
+ absoluteDelta = Math.abs(newd);
diff = Integer.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -916,11 +937,12 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
} else if (value instanceof VByte) {
byte data = ((VByte) value).getValue();
byte base = ((VNumber) baseValue).getValue().byteValue();
byte newd = (byte) (data - base);
+ absoluteDelta = Math.abs(newd);
diff = Byte.compare(data, base);
if (threshold.isPresent()) {
withinThreshold = ((Threshold) threshold.get()).isWithinThreshold(data, base);
@@ -930,9 +952,9 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
if (newd > 0) {
sb.append('+');
}
- sb.append(((SimpleValueFormat)FORMAT.get()).format(newd));
+ sb.append(((SimpleValueFormat) FORMAT.get()).format(newd));
}
- return new VTypeComparison(sb.toString(), diff, withinThreshold);
+ return new VTypeComparison(sb.toString(), diff, withinThreshold, absoluteDelta);
} else if (value instanceof VBoolean && baseValue instanceof VBoolean) {
String str = valueToString(value);
boolean b = ((VBoolean) value).getValue();
@@ -953,16 +975,13 @@ public static VTypeComparison deltaValueToString(VType value, VType baseValue, O
} else if (value instanceof VNumberArray && baseValue instanceof VNumberArray) {
boolean equal = areValuesEqual(value, baseValue, Optional.empty());
return new VTypeComparison(equal ? "---" : "NOT EQUAL", equal ? 0 : 1, equal);
- }
- else if (value instanceof VStringArray && baseValue instanceof VStringArray) {
+ } else if (value instanceof VStringArray && baseValue instanceof VStringArray) {
boolean equal = areValuesEqual(value, baseValue, Optional.empty());
return new VTypeComparison(equal ? "---" : "NOT EQUAL", equal ? 0 : 1, equal);
- }
- else if (value instanceof VBooleanArray && baseValue instanceof VBooleanArray) {
+ } else if (value instanceof VBooleanArray && baseValue instanceof VBooleanArray) {
boolean equal = areValuesEqual(value, baseValue, Optional.empty());
return new VTypeComparison(equal ? "---" : "NOT EQUAL", equal ? 0 : 1, equal);
- }
- else {
+ } else {
String str = valueToString(value);
boolean valuesEqual = areValuesEqual(value, baseValue, Optional.empty());
return new VTypeComparison(str, valuesEqual ? 0 : 1, valuesEqual);
@@ -974,7 +993,7 @@ else if (value instanceof VBooleanArray && baseValue instanceof VBooleanArray) {
* If the base va0lue and the transformed value are both of a {@link VNumber} type,
* the formatted percentage of the transformed value to the base value is returned.
*
- * @param value the value to compare
+ * @param value the value to compare
* @param baseValue the base value to compare the value to
* @return formatted percentage of the difference
*/
@@ -985,7 +1004,7 @@ public static String deltaValueToPercentage(VType value, VType baseValue) {
double base = ((VNumber) baseValue).getValue().doubleValue();
double newd = data - base;
- double percentage = newd/data*100;
+ double percentage = newd / data * 100;
if (Double.compare(newd, 0) == 0) {
return "";
@@ -1007,7 +1026,7 @@ public static String deltaValueToPercentage(VType value, VType baseValue) {
/**
* Transforms the timestamp to string, using the format HH:mm:ss.SSS MMM dd (yyyy).
*
- * @param t the timestamp to transform
+ * @param t the timestamp to transform
* @param includeYear true if the year should included in the format
* @return string representation of the timestamp using the above format
*/
@@ -1016,14 +1035,14 @@ public static String timestampToLittleEndianString(Instant t, boolean includeYea
return null;
}
return includeYear ? SLE_TIMESTAMP_FORMATTER.get().format(Date.from(t))
- : LE_TIMESTAMP_FORMATTER.get().format(Date.from(t));
+ : LE_TIMESTAMP_FORMATTER.get().format(Date.from(t));
}
/**
* Transforms the date to string formatted as yyyy MMM dd HH:mm:ss. Year is only included if the parameter
* includeYear
is true.
*
- * @param t the date to transform
+ * @param t the date to transform
* @param includeYear true if the year should be included or false otherwise
* @return string representation of the date
*/
@@ -1032,15 +1051,15 @@ public static String timestampToBigEndianString(Instant t, boolean includeYear)
return null;
}
return includeYear ? SBE_TIMESTAMP_FORMATTER.get().format(Date.from(t))
- : BE_TIMESTAMP_FORMATTER.get().format(Date.from(t));
+ : BE_TIMESTAMP_FORMATTER.get().format(Date.from(t));
}
/**
* Checks if the values of the given vtype are equal and returns true if they are or false if they are not.
* Timestamps, alarms and other parameters are ignored.
*
- * @param v1 the first value to check
- * @param v2 the second value to check
+ * @param v1 the first value to check
+ * @param v2 the second value to check
* @param threshold the threshold values which define if the difference is within limits or not
* @return true if the values are equal or false otherwise
*/
@@ -1141,12 +1160,12 @@ public static boolean areValuesEqual(VType v1, VType v2, Optional>
return b == c || b != null && b.equals(c);
} else if (v1 instanceof VNumberArray && v2 instanceof VNumberArray) {
if ((v1 instanceof VByteArray && v2 instanceof VByteArray)
- || (v1 instanceof VUByteArray && v2 instanceof VUByteArray)
- || (v1 instanceof VShortArray && v2 instanceof VShortArray)
- || (v1 instanceof VUShortArray && v2 instanceof VUShortArray)
- || (v1 instanceof VIntArray && v2 instanceof VIntArray)
- || (v1 instanceof VFloatArray && v2 instanceof VFloatArray)
- || (v1 instanceof VDoubleArray && v2 instanceof VDoubleArray)) {
+ || (v1 instanceof VUByteArray && v2 instanceof VUByteArray)
+ || (v1 instanceof VShortArray && v2 instanceof VShortArray)
+ || (v1 instanceof VUShortArray && v2 instanceof VUShortArray)
+ || (v1 instanceof VIntArray && v2 instanceof VIntArray)
+ || (v1 instanceof VFloatArray && v2 instanceof VFloatArray)
+ || (v1 instanceof VDoubleArray && v2 instanceof VDoubleArray)) {
ListNumber b = ((VNumberArray) v1).getData();
ListNumber c = ((VNumberArray) v2).getData();
int size = b.size();
@@ -1199,28 +1218,26 @@ public static boolean areValuesEqual(VType v1, VType v2, Optional>
}
return true;
}
- }
- else if (v1 instanceof VStringArray && v2 instanceof VStringArray) {
+ } else if (v1 instanceof VStringArray && v2 instanceof VStringArray) {
List value1 = ((VStringArray) v1).getData();
List value2 = ((VStringArray) v2).getData();
- if(value1.size() != value2.size()){
+ if (value1.size() != value2.size()) {
return false;
}
- for(int i = 0; i < value1.size(); i++){
- if(!value1.get(i).equals(value2.get(i))){
+ for (int i = 0; i < value1.size(); i++) {
+ if (!value1.get(i).equals(value2.get(i))) {
return false;
}
}
return true;
- }
- else if (v1 instanceof VBooleanArray && v2 instanceof VBooleanArray) {
+ } else if (v1 instanceof VBooleanArray && v2 instanceof VBooleanArray) {
ListBoolean value1 = ((VBooleanArray) v1).getData();
ListBoolean value2 = ((VBooleanArray) v2).getData();
- if(value1.size() != value2.size()){
+ if (value1.size() != value2.size()) {
return false;
}
- for(int i = 0; i < value1.size(); i++){
- if(Boolean.compare(value1.getBoolean(i), value2.getBoolean(i)) != 0){
+ for (int i = 0; i < value1.size(); i++) {
+ if (Boolean.compare(value1.getBoolean(i), value2.getBoolean(i)) != 0) {
return false;
}
}
@@ -1236,8 +1253,8 @@ else if (v1 instanceof VBooleanArray && v2 instanceof VBooleanArray) {
* are identical if their alarm signatures are identical, timestamps are the same, values are the same and in case
* of enum and enum array also the labels have to be identical.
*
- * @param v1 the first value
- * @param v2 the second value to compare to the first one
+ * @param v1 the first value
+ * @param v2 the second value to compare to the first one
* @param compareAlarmAndTime true if alarm and time values should be compare or false if no
* @return true if values are identical or false otherwise
*/
@@ -1309,13 +1326,13 @@ public static boolean areVTypesIdentical(VType v1, VType v2, boolean compareAlar
return false;
} else if (v1 instanceof VNumberArray && v2 instanceof VNumberArray) {
if ((v1 instanceof VByteArray && v2 instanceof VByteArray)
- || (v1 instanceof VUByteArray && v2 instanceof VUByteArray)
- || (v1 instanceof VShortArray && v2 instanceof VShortArray)
- || (v1 instanceof VUShortArray && v2 instanceof VUShortArray)
- || (v1 instanceof VIntArray && v2 instanceof VIntArray)
- || (v1 instanceof VUIntArray && v2 instanceof VUIntArray)
- || (v1 instanceof VFloatArray && v2 instanceof VFloatArray)
- || (v1 instanceof VDoubleArray && v2 instanceof VDoubleArray)) {
+ || (v1 instanceof VUByteArray && v2 instanceof VUByteArray)
+ || (v1 instanceof VShortArray && v2 instanceof VShortArray)
+ || (v1 instanceof VUShortArray && v2 instanceof VUShortArray)
+ || (v1 instanceof VIntArray && v2 instanceof VIntArray)
+ || (v1 instanceof VUIntArray && v2 instanceof VUIntArray)
+ || (v1 instanceof VFloatArray && v2 instanceof VFloatArray)
+ || (v1 instanceof VDoubleArray && v2 instanceof VDoubleArray)) {
ListNumber b = ((VNumberArray) v1).getData();
ListNumber c = ((VNumberArray) v2).getData();
int size = b.size();
@@ -1364,36 +1381,32 @@ public static boolean areVTypesIdentical(VType v1, VType v2, boolean compareAlar
private static boolean isAlarmAndTimeEqual(VType a1, VType a2) {
if (a1 instanceof VNumber && a2 instanceof VNumber) {
- VNumber vn1 = (VNumber)a1;
- VNumber vn2 = (VNumber)a2;
+ VNumber vn1 = (VNumber) a1;
+ VNumber vn2 = (VNumber) a2;
return vn1.getAlarm().getName().equals(vn2.getAlarm().getName()) &&
vn1.getAlarm().getSeverity().equals(vn2.getAlarm().getSeverity()) &&
vn1.getTime().getTimestamp().equals(vn2.getTime().getTimestamp());
- }
- else if (a1 instanceof VNumberArray && a2 instanceof VNumberArray) {
- VNumberArray vn1 = (VNumberArray)a1;
- VNumberArray vn2 = (VNumberArray)a2;
+ } else if (a1 instanceof VNumberArray && a2 instanceof VNumberArray) {
+ VNumberArray vn1 = (VNumberArray) a1;
+ VNumberArray vn2 = (VNumberArray) a2;
return vn1.getAlarm().getName().equals(vn2.getAlarm().getName()) &&
vn1.getAlarm().getSeverity().equals(vn2.getAlarm().getSeverity()) &&
vn1.getTime().getTimestamp().equals(vn2.getTime().getTimestamp());
- }
- else if (a1 instanceof VNumber && a2 instanceof VNumberArray) {
- VNumber vn1 = (VNumber)a1;
- VNumberArray vn2 = (VNumberArray)a2;
+ } else if (a1 instanceof VNumber && a2 instanceof VNumberArray) {
+ VNumber vn1 = (VNumber) a1;
+ VNumberArray vn2 = (VNumberArray) a2;
return vn1.getAlarm().getName().equals(vn2.getAlarm().getName()) &&
vn1.getAlarm().getSeverity().equals(vn2.getAlarm().getSeverity()) &&
vn1.getTime().getTimestamp().equals(vn2.getTime().getTimestamp());
- }
- else if (a1 instanceof VNumberArray && a2 instanceof VNumber) {
- VNumberArray vn1 = (VNumberArray)a1;
- VNumber vn2 = (VNumber)a2;
+ } else if (a1 instanceof VNumberArray && a2 instanceof VNumber) {
+ VNumberArray vn1 = (VNumberArray) a1;
+ VNumber vn2 = (VNumber) a2;
return vn1.getAlarm().getName().equals(vn2.getAlarm().getName()) &&
vn1.getAlarm().getSeverity().equals(vn2.getAlarm().getSeverity()) &&
vn1.getTime().getTimestamp().equals(vn2.getTime().getTimestamp());
- }
- else if (a1 instanceof VEnum && a2 instanceof VEnum) {
- VEnum vn1 = (VEnum)a1;
- VEnum vn2 = (VEnum)a2;
+ } else if (a1 instanceof VEnum && a2 instanceof VEnum) {
+ VEnum vn1 = (VEnum) a1;
+ VEnum vn2 = (VEnum) a2;
return vn1.getAlarm().getName().equals(vn2.getAlarm().getName()) &&
vn1.getAlarm().getSeverity().equals(vn2.getAlarm().getSeverity()) &&
vn1.getTime().getTimestamp().equals(vn2.getTime().getTimestamp());
diff --git a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotController.java b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotController.java
index dff6680aba..7af43d438d 100644
--- a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotController.java
+++ b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotController.java
@@ -220,8 +220,7 @@ public void initialize() {
defaultEpicsProtocol =
new PreferencesReader(PVFactory.class, "/pv_preferences.properties").get("default");
- isTreeTableViewEnabled =
- new PreferencesReader(getClass(), "/save_and_restore_preferences.properties").getBoolean("treeTableView.enable");
+ isTreeTableViewEnabled = new PreferencesReader(getClass(), "/save_and_restore_preferences.properties").getBoolean("treeTableView.enable");
snapshotNameLabel.getStylesheets().add(getClass().getResource("/style.css").toExternalForm());
snapshotNameLabel.getStyleClass().add("stand-out-mandatory");
diff --git a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTable.java b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTable.java
index 13e8691006..161f241942 100644
--- a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTable.java
+++ b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTable.java
@@ -669,18 +669,15 @@ private void createTableForSingleSnapshot(boolean showLiveReadback, boolean show
return vDeltaCellEditor;
});
delta.setEditable(false);
+
+
delta.setComparator((pair1, pair2) -> {
Utilities.VTypeComparison vtc1 = Utilities.valueToCompareString(pair1.value, pair1.base, pair1.threshold);
Utilities.VTypeComparison vtc2 = Utilities.valueToCompareString(pair2.value, pair2.base, pair2.threshold);
- if (!vtc1.isWithinThreshold() && vtc2.isWithinThreshold()) {
- return -1;
- } else if (vtc1.isWithinThreshold() && !vtc2.isWithinThreshold()) {
- return 1;
- } else {
- return 0;
- }
+ return Double.compare(vtc1.getAbsoluteDelta(), vtc2.getAbsoluteDelta());
});
+
storedValueBaseColumn.getColumns().add(delta);
snapshotTableEntries.add(storedValueBaseColumn);
diff --git a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTreeTable.java b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTreeTable.java
index ccf32be2dc..f0baafe6f5 100644
--- a/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTreeTable.java
+++ b/app/save-and-restore/ui/src/main/java/org/phoebus/applications/saveandrestore/ui/snapshot/SnapshotTreeTable.java
@@ -107,7 +107,6 @@ class SnapshotTreeTable extends TreeTableView {
* TimestampTableCell
is a table cell for rendering the {@link Instant} objects in the table.
*
* @author Jaka Bobnar
- *
*/
private static class TimestampTreeTableCell extends TreeTableCell {
@Override
@@ -138,13 +137,12 @@ protected void updateItem(TreeTableEntry item, boolean empty) {
* VTypeCellEditor
is an editor type for {@link VType} or {@link VTypePair}, which allows editing the
* value as a string.
*
- * @author Jaka Bobnar
- *
* @param {@link VType} or {@link VTypePair}
+ * @author Jaka Bobnar
*/
private static class VTypeTreeCellEditor extends MultitypeTreeTableCell {
private static final Image WARNING_IMAGE = new Image(
- SnapshotController.class.getResourceAsStream("/icons/hprio_tsk.png"));
+ SnapshotController.class.getResourceAsStream("/icons/hprio_tsk.png"));
private static final Image DISCONNECTED_IMAGE = new Image(
SnapshotController.class.getResourceAsStream("/icons/showerr_tsk.png"));
private final Tooltip tooltip = new Tooltip();
@@ -192,10 +190,10 @@ public T fromString(String string) {
VTypePair t = (VTypePair) item;
if (t.value instanceof VDisconnectedData) {
return (T) new VTypePair(t.base, Utilities.valueFromString(string, t.base),
- t.threshold);
+ t.threshold);
} else {
return (T) new VTypePair(t.base, Utilities.valueFromString(string, t.value),
- t.threshold);
+ t.threshold);
}
} else {
return item;
@@ -310,9 +308,9 @@ public void updateItem(T item, boolean empty) {
/**
* A dedicated CellEditor for displaying delta only.
* TODO can be simplified further
- * @author Kunal Shroff
*
* @param
+ * @author Kunal Shroff
*/
private static class VDeltaTreeCellEditor extends VTypeTreeCellEditor {
@@ -323,7 +321,10 @@ private static class VDeltaTreeCellEditor extends VTypeTreeCellEditor {
private final Tooltip tooltip = new Tooltip();
private boolean showDeltaPercentage = false;
- private void setShowDeltaPercentage() { showDeltaPercentage = true; }
+
+ private void setShowDeltaPercentage() {
+ showDeltaPercentage = true;
+ }
VDeltaTreeCellEditor() {
super();
@@ -389,9 +390,8 @@ public void updateItem(T item, boolean empty) {
/**
* TooltipTreeTableColumn
is the common table column implementation, which can also provide the tooltip.
*
- * @author Jaka Bobnar
- *
* @param the type of the values displayed by this column
+ * @author Jaka Bobnar
*/
private class TooltipTreeTableColumn extends TreeTableColumn {
private String text;
@@ -444,7 +444,6 @@ void setSaved(boolean saved) {
* a checkbox, whether the PV should be selected or not.
*
* @author Jaka Bobnar
- *
*/
private class SelectionTreeTableColumn extends TooltipTreeTableColumn {
SelectionTreeTableColumn() {
@@ -628,7 +627,7 @@ protected void updateItem(TreeTableEntry item, boolean empty) {
});
setRowFactory(tableView -> new TreeTableRow<>() {
- final ContextMenu contextMenu= new ContextMenu();
+ final ContextMenu contextMenu = new ContextMenu();
@Override
protected void updateItem(TreeTableEntry item, boolean empty) {
@@ -670,7 +669,7 @@ protected void updateItem(TreeTableEntry item, boolean empty) {
private void recursiveSortByName(ObservableList> list) {
FXCollections.sort(list, Comparator.comparing((TreeItem tte) -> !tte.getValue().folder)
- .thenComparing((TreeItem tte) -> tte.getValue().name));
+ .thenComparing((TreeItem tte) -> tte.getValue().name));
list.stream().forEach(item -> recursiveSortByName(item.getChildren()));
}
@@ -705,7 +704,7 @@ private void createTreeTableEntryItems(List tableEntryItems) {
signal.initializeEqualPropertyChangeListener(controller);
signal.initializeChangeListenerForColumnHeaderCheckBox(selectAllCheckBox);
signal.initializeReadonlyChangeListenerForToggle();
- treeTableEntryItems.put(getPVKey(pvName, entry.readOnlyProperty().get()^entry.readonlyOverrideProperty().get()), signal);
+ treeTableEntryItems.put(getPVKey(pvName, entry.readOnlyProperty().get() ^ entry.readonlyOverrideProperty().get()), signal);
}
}
}
@@ -719,7 +718,7 @@ private String getPVKey(String pvName, boolean isReadonly) {
* Set the column and row number at current mouse position.
*
* @param column the column at mouse cursor (null if none)
- * @param row the row index at mouse cursor
+ * @param row the row index at mouse cursor
*/
private void setColumnAndRowAtMouse(TreeTableColumn column, int row) {
this.columnAtMouse = column;
@@ -743,7 +742,7 @@ private void createTableForSingleSnapshot(boolean showLiveReadback, boolean show
int width = measureStringWidth("000", Font.font(20));
TreeTableColumn idColumn = new TooltipTreeTableColumn<>("#",
- Messages.toolTipTableColumIndex, width, width, false);
+ Messages.toolTipTableColumIndex, width, width, false);
idColumn.setCellValueFactory(cell -> {
TreeTableEntry treeTableEntry = cell.getValue().getValue();
if (treeTableEntry.folder) {
@@ -777,14 +776,14 @@ private void createTableForSingleSnapshot(boolean showLiveReadback, boolean show
width = measureStringWidth("MM:MM:MM.MMM MMM MM M", null);
TreeTableColumn timestampColumn = new TooltipTreeTableColumn<>("Timestamp",
- Messages.toolTipTableColumnTimestamp, width, width, true);
+ Messages.toolTipTableColumnTimestamp, width, width, true);
timestampColumn.setCellValueFactory(cell -> new ReadOnlyObjectWrapper<>(cell.getValue().getValue()));
timestampColumn.setCellFactory(c -> new TimestampTreeTableCell());
timestampColumn.setPrefWidth(width);
snapshotTreeTableColumns.add(timestampColumn);
TreeTableColumn statusColumn = new TooltipTreeTableColumn<>("Status",
- Messages.toolTipTableColumnAlarmStatus, 100, 100, true);
+ Messages.toolTipTableColumnAlarmStatus, 100, 100, true);
statusColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("status"));
statusColumn.setCellFactory(cell -> new StringTreeTableCell());
snapshotTreeTableColumns.add(statusColumn);
@@ -799,8 +798,8 @@ private void createTableForSingleSnapshot(boolean showLiveReadback, boolean show
"Stored Setpoint", "", -1);
TreeTableColumn storedValueColumn = new TooltipTreeTableColumn<>(
- "Stored Setpoint",
- Messages.toolTipTableColumnSetpointPVValue, 100);
+ "Stored Setpoint",
+ Messages.toolTipTableColumnSetpointPVValue, 100);
storedValueColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("snapshotVal"));
storedValueColumn.setCellFactory(e -> new VTypeTreeCellEditor<>());
storedValueColumn.setEditable(true);
@@ -839,18 +838,14 @@ private void createTableForSingleSnapshot(boolean showLiveReadback, boolean show
return vDeltaTreeCellEditor;
});
delta.setEditable(false);
+
delta.setComparator((pair1, pair2) -> {
Utilities.VTypeComparison vtc1 = Utilities.valueToCompareString(pair1.value, pair1.base, pair1.threshold);
Utilities.VTypeComparison vtc2 = Utilities.valueToCompareString(pair2.value, pair2.base, pair2.threshold);
- if (!vtc1.isWithinThreshold() && vtc2.isWithinThreshold()) {
- return -1;
- } else if (vtc1.isWithinThreshold() && !vtc2.isWithinThreshold()) {
- return 1;
- } else {
- return 0;
- }
+ return Double.compare(vtc1.getAbsoluteDelta(), vtc2.getAbsoluteDelta());
});
+
storedValueBaseColumn.getColumns().add(delta);
snapshotTreeTableColumns.add(storedValueBaseColumn);
@@ -865,7 +860,7 @@ private void createTableForSingleSnapshot(boolean showLiveReadback, boolean show
}
TreeTableColumn liveValueColumn = new TooltipTreeTableColumn<>("Live Setpoint", "Current PV Value",
- 100);
+ 100);
liveValueColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("liveValue"));
liveValueColumn.setCellFactory(e -> new VTypeTreeCellEditor<>());
liveValueColumn.setEditable(false);
@@ -891,7 +886,7 @@ private void createTableForMultipleSnapshots(List snapshots) {
int width = measureStringWidth("000", Font.font(20));
TreeTableColumn idColumn = new TooltipTreeTableColumn<>("#",
- Messages.toolTipTableColumIndex, width, width, false);
+ Messages.toolTipTableColumIndex, width, width, false);
idColumn.setCellValueFactory(cell -> {
TreeTableEntry treeTableEntry = cell.getValue().getValue();
if (treeTableEntry.folder) {
@@ -907,7 +902,7 @@ private void createTableForMultipleSnapshots(List snapshots) {
list.add(idColumn);
TreeTableColumn setpointPVName = new TooltipTreeTableColumn<>("PV Name",
- Messages.toolTipUnionOfSetpointPVNames, 100);
+ Messages.toolTipUnionOfSetpointPVNames, 100);
setpointPVName.setCellValueFactory(cell -> new SimpleObjectProperty<>(cell.getValue().getValue()));
setpointPVName.setCellFactory(cell -> new PVNameTreeTableCell());
setpointPVName.setComparator(Comparator.comparing((TreeTableEntry tte) -> !tte.folder).thenComparing(tte -> tte.name));
@@ -918,7 +913,7 @@ private void createTableForMultipleSnapshots(List snapshots) {
list.add(new DividerTreeTableColumn());
TreeTableColumn storedValueColumn = new TooltipTreeTableColumn<>("Stored Values",
- Messages.toolTipTableColumnPVValues, -1);
+ Messages.toolTipTableColumnPVValues, -1);
storedValueColumn.getStyleClass().add("toplevel");
String snapshotName = snapshots.get(0).getSnapshot().get().getName() + " (" +
@@ -926,13 +921,13 @@ private void createTableForMultipleSnapshots(List snapshots) {
TreeTableColumn baseCol = new TooltipTreeTableColumn<>(
- snapshotName,
- Messages.toolTipTableColumnSetpointPVValue, 33);
+ snapshotName,
+ Messages.toolTipTableColumnSetpointPVValue, 33);
baseCol.getStyleClass().add("second-level");
TreeTableColumn storedBaseSetpointValueColumn = new TooltipTreeTableColumn<>(
- "Base Setpoint",
- Messages.toolTipTableColumnBaseSetpointValue, 100);
+ "Base Setpoint",
+ Messages.toolTipTableColumnBaseSetpointValue, 100);
storedBaseSetpointValueColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("snapshotVal"));
storedBaseSetpointValueColumn.setCellFactory(e -> new VTypeTreeCellEditor<>());
@@ -1026,8 +1021,8 @@ private void createTableForMultipleSnapshots(List snapshots) {
baseSnapshotCol.getColumns().add(setpointValueCol);
TooltipTreeTableColumn deltaCol = new TooltipTreeTableColumn<>(
- Utilities.DELTA_CHAR + " Base Setpoint",
- "Setpoint PVV value when the " + snapshotName + " snapshot was taken", 50);
+ Utilities.DELTA_CHAR + " Base Setpoint",
+ "Setpoint PVV value when the " + snapshotName + " snapshot was taken", 50);
// deltaCol.label.setContextMenu(menu);
deltaCol.setCellValueFactory(e -> {
TreeTableEntry treeTableEntry = e.getValue().getValue();
@@ -1069,7 +1064,7 @@ private void createTableForMultipleSnapshots(List snapshots) {
list.add(storedValueColumn);
TreeTableColumn liveValueColumn = new TooltipTreeTableColumn<>("Live Setpoint",
- "Current Setpoint value", 100);
+ "Current Setpoint value", 100);
liveValueColumn.setCellValueFactory(new TreeItemPropertyValueFactory<>("liveValue"));
liveValueColumn.setCellFactory(e -> new VTypeTreeCellEditor<>());
@@ -1105,10 +1100,10 @@ private ContextMenu createContextMenu(final int snapshotIndex) {
* structure is identical to the old one. This is slightly more expensive; however, this method is only invoked per
* user request (button click).
*
- * @param entries the table entries (rows) to set on the table
- * @param snapshots the snapshots which are currently displayed
- * @param showLiveReadback true if readback column should be visible or false otherwise
- * @param showStoredReadback true if the stored readback value columns should be visible or false otherwise
+ * @param entries the table entries (rows) to set on the table
+ * @param snapshots the snapshots which are currently displayed
+ * @param showLiveReadback true if readback column should be visible or false otherwise
+ * @param showStoredReadback true if the stored readback value columns should be visible or false otherwise
* @param showDeltaPercentage true if delta percentage should be be visible or false otherwise
*/
public void updateTable(List entries, List snapshots, boolean showLiveReadback, boolean showStoredReadback, boolean showDeltaPercentage) {
@@ -1143,7 +1138,7 @@ public void updateTable(List entries) {
final boolean notHide = !controller.isHideEqualItems();
entries.forEach(tableEntry -> {
- TreeTableEntry treeTableEntry = treeTableEntryItems.get(getPVKey(tableEntry.pvNameProperty().get(), tableEntry.readOnlyProperty().get()^tableEntry.readonlyOverrideProperty().get()));
+ TreeTableEntry treeTableEntry = treeTableEntryItems.get(getPVKey(tableEntry.pvNameProperty().get(), tableEntry.readOnlyProperty().get() ^ tableEntry.readonlyOverrideProperty().get()));
if (treeTableEntry != null) {
treeTableEntry.update(tableEntry);
if (notHide || !tableEntry.liveStoredEqualProperty().get()) {
@@ -1173,7 +1168,7 @@ private void updateTableColumnTitles() {
TreeTableColumn column = getColumns().get(4);
for (int i = 0; i < uiSnapshots.size(); i++) {
TreeTableColumn tableColumn = column.getColumns().get(i);
- if(tableColumn instanceof DividerTreeTableColumn){
+ if (tableColumn instanceof DividerTreeTableColumn) {
continue;
}
((TooltipTreeTableColumn>) tableColumn).setSaved(true); //uiSnapshots.get(i).isSaved());
@@ -1184,11 +1179,9 @@ private void updateTableColumnTitles() {
/**
* SnapshotTable cell renderer styled to fit the {@link DividerTreeTableColumn}
*/
- private class DividerCell extends TreeTableCell
- {
+ private class DividerCell extends TreeTableCell {
@Override
- protected void updateItem(final Object object, final boolean empty)
- {
+ protected void updateItem(final Object object, final boolean empty) {
super.updateItem(object, empty);
getStyleClass().add("divider");
}
@@ -1197,9 +1190,9 @@ protected void updateItem(final Object object, final boolean empty)
/**
* A table column styled to act as a divider between other columns.
*/
- private class DividerTreeTableColumn extends TreeTableColumn{
+ private class DividerTreeTableColumn extends TreeTableColumn {
- public DividerTreeTableColumn(){
+ public DividerTreeTableColumn() {
setPrefWidth(10);
setMinWidth(10);
setMaxWidth(50);
diff --git a/app/save-and-restore/ui/src/test/java/org/phoebus/applications/saveandrestore/UtilitiesTest.java b/app/save-and-restore/ui/src/test/java/org/phoebus/applications/saveandrestore/UtilitiesTest.java
index 7e7ad1918e..08b95a31a6 100644
--- a/app/save-and-restore/ui/src/test/java/org/phoebus/applications/saveandrestore/UtilitiesTest.java
+++ b/app/save-and-restore/ui/src/test/java/org/phoebus/applications/saveandrestore/UtilitiesTest.java
@@ -24,7 +24,6 @@
import org.epics.util.array.ArrayUShort;
import org.epics.util.array.ListBoolean;
import org.epics.util.array.ListLong;
-import org.epics.util.array.ListNumber;
import org.epics.vtype.Alarm;
import org.epics.vtype.AlarmSeverity;
import org.epics.vtype.AlarmStatus;
@@ -64,10 +63,16 @@
import java.time.temporal.ChronoUnit;
import java.util.Arrays;
-import java.util.List;
import java.util.Optional;
-import static org.junit.Assert.*;
+import static org.junit.Assert.assertArrayEquals;
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertFalse;
+import static org.junit.Assert.assertNotEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.junit.Assert.assertNull;
+import static org.junit.Assert.assertTrue;
+import static org.junit.Assert.fail;
public class UtilitiesTest {
@@ -86,90 +91,90 @@ public void testValueToString() {
String result = Utilities.valueToString(val);
assertEquals("5.0", result);
- val = VFloat.of(5f,alarm,time,display);
+ val = VFloat.of(5f, alarm, time, display);
result = Utilities.valueToString(val);
assertEquals("5.0", result);
- val = VLong.of(5L,alarm,time,display);
+ val = VLong.of(5L, alarm, time, display);
result = Utilities.valueToString(val);
assertEquals("5", result);
- val = VInt.of(5,alarm,time,display);
+ val = VInt.of(5, alarm, time, display);
result = Utilities.valueToString(val);
assertEquals("5", result);
- val = VShort.of((short)5,alarm,time,display);
+ val = VShort.of((short) 5, alarm, time, display);
result = Utilities.valueToString(val);
assertEquals("5", result);
- val = VByte.of((byte)5,alarm,time,display);
+ val = VByte.of((byte) 5, alarm, time, display);
result = Utilities.valueToString(val);
assertEquals("5", result);
- val = VEnum.of(1, EnumDisplay.of("first", "second", "third"),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("first", "second", "third"), alarm, time);
result = Utilities.valueToString(val);
assertEquals("second", result);
- val = VEnum.of(1, EnumDisplay.of("", "", ""),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("", "", ""), alarm, time);
result = Utilities.valueToString(val);
assertEquals("1", result);
- val = VEnum.of(1, EnumDisplay.of("a", "", ""),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("a", "", ""), alarm, time);
result = Utilities.valueToString(val);
assertEquals("", result);
- val = VString.of("third",alarm, time);
+ val = VString.of("third", alarm, time);
result = Utilities.valueToString(val);
assertEquals("third", result);
- val = VDoubleArray.of(ArrayDouble.of(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VDoubleArray.of(ArrayDouble.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
result = Utilities.valueToString(val);
assertEquals("[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0,...]", result);
- val = VFloatArray.of(ArrayFloat.of(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VFloatArray.of(ArrayFloat.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
result = Utilities.valueToString(val);
assertEquals("[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0,...]", result);
- result = Utilities.valueToString(val,3);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1.0, 2.0, 3.0,...]", result);
- result = Utilities.valueToString(val,100);
+ result = Utilities.valueToString(val, 100);
assertEquals("[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]", result);
- val = VLongArray.of(ArrayLong.of(1,2,3,4,5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VLongArray.of(ArrayLong.of(1, 2, 3, 4, 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VULongArray.of(ArrayULong.of(1,2,3,4,5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VULongArray.of(ArrayULong.of(1, 2, 3, 4, 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VIntArray.of(ArrayInteger.of(1,2,3,4,5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VIntArray.of(ArrayInteger.of(1, 2, 3, 4, 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VUIntArray.of(ArrayUInteger.of(1,2,3,4,5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VUIntArray.of(ArrayUInteger.of(1, 2, 3, 4, 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VShortArray.of(ArrayShort.of((short)1,(short)2,(short)3,(short)4,(short)5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VShortArray.of(ArrayShort.of((short) 1, (short) 2, (short) 3, (short) 4, (short) 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VUShortArray.of(ArrayUShort.of((short)1,(short)2,(short)3,(short)4,(short)5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VUShortArray.of(ArrayUShort.of((short) 1, (short) 2, (short) 3, (short) 4, (short) 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VByteArray.of(ArrayByte.of((byte)1,(byte)2,(byte)3,(byte)4,(byte)5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VByteArray.of(ArrayByte.of((byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VUByteArray.of(ArrayUByte.of((byte)1,(byte)2,(byte)3,(byte)4,(byte)5),alarm,time,display);
- result = Utilities.valueToString(val,3);
+ val = VUByteArray.of(ArrayUByte.of((byte) 1, (byte) 2, (byte) 3, (byte) 4, (byte) 5), alarm, time, display);
+ result = Utilities.valueToString(val, 3);
assertEquals("[1, 2, 3,...]", result);
- val = VIntArray.of(ArrayInteger.of(1,2,3,4,5),alarm,time,display);
- result = Utilities.valueToString(val,0);
+ val = VIntArray.of(ArrayInteger.of(1, 2, 3, 4, 5), alarm, time, display);
+ result = Utilities.valueToString(val, 0);
assertEquals("[]", result);
val = VBoolean.of(true, alarm, time);
@@ -191,154 +196,154 @@ public void testValueFromString() {
Display display = Display.none();
Time time = Time.now();
- VType val = VDouble.of(5d,alarm,time,display);
+ VType val = VDouble.of(5d, alarm, time, display);
VType result = Utilities.valueFromString("5.0", val);
assertTrue(result instanceof VDouble);
- assertEquals(5.0, ((VDouble)result).getValue().doubleValue(),0);
+ assertEquals(5.0, ((VDouble) result).getValue().doubleValue(), 0);
result = Utilities.valueFromString("", val);
assertTrue(result instanceof VDouble);
- assertEquals(5.0, ((VDouble)result).getValue().doubleValue(),0);
+ assertEquals(5.0, ((VDouble) result).getValue().doubleValue(), 0);
- val = VFloat.of(5f,alarm,time,display);
+ val = VFloat.of(5f, alarm, time, display);
result = Utilities.valueFromString("5.0", val);
assertTrue(result instanceof VFloat);
- assertEquals(5.0f, ((VFloat)result).getValue().floatValue(),0);
+ assertEquals(5.0f, ((VFloat) result).getValue().floatValue(), 0);
- val = VLong.of(5L,alarm,time,display);
+ val = VLong.of(5L, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VLong);
- assertEquals(5L, ((VLong)result).getValue().longValue());
+ assertEquals(5L, ((VLong) result).getValue().longValue());
- val = VULong.of(5L,alarm,time,display);
+ val = VULong.of(5L, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VULong);
- assertEquals(5L, ((VULong)result).getValue().longValue());
+ assertEquals(5L, ((VULong) result).getValue().longValue());
- val = VUInt.of(5,alarm,time,display);
+ val = VUInt.of(5, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VUInt);
- assertEquals(5, ((VUInt)result).getValue().intValue());
+ assertEquals(5, ((VUInt) result).getValue().intValue());
- val = VInt.of(5,alarm,time,display);
+ val = VInt.of(5, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VInt);
- assertEquals(5, ((VInt)result).getValue().intValue());
+ assertEquals(5, ((VInt) result).getValue().intValue());
- val = VShort.of((short)5,alarm,time,display);
+ val = VShort.of((short) 5, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VShort);
- assertEquals((short)5, ((VShort)result).getValue().shortValue());
+ assertEquals((short) 5, ((VShort) result).getValue().shortValue());
- val = VUShort.of((short)5,alarm,time,display);
+ val = VUShort.of((short) 5, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VUShort);
- assertEquals((short)5, ((VUShort)result).getValue().shortValue());
+ assertEquals((short) 5, ((VUShort) result).getValue().shortValue());
- val = VByte.of((byte)5,alarm,time,display);
+ val = VByte.of((byte) 5, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VByte);
- assertEquals((byte)5, ((VByte)result).getValue().byteValue());
+ assertEquals((byte) 5, ((VByte) result).getValue().byteValue());
- val = VUByte.of((byte)5,alarm,time,display);
+ val = VUByte.of((byte) 5, alarm, time, display);
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VUByte);
- assertEquals((byte)5, ((VUByte)result).getValue().byteValue());
+ assertEquals((byte) 5, ((VUByte) result).getValue().byteValue());
- val = VEnum.of(1, EnumDisplay.of("first", "second", "third"),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("first", "second", "third"), alarm, time);
result = Utilities.valueFromString("second", val);
assertTrue(result instanceof VEnum);
- assertEquals("second", ((VEnum)result).getValue());
+ assertEquals("second", ((VEnum) result).getValue());
- val = VEnum.of(1, EnumDisplay.of("first", "second", "third"),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("first", "second", "third"), alarm, time);
try {
Utilities.valueFromString("invalid", val);
fail("Should throw exception");
} catch (IllegalArgumentException e) {
}
- val = VBoolean.of(false,alarm, time);
+ val = VBoolean.of(false, alarm, time);
result = Utilities.valueFromString("false", val);
assertTrue(result instanceof VBoolean);
- assertEquals(false, ((VBoolean)result).getValue());
+ assertEquals(false, ((VBoolean) result).getValue());
- val = VString.of("third",alarm, time);
+ val = VString.of("third", alarm, time);
result = Utilities.valueFromString("third", val);
assertTrue(result instanceof VString);
- assertEquals("third", ((VString)result).getValue());
+ assertEquals("third", ((VString) result).getValue());
try {
- val = VDoubleArray.of(ArrayDouble.of(1,2,3,4,5,6,7,8,9,0,1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VDoubleArray.of(ArrayDouble.of(1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
Utilities.valueFromString("[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 0.0, 1.0, 2.0, 3.0, 4.0, 5.0,...]", val);
fail("Exception should happen, because the number of elements is wrong");
} catch (IllegalArgumentException e) {
assertNotNull(e.getMessage());
}
- val = VDoubleArray.of(ArrayDouble.of(1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VDoubleArray.of(ArrayDouble.of(1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
result = Utilities.valueFromString("[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]", val);
- assertEquals(((VDoubleArray)result).getData(), ((VDoubleArray)val).getData());
+ assertEquals(((VDoubleArray) result).getData(), ((VDoubleArray) val).getData());
- val = VFloatArray.of(ArrayFloat.of(1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VFloatArray.of(ArrayFloat.of(1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
result = Utilities.valueFromString("[1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0]", val);
- assertEquals(((VFloatArray)result).getData(), ((VFloatArray)val).getData());
+ assertEquals(((VFloatArray) result).getData(), ((VFloatArray) val).getData());
- val = VULongArray.of(ArrayULong.of(1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VULongArray.of(ArrayULong.of(1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
result = Utilities.valueFromString("[1, 2, 3, 4, 5, 6, 7, 8, 9]", val);
- assertEquals(((VULongArray)result).getData(), ((VULongArray)val).getData());
+ assertEquals(((VULongArray) result).getData(), ((VULongArray) val).getData());
- val = VUIntArray.of(ArrayUInteger.of(1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VUIntArray.of(ArrayUInteger.of(1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
result = Utilities.valueFromString("[1, 2, 3, 4, 5, 6, 7, 8, 9]", val);
- assertEquals(((VUIntArray)result).getData(), ((VUIntArray)val).getData());
+ assertEquals(((VUIntArray) result).getData(), ((VUIntArray) val).getData());
- val = VIntArray.of(ArrayInteger.of(1,2,3,4,5,6,7,8,9),alarm,time,display);
+ val = VIntArray.of(ArrayInteger.of(1, 2, 3, 4, 5, 6, 7, 8, 9), alarm, time, display);
result = Utilities.valueFromString("[1, 2, 3, 4, 5, 6, 7, 8, 9]", val);
- assertEquals(((VIntArray)result).getData(), ((VIntArray)val).getData());
+ assertEquals(((VIntArray) result).getData(), ((VIntArray) val).getData());
- val = VShortArray.of(ArrayShort.of((short)1, (short)2, (short)3),alarm,time,display);
+ val = VShortArray.of(ArrayShort.of((short) 1, (short) 2, (short) 3), alarm, time, display);
result = Utilities.valueFromString("[1, 2, 3]", val);
- assertEquals(((VShortArray)result).getData(), ((VShortArray)val).getData());
+ assertEquals(((VShortArray) result).getData(), ((VShortArray) val).getData());
- val = VUShortArray.of(ArrayUShort.of((short)1, (short)2, (short)3),alarm,time,display);
+ val = VUShortArray.of(ArrayUShort.of((short) 1, (short) 2, (short) 3), alarm, time, display);
result = Utilities.valueFromString("[1, 2, 3]", val);
- assertEquals(((VUShortArray)result).getData(), ((VUShortArray)val).getData());
+ assertEquals(((VUShortArray) result).getData(), ((VUShortArray) val).getData());
- val = VByteArray.of(ArrayByte.of((byte)1, (byte)2, (byte)3),alarm,time,display);
+ val = VByteArray.of(ArrayByte.of((byte) 1, (byte) 2, (byte) 3), alarm, time, display);
result = Utilities.valueFromString("[1, 2, 3]", val);
- assertEquals(((VByteArray)result).getData(), ((VByteArray)val).getData());
+ assertEquals(((VByteArray) result).getData(), ((VByteArray) val).getData());
- val = VUByteArray.of(ArrayUByte.of((byte)1, (byte)2, (byte)3),alarm,time,display);
+ val = VUByteArray.of(ArrayUByte.of((byte) 1, (byte) 2, (byte) 3), alarm, time, display);
result = Utilities.valueFromString("[1, 2, 3]", val);
- assertEquals(((VUByteArray)result).getData(), ((VUByteArray)val).getData());
+ assertEquals(((VUByteArray) result).getData(), ((VUByteArray) val).getData());
- val = VStringArray.of(Arrays.asList("first", "second", "third"),alarm, time);
+ val = VStringArray.of(Arrays.asList("first", "second", "third"), alarm, time);
result = Utilities.valueFromString("[\"first\", \"second\", \"third\"]", val);
assertTrue(result instanceof VStringArray);
- assertArrayEquals(new String[]{"first","second","third"}, ((VStringArray)result).getData().toArray(new String[0]));
+ assertArrayEquals(new String[]{"first", "second", "third"}, ((VStringArray) result).getData().toArray(new String[0]));
- val = VLongArray.of(ArrayLong.of(1,2,3,4,5),alarm,time,display);
+ val = VLongArray.of(ArrayLong.of(1, 2, 3, 4, 5), alarm, time, display);
result = Utilities.valueFromString("1, 2, 3, 4, 5", val);
assertTrue(result instanceof VLongArray);
- assertTrue(((VLongArray)result).getData() instanceof ListLong);
+ assertTrue(((VLongArray) result).getData() instanceof ListLong);
- val = VBooleanArray.of(ArrayBoolean.of(true,true,false,true),alarm,time);
+ val = VBooleanArray.of(ArrayBoolean.of(true, true, false, true), alarm, time);
result = Utilities.valueFromString("[1, 1, 0, 2]", val);
assertTrue(result instanceof VBooleanArray);
- assertTrue(((VBooleanArray)result).getData() instanceof ListBoolean);
+ assertTrue(((VBooleanArray) result).getData() instanceof ListBoolean);
val = VDisconnectedData.INSTANCE;
result = Utilities.valueFromString("5", val);
assertTrue(result instanceof VLong);
- assertEquals(5L, ((VLong)result).getValue().longValue());
+ assertEquals(5L, ((VLong) result).getValue().longValue());
result = Utilities.valueFromString("5.1", val);
assertTrue(result instanceof VDouble);
- assertEquals(5.1, ((VDouble)result).getValue().doubleValue(), 0);
+ assertEquals(5.1, ((VDouble) result).getValue().doubleValue(), 0);
result = Utilities.valueFromString("string", val);
assertTrue(result instanceof VString);
- assertEquals("string", ((VString)result).getValue());
+ assertEquals("string", ((VString) result).getValue());
}
/**
@@ -352,58 +357,58 @@ public void testToRawValue() {
assertNull(Utilities.toRawValue(null));
- VType val = VDouble.of(5d,alarm,time,display);
+ VType val = VDouble.of(5d, alarm, time, display);
Object d = Utilities.toRawValue(val);
assertTrue(d instanceof Double);
- assertEquals(5.0,d);
+ assertEquals(5.0, d);
- val = VFloat.of(5f,alarm,time,display);
+ val = VFloat.of(5f, alarm, time, display);
d = Utilities.toRawValue(val);
assertTrue(d instanceof Float);
- assertEquals(5.0f,d);
+ assertEquals(5.0f, d);
- val = VLong.of(5L,alarm,time,display);
+ val = VLong.of(5L, alarm, time, display);
d = Utilities.toRawValue(val);
assertTrue(d instanceof Long);
- assertEquals(5L,d);
+ assertEquals(5L, d);
- val = VInt.of(5,alarm,time,display);
+ val = VInt.of(5, alarm, time, display);
d = Utilities.toRawValue(val);
assertTrue(d instanceof Integer);
- assertEquals(5,d);
+ assertEquals(5, d);
- val = VShort.of((short)5,alarm,time,display);
+ val = VShort.of((short) 5, alarm, time, display);
d = Utilities.toRawValue(val);
assertTrue(d instanceof Short);
- assertEquals((short)5,d);
+ assertEquals((short) 5, d);
- val = VByte.of((byte)5,alarm,time,display);
+ val = VByte.of((byte) 5, alarm, time, display);
d = Utilities.toRawValue(val);
assertTrue(d instanceof Byte);
- assertEquals((byte)5,d);
+ assertEquals((byte) 5, d);
- val = VEnum.of(1, EnumDisplay.of("first", "second", "third"),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("first", "second", "third"), alarm, time);
d = Utilities.toRawValue(val);
assertTrue(d instanceof String);
- assertEquals("second",d);
+ assertEquals("second", d);
- val = VEnum.of(1, EnumDisplay.of("", "", ""),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("", "", ""), alarm, time);
d = Utilities.toRawValue(val);
assertTrue(d instanceof String);
assertEquals("1", d);
- val = VEnum.of(1, EnumDisplay.of("a", "", ""),alarm, time);
+ val = VEnum.of(1, EnumDisplay.of("a", "", ""), alarm, time);
d = Utilities.toRawValue(val);
assertTrue(d instanceof String);
assertEquals("", d);
- val = VString.of("third",alarm, time);
+ val = VString.of("third", alarm, time);
d = Utilities.toRawValue(val);
assertTrue(d instanceof String);
- assertEquals("third",d);
+ assertEquals("third", d);
- ArrayDouble arrayDouble = ArrayDouble.of(1,2,3,4,5);
- val = VDoubleArray.of(arrayDouble,alarm,time,display);
+ ArrayDouble arrayDouble = ArrayDouble.of(1, 2, 3, 4, 5);
+ val = VDoubleArray.of(arrayDouble, alarm, time, display);
d = Utilities.toRawValue(val);
assertTrue(d instanceof double[]);
for (int i = 0; i < ((double[]) d).length; i++) {
@@ -417,25 +422,24 @@ public void testToRawValue() {
val = VBooleanArray.of(ArrayBoolean.of(true, false, true), alarm, time);
d = Utilities.toRawValue(val);
assertTrue(d instanceof boolean[]);
- assertTrue(((boolean[])d)[0]);
- assertFalse(((boolean[])d)[1]);
+ assertTrue(((boolean[]) d)[0]);
+ assertFalse(((boolean[]) d)[1]);
val = VEnumArray.of(ArrayInteger.of(0, 1, 2, 3, 4), EnumDisplay.of("a", "b", "c", "d", "e"), alarm, time);
d = Utilities.toRawValue(val);
assertTrue(d instanceof String[]);
- assertEquals("a", ((String[])d)[0]);
- assertEquals("e", ((String[])d)[4]);
+ assertEquals("a", ((String[]) d)[0]);
+ assertEquals("e", ((String[]) d)[4]);
val = VBoolean.of(true, alarm, time);
d = Utilities.toRawValue(val);
assertTrue(d instanceof Boolean);
- assertTrue(((Boolean)d));
+ assertTrue(((Boolean) d));
assertNull(Utilities.toRawValue(VDisconnectedData.INSTANCE));
}
-
/**
* Tests {@link Utilities#valueToCompareString(VType, VType, Optional)}. The test doesn't cover all possible
* combinations, but it does cover a handful of them.
@@ -446,355 +450,404 @@ public void testValueToCompareString() {
Display display = Display.none();
Time time = Time.now();
- Optional> threshold = Optional.of(new Threshold<>(5d,-5d));
+ Optional> threshold = Optional.of(new Threshold<>(5d, -5d));
Utilities.VTypeComparison result = Utilities.valueToCompareString(null, null, threshold);
assertEquals(VDisconnectedData.INSTANCE.toString(), result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals("---", result.getString());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- VType val1 = VDouble.of(5d,alarm,time,display);
+ VType val1 = VDouble.of(5d, alarm, time, display);
result = Utilities.valueToCompareString(null, val1, threshold);
assertEquals(VDisconnectedData.INSTANCE.toString(), result.getString());
assertEquals(-1, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
+ assertEquals("---", result.getString());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
result = Utilities.valueToCompareString(val1, null, threshold);
assertEquals("5.0", result.getString());
assertEquals(1, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
result = Utilities.valueToCompareString(VDisconnectedData.INSTANCE, val1, threshold);
assertEquals(VDisconnectedData.INSTANCE.toString(), result.getString());
assertEquals(-1, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
+ assertEquals("---", result.getString());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
result = Utilities.valueToCompareString(val1, VDisconnectedData.INSTANCE, threshold);
assertEquals("5.0", result.getString());
assertEquals(1, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VDouble.of(5d,alarm,time,display);
- VType val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VDouble.of(5d, alarm, time, display);
+ VType val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("15 \u0394+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VFloat.of(15f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(15f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("15 \u0394+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VDouble.of(6d,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VDouble.of(6d, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u03940.0", result.getString());
- assertEquals(0,result.getValuesEqual());
+ assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VFloat.of(5f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(5f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VFloat.of(5f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(5f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("5 \u0394-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VFloat.of(5f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(5f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("5 \u0394-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VLong.of(15L,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VLong.of(15L, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("15 \u0394+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VLong.of(15L,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VLong.of(15L, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("15 \u0394+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VULong.of(15L,alarm,time,display);
- val2 = VULong.of(6L,alarm,time,display);
+ val1 = VULong.of(15L, alarm, time, display);
+ val2 = VULong.of(6L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("15 \u0394+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VULong.of(5L,alarm,time,display);
- val2 = VULong.of(6L,alarm,time,display);
+ val1 = VULong.of(5L, alarm, time, display);
+ val2 = VULong.of(6L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VUInt.of(15,alarm,time,display);
- val2 = VUInt.of(6,alarm,time,display);
+ val1 = VUInt.of(15, alarm, time, display);
+ val2 = VUInt.of(6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("15 \u0394+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VUInt.of(15,alarm,time,display);
- val2 = VUInt.of(6,alarm,time,display);
+ val1 = VUInt.of(15, alarm, time, display);
+ val2 = VUInt.of(6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("15 \u0394+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VInt.of(15,alarm,time,display);
- val2 = VInt.of(6,alarm,time,display);
+ val1 = VInt.of(15, alarm, time, display);
+ val2 = VInt.of(6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("15 \u0394+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VLong.of(6L,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("15 \u0394+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VLong.of(6L,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("15 \u0394+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(9, result.getAbsoluteDelta(), 0.0);
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VLong.of(15L,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VLong.of(15L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("15 \u03940.0", result.getString());
- assertEquals(0,result.getValuesEqual());
+ assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VString.of("first",alarm,time);
- val2 = VLong.of(15L,alarm,time,display);
+ val1 = VString.of("first", alarm, time);
+ val2 = VLong.of(15L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("first", result.getString());
assertNotEquals(0, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VDoubleArray.of(ArrayDouble.of(1,2,3),alarm,time,display);
- val2 = VDoubleArray.of(ArrayDouble.of(1,2,3),alarm,time,display);
+ val1 = VDoubleArray.of(ArrayDouble.of(1, 2, 3), alarm, time, display);
+ val2 = VDoubleArray.of(ArrayDouble.of(1, 2, 3), alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("[1.0, 2.0, 3.0]", result.getString());
- assertEquals(0,result.getValuesEqual());
+ assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VDoubleArray.of(ArrayDouble.of(1,2,3),alarm,time,display);
- val2 = VLongArray.of(ArrayLong.of(1,2,3),alarm,time,display);
+ val1 = VDoubleArray.of(ArrayDouble.of(1, 2, 3), alarm, time, display);
+ val2 = VLongArray.of(ArrayLong.of(1, 2, 3), alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("[1.0, 2.0, 3.0]", result.getString());
assertNotEquals(0, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
//compare long values: equal, first less than second, second less than first
- val1 = VLong.of(6L,alarm,time,display);
- val2 = VLong.of(6L,alarm,time, display);
+ val1 = VLong.of(6L, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u03940", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VLong.of(5L,alarm,time,display);
- val2 = VLong.of(6L,alarm,time, display);
+ val1 = VLong.of(5L, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VLong.of(6L,alarm,time,display);
- val2 = VLong.of(5L,alarm,time, display);
+ val1 = VLong.of(6L, alarm, time, display);
+ val2 = VLong.of(5L, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
//compare int values: equal, first less than second, second less than first
- val1 = VInt.of(6,alarm,time,display);
- val2 = VInt.of(6,alarm,time, display);
+ val1 = VInt.of(6, alarm, time, display);
+ val2 = VInt.of(6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u03940", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VInt.of(5,alarm,time,display);
- val2 = VInt.of(6,alarm,time, display);
+ val1 = VInt.of(5, alarm, time, display);
+ val2 = VInt.of(6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VInt.of(6,alarm,time,display);
- val2 = VInt.of(5,alarm,time, display);
+ val1 = VInt.of(6, alarm, time, display);
+ val2 = VInt.of(5, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
//compare short values: equal, first less than second, second less than first
- val1 = VShort.of((short)6,alarm,time,display);
- val2 = VShort.of((short)6,alarm,time, display);
+ val1 = VShort.of((short) 6, alarm, time, display);
+ val2 = VShort.of((short) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u03940", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VShort.of((short)5,alarm,time,display);
- val2 = VShort.of((short)6,alarm,time, display);
+ val1 = VShort.of((short) 5, alarm, time, display);
+ val2 = VShort.of((short) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VShort.of((short)6,alarm,time,display);
- val2 = VShort.of((short)5,alarm,time, display);
+ val1 = VShort.of((short) 6, alarm, time, display);
+ val2 = VShort.of((short) 5, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VUShort.of((short)6,alarm,time,display);
- val2 = VUShort.of((short)5,alarm,time, display);
+ val1 = VUShort.of((short) 6, alarm, time, display);
+ val2 = VUShort.of((short) 5, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VUShort.of((short)6,alarm,time,display);
- val2 = VUShort.of((short)6,alarm,time, display);
+ val1 = VUShort.of((short) 6, alarm, time, display);
+ val2 = VUShort.of((short) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u03940", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VUShort.of((short)5,alarm,time,display);
- val2 = VUShort.of((short)6,alarm,time, display);
+ val1 = VUShort.of((short) 5, alarm, time, display);
+ val2 = VUShort.of((short) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VShort.of((short)5,alarm,time,display);
- val2 = VShort.of((short)6,alarm,time, display);
+ val1 = VShort.of((short) 5, alarm, time, display);
+ val2 = VShort.of((short) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VUShort.of((short)5,alarm,time,display);
- val2 = VUShort.of((short)6,alarm,time, display);
+ val1 = VUShort.of((short) 5, alarm, time, display);
+ val2 = VUShort.of((short) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
//compare enum values: equal, first less than second, second less than first
- EnumDisplay labels = EnumDisplay.of("val1","val2","val3");
+ EnumDisplay labels = EnumDisplay.of("val1", "val2", "val3");
- val1 = VEnum.of(1,labels,alarm,time);
- val2 = VEnum.of(1,labels,alarm,time);
+ val1 = VEnum.of(1, labels, alarm, time);
+ val2 = VEnum.of(1, labels, alarm, time);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("val2", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VEnum.of(1,labels,alarm,time);
- val2 = VEnum.of(2,labels,alarm,time);
+ val1 = VEnum.of(1, labels, alarm, time);
+ val2 = VEnum.of(2, labels, alarm, time);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("val2", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VEnum.of(2,labels,alarm,time);
- val2 = VEnum.of(1,labels,alarm,time);
+ val1 = VEnum.of(2, labels, alarm, time);
+ val2 = VEnum.of(1, labels, alarm, time);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("val3", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VByte.of((byte)5,alarm,time,display);
- val2 = VByte.of((byte)6,alarm,time, display);
+ val1 = VByte.of((byte) 5, alarm, time, display);
+ val2 = VByte.of((byte) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VByte.of((byte)6,alarm,time,display);
- val2 = VByte.of((byte)5,alarm,time, display);
+ val1 = VByte.of((byte) 6, alarm, time, display);
+ val2 = VByte.of((byte) 5, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VByte.of((byte)6,alarm,time,display);
- val2 = VByte.of((byte)5,alarm,time, display);
+ val1 = VByte.of((byte) 6, alarm, time, display);
+ val2 = VByte.of((byte) 5, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VUByte.of((byte)5,alarm,time,display);
- val2 = VUByte.of((byte)6,alarm,time, display);
+ val1 = VUByte.of((byte) 5, alarm, time, display);
+ val2 = VUByte.of((byte) 6, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("5 \u0394-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VUByte.of((byte)6,alarm,time,display);
- val2 = VUByte.of((byte)5,alarm,time, display);
+ val1 = VUByte.of((byte) 6, alarm, time, display);
+ val2 = VUByte.of((byte) 5, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, threshold);
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
- val1 = VUByte.of((byte)6,alarm,time,display);
- val2 = VUByte.of((byte)5,alarm,time, display);
+ val1 = VUByte.of((byte) 6, alarm, time, display);
+ val2 = VUByte.of((byte) 5, alarm, time, display);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("6 \u0394+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(1, result.getAbsoluteDelta(), 0.0);
- val1 = VBoolean.of(false,alarm,time);
- val2 = VBoolean.of(false,alarm,time);
+ val1 = VBoolean.of(false, alarm, time);
+ val2 = VBoolean.of(false, alarm, time);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("false", result.getString());
assertTrue(result.getValuesEqual() == 0);
assertTrue(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
- val1 = VString.of("a", alarm,time);
- val2 = VString.of("b", alarm,time);
+ val1 = VString.of("a", alarm, time);
+ val2 = VString.of("b", alarm, time);
result = Utilities.valueToCompareString(val1, val2, Optional.empty());
assertEquals("a", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
+ assertEquals(0, result.getAbsoluteDelta(), 0.0);
}
/**
@@ -809,8 +862,8 @@ public void testVTypesIdentical() {
Display display = Display.none();
Time time = Time.now();
Time time2 = Time.of(time.getTimestamp().plus(1, ChronoUnit.SECONDS));
- VType val1 = VDouble.of(5d,alarm,time,display);
- VType val2 = VDouble.of(6d,alarm2,time2,display);
+ VType val1 = VDouble.of(5d, alarm, time, display);
+ VType val2 = VDouble.of(6d, alarm2, time2, display);
assertTrue(Utilities.areVTypesIdentical(null, null, false));
assertFalse(Utilities.areVTypesIdentical(null, val1, false));
@@ -818,129 +871,129 @@ public void testVTypesIdentical() {
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val2 = VDouble.of(5d,alarm2,time,display);
+ val2 = VDouble.of(5d, alarm2, time, display);
assertTrue(Utilities.areVTypesIdentical(val1, val2, true));
assertTrue(Utilities.areVTypesIdentical(val1, val2, false));
- val2 = VDouble.of(5d,Alarm.none(),time,display);
+ val2 = VDouble.of(5d, Alarm.none(), time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertTrue(Utilities.areVTypesIdentical(val1, val2, false));
- val2 = VDouble.of(5d,alarm2,time2,display);
+ val2 = VDouble.of(5d, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertTrue(Utilities.areVTypesIdentical(val1, val2, false));
- val2 = VLong.of(5L,alarm2,time,display);
+ val2 = VLong.of(5L, alarm2, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VFloat.of(5f,alarm,time,display);
- val2 = VFloat.of(6d,alarm2,time2,display);
+ val1 = VFloat.of(5f, alarm, time, display);
+ val2 = VFloat.of(6d, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VULong.of(5L,alarm,time,display);
- val2 = VULong.of(6L,alarm2,time2,display);
+ val1 = VULong.of(5L, alarm, time, display);
+ val2 = VULong.of(6L, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VLong.of(5L,alarm,time,display);
- val2 = VLong.of(6L,alarm2,time2,display);
+ val1 = VLong.of(5L, alarm, time, display);
+ val2 = VLong.of(6L, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VUInt.of(5,alarm,time,display);
- val2 = VUInt.of(6,alarm2,time2,display);
+ val1 = VUInt.of(5, alarm, time, display);
+ val2 = VUInt.of(6, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VInt.of(5,alarm,time,display);
- val2 = VInt.of(6,alarm2,time2,display);
+ val1 = VInt.of(5, alarm, time, display);
+ val2 = VInt.of(6, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VUShort.of((short)5,alarm,time,display);
- val2 = VUShort.of((short)6,alarm2,time2,display);
+ val1 = VUShort.of((short) 5, alarm, time, display);
+ val2 = VUShort.of((short) 6, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VShort.of((short)5,alarm,time,display);
- val2 = VShort.of((short)6,alarm2,time2,display);
+ val1 = VShort.of((short) 5, alarm, time, display);
+ val2 = VShort.of((short) 6, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VUByte.of((byte)5,alarm,time,display);
- val2 = VUByte.of((byte)6,alarm2,time2,display);
+ val1 = VUByte.of((byte) 5, alarm, time, display);
+ val2 = VUByte.of((byte) 6, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VByte.of((byte)5,alarm,time,display);
- val2 = VByte.of((byte)6,alarm2,time2,display);
+ val1 = VByte.of((byte) 5, alarm, time, display);
+ val2 = VByte.of((byte) 6, alarm2, time2, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VBoolean.of(true,alarm,time);
- val2 = VBoolean.of(false,alarm2,time2);
+ val1 = VBoolean.of(true, alarm, time);
+ val2 = VBoolean.of(false, alarm2, time2);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- val1 = VEnum.of(1, EnumDisplay.of("a", "b", "c"), alarm,time);
- val2 = VEnum.of(2, EnumDisplay.of("a", "b", "c"),alarm2,time2);
+ val1 = VEnum.of(1, EnumDisplay.of("a", "b", "c"), alarm, time);
+ val2 = VEnum.of(2, EnumDisplay.of("a", "b", "c"), alarm2, time2);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val1, val2, false));
- VType val3 = VEnum.of(1, EnumDisplay.of("a", "b", "c"),alarm,time);
+ VType val3 = VEnum.of(1, EnumDisplay.of("a", "b", "c"), alarm, time);
assertTrue(Utilities.areVTypesIdentical(val1, val3, true));
- val1 = VDoubleArray.of(ArrayDouble.of(1,2,3),alarm,time,display);
- val2 = VDoubleArray.of(ArrayDouble.of(1,2,3),alarm,time,display);
+ val1 = VDoubleArray.of(ArrayDouble.of(1, 2, 3), alarm, time, display);
+ val2 = VDoubleArray.of(ArrayDouble.of(1, 2, 3), alarm, time, display);
assertTrue(Utilities.areVTypesIdentical(val1, val2, true));
assertTrue(Utilities.areVTypesIdentical(val1, val2, false));
- val2 = VDoubleArray.of(ArrayDouble.of(1,2,3,4),alarm,time,display);
+ val2 = VDoubleArray.of(ArrayDouble.of(1, 2, 3, 4), alarm, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
- val2 = VDoubleArray.of(ArrayDouble.of(1,2,4),alarm,time,display);
+ val2 = VDoubleArray.of(ArrayDouble.of(1, 2, 4), alarm, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
- val1 = VLongArray.of(ArrayLong.of(1,2,3),alarm,time,display);
- val2 = VLongArray.of(ArrayLong.of(1,2,3),alarm,time,display);
+ val1 = VLongArray.of(ArrayLong.of(1, 2, 3), alarm, time, display);
+ val2 = VLongArray.of(ArrayLong.of(1, 2, 3), alarm, time, display);
assertTrue(Utilities.areVTypesIdentical(val1, val2, true));
assertTrue(Utilities.areVTypesIdentical(val1, val2, false));
- val2 = VLongArray.of(ArrayLong.of(1,2,3,4),alarm,time,display);
+ val2 = VLongArray.of(ArrayLong.of(1, 2, 3, 4), alarm, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
- val2 = VLongArray.of(ArrayLong.of(1,2,4),alarm,time,display);
+ val2 = VLongArray.of(ArrayLong.of(1, 2, 4), alarm, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
- val1 = VULongArray.of(ArrayULong.of(1,2,3),alarm,time,display);
- val2 = VULongArray.of(ArrayULong.of(1,2,3),alarm,time,display);
+ val1 = VULongArray.of(ArrayULong.of(1, 2, 3), alarm, time, display);
+ val2 = VULongArray.of(ArrayULong.of(1, 2, 3), alarm, time, display);
assertTrue(Utilities.areVTypesIdentical(val1, val2, true));
assertTrue(Utilities.areVTypesIdentical(val1, val2, false));
- val2 = VULongArray.of(ArrayULong.of(1,2,3,4),alarm,time,display);
+ val2 = VULongArray.of(ArrayULong.of(1, 2, 3, 4), alarm, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
- val2 = VULongArray.of(ArrayULong.of(1,2,4),alarm,time,display);
+ val2 = VULongArray.of(ArrayULong.of(1, 2, 4), alarm, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
- val1 = VLongArray.of(ArrayLong.of(1,2,3),alarm,time,display);
+ val1 = VLongArray.of(ArrayLong.of(1, 2, 3), alarm, time, display);
val2 = VLong.of(10L, alarm, time, display);
assertFalse(Utilities.areVTypesIdentical(val1, val2, true));
assertFalse(Utilities.areVTypesIdentical(val2, val1, true));
}
@Test
- public void testDeltaValueToString(){
+ public void testDeltaValueToString() {
Alarm alarm = Alarm.none();
Display display = Display.none();
Time time = Time.now();
- Optional> threshold = Optional.of(new Threshold<>(5d,-5d));
+ Optional> threshold = Optional.of(new Threshold<>(5d, -5d));
- Utilities.VTypeComparison result = Utilities.deltaValueToString(null, null, threshold);
+ Utilities.VTypeComparison result = Utilities.deltaValueToString(null, null, threshold);
assertEquals(VDisconnectedData.INSTANCE.toString(), result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- VType val1 = VDouble.of(5d,alarm,time,display);
+ VType val1 = VDouble.of(5d, alarm, time, display);
result = Utilities.deltaValueToString(null, val1, threshold);
assertEquals(VDisconnectedData.INSTANCE.toString(), result.getString());
assertEquals(-1, result.getValuesEqual());
@@ -961,324 +1014,324 @@ public void testDeltaValueToString(){
assertEquals(1, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
- val1 = VDouble.of(5d,alarm,time,display);
- VType val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VDouble.of(5d, alarm, time, display);
+ VType val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VFloat.of(15f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(15f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VDouble.of(6d,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VDouble.of(6d, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("0.0", result.getString());
- assertEquals(0,result.getValuesEqual());
+ assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VFloat.of(5f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(5f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VFloat.of(5f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(5f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
- val1 = VFloat.of(5f,alarm,time,display);
- val2 = VFloat.of(6f,alarm,time,display);
+ val1 = VFloat.of(5f, alarm, time, display);
+ val2 = VFloat.of(6f, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("-1.0", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
- val1 = VLong.of(15L,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VLong.of(15L, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VLong.of(15L,alarm,time,display);
- val2 = VDouble.of(6d,alarm,time,display);
+ val1 = VLong.of(15L, alarm, time, display);
+ val2 = VDouble.of(6d, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VULong.of(15L,alarm,time,display);
- val2 = VULong.of(6L,alarm,time,display);
+ val1 = VULong.of(15L, alarm, time, display);
+ val2 = VULong.of(6L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VULong.of(5L,alarm,time,display);
- val2 = VULong.of(6L,alarm,time,display);
+ val1 = VULong.of(5L, alarm, time, display);
+ val2 = VULong.of(6L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
- val1 = VUInt.of(15,alarm,time,display);
- val2 = VUInt.of(6,alarm,time,display);
+ val1 = VUInt.of(15, alarm, time, display);
+ val2 = VUInt.of(6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VUInt.of(15,alarm,time,display);
- val2 = VUInt.of(6,alarm,time,display);
+ val1 = VUInt.of(15, alarm, time, display);
+ val2 = VUInt.of(6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VInt.of(15,alarm,time,display);
- val2 = VInt.of(6,alarm,time,display);
+ val1 = VInt.of(15, alarm, time, display);
+ val2 = VInt.of(6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("+9", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VLong.of(6L,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VLong.of(6L,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("+9.0", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VDouble.of(15d,alarm,time,display);
- val2 = VLong.of(15L,alarm,time,display);
+ val1 = VDouble.of(15d, alarm, time, display);
+ val2 = VLong.of(15L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("0.0", result.getString());
- assertEquals(0,result.getValuesEqual());
+ assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VString.of("first",alarm,time);
- val2 = VLong.of(15L,alarm,time,display);
+ val1 = VString.of("first", alarm, time);
+ val2 = VLong.of(15L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("first", result.getString());
assertNotEquals(0, result.getValuesEqual());
assertFalse(result.isWithinThreshold());
- val1 = VDoubleArray.of(ArrayDouble.of(1,2,3),alarm,time,display);
- val2 = VDoubleArray.of(ArrayDouble.of(1,2,3),alarm,time,display);
+ val1 = VDoubleArray.of(ArrayDouble.of(1, 2, 3), alarm, time, display);
+ val2 = VDoubleArray.of(ArrayDouble.of(1, 2, 3), alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("---", result.getString());
- assertEquals(0,result.getValuesEqual());
+ assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VBooleanArray.of(ArrayBoolean.of(true, false),alarm,time);
- val2 = VBooleanArray.of(ArrayBoolean.of(true, false),alarm,time);
+ val1 = VBooleanArray.of(ArrayBoolean.of(true, false), alarm, time);
+ val2 = VBooleanArray.of(ArrayBoolean.of(true, false), alarm, time);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("---", result.getString());
- assertEquals(0,result.getValuesEqual());
+ assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
//compare long values: equal, first less than second, second less than first
- val1 = VLong.of(6L,alarm,time,display);
- val2 = VLong.of(6L,alarm,time, display);
+ val1 = VLong.of(6L, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("0", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VLong.of(5L,alarm,time,display);
- val2 = VLong.of(6L,alarm,time, display);
+ val1 = VLong.of(5L, alarm, time, display);
+ val2 = VLong.of(6L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VLong.of(6L,alarm,time,display);
- val2 = VLong.of(5L,alarm,time, display);
+ val1 = VLong.of(6L, alarm, time, display);
+ val2 = VLong.of(5L, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
//compare int values: equal, first less than second, second less than first
- val1 = VInt.of(6,alarm,time,display);
- val2 = VInt.of(6,alarm,time, display);
+ val1 = VInt.of(6, alarm, time, display);
+ val2 = VInt.of(6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("0", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VInt.of(5,alarm,time,display);
- val2 = VInt.of(6,alarm,time, display);
+ val1 = VInt.of(5, alarm, time, display);
+ val2 = VInt.of(6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VInt.of(6,alarm,time,display);
- val2 = VInt.of(5,alarm,time, display);
+ val1 = VInt.of(6, alarm, time, display);
+ val2 = VInt.of(5, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
//compare short values: equal, first less than second, second less than first
- val1 = VShort.of((short)6,alarm,time,display);
- val2 = VShort.of((short)6,alarm,time, display);
+ val1 = VShort.of((short) 6, alarm, time, display);
+ val2 = VShort.of((short) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("0", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VShort.of((short)5,alarm,time,display);
- val2 = VShort.of((short)6,alarm,time, display);
+ val1 = VShort.of((short) 5, alarm, time, display);
+ val2 = VShort.of((short) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VShort.of((short)6,alarm,time,display);
- val2 = VShort.of((short)5,alarm,time, display);
+ val1 = VShort.of((short) 6, alarm, time, display);
+ val2 = VShort.of((short) 5, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
- val1 = VUShort.of((short)6,alarm,time,display);
- val2 = VUShort.of((short)5,alarm,time, display);
+ val1 = VUShort.of((short) 6, alarm, time, display);
+ val2 = VUShort.of((short) 5, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
- val1 = VUShort.of((short)6,alarm,time,display);
- val2 = VUShort.of((short)6,alarm,time, display);
+ val1 = VUShort.of((short) 6, alarm, time, display);
+ val2 = VUShort.of((short) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("0", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VUShort.of((short)5,alarm,time,display);
- val2 = VUShort.of((short)6,alarm,time, display);
+ val1 = VUShort.of((short) 5, alarm, time, display);
+ val2 = VUShort.of((short) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VShort.of((short)5,alarm,time,display);
- val2 = VShort.of((short)6,alarm,time, display);
+ val1 = VShort.of((short) 5, alarm, time, display);
+ val2 = VShort.of((short) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
- val1 = VUShort.of((short)5,alarm,time,display);
- val2 = VUShort.of((short)6,alarm,time, display);
+ val1 = VUShort.of((short) 5, alarm, time, display);
+ val2 = VUShort.of((short) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
//compare enum values: equal, first less than second, second less than first
- EnumDisplay labels = EnumDisplay.of("val1","val2","val3");
+ EnumDisplay labels = EnumDisplay.of("val1", "val2", "val3");
- val1 = VEnum.of(1,labels,alarm,time);
- val2 = VEnum.of(1,labels,alarm,time);
+ val1 = VEnum.of(1, labels, alarm, time);
+ val2 = VEnum.of(1, labels, alarm, time);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("val2", result.getString());
assertEquals(0, result.getValuesEqual());
assertTrue(result.isWithinThreshold());
- val1 = VEnum.of(1,labels,alarm,time);
- val2 = VEnum.of(2,labels,alarm,time);
+ val1 = VEnum.of(1, labels, alarm, time);
+ val2 = VEnum.of(2, labels, alarm, time);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("val2", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertFalse(result.isWithinThreshold());
- val1 = VEnum.of(2,labels,alarm,time);
- val2 = VEnum.of(1,labels,alarm,time);
+ val1 = VEnum.of(2, labels, alarm, time);
+ val2 = VEnum.of(1, labels, alarm, time);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("val3", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VByte.of((byte)5,alarm,time,display);
- val2 = VByte.of((byte)6,alarm,time, display);
+ val1 = VByte.of((byte) 5, alarm, time, display);
+ val2 = VByte.of((byte) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VByte.of((byte)6,alarm,time,display);
- val2 = VByte.of((byte)5,alarm,time, display);
+ val1 = VByte.of((byte) 6, alarm, time, display);
+ val2 = VByte.of((byte) 5, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
- val1 = VByte.of((byte)6,alarm,time,display);
- val2 = VByte.of((byte)5,alarm,time, display);
+ val1 = VByte.of((byte) 6, alarm, time, display);
+ val2 = VByte.of((byte) 5, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VUByte.of((byte)5,alarm,time,display);
- val2 = VUByte.of((byte)6,alarm,time, display);
+ val1 = VUByte.of((byte) 5, alarm, time, display);
+ val2 = VUByte.of((byte) 6, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("-1", result.getString());
assertTrue(result.getValuesEqual() < 0);
assertTrue(result.isWithinThreshold());
- val1 = VUByte.of((byte)6,alarm,time,display);
- val2 = VUByte.of((byte)5,alarm,time, display);
+ val1 = VUByte.of((byte) 6, alarm, time, display);
+ val2 = VUByte.of((byte) 5, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, threshold);
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertTrue(result.isWithinThreshold());
- val1 = VUByte.of((byte)6,alarm,time,display);
- val2 = VUByte.of((byte)5,alarm,time, display);
+ val1 = VUByte.of((byte) 6, alarm, time, display);
+ val2 = VUByte.of((byte) 5, alarm, time, display);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("+1", result.getString());
assertTrue(result.getValuesEqual() > 0);
assertFalse(result.isWithinThreshold());
- val1 = VBoolean.of(false,alarm,time);
- val2 = VBoolean.of(false,alarm,time);
+ val1 = VBoolean.of(false, alarm, time);
+ val2 = VBoolean.of(false, alarm, time);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("false", result.getString());
assertTrue(result.getValuesEqual() == 0);
assertTrue(result.isWithinThreshold());
- val1 = VString.of("a", alarm,time);
- val2 = VString.of("b", alarm,time);
+ val1 = VString.of("a", alarm, time);
+ val2 = VString.of("b", alarm, time);
result = Utilities.deltaValueToString(val1, val2, Optional.empty());
assertEquals("a", result.getString());
assertTrue(result.getValuesEqual() < 0);
@@ -1286,12 +1339,12 @@ public void testDeltaValueToString(){
}
@Test
- public void testDeltaValueToPercentage(){
+ public void testDeltaValueToPercentage() {
Alarm alarm = Alarm.none();
Display display = Display.none();
Time time = Time.now();
- Optional> threshold = Optional.of(new Threshold<>(5d,-5d));
+ Optional> threshold = Optional.of(new Threshold<>(5d, -5d));
VDouble val1 = VDouble.of(5d, alarm, time, display);
VDouble val2 = VDouble.of(4d, alarm, time, display);
@@ -1317,13 +1370,13 @@ public void testDeltaValueToPercentage(){
}
@Test
- public void testAreValuesEqual(){
+ public void testAreValuesEqual() {
Alarm alarm = Alarm.none();
Display display = Display.none();
Time time = Time.now();
- Optional> threshold = Optional.of(new Threshold<>(5d,-5d));
- Optional> threshold2 = Optional.of(new Threshold<>(0.5d,-0.5d));
+ Optional> threshold = Optional.of(new Threshold<>(5d, -5d));
+ Optional> threshold2 = Optional.of(new Threshold<>(0.5d, -0.5d));
assertTrue(Utilities.areValuesEqual(null, null, threshold));
@@ -1394,41 +1447,41 @@ public void testAreValuesEqual(){
result = Utilities.areValuesEqual(val1, val3, threshold2);
assertFalse(result);
- val2 = VUShort.of((short)10, alarm, time, display);
- val1 = VUShort.of((short)10, alarm, time, display);
+ val2 = VUShort.of((short) 10, alarm, time, display);
+ val1 = VUShort.of((short) 10, alarm, time, display);
result = Utilities.areValuesEqual(val1, val2, Optional.empty());
assertTrue(result);
- val3 = VUShort.of((short)11, alarm, time, display);
+ val3 = VUShort.of((short) 11, alarm, time, display);
result = Utilities.areValuesEqual(val1, val3, threshold);
assertTrue(result);
result = Utilities.areValuesEqual(val1, val3, threshold2);
assertFalse(result);
- val2 = VShort.of((short)10, alarm, time, display);
- val1 = VShort.of((short)10, alarm, time, display);
+ val2 = VShort.of((short) 10, alarm, time, display);
+ val1 = VShort.of((short) 10, alarm, time, display);
result = Utilities.areValuesEqual(val1, val2, Optional.empty());
assertTrue(result);
- val3 = VShort.of((short)11, alarm, time, display);
+ val3 = VShort.of((short) 11, alarm, time, display);
result = Utilities.areValuesEqual(val1, val3, threshold);
assertTrue(result);
result = Utilities.areValuesEqual(val1, val3, threshold2);
assertFalse(result);
- val2 = VUByte.of((byte)10, alarm, time, display);
- val1 = VUByte.of((byte)10, alarm, time, display);
+ val2 = VUByte.of((byte) 10, alarm, time, display);
+ val1 = VUByte.of((byte) 10, alarm, time, display);
result = Utilities.areValuesEqual(val1, val2, Optional.empty());
assertTrue(result);
- val3 = VUByte.of((byte)11, alarm, time, display);
+ val3 = VUByte.of((byte) 11, alarm, time, display);
result = Utilities.areValuesEqual(val1, val3, threshold);
assertTrue(result);
result = Utilities.areValuesEqual(val1, val3, threshold2);
assertFalse(result);
- val2 = VByte.of((byte)10, alarm, time, display);
- val1 = VByte.of((byte)10, alarm, time, display);
+ val2 = VByte.of((byte) 10, alarm, time, display);
+ val1 = VByte.of((byte) 10, alarm, time, display);
result = Utilities.areValuesEqual(val1, val2, Optional.empty());
assertTrue(result);
- val3 = VByte.of((byte)11, alarm, time, display);
+ val3 = VByte.of((byte) 11, alarm, time, display);
result = Utilities.areValuesEqual(val1, val3, threshold);
assertTrue(result);
result = Utilities.areValuesEqual(val1, val3, threshold2);