Changeset 11555 in osm for applications/editors/josm/plugins/globalsat/src/org
- Timestamp:
- 2008-10-29T22:29:00+01:00 (16 years ago)
- Location:
- applications/editors/josm/plugins/globalsat/src/org
- Files:
-
- 1 added
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
applications/editors/josm/plugins/globalsat/src/org/kaintoch/gps/globalsat/dg100/Dg100Config.java
r10378 r11555 156 156 * @return Returns the disableLogDist. 157 157 */ 158 public b ytegetDisableLogDist()159 { 160 return disableLogDist ;158 public boolean getDisableLogDist() 159 { 160 return disableLogDist != 0; 161 161 } 162 162 … … 164 164 * @param disableLogDist The disableLogDist to set. 165 165 */ 166 public void setDisableLogDist(b ytedisableLogDist)167 { 168 this.disableLogDist = disableLogDist;166 public void setDisableLogDist(boolean disableLogDist) 167 { 168 this.disableLogDist = (byte)(disableLogDist ? 1 : 0); 169 169 } 170 170 … … 172 172 * @return Returns the disableLogSpeed. 173 173 */ 174 public b ytegetDisableLogSpeed()175 { 176 return disableLogSpeed ;174 public boolean getDisableLogSpeed() 175 { 176 return disableLogSpeed != 0; 177 177 } 178 178 … … 180 180 * @param disableLogSpeed The disableLogSpeed to set. 181 181 */ 182 public void setDisableLogSpeed(b ytedisableLogSpeed)183 { 184 this.disableLogSpeed = disableLogSpeed;182 public void setDisableLogSpeed(boolean disableLogSpeed) 183 { 184 this.disableLogSpeed = (byte)(disableLogSpeed ? 1 : 0); 185 185 } 186 186 -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatDg100.java
r11496 r11555 18 18 19 19 import org.kaintoch.gps.globalsat.dg100.Response; 20 import org.kaintoch.gps.globalsat.dg100.Dg100Config; 20 21 import org.kaintoch.gps.globalsat.dg100.FileInfoRec; 21 22 import org.kaintoch.gps.globalsat.dg100.GpsRec; … … 124 125 public void cancel(){ 125 126 cancelled = true; 127 disconnect(); 126 128 } 127 129 … … 258 260 int len = sendCmd(src, response, -1); 259 261 return Response.parseResponse(response, len); 262 } 263 264 private Response sendCmdGetConfig() throws IOException, UnsupportedCommOperationException 265 { 266 byte[] src = dg100CmdGetConfig; 267 int len = sendCmd(src, response, -1); 268 return Response.parseResponse(response, len); 269 } 270 271 public Dg100Config getConfig() throws ConnectionException{ 272 try{ 273 if(port == null){ 274 connect(); 275 } 276 Response response = sendCmdGetConfig(); 277 return response.getConfig(); 278 }catch(Exception e){ 279 throw new ConnectionException(e); 280 } 281 } 282 283 284 private void sendCmdSetConfig(Dg100Config config) throws IOException, UnsupportedCommOperationException 285 { 286 byte[] src = dg100CmdSetConfig; 287 ByteBuffer buf = ByteBuffer.wrap(src); 288 if (config != null){ 289 config.write(buf); 290 } 291 updateCheckSum(buf); 292 int len = sendCmd(src, response, -1); 293 294 Response.parseResponse(response, len); 295 } 296 297 public void setConfig(Dg100Config conf) throws ConnectionException{ 298 try{ 299 sendCmdSetConfig(conf); 300 }catch(Exception e){ 301 throw new ConnectionException(e); 302 } 260 303 } 261 304 -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatImportDialog.java
r11496 r11555 22 22 import javax.swing.JComboBox; 23 23 import javax.swing.ListCellRenderer; 24 import javax.swing.JDialog; 24 25 25 26 import gnu.io.*; … … 70 71 Object i = portCombo.getSelectedItem(); 71 72 if(i instanceof CommPortIdentifier){ 73 GlobalsatPlugin.setPortIdent((CommPortIdentifier)i); 72 74 Main.pref.put("globalsat.portIdentifier", ((CommPortIdentifier)i).getName()); 73 75 } … … 108 110 public void actionPerformed(java.awt.event.ActionEvent e){ 109 111 System.out.println("configureing the device"); 112 try{ 113 114 GlobalsatConfigDialog dialog = new GlobalsatConfigDialog(GlobalsatPlugin.dg100().getConfig()); 115 JOptionPane pane = new JOptionPane(dialog, JOptionPane.PLAIN_MESSAGE, JOptionPane.OK_CANCEL_OPTION); 116 JDialog dlg = pane.createDialog(Main.parent, tr("Configure Device")); 117 dialog.setOptionPane(pane); 118 dlg.setVisible(true); 119 if(((Integer)pane.getValue()) == JOptionPane.OK_OPTION){ 120 GlobalsatPlugin.dg100().setConfig(dialog.getConfig()); 121 } 122 dlg.dispose(); 123 124 }catch(GlobalsatDg100.ConnectionException ex){ 125 JOptionPane.showMessageDialog(Main.parent, tr("Connection Error.") + " " + ex.toString()); 126 } 127 System.out.println("configureing the device finised"); 110 128 } 111 129 }); … … 116 134 c.gridx = 2; 117 135 c.gridy = 1; 118 //add(configBtn, c);136 add(configBtn, c); 119 137 120 138 … … 141 159 if(sel != null && port.getName() == sel){ 142 160 portCombo.setSelectedItem(port); 161 GlobalsatPlugin.setPortIdent(port); 143 162 } 144 163 } 145 164 } 146 165 portCombo.setVisible(true); 166 GlobalsatPlugin.setPortIdent(getPort()); 167 147 168 } 148 169 -
applications/editors/josm/plugins/globalsat/src/org/openstreetmap/josm/plugins/globalsat/GlobalsatPlugin.java
r11496 r11555 27 27 28 28 public class GlobalsatPlugin extends Plugin { 29 private static GlobalsatDg100 device = null; 30 public static GlobalsatDg100 dg100(){ 31 return device; 32 } 33 34 public static void setPortIdent(CommPortIdentifier port){ 35 if(device != null){ 36 device.disconnect(); 37 } 38 device = new GlobalsatDg100(port); 39 } 29 40 30 41 private static class ImportTask extends PleaseWaitRunnable { 31 42 public GpxData data; 32 private GlobalsatDg100 dg100;33 43 public Exception eee; 34 44 private boolean deleteAfter; 35 45 36 public ImportTask( GlobalsatDg100 dg100,boolean delete){46 public ImportTask(boolean delete){ 37 47 super(tr("Importing data from device.")); 38 this.dg100 = dg100;39 48 deleteAfter = delete; 40 49 } … … 44 53 Main.pleaseWaitDlg.currentAction.setText(tr("Importing data from DG100...")); 45 54 try{ 46 data = dg100.readData();55 data = GlobalsatPlugin.dg100().readData(); 47 56 }catch(Exception e){ 48 57 eee = e; … … 51 60 52 61 @Override protected void finish() { 53 if(deleteAfter && dg100.isCancelled() == false){62 if(deleteAfter && GlobalsatPlugin.dg100().isCancelled() == false){ 54 63 Main.pref.put("globalsat.deleteAfterDownload", true); 55 64 try{ 56 dg100.deleteData();65 GlobalsatPlugin.dg100().deleteData(); 57 66 }catch(Exception ex){ 58 67 JOptionPane.showMessageDialog(Main.parent, tr("Error deleting data.") + " " + ex.toString()); … … 72 81 JOptionPane.showMessageDialog(Main.parent, tr("Connection failed.") + " (" + eee.toString() + ")"); 73 82 } 74 dg100.disconnect();83 GlobalsatPlugin.dg100().disconnect(); 75 84 } 76 85 77 86 @Override protected void cancel() { 78 dg100.cancel();79 dg100.disconnect();87 GlobalsatPlugin.dg100().cancel(); 88 GlobalsatPlugin.dg100().disconnect(); 80 89 } 81 90 } … … 108 117 dlg.setVisible(true); 109 118 if(((Integer)pane.getValue()) == JOptionPane.OK_OPTION){ 110 GlobalsatDg100 dg100 = new GlobalsatDg100(dialog.getPort());111 ImportTask task = new ImportTask(d g100, dialog.deleteFilesAfterDownload());119 setPortIdent(dialog.getPort()); 120 ImportTask task = new ImportTask(dialog.deleteFilesAfterDownload()); 112 121 Main.worker.execute(task); 113 122 }
Note:
See TracChangeset
for help on using the changeset viewer.