首页 文章

CAPL阻止节点发送消息

提问于
浏览
0

我有一个连接到CAN节点的CAPL文件,它定期使用'output'函数发送消息 . 如何使用第二个CAPL文件阻止发送消息的节点(在执行节点执行的所有操作时)?

3 回答

  • 1

    您可以向节点添加输出过滤器,如下所示,以阻止消息 .

    enter image description here

  • 0

    您可以通过取消每条消息的计时器来停止所有循环消息

    示例:

    message can1.0x12 message1;
    
    msTimer tmessage1;  
    
    on timer tmessage1
    {
    output(message1); // sending message
    setTimer(tmessage1,100); //set the cyclic time as 100ms
    }
    
    
    on envVar envmessage1
    {
    if (getValue(envmessage1) == 1)
    {
    setTimer(tmessage1,100); //set and start the cyclic time as 100ms
    }
    else
    {
    cancelTimer(tmessage1); // cancel the cyclic timer 
    }
    }
    

    如果你只是在其他节点中执行“envmessage1 = 0”它将停止消息,就像所有消息都必须写入环境变量一样,然后就可以控制其他节点消息了 .

  • 0

    您可以在模拟中创建一个sysvar,它将用作模拟.can节点中的开关 .

    您只需将输出代码 condition 设置为您创建的系统变量的值 .

    if (Sysvar_SimEnabled)
    {
    output(message);
    output(message1);
    output(message3);
    }
    

    这个“Sysvar_SimEnabled”将是一个全局变量,因此可以设置为来自另一个.can CAPL节点的任何值 .

相关问题