Rev 181 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed
Rev 181 | Rev 208 | ||
---|---|---|---|
Line 1... | Line 1... | ||
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 * |
Line 11... | Line 10... | ||
11 | *********************************************************************************************************************************/ |
10 | *********************************************************************************************************************************/ |
Line 12... | Line 11... | ||
12 | 11 | ||
13 | public class MKStatistics |
12 | public class MKStatistics |
14 | implements Runnable |
13 | implements Runnable |
- | 14 | { |
|
- | 15 | public long motor_on_time=-1; |
|
- | 16 | public long motor_stand_time=-1; |
|
- | 17 | public long motor_sum=-1; |
|
15 | { |
18 | |
Line 16... | Line 19... | ||
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; |
Line 21... | Line -... | ||
21 | new Thread( this ).start(); // fire up main Thread |
- | |
Line -... | Line 24... | ||
- | 24 | new Thread( this ).start(); // fire up main Thread |
|
22 | } |
25 | } |
- | 26 | ||
Line 23... | Line 27... | ||
23 | 27 | ||
24 | public long motor_on_time=-1; |
28 | |
25 | 29 | ||
26 | 30 | private long last_run_ms=-1; |
|
Line 27... | Line 31... | ||
27 | long last_run_ms=-1; |
31 | private long last_step=-1; |
28 | 32 | ||
- | 33 | public void run() |
|
- | 34 | { |
|
29 | public void run() |
35 | while(true) |
30 | { |
36 | { |
- | 37 | ||
- | 38 | if (mk.connected) |
|
- | 39 | { |
|
31 | while(true) |
40 | last_step=System.currentTimeMillis()-last_run_ms; |
32 | { |
41 | |
- | 42 | if (last_run_ms!=-1) |
|
- | 43 | { |
|
33 | 44 | ||
34 | if (mk.connected) |
- | |
35 | { |
45 | if (mk.debug_data.motor_complete>0) |
Line 36... | Line 46... | ||
36 | if (last_run_ms!=-1) |
46 | motor_sum+=mk.debug_data.motor_complete; |
37 | { |
47 | if (mk.debug_data.motor_complete>60) |
38 | if (mk.debug_data.analog[14]>15) |
48 | motor_on_time+=last_step; |
39 | motor_on_time+=System.currentTimeMillis()-last_run_ms; |
49 | if (mk.debug_data.motor_complete==60) |
40 | } |
50 | motor_stand_time+=last_step; |
- | 51 | } |
|
41 | last_run_ms=System.currentTimeMillis(); |
52 | |
42 | 53 | ||
43 | 54 | } |
|
44 | } |
55 | else |
45 | else |
56 | { |