CAPL尝试

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


CAPL尝试_第1张图片
image.png

你可能感兴趣的:(CAPL尝试)