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 gov.lanl.isr.sensix.sensing;
00036
00037 import gov.lanl.isr.sensix.*;
00038
00039
00040publicclass LocationImplextends _LocationStub
00041 {
00042publicstaticfinaldoubleDEFAULT_LAT = 35.8880556;
00043publicstaticfinaldoubleDEFAULT_LON = -106.3063889;
00044publicstaticfinaldoubleDEFAULT_ALT = 2255.52;
00045
00046protecteddoublelat, lon, alt;
00047protectedlongnow;
00048protectedbooleanhave_device;
00049
00050
00051publicLocationImpl() {
00052 this(DEFAULT_LAT, DEFAULT_LON, DEFAULT_ALT);
00053 }
00054
00055publicLocationImpl(doublelatitude, doublelongitude) {
00056 this(latitude, longitude, 0.0);
00057 }
00058
00059publicLocationImpl(doublelatitude, doublelongitude, doublealtitude) {
00060 have_device = false;
00061 lat = latitude;
00062 lon = longitude;
00063 alt = altitude;
00064 now = System.currentTimeMillis();
00065 }
00066
00067
00068public byte identifier() {
00069 returnSenseCorba.GPS;
00070 }
00071
00072publicdoublelatitude() {
00073 getGPS();
00074 returnlat;
00075 }
00076
00077publicdoublelongitude() {
00078 getGPS();
00079 returnlon;
00080 }
00081
00082publicdoublealtitude() {
00083 getGPS();
00084 returnalt;
00085 }
00086
00087publiclongtime() {
00088 getGPS();
00089 returnnow;
00090 }
00091
00092
00093protectedvoidgetGPS() {
00094 now = System.currentTimeMillis();
00095 }
00096
00097publicvoidacquire(Functor f) {
00098 getGPS();
00099 Data[] array = new Data[4];
00100 for (int i = 0; i < 4; i++)
00101 array[i] = new Data();
00102 array[0].fresult(lat);
00103 array[1].fresult(lon);
00104 array[2].fresult(alt);
00105 array[3].iresult(now);
00106 f.results(array);
00107 }
00108 }