Subversion Repositories FlightCtrl

Rev

Rev 403 | Go to most recent revision | Only display areas with differences | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

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