/// <summary> /// 电机控制器1 状态反馈第4帧 版本 /// ID:0x0C4503D5 /// 波特率:250Kbps /// 数据长度:8bytes /// 周期:50ms /// </summary> /// <param name="scmCanByte4"></param> /// <returns></returns> ElecOilPump_Scm_MCU1_Frame4 ElecOilPump_ByteToScmMcu1Frame4(CanStandardData scmCanByte4) { ElecOilPump_Scm_MCU1_Frame4 scmMcu1Frame4 = new ElecOilPump_Scm_MCU1_Frame4(); scmMcu1Frame4.year = scmCanByte4.datas[0]; scmMcu1Frame4.month = scmCanByte4.datas[1]; scmMcu1Frame4.day = scmCanByte4.datas[2]; scmMcu1Frame4.hour = scmCanByte4.datas[3]; scmMcu1Frame4.minute = scmCanByte4.datas[4]; return(scmMcu1Frame4); }
/// <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); //推送数据 }