English 中文(简体)
CAPL 编码,使法典出现拖延
原标题:CAPL code, putting delay in the code

I have a CAPL test code that controls the start of CAN signal sending. My goal is to delay the start of the sending process. My idea to do this is via a setTimer() function in combination with isTimerActive().

总的说来,我的法律着眼于:

main() {   
CANstart();
function_2();
function_3();   
}

CANstart() {    
  SetTimer(Delay, 5000); //Timer initialization, set to be 5000ms

  while (isTimerActive()==1) {
    // this while loop avoids that the code is proceding while the settimer exception is being called and executed
  }

  StartCANTransmitting(); // After this function, jump back to main and proceed with function_2   
}

on timer Delay {
  // Do nothing, just wait   
}

以上方案守则导致当时陷入瘫痪,CANoe没有反应,我结束模拟的唯一途径是通过任务人员。

  • Further examination from my side lead to the conclusion that the timer need more time to process and is not executed at all.
  • Without the isTimerActive() function, the program code does not wait for the timer to finish and there is no delay at all. Seems like the code runs through without waiting for the exception.
  • Seems like CAPL handles loops very bad.

我检查了 st流,以下论坛员额谈到我没有提出任何解决办法的非常相似的问题:

CAPL 时间安排的使用作为延迟

时间过长者是否运行,而休息时间则活跃?

除了测试waitfortime()外,在CAPL中的职能。

问题回答

看来,你在<代码>上存在问题(时间()==1){说明。

CAPL function int isTimerActive requires the parameters timer or mstimer variable and return values 1, if the timer is active otherwise 0.

You can check if the timer is active and the time to elapse in the following way.

timer t;
write("Active? %d", isTimerActive(t)); // writes 0
setTimer(t, 5);
write("Active? %d", isTimerActive(t)); // writes 1
write("Time to elapse: %d",timeToElapse(t)); // Writes 5

添加以下参数的试验:timer,while (istimerActive(Delay)==1){

I would not suggest using the while statement instead you can use the timer directly to call the function StartCANTransmitting() and your Main() should be MainTest()

void MainTest()
{
   TestModuleTitle("Sample Tests");
   TestModuleDescription("This test module calls some test cases to demonstrate ");
   CANstart();
   if (TestGetVerdictLastTestCase() == 1)
      Write("CANstart failed.");
   else
      Write("CANstart passed.");
}

testcase CANstart() {   
  // add info block to test case in report  
  TestReportAddMiscInfoBlock("Used Test Parameters");
  TestReportAddMiscInfo("Max. voltage", "19.5 V");
  TestReportAddMiscInfo("Max. current", "560 mA");
  TestReportAddMiscInfo("StartCANTransmitting");

  SetTimer(Delay, 5000); //Timer initialization, set to be 5000ms
}

on timer Delay {
  StartCANTransmitting();   
}

在测试单元中,你有各种等待功能。 你可以推迟执行,如:

main() {   
  CANstart();
  testWaitForSysVar(sysvar::namespace::any, 5000);  // wait 5000ms or until @namespace::any is changed
  function_2();
  function_3();   
}

An empty while loop like you tried consumes all resources it gets and makes CANoe unusable.

这种办法并不在辛醇标准中发挥作用。 你们需要使用基于事件的守则。





相关问题
sample iphone code for delay and echo

Does anyone know where i can find sample code to apply processing to audio to simulate an echo or delay effect? I am currently using AVAudioPlayer to play samples and would like to layer the effects ...

How do I add a delay after a count down timer

I am using a DispatcherTimer to perform a count down before triggering the release on a camera. The UpdateCountdown method is used to change the image displayed to the user before the camera fires. ...

show data with delay from jquery each loop

My question is the following: What is the best way for looping some json array too show some data with like a one second delay. The one below does not work, because it only shows one message once ...

Flash / actionscript 3 sound delay

Im working on a flash project where I am loading multiple sounds from external files. The problem is that when I play them within my project there is a small delay from when they should be played ...

热门标签