Rev 221 |
Blame |
Last modification |
View Log
| RSS feed
/********************************************************************************
* Statistics from MK-Connection ( needed for 2. Thread and Readability of Code )
*
* Author: Marcus -LiGi- Bueschleb
*
* see README for further Infos
*
********************************************************************************/
public class MKStatistics
implements Runnable
{
public long motor_on_time=-
1;
public long motor_stand_time=-
1;
public long motor_sum=-
1;
MKCommunicator mk=
null;
public MKStatistics
(MKCommunicator _mk
)
{
mk=_mk
;
new Thread( this ).
start(); // fire up main Thread
}
private long last_run_ms=
0;
private long last_step=-
1;
public void run
()
{
while(true)
{
if (mk.
connected)
{
if (last_run_ms
!=
0)
{
last_step=
System.
currentTimeMillis()-last_run_ms
;
if (mk.
debug_data.
motor_complete>0)
motor_sum+=mk.
debug_data.
motor_complete;
if (mk.
debug_data.
motor_complete>60)
motor_on_time+=last_step
;
if (mk.
debug_data.
motor_complete==
60)
motor_stand_time+=last_step
;
}
last_run_ms=
System.
currentTimeMillis();
}
else
{
last_run_ms=-
1;
motor_on_time=-
1;
motor_stand_time=-
1;
}
try { Thread.
sleep(500); }
catch (Exception e
) { }
}
}
}