1

我想知道是否可以创建一个 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.
}

如果不清楚,我可以更好地解释我的要求:)

提前谢谢你^^干杯

4

2 回答 2

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 *,该标志又用作过滤器,阻止消息并仅在设置标志时重复它。

于 2019-03-06T15:02:53.710 回答
0

您可以将重播块添加到总线,并在配置类型中指定启动/停止键。指定的信号激活/停用可以在您编写时保持不变。

重播块配置

于 2019-11-27T11:00:01.320 回答