Blame |
Last modification |
View Log
| RSS feed
/*********************************************************************************************************************************
* *
* Some Statistics from MK-Connection ( needed for 2. Thread and Readability of Code ) *
* *
* Author: Marcus -LiGi- Bueschleb *
* Project-Start: 9/2007 *
* Version: 0.07 *
* Mailto: ligi@smart4mobile.de *
* Licence: Creative Commons / Non Commercial *
* Big Up: Holger&Ingo *
*********************************************************************************************************************************/
public class MKStatistics
implements Runnable
{
MKCommunicator mk=
null;
public MKStatistics
(MKCommunicator _mk
)
{
mk=_mk
;
new Thread( this ).
start(); // fire up main Thread
}
public long motor_on_time=-
1;
long last_run_ms=-
1;
public void run
()
{
while(true)
{
if (mk.
connected)
{
if (last_run_ms
!=-
1)
{
if (mk.
debug_data.
analog[14]>15)
motor_on_time+=
System.
currentTimeMillis()-last_run_ms
;
}
last_run_ms=
System.
currentTimeMillis();
}
else
{
last_run_ms=-
1;
motor_on_time=-
1;
}
try { Thread.
sleep(500); }
catch (Exception e
) { }
}
}
}