Details | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
303 | ligi | 1 | /************************************** |
403 | ligi | 2 | * |
3 | * WatchDog for MK-Connection |
||
303 | ligi | 4 | * |
5 | * Author: Marcus -LiGi- Bueschleb |
||
403 | ligi | 6 | * |
7 | * see README for further Infos |
||
303 | ligi | 8 | * |
403 | ligi | 9 | * |
303 | ligi | 10 | **************************************/ |
221 | ligi | 11 | |
12 | public class MKWatchDog |
||
13 | implements Runnable |
||
14 | { |
||
15 | |||
16 | MKCommunicator mk=null; |
||
17 | |||
18 | int debug_data_count_buff=-123; |
||
303 | ligi | 19 | int lcd_data_count_buff=-123; |
221 | ligi | 20 | |
495 | ligi | 21 | |
221 | ligi | 22 | public MKWatchDog(MKCommunicator _mk) |
23 | { |
||
495 | ligi | 24 | |
221 | ligi | 25 | mk=_mk; |
26 | new Thread( this ).start(); // fire up main Thread |
||
27 | } |
||
28 | |||
29 | public void run() |
||
30 | { |
||
31 | while(true) |
||
32 | { |
||
303 | ligi | 33 | try { Thread.sleep(1000); } |
221 | ligi | 34 | catch (Exception e) { } |
35 | |||
303 | ligi | 36 | if (mk.connected&&(!mk.force_disconnect)) |
221 | ligi | 37 | { |
38 | if (debug_data_count_buff==mk.debug_data_count) |
||
495 | ligi | 39 | { |
40 | mk.close_connections(false); |
||
41 | } |
||
303 | ligi | 42 | if ((lcd_data_count_buff==mk.lcd_data_count)||(mk.lcd_data_count==0)) |
43 | mk.LCD.trigger_LCD(); |
||
44 | |||
221 | ligi | 45 | debug_data_count_buff=mk.debug_data_count; |
303 | ligi | 46 | lcd_data_count_buff=mk.lcd_data_count; |
47 | |||
221 | ligi | 48 | if (mk.version.major==-1) |
49 | mk.get_version(); |
||
50 | |||
314 | ligi | 51 | if (mk.params.field[0][0]==-1) |
303 | ligi | 52 | mk.get_params(1); |
314 | ligi | 53 | else if (mk.params.field[1][0]==-1) |
54 | mk.get_params(2); |
||
55 | else if (mk.params.field[2][0]==-1) |
||
56 | mk.get_params(3); |
||
57 | else if (mk.params.field[3][0]==-1) |
||
58 | mk.get_params(4); |
||
59 | else if (mk.params.field[4][0]==-1) |
||
60 | mk.get_params(5); |
||
61 | |||
502 | ligi | 62 | for (int c=0;c<32;c++) |
63 | if (!mk.debug_data.got_name[c]) |
||
64 | { |
||
65 | mk.get_debug_name(c); |
||
66 | break; |
||
67 | } |
||
221 | ligi | 68 | |
314 | ligi | 69 | |
221 | ligi | 70 | } |
303 | ligi | 71 | |
221 | ligi | 72 | |
73 | } |
||
74 | } |
||
75 | |||
76 | |||
77 | } |