Subversion Repositories FlightCtrl

Rev

Rev 181 | Go to most recent revision | Details | Compare with Previous | Last modification | View Log | RSS feed

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