我想知道是否可以创建一个CAPL代码,其中通过使用“ on key”功能,用户可以: -激活重播模式(.asc文件) -在其上激活过滤器 -额外激活一个特定的信号(asc文件中不存在) -停用重播模式 -停用特定信号 -启用或停用特定消息和/或跟踪
详细说明一下,目前我正在使用此代码:
/*@!Encoding:1252*/
variables // declaration of the specific messages I need
{
message MESSAGE01 msg_MESSAGE01 ;
message MESSAGE02 msg_MESSAGE02 ;
}
on key 't' // here I'd need the activation of a replay block in .asc format with a filter on a specific message
{
// Really don't know how to insert here
}
on key 'd' // here I'd need the deactivation of a replay block in .asc format
{
// Really don't know how to insert here
}
on key 'p' // specific signals deactivation
{
msg_MESSAGE01.SIGNAL01= 0; // assign the value to the message
msg_MESSAGE02.SIGNAL02 = 1; // assign the value to the message
output(msg_MESSAGE01); //send the message to the CAN bus
output(msg_MESSAGE02); //send the message to the CAN bus
// output(output of the asc file); // if activated, I'd like to see in output all the messages of the .asc; if not, I'd like to see just those specific signals.
}
on key 'u' // specific signals deactivation
{
// msg_MESSAGE01.SIGNAL01 = none; // here, I'd like to "unset" the value
msg_MESSAGE02.SIGNAL02= 0;
output(msg_MESSAGE01);
output (msg_MESSAGE02);
// output(output of the asc file); // if activated, I'd like to see in output all the messages of the .asc; if not, I'd like to see just those specific signals.
}
如果不清楚,我可以更好地解释我的要求:)
提前谢谢^^ 干杯
答案 0 :(得分:1)
欢迎使用StackOverflow!
您实际上可以激活重播块(至少在CANoe上,请查看CANalyzer的兼容性)。
我需要激活/停用.asc格式的重播块
variables
{
char replayName[32] = "ibus_data";
}
on key 'b'
{
replayStart( replayName);
}
on key 'e'
{
replayStop( replayName);
}
on key 's'
{
replaySuspend( replayName);
}
on key 'r'
{
replayResume( replayName);
}
on key 'w'
{
writeReplayState( replayName);
}
void writeReplayState( char name[])
{
switch ( replayState( name))
{
case 0:
write( "Replay Block %s is stopped", replayName);
break;
case 1:
write( "Replay Block %s is running", replayName);
break;
case 2:
write( "Replay Block %s is suspended", replayName);
break;
default:
write( "Error: Replay Block %s has an unknown state!", replayName);
break;
};
}
您必须预先配置重放文件,并且过滤器部分需要其他解决方案。有关更多信息,请参见参考和以下示例:ReplayStart, ReplayStop, ReplaySuspend, ReplayResume, ReplayState
来自: CAPL功能概述»常规»示例:ReplayStart,ReplayStop,ReplaySuspend,ReplayResume,ReplayState
特定信号的激活/停用
一个“ hacky”解决方案突然出现在我的脑海中,它具有适当的标记系统。当然,丑陋的解决方案可能手头上有更好的东西。尝试类似的东西:
on message myMessage
{
if (flag)
output(myMessage)
}
on key 'u'
{
flag ? 0 : 1 // short for: toggle the status of the flag
}
请告诉我这是否有帮助。
关于这段代码:
on key 'p' // specific signals deactivation
{
msg_MESSAGE01.SIGNAL01= 0; // assign the value to the message
msg_MESSAGE02.SIGNAL02 = 1; // assign the value to the message
output(msg_MESSAGE01); //send the message to the CAN bus
output(msg_MESSAGE02); //send the message to the CAN bus
}
请注意,它不会达到您的期望。您要求发送有关用户键盘操作的消息。如果已将消息设置为循环输出,它将继续运行,并在键盘上进行额外的发布。否则,消息将仅发布一次。
建议的解决方案与on message *
中的标志一起使用,该标志又用作过滤器,阻止消息并仅在设置了标志的情况下重复消息。
答案 1 :(得分:0)