Timer 如何读取CAPL中的计时器值?
当定时器设置为1ms时,该值(y-x)始终显示1ms,但如果该条件在0.7ms时变为真,该怎么办。我想知道条件变为现实的确切时间Timer 如何读取CAPL中的计时器值?,timer,capl,canoe,Timer,Capl,Canoe,当定时器设置为1ms时,该值(y-x)始终显示1ms,但如果该条件在0.7ms时变为真,该怎么办。我想知道条件变为现实的确切时间 我使用了timeNow函数来获取时间戳。我看不到要访问的任何值。这里你正在做布尔检查,仅此而已。请澄清您的问题。我看不到要访问的任何值。这里你正在做布尔检查,仅此而已。请澄清您的问题。使用CAPL函数TIMETEOEFASE可以读取计时器的剩余时间,当计时器过期时,将调用在on timer V2G中实现的事件过程 在“帮助”中,您可以找到有关CANoe中计时器方法的更
我使用了timeNow函数来获取时间戳。我看不到要访问的任何值。这里你正在做布尔检查,仅此而已。请澄清您的问题。我看不到要访问的任何值。这里你正在做布尔检查,仅此而已。请澄清您的问题。使用CAPL函数TIMETEOEFASE可以读取计时器的剩余时间,当计时器过期时,将调用在on timer V2G中实现的事件过程 在“帮助”中,您可以找到有关CANoe中计时器方法的更多解释
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");
}
}
关于原始问题中的更新。这个怎么样:
CAPL Functions » Classes » Timer, MsTimer
在测量运行时,不要忘记按定义的键。使用CAPL函数TIMETEOEFASE可以读取计时器的剩余时间,当计时器到期时,将调用在on timer V2G中实现的事件过程
variables{
mstimer myTimer;
long timePoint = 0;
int somethinghappen = 0;
}
on start{
long firstTimeDuration, period;
firstTimeDuration = 1000; period = 100;
setTimerCyclic(myTimer, firstTimeDuration, period); /*Timer is set cyclical*/
timePoint = timeNow()/100000.0; /*
Remember the time on measurement start,
which is on start always 0, so what's the reason to do this here?
*/
write("Start time %5.3f", timePoint);
}
on timer myTimer{
if(somethinghappen != 0){
//you need to cancel the timer only when it was set as cyclic, see setTimerCyclic()
cancelTimer(myTimer); /*Cancel timer if response arrived*/
write("Total time taken is %5.3f", timeNow()/100000.0 - timePoint);
}else{
//nothing todo at the moment
}
}
on key 'b' {//boom
somethinghappen = 1;
}
在“帮助”中,您可以找到有关CANoe中计时器方法的更多解释
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");
}
}
关于原始问题中的更新。这个怎么样:
CAPL Functions » Classes » Timer, MsTimer
当测量运行时,不要忘记按定义键。正如许多人已经指出的那样,我相信您在计时器上使用的
不正确。
variables{
mstimer myTimer;
long timePoint = 0;
int somethinghappen = 0;
}
on start{
long firstTimeDuration, period;
firstTimeDuration = 1000; period = 100;
setTimerCyclic(myTimer, firstTimeDuration, period); /*Timer is set cyclical*/
timePoint = timeNow()/100000.0; /*
Remember the time on measurement start,
which is on start always 0, so what's the reason to do this here?
*/
write("Start time %5.3f", timePoint);
}
on timer myTimer{
if(somethinghappen != 0){
//you need to cancel the timer only when it was set as cyclic, see setTimerCyclic()
cancelTimer(myTimer); /*Cancel timer if response arrived*/
write("Total time taken is %5.3f", timeNow()/100000.0 - timePoint);
}else{
//nothing todo at the moment
}
}
on key 'b' {//boom
somethinghappen = 1;
}
从矢量知识库中
您可以在CAPL中定义时间事件。当此事件发生时,即当某一时间段过去时,将调用相关的开启计时器过程
从这里我看到,通过在计时器上执行内部的布尔检查,您将始终读取计时器结束时经过的当前时间。如果由于某种情况发生,您想提前退出计时器,我建议您采取一种完整的解决方法。您是否尝试过设置系统变量?正如许多人已经指出的那样,我认为您在计时器上使用的不正确。
从矢量知识库中
您可以在CAPL中定义时间事件。当此事件发生时,即当某一时间段过去时,将调用相关的开启计时器过程
从这里我看到,通过在计时器上执行内部的布尔检查,您将始终读取计时器结束时经过的当前时间。如果由于某种情况发生,您想提前退出计时器,我建议您采取一种完整的解决方法。是否尝试设置系统变量?如果需要测量小于1ms单位的时间,请使用TimeNowNS()函数(纳秒)。基本上,用TimeNowNS()替换您的代码,并将使用的变量调整为双倍,以便记录的时间戳能够正确地匹配 如果需要测量小于1ms单位的时间,请使用TimeNowNS()函数(纳秒)。基本上,用TimeNowNS()替换您的代码,并将使用的变量调整为双倍,以便记录的时间戳能够正确地匹配