private string GetCommParamData()
 {
     try
     {
         //光源信息字 1字节
         string meamtObjTypeB = Convert.ToString(meamtObjType.SelectedIndex, 2);
         string lPTypeB       = Convert.ToString(lPType.SelectedIndex, 2);
         string pixelB        = Convert.ToString(pixel.SelectedIndex, 2);
         if (pixelB.Length == 1)
         {
             pixelB = "0" + pixelB;
         }
         string sensorTypeB = Convert.ToString(sensorType.SelectedIndex, 2);
         string lSTypeB     = Convert.ToString(lSType.SelectedIndex, 2);
         string lightSource = Convert.ToByte(lSTypeB + sensorTypeB + pixelB + lPTypeB + meamtObjTypeB, 2).ToString("x2").ToUpper();
         //光源控制电压 4字节
         byte[] controlVol = BitConverter.GetBytes(Convert.ToSingle(lSControlVol.Text));
         Array.Reverse(controlVol);
         //应用模式信息字 1字节
         string appModeInfoB = Convert.ToString(dualLPAppModeInfo.SelectedIndex, 2);
         string appModeInfo  = Convert.ToByte(appModeInfoB, 2).ToString("x2").ToUpper();
         //调零次数 2字节
         byte[] calTimes = BitConverter.GetBytes(Convert.ToUInt16(zeroConcCalTimes.Text));
         Array.Reverse(calTimes);
         return(lightSource + ByteStrUtil.ByteToHexStr(controlVol) + appModeInfo + ByteStrUtil.ByteToHexStr(calTimes));
     }
     catch
     {
         MessageBox.Show("请检查输入参数!");
         return("");
     }
 }
        private string GetCaliData()
        {
            try
            {
                //气体1,2,3,4判据数据 4*2*4字节
                byte[] gas_1_lowCC = BitConverter.GetBytes(Convert.ToSingle(gas_1_lowRangCC.Text));
                Array.Reverse(gas_1_lowCC);
                byte[] gas_1_highCC = BitConverter.GetBytes(Convert.ToSingle(gas_1_highRangCC.Text));
                Array.Reverse(gas_1_highCC);

                byte[] gas_2_lowCC = BitConverter.GetBytes(Convert.ToSingle(gas_2_lowRangCC.Text));
                Array.Reverse(gas_2_lowCC);
                byte[] gas_2_highCC = BitConverter.GetBytes(Convert.ToSingle(gas_2_highRangCC.Text));
                Array.Reverse(gas_2_highCC);

                byte[] gas_3_lowCC = BitConverter.GetBytes(Convert.ToSingle(gas_3_lowRangCC.Text));
                Array.Reverse(gas_3_lowCC);
                byte[] gas_3_highCC = BitConverter.GetBytes(Convert.ToSingle(gas_3_highRangCC.Text));
                Array.Reverse(gas_3_highCC);

                byte[] gas_4_lowCC = BitConverter.GetBytes(Convert.ToSingle(gas_4_lowRangCC.Text));
                Array.Reverse(gas_4_lowCC);
                byte[] gas_4_highCC = BitConverter.GetBytes(Convert.ToSingle(gas_4_highRangCC.Text));
                Array.Reverse(gas_4_highCC);

                return(cc_lPInfo.SelectedIndex.ToString("x2") + "0F" + ByteStrUtil.ByteToHexStr(gas_1_lowCC) + ByteStrUtil.ByteToHexStr(gas_1_highCC) + ByteStrUtil.ByteToHexStr(gas_2_lowCC) + ByteStrUtil.ByteToHexStr(gas_2_highCC) + ByteStrUtil.ByteToHexStr(gas_3_lowCC) + ByteStrUtil.ByteToHexStr(gas_3_highCC) + ByteStrUtil.ByteToHexStr(gas_4_lowCC) + ByteStrUtil.ByteToHexStr(gas_4_highCC));
            }
            catch
            {
                MessageBox.Show("请检查输入参数!");
                return("");
            }
        }
Esempio n. 3
0
        private void Measure()
        {
            //光谱采集与算法生成
            SpecOperatorImpl.Instance.SendSpecCmn(lightPath, specType);
            //浓度测量
            string data = lightPath + ByteStrUtil.ByteToHexStr(tempValues) + ByteStrUtil.ByteToHexStr(pressValues);

            SuperSerialPort.Instance.Send(new Command {
                Cmn = "29", ExpandCmn = "55", Data = data
            }, true);
        }
 private string GetRangeSwitchData()
 {
     try
     {
         //气体1,2,3,4判据数据 4*4字节
         byte[] gas_1_crit = BitConverter.GetBytes(Convert.ToSingle(gas_1_critData.Text));
         Array.Reverse(gas_1_crit);
         byte[] gas_2_crit = BitConverter.GetBytes(Convert.ToSingle(gas_2_critData.Text));
         Array.Reverse(gas_2_crit);
         byte[] gas_3_crit = BitConverter.GetBytes(Convert.ToSingle(gas_3_critData.Text));
         Array.Reverse(gas_3_crit);
         byte[] gas_4_crit = BitConverter.GetBytes(Convert.ToSingle(gas_4_critData.Text));
         Array.Reverse(gas_4_crit);
         return(rs_lpInfo.SelectedIndex.ToString("x2") + "0F" + ByteStrUtil.ByteToHexStr(gas_1_crit) + ByteStrUtil.ByteToHexStr(gas_2_crit) + ByteStrUtil.ByteToHexStr(gas_3_crit) + ByteStrUtil.ByteToHexStr(gas_4_crit));
     }
     catch
     {
         MessageBox.Show("请检查输入参数!");
         return("");
     }
 }
 private string GetLPParamData()
 {
     try
     {
         //光路信息 1字节
         string lPInfo = "0" + alpp_lPInfo.SelectedIndex.ToString();
         //组分信息 1字节
         string compntInfoB = Convert.ToString(compntInfo.SelectedIndex, 2);
         string comptInfo   = Convert.ToByte(compntInfoB, 2).ToString("x2").ToUpper();
         //量程信息字一 1字节
         string range_1    = Convert.ToString(gas_liquid_1_range.SelectedIndex, 2);
         string range_2    = Convert.ToString(gas_liquid_2_range.SelectedIndex, 2);
         string rangeInfo1 = Convert.ToByte("00" + range_2 + "00" + range_1, 2).ToString("x2").ToUpper();
         //量程信息字二 1字节
         string range_3    = Convert.ToString(gas_liquid_3_range.SelectedIndex, 2);
         string range_4    = Convert.ToString(gas_liquid_4_range.SelectedIndex, 2);
         string rangeInfo2 = Convert.ToByte("00" + range_4 + "00" + range_3, 2).ToString("x2").ToUpper();
         //光谱平均次数,浓度滑动平均次数,零点平均次数,标定平均次数,打灯次数 各1字节
         string sATs  = Convert.ToByte(specATs.Text).ToString("x2");
         string coATs = Convert.ToByte(concSlidATs.Text).ToString("x2");
         string zATs  = Convert.ToByte(zeroATs.Text).ToString("x2");
         string caATs = Convert.ToByte(caliATs.Text).ToString("x2");
         string lTs   = Convert.ToByte(lightTimes.Text).ToString("x2");
         //积分时间,采样时间间隔,光路切换时间间隔 各2字节
         byte[] integrTimes = BitConverter.GetBytes(Convert.ToUInt16(integTime.Text));
         Array.Reverse(integrTimes);
         byte[] samplInter = BitConverter.GetBytes(Convert.ToUInt16(samplInterval.Text));
         Array.Reverse(samplInter);
         byte[] lPSwitchInter = BitConverter.GetBytes(Convert.ToUInt16(lPSwitchInterval.Text));
         Array.Reverse(lPSwitchInter);
         return(lPInfo + "0F" + comptInfo + rangeInfo1 + rangeInfo2 + sATs + coATs + zATs + caATs + lTs + ByteStrUtil.ByteToHexStr(integrTimes) + ByteStrUtil.ByteToHexStr(samplInter) + ByteStrUtil.ByteToHexStr(lPSwitchInter));
     }
     catch
     {
         MessageBox.Show("请检查输入参数!");
         return("");
     }
 }