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");
}
}
当计时器设置为 1 毫秒时,值 (yx) 始终显示 1 毫秒,但如果条件在 0.7 毫秒时变为真,该怎么办。我想要条件变为真的确切时间。
我已经使用 timeNow 函数来获取时间戳。