Subversion Repositories FlightCtrl

Rev

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

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