Subversion Repositories FlightCtrl

Rev

Rev 208 | 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
 
221 ligi 30
    private long last_run_ms=0;
208 ligi 31
    private long last_step=-1;
32
 
181 ligi 33
    public void run()
34
    {
35
        while(true)
36
            {
37
 
38
                if (mk.connected)
39
                    {
221 ligi 40
 
208 ligi 41
 
221 ligi 42
                        if (last_run_ms!=0)
181 ligi 43
                            {
221 ligi 44
                                last_step=System.currentTimeMillis()-last_run_ms;      
208 ligi 45
 
46
                                if (mk.debug_data.motor_complete>0)
47
                                    motor_sum+=mk.debug_data.motor_complete;
48
                                if (mk.debug_data.motor_complete>60)
49
                                    motor_on_time+=last_step;
50
                                if (mk.debug_data.motor_complete==60)
51
                                    motor_stand_time+=last_step;
181 ligi 52
                            }
221 ligi 53
                        last_run_ms=System.currentTimeMillis();
208 ligi 54
 
181 ligi 55
 
56
                    }
57
                else
58
                    {
59
                        last_run_ms=-1;
60
                        motor_on_time=-1;
208 ligi 61
                        motor_stand_time=-1;
181 ligi 62
                    }
63
                try { Thread.sleep(500); }
64
                catch (Exception e)  {   }
65
            }
66
    }
67
 
68
 
69
}