全局变量法

/*@!Encoding:936*/
includes
{
  
}
//报文时序监控与管理
variables
{
  byte Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq = 0;
}

//三帧触发逻辑
on signal_update CdcEcasMaintenanceModeReq
{
  if(@sysvar::SignalTiming::ARun::`Start ==1)
  {
      if(Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq >= 2)
      {
        $CdcEcasMaintenanceModeReq = 0x00;
        Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq=0; 
        write("Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq 2 %d",Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq);
      }
      if(this != 0x0)
      {
        Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq++;
        write("Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq 1 %d",Counter_SendFrame_GW_2F4_CdcEcasMaintenanceModeReq);
      }    
  }
}

不需要全局变量法

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

variables
{

}

//三帧触发逻辑
on signal_update CdcEcasMaintenanceModeReq
{
  int i;
  if(@sysvar::SignalTiming::ARun::`Start ==1)
  { 
    if(getSignal(CdcEcasMaintenanceModeReq)!= DBLookup(CdcEcasMaintenanceModeReq).DefaultValue)
    {
      i++;
      if(i==3)
      {
        setsignal(CdcEcasMaintenanceModeReq,DBLookup(CdcEcasMaintenanceModeReq).DefaultValue);
        i = 0;
      }
    }
  }
}

Logo

获取更多汽车电子技术干货

更多推荐