Delay function in CAPL apart from testwaitfortimeout()

旧城冷巷雨未停 提交于 2020-01-06 07:22:11

问题


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);
   ...
}

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.

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*/
   }
}

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?


回答1:


One idea could be to use a timer:

variables
{
  msTimer myTimer;
}

testcase wavGenerator()
{
  GPIBWrite(myDevice, "VOLT", voltValue);
  setTimer(myTimer, 3);
}

on timer myTimer
{
  // your code
}

Alternatively you can always create a custom style-sheet (XSLT) that filters all calls to testwaitfortimeout from the report.




回答2:


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;
}


来源:https://stackoverflow.com/questions/47803601/delay-function-in-capl-apart-from-testwaitfortimeout

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!