Subversion Repositories Projects

Rev

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

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