00001
00010 /*00011 * Copyright 2008. Los Alamos National Security, LLC. This material00012 * was produced under U.S. Government contract DE-AC52-06NA25396 for00013 * Los Alamos National Laboratory (LANL), which is operated by Los00014 * Alamos National Security, LLC, for the Department of Energy. The00015 * U.S. Government has rights to use, reproduce, and distribute this00016 * software. NEITHER THE GOVERNMENT NOR LOS ALAMOS NATIONAL SECURITY,00017 * LLC, MAKES ANY WARRANTY, EXPRESS OR IMPLIED, OR ASSUMES ANY LEGAL00018 * LIABILITY FOR THE USE OF THIS SOFTWARE. If software is modified to00019 * produce derivative works, such modified software should be clearly00020 * marked, so as not to confuse it with the version available from LANL.00021 *00022 * Additionally, this program is free software; you can redistribute00023 * it and/or modify it under the terms of the GNU General Public00024 * License as published by the Free Software Foundation; version 2 of00025 * the License. Accordingly, this program is distributed in the hope00026 * it will be useful, but WITHOUT ANY WARRANTY; without even the00027 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR00028 * PURPOSE. See the GNU General Public License for more details.00029 *00030 * You should have received a copy of the GNU General Public License00031 * along with this program; if not, write to the Free Software00032 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA. 00033 */00034
00035 package sensix.sensing;
00036
00037 import sensix.*;
00038
00039
00040publicclass MeanextendsAggregate00041 {
00042publicMean(byte l, Collection[] c) {
00043 super("Mean", l, c);
00044 }
00045
00046publicMean(Collection[] c) {
00047 super("Mean", c);
00048 }
00049
00050publicMean(byte l, Collection[] c, int seq) {
00051 super("Mean", l, c, seq);
00052 }
00053
00054
00055public byte identifier() {
00056 returnSensix.BARX;
00057 }
00058
00059protectedDatagetResult(int idx) {
00060 doublevalue = 0;
00061 Data[] res = collectors()[idx].results();
00062 for (int i = 0; i < res.length; i++) {
00063 Data d = res[i];
00064 if (SenseUtil.isIntegerData(d.discriminator()))
00065 value += d.iresult();
00066 elseif (SenseUtil.isFloatingPointData(d.discriminator()))
00067 value += d.fresult();
00068 }
00069 value /= res.length;
00070
00071 Data ret = newData();
00072 ret.fresult(value);
00073 return ret;
00074 }
00075
00076publicDataresult() {
00077 returngetResult(0);
00078 }
00079
00080publicData[] results() {
00081 int num = collectors().length;
00082 Data[] array = newData[num];
00083 for (int i = 0; i < num; i++)
00084 array[i] = getResult(i);
00085 return array;
00086 }
00087
00088publicvoidresults(Data[] data) {}
00089 }
00090