public FormCalibrate(GasCalibration gc, SenserForm sf) { InitializeComponent(); this.gc = gc; this.parentForm = sf; for (int i = 0; i < 6; i++) { string name = "desc" + i; Label lb = this.Controls.Find(name, true).FirstOrDefault() as Label; if (i < gc.descs.Length) { lb.Text = gc.descs[i]; } else { lb.Text = String.Empty; } } time_label.Text = (gc.time / 60).ToString() + ":" + (gc.time % 60).ToString().PadLeft(2, '0'); switch (gc.type) { case "o2": calibrate_send_btn.Text = "氧气校准[21.9]"; cmd_label.Text = gc.cmd.Replace(" ", string.Empty); customValue_NumberUpDown.Visible = false; custom_gen.Visible = false; custom_calibrate_btn.Visible = false; break; case "ch4": calibrate_send_btn.Text = "ch4零点校准"; cmd_label.Text = gc.cmd.Replace(" ", string.Empty) + "0000"; customValue_NumberUpDown.Value = 50; custom_calibrate_btn.Text = "50%LEL校准"; break; case "h2s": calibrate_send_btn.Text = "h2s零点校准"; cmd_label.Text = gc.cmd.Replace(" ", string.Empty) + "0000"; customValue_NumberUpDown.Value = 50; custom_calibrate_btn.Text = "50ppm校准"; break; case "co": calibrate_send_btn.Text = "co零点校准"; cmd_label.Text = gc.cmd.Replace(" ", string.Empty) + "0000"; customValue_NumberUpDown.Value = 200; custom_calibrate_btn.Text = "200ppm校准"; break; } customValue_NumberUpDown.Enabled = false; string v = Decimal.ToInt32(customValue_NumberUpDown.Value).ToString("X2").PadLeft(4, '0'); custom_gen.Text = (gc.cmd + v).Replace(" ", string.Empty); }
/// <summary> /// /// </summary> /// <param name="formText"></param> 窗体的标题 /// <param name="gasType"></param> 气体类型 /// <param name="descriptions"></param> 描述的数组 填充label /// <param name="time"></param> 定时秒数 /// <param name="cmd"></param> 校验的命令 public void OpenCalibrateForm(GasCalibration gc) { if (!serialPort.IsOpen) { MessageBox.Show("串口未打开或连接异常", "提示"); return; } FormCalibrate fc = new FormCalibrate(gc, this); fc.Text = gc.title; fc.ShowDialog(); }
private void ch4_calibrate_Click(object sender, EventArgs e) { GasCalibration ch4 = new GasCalibration(); ch4.title = "甲烷校准"; ch4.type = "ch4"; ch4.time = 180; ch4.cmd = "ff1000 3100 0102"; string[] descs = { "1.首先保证传感器上电时间大于30分钟以。", "2.使用50%LEL的CH4标气,流速是500ml/min,通过管路将气体通到传感器表面。", "3.通气三分钟后,向模组发送零点校准指令【FF 10 00 30 00 01 02 00 00 】。", "4.观察模组输出数据是否为50%LEL 是则说明校准正常,否则说明校准失败。", "5.多次标定不成功或出现其它情况,请联系本公司。" }; ch4.descs = descs; OpenCalibrateForm(ch4); }
private void co_calibrate_Click(object sender, EventArgs e) { GasCalibration co = new GasCalibration(); co.title = "一氧化碳校准"; co.type = "co"; co.time = 210; co.cmd = "ff1000 3300 0102"; string[] descs = { "1.首先保证传感器上电时间大于5min。(长时间未使用的,需要老化24h)", "2.使用200ppm的CO,流量在100ml/min左右,通过管路将气体通到传感器表面。", "3.通气三分钟后,向模组发送校准指令 【FF 01 88 00 C8 00 00 00 AF】。", "4.观察模组输出数据是否为200ppm, 是则说明校准正常,否则说明校准失败。", "5.在200ppm环境下发送校准命令时,模组输出的模拟电压需在0.8V~1.3V之间,", " 若超出此范围,则不能校准成功,需要返厂校准。" }; co.descs = descs; OpenCalibrateForm(co); }
private void h2s_calibrate_Click(object sender, EventArgs e) { GasCalibration h2s = new GasCalibration(); h2s.title = "硫化氢校准"; h2s.type = "h2s"; h2s.time = 180; h2s.cmd = "ff1000 3200 0102"; string[] descs = { "1.首先保证传感器上电时间大于5min。", "2.使用50ppm的H2S,流量在100ml/min左右,通过管路将气体通到传感器表面。", "3.通气三分钟后,向模组发送校准指令 【FF 10 00 30 00 01 02 00 01 】。", "4.观察模组输出数据是否为50ppm 是则说明校准正常,否则说明校准失败。", "5.发送校准命令时,模组输出的模拟电压需在0.8V~1.8V之间,", " 若超出此范围,则不能校准成功,需要返厂校准。" }; h2s.descs = descs; OpenCalibrateForm(h2s); }
private void o2_calibrate_Click(object sender, EventArgs e) { GasCalibration o2 = new GasCalibration(); o2.title = "氧气校准"; o2.type = "o2"; o2.time = 210; o2.cmd = "ff 10 00 30 00 01 02 00 03";//校准O2: string[] descs = { "1.模组上电老化24小时,如果已老化,可直接进行步骤2", "2.老化完成后,断电,重新上电,开始计时三分钟半", "3.通气三分半钟后,向模组发送校准指令【 ff 10 00 30 00 01 02 00 03】", "4.串口返回命令或当前浓度值,标定成功", "5.如标定不成功,等待5秒后重新发送标定命令。", "6.步骤5多次不成功,请尝试重新断电上电,重复标定步骤。", "6.多次标定不成功或出现其它情况,请联系本公司。" }; o2.descs = descs; OpenCalibrateForm(o2); }