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 gov.lanl.isr.sensix.sensing;
00036
00037 import gov.lanl.isr.sensix.*;
00038
00039
00040 public class AggregateImpl extends AggregatePOA
00041 {
00042 protected String name = "";
00043 protected Collection[] series;
00044
00045 private SensoryImpl del;
00046
00047
00048 public AggregateImpl(String n, byte l, Collection[] c) {
00049 del = new SensoryImpl(l, SenseCorba.INVALID, (Functor[])c);
00050 name = n;
00051 series = c;
00052 if (series == null)
00053 series = new Collection[0];
00054 }
00055
00056 public AggregateImpl(String n, Collection[] c) {
00057 del = new SensoryImpl((Functor[])c);
00058 name = n;
00059 series = c;
00060 if (series == null)
00061 series = new Collection[0];
00062 }
00063
00064 public AggregateImpl(String n, byte l, Collection[] c, int seq) {
00065 del = new SensoryImpl(l, SenseCorba.INVALID, (Functor[])c, seq);
00066 name = n;
00067 series = c;
00068 if (series == null)
00069 series = new Collection[0];
00070 }
00071
00072
00073 public Sensory[] senses() {
00074 int num = series.length;
00075 Sensory[] array = new Sensory[num];
00076 for (int i = 0; i < num; i++)
00077 array[i] = series[i].sense();
00078 return array;
00079 }
00080
00081
00082 public Collection[] collectors() {
00083 return series;
00084 }
00085
00086 public void collectors(Collection[] c) {
00087 series = c;
00088 }
00089
00090
00091 public byte sensor() {
00092 return SenseCorba.INVALID;
00093 }
00094
00095 public Sensory sense() {
00096 return series[0].sense();
00097 }
00098
00099 public void sense(Sensory s) {}
00100
00101 public long timeused() {
00102 long max = 0;
00103 for (int i = 0; i < series.length; i++) {
00104 if (series[i].timeused() > max)
00105 max = series[i].timeused();
00106 }
00107 return max;
00108 }
00109
00110 public void timeused(long t) {}
00111
00112 public double energyused() {
00113 double sum = 0.0;
00114 for (int i = 0; i < series.length; i++)
00115 sum += series[i].energyused();
00116 return sum;
00117 }
00118
00119 public void energyused(double e) {}
00120
00121 public byte priority() {
00122 byte max = 0;
00123 for (int i = 0; i < series.length; i++) {
00124 if (series[i].priority() > max)
00125 max = series[i].priority();
00126 }
00127 return max;
00128 }
00129
00130 public void priority(byte p) {
00131 for (int i = 0; i < series.length; i++)
00132 series[i].priority(p);
00133 }
00134
00135 public FunctorError[] errors() {
00136 int num = 0, pos = 0;
00137 for (int i = 0; i < series.length; i++) {
00138 if (series[i].errors() != null)
00139 num += series[i].errors().length;
00140 }
00141 FunctorError[] e = new FunctorError[num];
00142 for (int i = 0; i < series.length; i++) {
00143 if (series[i].errors() != null && series[i].errors().length > 0) {
00144 System.arraycopy(series[i].errors(), 0, e, pos,
00145 series[i].errors().length);
00146 pos += series[i].errors().length;
00147 }
00148 }
00149 return e;
00150 }
00151
00152 public void errors(FunctorError[] fe) {}
00153
00154 public String asString() {
00155 String string_rep = name + "(";
00156 if (del.level() != SenseCorba.INVALID)
00157 string_rep += "level=" + (int)del.level() + ",";
00158 for (int i = 0; i < series.length; i ++) {
00159 string_rep += series[i].asString();
00160 if (i < series.length - 1)
00161 string_rep += "&&";
00162 }
00163 string_rep += ")";
00164 return string_rep;
00165 }
00166
00167
00168
00169
00170
00171 public byte identifier() {
00172 return del.identifier();
00173 }
00174
00175 public int sequencer() {
00176 return del.sequencer();
00177 }
00178
00179 public byte level() {
00180 return del.level();
00181 }
00182
00183 public Data[] results() {
00184 return del.results();
00185 }
00186
00187 public void results(Data[] data) {
00188 del.results(data);
00189 }
00190
00191 public Functor[] subfunctors() {
00192 return del.subfunctors();
00193 }
00194
00195 public void subfunctors(Functor[] fs) {
00196 del.subfunctors(fs);
00197 }
00198 }