Changeset 3337 in osm for applications/editors/josm/plugins
- Timestamp:
- 2007-06-25T19:10:28+02:00 (17 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/livegps/livegps/LiveGpsAcquirer.java
r3076 r3337 22 22 boolean shutdownFlag = false; 23 23 private List<PropertyChangeListener> propertyChangeListener = new ArrayList<PropertyChangeListener>(); 24 private PropertyChangeEvent lastStatusEvent; 25 private PropertyChangeEvent lastDataEvent; 24 26 25 27 public LiveGpsAcquirer() { … … 45 47 public void fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus status, String statusMessage) { 46 48 PropertyChangeEvent event = new PropertyChangeEvent(this, "gpsstatus", null, new LiveGpsStatus(status, statusMessage)); 47 firePropertyChangeEvent(event); 49 if(!event.equals(lastStatusEvent)) { 50 firePropertyChangeEvent(event); 51 lastStatusEvent = event; 52 } 48 53 } 49 54 … … 56 61 public void fireGpsDataChangeEvent(LiveGpsData oldData, LiveGpsData newData) { 57 62 PropertyChangeEvent event = new PropertyChangeEvent(this, "gpsdata", oldData, newData); 58 firePropertyChangeEvent(event); 63 if(!event.equals(lastDataEvent)) { 64 firePropertyChangeEvent(event); 65 lastDataEvent = event; 66 } 59 67 } 60 68 … … 84 92 if (!connected) 85 93 { 94 System.out.println("LiveGps try to connect to gpsd"); 86 95 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTING, tr("Connecting")); 87 96 InetAddress[] addrs = InetAddress.getAllByName(gpsdHost); … … 99 108 gpsdReader = new BufferedReader(new InputStreamReader(gpsdSocket.getInputStream())); 100 109 gpsdSocket.getOutputStream().write(new byte[] { 'w', 13, 10 }); 101 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECT ED, tr("Connected"));110 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTING, tr("Connecting")); 102 111 connected = true; 103 112 } … … 106 115 107 116 if(connected) { 117 // <FIXXME date="23.06.2007" author="cdaller"> 118 // TODO this read is blocking if gps is connected but has no fix, so gpsd does not send positions 108 119 String line = gpsdReader.readLine(); 120 // </FIXXME> 109 121 if (line == null) break; 110 122 String words[] = line.split(","); … … 155 167 // not interested 156 168 } 169 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTED, tr("Connected")); 157 170 gpsData.setFix(haveFix); 158 171 if (haveFix) { … … 166 179 } else { 167 180 // not connected: 181 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not connected")); 168 182 try { Thread.sleep(1000); } catch (InterruptedException ignore) {}; 169 183 } 170 184 } catch(IOException iox) { 171 185 connected = false; 172 gpsData.setFix(false); 173 fireGpsDataChangeEvent(oldGpsData, gpsData); 186 if(gpsData != null) { 187 gpsData.setFix(false); 188 fireGpsDataChangeEvent(oldGpsData, gpsData); 189 } 174 190 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.CONNECTION_FAILED, tr("Connection Failed")); 175 191 try { Thread.sleep(1000); } catch (InterruptedException ignore) {}; … … 178 194 } 179 195 } 180 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr(" Disconnected"));196 fireGpsStatusChangeEvent(LiveGpsStatus.GpsStatus.DISCONNECTED, tr("Not connected")); 181 197 if (gpsdSocket != null) try { gpsdSocket.close(); } catch (Exception ignore) {}; 182 198 }
Note:
See TracChangeset
for help on using the changeset viewer.