if (messageId == 0x02001040) { // 大小端的值不一样,我直接组成的包是这样的 byte[] Bytetmp = new byte[4]; uint tmp_Uint32; ushort tmp_Uint16; int year; int month; int day; int hour; int minute; int second; float V48_V; float V48_I; uint masterSta_Leakage1; // 电能板1漏电流状态 uint masterSta_Leakage2; // 电能板2漏电流状态 uint masterSta_Leakage3; // 电能板3漏电流状态 uint masterSta_Leakage4; // 电能板4漏电流状态 uint masterSta_Temp1; // 主控内部温度1状态 uint masterSta_Temp2; // 主控内部温度2状态 uint masterSta_Humi1; // 主控内部湿度1状态 uint masterSta_Humi2; // 主控内部湿度2状态 uint masterSta_LeakWater1; // 主控内部漏水1状态 uint masterSta_LeakWater2; // 主控内部漏水2状态 uint masterSta_InsidePress1; // 主控内部腔体压力1状态 uint masterSta_InsidePress2; // 主控内部腔体压力2状态 uint downTimeSeqSta; // 时序下发状态 uint deviceDate_gcms; // 色质联用仪 uint deviceDate_serialPort1; // 备用串口1 uint deviceDate_serialPort2; // 备用串口2 uint deviceDate_osc; // 光纤,目前接的是基因测序仪 uint deviceDate_adcp; // ADCP uint deviceDate_ctdo; // CTDO uint deviceDate_vedio1; // 摄像1 uint deviceDate_ch4; // 甲烷 uint deviceDate_icl; // ICL uint deviceDate_gc; // 色谱仪 uint deviceDate_co2; // 二氧化碳仪 uint deviceDate_raman; // 显微拉曼仪 uint deviceDate_ms; // 质谱仪 uint deviceDate_vedio2; // 摄像2 uint deviceDate_net; // 备用网口 uint deviceDate_acoustic; // 声学定位 uint breakdown_gcms; // 色质联用仪 uint breakdown_serialPort1; // 备用串口1 uint breakdown_serialPort2; // 备用串口2 uint breakdown_osc; // 光纤,目前接的是基因测序仪 uint breakdown_adcp; // ADCP uint breakdown_ctdo; // CTDO uint breakdown_vedio1; // 摄像1 uint breakdown_ch4; // 甲烷 uint breakdown_icl; // ICL uint breakdown_gc; // 色谱仪 uint breakdown_co2; // 二氧化碳仪 uint breakdown_raman; // 显微拉曼仪 uint breakdown_ms; // 质谱仪 uint breakdown_vedio2; // 摄像2 uint breakdown_net; // 备用网口 uint breakdown_acoustic; // 声学定位 /* 色谱 */ uint cgdeviceTemp; // 设备温度状态 uint cgdeviceHumi; // 设备湿度状态 uint cgdevicePress; // 设备压力状态 uint cgdeviceInsulatio; // 设备故障状态 uint cgC2_concentration; // C2浓度 uint cgC3_concentration; // C3浓度 uint cgC4_concentration; // C4浓度 /* 质谱 */ uint msdeviceTemp; // 设备温度状态 uint msdeviceHumi; // 设备湿度状态 uint msdevicePress; // 设备压力状态 uint msdeviceInsulation; // 设备故障状态 uint msCH4_concentration; // 甲烷 uint msH2O_concentration; // 水 uint msN2_concentration; // N2浓度 uint msO2_concentration; // O2浓度 uint msAR_concentration; // N2浓度 uint msCO2_concentration; // CO2浓度 /* 色质联用仪 */ uint gcmsdeviceTemp; // 设备温度状态 uint gcmsdeviceHumi; // 设备湿度状态 uint gcmsdevicePress; // 设备压力状态 uint gcmsdeviceInsulation; // 设备故障状态 uint gcmsC2_concentration; // C2浓度 uint gcmsC3_concentration; // C3浓度 uint gcmsC4_concentration; // C4浓度 uint gcmsC5_concentration; // C5浓度 uint gcmsC6_concentration; // C6浓度 uint gcmsC7_concentration; // C7浓度 uint gcmsC8_concentration; // C8浓度 uint gcmsC9_concentration; // C9浓度 /* 甲烷 */ uint ch4deviceTemp; // 设备温度状态 uint ch4deviceHumi; // 设备湿度状态 uint ch4devicePress; // 设备压力状态 uint ch4deviceInsulation; // 设备故障状态 float ch4C12_concentration; float ch4Abundance; float ch4H2O_concentrations; /* 二氧化碳 */ uint co2deviceTemp; // 设备温度状态 uint co2deviceHumi; // 设备湿度状态 uint co2devicePress; // 设备压力状态 uint co2deviceInsulation; // 设备故障状态 float co2LuminousIntensity; // 光强 float co2LaserTemperature; // 激光温度 float C12_concentration; // C12浓度 float co2Abundance; // 丰度 /* 拉曼 */ uint ramandeviceTemp; // 设备温度状态 uint ramandeviceHumi; // 设备湿度状态 uint ramandevicePress; // 设备压力状态 uint ramandeviceInsulation; // 设备故障状态 float ramanPM_num; // 颗粒物序号 float ramanPM_X; // 颗粒物横坐标 float ramanPM_Y; // 颗粒物纵坐标 float ramanPM_TYPE;// 颗粒物类型 float ramanPM_S; // 颗粒物面积 /* 基因测序仪 */ uint genedeviceTemp; // 设备温度状态 uint genedeviceHumi; // 设备湿度状态 uint genedevicePress; // 设备压力状态 uint genedeviceInsulation; // 设备故障状态 float geneReagentTemp; // 试剂温度 float geneSampleConcentration; // 样本浓度 byte geneworkflow; // 工作流程 /* 时间 */ year = recvBuffer[9] + 2000; month = recvBuffer[10]; day = recvBuffer[11]; hour = recvBuffer[12]; minute = recvBuffer[13]; second = recvBuffer[14]; /* 电压电流 */ V48_V = BitConverter.ToSingle(recvBuffer, 21); V48_I = BitConverter.ToSingle(recvBuffer, 25); /* 主控状态 */ Bytetmp[0] = recvBuffer[29]; Bytetmp[1] = recvBuffer[30]; Bytetmp[2] = recvBuffer[31]; Bytetmp[3] = recvBuffer[32]; tmp_Uint32 = BitConverter.ToUInt32(Bytetmp, 0); masterSta_Leakage1 = tmp_Uint32 & 0x3; masterSta_Leakage2 = (tmp_Uint32 >> 2) & 0x3; masterSta_Leakage3 = (tmp_Uint32 >> 4) & 0x3; masterSta_Leakage4 = (tmp_Uint32 >> 6) & 0x3; masterSta_Temp1 = (tmp_Uint32 >> 8) & 0x3; masterSta_Temp2 = (tmp_Uint32 >> 10) & 0x3; masterSta_Humi1 = (tmp_Uint32 >> 12) & 0x3; masterSta_Humi2 = (tmp_Uint32 >> 14) & 0x3; masterSta_LeakWater1 = (tmp_Uint32 >> 16) & 0x3; masterSta_LeakWater2 = (tmp_Uint32 >> 18) & 0x3; masterSta_InsidePress1 = (tmp_Uint32 >> 20) & 0x3; masterSta_InsidePress2 = (tmp_Uint32 >> 22) & 0x3; /* 时序下配状态 */ downTimeSeqSta = recvBuffer[33]; /* 设备输出状态 */ Bytetmp[0] = recvBuffer[34]; Bytetmp[1] = recvBuffer[35]; Bytetmp[2] = recvBuffer[36]; Bytetmp[3] = recvBuffer[37]; tmp_Uint32 = BitConverter.ToUInt32(Bytetmp, 0); deviceDate_gcms = tmp_Uint32 & 0x1; deviceDate_serialPort1 = (tmp_Uint32 >> 1) & 0x1; deviceDate_serialPort2 = (tmp_Uint32 >> 2) & 0x1; deviceDate_osc = (tmp_Uint32 >> 3) & 0x1; deviceDate_adcp = (tmp_Uint32 >> 4) & 0x1; deviceDate_ctdo = (tmp_Uint32 >> 5) & 0x1; deviceDate_vedio1 = (tmp_Uint32 >> 6) & 0x1; deviceDate_ch4 = (tmp_Uint32 >> 7) & 0x1; deviceDate_icl = (tmp_Uint32 >> 8) & 0x1; deviceDate_gc = (tmp_Uint32 >> 9) & 0x1; deviceDate_co2 = (tmp_Uint32 >> 10) & 0x1; deviceDate_raman = (tmp_Uint32 >> 11) & 0x1; deviceDate_ms = (tmp_Uint32 >> 12) & 0x1; deviceDate_vedio2 = (tmp_Uint32 >> 13) & 0x1; deviceDate_net = (tmp_Uint32 >> 14) & 0x1; deviceDate_acoustic = (tmp_Uint32 >> 15) & 0x1; /* 设备故障信息 */ Bytetmp[0] = recvBuffer[38]; Bytetmp[1] = recvBuffer[39]; Bytetmp[2] = recvBuffer[40]; Bytetmp[3] = recvBuffer[41]; tmp_Uint32 = BitConverter.ToUInt32(Bytetmp, 0); breakdown_gcms = tmp_Uint32 & 0x1; breakdown_serialPort1 = (tmp_Uint32 >> 1) & 0x1; breakdown_serialPort2 = (tmp_Uint32 >> 2) & 0x1; breakdown_osc = (tmp_Uint32 >> 3) & 0x1; breakdown_adcp = (tmp_Uint32 >> 4) & 0x1; breakdown_ctdo = (tmp_Uint32 >> 5) & 0x1; breakdown_vedio1 = (tmp_Uint32 >> 6) & 0x1; breakdown_ch4 = (tmp_Uint32 >> 7) & 0x1; breakdown_icl = (tmp_Uint32 >> 8) & 0x1; breakdown_gc = (tmp_Uint32 >> 9) & 0x1; breakdown_co2 = (tmp_Uint32 >> 10) & 0x1; breakdown_raman = (tmp_Uint32 >> 11) & 0x1; breakdown_ms = (tmp_Uint32 >> 12) & 0x1; breakdown_vedio2 = (tmp_Uint32 >> 13) & 0x1; breakdown_net = (tmp_Uint32 >> 14) & 0x1; breakdown_acoustic = (tmp_Uint32 >> 15) & 0x1; /* 色谱 */ Bytetmp[0] = recvBuffer[48]; Bytetmp[1] = recvBuffer[49]; tmp_Uint16 = BitConverter.ToUInt16(Bytetmp, 0); cgdeviceTemp = (uint)(tmp_Uint16 & 0x3); cgdeviceHumi = (uint)((tmp_Uint16 >> 2) & 0x3); cgdevicePress = (uint)((tmp_Uint16 >> 4) & 0x3); cgdeviceInsulatio = (uint)((tmp_Uint16 >> 6) & 0x3); Bytetmp[0] = recvBuffer[50]; Bytetmp[1] = recvBuffer[51]; cgC2_concentration = BitConverter.ToUInt16(Bytetmp, 0);// C2浓度 Bytetmp[0] = recvBuffer[52]; Bytetmp[1] = recvBuffer[53]; cgC3_concentration = BitConverter.ToUInt16(Bytetmp, 0); ; // C3浓度 Bytetmp[0] = recvBuffer[54]; Bytetmp[1] = recvBuffer[55]; cgC4_concentration = BitConverter.ToUInt16(Bytetmp, 0); ; // C4浓度 /* 质谱 */ Bytetmp[0] = recvBuffer[62]; Bytetmp[1] = recvBuffer[63]; tmp_Uint16 = BitConverter.ToUInt16(Bytetmp, 0); msdeviceTemp = (uint)(tmp_Uint16 & 0x3); msdeviceHumi = (uint)((tmp_Uint16 >> 2) & 0x3); msdevicePress = (uint)((tmp_Uint16 >> 4) & 0x3); msdeviceInsulation = (uint)((tmp_Uint16 >> 6) & 0x3); Bytetmp[0] = recvBuffer[64]; Bytetmp[1] = recvBuffer[65]; msCH4_concentration = BitConverter.ToUInt16(Bytetmp, 0);// 甲烷 Bytetmp[0] = recvBuffer[66]; Bytetmp[1] = recvBuffer[67]; msH2O_concentration = BitConverter.ToUInt16(Bytetmp, 0); ; // 水 Bytetmp[0] = recvBuffer[68]; Bytetmp[1] = recvBuffer[69]; msN2_concentration = BitConverter.ToUInt16(Bytetmp, 0); ; // 氮气 Bytetmp[0] = recvBuffer[70]; Bytetmp[1] = recvBuffer[71]; msO2_concentration = BitConverter.ToUInt16(Bytetmp, 0);// 氧气 Bytetmp[0] = recvBuffer[72]; Bytetmp[1] = recvBuffer[73]; msAR_concentration = BitConverter.ToUInt16(Bytetmp, 0); ; // 氩气 Bytetmp[0] = recvBuffer[74]; Bytetmp[1] = recvBuffer[75]; msCO2_concentration = BitConverter.ToUInt16(Bytetmp, 0); ; // 二氧化碳 /* 色质联用仪 */ Bytetmp[0] = recvBuffer[82]; Bytetmp[1] = recvBuffer[83]; tmp_Uint16 = BitConverter.ToUInt16(Bytetmp, 0); gcmsdeviceTemp = (uint)(tmp_Uint16 & 0x3); gcmsdeviceHumi = (uint)((tmp_Uint16 >> 2) & 0x3); gcmsdevicePress = (uint)((tmp_Uint16 >> 4) & 0x3); gcmsdeviceInsulation = (uint)((tmp_Uint16 >> 6) & 0x3); Bytetmp[0] = recvBuffer[84]; Bytetmp[1] = recvBuffer[85]; gcmsC2_concentration = BitConverter.ToUInt16(Bytetmp, 0); Bytetmp[0] = recvBuffer[86]; Bytetmp[1] = recvBuffer[87]; gcmsC3_concentration = BitConverter.ToUInt16(Bytetmp, 0); Bytetmp[0] = recvBuffer[88]; Bytetmp[1] = recvBuffer[89]; gcmsC4_concentration = BitConverter.ToUInt16(Bytetmp, 0); Bytetmp[0] = recvBuffer[90]; Bytetmp[1] = recvBuffer[91]; gcmsC5_concentration = BitConverter.ToUInt16(Bytetmp, 0); Bytetmp[0] = recvBuffer[92]; Bytetmp[1] = recvBuffer[93]; gcmsC6_concentration = BitConverter.ToUInt16(Bytetmp, 0); Bytetmp[0] = recvBuffer[94]; Bytetmp[1] = recvBuffer[95]; gcmsC7_concentration = BitConverter.ToUInt16(Bytetmp, 0); Bytetmp[0] = recvBuffer[96]; Bytetmp[1] = recvBuffer[97]; gcmsC8_concentration = BitConverter.ToUInt16(Bytetmp, 0); Bytetmp[0] = recvBuffer[98]; Bytetmp[1] = recvBuffer[99]; gcmsC9_concentration = BitConverter.ToUInt16(Bytetmp, 0); /* 甲烷 */ Bytetmp[0] = recvBuffer[106]; Bytetmp[1] = recvBuffer[107]; tmp_Uint16 = BitConverter.ToUInt16(Bytetmp, 0); ch4deviceTemp = (uint)(tmp_Uint16 & 0x3); ch4deviceHumi = (uint)((tmp_Uint16 >> 2) & 0x3); ch4devicePress = (uint)((tmp_Uint16 >> 4) & 0x3); ch4deviceInsulation = (uint)((tmp_Uint16 >> 6) & 0x3); ch4C12_concentration = BitConverter.ToSingle(recvBuffer, 108); ch4Abundance = BitConverter.ToSingle(recvBuffer, 112); ch4H2O_concentrations = BitConverter.ToSingle(recvBuffer, 116); /* 二氧化碳 */ Bytetmp[0] = recvBuffer[126]; Bytetmp[1] = recvBuffer[127]; tmp_Uint16 = BitConverter.ToUInt16(Bytetmp, 0); co2deviceTemp = (uint)(tmp_Uint16 & 0x3); co2deviceHumi = (uint)((tmp_Uint16 >> 2) & 0x3); co2devicePress = (uint)((tmp_Uint16 >> 4) & 0x3); co2deviceInsulation = (uint)((tmp_Uint16 >> 6) & 0x3); co2LuminousIntensity = BitConverter.ToSingle(recvBuffer, 128); // 光强 co2LaserTemperature = BitConverter.ToSingle(recvBuffer, 132); // 激光温度 C12_concentration = BitConverter.ToSingle(recvBuffer, 136); // C12浓度 co2Abundance = BitConverter.ToSingle(recvBuffer, 140); // 丰度 /* 颗粒物分析物 */ Bytetmp[0] = recvBuffer[150]; Bytetmp[1] = recvBuffer[151]; tmp_Uint16 = BitConverter.ToUInt16(Bytetmp, 0); ramandeviceTemp = (uint)(tmp_Uint16 & 0x3); ramandeviceHumi = (uint)((tmp_Uint16 >> 2) & 0x3); ramandevicePress = (uint)((tmp_Uint16 >> 4) & 0x3); ramandeviceInsulation = (uint)((tmp_Uint16 >> 6) & 0x3); ramanPM_num = BitConverter.ToSingle(recvBuffer, 152); // 颗粒物序号 ramanPM_X = BitConverter.ToSingle(recvBuffer, 156); // 颗粒物横坐标 ramanPM_Y = BitConverter.ToSingle(recvBuffer, 160); // 颗粒物纵坐标 ramanPM_TYPE = BitConverter.ToSingle(recvBuffer, 164); // 颗粒物类型 ramanPM_S = BitConverter.ToSingle(recvBuffer, 168); // 颗粒物面积 /* 基因测序仪 */ Bytetmp[0] = recvBuffer[178]; Bytetmp[1] = recvBuffer[179]; tmp_Uint16 = BitConverter.ToUInt16(Bytetmp, 0); genedeviceTemp = (uint)(tmp_Uint16 & 0x3); genedeviceHumi = (uint)((tmp_Uint16 >> 2) & 0x3); genedevicePress = (uint)((tmp_Uint16 >> 4) & 0x3); genedeviceInsulation = (uint)((tmp_Uint16 >> 6) & 0x3); geneReagentTemp = BitConverter.ToSingle(recvBuffer, 180); // 试剂温度 geneSampleConcentration = BitConverter.ToSingle(recvBuffer, 184); // 样本浓度 geneworkflow = recvBuffer[188]; // 工作流程 }