Skip to content

Commit 77aacfb

Browse files
committed
Return infinite delta if arrays are of different length
1 parent ba95624 commit 77aacfb

File tree

1 file changed

+12
-2
lines changed
  • app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui

1 file changed

+12
-2
lines changed

app/save-and-restore/app/src/main/java/org/phoebus/applications/saveandrestore/ui/VTypePair.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,9 @@
2020
import org.epics.vtype.VNumber;
2121
import org.epics.vtype.VString;
2222
import org.epics.vtype.VType;
23+
import org.phoebus.core.vtypes.VTypeHelper;
2324
import org.phoebus.saveandrestore.util.Threshold;
25+
import org.phoebus.saveandrestore.util.VNoData;
2426

2527
import java.util.Optional;
2628

@@ -59,11 +61,19 @@ public VTypePair(VType base, VType value, Optional<Threshold<?>> threshold) {
5961
* Main use case for this is ordering on delta. Absolute delta may be more useful as otherwise zero
6062
* deltas would be found between positive and negative deltas.
6163
* </p>
64+
* <p>
65+
* If {@link #base} or {@link #value} are <code>null</code> or {@link VNoData#INSTANCE}, then
66+
* the delta cannot be computed as a number. In this case {@link Double#MAX_VALUE} is returned
67+
* to indicate an "infinite delta".
68+
* </p>
6269
* @return Absolute delta between {@link #base} and {@link #value}.
6370
*/
6471
public double getAbsoluteDelta(){
65-
if(base == null || value == null){
66-
return 0.0;
72+
if(base.equals(VNoData.INSTANCE) ||
73+
value.equals(VNoData.INSTANCE) ||
74+
base == null ||
75+
value == null){
76+
return Double.MAX_VALUE;
6777
}
6878
if(base instanceof VNumber){
6979
return Math.abs(((VNumber)base).getValue().doubleValue() -

0 commit comments

Comments
 (0)