CANoe 使用Programming Node分析数据

文章描述了一种在CANoe的offline模式下,通过ProgrammingNode和CAPL编程语言处理和分析汽车诊断数据的方法。它涉及到里程计、发动机状态、燃油消耗等参数的计算和更新,并利用定时器进行周期性打印和记录。
摘要由CSDN通过智能技术生成

 经常需要使用CANoe分析离线数据,offline 模式下可以使用Programming Node进行数据分析,Programming Node关联一个CAPL脚本,可以使用CAPL编程进行各种处理。

 

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

variables
{
  long  ICM_TotalOdometer;
  long  ICM_VehRunningTime;
  long  ICM_FuelAverageConsumed;
  long  ODOCount;
  long  TripA;
  int EMS_EngSt;
  
  long  wheelPulseTotal;
  long  wheelPulse;
  long pre_wheel_pulse;
  long odo_pulse_inc;
  
  long  fuelPulseTotal;
  long  fuelPulse;
  long pre_fuel_pulse;
  long fuel_pulse_inc;
  
  long ACU_Time_Year;
  long ACU_Time_Month;
  long ACU_Time_Day;
  long ACU_Time_Hour;
  long ACU_Time_Min;
  long ACU_Time_Sec;
  
  msTimer printer;
}


on preStart
{
  //NMStartOffline();
  //setTimer(printer, 1000);
}

on Start
{
  ICM_TotalOdometer = 0;
  ODOCount = 0;
  
  EMS_EngSt = 0;
  
  wheelPulseTotal = 0;
  wheelPulse = 0;
  pre_wheel_pulse = 0;
  odo_pulse_inc = 0;
  
  fuelPulseTotal = 0;
  fuelPulse = 0;
  pre_fuel_pulse = 0;
  fuel_pulse_inc = 0;
  
  // setTimer(printer, 10000);
  setTimerCyclic(printer, 10000);
}

on preStop
{
  cancelTimer(printer);
}

on message GW_BCS_5_B
{
  if (this.BCS_RLWheelSpdEdgesSumVD == 1)
  {
    if(this.BCS_RLWheelSpdEdgesSum >= pre_wheel_pulse){
      odo_pulse_inc = this.BCS_RLWheelSpdEdgesSum - pre_wheel_pulse;
    }
    else{
      odo_pulse_inc = 4096 - pre_wheel_pulse + this.BCS_RLWheelSpdEdgesSum;
    }
    pre_wheel_pulse = this.BCS_RLWheelSpdEdgesSum;
    wheelPulseTotal += odo_pulse_inc;
    wheelPulse += odo_pulse_inc;
    
    ODOCount = wheelPulseTotal/43280;
    TripA = wheelPulse/43280;
  }
}

on message GW_EMS_1_B
{
  if (this.EMS_EngSt == 1)
  {
    EMS_EngSt = 1;
    
    if(this.EMS_FuelPulse >= pre_fuel_pulse){
      fuel_pulse_inc = this.EMS_FuelPulse - pre_fuel_pulse;
    }
    else{
      fuel_pulse_inc = 65536 - pre_fuel_pulse + this.EMS_FuelPulse;
    }
    pre_fuel_pulse = this.EMS_FuelPulse;
    fuelPulseTotal += fuel_pulse_inc;
    fuelPulse += fuel_pulse_inc;
  }
  else
  {
    if (EMS_EngSt == 1)
    {
      TripA = 0;
    
      wheelPulse = 0;
      //pre_wheel_pulse = 0;
      odo_pulse_inc = 0;
      
      fuelPulse = 0;
      //pre_fuel_pulse = 0;
      fuel_pulse_inc = 0;
      
      EMS_EngSt = 0;
    }
  }
}

on message ACU_10_B
{
    ACU_Time_Year = this.ACU_Time_Year;
    ACU_Time_Month = this.ACU_Time_Month;
    ACU_Time_Day = this.ACU_Time_Day;
    ACU_Time_Hour = this.ACU_Time_Hour;
    ACU_Time_Min = this.ACU_Time_Min;
    ACU_Time_Sec = this.ACU_Time_Sec;
}

on message ICM_1_B
{
  ICM_TotalOdometer = this.ICM_TotalOdometer;
}

on message ICM_2_B
{
  ICM_FuelAverageConsumed = this.ICM_FuelAverageConsumed;
}

on message ICM_3_B
{
  ICM_VehRunningTime = this.ICM_VehRunningTime;
}

on timer printer
{
  write("20%d/%d/%d %d:%02d:%02d  "
  "EMS_EngSt:%d, ICM_TotalOdometer: %ld, ODOCount: %ld, TripA: %ld, "
  "fuelPulse: %ld "
  "ICM_FuelAverageConsumed:%d, ICM_VehRunningTime: %02ld:%02d:00",
  ACU_Time_Year,ACU_Time_Month,ACU_Time_Day,ACU_Time_Hour,ACU_Time_Min,ACU_Time_Sec,
  EMS_EngSt, ICM_TotalOdometer, ODOCount, TripA,
  fuelPulse,
  ICM_FuelAverageConsumed, ICM_VehRunningTime/60, ICM_VehRunningTime%60);
  
  // setTimer(printer, 10000);
}

log打印如下,也可以export到文本使用其他编辑器进行分析

 

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值