Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
4 | ligi | 1 | /************************************** |
2 | * |
||
3 | * WatchDog for MK-Connection |
||
4 | * |
||
5 | * Author: Marcus -LiGi- Bueschleb |
||
6 | * |
||
7 | * see README for further Infos |
||
8 | * |
||
9 | * |
||
10 | **************************************/ |
||
11 | |||
12 | public class MKWatchDog |
||
135 | ligi | 13 | implements Runnable,DUBwiseDefinitions |
4 | ligi | 14 | { |
15 | |||
16 | MKCommunicator mk=null; |
||
17 | |||
18 | int debug_data_count_buff=-123; |
||
19 | int lcd_data_count_buff=-123; |
||
20 | |||
21 | |||
22 | public MKWatchDog(MKCommunicator _mk) |
||
23 | { |
||
24 | |||
25 | mk=_mk; |
||
26 | new Thread( this ).start(); // fire up main Thread |
||
27 | } |
||
28 | |||
135 | ligi | 29 | int lcd_timeout=0; // detect if we lost packets |
30 | |||
31 | public int act_paramset=0; |
||
32 | |||
4 | ligi | 33 | public void run() |
34 | { |
||
135 | ligi | 35 | |
36 | |||
37 | |||
38 | |||
39 | // get all params |
||
40 | |||
41 | int act_debug_name=0; |
||
42 | |||
43 | |||
4 | ligi | 44 | while(true) |
45 | { |
||
135 | ligi | 46 | |
47 | try { Thread.sleep(30); } // 3000 |
||
4 | ligi | 48 | catch (Exception e) { } |
49 | |||
50 | if (mk.connected&&(!mk.force_disconnect)) |
||
51 | { |
||
135 | ligi | 52 | |
53 | if ( mk.version.major==-1 ) |
||
54 | { |
||
55 | try { Thread.sleep(150); } |
||
56 | catch (Exception e) { } |
||
57 | mk.get_version(); |
||
58 | } |
||
59 | else if ((act_paramset<5)&&(mk.root.canvas.user_intent==USER_INTENT_PARAMS) &&(! mk.root.canvas.ufo_prober.is_navi())) |
||
60 | { |
||
61 | mk.get_params(act_paramset+1); |
||
62 | |||
63 | try { Thread.sleep(450); } |
||
64 | catch (Exception e) { } |
||
65 | |||
66 | if(mk.params.field[act_paramset]!=null) |
||
67 | act_paramset++; |
||
68 | } |
||
69 | else if (( act_debug_name<32)&&(mk.root.canvas.user_intent==USER_INTENT_RAWDEBUG)) |
||
70 | { |
||
71 | mk.get_debug_name(act_debug_name); |
||
72 | |||
73 | try { Thread.sleep(350); } |
||
74 | catch (Exception e) { } |
||
75 | |||
76 | |||
77 | if (mk.debug_data.got_name[act_debug_name]) act_debug_name++; |
||
78 | } |
||
79 | |||
80 | |||
81 | |||
82 | |||
83 | |||
84 | |||
85 | |||
86 | /* |
||
87 | |||
88 | |||
4 | ligi | 89 | if (debug_data_count_buff==mk.debug_data_count) |
90 | { |
||
81 | ligi | 91 | // mk.close_connections(false); |
4 | ligi | 92 | } |
62 | ligi | 93 | |
135 | ligi | 94 | */ |
62 | ligi | 95 | |
135 | ligi | 96 | /*if (mk.version.major==-1) |
4 | ligi | 97 | mk.get_version(); |
135 | ligi | 98 | else |
99 | */ |
||
100 | /*for ( int cnt=0;cnt<5;cnt++) |
||
62 | ligi | 101 | if (mk.params.field[cnt]==null) |
102 | { |
||
103 | mk.get_params(cnt+1); |
||
104 | break; |
||
135 | ligi | 105 | }*/ |
106 | /* |
||
4 | ligi | 107 | for (int c=0;c<32;c++) |
108 | if (!mk.debug_data.got_name[c]) |
||
109 | { |
||
110 | mk.get_debug_name(c); |
||
111 | break; |
||
112 | } |
||
135 | ligi | 113 | */ |
114 | |||
115 | else if ((lcd_data_count_buff!=mk.lcd_data_count)||(mk.lcd_data_count==0)||(lcd_timeout==23)) |
||
116 | { |
||
117 | lcd_timeout=0; |
||
118 | lcd_data_count_buff=mk.lcd_data_count; |
||
119 | mk.LCD.trigger_LCD(); |
||
120 | try { Thread.sleep(50); } |
||
121 | catch (Exception e) { } |
||
122 | //debug_data_count_buff=mk.debug_data_count; |
||
123 | |||
124 | } |
||
125 | else |
||
126 | { |
||
127 | lcd_timeout++; |
||
128 | } |
||
4 | ligi | 129 | |
135 | ligi | 130 | |
4 | ligi | 131 | |
132 | } |
||
133 | |||
134 | |||
135 | } |
||
136 | } |
||
137 | |||
138 | |||
139 | } |