|
|
/home/brennan/Software/sensix/source/C^4/corba/gov/lanl/isr/sensix/sensing/SumImpl.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 SumImpl extends SumPOA 00041 { 00042 private AggregateImpl del; 00043 00044 00045 public SumImpl(byte l, Collection[] c) { 00046 del = new AggregateImpl("Sum", l, c); 00047 } 00048 00049 public SumImpl(Collection[] c) { 00050 del = new AggregateImpl("Sum", c); 00051 } 00052 00053 public SumImpl(byte l, Collection[] c, int seq) { 00054 del = new AggregateImpl("Sum", l, c, seq); 00055 } 00056 00057 00058 public byte identifier() { 00059 return SenseCorba.SUMMA; 00060 } 00061 00062 protected Data getResult(int idx) { 00063 double value = 0.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 00073 Data ret = new Data(); 00074 ret.fresult(value); 00075 return ret; 00076 } 00077 00078 public Data[] results() { 00079 int num = del.collectors().length; 00080 Data[] array = new Data[num]; 00081 for (int i = 0; i < num; i++) 00082 array[i] = getResult(i); 00083 return array; 00084 } 00085 00086 public void results(Data[] data) {} 00087 00088 00089 /********** delegation **********/ 00090 00091 00092 public String asString() { 00093 return del.asString(); 00094 } 00095 00096 public int sequencer() { 00097 return del.sequencer(); 00098 } 00099 00100 public byte level() { 00101 return del.level(); 00102 } 00103 00104 public Collection[] collectors() { 00105 return del.collectors(); 00106 } 00107 00108 public void collectors(Collection[] c) { 00109 del.collectors(c); 00110 } 00111 00112 public Sensory[] senses() { 00113 return del.senses(); 00114 } 00115 00116 public Sensory sense() { 00117 return del.sense(); 00118 } 00119 00120 public void sense(Sensory s) { 00121 del.sense(s); 00122 } 00123 00124 public byte sensor() { 00125 return del.sensor(); 00126 } 00127 00128 public long timeused() { 00129 return del.timeused(); 00130 } 00131 00132 public void timeused(long t) { 00133 del.timeused(t); 00134 } 00135 00136 public double energyused() { 00137 return del.energyused(); 00138 } 00139 00140 public void energyused(double e) { 00141 del.energyused(e); 00142 } 00143 00144 public byte priority() { 00145 return del.priority(); 00146 } 00147 00148 public void priority(byte p) { 00149 del.priority(p); 00150 } 00151 00152 public FunctorError[] errors() { 00153 return del.errors(); 00154 } 00155 00156 public void errors(FunctorError[] e) { 00157 del.errors(e); 00158 } 00159 00160 public Functor[] subfunctors() { 00161 return del.subfunctors(); 00162 } 00163 00164 public void subfunctors(Functor[] fs) { 00165 del.subfunctors(fs); 00166 } 00167 } |