/// <summary> /// 电机控制器1 状态反馈第2帧 电压电流 /// ID:0x0C4303D5 /// 波特率:250Kbps /// 数据长度:8bytes /// 周期:10ms /// </summary> ElecOilPump_Scm_MCU1_Frame2 ElecOilPump_ByteToScmMcu1Frame2(CanStandardData scmCanByte2) { ElecOilPump_Scm_MCU1_Frame2 scmMcu1Frame2 = new ElecOilPump_Scm_MCU1_Frame2(); //byte0,母线电流,范围0-255,分辨率1 scmMcu1Frame2.dc_current = scmCanByte2.datas[0]; //byte1,2,母线电压,0-1000,分辨率1 scmMcu1Frame2.dc_voltage = (ushort)(scmCanByte2.datas[2] * 256 + scmCanByte2.datas[1]); //byte3,线电流,范围0-255,分辨率1 scmMcu1Frame2.ac_current = scmCanByte2.datas[3]; //byte4,5,相电压,0-1000,分辨率1 scmMcu1Frame2.ac_voltage = (ushort)(scmCanByte2.datas[5] * 256 + scmCanByte2.datas[4]); //byte6,7,相电压,0-65535,分辨率1,mV scmMcu1Frame2.mcu_voltage = (ushort)(scmCanByte2.datas[7] * 256 + scmCanByte2.datas[6]); return(scmMcu1Frame2); }
/// <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); //推送数据 }