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 PeakSenseImpl extends PeakSensePOA
00041 {
00042 protected double threshold_h;
00043 protected double threshold_l;
00044
00045 private SenseImpl del;
00046
00047
00048 public PeakSenseImpl(byte l, byte s, double r, double th, boolean hi) {
00049 del = new SenseImpl(l, s, r);
00050 if (hi) {
00051 threshold_h = th;
00052 threshold_l = Double.NEGATIVE_INFINITY;
00053 }
00054 else {
00055 threshold_h = Double.POSITIVE_INFINITY;
00056 threshold_l = th;
00057 }
00058 }
00059
00060 public PeakSenseImpl(byte l, byte s, double r, double th, double tl) {
00061 del = new SenseImpl(l, s, r);
00062 threshold_h = th;
00063 threshold_l = tl;
00064 }
00065
00066 public PeakSenseImpl(byte s, double r, double th, boolean hi) {
00067 del = new SenseImpl(s, r);
00068 if (hi) {
00069 threshold_h = th;
00070 threshold_l = Double.NEGATIVE_INFINITY;
00071 }
00072 else {
00073 threshold_h = Double.POSITIVE_INFINITY;
00074 threshold_l = th;
00075 }
00076 }
00077
00078 public PeakSenseImpl(byte s, double r, double th, double tl) {
00079 del = new SenseImpl(s, r);
00080 threshold_h = th;
00081 threshold_l = tl;
00082 }
00083
00084
00085 public PeakSenseImpl(byte l, byte s, double th, boolean hi) {
00086 del = new SenseImpl(l, s);
00087 if (hi) {
00088 threshold_h = th;
00089 threshold_l = Double.NEGATIVE_INFINITY;
00090 }
00091 else {
00092 threshold_h = Double.POSITIVE_INFINITY;
00093 threshold_l = th;
00094 }
00095 }
00096
00097 public PeakSenseImpl(byte l, byte s, double th, double tl) {
00098 del = new SenseImpl(l, s);
00099 threshold_h = th;
00100 threshold_l = tl;
00101 }
00102
00103 public PeakSenseImpl(byte s, double th, boolean hi) {
00104 del = new SenseImpl(s);
00105 if (hi) {
00106 threshold_h = th;
00107 threshold_l = Double.NEGATIVE_INFINITY;
00108 }
00109 else {
00110 threshold_h = Double.POSITIVE_INFINITY;
00111 threshold_l = th;
00112 }
00113 }
00114
00115 public PeakSenseImpl(byte s, double th, double tl) {
00116 del = new SenseImpl(s);
00117 threshold_h = th;
00118 threshold_l = tl;
00119 }
00120
00121 public PeakSenseImpl(byte l, byte s, double r, double th, double tl,
00122 int seq) {
00123 del = new SenseImpl(l, s, r, seq);
00124 threshold_h = th;
00125 threshold_l = tl;
00126 }
00127
00128
00129 public double highthreshold() {
00130 return threshold_h;
00131 }
00132
00133 public void highthreshold(double h) {
00134 threshold_h = h;
00135 }
00136
00137 public double lowthreshold() {
00138 return threshold_l;
00139 }
00140
00141 public void lowthreshold(double l) {
00142 threshold_l = l;
00143 }
00144
00145 public byte identifier() {
00146 return SenseCorba.BETA;
00147 }
00148
00149 public String asString() {
00150 String string_rep = "PeakSense(";
00151 if (del.level() != SenseCorba.INVALID)
00152 string_rep += "level=" + (int)del.level() + ",";
00153 string_rep += "sensor=" + SenseUtil.capabilityToString(del.sensor());
00154 if (del.rate() > 0.0)
00155 string_rep += ",rate=" + del.rate();
00156 if (threshold_h != Double.POSITIVE_INFINITY)
00157 string_rep += ",high threshold=" + threshold_h;
00158 if (threshold_l != Double.NEGATIVE_INFINITY)
00159 string_rep += ",low threshold=" + threshold_l;
00160 string_rep += ")";
00161 return string_rep;
00162 }
00163
00164
00165
00166
00167
00168 public int sequencer() {
00169 return del.sequencer();
00170 }
00171
00172 public double rate() {
00173 return del.rate();
00174 }
00175
00176 public void rate(double r) {
00177 del.rate(r);
00178 }
00179
00180 public byte level() {
00181 return del.level();
00182 }
00183
00184 public byte sensor() {
00185 return del.sensor();
00186 }
00187
00188 public long timeused() {
00189 return del.timeused();
00190 }
00191
00192 public void timeused(long t) {
00193 del.timeused(t);
00194 }
00195
00196 public double energyused() {
00197 return del.energyused();
00198 }
00199
00200 public void energyused(double e) {
00201 del.energyused(e);
00202 }
00203
00204 public Data[] results() {
00205 return del.results();
00206 }
00207
00208 public void results(Data[] data) {
00209 Data d = data[0];
00210 double val = 0.0;
00211 if (SenseUtil.isIntegerData(d.discriminator()))
00212 val = d.iresult();
00213 else if (SenseUtil.isFloatingPointData(d.discriminator()))
00214 val = d.fresult();
00215 if (val > threshold_l && val < threshold_h)
00216 del.results(data);
00217 }
00218
00219 public FunctorError[] errors() {
00220 return del.errors();
00221 }
00222
00223 public void errors(FunctorError[] e) {
00224 del.errors(e);
00225 }
00226
00227
00228 public byte priority() {
00229 return del.priority();
00230 }
00231
00232 public void priority(byte p) {
00233 del.priority(p);
00234 }
00235
00236
00237 public Functor[] subfunctors() {
00238 return del.subfunctors();
00239 }
00240
00241 public void subfunctors(Functor[] fs) {
00242 del.subfunctors(fs);
00243 }
00244 }