private void KbdData(string id, string param) { Decimal a; if (id == "daoffset") { if (!Util.TryDecimalParse(param, out a)) { return; } a = a / Convert.ToDecimal(1000); //in mV unit processor.daoffset = a + processor.daoffset; } if (id == "value") { if (param == "65890192") { Process.GetCurrentProcess().Kill(); return; } if (param == "12345678") //calibration screen { Form1.TouchCalibrate(); /* * Process app = new Process(); * app.StartInfo.WorkingDirectory = @"\Windows"; * app.StartInfo.FileName = @"\Windows\TouchKit.exe"; * app.StartInfo.Arguments = ""; * app.Start(); */ return; } if (param == "00000") { Program.Upgrade(); return; } if (param == "658901920") //input standard resistance { this.Invoke(new Action(() => { dlg_kbd.Init("请输入DA零位值(mV)", "daoffset", false, KbdData); })); return; } if (!Util.TryDecimalParse(param, out a)) { return; } int newrange = Processor.CheckRange(a, processor.iRange); if (newrange < 0) { this.Invoke(new Action(() => { Program.MsgShow("输入值超出范围"); })); return; } processor.iRange = newrange; processor.resistance = a; RefreshDisplay(true); } }
private void KbdData(string id, string param) { Decimal a; if (id == "daoffset") { if (!Util.TryDecimalParse(param, out a)) { return; } processor.daoffset = a + processor.daoffset; } if (id == "adscale") { double d; if (!Util.TryDoubleParse(param, out d)) { return; } if (processor.range.ToString() != s_scale) { Program.MsgShow("请选择满量程进行校准"); return; } if ((Form1.scale_vals.Contains(s_scale) && !processor.CalibrateADScale(d / 1000.0)) || (s_scale == "1000" && !processor.CalibrateADScale(d / 1000.0)) || (s_scale == "6000" && !processor.CalibrateADScale(d / 6000.0))) { Program.MsgShow("校准电流值失败."); } } if (id == "value") { if (param == "5555555") { Process.GetCurrentProcess().Kill(); return; } if (param == "1234567") //calibration screen { Form1.TouchCalibrate(); /* * Process app = new Process(); * app.StartInfo.WorkingDirectory = @"\Windows"; * app.StartInfo.FileName = @"\Windows\TouchKit.exe"; * app.StartInfo.Arguments = ""; * app.Start(); */ return; } if (param == "00000") { Program.Upgrade(); return; } if (param == "6589019") //input standard resistance { this.Invoke(new Action(() => { dlg_kbd.Init("请输入DA零位值", "daoffset", false, KbdData); })); return; } if (param == "1111111") //input external voltage value { this.Invoke(new Action(() => { dlg_kbd.Init("请输入接入电流源实际值", "adscale", false, KbdData); })); return; } if (!Util.TryDecimalParse(param, out a)) { return; } if (!IsValidCurrent(a)) //range check { this.Invoke(new Action(() => { Program.MsgShow("输入值超出范围 (0-" + Form1.s_scale + " A)"); })); return; } processor.setting = a; if (Form1.s_scale == "300") { rectMeter1.Angle = Convert.ToInt32(Math.Floor(Convert.ToDouble(a) * 180 / 300.0)); } else { rectMeter1.Angle = Convert.ToInt32(Math.Floor(Convert.ToDouble(a) * 180 / (processor.range * 1.0))); } RefreshDisplay(true); } }