Subversion Repositories FlightCtrl

Rev

Go to most recent revision | Details | Last modification | View Log | RSS feed

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