Revision 4763 trunk/extensions/extGPS/src/org/gvsig/gps/GPSDriver.java
GPSDriver.java | ||
---|---|---|
43 | 43 |
* |
44 | 44 |
* $Id$ |
45 | 45 |
* $Log$ |
46 |
* Revision 1.4 2006-04-07 08:27:48 jaume
|
|
46 |
* Revision 1.5 2006-04-07 11:10:26 jaume
|
|
47 | 47 |
* *** empty log message *** |
48 | 48 |
* |
49 |
* Revision 1.4 2006/04/07 08:27:48 jaume |
|
50 |
* *** empty log message *** |
|
51 |
* |
|
49 | 52 |
* Revision 1.3 2006/04/06 10:34:46 jaume |
50 | 53 |
* *** empty log message *** |
51 | 54 |
* |
... | ... | |
70 | 73 |
import gnu.io.SerialPort; |
71 | 74 |
import gnu.io.UnsupportedCommOperationException; |
72 | 75 |
|
76 |
import java.io.BufferedWriter; |
|
77 |
import java.io.File; |
|
78 |
import java.io.FileWriter; |
|
73 | 79 |
import java.io.IOException; |
74 | 80 |
import java.io.InputStream; |
75 | 81 |
import java.io.OutputStream; |
... | ... | |
79 | 85 |
import java.util.Iterator; |
80 | 86 |
|
81 | 87 |
import org.gvsig.gps.listeners.GPSEventListener; |
82 |
import org.gvsig.gps.parser.NMEA.*; |
|
88 |
import org.gvsig.gps.parser.NMEA.GGASentence; |
|
89 |
import org.gvsig.gps.parser.NMEA.IllegalSentenceException; |
|
90 |
import org.gvsig.gps.parser.NMEA.NMEASentence; |
|
91 |
import org.gvsig.gps.parser.NMEA.NMEASentenceFactory; |
|
92 |
import org.gvsig.gps.parser.NMEA.RMCSentence; |
|
93 |
import org.gvsig.gps.parser.NMEA.VTGSentence; |
|
83 | 94 |
|
84 | 95 |
/** |
85 | 96 |
* Singleton class that handles the communication within the application and the |
... | ... | |
111 | 122 |
|
112 | 123 |
private static GPSDriver instance = null; |
113 | 124 |
|
125 |
|
|
126 |
|
|
127 |
private static String fileName = "c:/gps points.txt"; |
|
128 |
static BufferedWriter bw ; |
|
129 |
|
|
114 | 130 |
/** |
115 | 131 |
* Public instantiation of the driver is forbidden. |
116 | 132 |
*/ |
... | ... | |
119 | 135 |
public static GPSDriver getInstance() { |
120 | 136 |
if (instance == null) |
121 | 137 |
instance = new GPSDriver(); |
138 |
if (bw == null) |
|
139 |
try { |
|
140 |
bw = new BufferedWriter(new FileWriter(new File(fileName))); |
|
141 |
} catch (IOException e) { |
|
142 |
// TODO Auto-generated catch block |
|
143 |
e.printStackTrace(); |
|
144 |
} |
|
122 | 145 |
return instance; |
123 | 146 |
} |
124 | 147 |
|
... | ... | |
249 | 272 |
// This is a valid record |
250 | 273 |
if (aux instanceof GGASentence) { |
251 | 274 |
GGASentence s = (GGASentence) aux; |
275 |
{ |
|
276 |
try { |
|
277 |
bw.write(s.getLongitude() + "," + s.getLatitude()+"\n"); |
|
278 |
bw.flush(); |
|
279 |
} catch (IOException e) { |
|
280 |
// TODO Auto-generated catch block |
|
281 |
e.printStackTrace(); |
|
282 |
} |
|
283 |
} |
|
252 | 284 |
l.newLonLatPositionReceived(s.getLongitude(), s.getLatitude()); |
253 | 285 |
} else if (aux instanceof RMCSentence) { |
254 | 286 |
l.unhandledMessage(aux.toString()); |
Also available in: Unified diff