CAPL尝试

2020-11-25  本文已影响0人  黑山老雕

CAPL是CANoe的脚本。
当系统变量发生变化时触发逻辑:

/*@!Encoding:1252*/
includes
{
  
}



variables
{
   char buffer[100];
  float timestamp;
}

on start{
writeLineEx(4, 1, "I START");
}

on stopMeasurement{
  writeLineEx(4, 1,"I STOP");
}

// 当这个Struct的值更新时
on sysvar_update My::TEST.status{
   sysSetVariableFloat (sysvar::MyVariables::DeltaTime, timestamp);
  sysSetVariableAsync(sysvar::MyVariables::MyVar, 100);
  // 把数值转换成字符串
  snprintf(buffer,elcount(buffer),"%d",@this);
  // 获取时间戳
  timestamp = this.time_ns / 1000000000;
  // 向TEST窗口写一条log
  writeLineEx(4, 1, "status CHANGED to %s, time: %f" , buffer, timestamp);
  
 
}

这里,如果设置的sysvar要生效,需要设置为analysis only,并且设置事件为All Events


image.png
上一篇下一篇

猜你喜欢

热点阅读