/[zanavi_public1]/navit/navit/android/src/com/zoffcc/applications/zanavi/ZANaviDebugReceiver.java
ZANavi

Diff of /navit/navit/android/src/com/zoffcc/applications/zanavi/ZANaviDebugReceiver.java

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

Revision 49 Revision 50
23import java.io.File; 23import java.io.File;
24import java.io.FileOutputStream; 24import java.io.FileOutputStream;
25import java.io.FileReader; 25import java.io.FileReader;
26import java.io.FilenameFilter; 26import java.io.FilenameFilter;
27import java.io.OutputStreamWriter; 27import java.io.OutputStreamWriter;
28import java.net.URLEncoder;
28import java.text.SimpleDateFormat; 29import java.text.SimpleDateFormat;
30import java.util.Arrays;
29import java.util.Date; 31import java.util.Date;
30import java.util.Locale; 32import java.util.Locale;
31 33
32import android.content.BroadcastReceiver; 34import android.content.BroadcastReceiver;
33import android.content.Context; 35import android.content.Context;
34import android.content.Intent; 36import android.content.Intent;
35import android.location.Location; 37import android.location.Location;
36import android.os.Bundle; 38import android.os.Bundle;
37import android.os.Message; 39import android.os.Message;
40import android.view.inputmethod.InputMethodManager;
38 41
39public class ZANaviDebugReceiver extends BroadcastReceiver 42public class ZANaviDebugReceiver extends BroadcastReceiver
40{ 43{
41 44
42 static boolean stop_me = false; 45 static boolean stop_me = false;
53 static String success_item = ""; 56 static String success_item = "";
54 static String success_value = ""; 57 static String success_value = "";
55 static String success_operator = ""; 58 static String success_operator = "";
56 static int result_code = -1; 59 static int result_code = -1;
57 static int local_meters_value = 0; 60 static int local_meters_value = 0;
61
62 static int yaml_sum = 0;
63 static int yaml_err = 0;
58 64
59 /* 65 /*
60 * 66 *
61 * Examples: 67 * Examples:
62 * 68 *
75 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es set_pos_and_dest "Via_Graf 9.1439748 45.5133242 9.1391345 45.5146592" 81 * adb shell am broadcast -a com.zoffcc.applications.zanavi.comm --es set_pos_and_dest "Via_Graf 9.1439748 45.5133242 9.1391345 45.5146592"
76 * 82 *
77 * - 83 * -
78 */ 84 */
79 85
86 static void enable_normal_location()
87 {
88 Navit.runOnUI(new Runnable()
89 {
90 @Override
91 public void run()
92 {
93 System.out.println("ZANaviDebugReceiver:" + "ENABLE normal location");
94
95 if (Navit.p.PREF_use_fast_provider)
96 {
97 NavitVehicle.turn_on_fast_provider();
98 }
99 else
100 {
101 NavitVehicle.turn_off_fast_provider();
102 }
103
104 // activate gps AFTER 3g-location
105 NavitVehicle.turn_on_precise_provider();
106 }
107 });
108 }
109
80 static void disable_normal_location() 110 static void disable_normal_location()
81 { 111 {
112 Navit.runOnUI(new Runnable()
113 {
114 @Override
115 public void run()
116 {
82 NavitVehicle.turn_off_all_providers(); 117 NavitVehicle.turn_off_all_providers();
83 NavitVehicle.turn_off_sat_status(); 118 NavitVehicle.turn_off_sat_status();
84 System.out.println("ZANaviDebugReceiver:" + "disable normal location"); 119 System.out.println("ZANaviDebugReceiver:" + "disable normal location");
120 }
121 });
85 } 122 }
86 123
87 static void DR_add_destination(String key, Bundle extras) 124 static void DR_add_destination(String key, Bundle extras)
88 { 125 {
89 Object value = extras.get(key); 126 Object value = extras.get(key);
182 msg.setData(b); 219 msg.setData(b);
183 NavitGraphics.callback_handler.sendMessage(msg); 220 NavitGraphics.callback_handler.sendMessage(msg);
184 System.out.println("ZANaviDebugReceiver:" + "file=" + filename); 221 System.out.println("ZANaviDebugReceiver:" + "file=" + filename);
185 } 222 }
186 223
224 static void DR_save_route_to_gpx_file_with_name(String name)
225 {
226 Message msg = new Message();
227 Bundle b = new Bundle();
228 b.putInt("Callback", 96);
229 // String date = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
230 String filename = name;
231 b.putString("s", filename);
232 msg.setData(b);
233 NavitGraphics.callback_handler.sendMessage(msg);
234 System.out.println("ZANaviDebugReceiver:" + "file=" + filename);
235 }
236
187 static void DR_clear_route() 237 static void DR_clear_route()
188 { 238 {
189 // clear any previous destinations 239 // clear any previous destinations
190 Message msg2 = new Message(); 240 Message msg2 = new Message();
191 Bundle b2 = new Bundle(); 241 Bundle b2 = new Bundle();
205 { 255 {
206 skip_count = 0; 256 skip_count = 0;
207 System.out.println("ZANaviDebugReceiver:" + "skip"); 257 System.out.println("ZANaviDebugReceiver:" + "skip");
208 } 258 }
209 259
260 static double lat_pos = 0.0;
261 static double lon_pos = 0.0;
262 static double lat_dst = 0.0;
263 static double lon_dst = 0.0;
264 static double heading_pos = 0.0;
265
210 static void DR_replay_yaml_file(String filename, final String date) 266 static void DR_replay_yaml_file(String filename, final String date)
211 { 267 {
212 268
213 file_name_global = filename; 269 file_name_global = filename;
270
271 yaml_err++; // incr. error count (on success later -> decrease it again)
214 272
215 try 273 try
216 { 274 {
217 if ((filename != null) && (!filename.equals(""))) 275 if ((filename != null) && (!filename.equals("")))
218 { 276 {
223 NavitGraphics.NavitAOverlay_s.postInvalidate(); 281 NavitGraphics.NavitAOverlay_s.postInvalidate();
224 282
225 disable_normal_location(); 283 disable_normal_location();
226 284
227 String mode = "-"; 285 String mode = "-";
228 double lat_pos = 0.0; 286 lat_pos = 0.0;
229 double lon_pos = 0.0; 287 lon_pos = 0.0;
230 double lat_dst = 0.0; 288 lat_dst = 0.0;
231 double lon_dst = 0.0; 289 lon_dst = 0.0;
290 heading_pos = 0.0;
232 291
233 String line = ""; 292 String line = "";
234 while ((line = br.readLine()) != null) 293 while ((line = br.readLine()) != null)
235 { 294 {
236 if ((line.length() >= "from:".length()) && (line.equals("from:"))) 295 if ((line.length() >= "from:".length()) && (line.equals("from:")))
289 // read lat,lon 348 // read lat,lon
290 String name_str = line.split(":", 2)[0]; 349 String name_str = line.split(":", 2)[0];
291 String value_str = line.split(":", 2)[1]; 350 String value_str = line.split(":", 2)[1];
292 double lat = 0.0; 351 double lat = 0.0;
293 double lon = 0.0; 352 double lon = 0.0;
353 double heading = 0.0;
294 354
295 if (name_str.contains("lat")) 355 if (name_str.contains("lat"))
296 { 356 {
297 lat = Double.parseDouble(value_str); 357 lat = Double.parseDouble(value_str);
298 if (mode.equals("from")) 358 if (mode.equals("from"))
314 else if (mode.equals("to")) 374 else if (mode.equals("to"))
315 { 375 {
316 lon_dst = lon; 376 lon_dst = lon;
317 } 377 }
318 } 378 }
379 else if (name_str.contains("heading"))
380 {
381 heading = Double.parseDouble(value_str);
382 if (mode.equals("from"))
383 {
384 heading_pos = heading;
385 }
386 }
319 } 387 }
320 } 388 }
321 catch (Exception e2) 389 catch (Exception e2)
322 { 390 {
391 System.out.println("_DREX_:001" + e2.getMessage());
323 } 392 }
324 } 393 }
325 } 394 }
326 395
327 DR_clear_route(); 396 DR_clear_route();
328 Thread.sleep(200); 397 Thread.sleep(1000);
398
399 try
400 {
401 int jj = 0;
402 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
403 {
404 jj++;
405 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
406 // wait for old route to be cleared
407 Thread.sleep(1000);
408 }
409 }
410 catch (Exception e)
411 {
412 e.printStackTrace();
413 }
414
415 // DR_clear_route();
416 // Thread.sleep(3000);
417
329 Bundle extras = new Bundle(); 418 Bundle extras = new Bundle();
330
331 // System.out.println("ZANaviDebugReceiver:" + "set_position" + lat_pos + "," + lon_pos + "," + "0.0" + "," + "0"); 419 System.out.println("ZANaviDebugReceiver:" + "set_position" + lat_pos + "," + lon_pos + "," + "0.0" + "," + heading_pos);
332
333 extras.putString("set_position", "" + lat_pos + "," + lon_pos + "," + "0.0" + "," + "0"); 420 extras.putString("set_position", "" + lat_pos + "," + lon_pos + "," + "0.0" + "," + heading_pos);
334 DR_set_position("set_position", extras, true); 421 DR_set_position("set_position", extras, true);
335 Thread.sleep(1200); 422 Thread.sleep(2500);
423 //xy//DR_set_position("set_position", extras, true);
424 //xy//Thread.sleep(3200);
425
336 extras = new Bundle(); 426 extras = new Bundle();
337
338 // System.out.println("ZANaviDebugReceiver:" + "add_destination" + lat_dst + "," + lon_dst); 427 System.out.println("ZANaviDebugReceiver:" + "add_destination" + lat_dst + "," + lon_dst);
339
340 extras.putString("add_destination", "" + lat_dst + "," + lon_dst); 428 extras.putString("add_destination", "" + lat_dst + "," + lon_dst);
341 DR_add_destination("add_destination", extras); 429 DR_add_destination("add_destination", extras);
430 Thread.sleep(2000);
342 431
343 flag_route_ready = false; 432 flag_route_ready = false;
433
434 // Thread.sleep(1200);
435 // Navit.draw_map();
436
437 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
344 438
345 final Thread debug_zoom_to_route_001 = new Thread() 439 final Thread debug_zoom_to_route_001 = new Thread()
346 { 440 {
347 int wait = 1; 441 int wait = 1;
348 int count = 0; 442 int count = 0;
349 int max_count = 45; 443 int max_count = 380; // seconds
444 int first_status = -999;
445 int status_wrong = 0;
350 446
351 @Override 447 @Override
352 public void run() 448 public void run()
353 { 449 {
354 while (wait == 1) 450 while (wait == 1)
355 { 451 {
356 try 452 try
357 { 453 {
358 // System.out.println("XXXX:#" + count + ":rstatus=" + NavitGraphics.navit_route_status); 454 System.out.println("XXXX:#" + count + ":rstatus=" + NavitGraphics.navit_route_status);
359 455
360 if ((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) 456 if (first_status == -999)
457 {
458 first_status = NavitGraphics.navit_route_status;
459 }
460
461 if ((first_status == -999) || (first_status == 17) || (first_status == 33))
462 {
463 if (count < 30)
361 { 464 {
362 // zoom to route 465 // wait some more! status is wrong it seems!
363 Message msg = new Message(); 466 status_wrong = 1;
364 Bundle b = new Bundle(); 467 }
365 b.putInt("Callback", 17); 468 else
366 msg.setData(b); 469 {
367 NavitGraphics.callback_handler.sendMessage(msg); 470 status_wrong = 0;
471 }
472 }
368 473
369 Navit.set_map_position_to_screen_center(); 474 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
475
476 if (((NavitGraphics.navit_route_status == 17) || (NavitGraphics.navit_route_status == 33)) && (status_wrong == 0))
477 {
478 System.out.println("XXXX:--:001");
479
480 // Navit.static_show_route_graph(4);
481
482 Navit.zoom_to_route();
483 Thread.sleep(2000);
484 Navit.zoom_to_route();
485 Thread.sleep(15000);
486 //xy//Navit.draw_map();
487 //xy//Thread.sleep(15000);
488
489 System.out.println("XXXX:--:002");
490
491 File f = new File(file_name_global);
492 File d2 = new File(f.getParent() + "/" + date + "/");
493 d2.mkdirs();
494
495 System.out.println("XXXX:--:003");
370 496
371 // save route to gpx file 497 // save route to gpx file
372 DR_save_route_to_gpx_file(); 498 DR_save_route_to_gpx_file_with_name(f.getParent() + "/" + date + "/" + f.getName() + ".gpx");
499
500 System.out.println("XXXX:--:004");
373 501
374 wait = 0; 502 wait = 0;
375 } 503 }
376 else 504 else
377 { 505 {
506 System.out.println("XXXX:--:005");
507
378 wait = 1; 508 wait = 1;
379 } 509 }
380 510
381 if (count > 0) 511 if (count > 0)
382 { 512 {
513 System.out.println("XXXX:--:006");
514
383 if (NavitGraphics.navit_route_status == 1) 515 //if (NavitGraphics.navit_route_status == 1)
516 if (NavitGraphics.navit_route_status == 999199) // disable !!
384 { 517 {
518 System.out.println("XXXX:--:007");
385 wait = 0; 519 wait = 0;
386 count = max_count; 520 count = max_count;
387 } 521 }
388 else if (NavitGraphics.navit_route_status == 3) 522 else if (NavitGraphics.navit_route_status == 3)
389 { 523 {
524 System.out.println("XXXX:--:008");
390 wait = 0; 525 wait = 0;
391 count = max_count; 526 count = max_count;
392 } 527 }
393 } 528 }
394 529
530 System.out.println("XXXX:--:009");
531
395 count++; 532 count++;
396 if (count > max_count) 533 if (count > max_count)
397 { 534 {
535 System.out.println("XXXX:--:010");
536
398 wait = 0; 537 wait = 0;
399 538
400 Message msg7 = Navit.Navit_progress_h.obtainMessage(); 539 Message msg7 = Navit.Navit_progress_h.obtainMessage();
401 Bundle b7 = new Bundle(); 540 Bundle b7 = new Bundle();
402 msg7.what = 2; // long Toast message 541 msg7.what = 2; // long Toast message
404 msg7.setData(b7); 543 msg7.setData(b7);
405 Navit.Navit_progress_h.sendMessage(msg7); 544 Navit.Navit_progress_h.sendMessage(msg7);
406 } 545 }
407 else 546 else
408 { 547 {
548 System.out.println("XXXX:--:011");
549
409 Thread.sleep(1000); 550 Thread.sleep(1000);
410 } 551 }
411 } 552 }
412 catch (Exception e) 553 catch (Exception e)
413 { 554 {
414 } 555 System.out.println("XXXX:--:012");
556
557 System.out.println("_DREX_:002" + Navit.stacktrace_to_string(e));
415 } 558 }
559 }
416 560
561 System.out.println("XXXX:--:013");
562
417 System.out.println("XXXX:rstatus=" + NavitGraphics.navit_route_status); 563 System.out.println("XXXX:rstatus[FIN]=" + NavitGraphics.navit_route_status);
418 564
565 try
566 {
567
419 if (NavitGraphics.navit_route_status == 3) 568 if (NavitGraphics.navit_route_status == 3)
420 { 569 {
421 // route blocked / no route found 570 // route blocked / no route found
422 DR_clear_route(); 571 DR_clear_route();
572 Thread.sleep(1000);
423 System.out.println("XXXX:route blocked"); 573 System.out.println("XXXX:route blocked");
424 } 574 }
425 else if (NavitGraphics.navit_route_status == 1) 575 else if (NavitGraphics.navit_route_status == 1)
426 { 576 {
427 // still calculating route 577 // still calculating route
428 DR_clear_route(); 578 DR_clear_route();
579 Thread.sleep(1000);
429 System.out.println("XXXX:still calculating route"); 580 System.out.println("XXXX:still calculating route");
430 } 581 }
431 else 582 else
432 { 583 {
433 // save map screenshot 584 // save map screenshot
434 File f = new File(file_name_global); 585 File f = new File(file_name_global);
435 // System.out.println("NNNNN=" + f.getParent() + "/" + date + "/" + f.getName()); 586 // System.out.println("NNNNN=" + f.getParent() + "/" + date + "/" + f.getName());
436 File d2 = new File(f.getParent() + "/" + date + "/"); 587 File d2 = new File(f.getParent() + "/" + date + "/");
437 d2.mkdirs(); 588 d2.mkdirs();
438 Navit.take_map_screenshot(f.getParent() + "/" + date + "/", f.getName()); 589 Navit.take_map_screenshot(f.getParent() + "/" + date + "/", f.getName());
590 // Navit.take_phone_screenshot(Navit.Global_Navit_Object, f.getParent() + "/" + date + "/", f.getName() + "_full");
439 591
440 // save roadbook 592 // save roadbook
441 String[] separated = NavitGraphics.GetRoadBookItems(9990001); 593 String[] separated = NavitGraphics.GetRoadBookItems(9990001);
442 594
595 if (separated == null)
596 {
597 System.out.println("XXXX:Roadbook try #2");
598
599 try
600 {
601 Thread.sleep(3000);
602 }
603 catch (InterruptedException e)
604 {
605 }
606 separated = NavitGraphics.GetRoadBookItems(9990001);
607
608 if (separated == null)
609 {
610 System.out.println("XXXX:Roadbook try #3");
611
612 try
613 {
614 Bundle extras77 = new Bundle();
615 System.out.println("ZANaviDebugReceiver:77:" + "set_position" + lat_pos + "," + lon_pos + "," + "0.0" + "," + "0");
616 extras77.putString("set_position", "" + lat_pos + "," + lon_pos + "," + "0.0" + "," + "0");
617 DR_set_position("set_position", extras77, true);
618 Thread.sleep(1000);
619 }
620 catch (InterruptedException e)
621 {
622 }
623
624 try
625 {
626 Thread.sleep(6000);
627 }
628 catch (InterruptedException e)
629 {
630 }
631 separated = NavitGraphics.GetRoadBookItems(9990001);
632
633 if (separated == null)
634 {
635 separated = new String[4];
636 separated[0] = "broken";
637 separated[1] = "broken";
638 separated[2] = "broken";
639 separated[3] = "broken";
640 }
641 }
642 }
643
644 System.out.println("XXXX:Roadbook(1)=" + separated);
645 if (separated != null)
646 {
647 try
648 {
649 System.out.println("XXXX:Roadbook(2)=" + Arrays.toString(separated));
650 }
651 catch (Exception e)
652 {
653 }
654 }
655
656 if ((separated != null) && (separated.length < 3))
657 {
658 System.out.println("_DRxx_:018" + "Roadbook items < 3 !!");
659 }
660
443 int jk = 0; 661 int jk = 0;
662 if (separated != null)
663 {
444 if (separated.length > 2) 664 if (separated.length > 2)
665 {
666 FileOutputStream outf = null;
667 try
668 {
669 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
670 }
671 catch (Exception ef)
672 {
673 //System.out.println("EE002:" + ef.getMessage());
674 System.out.println("_DREX_:003" + ef.getMessage());
675 }
676
677 OutputStreamWriter out = null;
678 try
679 {
680 out = new OutputStreamWriter(outf);
681 }
682 catch (Exception e)
683 {
684 // System.out.println("EE003:" + e.getMessage());
685 System.out.println("_DREX_:004" + e.getMessage());
686 }
687
688 //System.out.println("Roadbook:length=" + (separated.length - 2));
689 try
690 {
691 out.write("Roadbook:length=" + (separated.length - 2) + "\n");
692 }
693 catch (Exception e)
694 {
695 //System.out.println("EE004:" + e.getMessage());
696 System.out.println("_DREX_:005" + e.getMessage());
697 }
698
699 for (jk = 0; jk < separated.length; jk++)
700 {
701 System.out.println("ROADBOOK_RES=" + jk + ":" + separated[jk]);
702 if (jk > 2)
703 {
704 String[] values = new String[5];
705 String[] values2 = separated[jk].split(":");
706 values[0] = values2[0];
707 values[1] = values2[1];
708 values[2] = values2[2];
709 values[3] = values2[3];
710 try
711 {
712 values[4] = values2[4];
713 }
714 catch (Exception ee)
715 {
716 values[4] = "";
717 System.out.println("_DREX_:006" + ee.getMessage());
718 }
719 // 0 string:distance short form
720 // 1 lat
721 // 2 lon
722 // 3 icon name
723 // 4 text
724
725 // if (values[3].compareTo("nav_waypoint") == 0)
726 // {
727 // }
728 // else if (values[3].compareTo("nav_destination") == 0)
729 // {
730 // }
731 // else
732 // {
733 // }
734
735 try
736 {
737 System.out.println("Roadbook:" + jk + ":" + values[0] + ":" + values[1] + ":" + values[2] + ":" + values[3] + ":" + values[4]);
738 out.write("Roadbook:" + jk + ":" + values[0] + ":" + values[1] + ":" + values[2] + ":" + values[3] + ":" + values[4] + "\n");
739 }
740 catch (Exception ee)
741 {
742 System.out.println("_DREX_:007" + ee.getMessage());
743 }
744 }
745 else if (jk == 1)
746 {
747 String[] values_local = separated[jk].split(":");
748 try
749 {
750 local_meters_value = Integer.parseInt(values_local[1]);
751 }
752 catch (Exception e)
753 {
754 local_meters_value = 0;
755 System.out.println("_DREX_:008" + Navit.stacktrace_to_string(e));
756 }
757
758 System.out.println("Roadbook:distance=" + local_meters_value);
759 try
760 {
761 out.write("Roadbook:distance [m]=" + local_meters_value + "\n");
762 }
763 catch (Exception e)
764 {
765 System.out.println("_DREX_:009" + e.getMessage());
766 }
767 }
768 else if (jk == 2)
769 {
770 System.out.println("Roadbook:" + jk + ":" + "0" + ":" + "0" + ":" + "0" + ":" + "start" + ":" + "");
771 try
772 {
773 out.write("Roadbook:" + jk + ":" + "0" + ":" + "0" + ":" + "0" + ":" + "start" + ":" + "" + "\n");
774 }
775 catch (Exception e)
776 {
777 System.out.println("_DREX_:010" + e.getMessage());
778 }
779 }
780 }
781
782 try
783 {
784 out.write("URL1:" + "http://map.project-osrm.org/?z=10&loc=" + lat_pos + "%2C" + lon_pos + "&loc=" + lat_dst + "%2C" + lon_dst + "&hl=en&alt=0\n");
785 out.write("URL2:" + "https://graphhopper.com/maps/?point=" + lat_pos + "%2C" + lon_pos + "&point=" + lat_dst + "%2C" + lon_dst + "\n");
786 out.write("URL3:" + "http://www.google.com/maps/dir/" + lat_pos + "," + lon_pos + "/" + lat_dst + "," + lon_dst + "\n");
787 out.write("URL4:" + "http://www.openstreetmap.org/directions?engine=osrm_car&route=" + lat_pos + "%2C" + lon_pos + "%3B" + lat_dst + "%2C" + lon_dst + "\n");
788 }
789 catch (Exception e)
790 {
791 System.out.println("_DREX_:046" + e.getMessage());
792 }
793
794 try
795 {
796 out.flush();
797 out.close();
798 outf.flush();
799 outf.close();
800 }
801 catch (Exception e)
802 {
803 System.out.println("_DREX_:016" + e.getMessage());
804 }
805 }
806 }
807 // else
808 // {
809 // System.out.println("_DRxx_:017" + "Roadbook items = NULL !!");
810 // }
811
812 // calculate success criterion ----------------------
813 // calculate success criterion ----------------------
814
815 result_code = -1;
816
817 if ((!success_operator.equals("")) && (!success_value.equals("")))
445 { 818 {
819 System.out.println("roadbook:so=" + success_source);
820 System.out.println("roadbook:it=" + success_item);
821 System.out.println("roadbook:sv=" + success_value);
822
823 if (success_source.equalsIgnoreCase("'dbus'"))
824 {
825 if (success_item.equalsIgnoreCase("'status'"))
826 {
827 int s = NavitGraphics.navit_route_status;
828 int v = Integer.parseInt(success_value);
829
830 if ((success_operator.contains(">")) || ((success_operator.contains("<"))))
831 {
832 if (s == 17)
833 {
834 s = 33;
835 }
836 }
837 else
838 {
839 if (v == 33)
840 {
841 v = 17;
842 if (s == 33)
843 {
844 s = 17;
845 }
846 }
847 else if (v == 17)
848 {
849 if (s == 33)
850 {
851 s = 17;
852 }
853 }
854 }
855 result_code = success_value_compare(s, v);
856
857 System.out.println("roadbook:003:" + s + " " + v);
858 }
859 else if (success_item.equalsIgnoreCase("'distance'"))
860 {
861 int s = local_meters_value;
862 int v = Integer.parseInt(success_value);
863 result_code = success_value_compare(s, v);
864
865 System.out.println("roadbook:001:" + s + " " + v);
866 }
867 }
868 else if (success_source.equalsIgnoreCase("'gpx'"))
869 {
870 if (success_item.equalsIgnoreCase("'nodes'"))
871 {
872 int s = -99;
873 s = (separated.length - 2);
874 int v = Integer.parseInt(success_value);
875 result_code = success_value_compare(s, v);
876
877 System.out.println("roadbook:002:" + s + " " + v);
878 }
879 else if (success_item.startsWith("'nav"))
880 {
881 String nav_num_str = success_item.replace("'nav", "").replace("'", "");
882 int nav_num = Integer.parseInt(nav_num_str);
883
884 if (separated.length > (nav_num + 2))
885 {
886 // ok we have enough entries in roadbook
887
888 String[] values = new String[5];
889 String[] values2 = separated[nav_num + 2].split(":");
890 values[0] = values2[0];
891 values[1] = values2[1];
892 values[2] = values2[2];
893 values[3] = values2[3];
894 try
895 {
896 values[4] = values2[4];
897 }
898 catch (Exception ee)
899 {
900 values[4] = "";
901 System.out.println("_DREX_:006entries" + ee.getMessage());
902 }
903 // 0 string:distance short form
904 // 1 lat
905 // 2 lon
906 // 3 icon name
907 // 4 text
908
909 if (values[3].equalsIgnoreCase(success_value))
910 {
911 result_code = 0;
912 }
913 else
914 {
915 result_code = -1;
916 }
917 }
918 else
919 {
920 // not enough entries in roadbook --> fail
921 result_code = -1;
922 }
923
924 System.out.println("roadbook:002:" + success_item + " " + success_value);
925 }
926
927 }
928 }
929
930 System.out.println("++--------++ roadbook:RES=" + result_code);
931
932 if (result_code == 0)
933 {
934 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
935 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
936 File f2 = new File(orig);
937 File f2_to = new File(rename_to);
938 f2.renameTo(f2_to);
939
940 yaml_err--;
941 }
942 else
943 {
944 }
945
946 // calculate success criterion ----------------------
947 // calculate success criterion ----------------------
948
949 }
950
951 }
952 catch (Exception ebig)
953 {
954 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
955 }
956
957 flag_route_ready = true;
958 }
959 };
960 debug_zoom_to_route_001.start();
961 debug_zoom_to_route_001.join();
962 Thread.sleep(500);
963
964 is_replaying = false;
965 NavitGraphics.NavitAOverlay_s.postInvalidate();
966 br.close();
967 }
968 }
969 catch (Exception e)
970 {
971 System.out.println("_DREX_:011" + e.getMessage());
972 is_replaying = false;
973 NavitGraphics.NavitAOverlay_s.postInvalidate();
974 }
975 }
976
977 static void DR_replay_yaml_file_search_n(String filename, final String date)
978 {
979
980 file_name_global = filename;
981
982 yaml_err++; // incr. error count (on success later -> decrease it again)
983
984 try
985 {
986 if ((filename != null) && (!filename.equals("")))
987 {
988 BufferedReader br = null;
989 br = new BufferedReader(new FileReader(filename));
990
991 is_replaying = true;
992 NavitGraphics.NavitAOverlay_s.postInvalidate();
993
994 disable_normal_location();
995
996 DR_clear_route();
997 Thread.sleep(1000);
998
999 String str_str = "";
1000 String city_str = "";
1001 String hn_str = "";
1002
1003 String mode = "-";
1004 String line = "";
1005 while ((line = br.readLine()) != null)
1006 {
1007 if ((line.length() >= "type:".length()) && (line.equals("type:")))
1008 {
1009 mode = "type";
1010 }
1011 else if ((line.length() >= "input:".length()) && (line.equals("input:")))
1012 {
1013 mode = "input";
1014 }
1015 else if ((line.length() >= "success:".length()) && (line.equals("success:")))
1016 {
1017 mode = "success";
1018 }
1019 else if ((line.length() > 2) && (!line.startsWith("#")))
1020 {
1021 try
1022 {
1023 if (mode == "success")
1024 {
1025 String name_str = line.split(":", 2)[0].replace(" ", "");
1026 String value_str = line.split(":", 2)[1].replace(" ", "");
1027
1028 if (name_str.equalsIgnoreCase("item"))
1029 {
1030 success_item = value_str;
1031 }
1032 else if (name_str.equalsIgnoreCase("value"))
1033 {
1034 success_value = value_str;
1035 }
1036 else if (name_str.equalsIgnoreCase("operator"))
1037 {
1038 success_operator = value_str;
1039 }
1040 }
1041 else if (mode == "type")
1042 {
1043 // do nothing
1044 }
1045 else
1046 {
1047 String name_str = line.split(":", 2)[0];
1048 String value_str = line.split(":", 2)[1];
1049
1050 if (name_str.contains("street"))
1051 {
1052 str_str = value_str;
1053 }
1054 else if (name_str.contains("city"))
1055 {
1056 city_str = value_str;
1057 }
1058 else if (name_str.contains("housenumber"))
1059 {
1060 hn_str = value_str;
1061 }
1062 }
1063 }
1064 catch (Exception e2)
1065 {
1066 System.out.println("_DREX_:001" + e2.getMessage());
1067 }
1068 }
1069 }
1070
1071 try
1072 {
1073 int jj = 0;
1074 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
1075 {
1076 jj++;
1077 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
1078 // wait for old route to be cleared
1079 Thread.sleep(1000);
1080 }
1081 }
1082 catch (Exception e)
1083 {
1084 e.printStackTrace();
1085 }
1086
1087 final String str_str_f = str_str;
1088 final String city_str_f = city_str;
1089 final String hn_str_f = hn_str;
1090
1091 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1092
1093 final Thread search_n_002 = new Thread()
1094 {
1095 int wait = 1;
1096
1097 @Override
1098 public void run()
1099 {
1100 while (wait == 1)
1101 {
1102 try
1103 {
1104 // -------- ST N --------
1105 // -------- ST N --------
1106 // -------- ST N --------
1107
1108 // clear results
1109 Navit.NavitAddressResultList_foundItems.clear();
1110 Navit.Navit_Address_Result_double_index.clear();
1111 Navit.NavitSearchresultBarIndex = -1;
1112 Navit.NavitSearchresultBar_title = "";
1113 Navit.NavitSearchresultBar_text = "";
1114 Navit.search_results_towns = 0;
1115 Navit.search_results_streets = 0;
1116 Navit.search_results_streets_hn = 0;
1117 Navit.search_results_poi = 0;
1118
1119 Navit.search_list_ready = false;
1120
1121 final Thread tttt2 = new Thread()
1122 {
1123 @Override
1124 public void run()
1125 {
1126 System.out.println("search test 001");
1127 Navit.use_index_search = false;
1128 Navit.executeSearch_with_values(str_str_f, city_str_f, hn_str_f, true, false, true, true);
1129 }
1130 };
1131 tttt2.start();
1132 System.out.println("search test 002");
1133 Thread.sleep(2000);
1134 System.out.println("search test 003");
1135
1136 // -- wait for search result --
1137 int c4 = 0;
1138 boolean no_result = false;
1139 while (Navit.search_ready == false)
1140 {
1141 System.out.println("search test 004:" + c4);
1142 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1143
1144 Thread.sleep(500);
1145 c4++;
1146
1147 if (c4 > (2 * 60) * 40)
1148 {
1149 System.out.println("search test 004a");
1150 Navit.search_ready = true;
1151 no_result = true;
1152 }
1153 }
1154 // -- wait for search result --
1155
1156 Thread.sleep(1500);
1157
1158 System.out.println("search test 005");
1159 c4 = 0;
1160 if (no_result == false)
1161 {
1162 while (Navit.search_list_ready == false)
1163 {
1164 System.out.println("search test 004b:" + c4);
1165 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1166
1167 Thread.sleep(500);
1168 c4++;
1169
1170 if (c4 > (2 * 60) * 2)
1171 {
1172 System.out.println("search test 004ab");
1173 break;
1174 }
1175 }
1176 }
1177 System.out.println("search test 006");
1178
1179 Thread.sleep(5000);
1180
1181 // save screenshot
1182 System.out.println("SCREENSHOT 001");
1183 try
1184 {
1185 File f = new File(file_name_global);
1186 File d2 = new File(f.getParent() + "/" + date + "/");
1187 d2.mkdirs();
1188 Navit.take_phone_screenshot(NavitAddressResultListActivity.NavitAddressResultListActivity_s, f.getParent() + "/" + date + "/", f.getName());
1189 }
1190 catch (Exception ee4)
1191 {
1192 System.out.println("SCREENSHOT:error1:" + Navit.stacktrace_to_string(ee4));
1193 ee4.printStackTrace();
1194 }
1195 System.out.println("SCREENSHOT 002");
1196
1197 try
1198 {
1199 NavitAddressResultListActivity.force_done();
1200 }
1201 catch (Exception ee4)
1202 {
1203 System.out.println("SCREENSHOT:error2:" + Navit.stacktrace_to_string(ee4));
1204 ee4.printStackTrace();
1205 }
1206
1207 System.out.println("SCREENSHOT 003");
1208
1209 wait = 0;
1210 // -------- ST N --------
1211 // -------- ST N --------
1212 // -------- ST N --------
1213
446 FileOutputStream outf = null; 1214 FileOutputStream outf = null;
447 try 1215 try
448 { 1216 {
1217 File f = new File(file_name_global);
449 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt"); 1218 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
450 } 1219 }
451 catch (Exception ef) 1220 catch (Exception ef)
452 { 1221 {
453 System.out.println("EE002:" + ef.getMessage()); 1222 //System.out.println("EE002:" + ef.getMessage());
1223 System.out.println("_DREX_:003" + ef.getMessage());
454 } 1224 }
455 1225
456 OutputStreamWriter out = null; 1226 OutputStreamWriter out = null;
457 try 1227 try
458 { 1228 {
459 out = new OutputStreamWriter(outf); 1229 out = new OutputStreamWriter(outf);
460 } 1230 }
461 catch (Exception e) 1231 catch (Exception e)
462 { 1232 {
463 System.out.println("EE003:" + e.getMessage()); 1233 // System.out.println("EE003:" + e.getMessage());
1234 System.out.println("_DREX_:004" + e.getMessage());
464 } 1235 }
465 1236
466 //System.out.println("Roadbook:length=" + (separated.length - 2)); 1237 //System.out.println("Roadbook:length=" + (separated.length - 2));
467 try 1238 try
468 { 1239 {
469 out.write("Roadbook:length=" + (separated.length - 2) + "\n"); 1240 out.write("Search:length=" + Navit.NavitAddressResultList_foundItems.size() + "\n");
470 } 1241 }
471 catch (Exception e) 1242 catch (Exception e)
472 { 1243 {
473 System.out.println("EE004:" + e.getMessage()); 1244 //System.out.println("EE004:" + e.getMessage());
474 } 1245 System.out.println("_DREX_:005" + e.getMessage());
475
476 for (jk = 0; jk < separated.length; jk++)
477 { 1246 }
478 // System.out.println("ROADBOOK_RES=" + jk + ":" + separated[jk]); 1247
479 if (jk > 2) 1248 try
480 { 1249 {
481 String[] values = new String[5]; 1250 int i = 0;
482 String[] values2 = separated[jk].split(":"); 1251 for (i = 0; i < Navit.NavitAddressResultList_foundItems.size(); i++)
483 values[0] = values2[0];
484 values[1] = values2[1];
485 values[2] = values2[2];
486 values[3] = values2[3];
487 try
488 { 1252 {
489 values[4] = values2[4]; 1253 out.write("result:" + i + ":" + Navit.NavitAddressResultList_foundItems.get(i).result_type + ":" + Navit.NavitAddressResultList_foundItems.get(i).lat + ":" + Navit.NavitAddressResultList_foundItems.get(i).lon + ":" + Navit.NavitAddressResultList_foundItems.get(i).addr + "\n");
490 } 1254 }
491 catch (Exception ee)
492 {
493 values[4] = "";
494 }
495 // 0 string:distance short form
496 // 1 lat
497 // 2 lon
498 // 3 icon name
499 // 4 text
500
501 // if (values[3].compareTo("nav_waypoint") == 0)
502 // {
503 // }
504 // else if (values[3].compareTo("nav_destination") == 0)
505 // {
506 // }
507 // else
508 // {
509 // }
510
511 try
512 {
513 //System.out.println("Roadbook:" + jk + ":" + values[0] + ":" + values[1] + ":" + values[2] + ":" + values[3] + ":" + values[4]);
514 out.write("Roadbook:" + jk + ":" + values[0] + ":" + values[1] + ":" + values[2] + ":" + values[3] + ":" + values[4] + "\n");
515 }
516 catch (Exception ee)
517 {
518 }
519 } 1255 }
520 else if (jk == 1)
521 {
522 String[] values_local = separated[jk].split(":");
523 try
524 {
525 local_meters_value = Integer.parseInt(values_local[1]);
526 }
527 catch (Exception e) 1256 catch (Exception e)
528 { 1257 {
529 local_meters_value = 0; 1258 //System.out.println("EE004:" + e.getMessage());
1259 System.out.println("_DREX_:005a" + e.getMessage());
530 } 1260 }
531 1261
532 System.out.println("Roadbook:distance=" + local_meters_value);
533 try 1262 try
534 { 1263 {
535 out.write("Roadbook:distance [m]=" + local_meters_value + "\n"); 1264 out.write("URL1:" + "http://nominatim.openstreetmap.org/search.php?q=" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1265 out.write("URL2:" + "https://www.google.at/maps/place/" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1266 // out.write("URL3:" + "about:\n");
536 } 1267 }
537 catch (Exception e) 1268 catch (Exception e)
538 {
539 }
540 }
541 else if (jk == 2)
542 { 1269 {
543 //System.out.println("Roadbook:" + jk + ":" + "0" + ":" + "0" + ":" + "0" + ":" + "start" + ":" + ""); 1270 System.out.println("_DREX_:046" + e.getMessage());
544 try
545 {
546 out.write("Roadbook:" + jk + ":" + "0" + ":" + "0" + ":" + "0" + ":" + "start" + ":" + "" + "\n");
547 }
548 catch (Exception e)
549 {
550 }
551 }
552 } 1271 }
553 1272
554 try 1273 try
555 { 1274 {
556 out.flush(); 1275 out.flush();
558 outf.flush(); 1277 outf.flush();
559 outf.close(); 1278 outf.close();
560 } 1279 }
561 catch (Exception e) 1280 catch (Exception e)
562 { 1281 {
563 } 1282 System.out.println("_DREX_:016" + e.getMessage());
564 } 1283 }
565 1284
566 // calculate success criterion ---------------------- 1285 // calculate success criterion ----------------------
567 // calculate success criterion ---------------------- 1286 // calculate success criterion ----------------------
568 1287
569 result_code = -1; 1288 result_code = -1;
570 1289
571 if ((!success_operator.equals("")) && (!success_value.equals(""))) 1290 if ((!success_operator.equals("")) && (!success_value.equals("")))
572 { 1291 {
573 System.out.println("roadbook:so=" + success_source); 1292 // System.out.println("search:so=" + success_source);
574 System.out.println("roadbook:it=" + success_item); 1293 System.out.println("search:it=" + success_item);
575 System.out.println("roadbook:sv=" + success_value); 1294 System.out.println("search:sv=" + success_value);
576 1295
577 if (success_source.equalsIgnoreCase("'dbus'")) 1296 if (success_item.equalsIgnoreCase("'resultcount'"))
578 { 1297 {
579 if (success_item.equalsIgnoreCase("'status'")) 1298 try
580 { 1299 {
581 int s = NavitGraphics.navit_route_status; 1300 int s = Navit.NavitAddressResultList_foundItems.size();
582 int v = Integer.parseInt(success_value); 1301 int v = Integer.parseInt(success_value);
583 if (v == 33)
584 {
585 v = 17;
586 if (s == 33)
587 {
588 s = 17;
589 }
590 }
591 else if (v == 17)
592 {
593 if (s == 33)
594 {
595 s = 17;
596 }
597 }
598 result_code = success_value_compare(s, v); 1302 result_code = success_value_compare(s, v);
599
600 System.out.println("roadbook:003:" + s + " " + v);
601 } 1303 }
602 else if (success_item.equalsIgnoreCase("'distance'")) 1304 catch (Exception e)
603 { 1305 {
604 int s = local_meters_value; 1306 result_code = -1;
605 int v = Integer.parseInt(success_value);
606 result_code = success_value_compare(s, v);
607
608 System.out.println("roadbook:001:" + s + " " + v);
609 } 1307 }
610 } 1308 }
611 else if (success_source.equalsIgnoreCase("'gpx'"))
612 {
613 if (success_item.equalsIgnoreCase("'nodes'"))
614 {
615 int s = (separated.length - 2);
616 int v = Integer.parseInt(success_value);
617 result_code = success_value_compare(s, v);
618
619 System.out.println("roadbook:002:" + s + " " + v);
620 } 1309 }
621 }
622 }
623 1310
624 System.out.println("roadbook:RES=" + result_code); 1311 // dummy for circleCI
1312 File f3 = new File(file_name_global);
1313 System.out.println("ZANaviDebugReceiver:" + "file=" + (f3.getParent() + "/" + date + "/" + f3.getName()));
1314 // dummy for circleCI
625 1315
626 if (result_code == 0) 1316 if (result_code == 0)
627 { 1317 {
1318 File f = new File(file_name_global);
628 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt"; 1319 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
629 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt"; 1320 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
630 File f2 = new File(orig); 1321 File f2 = new File(orig);
631 File f2_to = new File(rename_to); 1322 File f2_to = new File(rename_to);
632 f2.renameTo(f2_to); 1323 f2.renameTo(f2_to);
1324
1325 yaml_err--;
633 } 1326 }
1327 else
1328 {
1329 }
634 1330
635 // calculate success criterion ---------------------- 1331 // calculate success criterion ----------------------
636 // calculate success criterion ---------------------- 1332 // calculate success criterion ----------------------
637 1333
638 } 1334 }
639 1335 catch (Exception ebig)
640 flag_route_ready = true; 1336 {
1337 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
1338 }
1339 }
641 } 1340 }
642 }; 1341 };
643 debug_zoom_to_route_001.start(); 1342 search_n_002.start();
644 debug_zoom_to_route_001.join(); 1343 search_n_002.join();
1344 Thread.sleep(500);
645 1345
646 is_replaying = false; 1346 is_replaying = false;
647 NavitGraphics.NavitAOverlay_s.postInvalidate(); 1347 NavitGraphics.NavitAOverlay_s.postInvalidate();
648 br.close(); 1348 br.close();
649 } 1349 }
650 } 1350 }
651 catch (Exception e) 1351 catch (Exception e)
652 { 1352 {
1353 System.out.println("_DREX_:011" + e.getMessage());
1354 is_replaying = false;
1355 NavitGraphics.NavitAOverlay_s.postInvalidate();
1356 }
1357 }
1358
1359 static void DR_replay_yaml_file_search_i(String filename, final String date)
1360 {
1361
1362 file_name_global = filename;
1363
1364 yaml_err++; // incr. error count (on success later -> decrease it again)
1365
1366 try
1367 {
1368 if ((filename != null) && (!filename.equals("")))
1369 {
1370 BufferedReader br = null;
1371 br = new BufferedReader(new FileReader(filename));
1372
1373 is_replaying = true;
1374 NavitGraphics.NavitAOverlay_s.postInvalidate();
1375
1376 disable_normal_location();
1377
1378 DR_clear_route();
1379 Thread.sleep(1000);
1380
1381 String str_str = "";
1382 String city_str = "";
1383 String hn_str = "";
1384
1385 String mode = "-";
1386 String line = "";
1387 while ((line = br.readLine()) != null)
1388 {
1389 if ((line.length() >= "type:".length()) && (line.equals("type:")))
1390 {
1391 mode = "type";
1392 }
1393 else if ((line.length() >= "input:".length()) && (line.equals("input:")))
1394 {
1395 mode = "input";
1396 }
1397 else if ((line.length() >= "success:".length()) && (line.equals("success:")))
1398 {
1399 mode = "success";
1400 }
1401 else if ((line.length() > 2) && (!line.startsWith("#")))
1402 {
1403 try
1404 {
1405 if (mode == "success")
1406 {
1407 String name_str = line.split(":", 2)[0].replace(" ", "");
1408 String value_str = line.split(":", 2)[1].replace(" ", "");
1409
1410 if (name_str.equalsIgnoreCase("item"))
1411 {
1412 success_item = value_str;
1413 }
1414 else if (name_str.equalsIgnoreCase("value"))
1415 {
1416 success_value = value_str;
1417 }
1418 else if (name_str.equalsIgnoreCase("operator"))
1419 {
1420 success_operator = value_str;
1421 }
1422 }
1423 else if (mode == "type")
1424 {
1425 // do nothing
1426 }
1427 else
1428 {
1429 String name_str = line.split(":", 2)[0];
1430 String value_str = line.split(":", 2)[1];
1431
1432 if (name_str.contains("street"))
1433 {
1434 str_str = value_str;
1435 }
1436 else if (name_str.contains("city"))
1437 {
1438 city_str = value_str;
1439 }
1440 else if (name_str.contains("housenumber"))
1441 {
1442 hn_str = value_str;
1443 }
1444 }
1445 }
1446 catch (Exception e2)
1447 {
1448 System.out.println("_DREX_:001" + e2.getMessage());
1449 }
1450 }
1451 }
1452
1453 try
1454 {
1455 int jj = 0;
1456 while ((NavitGraphics.navit_route_status != 0) && (jj < 120))
1457 {
1458 jj++;
1459 System.out.println("ZANaviDebugReceiver:" + "waiting for route to clear (status=" + NavitGraphics.navit_route_status + "):" + jj);
1460 // wait for old route to be cleared
1461 Thread.sleep(1000);
1462 }
1463 }
1464 catch (Exception e)
1465 {
1466 e.printStackTrace();
1467 }
1468
1469 final String str_str_f = str_str;
1470 final String city_str_f = city_str;
1471 final String hn_str_f = hn_str;
1472
1473 System.out.println("ZANaviDebugReceiver:" + "mem0:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1474
1475 final Thread search_n_001 = new Thread()
1476 {
1477 int wait = 1;
1478
1479 @Override
1480 public void run()
1481 {
1482 while (wait == 1)
1483 {
1484 try
1485 {
1486
1487 // -------- ST I --------
1488 // -------- ST I --------
1489 // -------- ST I --------
1490
1491 // clear results
1492 Navit.NavitAddressResultList_foundItems.clear();
1493 Navit.Navit_Address_Result_double_index.clear();
1494 Navit.NavitSearchresultBarIndex = -1;
1495 Navit.NavitSearchresultBar_title = "";
1496 Navit.NavitSearchresultBar_text = "";
1497 Navit.search_results_towns = 0;
1498 Navit.search_results_streets = 0;
1499 Navit.search_results_streets_hn = 0;
1500 Navit.search_results_poi = 0;
1501
1502 final Thread tttt2 = new Thread()
1503 {
1504 @Override
1505 public void run()
1506 {
1507 System.out.println("search test 001");
1508 Navit.use_index_search = true;
1509 Navit.executeSearch_with_values(str_str_f, city_str_f, hn_str_f, true, true, true, true);
1510 }
1511 };
1512 tttt2.start();
1513 System.out.println("search test 002");
1514 Thread.sleep(2000);
1515 System.out.println("search test 003");
1516
1517 // -- wait for search result --
1518 int c4 = 0;
1519 boolean no_result = false;
1520 Navit.search_list_ready = false;
1521 while (Navit.search_ready == false)
1522 {
1523 System.out.println("search test 004:" + c4);
1524 System.out.println("ZANaviDebugReceiver:" + "mem1:" + Navit.logHeap_for_batch(Navit.Global_Navit_Object.getClass()));
1525
1526 Thread.sleep(500);
1527 c4++;
1528
1529 if (c4 > (2 * 60) * 40)
1530 {
1531 System.out.println("search test 004a");
1532 Navit.search_ready = true;
1533 no_result = true;
1534 }
1535 }
1536 // -- wait for search result --
1537
1538 System.out.println("search test 005");
1539
1540 Thread.sleep(6000);
1541
1542 Navit.runOnUI(new Runnable()
1543 {
1544 @Override
1545 public void run()
1546 {
1547 try
1548 {
1549 System.out.println("hide keyboard-1");
1550 // now hide the keyboard
1551 InputMethodManager inputManager = (InputMethodManager) Navit.Global_Navit_Object.getSystemService(Context.INPUT_METHOD_SERVICE);
1552 inputManager.hideSoftInputFromWindow(Navit.Global_Navit_Object.getCurrentFocus().getWindowToken(), InputMethodManager.HIDE_NOT_ALWAYS);
1553 inputManager.toggleSoftInput(InputMethodManager.SHOW_FORCED, 0);
1554 System.out.println("hide keyboard-2");
1555 }
1556 catch (Exception e)
1557 {
1558 e.printStackTrace();
1559 System.out.println("hide keyboard-3");
1560 }
1561 }
1562 });
1563
1564 System.out.println("search test 005");
1565 Thread.sleep(1500);
1566
1567 // save screenshot
1568 System.out.println("SCREENSHOT 001");
1569 try
1570 {
1571 File f = new File(file_name_global);
1572 File d2 = new File(f.getParent() + "/" + date + "/");
1573 d2.mkdirs();
1574 Navit.take_phone_screenshot(NavitAddressSearchActivity.NavitAddressSearchActivity_s, f.getParent() + "/" + date + "/", f.getName());
1575 }
1576 catch (Exception ee4)
1577 {
1578 System.out.println("SCREENSHOT:error1:" + Navit.stacktrace_to_string(ee4));
1579 ee4.printStackTrace();
1580 }
1581 System.out.println("SCREENSHOT 002");
1582
1583 try
1584 {
1585 NavitAddressSearchActivity.force_done();
1586 }
1587 catch (Exception ee4)
1588 {
1589 System.out.println("SCREENSHOT:error2:" + Navit.stacktrace_to_string(ee4));
1590 ee4.printStackTrace();
1591 }
1592
1593 System.out.println("SCREENSHOT 003");
1594
1595 wait = 0;
1596 // -------- ST I --------
1597 // -------- ST I --------
1598 // -------- ST I --------
1599
1600 FileOutputStream outf = null;
1601 try
1602 {
1603 File f = new File(file_name_global);
1604 outf = new FileOutputStream(f.getParent() + "/" + date + "/" + f.getName() + ".result.txt");
1605 }
1606 catch (Exception ef)
1607 {
1608 //System.out.println("EE002:" + ef.getMessage());
1609 System.out.println("_DREX_:003" + ef.getMessage());
1610 }
1611
1612 OutputStreamWriter out = null;
1613 try
1614 {
1615 out = new OutputStreamWriter(outf);
1616 }
1617 catch (Exception e)
1618 {
1619 // System.out.println("EE003:" + e.getMessage());
1620 System.out.println("_DREX_:004" + e.getMessage());
1621 }
1622
1623 //System.out.println("Roadbook:length=" + (separated.length - 2));
1624 try
1625 {
1626 out.write("Search:length=" + Navit.NavitAddressResultList_foundItems.size() + "\n");
1627 }
1628 catch (Exception e)
1629 {
1630 //System.out.println("EE004:" + e.getMessage());
1631 System.out.println("_DREX_:005" + e.getMessage());
1632 }
1633
1634 try
1635 {
1636 int i = 0;
1637 for (i = 0; i < Navit.NavitAddressResultList_foundItems.size(); i++)
1638 {
1639 out.write("result:" + i + ":" + Navit.NavitAddressResultList_foundItems.get(i).result_type + ":" + Navit.NavitAddressResultList_foundItems.get(i).lat + ":" + Navit.NavitAddressResultList_foundItems.get(i).lon + ":" + Navit.NavitAddressResultList_foundItems.get(i).addr + "\n");
1640 }
1641 }
1642 catch (Exception e)
1643 {
1644 //System.out.println("EE004:" + e.getMessage());
1645 System.out.println("_DREX_:005a" + e.getMessage());
1646 }
1647
1648 try
1649 {
1650 // http://nominatim.openstreetmap.org/search.php?q=wienerneustadt+blubgasse+99
1651 out.write("URL1:" + "http://nominatim.openstreetmap.org/search.php?q=" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1652 out.write("URL2:" + "https://www.google.at/maps/place/" + URLEncoder.encode(city_str_f, "UTF-8") + "+" + URLEncoder.encode(str_str_f, "UTF-8") + "+" + URLEncoder.encode(hn_str_f, "UTF-8") + "\n");
1653 // out.write("URL3:" + "\n");
1654 }
1655 catch (Exception e)
1656 {
1657 System.out.println("_DREX_:046" + e.getMessage());
1658 }
1659
1660 try
1661 {
1662 out.flush();
1663 out.close();
1664 outf.flush();
1665 outf.close();
1666 }
1667 catch (Exception e)
1668 {
1669 System.out.println("_DREX_:016" + e.getMessage());
1670 }
1671
1672 // calculate success criterion ----------------------
1673 // calculate success criterion ----------------------
1674
1675 result_code = -1;
1676
1677 if ((!success_operator.equals("")) && (!success_value.equals("")))
1678 {
1679 // System.out.println("search:so=" + success_source);
1680 System.out.println("search:it=" + success_item);
1681 System.out.println("search:sv=" + success_value);
1682
1683 if (success_item.equalsIgnoreCase("'resultcount'"))
1684 {
1685 try
1686 {
1687 int s = Navit.NavitAddressResultList_foundItems.size();
1688 int v = Integer.parseInt(success_value);
1689 result_code = success_value_compare(s, v);
1690 }
1691 catch (Exception e)
1692 {
1693 result_code = -1;
1694 }
1695 }
1696 }
1697
1698 // dummy for circleCI
1699 File f3 = new File(file_name_global);
1700 System.out.println("ZANaviDebugReceiver:" + "file=" + (f3.getParent() + "/" + date + "/" + f3.getName()));
1701 // dummy for circleCI
1702
1703 if (result_code == 0)
1704 {
1705 File f = new File(file_name_global);
1706 String orig = f.getParent() + "/" + date + "/" + f.getName() + ".result.txt";
1707 String rename_to = f.getParent() + "/" + date + "/" + f.getName() + "._SUCCESS_.result.txt";
1708 File f2 = new File(orig);
1709 File f2_to = new File(rename_to);
1710 f2.renameTo(f2_to);
1711
1712 yaml_err--;
1713 }
1714 else
1715 {
1716 }
1717
1718 // calculate success criterion ----------------------
1719 // calculate success criterion ----------------------
1720
1721 }
1722 catch (Exception ebig)
1723 {
1724 System.out.println("_DREX_:033" + Navit.stacktrace_to_string(ebig));
1725 }
1726 }
1727 }
1728 };
1729 search_n_001.start();
1730 search_n_001.join();
1731 Thread.sleep(500);
1732
1733 is_replaying = false;
1734 NavitGraphics.NavitAOverlay_s.postInvalidate();
1735 br.close();
1736 }
1737 }
1738 catch (Exception e)
1739 {
1740 System.out.println("_DREX_:011" + e.getMessage());
653 is_replaying = false; 1741 is_replaying = false;
654 NavitGraphics.NavitAOverlay_s.postInvalidate(); 1742 NavitGraphics.NavitAOverlay_s.postInvalidate();
655 } 1743 }
656 } 1744 }
657 1745
662 if (s == v) 1750 if (s == v)
663 { 1751 {
664 return 0; 1752 return 0;
665 } 1753 }
666 } 1754 }
1755 else if (success_operator.equalsIgnoreCase("'<>'"))
1756 {
1757 if (s != v)
1758 {
1759 return 0;
1760 }
1761 }
1762 else if (success_operator.equalsIgnoreCase("'!='"))
1763 {
1764 if (s != v)
1765 {
1766 return 0;
1767 }
1768 }
667 else if (success_operator.equalsIgnoreCase("'<'")) 1769 else if (success_operator.equalsIgnoreCase("'<'"))
668 { 1770 {
669 if (s < v) 1771 if (s < v)
670 { 1772 {
671 return 0; 1773 return 0;
672 } 1774 }
673 } 1775 }
1776 else if (success_operator.equalsIgnoreCase("'<='"))
1777 {
1778 if (s <= v)
1779 {
1780 return 0;
1781 }
1782 }
1783 else if (success_operator.equalsIgnoreCase("'=<'"))
1784 {
1785 if (s <= v)
1786 {
1787 return 0;
1788 }
1789 }
674 else if (success_operator.equalsIgnoreCase("'>'")) 1790 else if (success_operator.equalsIgnoreCase("'>'"))
675 { 1791 {
676 if (s > v) 1792 if (s > v)
677 { 1793 {
678 return 0; 1794 return 0;
679 } 1795 }
680 } 1796 }
1797 else if (success_operator.equalsIgnoreCase("'>='"))
1798 {
1799 if (s >= v)
1800 {
1801 return 0;
1802 }
1803 }
1804 else if (success_operator.equalsIgnoreCase("'=>'"))
1805 {
1806 if (s >= v)
1807 {
1808 return 0;
1809 }
1810 }
681 1811
682 return -1; 1812 return -1;
683 } 1813 }
684 1814
685 static void DR_run_all_yaml_tests() 1815 static void DR_run_all_yaml_tests()
686 { 1816 {
1817 String yaml_dir = Navit.NAVIT_DATA_DEBUG_DIR + "../yamltests/";
1818 String duration_string = "";
1819
687 try 1820 try
688 { 1821 {
689 String yaml_dir = Navit.NAVIT_DATA_DEBUG_DIR + "../yamltests/";
690 File dir = new File(yaml_dir); 1822 File dir = new File(yaml_dir);
691 try 1823 try
692 { 1824 {
693 dir.mkdirs(); 1825 dir.mkdirs();
694 } 1826 }
695 catch (Exception e2) 1827 catch (Exception e2)
696 { 1828 {
697 System.out.println("XXXX:E01" + e2.getMessage()); 1829 // System.out.println("XXXX:E01" + e2.getMessage());
1830 System.out.println("_DREX_:012" + e2.getMessage());
698 } 1831 }
1832
1833 Navit.static_show_route_graph(4);
699 1834
700 String date_str = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date()); 1835 String date_str = new SimpleDateFormat("yyyy-MM-dd_HHmmss", Locale.GERMAN).format(new Date());
701 1836
702 FilenameFilter textFilter = new FilenameFilter() 1837 FilenameFilter textFilter = new FilenameFilter()
703 { 1838 {
704 public boolean accept(File dir, String name) 1839 public boolean accept(File dir, String name)
705 { 1840 {
706 String lowercaseName = name.toLowerCase(); 1841 String lowercaseName = name.toLowerCase(Locale.GERMAN);
707 if (lowercaseName.endsWith(".yaml")) 1842 if (lowercaseName.endsWith(".yaml"))
708 { 1843 {
709 return true; 1844 return true;
710 } 1845 }
711 else 1846 else
713 return false; 1848 return false;
714 } 1849 }
715 } 1850 }
716 }; 1851 };
717 1852
718 // System.out.println("XXXX:1:" + dir); 1853 System.out.println("XXXX:1:" + dir);
1854
1855 yaml_sum = 0;
1856 yaml_err = 0;
1857 BufferedReader br = null;
1858 String line2 = "";
719 1859
720 File[] directoryListing = dir.listFiles(textFilter); 1860 File[] directoryListing = dir.listFiles(textFilter);
721 if (directoryListing != null) 1861 if (directoryListing != null)
722 { 1862 {
723 for (File yamlfile : directoryListing) 1863 for (File yamlfile : directoryListing)
724 { 1864 {
1865 yaml_sum++;
1866
725 final Thread temp_work_thread = new Thread() 1867 final Thread temp_work_thread = new Thread()
726 { 1868 {
727 @Override 1869 @Override
728 public void run() 1870 public void run()
729 { 1871 {
730 try 1872 try
731 { 1873 {
1874 //if (Navit.CIDEBUG > 0) // automatic debug run
1875 //{
1876 // Navit.show_geo_on_screen_no_draw(0, 0);
1877 // Thread.sleep(200);
1878 // Navit.set_zoom_level_no_draw((int) Math.pow(2, 5)); // zoom level: (18 - 5) = 13
1879 // Thread.sleep(200);
1880 //}
1881 //else
1882 //{
732 Navit.show_geo_on_screen_no_draw(0, 0); 1883 Navit.show_geo_on_screen_no_draw(0, 0);
733 Thread.sleep(500); 1884 Thread.sleep(150);
734 Navit.set_zoom_level_no_draw((int) Math.pow(2, 17)); 1885 Navit.set_zoom_level_no_draw((int) Math.pow(2, 17));
735 Thread.sleep(120); 1886 Thread.sleep(120);
736 Navit.draw_map(); 1887 //}
737 } 1888 }
738 catch (Exception e2) 1889 catch (Exception e2)
739 { 1890 {
1891 System.out.println("_DREX_:013" + e2.getMessage());
740 e2.printStackTrace(); 1892 e2.printStackTrace();
741 } 1893 }
742 } 1894 }
743 }; 1895 };
744 temp_work_thread.start(); 1896 temp_work_thread.start();
745 temp_work_thread.join(); 1897 temp_work_thread.join();
746 1898
1899 System.out.println("XXXX:2:1:" + "");
1900 System.out.println("XXXX:2:2:" + "");
1901 System.out.println("XXXX:2:3:" + "======= START =======");
1902 long startTime = System.currentTimeMillis();
1903 System.out.println("XXXX:2:4:" + yamlfile.getAbsolutePath());
1904
1905 br = null;
1906 line2 = "";
1907 try
1908 {
1909 br = new BufferedReader(new FileReader(yamlfile.getAbsolutePath()));
1910 line2 = br.readLine();
1911 }
1912 catch (Exception e66)
1913 {
1914 }
1915
1916 if ((line2.length() >= "type:".length()) && (line2.equals("type: 'NS'")))
1917 {
1918 DR_replay_yaml_file_search_n(yamlfile.getAbsolutePath(), date_str);
1919 }
1920 else if ((line2.length() >= "type:".length()) && (line2.equals("type: 'IS'")))
1921 {
1922 DR_replay_yaml_file_search_i(yamlfile.getAbsolutePath(), date_str);
1923 }
1924 else
1925 {
747 DR_replay_gps_file(yamlfile.getAbsolutePath(), date_str); 1926 DR_replay_gps_file(yamlfile.getAbsolutePath(), date_str);
1927 }
1928
748 // System.out.println("XXXX:2:" + yamlfile.getAbsolutePath()); 1929 System.out.println("XXXX:2:5:" + yamlfile.getAbsolutePath());
1930 float difference = (float) (System.currentTimeMillis() - startTime);
1931 duration_string = duration_string + yamlfile.getName() + ":" + (difference / 1000.0f) + "\n";
1932 System.out.println("XXXX:2:6:" + "======= END ======= duration: " + (difference / 1000.0f) + " secs.");
1933 System.out.println("XXXX:2:7:" + "");
1934 System.out.println("XXXX:2:8:" + "");
1935
1936 //xy//Thread.sleep(1500);
1937
749 } 1938 }
750 } 1939 }
751 } 1940 }
752 catch (Exception e) 1941 catch (Exception e)
753 { 1942 {
754 System.out.println("XXXX:E02" + e.getMessage()); 1943 // System.out.println("XXXX:E02" + e.getMessage());
1944 System.out.println("_DREX_:019" + e.getMessage());
1945 }
1946
1947 try
1948 {
1949 FileOutputStream outf = null;
1950 OutputStreamWriter out = null;
1951 outf = new FileOutputStream(yaml_dir + "/" + "_XX_XX_DURATION_XX_XX_.txt");
1952 out = new OutputStreamWriter(outf);
1953 out.write(duration_string);
1954 out.flush();
1955 out.close();
1956 }
1957 catch (Exception ef2)
1958 {
1959 System.out.println("_DREX_:034" + ef2.getMessage());
1960 }
1961
1962 try
1963 {
1964 FileOutputStream outf = null;
1965 OutputStreamWriter out = null;
1966 outf = new FileOutputStream(yaml_dir + "/" + "_XX_XX_SUMMARY_XX_XX_.txt");
1967 out = new OutputStreamWriter(outf);
1968 out.write("tests:" + yaml_sum + "\n");
1969 out.write("errors:" + yaml_err + "\n");
1970 if (yaml_err > 0)
1971 {
1972 out.write("RES:" + "ERR" + "\n");
1973 }
1974 else
1975 {
1976 out.write("RES:" + "OK" + "\n");
1977 }
1978 out.flush();
1979 out.close();
1980 }
1981 catch (Exception ef2)
1982 {
1983 System.out.println("_DREX_:014" + ef2.getMessage());
1984 // System.out.println("EE00SUM:" + ef2.getMessage());
755 } 1985 }
756 1986
757 DR_clear_route(); 1987 DR_clear_route();
1988
1989 // restore normal state ----------------------
1990 Navit.static_show_route_graph(3);
1991 enable_normal_location();
1992 // restore normal state ----------------------
758 } 1993 }
759 1994
760 static void DR_replay_gps_file(String filename, String date_str) 1995 static void DR_replay_gps_file(String filename, String date_str)
761 { 1996 {
762 1997
913 } 2148 }
914 2149
915 } 2150 }
916 catch (Exception e) 2151 catch (Exception e)
917 { 2152 {
2153 System.out.println("_DREX_:015" + e.getMessage());
918 e.printStackTrace(); 2154 e.printStackTrace();
919 System.out.println("ZANaviDebugReceiver:" + "EX:" + e.getMessage()); 2155 System.out.println("ZANaviDebugReceiver:" + "EX:" + e.getMessage());
920 } 2156 }
921 2157
922 is_replaying = false; 2158 is_replaying = false;
981 Thread.sleep(1000); 2217 Thread.sleep(1000);
982 extras = new Bundle(); 2218 extras = new Bundle();
983 extras.putString("add_destination", "" + lat2 + "," + lon2); 2219 extras.putString("add_destination", "" + lat2 + "," + lon2);
984 DR_add_destination("add_destination", extras); 2220 DR_add_destination("add_destination", extras);
985 2221
986 final Thread debug_zoom_to_route_001 = new Thread() 2222 final Thread debug_zoom_to_route_001a = new Thread()
987 { 2223 {
988 int wait = 1; 2224 int wait = 1;
989 int count = 0; 2225 int count = 0;
990 int max_count = 60; 2226 int max_count = 60;
991 2227
1038 { 2274 {
1039 } 2275 }
1040 } 2276 }
1041 } 2277 }
1042 }; 2278 };
1043 debug_zoom_to_route_001.start(); 2279 debug_zoom_to_route_001a.start();
1044 2280
1045 break; 2281 break;
1046 } 2282 }
1047 else if (key.equals("set_position")) 2283 else if (key.equals("set_position"))
1048 { 2284 {
1134 { 2370 {
1135 e.printStackTrace(); 2371 e.printStackTrace();
1136 } 2372 }
1137 } 2373 }
1138 } 2374 }
1139} 2375}

Legend:
Removed from v.49  
changed lines
  Added in v.50

   
Visit the ZANavi Wiki