package org.yamcs.algorithms;

import java.util.Calendar;
import java.util.Date;

import org.yamcs.parameter.ParameterValue;
import org.yamcs.protobuf.Pvalue.AcquisitionStatus;
import org.yamcs.protobuf.Pvalue.MonitoringResult;
import org.yamcs.utils.TimeEncoding;

/**
 * A ParameterValue as passed to an algorithm. Actual implementations are
 * generated on-the-fly to walk around the issue of Rhino that maps
 * boxed primitives to JavaScript Objects instead of Numbers
 */
public abstract class ValueBinding {
    
    public Date acquisitionTime;
    public long acquisitionTimeMs;
    public Date generationTime;
    public long generationTimeMs;
    public AcquisitionStatus acquisitionStatus;
    public MonitoringResult monitoringResult;

    public void updateValue(ParameterValue newValue) {
        acquisitionStatus = newValue.getAcquisitionStatus();
        monitoringResult = newValue.getMonitoringResult();
        if(newValue.hasAcquisitionTime()) {
            Calendar cal = TimeEncoding.toCalendar(newValue.getAcquisitionTime());
            acquisitionTime = cal.getTime();
        }
        acquisitionTimeMs = newValue.getAcquisitionTime();
        generationTime = TimeEncoding.toCalendar(newValue.getGenerationTime()).getTime();
        generationTimeMs = newValue.getGenerationTime();
    }
}

@@ -221,16 +221,65 @@
 Result;%0A
+import org.yamcs.protobuf.Pvalue.RangeCondition;%0A
 import o
@@ -385,19 +385,16 @@
 ions are
-%0A *
  generat
@@ -431,16 +431,19 @@
 he issue
+%0A *
  of Rhin
@@ -453,19 +453,16 @@
 hat maps
-%0A *
  boxed p
@@ -553,20 +553,16 @@
 nding %7B%0A
-    
 %0A    pub
@@ -781,16 +781,58 @@
 gResult;
+%0A    public RangeCondition rangeCondition;
 %0A%0A    pu
@@ -996,24 +996,80 @@
 ngResult();%0A
+        rangeCondition = newValue.getRangeCondition();%0A%0A
         if(n
@@ -1066,16 +1066,17 @@
       if
+ 
 (newValu

Add rangeCondition to algorithm binding