|
|
/home/brennan/Software/sensix/source/C^4/corba/gov/lanl/isr/sensix/sensing/MeanImpl.javaGo to the documentation of this file.00001 00010 /* 00011 * Copyright 2008. Los Alamos National Security, LLC. This material 00012 * was produced under U.S. Government contract DE-AC52-06NA25396 for 00013 * Los Alamos National Laboratory (LANL), which is operated by Los 00014 * Alamos National Security, LLC, for the Department of Energy. The 00015 * U.S. Government has rights to use, reproduce, and distribute this 00016 * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY, 00017 * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL 00018 * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to 00019 * produce derivative works, such modified software should be clearly 00020 * marked, so as not to confuse it with the version available from LANL. 00021 * 00022 * Additionally, this program is free software; you can redistribute 00023 * it and/or modify it under the terms of the GNU General Public 00024 * License as published by the Free Software Foundation; version 2 of 00025 * the License. Accordingly, this program is distributed in the hope 00026 * it will be useful, but WITHOUT ANY WARRANTY; without even the 00027 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR 00028 * PURPOSE. See the GNU General Public License for more details. 00029 * 00030 * You should have received a copy of the GNU General Public License 00031 * along with this program; if not, write to the Free Software 00032 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00033 */ 00034 00035 package gov.lanl.isr.sensix.sensing; 00036 00037 import gov.lanl.isr.sensix.*; 00038 00039 00040 public class MeanImpl extends MeanPOA 00041 { 00042 private AggregateImpl del; 00043 00044 00045 public MeanImpl(byte l, Collection[] c) { 00046 del = new AggregateImpl("Mean", l, c); 00047 } 00048 00049 public MeanImpl(Collection[] c) { 00050 del = new AggregateImpl("Mean", c); 00051 } 00052 00053 public MeanImpl(byte l, Collection[] c, int seq) { 00054 del = new AggregateImpl("Mean", l, c, seq); 00055 } 00056 00057 00058 public byte identifier() { 00059 return SenseCorba.BARX; 00060 } 00061 00062 protected Data getResult(int idx) { 00063 double value = 0; 00064 Data[] res = del.collectors()[idx].results(); 00065 for (int i = 0; i < res.length; i++) { 00066 Data d = res[i]; 00067 if (SenseUtil.isIntegerData(d.discriminator())) 00068 value += d.iresult(); 00069 else if (SenseUtil.isFloatingPointData(d.discriminator())) 00070 value += d.fresult(); 00071 } 00072 value /= res.length; 00073 00074 Data ret = new Data(); 00075 ret.fresult(value); 00076 return ret; 00077 } 00078 00079 public Data result() { 00080 return getResult(0); 00081 } 00082 00083 public Data[] results() { 00084 int num = del.collectors().length; 00085 Data[] array = new Data[num]; 00086 for (int i = 0; i < num; i++) 00087 array[i] = getResult(i); 00088 return array; 00089 } 00090 00091 public void results(Data[] data) {} 00092 00093 00094 /********** delegation **********/ 00095 00096 00097 public String asString() { 00098 return del.asString(); 00099 } 00100 00101 public int sequencer() { 00102 return del.sequencer(); 00103 } 00104 00105 public byte level() { 00106 return del.level(); 00107 } 00108 00109 public Collection[] collectors() { 00110 return del.collectors(); 00111 } 00112 00113 public void collectors(Collection[] c) { 00114 del.collectors(c); 00115 } 00116 00117 public Sensory[] senses() { 00118 return del.senses(); 00119 } 00120 00121 public Sensory sense() { 00122 return del.sense(); 00123 } 00124 00125 public void sense(Sensory s) { 00126 del.sense(s); 00127 } 00128 00129 public byte sensor() { 00130 return del.sensor(); 00131 } 00132 00133 public long timeused() { 00134 return del.timeused(); 00135 } 00136 00137 public void timeused(long t) { 00138 del.timeused(t); 00139 } 00140 00141 public double energyused() { 00142 return del.energyused(); 00143 } 00144 00145 public void energyused(double e) { 00146 del.energyused(e); 00147 } 00148 00149 public byte priority() { 00150 return del.priority(); 00151 } 00152 00153 public void priority(byte p) { 00154 del.priority(p); 00155 } 00156 00157 public FunctorError[] errors() { 00158 return del.errors(); 00159 } 00160 00161 public void errors(FunctorError[] e) { 00162 del.errors(e); 00163 } 00164 00165 public Functor[] subfunctors() { 00166 return del.subfunctors(); 00167 } 00168 00169 public void subfunctors(Functor[] fs) { 00170 del.subfunctors(fs); 00171 } 00172 } 00173 |