/// <summary> /// 电机控制器1 状态反馈第3帧 功率及温度 /// ID:0x0C4403D5 /// 波特率:250Kbps /// 数据长度:8bytes /// 周期:50ms /// </summary> /// <param name="scmCanByte2"></param> /// <returns></returns> ElecOilPump_Scm_MCU1_Frame3 ElecOilPump_ByteToScmMcu1Frame3(CanStandardData scmCanByte3) { ElecOilPump_Scm_MCU1_Frame3 scmMcu1Frame3 = new ElecOilPump_Scm_MCU1_Frame3(); //byte0,1,实际电功率,KW,范围-300-300,分辨率,0.01 scmMcu1Frame3.actual_power = (short)((scmCanByte3.datas[1] * 256 + scmCanByte3.datas[0]) * 0.01 - 300); //byte2,3,实际电能消耗KWh,范围-300-300,分辨率,0.01 scmMcu1Frame3.actual_totalenergy = (short)((scmCanByte3.datas[3] * 256 + scmCanByte3.datas[2]) * 0.01 - 300); //byte4,绕组温度,范围-40-210,分辨率1,默认-40 scmMcu1Frame3.wind_temperature = (short)(scmCanByte3.datas[4] - 40); //byte5,逆变器温度,范围-40-210,分辨率1,默认-40 scmMcu1Frame3.inverter_temperature = (short)(scmCanByte3.datas[5] - 40); //byte6,控制芯片温度,范围-40-210,分辨率1,默认-40 scmMcu1Frame3.mtclChip_temperature = (short)(scmCanByte3.datas[6] - 40); return(scmMcu1Frame3); }
/// <summary> /// 接收数据并处理 /// </summary> /// <param name="canRecDatas"></param> public override ScmCanReceiveMsg TransformEcuReceiveData(CanStandardData canRecDatas) { uint rec = CanDataFilterById(canRecDatas); ScmCanReceiveMsg recMsg = new ScmCanReceiveMsg(); //若是ID被筛选,则推送筛选ID if (rec != 0xffffffff) //筛选id { return(null); } //ID未被筛选 recMsg.canId = canRecDatas.canId; recMsg.baudrate = canRecDatas.baudrate; recMsg.datas = canRecDatas.datas; switch (canRecDatas.canId) { case ElecOilPump_Scm_MCU1_Frame1.canId: //反馈第一帧,使能,方向,扭矩,转速 { ElecOilPump_Scm_MCU1_Frame1 scmMcu1 = ElecOilPump_ByteToScmMcu1Frame1(canRecDatas); //工作模式 recMsg.containFeedBkMtclMode = true; switch (scmMcu1.actual_control_mode) { case 0: recMsg.FeedBkMtclMode = Ecm_WorkMode.None; break; //初始化 case 1: recMsg.FeedBkMtclMode = Ecm_WorkMode.TorqueMode; break; //转矩环 case 2: recMsg.FeedBkMtclMode = Ecm_WorkMode.SpeedMode; break; //转速环 default: recMsg.FeedBkMtclMode = Ecm_WorkMode.None; break; } //转速 recMsg.containFeedBkMotorSpeed = true; recMsg.FeedBkMotorSpeed = (short)scmMcu1.actual_speed; //转矩 recMsg.containFeedBkMotorTorque = true; recMsg.FeedBkMotorTorque = (short)scmMcu1.actual_torque; //故障等级 recMsg.containFeedBkErrorLevel = true; recMsg.FeedBkErrorLevel = scmMcu1.error_level; //故障码 recMsg.containFeedBkErrorCode = true; recMsg.FeedBkErrorCode = new byte[1] { scmMcu1.error_code }; //故障名称 recMsg.containFeedBkErrorStr = true; recMsg.FeedBkErrorStr = ReceiveErrorTransform(scmMcu1.error_code); break; } case ElecOilPump_Scm_MCU1_Frame2.canId: //电流电压 { ElecOilPump_Scm_MCU1_Frame2 scmMcu2 = ElecOilPump_ByteToScmMcu1Frame2(canRecDatas); //实际电流 recMsg.containFeedBkDcCurrent = true; recMsg.FeedBkDcCurrent = scmMcu2.dc_current; //相电压 recMsg.containFeedBkDcVoltage = true; recMsg.FeedBkDcVoltage = scmMcu2.dc_voltage; //实际电流 recMsg.containFeedBkAcCurrent = true; recMsg.FeedBkAcCurrent = scmMcu2.ac_current; //相电压 recMsg.containFeedBkAcVoltage = true; recMsg.FeedBkAcVoltage = scmMcu2.ac_voltage; //MCU电压 recMsg.containFeedBkMcuVoltage = true; recMsg.FeedBkMcuVoltage = scmMcu2.mcu_voltage; break; } case ElecOilPump_Scm_MCU1_Frame3.canId: //功率、温度 { ElecOilPump_Scm_MCU1_Frame3 scmMcu3 = ElecOilPump_ByteToScmMcu1Frame3(canRecDatas); recMsg.containFeedBkActPower = true; recMsg.FeedBkActPower = scmMcu3.actual_power; recMsg.containFeedBkMtclInvTemp = true; recMsg.FeedBkMtclInvTemp = scmMcu3.inverter_temperature; recMsg.containFeedBkMotorWindingTemp = true; recMsg.FeedBkMotorWindingTemp = scmMcu3.wind_temperature; recMsg.containFeedBkMtclChipTemp = true; recMsg.FeedBkMtclChipTemp = scmMcu3.mtclChip_temperature; break; } case ElecOilPump_Scm_MCU1_Frame4.canId: //软件版本 { ElecOilPump_Scm_MCU1_Frame4 scmMcu4 = ElecOilPump_ByteToScmMcu1Frame4(canRecDatas); recMsg.containFeekBkMtclVersion = true; recMsg.FeekBkMtclVersion = scmMcu4.year.ToString("X2") + "." + scmMcu4.month.ToString("X2") + "." + scmMcu4.day.ToString("X2") + "." + scmMcu4.hour.ToString("X2") + "." + scmMcu4.minute.ToString("X2"); break; } default: //continue; //其他ID的数据一律不接收 break; } return(recMsg); //推送数据 }