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 | |
21 | public MKWatchDog(MKCommunicator _mk) |
||
22 | { |
||
23 | mk=_mk; |
||
24 | new Thread( this ).start(); // fire up main Thread |
||
25 | } |
||
26 | |||
27 | public void run() |
||
28 | { |
||
29 | while(true) |
||
30 | { |
||
303 | ligi | 31 | try { Thread.sleep(1000); } |
221 | ligi | 32 | catch (Exception e) { } |
33 | |||
303 | ligi | 34 | if (mk.connected&&(!mk.force_disconnect)) |
221 | ligi | 35 | { |
36 | if (debug_data_count_buff==mk.debug_data_count) |
||
37 | mk.close_connections(false); |
||
303 | ligi | 38 | |
39 | if ((lcd_data_count_buff==mk.lcd_data_count)||(mk.lcd_data_count==0)) |
||
40 | mk.LCD.trigger_LCD(); |
||
41 | |||
221 | ligi | 42 | debug_data_count_buff=mk.debug_data_count; |
303 | ligi | 43 | lcd_data_count_buff=mk.lcd_data_count; |
44 | |||
221 | ligi | 45 | if (mk.version.major==-1) |
46 | mk.get_version(); |
||
47 | |||
314 | ligi | 48 | if (mk.params.field[0][0]==-1) |
303 | ligi | 49 | mk.get_params(1); |
314 | ligi | 50 | else if (mk.params.field[1][0]==-1) |
51 | mk.get_params(2); |
||
52 | else if (mk.params.field[2][0]==-1) |
||
53 | mk.get_params(3); |
||
54 | else if (mk.params.field[3][0]==-1) |
||
55 | mk.get_params(4); |
||
56 | else if (mk.params.field[4][0]==-1) |
||
57 | mk.get_params(5); |
||
58 | |||
221 | ligi | 59 | |
314 | ligi | 60 | |
221 | ligi | 61 | } |
303 | ligi | 62 | |
221 | ligi | 63 | |
64 | } |
||
65 | } |
||
66 | |||
67 | |||
68 | } |