除了testwaitfortimeout()外,CAPL中的延迟函数 [英] Delay function in CAPL apart from testwaitfortimeout()

查看:2501
本文介绍了除了testwaitfortimeout()外,CAPL中的延迟函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个控制GPIB电源的CAPL测试节点。该CAPL生成一个每3 ms修改一次的信号。我的CAPL看起来像这样:

I have a CAPL test node that controls a GPIB power supply. This CAPL generates a signal that is modified each 3 ms. My CAPL looks like this:

...
testcase wavGenerator()
{
   GPIBWrite(myDevice, "VOLT", voltValue);
   testwaitfortimeout(3);
   ...
}

问题是此testwaitfortimeout()函数会在测试报告中生成注释,并且由于我为每个测试用例使用此功能2000/3000次,因此我得出了巨大的测试报告。

The problem is that this testwaitfortimeout() function generates a comment in the test report, and since i use this function 2000/3000 times for each testcase, I end with a enormous test report.

我尝试实现一个函数来生成延迟,就像waitfortimeout()一样,

I have tried implementing a function to generate a "delay" like waitfortimeout() does, like this:

void delay(int ms)
{
   float refTime;
   refTime = timeNowFloat();
   while(timeNowFloat() < (refTime + ms*100))
   {
      /* Wait to reach expected time*/
   }
}

但这会使CANoe崩溃。我已经使用setTimer()函数尝试过类似的操作,但是问题是相同的。我怎么能产生这种延迟?

but this crashes CANoe. I have tried something like this with setTimer() functions but the problem is the same. How can I generate this delay?

推荐答案

我找到了一种使用计时器,EnvVar和函数来处理此延迟的方法。 testWaitForEnvVar()

I found a way to deal with this, using a timer, an EnvVar and the function testWaitForEnvVar()

on timer tDelay
{
  @EnvDelayFunct = 1;
}

void delay(int ms)
{
  int a;
  write("Wait for %i ms", ms); 
  setTimer(tDelay, ms);
  a = testWaitForEnvVar(EnvDelayFunct, 0);
  @EnvDelayFunct = 0;
}

这篇关于除了testwaitfortimeout()外,CAPL中的延迟函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆