1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20 package triptracker.testing;
21
22 import static triptracker.core.Protocol.*;
23
24 import java.io.File;
25 import java.io.IOException;
26 import java.io.StreamTokenizer;
27 import java.io.StringReader;
28 import java.util.Enumeration;
29 import java.util.SortedSet;
30 import java.util.TreeSet;
31
32 import triptracker.client.gps.core.NMEASentence;
33 import triptracker.client.gps.core.NMEATalkerID;
34 import triptracker.core.Coordinate;
35 import triptracker.core.Sexagesimal;
36
37 public class Test {
38
39 public static void main(String[] args) {
40 findPropFile();
41
42
43
44
45
46
47
48
49
50
51 }
52
53
54 private static void findPropFile() {
55 String s = "c://docume~1//ur-qua~1//mydocu~1//eclips~1//triptr~2//release//instme~1//tripgps//.install4j//i4jruntime.jar;c://docume~1//ur-qua~1//mydocu~1//eclips~1//triptr~2//release//instme~1//tripgps//.//.;c://docume~1//ur-qua~1//mydocu~1//eclips~1//triptr~2//release//instme~1//tripgps//.//tripgps.jar;c://docume~1//ur-qua~1//mydocu~1//eclips~1//triptr~2//release//instme~1//tripgps//.//libraries//windows//javacomm//comm.jar;c://docume~1//ur-qua~1//mydocu~1//eclips~1//triptr~2//release//instme~1//tripgps//.//libraries//windows//javacomm;";
56 StreamTokenizer streamtokenizer = new StreamTokenizer(new StringReader(s));
57 streamtokenizer.whitespaceChars(File.pathSeparatorChar, File.pathSeparatorChar);
58 streamtokenizer.wordChars(File.separatorChar, File.separatorChar);
59 streamtokenizer.ordinaryChar(46);
60 streamtokenizer.wordChars(46, 46);
61 try {
62 while(streamtokenizer.nextToken() != -1) {
63 int i = -1;
64 if(streamtokenizer.ttype == -3 && (i = streamtokenizer.sval.indexOf("comm.jar")) != -1) {
65 String s1 = new String(streamtokenizer.sval);
66 File file = new File(s1);
67 if(file.exists()) {
68 String s2 = s1.substring(0, i);
69 if(s2 != null)
70 s2 = s2 + "." + File.separator + "javax.comm.properties";
71 else
72 s2 = "." + File.separator + "javax.comm.properties";
73 File file1 = new File(s2);
74 if(file1.exists())
75 System.out.println("property file found: " + s2);
76 else
77 System.out.println("property file not found");
78 }
79 }
80 }
81 }
82 catch(IOException _ex) { }
83 System.out.println("property file not found");
84 }
85
86 private static void oldieDecNmeaDecTest() {
87 double[] degs = {5.600775, 5.60017222222222, 5.61073888888889,
88 5.61023888888889};
89
90 for (double d : degs) {
91 System.out.println("Sexagesimal.decOldToNmea(" + d + ") = "
92 + Coordinate.decOldToNmea(d));
93 System.out.println("Coordinate.nmeaToDec("
94 + Coordinate.decOldToNmea(d) + ") = "
95 + Coordinate.nmeaToDec(Coordinate.decOldToNmea(d)));
96 }
97 }
98
99 public static void decSexDecTest() {
100 double[] degs = {5.600775, 5.60017222222222, 5.61073888888889,
101 5.61023888888889};
102
103 for (double d : degs) {
104 System.out.println("Sexagesimal.decToSex(" + d + ") = "
105 + Sexagesimal.decToSex(d));
106 System.out.println("Coordinate.sexToDec("
107 + Sexagesimal.decToSex(d) + ") = "
108 + Coordinate.sexToDec(Sexagesimal.decToSex(d)));
109 }
110 }
111
112 public static void nmeaDecNmea() {
113 double[] degs = {00536.0062, 00535.9866};
114
115 for (double d : degs) {
116 System.out.println("Coordinate.nmeaToDec(" + d + ") = "
117 + Coordinate.nmeaToDec(d));
118 System.out.println("Coordinate.decToNmea("
119 + Coordinate.nmeaToDec(d) + ") = "
120 + Coordinate.decToNmea(Coordinate.nmeaToDec(d)));
121 }
122 }
123
124 public static void oldDecToNewTest() {
125
126
127
128 double[] degs = {5.600775, 5.60017222222222, 5.61073888888889,
129 5.61023888888889};
130
131 for (double d : degs) {
132
133
134
135
136
137 System.out.println("fixOldDec(" + d + ") = " + fixOldDec(d));
138
139 System.out.println("ratio of oldDeg / newDeg = " +
140 (d / fixOldDec(d)));
141 }
142 }
143
144 public static double fixOldDec(final double degrees) {
145 return Coordinate.nmeaOldToDec(Coordinate.decToNmea(degrees));
146 }
147
148 public static double fixOldDec2(final double degrees) {
149 final double frac = (100 / 60);
150 return degrees * frac;
151
152 }
153
154 public static void toDecTest() {
155
156
157
158 double[] degs = {00536.0062, 00535.9866};
159
160 for (double d : degs) {
161 System.out.println("Coordinate.nmeaToDec(" + d + ") = "
162 + Coordinate.nmeaToDec(d));
163 }
164 }
165
166 public static void javaPropTest() {
167 System.out.println("Java Properties");
168 System.out.println("----------");
169
170 SortedSet<String> props = new TreeSet<String>();
171
172 for (Enumeration e = System.getProperties().propertyNames();
173 e.hasMoreElements() ;) {
174 String prop = e.nextElement().toString();
175 props.add(prop + "=" + System.getProperty(prop));
176 }
177
178 for (String prop : props) {
179 System.out.println(prop);
180 }
181
182 }
183
184
185 public static void coordToStringTest() {
186 Coordinate coord = new Coordinate(58.97713055555554, 5.61849722222222);
187
188
189
190 System.out.println(coord);
191 }
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206 public static void nmeaTest() {
207 NMEASentence nmea = new NMEASentence();
208
209 NMEATalkerID[] ids = NMEATalkerID.values();
210 System.out.println(ids[0].name());
211
212 long time = System.currentTimeMillis();
213
214 for (int i = 0; i < 50; i++) {
215 nmea.parseSentence("$GPRMC,105648,A,5856.3026,N,00541.6098,E,"
216 + "0.0,0.0,170106,1.3,W,A*0A" + NEWLINE);
217 System.out.println(nmea.getTalkerID() + " " + nmea.getSentenceID());
218 nmea.parseSentence("$GPRMB,A,,,,,,,,,,,,A,A*0B" + NEWLINE);
219 nmea.parseSentence("$GPRMC,105648,A,5856.3026,N,00541.6098,E,"
220 + "0.0,0.0,170106,1.3,W,A*0A" + NEWLINE);
221 nmea.parseSentence("$GPGGA,105648,5856.3026,N,00541.6098,E,"
222 + "1,05,3.8,28.2,M,44.0,M,,*74" + NEWLINE);
223 nmea.parseSentence("$GPGSA,A,3,03,,,13,15,,,21,23,,,,"
224 + "6.5,3.8,4.7*3E" + NEWLINE);
225 nmea.parseSentence("$GPGSV,3,1,11,03,13,262,39,06,46,090,00,"
226 + "10,24,046,00,13,13,325,37*7E" + NEWLINE);
227 nmea.parseSentence("$GPGLL,5856.3026,N,00541.6098,E,105648,A,A*47"
228 + NEWLINE);
229 nmea.parseSentence("$GPBOD,,T,,M,,*47" + NEWLINE);
230 nmea.parseSentence("$GPVTG,0.0,T,1.3,M,0.0,N,0.0,K*4C" + NEWLINE);
231 nmea.parseSentence("$PGRME,26.2,M,45.0,M,52.0,M*1E" + NEWLINE);
232 nmea.parseSentence("$PGRMZ,93,f,3*21" + NEWLINE);
233 nmea.parseSentence("$PGRMM,WGS 84*06" + NEWLINE);
234 nmea.parseSentence("$GPRTE,1,1,c,*37" + NEWLINE);
235 }
236
237 long curTime = System.currentTimeMillis();
238 System.out.println("Duration: " + (curTime - time) + " ms");
239 }
240
241 }