Changeset 12778 in osm for applications/editors/josm/plugins/globalsat
- Timestamp:
- 2009-01-01T18:28:53+01:00 (17 years ago)
- Location:
- applications/editors/josm/plugins/globalsat/src/org
- Files:
-
- 9 edited
-
kaintoch/gps/globalsat/dg100/ByteHelper.java (modified) (1 diff)
-
kaintoch/gps/globalsat/dg100/Dg100Config.java (modified) (1 diff)
-
kaintoch/gps/globalsat/dg100/FileInfoRec.java (modified) (1 diff)
-
kaintoch/gps/globalsat/dg100/GpsRec.java (modified) (1 diff)
-
kaintoch/gps/globalsat/dg100/Response.java (modified) (1 diff)
-
openstreetmap/josm/plugins/globalsat/GlobalsatConfigDialog.java (modified) (8 diffs)
-
openstreetmap/josm/plugins/globalsat/GlobalsatDg100.java (modified) (10 diffs)
-
openstreetmap/josm/plugins/globalsat/GlobalsatImportDialog.java (modified) (4 diffs)
-
openstreetmap/josm/plugins/globalsat/GlobalsatPlugin.java (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/globalsat/src/org/kaintoch/gps/globalsat/dg100/ByteHelper.java
r10378 r12778 12 12 { 13 13 14 /**15 * 16 * @param src17 * @param startS18 * @param len19 * @param dest20 * @param startD21 * @return22 */23 public static int copyByteArr2ByteArr(byte src[], int startS, int len, byte dest[], int startD)24 {25 for (int ii = 0 ;26 ii < len && startD < dest.length && startS < src.length && startD >= 0 && startS >= 0;27 ++ii, ++startD, ++startS)28 {29 dest[startD] = src[startS];30 }31 return startD;32 }14 /** 15 * 16 * @param src 17 * @param startS 18 * @param len 19 * @param dest 20 * @param startD 21 * @return 22 */ 23 public static int copyByteArr2ByteArr(byte src[], int startS, int len, byte dest[], int startD) 24 { 25 for (int ii = 0 ; 26 ii < len && startD < dest.length && startS < src.length && startD >= 0 && startS >= 0; 27 ++ii, ++startD, ++startS) 28 { 29 dest[startD] = src[startS]; 30 } 31 return startD; 32 } 33 33 34 /**35 * 36 * @param byt37 * @return38 */39 public static int byte2IntUnsigned(byte byt)40 {41 return ((byt >= 0) ? byt : 256 + byt);42 }34 /** 35 * 36 * @param byt 37 * @return 38 */ 39 public static int byte2IntUnsigned(byte byt) 40 { 41 return ((byt >= 0) ? byt : 256 + byt); 42 } 43 43 44 /**45 * 46 * @param nibble47 */48 private static char nibble2Char(int nibble)49 {50 char chr = '*';51 nibble = nibble & 0xF;52 switch (nibble)53 {54 case 0: chr = '0'; break;55 case 1: chr = '1'; break;56 case 2: chr = '2'; break;57 case 3: chr = '3'; break;58 case 4: chr = '4'; break;59 case 5: chr = '5'; break;60 case 6: chr = '6'; break;61 case 7: chr = '7'; break;62 case 8: chr = '8'; break;63 case 9: chr = '9'; break;64 case 10: chr = 'A'; break;65 case 11: chr = 'B'; break;66 case 12: chr = 'C'; break;67 case 13: chr = 'D'; break;68 case 14: chr = 'E'; break;69 case 15: chr = 'F'; break;70 }71 return chr;72 }44 /** 45 * 46 * @param nibble 47 */ 48 private static char nibble2Char(int nibble) 49 { 50 char chr = '*'; 51 nibble = nibble & 0xF; 52 switch (nibble) 53 { 54 case 0: chr = '0'; break; 55 case 1: chr = '1'; break; 56 case 2: chr = '2'; break; 57 case 3: chr = '3'; break; 58 case 4: chr = '4'; break; 59 case 5: chr = '5'; break; 60 case 6: chr = '6'; break; 61 case 7: chr = '7'; break; 62 case 8: chr = '8'; break; 63 case 9: chr = '9'; break; 64 case 10: chr = 'A'; break; 65 case 11: chr = 'B'; break; 66 case 12: chr = 'C'; break; 67 case 13: chr = 'D'; break; 68 case 14: chr = 'E'; break; 69 case 15: chr = 'F'; break; 70 } 71 return chr; 72 } 73 73 74 /**75 * 76 * @return77 */78 public static String byte2StringUnsigned(byte byt)79 {80 StringBuffer buf = new StringBuffer(4);81 int bb = byte2IntUnsigned(byt);82 //buf.append("0x");83 buf.append(nibble2Char(bb / 16));84 buf.append(nibble2Char(bb % 16));85 return buf.toString();86 }74 /** 75 * 76 * @return 77 */ 78 public static String byte2StringUnsigned(byte byt) 79 { 80 StringBuffer buf = new StringBuffer(4); 81 int bb = byte2IntUnsigned(byt); 82 //buf.append("0x"); 83 buf.append(nibble2Char(bb / 16)); 84 buf.append(nibble2Char(bb % 16)); 85 return buf.toString(); 86 } 87 87 88 /**89 * 90 * @param byt91 */92 public static String byteArray2String(byte byt[])93 {94 return byteArray2String(byt, byt.length);95 }88 /** 89 * 90 * @param byt 91 */ 92 public static String byteArray2String(byte byt[]) 93 { 94 return byteArray2String(byt, byt.length); 95 } 96 96 97 /**98 * 99 * @param byt100 * @param cnt101 */102 public static String byteArray2String(byte byt[], int cnt)103 {104 StringBuffer buf = new StringBuffer(cnt * 5);105 for (int ii = 0 ; ii < cnt && ii < byt.length ; ++ii)106 {107 if (ii > 0) {buf.append(" ");}108 buf.append(byte2StringUnsigned(byt[ii]));109 }110 return buf.toString();111 }97 /** 98 * 99 * @param byt 100 * @param cnt 101 */ 102 public static String byteArray2String(byte byt[], int cnt) 103 { 104 StringBuffer buf = new StringBuffer(cnt * 5); 105 for (int ii = 0 ; ii < cnt && ii < byt.length ; ++ii) 106 { 107 if (ii > 0) {buf.append(" ");} 108 buf.append(byte2StringUnsigned(byt[ii])); 109 } 110 return buf.toString(); 111 } 112 112 113 113 } -
applications/editors/josm/plugins/globalsat/src/org/kaintoch/gps/globalsat/dg100/Dg100Config.java
r11555 r12778 30 30 // nn nn nn nn: distance in m 31 31 // xx xx: checksum 32 // A0 A2 00 35 B7 jj kk ll ll ll ll mm nn nn nn nn32 // A0 A2 00 35 B7 jj kk ll ll ll ll mm nn nn nn nn 33 33 // aa aa aa aa bb bb bb bb cc cc cc cc 00 00 gg hh 34 34 // ii dd dd dd dd ee ee ee ee ff ff ff ff 01 61 01 35 35 // 01 0C D5 0D 00 04 CC B0 B3 36 36 37 private byte logFormat = -1;38 private byte disableLogSpeed = -1;39 private int speedThres = -1;40 private byte disableLogDist = -1;41 private int distThres = -1;42 private int swATime = -1;43 private int swBTime = -1;44 private int swCTime = -1;45 private short unk1 = -1;46 private byte swATimeOrDist = -1;47 private byte swBTimeOrDist = -1;48 private byte swCTimeOrDist = -1;49 private int swADist = -1;50 private int swBDist = -1;51 private int swCDist = -1;52 private byte unk2 = -1;53 private int remainder = -1;54 private int unk3 = -1;55 private int unk4 = -1;56 57 private static String propLogFormat = "logFormat";58 private static String propDisableLogSpeed = "disableLogSpeed";59 private static String propSpeedThres = "speedThres";60 private static String propDisableLogDist = "disableLogDist";61 private static String propDistThres = "distThres";62 private static String propSwATime = "swATime";63 private static String propSwBTime = "swBTime";64 private static String propSwCTime = "swCTime";65 private static String propUnk1 = "unk1";66 private static String propSwATimeOrDist = "swATimeOrDist";67 private static String propSwBTimeOrDist = "swBTimeOrDist";68 private static String propSwCTimeOrDist = "swCTimeOrDist";69 private static String propSwADist = "swADist";70 private static String propSwBDist = "swBDist";71 private static String propSwCDist = "swCDist";72 private static String propUnk2 = "unk2";73 private static String propRemainder = "remainder";74 private static String propUnk3 = "unk3";75 private static String propUnk4 = "unk4";76 77 public Dg100Config(ByteBuffer buf)78 {79 logFormat = buf.get();80 disableLogSpeed = buf.get();81 speedThres = buf.getInt();82 disableLogDist = buf.get();83 distThres = buf.getInt();84 swATime = buf.getInt();85 swBTime = buf.getInt();86 swCTime = buf.getInt();87 unk1 = buf.getShort();88 swATimeOrDist = buf.get();89 swBTimeOrDist = buf.get();90 swCTimeOrDist = buf.get();91 swADist = buf.getInt();92 swBDist = buf.getInt();93 swCDist = buf.getInt();94 unk2 = buf.get();95 remainder = buf.get();96 unk3 = buf.get();97 unk4 = buf.get();98 }99 100 public Dg100Config(String fName)101 throws Exception102 {103 readProps(fName);104 }105 106 public String toString()107 {108 return 109 "[Dg100Config: logFormat = " + logFormat110 + ",disableLogSpeed = " + disableLogSpeed111 + ",speedThres = " + speedThres112 + ",disableLogDist = " + disableLogDist113 + ",distThres = " + distThres114 + ",swATime = " + swATime115 + ",swBTime = " + swBTime116 + ",swCTime = " + swCTime117 + ",unk1 = " + unk1118 + ",swATimeOrDist = " + swATimeOrDist119 + ",swBTimeOrDist = " + swBTimeOrDist120 + ",swCTimeOrDist = " + swCTimeOrDist121 + ",swADist = " + swADist122 + ",swBDist = " + swBDist123 + ",swCDist = " + swCDist124 + ",unk2 = " + unk2125 + ",remainder = " + remainder126 + ",unk3 = " + unk3127 + ",unk4 = " + unk4128 ;129 }130 131 /**132 * @param buf133 */134 public void write(ByteBuffer buf)135 {136 buf.position(5);137 buf.put(logFormat);138 buf.put(disableLogSpeed);139 buf.putInt(speedThres);140 buf.put(disableLogDist);141 buf.putInt(distThres);142 buf.putInt(swATime);143 buf.putInt(swBTime);144 buf.putInt(swCTime);145 buf.putShort(unk1);146 buf.put(swATimeOrDist);147 buf.put(swBTimeOrDist);148 buf.put(swCTimeOrDist);149 buf.putInt(swADist);150 buf.putInt(swBDist);151 buf.putInt(swCDist);152 buf.put(unk2);153 }154 155 /**156 * @return Returns the disableLogDist.157 */158 public boolean getDisableLogDist()159 {160 return disableLogDist != 0;161 }162 163 /**164 * @param disableLogDist The disableLogDist to set.165 */166 public void setDisableLogDist(boolean disableLogDist)167 {37 private byte logFormat = -1; 38 private byte disableLogSpeed = -1; 39 private int speedThres = -1; 40 private byte disableLogDist = -1; 41 private int distThres = -1; 42 private int swATime = -1; 43 private int swBTime = -1; 44 private int swCTime = -1; 45 private short unk1 = -1; 46 private byte swATimeOrDist = -1; 47 private byte swBTimeOrDist = -1; 48 private byte swCTimeOrDist = -1; 49 private int swADist = -1; 50 private int swBDist = -1; 51 private int swCDist = -1; 52 private byte unk2 = -1; 53 private int remainder = -1; 54 private int unk3 = -1; 55 private int unk4 = -1; 56 57 private static String propLogFormat = "logFormat"; 58 private static String propDisableLogSpeed = "disableLogSpeed"; 59 private static String propSpeedThres = "speedThres"; 60 private static String propDisableLogDist = "disableLogDist"; 61 private static String propDistThres = "distThres"; 62 private static String propSwATime = "swATime"; 63 private static String propSwBTime = "swBTime"; 64 private static String propSwCTime = "swCTime"; 65 private static String propUnk1 = "unk1"; 66 private static String propSwATimeOrDist = "swATimeOrDist"; 67 private static String propSwBTimeOrDist = "swBTimeOrDist"; 68 private static String propSwCTimeOrDist = "swCTimeOrDist"; 69 private static String propSwADist = "swADist"; 70 private static String propSwBDist = "swBDist"; 71 private static String propSwCDist = "swCDist"; 72 private static String propUnk2 = "unk2"; 73 private static String propRemainder = "remainder"; 74 private static String propUnk3 = "unk3"; 75 private static String propUnk4 = "unk4"; 76 77 public Dg100Config(ByteBuffer buf) 78 { 79 logFormat = buf.get(); 80 disableLogSpeed = buf.get(); 81 speedThres = buf.getInt(); 82 disableLogDist = buf.get(); 83 distThres = buf.getInt(); 84 swATime = buf.getInt(); 85 swBTime = buf.getInt(); 86 swCTime = buf.getInt(); 87 unk1 = buf.getShort(); 88 swATimeOrDist = buf.get(); 89 swBTimeOrDist = buf.get(); 90 swCTimeOrDist = buf.get(); 91 swADist = buf.getInt(); 92 swBDist = buf.getInt(); 93 swCDist = buf.getInt(); 94 unk2 = buf.get(); 95 remainder = buf.get(); 96 unk3 = buf.get(); 97 unk4 = buf.get(); 98 } 99 100 public Dg100Config(String fName) 101 throws Exception 102 { 103 readProps(fName); 104 } 105 106 public String toString() 107 { 108 return 109 "[Dg100Config: logFormat = " + logFormat 110 + ",disableLogSpeed = " + disableLogSpeed 111 + ",speedThres = " + speedThres 112 + ",disableLogDist = " + disableLogDist 113 + ",distThres = " + distThres 114 + ",swATime = " + swATime 115 + ",swBTime = " + swBTime 116 + ",swCTime = " + swCTime 117 + ",unk1 = " + unk1 118 + ",swATimeOrDist = " + swATimeOrDist 119 + ",swBTimeOrDist = " + swBTimeOrDist 120 + ",swCTimeOrDist = " + swCTimeOrDist 121 + ",swADist = " + swADist 122 + ",swBDist = " + swBDist 123 + ",swCDist = " + swCDist 124 + ",unk2 = " + unk2 125 + ",remainder = " + remainder 126 + ",unk3 = " + unk3 127 + ",unk4 = " + unk4 128 ; 129 } 130 131 /** 132 * @param buf 133 */ 134 public void write(ByteBuffer buf) 135 { 136 buf.position(5); 137 buf.put(logFormat); 138 buf.put(disableLogSpeed); 139 buf.putInt(speedThres); 140 buf.put(disableLogDist); 141 buf.putInt(distThres); 142 buf.putInt(swATime); 143 buf.putInt(swBTime); 144 buf.putInt(swCTime); 145 buf.putShort(unk1); 146 buf.put(swATimeOrDist); 147 buf.put(swBTimeOrDist); 148 buf.put(swCTimeOrDist); 149 buf.putInt(swADist); 150 buf.putInt(swBDist); 151 buf.putInt(swCDist); 152 buf.put(unk2); 153 } 154 155 /** 156 * @return Returns the disableLogDist. 157 */ 158 public boolean getDisableLogDist() 159 { 160 return disableLogDist != 0; 161 } 162 163 /** 164 * @param disableLogDist The disableLogDist to set. 165 */ 166 public void setDisableLogDist(boolean disableLogDist) 167 { 168 168 this.disableLogDist = (byte)(disableLogDist ? 1 : 0); 169 }170 171 /**172 * @return Returns the disableLogSpeed.173 */174 public boolean getDisableLogSpeed()175 {176 return disableLogSpeed != 0;177 }178 179 /**180 * @param disableLogSpeed The disableLogSpeed to set.181 */182 public void setDisableLogSpeed(boolean disableLogSpeed)183 {169 } 170 171 /** 172 * @return Returns the disableLogSpeed. 173 */ 174 public boolean getDisableLogSpeed() 175 { 176 return disableLogSpeed != 0; 177 } 178 179 /** 180 * @param disableLogSpeed The disableLogSpeed to set. 181 */ 182 public void setDisableLogSpeed(boolean disableLogSpeed) 183 { 184 184 this.disableLogSpeed = (byte)(disableLogSpeed ? 1 : 0); 185 }186 187 /**188 * @return Returns the distThres.189 */190 public int getDistThres()191 {192 return distThres;193 }194 195 /**196 * @param distThres The distThres to set.197 */198 public void setDistThres(int distThres)199 {200 this.distThres = distThres;201 }202 203 /**204 * @return Returns the logFormat.205 */206 public byte getLogFormat()207 {208 return logFormat;209 }210 211 /**212 * @param logFormat The logFormat to set.213 */214 public void setLogFormat(byte logFormat)215 {216 this.logFormat = logFormat;217 }218 219 /**220 * @return Returns the speedThres.221 */222 public int getSpeedThres()223 {224 return speedThres;225 }226 227 /**228 * @param speedThres The speedThres to set.229 */230 public void setSpeedThres(int speedThres)231 {232 this.speedThres = speedThres;233 }234 235 /**236 * @return Returns the swADist.237 */238 public int getSwADist()239 {240 return swADist;241 }242 243 /**244 * @param swADist The swADist to set.245 */246 public void setSwADist(int swADist)247 {248 this.swADist = swADist;249 }250 251 /**252 * @return Returns the swATime.253 */254 public int getSwATime()255 {256 return swATime;257 }258 259 /**260 * @param swATime The swATime to set.261 */262 public void setSwATime(int swATime)263 {264 this.swATime = swATime;265 }266 267 /**268 * @return Returns the swATimeOrDist.269 */270 public byte getSwATimeOrDist()271 {272 return swATimeOrDist;273 }274 275 /**276 * @param swATimeOrDist The swATimeOrDist to set.277 */278 public void setSwATimeOrDist(byte swATimeOrDist)279 {280 this.swATimeOrDist = swATimeOrDist;281 }282 283 /**284 * @return Returns the swBDist.285 */286 public int getSwBDist()287 {288 return swBDist;289 }290 291 /**292 * @param swBDist The swBDist to set.293 */294 public void setSwBDist(int swBDist)295 {296 this.swBDist = swBDist;297 }298 299 /**300 * @return Returns the swBTime.301 */302 public int getSwBTime()303 {304 return swBTime;305 }306 307 /**308 * @param swBTime The swBTime to set.309 */310 public void setSwBTime(int swBTime)311 {312 this.swBTime = swBTime;313 }314 315 /**316 * @return Returns the swBTimeOrDist.317 */318 public byte getSwBTimeOrDist()319 {320 return swBTimeOrDist;321 }322 323 /**324 * @param swBTimeOrDist The swBTimeOrDist to set.325 */326 public void setSwBTimeOrDist(byte swBTimeOrDist)327 {328 this.swBTimeOrDist = swBTimeOrDist;329 }330 331 /**332 * @return Returns the swCDist.333 */334 public int getSwCDist()335 {336 return swCDist;337 }338 339 /**340 * @param swCDist The swCDist to set.341 */342 public void setSwCDist(int swCDist)343 {344 this.swCDist = swCDist;345 }346 347 /**348 * @return Returns the swCTime.349 */350 public int getSwCTime()351 {352 return swCTime;353 }354 355 /**356 * @param swCTime The swCTime to set.357 */358 public void setSwCTime(int swCTime)359 {360 this.swCTime = swCTime;361 }362 363 /**364 * @return Returns the swCTimeOrDist.365 */366 public byte getSwCTimeOrDist()367 {368 return swCTimeOrDist;369 }370 371 /**372 * @param swCTimeOrDist The swCTimeOrDist to set.373 */374 public void setSwCTimeOrDist(byte swCTimeOrDist)375 {376 this.swCTimeOrDist = swCTimeOrDist;377 }378 379 /**380 * @return Returns the unk1.381 */382 public short getUnk1()383 {384 return unk1;385 }386 387 /**388 * @param unk1 The unk1 to set.389 */390 public void setUnk1(short unk1)391 {392 this.unk1 = unk1;393 }394 395 /**396 * @return Returns the unk2.397 */398 public byte getUnk2()399 {400 return unk2;401 }402 403 /**404 * @param unk2 The unk2 to set.405 */406 public void setUnk2(byte unk2)407 {408 this.unk2 = unk2;409 }410 411 /**412 * @return Returns the remainder.413 */414 public int getRemainder()415 {416 return remainder;417 }418 419 /**420 * @return Returns the unk3.421 */422 public int getUnk3()423 {424 return unk3;425 }426 427 /**428 * @return Returns the unk4.429 */430 public int getUnk4()431 {432 return unk4;433 }434 435 public void writeProps(String fName)436 throws Exception437 {438 Properties props = new Properties();439 props.setProperty(propLogFormat, "" + logFormat);440 props.setProperty(propDisableLogSpeed, "" + disableLogSpeed);441 props.setProperty(propSpeedThres, "" + speedThres);442 props.setProperty(propDisableLogDist, "" + disableLogDist);443 props.setProperty(propDistThres, "" + distThres);444 props.setProperty(propSwATime, "" + swATime);445 props.setProperty(propSwBTime, "" + swBTime);446 props.setProperty(propSwCTime, "" + swCTime);447 props.setProperty(propUnk1, "" + unk1);448 props.setProperty(propSwATimeOrDist, "" + swATimeOrDist);449 props.setProperty(propSwBTimeOrDist, "" + swBTimeOrDist);450 props.setProperty(propSwCTimeOrDist, "" + swCTimeOrDist);451 props.setProperty(propSwADist, "" + swADist);452 props.setProperty(propSwBDist, "" + swBDist);453 props.setProperty(propSwCDist, "" + swCDist);454 props.setProperty(propUnk2, "" + unk2);455 props.setProperty(propRemainder, "" + remainder);456 props.setProperty(propUnk3, "" + unk3);457 props.setProperty(propUnk4, "" + unk4);458 OutputStream os = null;459 try460 {461 os = new FileOutputStream(fName);462 props.store(os, "dg100 config");463 }464 catch (Exception ex)465 {466 ex.printStackTrace();467 throw ex;468 }469 finally470 {471 if (os != null) {os.close();}472 }473 }474 475 public void readProps(String fName)476 throws Exception477 {478 Properties props = new Properties();479 InputStream is = null;480 try481 {482 is = new FileInputStream(fName);483 props.load(is);484 }485 catch (Exception ex)486 {487 ex.printStackTrace();488 throw ex;489 }490 finally491 {492 if (is != null) {is.close();}493 }494 logFormat = Byte.parseByte(props.getProperty(propLogFormat, "2"));495 disableLogSpeed = Byte.parseByte(props.getProperty(propDisableLogSpeed, "0"));496 speedThres = Integer.parseInt(props.getProperty(propSpeedThres, "0"));497 disableLogDist = Byte.parseByte(props.getProperty(propDisableLogDist, "0"));498 distThres = Integer.parseInt(props.getProperty(propDistThres, "0"));499 swATime = Integer.parseInt(props.getProperty(propSwATime, "1000"));500 swBTime = Integer.parseInt(props.getProperty(propSwBTime, "1000"));501 swCTime = Integer.parseInt(props.getProperty(propSwCTime, "1000"));502 swATimeOrDist = Byte.parseByte(props.getProperty(propSwATimeOrDist, "0"));503 swBTimeOrDist = Byte.parseByte(props.getProperty(propSwBTimeOrDist, "0"));504 swCTimeOrDist = Byte.parseByte(props.getProperty(propSwCTimeOrDist, "0"));505 swADist = Integer.parseInt(props.getProperty(propSwADist, "0"));506 swBDist = Integer.parseInt(props.getProperty(propSwBDist, "0"));507 swCDist = Integer.parseInt(props.getProperty(propSwCDist, "0"));508 unk1 = Short.parseShort(props.getProperty(propUnk1, "0"));509 unk2 = Byte.parseByte(props.getProperty(propUnk2, "0"));510 unk3 = Integer.parseInt(props.getProperty(propUnk3, "0"));511 unk4 = Integer.parseInt(props.getProperty(propUnk4, "0"));512 }185 } 186 187 /** 188 * @return Returns the distThres. 189 */ 190 public int getDistThres() 191 { 192 return distThres; 193 } 194 195 /** 196 * @param distThres The distThres to set. 197 */ 198 public void setDistThres(int distThres) 199 { 200 this.distThres = distThres; 201 } 202 203 /** 204 * @return Returns the logFormat. 205 */ 206 public byte getLogFormat() 207 { 208 return logFormat; 209 } 210 211 /** 212 * @param logFormat The logFormat to set. 213 */ 214 public void setLogFormat(byte logFormat) 215 { 216 this.logFormat = logFormat; 217 } 218 219 /** 220 * @return Returns the speedThres. 221 */ 222 public int getSpeedThres() 223 { 224 return speedThres; 225 } 226 227 /** 228 * @param speedThres The speedThres to set. 229 */ 230 public void setSpeedThres(int speedThres) 231 { 232 this.speedThres = speedThres; 233 } 234 235 /** 236 * @return Returns the swADist. 237 */ 238 public int getSwADist() 239 { 240 return swADist; 241 } 242 243 /** 244 * @param swADist The swADist to set. 245 */ 246 public void setSwADist(int swADist) 247 { 248 this.swADist = swADist; 249 } 250 251 /** 252 * @return Returns the swATime. 253 */ 254 public int getSwATime() 255 { 256 return swATime; 257 } 258 259 /** 260 * @param swATime The swATime to set. 261 */ 262 public void setSwATime(int swATime) 263 { 264 this.swATime = swATime; 265 } 266 267 /** 268 * @return Returns the swATimeOrDist. 269 */ 270 public byte getSwATimeOrDist() 271 { 272 return swATimeOrDist; 273 } 274 275 /** 276 * @param swATimeOrDist The swATimeOrDist to set. 277 */ 278 public void setSwATimeOrDist(byte swATimeOrDist) 279 { 280 this.swATimeOrDist = swATimeOrDist; 281 } 282 283 /** 284 * @return Returns the swBDist. 285 */ 286 public int getSwBDist() 287 { 288 return swBDist; 289 } 290 291 /** 292 * @param swBDist The swBDist to set. 293 */ 294 public void setSwBDist(int swBDist) 295 { 296 this.swBDist = swBDist; 297 } 298 299 /** 300 * @return Returns the swBTime. 301 */ 302 public int getSwBTime() 303 { 304 return swBTime; 305 } 306 307 /** 308 * @param swBTime The swBTime to set. 309 */ 310 public void setSwBTime(int swBTime) 311 { 312 this.swBTime = swBTime; 313 } 314 315 /** 316 * @return Returns the swBTimeOrDist. 317 */ 318 public byte getSwBTimeOrDist() 319 { 320 return swBTimeOrDist; 321 } 322 323 /** 324 * @param swBTimeOrDist The swBTimeOrDist to set. 325 */ 326 public void setSwBTimeOrDist(byte swBTimeOrDist) 327 { 328 this.swBTimeOrDist = swBTimeOrDist; 329 } 330 331 /** 332 * @return Returns the swCDist. 333 */ 334 public int getSwCDist() 335 { 336 return swCDist; 337 } 338 339 /** 340 * @param swCDist The swCDist to set. 341 */ 342 public void setSwCDist(int swCDist) 343 { 344 this.swCDist = swCDist; 345 } 346 347 /** 348 * @return Returns the swCTime. 349 */ 350 public int getSwCTime() 351 { 352 return swCTime; 353 } 354 355 /** 356 * @param swCTime The swCTime to set. 357 */ 358 public void setSwCTime(int swCTime) 359 { 360 this.swCTime = swCTime; 361 } 362 363 /** 364 * @return Returns the swCTimeOrDist. 365 */ 366 public byte getSwCTimeOrDist() 367 { 368 return swCTimeOrDist; 369 } 370 371 /** 372 * @param swCTimeOrDist The swCTimeOrDist to set. 373 */ 374 public void setSwCTimeOrDist(byte swCTimeOrDist) 375 { 376 this.swCTimeOrDist = swCTimeOrDist; 377 } 378 379 /** 380 * @return Returns the unk1. 381 */ 382 public short getUnk1() 383 { 384 return unk1; 385 } 386 387 /** 388 * @param unk1 The unk1 to set. 389 */ 390 public void setUnk1(short unk1) 391 { 392 this.unk1 = unk1; 393 } 394 395 /** 396 * @return Returns the unk2. 397 */ 398 public byte getUnk2() 399 { 400 return unk2; 401 } 402 403 /** 404 * @param unk2 The unk2 to set. 405 */ 406 public void setUnk2(byte unk2) 407 { 408 this.unk2 = unk2; 409 } 410 411 /** 412 * @return Returns the remainder. 413 */ 414 public int getRemainder() 415 { 416 return remainder; 417 } 418 419 /** 420 * @return Returns the unk3. 421 */ 422 public int getUnk3() 423 { 424 return unk3; 425 } 426 427 /** 428 * @return Returns the unk4. 429 */ 430 public int getUnk4() 431 { 432 return unk4; 433 } 434 435 public void writeProps(String fName) 436 throws Exception 437 { 438 Properties props = new Properties(); 439 props.setProperty(propLogFormat, "" + logFormat); 440 props.setProperty(propDisableLogSpeed, "" + disableLogSpeed); 441 props.setProperty(propSpeedThres, "" + speedThres); 442 props.setProperty(propDisableLogDist, "" + disableLogDist); 443 props.setProperty(propDistThres, "" + distThres); 444 props.setProperty(propSwATime, "" + swATime); 445 props.setProperty(propSwBTime, "" + swBTime); 446 props.setProperty(propSwCTime, "" + swCTime); 447 props.setProperty(propUnk1, "" + unk1); 448 props.setProperty(propSwATimeOrDist, "" + swATimeOrDist); 449 props.setProperty(propSwBTimeOrDist, "" + swBTimeOrDist); 450 props.setProperty(propSwCTimeOrDist, "" + swCTimeOrDist); 451 props.setProperty(propSwADist, "" + swADist); 452 props.setProperty(propSwBDist, "" + swBDist); 453 props.setProperty(propSwCDist, "" + swCDist); 454 props.setProperty(propUnk2, "" + unk2); 455 props.setProperty(propRemainder, "" + remainder); 456 props.setProperty(propUnk3, "" + unk3); 457 props.setProperty(propUnk4, "" + unk4); 458 OutputStream os = null; 459 try 460 { 461 os = new FileOutputStream(fName); 462 props.store(os, "dg100 config"); 463 } 464 catch (Exception ex) 465 { 466 ex.printStackTrace(); 467 throw ex; 468 } 469 finally 470 { 471 if (os != null) {os.close();} 472 } 473 } 474 475 public void readProps(String fName) 476 throws Exception 477 { 478 Properties props = new Properties(); 479 InputStream is = null; 480 try 481 { 482 is = new FileInputStream(fName); 483 props.load(is); 484 } 485 catch (Exception ex) 486 { 487 ex.printStackTrace(); 488 throw ex; 489 } 490 finally 491 { 492 if (is != null) {is.close();} 493 } 494 logFormat = Byte.parseByte(props.getProperty(propLogFormat, "2")); 495 disableLogSpeed = Byte.parseByte(props.getProperty(propDisableLogSpeed, "0")); 496 speedThres = Integer.parseInt(props.getProperty(propSpeedThres, "0")); 497 disableLogDist = Byte.parseByte(props.getProperty(propDisableLogDist, "0")); 498 distThres = Integer.parseInt(props.getProperty(propDistThres, "0")); 499 swATime = Integer.parseInt(props.getProperty(propSwATime, "1000")); 500 swBTime = Integer.parseInt(props.getProperty(propSwBTime, "1000")); 501 swCTime = Integer.parseInt(props.getProperty(propSwCTime, "1000")); 502 swATimeOrDist = Byte.parseByte(props.getProperty(propSwATimeOrDist, "0")); 503 swBTimeOrDist = Byte.parseByte(props.getProperty(propSwBTimeOrDist, "0")); 504 swCTimeOrDist = Byte.parseByte(props.getProperty(propSwCTimeOrDist, "0")); 505 swADist = Integer.parseInt(props.getProperty(propSwADist, "0")); 506 swBDist = Integer.parseInt(props.getProperty(propSwBDist, "0")); 507 swCDist = Integer.parseInt(props.getProperty(propSwCDist, "0")); 508 unk1 = Short.parseShort(props.getProperty(propUnk1, "0")); 509 unk2 = Byte.parseByte(props.getProperty(propUnk2, "0")); 510 unk3 = Integer.parseInt(props.getProperty(propUnk3, "0")); 511 unk4 = Integer.parseInt(props.getProperty(propUnk4, "0")); 512 } 513 513 514 514 } -
applications/editors/josm/plugins/globalsat/src/org/kaintoch/gps/globalsat/dg100/FileInfoRec.java
r10378 r12778 13 13 public class FileInfoRec 14 14 { 15 private int timeZ = 0; 16 private int date = 0; 17 private int idx = 0; 18 19 public FileInfoRec(ByteBuffer buf) 20 { 21 timeZ = buf.getInt(); 22 date = buf.getInt(); 23 idx = buf.getInt(); 24 } 25 26 public String toString() 27 { 28 return "[FileInfoRec: timeZ = " + timeZ + ", date = " + date + ", idx = " + idx + "]"; 29 } 15 private int timeZ = 0; 16 private int date = 0; 17 private int idx = 0; 30 18 31 /** 32 * @return Returns the idx. 33 */ 34 public int getIdx() 35 { 36 return idx; 37 } 19 public FileInfoRec(ByteBuffer buf) 20 { 21 timeZ = buf.getInt(); 22 date = buf.getInt(); 23 idx = buf.getInt(); 24 } 25 26 public String toString() 27 { 28 return "[FileInfoRec: timeZ = " + timeZ + ", date = " + date + ", idx = " + idx + "]"; 29 } 30 31 /** 32 * @return Returns the idx. 33 */ 34 public int getIdx() 35 { 36 return idx; 37 } 38 38 } -
applications/editors/josm/plugins/globalsat/src/org/kaintoch/gps/globalsat/dg100/GpsRec.java
r12588 r12778 22 22 // ff ff ff ff: dg100Altitude (m): alt * 10000 23 23 24 private int dg100Latitude = -1;25 private int dg100Longitude = -1;26 private int dg100TimeZ = -1;27 private int dg100Date = -1;28 private int dg100Speed = -1;29 private int dg100Altitude = -1;30 private int dg100Unk1 = -1;31 private int dg100TypeOfCurRec = -1;32 private int dg100TypeOfNextRec = -1;33 // calculated data34 private Calendar dateTime = null;35 36 public GpsRec()37 {38 dg100TypeOfNextRec = 2;39 dg100TypeOfCurRec = 2;40 dg100Latitude = 0;41 dg100Longitude = 0;42 dg100TimeZ = 0;43 dg100Date = 0;44 dg100Speed = 0;45 dg100Altitude = 0;46 dg100Unk1 = -1;47 dateTime = null;48 }49 50 public void copy(GpsRec init)51 {52 dg100TypeOfNextRec = init.dg100TypeOfNextRec;53 dg100TypeOfCurRec = init.dg100TypeOfCurRec;54 dg100Latitude = init.dg100Latitude;55 dg100Longitude = init.dg100Longitude;56 dg100TimeZ = init.dg100TimeZ;57 dg100Date = init.dg100Date;58 dg100Speed = init.dg100Speed;59 dg100Altitude = init.dg100Altitude;60 dg100Unk1 = init.dg100Unk1;61 dateTime = init.dateTime;62 }63 64 public GpsRec(GpsRec init)65 {66 copy(init);67 }68 69 /**70 * @see java.lang.Object#equals(java.lang.Object)71 */72 public boolean equals(Object arg0)73 {74 boolean isEqual = false;75 if (arg0 != null && arg0 instanceof GpsRec)76 {77 GpsRec otherGpsRec = (GpsRec)arg0;78 isEqual =79 dg100TypeOfNextRec == otherGpsRec.dg100TypeOfNextRec80 && dg100TypeOfCurRec == otherGpsRec.dg100TypeOfCurRec81 && dg100Latitude == otherGpsRec.dg100Latitude82 && dg100Longitude == otherGpsRec.dg100Longitude83 && dg100TimeZ == otherGpsRec.dg100TimeZ84 && dg100Date == otherGpsRec.dg100Date85 && dg100Speed == otherGpsRec.dg100Speed86 && dg100Altitude == otherGpsRec.dg100Altitude87 //&& dg100Unk1 == otherGpsRec.unk188 ;89 }90 return isEqual;91 }92 93 public GpsRec(ByteBuffer buf, int recType)94 {95 dg100Latitude = buf.getInt();96 dg100Longitude = buf.getInt();97 dg100TypeOfNextRec = recType;98 dg100TypeOfCurRec = recType;99 dateTime = null;100 if (dg100TypeOfNextRec >= 1)101 {102 dg100TimeZ = buf.getInt();103 dg100Date = buf.getInt();104 calcDateTime();105 dg100Speed = buf.getInt();106 if (dg100TypeOfNextRec >= 1)107 {108 dg100Altitude = buf.getInt();109 dg100Unk1 = buf.getInt();110 dg100TypeOfNextRec = buf.getInt();111 }112 }113 }114 115 /**116 * Shows wether this is a valid GPS record.117 * @return true if GPS record is valid; otherwise false.118 */119 public boolean isValid()120 {121 return122 dg100Latitude <= 360000000123 && dg100Latitude >= 0124 && dg100Longitude <= 360000000125 && dg100Longitude >= 0126 && dg100TimeZ >= 0127 && dg100TimeZ <= 240000128 && dg100Unk1 >= 0129 && dg100Unk1 <= 1130 ;131 }132 133 public int getDg100TypeOfNextRec()134 {135 return dg100TypeOfNextRec;136 }137 138 public int getDg100TypeOfCurRec()139 {140 return dg100TypeOfCurRec;141 }142 143 public String toString()144 {145 return "[GpsRec: "146 + " Lat = " + dg100Latitude147 + ", Long = " + dg100Longitude148 + ", TimeZ = " + dg100TimeZ149 + ", Date = " + dg100Date150 + ", Speed = " + dg100Speed151 + ", Alt = " + dg100Altitude152 + ", Unk1 = " + dg100Unk1153 + ", TypeOfCurRec = " + dg100TypeOfCurRec154 + ", TypeOfNextRec = " + dg100TypeOfNextRec155 + "]";156 }157 158 /**159 * @return Returns the dg100Latitude.160 */161 public int getDg100Latitude()162 {163 return dg100Latitude;164 }165 166 /**167 * Converts this object to its GPX representation.168 * @return this object's GPX representation as a String.169 */170 public String toGpxTrkpt()171 {172 // <trkpt lat="47.6972383333" lon="11.4178650000">173 // <ele>662.0000000000</ele>174 // <time>2007-04-21T13:56:05Z</time>175 // <dg100Speed>1.0833333333</dg100Speed>176 // </trkpt>177 StringBuffer buf = new StringBuffer(500);178 buf.append("<trkpt");179 buf.append(" lat=\"").append(getLatitude()).append("\"");180 buf.append(" lon=\"").append(getLongitude()).append("\"");181 buf.append(">");182 if (dg100TypeOfCurRec > 0)183 {184 if (dg100TypeOfCurRec > 1)185 {186 buf.append("<ele>").append(getAltitude()).append("</ele>");187 }188 buf.append("<time>").append(getStringZuluTime()).append("</time>");189 buf.append("<speed>").append(getSpeed()).append("</speed>");190 }191 buf.append("</trkpt>");192 return buf.toString();193 }194 195 /**196 * Converts this object to its GPX waypoint representation.197 * @return this object's GPX representation as a String.198 */199 public String toGpxWpt()200 {201 // <wpt lat="47.6972383333" lon="11.4178650000">202 // <ele>662.0000000000</ele>203 // <time>2007-04-21T13:56:05Z</time>204 // </wpt>205 StringBuffer buf = new StringBuffer(500);206 buf.append("<wpt");207 buf.append(" lat=\"").append(getLatitude()).append("\"");208 buf.append(" lon=\"").append(getLongitude()).append("\"");209 buf.append(">");210 if (dg100TypeOfCurRec > 0)211 {212 if (dg100TypeOfCurRec > 1)213 {214 buf.append("<ele>").append(getAltitude()).append("</ele>");215 }216 buf.append("<time>").append(getStringZuluTime()).append("</time>");217 }218 buf.append("</wpt>");219 return buf.toString();220 }221 222 /**223 * Converts GlobalSat dg100Latitude and dg100Longitude internal format to degrees.224 * @param gsLatOrLon225 * @return nodeg in degrees226 */227 private double toDegree(int gsLatOrLon)228 {229 int scale = 1000000;230 double deg = 9999.9999;231 double degScaled = (double)(gsLatOrLon / scale);232 double minScaled = ((double)(gsLatOrLon - degScaled * scale)) / 600000.0;233 deg = degScaled + minScaled;234 return deg;235 }236 237 /**238 * Gets dg100Date and time as a String in GPX dg100Date-time-format (aka zulu time).239 * @return a dg100Date-time-string in GPX dg100Date-time-format (aka zulu time).240 */241 public String getStringZuluTime()242 {243 return getStringDateTime("yyyy-MM-dd'T'HH:mm:ss'Z'");244 }245 246 /**247 * Gets dg100Date and time as a String in format "yyyyMMddHHmmss".248 * @return a dg100Date-time-string in format "yyyyMMddHHmmss".249 */250 public String getStringDateTime()251 {252 return getStringDateTime("yyyyMMddHHmmss");253 }254 255 /**256 * Gets dg100Date and time as a String in given format.257 * @param dateTimeFormat258 * @return259 */260 private String getStringDateTime(String dateTimeFormat)261 {262 String dateTimeString = "???";263 if (dateTime != null)264 {265 SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat);266 //logger.info(gsTime + " " + gsDate);267 dateTimeString = sdf.format(dateTime.getTime());268 }269 return dateTimeString;270 }271 272 /**273 * @return Returns the dg100Altitude.274 */275 public int getDg100Altitude()276 {277 return dg100Altitude;278 }279 280 /**281 * @param dg100Altitude The dg100Altitude to set.282 */283 private void setDg100Altitude(int altitude)284 {285 this.dg100Altitude = altitude;286 }287 288 /**289 * @return Returns the dg100Date.290 */291 public int getDg100Date()292 {293 return dg100Date;294 }295 296 /**297 * @param dg100Date The dg100Date to set.298 */299 private void setDg100Date(int date)300 {301 this.dg100Date = date;302 calcDateTime();303 }304 305 /**306 * @return307 */308 private void calcDateTime()309 {310 int hh = dg100TimeZ / 10000;311 int mm = (dg100TimeZ - hh * 10000) / 100;312 int ss = dg100TimeZ - hh * 10000 - mm * 100;313 int DD = dg100Date / 10000;314 int MM = (dg100Date - DD * 10000) / 100;315 int YY = dg100Date - DD * 10000 - MM * 100;316 dateTime = GregorianCalendar.getInstance();317 dateTime.set(2000 + YY, MM, DD, hh, mm, ss);318 }319 320 /**321 * @return Returns the dg100Longitude.322 */323 public int getDg100Longitude()324 {325 return dg100Longitude;326 }327 328 /**329 * @param dg100Longitude The dg100Longitude to set.330 */331 private void setDg100Longitude(int longitude)332 {333 this.dg100Longitude = longitude;334 }335 336 /**337 * @return Returns the dg100Speed.338 */339 public int getDg100Speed()340 {341 return dg100Speed;342 }343 344 /**345 * @param dg100Speed The dg100Speed to set.346 */347 private void setDg100Speed(int speed)348 {349 this.dg100Speed = speed;350 }351 352 /**353 * @return Returns the dg100TimeZ.354 */355 public int getDg100TimeZ()356 {357 return dg100TimeZ;358 }359 360 /**361 * @param dg100TimeZ The dg100TimeZ to set.362 */363 private void setDg100TimeZ(int timeZ)364 {365 this.dg100TimeZ = timeZ;366 calcDateTime();367 }368 369 /**370 * @param dg100Latitude The dg100Latitude to set.371 */372 private void setDg100Latitude(int latitude)373 {374 this.dg100Latitude = latitude;375 }376 377 public void updateMin(GpsRec next)378 {379 if (next != null)380 {381 if (next.getDg100Latitude() < getDg100Latitude()) {setDg100Latitude(next.getDg100Latitude());}382 if (next.getDg100Longitude() < getDg100Longitude()) {setDg100Longitude(next.getDg100Longitude());}383 if (next.getDg100Altitude() < getDg100Altitude()) {setDg100Altitude(next.getDg100Altitude());}384 if (next.getDg100Date() < getDg100Date()385 || (next.getDg100Date() == getDg100Date() && next.getDg100TimeZ() < getDg100TimeZ())386 )387 {388 setDg100Date(next.getDg100Date());389 setDg100TimeZ(next.getDg100TimeZ());390 }391 if (next.getDg100Speed() < getDg100Speed()) {setDg100Speed(next.getDg100Speed());}392 }393 }394 395 public void updateMax(GpsRec next)396 {397 if (next != null)398 {399 if (next.getDg100Latitude() > getDg100Latitude()) {setDg100Latitude(next.getDg100Latitude());}400 if (next.getDg100Longitude() > getDg100Longitude()) {setDg100Longitude(next.getDg100Longitude());}401 if (next.getDg100Altitude() > getDg100Altitude()) {setDg100Altitude(next.getDg100Altitude());}402 if (next.getDg100Date() > getDg100Date()403 || (next.getDg100Date() == getDg100Date() && next.getDg100TimeZ() > getDg100TimeZ())404 )405 {406 setDg100Date(next.getDg100Date());407 setDg100TimeZ(next.getDg100TimeZ());408 }409 if (next.getDg100Speed() > getDg100Speed()) {setDg100Speed(next.getDg100Speed());}410 }411 }412 413 /**414 * @return Returns the dateTime.415 */416 public Calendar getDateTime()417 {418 return dateTime;419 }420 421 public double getLatitude()422 {423 return toDegree(dg100Latitude);424 }425 426 public double getLongitude()427 {428 return toDegree(dg100Longitude);429 }430 431 public double getAltitude()432 {433 return dg100Altitude / (double)10000.0;434 }435 436 public double getSpeed()437 {438 return dg100Speed / (double)360.0;439 }24 private int dg100Latitude = -1; 25 private int dg100Longitude = -1; 26 private int dg100TimeZ = -1; 27 private int dg100Date = -1; 28 private int dg100Speed = -1; 29 private int dg100Altitude = -1; 30 private int dg100Unk1 = -1; 31 private int dg100TypeOfCurRec = -1; 32 private int dg100TypeOfNextRec = -1; 33 // calculated data 34 private Calendar dateTime = null; 35 36 public GpsRec() 37 { 38 dg100TypeOfNextRec = 2; 39 dg100TypeOfCurRec = 2; 40 dg100Latitude = 0; 41 dg100Longitude = 0; 42 dg100TimeZ = 0; 43 dg100Date = 0; 44 dg100Speed = 0; 45 dg100Altitude = 0; 46 dg100Unk1 = -1; 47 dateTime = null; 48 } 49 50 public void copy(GpsRec init) 51 { 52 dg100TypeOfNextRec = init.dg100TypeOfNextRec; 53 dg100TypeOfCurRec = init.dg100TypeOfCurRec; 54 dg100Latitude = init.dg100Latitude; 55 dg100Longitude = init.dg100Longitude; 56 dg100TimeZ = init.dg100TimeZ; 57 dg100Date = init.dg100Date; 58 dg100Speed = init.dg100Speed; 59 dg100Altitude = init.dg100Altitude; 60 dg100Unk1 = init.dg100Unk1; 61 dateTime = init.dateTime; 62 } 63 64 public GpsRec(GpsRec init) 65 { 66 copy(init); 67 } 68 69 /** 70 * @see java.lang.Object#equals(java.lang.Object) 71 */ 72 public boolean equals(Object arg0) 73 { 74 boolean isEqual = false; 75 if (arg0 != null && arg0 instanceof GpsRec) 76 { 77 GpsRec otherGpsRec = (GpsRec)arg0; 78 isEqual = 79 dg100TypeOfNextRec == otherGpsRec.dg100TypeOfNextRec 80 && dg100TypeOfCurRec == otherGpsRec.dg100TypeOfCurRec 81 && dg100Latitude == otherGpsRec.dg100Latitude 82 && dg100Longitude == otherGpsRec.dg100Longitude 83 && dg100TimeZ == otherGpsRec.dg100TimeZ 84 && dg100Date == otherGpsRec.dg100Date 85 && dg100Speed == otherGpsRec.dg100Speed 86 && dg100Altitude == otherGpsRec.dg100Altitude 87 //&& dg100Unk1 == otherGpsRec.unk1 88 ; 89 } 90 return isEqual; 91 } 92 93 public GpsRec(ByteBuffer buf, int recType) 94 { 95 dg100Latitude = buf.getInt(); 96 dg100Longitude = buf.getInt(); 97 dg100TypeOfNextRec = recType; 98 dg100TypeOfCurRec = recType; 99 dateTime = null; 100 if (dg100TypeOfNextRec >= 1) 101 { 102 dg100TimeZ = buf.getInt(); 103 dg100Date = buf.getInt(); 104 calcDateTime(); 105 dg100Speed = buf.getInt(); 106 if (dg100TypeOfNextRec >= 1) 107 { 108 dg100Altitude = buf.getInt(); 109 dg100Unk1 = buf.getInt(); 110 dg100TypeOfNextRec = buf.getInt(); 111 } 112 } 113 } 114 115 /** 116 * Shows wether this is a valid GPS record. 117 * @return true if GPS record is valid; otherwise false. 118 */ 119 public boolean isValid() 120 { 121 return 122 dg100Latitude <= 360000000 123 && dg100Latitude >= 0 124 && dg100Longitude <= 360000000 125 && dg100Longitude >= 0 126 && dg100TimeZ >= 0 127 && dg100TimeZ <= 240000 128 && dg100Unk1 >= 0 129 && dg100Unk1 <= 1 130 ; 131 } 132 133 public int getDg100TypeOfNextRec() 134 { 135 return dg100TypeOfNextRec; 136 } 137 138 public int getDg100TypeOfCurRec() 139 { 140 return dg100TypeOfCurRec; 141 } 142 143 public String toString() 144 { 145 return "[GpsRec: " 146 + " Lat = " + dg100Latitude 147 + ", Long = " + dg100Longitude 148 + ", TimeZ = " + dg100TimeZ 149 + ", Date = " + dg100Date 150 + ", Speed = " + dg100Speed 151 + ", Alt = " + dg100Altitude 152 + ", Unk1 = " + dg100Unk1 153 + ", TypeOfCurRec = " + dg100TypeOfCurRec 154 + ", TypeOfNextRec = " + dg100TypeOfNextRec 155 + "]"; 156 } 157 158 /** 159 * @return Returns the dg100Latitude. 160 */ 161 public int getDg100Latitude() 162 { 163 return dg100Latitude; 164 } 165 166 /** 167 * Converts this object to its GPX representation. 168 * @return this object's GPX representation as a String. 169 */ 170 public String toGpxTrkpt() 171 { 172 // <trkpt lat="47.6972383333" lon="11.4178650000"> 173 // <ele>662.0000000000</ele> 174 // <time>2007-04-21T13:56:05Z</time> 175 // <dg100Speed>1.0833333333</dg100Speed> 176 // </trkpt> 177 StringBuffer buf = new StringBuffer(500); 178 buf.append("<trkpt"); 179 buf.append(" lat=\"").append(getLatitude()).append("\""); 180 buf.append(" lon=\"").append(getLongitude()).append("\""); 181 buf.append(">"); 182 if (dg100TypeOfCurRec > 0) 183 { 184 if (dg100TypeOfCurRec > 1) 185 { 186 buf.append("<ele>").append(getAltitude()).append("</ele>"); 187 } 188 buf.append("<time>").append(getStringZuluTime()).append("</time>"); 189 buf.append("<speed>").append(getSpeed()).append("</speed>"); 190 } 191 buf.append("</trkpt>"); 192 return buf.toString(); 193 } 194 195 /** 196 * Converts this object to its GPX waypoint representation. 197 * @return this object's GPX representation as a String. 198 */ 199 public String toGpxWpt() 200 { 201 // <wpt lat="47.6972383333" lon="11.4178650000"> 202 // <ele>662.0000000000</ele> 203 // <time>2007-04-21T13:56:05Z</time> 204 // </wpt> 205 StringBuffer buf = new StringBuffer(500); 206 buf.append("<wpt"); 207 buf.append(" lat=\"").append(getLatitude()).append("\""); 208 buf.append(" lon=\"").append(getLongitude()).append("\""); 209 buf.append(">"); 210 if (dg100TypeOfCurRec > 0) 211 { 212 if (dg100TypeOfCurRec > 1) 213 { 214 buf.append("<ele>").append(getAltitude()).append("</ele>"); 215 } 216 buf.append("<time>").append(getStringZuluTime()).append("</time>"); 217 } 218 buf.append("</wpt>"); 219 return buf.toString(); 220 } 221 222 /** 223 * Converts GlobalSat dg100Latitude and dg100Longitude internal format to degrees. 224 * @param gsLatOrLon 225 * @return nodeg in degrees 226 */ 227 private double toDegree(int gsLatOrLon) 228 { 229 int scale = 1000000; 230 double deg = 9999.9999; 231 double degScaled = (double)(gsLatOrLon / scale); 232 double minScaled = ((double)(gsLatOrLon - degScaled * scale)) / 600000.0; 233 deg = degScaled + minScaled; 234 return deg; 235 } 236 237 /** 238 * Gets dg100Date and time as a String in GPX dg100Date-time-format (aka zulu time). 239 * @return a dg100Date-time-string in GPX dg100Date-time-format (aka zulu time). 240 */ 241 public String getStringZuluTime() 242 { 243 return getStringDateTime("yyyy-MM-dd'T'HH:mm:ss'Z'"); 244 } 245 246 /** 247 * Gets dg100Date and time as a String in format "yyyyMMddHHmmss". 248 * @return a dg100Date-time-string in format "yyyyMMddHHmmss". 249 */ 250 public String getStringDateTime() 251 { 252 return getStringDateTime("yyyyMMddHHmmss"); 253 } 254 255 /** 256 * Gets dg100Date and time as a String in given format. 257 * @param dateTimeFormat 258 * @return 259 */ 260 private String getStringDateTime(String dateTimeFormat) 261 { 262 String dateTimeString = "???"; 263 if (dateTime != null) 264 { 265 SimpleDateFormat sdf = new SimpleDateFormat(dateTimeFormat); 266 //logger.info(gsTime + " " + gsDate); 267 dateTimeString = sdf.format(dateTime.getTime()); 268 } 269 return dateTimeString; 270 } 271 272 /** 273 * @return Returns the dg100Altitude. 274 */ 275 public int getDg100Altitude() 276 { 277 return dg100Altitude; 278 } 279 280 /** 281 * @param dg100Altitude The dg100Altitude to set. 282 */ 283 private void setDg100Altitude(int altitude) 284 { 285 this.dg100Altitude = altitude; 286 } 287 288 /** 289 * @return Returns the dg100Date. 290 */ 291 public int getDg100Date() 292 { 293 return dg100Date; 294 } 295 296 /** 297 * @param dg100Date The dg100Date to set. 298 */ 299 private void setDg100Date(int date) 300 { 301 this.dg100Date = date; 302 calcDateTime(); 303 } 304 305 /** 306 * @return 307 */ 308 private void calcDateTime() 309 { 310 int hh = dg100TimeZ / 10000; 311 int mm = (dg100TimeZ - hh * 10000) / 100; 312 int ss = dg100TimeZ - hh * 10000 - mm * 100; 313 int DD = dg100Date / 10000; 314 int MM = (dg100Date - DD * 10000) / 100; 315 int YY = dg100Date - DD * 10000 - MM * 100; 316 dateTime = GregorianCalendar.getInstance(); 317 dateTime.set(2000 + YY, MM, DD, hh, mm, ss); 318 } 319 320 /** 321 * @return Returns the dg100Longitude. 322 */ 323 public int getDg100Longitude() 324 { 325 return dg100Longitude; 326 } 327 328 /** 329 * @param dg100Longitude The dg100Longitude to set. 330 */ 331 private void setDg100Longitude(int longitude) 332 { 333 this.dg100Longitude = longitude; 334 } 335 336 /** 337 * @return Returns the dg100Speed. 338 */ 339 public int getDg100Speed() 340 { 341 return dg100Speed; 342 } 343 344 /** 345 * @param dg100Speed The dg100Speed to set. 346 */ 347 private void setDg100Speed(int speed) 348 { 349 this.dg100Speed = speed; 350 } 351 352 /** 353 * @return Returns the dg100TimeZ. 354 */ 355 public int getDg100TimeZ() 356 { 357 return dg100TimeZ; 358 } 359 360 /** 361 * @param dg100TimeZ The dg100TimeZ to set. 362 */ 363 private void setDg100TimeZ(int timeZ) 364 { 365 this.dg100TimeZ = timeZ; 366 calcDateTime(); 367 } 368 369 /** 370 * @param dg100Latitude The dg100Latitude to set. 371 */ 372 private void setDg100Latitude(int latitude) 373 { 374 this.dg100Latitude = latitude; 375 } 376 377 public void updateMin(GpsRec next) 378 { 379 if (next != null) 380 { 381 if (next.getDg100Latitude() < getDg100Latitude()) {setDg100Latitude(next.getDg100Latitude());} 382 if (next.getDg100Longitude() < getDg100Longitude()) {setDg100Longitude(next.getDg100Longitude());} 383 if (next.getDg100Altitude() < getDg100Altitude()) {setDg100Altitude(next.getDg100Altitude());} 384 if (next.getDg100Date() < getDg100Date() 385 || (next.getDg100Date() == getDg100Date() && next.getDg100TimeZ() < getDg100TimeZ()) 386 ) 387 { 388 setDg100Date(next.getDg100Date()); 389 setDg100TimeZ(next.getDg100TimeZ()); 390 } 391 if (next.getDg100Speed() < getDg100Speed()) {setDg100Speed(next.getDg100Speed());} 392 } 393 } 394 395 public void updateMax(GpsRec next) 396 { 397 if (next != null) 398 { 399 if (next.getDg100Latitude() > getDg100Latitude()) {setDg100Latitude(next.getDg100Latitude());} 400 if (next.getDg100Longitude() > getDg100Longitude()) {setDg100Longitude(next.getDg100Longitude());} 401 if (next.getDg100Altitude() > getDg100Altitude()) {setDg100Altitude(next.getDg100Altitude());} 402 if (next.getDg100Date() > getDg100Date() 403 || (next.getDg100Date() == getDg100Date() && next.getDg100TimeZ() > getDg100TimeZ()) 404 ) 405 { 406 setDg100Date(next.getDg100Date()); 407 setDg100TimeZ(next.getDg100TimeZ()); 408 } 409 if (next.getDg100Speed() > getDg100Speed()) {setDg100Speed(next.getDg100Speed());} 410 } 411 } 412 413 /** 414 * @return Returns the dateTime. 415 */ 416 public Calendar getDateTime() 417 { 418 return dateTime; 419 } 420 421 public double getLatitude() 422 { 423 return toDegree(dg100Latitude); 424 } 425 426 public double getLongitude() 427 { 428 return toDegree(dg100Longitude); 429 } 430 431 public double getAltitude() 432 { 433 return dg100Altitude / (double)10000.0; 434 } 435 436 public double getSpeed() 437 { 438 return dg100Speed / (double)360.0; 439 } 440 440 441 441 } -
applications/editors/josm/plugins/globalsat/src/org/kaintoch/gps/globalsat/dg100/Response.java
r10378 r12778 14 14 public class Response 15 15 { 16 final static public byte typeFileInfo = (byte)0xBB;17 final static public byte typeId = (byte)0xBF;18 final static public byte typeGpsRec = (byte)0xB5;19 final static public byte typeConfig = (byte)0xB7;16 final static public byte typeFileInfo = (byte)0xBB; 17 final static public byte typeId = (byte)0xBF; 18 final static public byte typeGpsRec = (byte)0xB5; 19 final static public byte typeConfig = (byte)0xB7; 20 20 21 private int typeOfResponse = 0; 22 private int cntDataCur = 0; 23 private int nextIdx = 0; 24 private Dg100Config config = null; 25 private List data = new ArrayList(100); 26 private long id = 0; 27 28 private Response(int typeOfResponse) 29 { 30 this.typeOfResponse = typeOfResponse; 31 } 21 private int typeOfResponse = 0; 22 private int cntDataCur = 0; 23 private int nextIdx = 0; 24 private Dg100Config config = null; 25 private List data = new ArrayList(100); 26 private long id = 0; 32 27 33 /** 34 * 35 * @param resp 36 */ 37 static public Response parseResponse(byte resp[], int len) 38 { 39 ByteBuffer buf = ByteBuffer.wrap(resp); 40 byte respType = buf.get(4); 41 Response response = new Response(respType); 42 buf.position(5); 43 if (respType == typeFileInfo) // file info 44 { 45 int cntInfoCur = buf.getShort(); 46 int nextIdx = buf.getShort(); 47 response.cntDataCur = cntInfoCur; 48 response.nextIdx = nextIdx; 49 for (int ii = 0 ; ii < cntInfoCur ; ++ii) 50 { 51 FileInfoRec fileInfoRec = new FileInfoRec(buf); 52 response.addRec(fileInfoRec); 53 } 54 } 55 else if (respType == typeGpsRec) // gps recs 56 { 57 int recType = 2; 58 int ii = 0; 59 // read part 1 60 while (buf.position() <= len) 61 { 62 GpsRec gpsRec = new GpsRec(buf, recType); 63 if (gpsRec.isValid() && buf.position() <= len) 64 { 65 response.addRec(gpsRec); 66 } 67 else 68 { 69 break; 70 } 71 recType = gpsRec.getDg100TypeOfNextRec(); 72 ++ii; 73 } 74 // read part 2 75 buf.position(1042); 76 while (buf.position() <= len) 77 { 78 GpsRec gpsRec = new GpsRec(buf, recType); 79 if (gpsRec.isValid() && buf.position() <= len) 80 { 81 response.addRec(gpsRec); 82 } 83 else 84 { 85 break; 86 } 87 recType = gpsRec.getDg100TypeOfNextRec(); 88 ++ii; 89 } 90 } 91 else if (respType == typeConfig) // config 92 { 93 Dg100Config config = new Dg100Config(buf); 94 response.config = config; 95 } 96 else if (respType == typeId) // id 97 { 98 response.id = 0; 99 for (int ii = 0 ; ii < 8 ; ++ii) 100 { 101 int digit = (int)buf.get(); 102 response.id = response.id * 10 + digit; 103 } 104 } 105 else 106 { 107 } 108 return response; 109 } 28 private Response(int typeOfResponse) 29 { 30 this.typeOfResponse = typeOfResponse; 31 } 110 32 111 private void addRec(Object obj) 112 { 113 data.add(obj); 114 } 33 /** 34 * 35 * @param resp 36 */ 37 static public Response parseResponse(byte resp[], int len) 38 { 39 ByteBuffer buf = ByteBuffer.wrap(resp); 40 byte respType = buf.get(4); 41 Response response = new Response(respType); 42 buf.position(5); 43 if (respType == typeFileInfo) // file info 44 { 45 int cntInfoCur = buf.getShort(); 46 int nextIdx = buf.getShort(); 47 response.cntDataCur = cntInfoCur; 48 response.nextIdx = nextIdx; 49 for (int ii = 0 ; ii < cntInfoCur ; ++ii) 50 { 51 FileInfoRec fileInfoRec = new FileInfoRec(buf); 52 response.addRec(fileInfoRec); 53 } 54 } 55 else if (respType == typeGpsRec) // gps recs 56 { 57 int recType = 2; 58 int ii = 0; 59 // read part 1 60 while (buf.position() <= len) 61 { 62 GpsRec gpsRec = new GpsRec(buf, recType); 63 if (gpsRec.isValid() && buf.position() <= len) 64 { 65 response.addRec(gpsRec); 66 } 67 else 68 { 69 break; 70 } 71 recType = gpsRec.getDg100TypeOfNextRec(); 72 ++ii; 73 } 74 // read part 2 75 buf.position(1042); 76 while (buf.position() <= len) 77 { 78 GpsRec gpsRec = new GpsRec(buf, recType); 79 if (gpsRec.isValid() && buf.position() <= len) 80 { 81 response.addRec(gpsRec); 82 } 83 else 84 { 85 break; 86 } 87 recType = gpsRec.getDg100TypeOfNextRec(); 88 ++ii; 89 } 90 } 91 else if (respType == typeConfig) // config 92 { 93 Dg100Config config = new Dg100Config(buf); 94 response.config = config; 95 } 96 else if (respType == typeId) // id 97 { 98 response.id = 0; 99 for (int ii = 0 ; ii < 8 ; ++ii) 100 { 101 int digit = (int)buf.get(); 102 response.id = response.id * 10 + digit; 103 } 104 } 105 else 106 { 107 } 108 return response; 109 } 115 110 116 public List getRecs()117 {118 return data;119 }111 private void addRec(Object obj) 112 { 113 data.add(obj); 114 } 120 115 121 /** 122 * @return Returns the cntDataCur. 123 */ 124 public int getCntDataCur() 125 { 126 return cntDataCur; 127 } 116 public List getRecs() 117 { 118 return data; 119 } 128 120 129 /**130 * @return Returns thenextIdx.131 */132 public int getNextIdx()133 {134 returnnextIdx;135 }121 /** 122 * @return Returns the cntDataCur. 123 */ 124 public int getCntDataCur() 125 { 126 return cntDataCur; 127 } 136 128 137 /**138 * @return Returns thetypeOfResponse.139 */140 public int getTypeOfResponse()141 {142 returntypeOfResponse;143 }129 /** 130 * @return Returns the nextIdx. 131 */ 132 public int getNextIdx() 133 { 134 return nextIdx; 135 } 144 136 145 /**146 * @return Returns theconfig.147 */148 publicDg100Config getConfig()149 {150 returnconfig;151 }137 /** 138 * @return Returns the typeOfResponse. 139 */ 140 public int getTypeOfResponse() 141 { 142 return typeOfResponse; 143 } 152 144 153 /** 154 * @return Returns the id. 155 */ 156 public long getId() 157 { 158 return id; 159 } 145 /** 146 * @return Returns the config. 147 */ 148 public Dg100Config getConfig() 149 { 150 return config; 151 } 152 153 /** 154 * @return Returns the id. 155 */ 156 public long getId() 157 { 158 return id; 159 } 160 160 161 161 } -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatConfigDialog.java
r11555 r12778 50 50 /** 51 51 * Configuration download dialog. 52 * 52 * 53 53 * @author Raphael Mack <ramack@raphael-mack.de> 54 54 * … … 58 58 59 59 public class IntegerTextField extends JTextField { 60 60 61 61 final static String badchars = "-`~!@#$%^&*()_+=\\|\"':;?/>.<, "; 62 62 63 63 public void processKeyEvent(KeyEvent ev) { 64 64 65 65 char c = ev.getKeyChar(); 66 if((Character.isLetter(c) && !ev.isAltDown()) 66 if((Character.isLetter(c) && !ev.isAltDown()) 67 67 || badchars.indexOf(c) > -1) { 68 68 ev.consume(); … … 74 74 75 75 76 76 77 77 // the JOptionPane that contains this dialog. required for the closeDialog() method. 78 78 private JOptionPane optionPane; … … 103 103 104 104 private List<CommPortIdentifier> ports = new LinkedList<CommPortIdentifier>(); 105 105 106 106 private Dg100Config conf; 107 107 … … 132 132 logFormat.add(formatPosTDS); 133 133 logFormat.add(formatPosTDSA); 134 134 135 135 JPanel logPanel = new JPanel(); 136 136 logPanel.setLayout(new BoxLayout(logPanel, BoxLayout.PAGE_AXIS)); … … 209 209 minLogSpeed.setText("" + conf.getSpeedThres()); 210 210 minLogDist.setText("" + conf.getDistThres()); 211 211 212 212 ButtonGroup group = new ButtonGroup(); 213 213 group.add(aTime); … … 261 261 c.gridy = 6; 262 262 add(bMeters, c); 263 263 264 264 group = new ButtonGroup(); 265 265 group.add(cTime); 266 266 group.add(cDist); 267 267 268 268 c.insets = new Insets(4,4,0,4); 269 269 c.gridwidth = 1; … … 307 307 JOptionPane.showMessageDialog(Main.parent, tr("Unknown logFormat")); 308 308 } 309 309 310 310 if(conf.getSwATimeOrDist() == 0){ 311 311 aTime.setSelected(true); -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatDg100.java
r11555 r12778 45 45 46 46 public static final int TIMEOUT = 2000; 47 public static final int TRACK_TYPE = 1; 48 47 public static final int TRACK_TYPE = 1; 48 49 49 /** delete file: A0 A2 00 02 BC 01 00 BD B0 B3 */ 50 50 private static byte dg100CmdSwitch2Nmea[] = … … 111 111 , (byte) 0x00, (byte) 0x00, (byte) 0x00, (byte) 0x00 112 112 , (byte) 0x00, (byte) 0xC0, (byte) 0xB0, (byte) 0xB3}; 113 113 114 114 private byte[] response = new byte[65536]; 115 115 116 116 private CommPortIdentifier portIdentifier; 117 117 private SerialPort port = null; 118 118 119 119 private boolean cancelled = false; 120 120 121 121 public GlobalsatDg100(CommPortIdentifier portId){ 122 122 this.portIdentifier = portId; … … 178 178 return result; 179 179 } 180 180 181 181 public void deleteData() throws ConnectionException{ 182 182 if(port == null){ … … 189 189 } 190 190 } 191 191 192 192 public void disconnect(){ 193 193 if(port != null){ … … 210 210 } 211 211 } 212 212 213 213 private List<FileInfoRec> readFileInfoList() throws ConnectionException 214 214 { … … 226 226 } 227 227 } 228 228 229 229 public List<GpsRec> readGpsRecList(List<FileInfoRec> fileInfoList) throws ConnectionException 230 230 { 231 231 int cnt = 0; 232 232 List<GpsRec> result = new ArrayList<GpsRec>(200); 233 233 234 234 try{ 235 235 for(FileInfoRec fileInfoRec:fileInfoList){ … … 243 243 } 244 244 } 245 245 246 246 private Response sendCmdDelFiles() throws IOException, UnsupportedCommOperationException 247 247 { … … 317 317 return Response.parseResponse(response, len); 318 318 } 319 319 320 320 /** 321 321 * … … 348 348 } 349 349 350 350 351 351 private int readResponse(byte[] response, int bytesToRead) throws IOException, UnsupportedCommOperationException 352 352 { … … 396 396 } 397 397 return ((cntBytTot > bytesToRead) ? bytesToRead : cntBytTot); 398 }398 } 399 399 return -1; 400 400 } -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatImportDialog.java
r11555 r12778 39 39 /** 40 40 * Main download dialog. 41 * 41 * 42 42 * @author Raphael Mack <ramack@raphael-mack.de> 43 43 * 44 44 */ 45 45 public class GlobalsatImportDialog extends JPanel { 46 46 47 47 // the JOptionPane that contains this dialog. required for the closeDialog() method. 48 48 private JOptionPane optionPane; … … 111 111 System.out.println("configureing the device"); 112 112 try{ 113 113 114 114 GlobalsatConfigDialog dialog = new GlobalsatConfigDialog(GlobalsatPlugin.dg100().getConfig()); 115 115 JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); … … 136 136 add(configBtn, c); 137 137 138 138 139 139 delete = new JCheckBox(tr("delete data after import")); 140 140 delete.setSelected(Main.pref.getBoolean("globalsat.deleteAfterDownload", false)); … … 167 167 168 168 } 169 169 170 170 public boolean deleteFilesAfterDownload(){ 171 171 return delete.isSelected(); -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatPlugin.java
r12707 r12778 106 106 } 107 107 } 108 108 109 109 class GlobalsatImportAction extends JosmAction{ 110 110 public GlobalsatImportAction(){
Note:
See TracChangeset
for help on using the changeset viewer.
