Rev 266 | Details | Compare with Previous | Last modification | View Log | RSS feed
Rev | Author | Line No. | Line |
---|---|---|---|
206 | ligi | 1 | /******************************************************************************** |
2 | * Statistics from MK-Connection ( needed for 2. Thread and Readability of Code ) |
||
3 | * |
||
4 | * Author: Marcus -LiGi- Bueschleb |
||
5 | * |
||
6 | * see README for further Infos |
||
7 | * |
||
8 | ********************************************************************************/ |
||
9 | |||
10 | package org.ligi.ufo; |
||
11 | |||
12 | public class MKStatistics |
||
13 | |||
14 | { |
||
15 | public int bytes_in=0; |
||
16 | public int bytes_out=0; |
||
17 | |||
18 | |||
265 | ligi | 19 | |
219 | ligi | 20 | public int resend_count=0; |
381 | ligi | 21 | public int crc_fail=0; |
219 | ligi | 22 | |
206 | ligi | 23 | public int debug_data_count=0; |
24 | public int debug_names_count=0; |
||
25 | public int angle_data_count=0; |
||
26 | public int version_data_count=0; |
||
27 | public int other_data_count=0; |
||
28 | public int lcd_data_count=0; |
||
29 | public int params_data_count=0; |
||
30 | public int navi_data_count=0; |
||
31 | public int stick_data_count=0; |
||
219 | ligi | 32 | public int external_control_confirm_frame_count=0; |
206 | ligi | 33 | |
34 | |||
35 | public int debug_data_request_count=0; |
||
36 | public int debug_name_request_count=0; |
||
37 | public int version_data_request_count=0; |
||
38 | public int lcd_data_request_count=0; |
||
39 | public int params_data_request_count=0; |
||
40 | // public int navi_data_count=0; |
||
41 | public int stick_data_request_count=0; |
||
42 | public int motortest_request_count=0; |
||
219 | ligi | 43 | public int external_control_request_count=0; |
206 | ligi | 44 | |
219 | ligi | 45 | |
265 | ligi | 46 | |
47 | public long flying_start=-1; |
||
48 | |||
49 | public int heading_start=0; |
||
50 | public int last_heading=0; |
||
266 | ligi | 51 | public int max_speed=0; |
265 | ligi | 52 | |
266 | ligi | 53 | |
54 | public long speed_sum=0; |
||
55 | public int speed_cnt=1; |
||
56 | |||
57 | public int max_alt=0; |
||
58 | |||
381 | ligi | 59 | |
60 | public MKStatistics() |
||
61 | { |
||
62 | reset(); |
||
63 | } |
||
266 | ligi | 64 | public int avg_speed() |
65 | { |
||
66 | return (int)(speed_sum/speed_cnt); |
||
67 | } |
||
68 | public void process_speed(int speed) |
||
69 | { |
||
70 | if (speed>max_speed) |
||
71 | max_speed=speed; |
||
72 | speed_sum+=speed; |
||
73 | speed_cnt++; |
||
74 | } |
||
75 | |||
76 | public void process_alt(int alt) |
||
77 | { |
||
78 | if (alt>max_alt) |
||
79 | max_alt=alt; |
||
80 | |||
81 | } |
||
265 | ligi | 82 | public void process_mkflags(int flags) |
83 | { |
||
84 | if (flags==0) |
||
85 | flying_start=-1; |
||
86 | |||
87 | else |
||
88 | |||
89 | if (flying_start==-1) |
||
90 | { |
||
91 | flying_start=System.currentTimeMillis(); |
||
92 | heading_start=last_heading; |
||
93 | } |
||
94 | |||
95 | } |
||
96 | |||
97 | public void process_compas(int heading) |
||
98 | { |
||
99 | last_heading=heading; |
||
100 | } |
||
101 | |||
102 | public int flying_time() |
||
103 | { |
||
104 | if (flying_start!=-1) |
||
105 | return (int)((System.currentTimeMillis()-flying_start)/1000); |
||
106 | else |
||
107 | return 0; |
||
108 | } |
||
109 | |||
110 | |||
206 | ligi | 111 | public void reset() |
112 | { |
||
381 | ligi | 113 | flying_start=-1; |
114 | crc_fail=0; |
||
206 | ligi | 115 | debug_data_count=0; |
116 | debug_names_count=0; |
||
117 | angle_data_count=0; |
||
118 | version_data_count=0; |
||
119 | other_data_count=0; |
||
120 | lcd_data_count=0; |
||
121 | params_data_count=0; |
||
122 | navi_data_count=0; |
||
123 | bytes_in=0; |
||
124 | bytes_out=0; |
||
125 | stick_data_count=0; |
||
126 | |||
127 | |||
128 | debug_data_request_count=0; |
||
129 | debug_name_request_count=0; |
||
130 | version_data_request_count=0; |
||
131 | lcd_data_request_count=0; // |
||
132 | params_data_request_count=0; // |
||
133 | stick_data_request_count=0; |
||
134 | motortest_request_count=0; // |
||
135 | |||
136 | |||
137 | } |
||
138 | |||
139 | } |