Subversion Repositories FlightCtrl

Rev

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

Rev 181 Rev 208
1
/*********************************************************************************************************************************
1
/**********************************************************************************************************************************
2
 *                                                                                                                                *
-
 
3
 * Some Statistics from MK-Connection ( needed for 2. Thread and Readability of Code )                                            *
2
 *      Statistics from MK-Connection ( needed for 2. Thread and Readability of Code )                                            *
4
 *                                                                                                                                *
3
 *                                                                                                                                *
5
 * Author:        Marcus -LiGi- Bueschleb                                                                                         *
4
 * Author:        Marcus -LiGi- Bueschleb                                                                                         *
6
 * Project-Start: 9/2007                                                                                                          *
5
 * Project-Start: 9/2007                                                                                                          *
7
 * Version:       0.07                                                                                                            *            
6
 * Version:       0.07                                                                                                            *            
8
 * Mailto:        ligi@smart4mobile.de                                                                                            *
7
 * Mailto:        ligi@smart4mobile.de                                                                                            *
9
 * Licence:       Creative Commons / Non Commercial                                                                               *
8
 * Licence:       Creative Commons / Non Commercial                                                                               *
10
 * Big Up:        Holger&Ingo                                                                                                     *
9
 * Big Up:        Holger&Ingo                                                                                                     *
11
 *********************************************************************************************************************************/
10
 *********************************************************************************************************************************/
12
 
11
 
13
public class MKStatistics
12
public class MKStatistics
14
   implements Runnable
13
   implements Runnable
15
{
14
{
-
 
15
    public long motor_on_time=-1;
-
 
16
    public long motor_stand_time=-1;
-
 
17
    public long motor_sum=-1;
-
 
18
 
16
    MKCommunicator mk=null;
19
    MKCommunicator mk=null;
17
 
20
 
18
    public MKStatistics(MKCommunicator _mk)
21
    public MKStatistics(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 long motor_on_time=-1;
27
 
-
 
28
 
25
 
29
 
26
 
30
    private long last_run_ms=-1;
27
    long last_run_ms=-1;
31
    private long last_step=-1;
28
 
32
 
29
    public void run()
33
    public void run()
30
    {
34
    {
31
        while(true)
35
        while(true)
32
            {
36
            {
33
               
37
               
34
                if (mk.connected)
38
                if (mk.connected)
35
                    {
39
                    {
-
 
40
                        last_step=System.currentTimeMillis()-last_run_ms;      
-
 
41
 
36
                        if (last_run_ms!=-1)
42
                        if (last_run_ms!=-1)
37
                            {
43
                            {
-
 
44
 
-
 
45
                                if (mk.debug_data.motor_complete>0)
-
 
46
                                    motor_sum+=mk.debug_data.motor_complete;
38
                                if (mk.debug_data.analog[14]>15)
47
                                if (mk.debug_data.motor_complete>60)
39
                                    motor_on_time+=System.currentTimeMillis()-last_run_ms;     
48
                                    motor_on_time+=last_step;
-
 
49
                                if (mk.debug_data.motor_complete==60)
-
 
50
                                    motor_stand_time+=last_step;
40
                            }
51
                            }
41
                        last_run_ms=System.currentTimeMillis();
-
 
42
                       
52
               
43
                       
53
                       
44
                    }
54
                    }
45
                else
55
                else
46
                    {
56
                    {
47
                        last_run_ms=-1;
57
                        last_run_ms=-1;
48
                        motor_on_time=-1;
58
                        motor_on_time=-1;
-
 
59
                        motor_stand_time=-1;
49
                    }
60
                    }
50
                try { Thread.sleep(500); }
61
                try { Thread.sleep(500); }
51
                catch (Exception e)  {   }
62
                catch (Exception e)  {   }
52
            }
63
            }
53
    }
64
    }
54
 
65
 
55
   
66
   
56
}
67
}
57
 
68