variables
{
mstimer T1;
long x,y;
}
on start
{
setTimer(T1,1); /*Timer set to 1ms*/
x=timeNow()/100000.0; /*Getting a time stamp when i start a timer*/
}
on timer T1
{
if(response==0) /*Check if response is sent or a function*/ has completed successfully*/ /*CONDITION*/
{
cancelTimer(T1); /*Cancel timer if response is correct*/
y=timeNow()/100000.0; /*Getting a timestamp when i stop a timer.*/
write("Total time taken is %d",y-x); /*Getting the time required to complete the condition (response==0)*/
}
else /*Setting timer again to check the condition*/
{
setTimer(T1,1);
write("Timer started again");
}
}
the value (y-x) always shows 1ms as the timer is set to 1ms, but what if the condition has become true at 0.7ms. I wanted the exact time at which the condition became true.
I have used timeNow function to get the timestamps.