Rev 4 | Go to most recent revision | Details | Compare with Previous | 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 |
||
13 | implements Runnable |
||
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 | |||
29 | public void run() |
||
30 | { |
||
31 | while(true) |
||
32 | { |
||
33 | try { Thread.sleep(1000); } |
||
34 | catch (Exception e) { } |
||
35 | |||
36 | if (mk.connected&&(!mk.force_disconnect)) |
||
37 | { |
||
38 | if (debug_data_count_buff==mk.debug_data_count) |
||
39 | { |
||
40 | mk.close_connections(false); |
||
41 | } |
||
42 | if ((lcd_data_count_buff==mk.lcd_data_count)||(mk.lcd_data_count==0)) |
||
43 | mk.LCD.trigger_LCD(); |
||
44 | |||
45 | debug_data_count_buff=mk.debug_data_count; |
||
46 | lcd_data_count_buff=mk.lcd_data_count; |
||
62 | ligi | 47 | |
4 | ligi | 48 | |
62 | ligi | 49 | |
4 | ligi | 50 | if (mk.version.major==-1) |
51 | mk.get_version(); |
||
52 | |||
62 | ligi | 53 | for ( int cnt=0;cnt<5;cnt++) |
54 | if (mk.params.field[cnt]==null) |
||
55 | { |
||
56 | mk.get_params(cnt+1); |
||
57 | break; |
||
58 | } |
||
59 | |||
4 | ligi | 60 | for (int c=0;c<32;c++) |
61 | if (!mk.debug_data.got_name[c]) |
||
62 | { |
||
63 | mk.get_debug_name(c); |
||
64 | break; |
||
65 | } |
||
66 | |||
67 | |||
68 | } |
||
69 | |||
70 | |||
71 | } |
||
72 | } |
||
73 | |||
74 | |||
75 | } |