00001
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035 package sensix.sensing;
00036
00037 import sensix.*;
00038
00039
00040 public class Delta extends Aggregate
00041 {
00042 public Delta(byte l, Collection[] c) {
00043 super("Delta", l, c);
00044 }
00045
00046 public Delta(Collection[] c) {
00047 super("Delta", c);
00048 }
00049
00050 public Delta(byte l, Collection[] c, int seq) {
00051 super("Delta", l, c, seq);
00052 }
00053
00054
00055 public byte identifier() {
00056 return Sensix.DELTA;
00057 }
00058
00059 protected Data getResult(int idx) {
00060 double min = Double.POSITIVE_INFINITY, max = Double.NEGATIVE_INFINITY;
00061 double value = 0;
00062 Data[] res = collectors()[idx].results();
00063 for (int i = 0; i < res.length; i++) {
00064 Data d = res[i];
00065 if (SenseUtil.isIntegerData(d.discriminator())) {
00066 if (d.iresult() > max)
00067 max = d.iresult();
00068 if (d.iresult() < min)
00069 min = d.iresult();
00070 }
00071 else if (SenseUtil.isFloatingPointData(d.discriminator())) {
00072 if (d.fresult() > max)
00073 max = d.fresult();
00074 if (d.fresult() < min)
00075 min = d.fresult();
00076 }
00077 }
00078 value = max - min;
00079 Data ret = new Data();
00080 ret.fresult(value);
00081 return ret;
00082 }
00083
00084 public Data result() {
00085 return getResult(0);
00086 }
00087
00088 public Data[] results() {
00089 int num = collectors().length;
00090 Data[] array = new Data[num];
00091 for (int i = 0; i < num; i++)
00092 array[i] = getResult(i);
00093 return array;
00094 }
00095
00096 public void results(Data[] data) {}
00097 }