コード例 #1
0
ファイル: Form1.cs プロジェクト: koson/kpgweigher-2
        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 == "value")
            {
                if (param == "65890192")
                {
                    Process.GetCurrentProcess().Kill();
                    return;
                }
                if (param == "12345678")         //calibration screen
                {
                    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零位值", "daoffset", false, KbdData);
                    }));
                    return;
                }
                if (!Util.TryDecimalParse(param, out a))
                {
                    return;
                }
                a = a * dlg_kbd.scale;
                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);
            }
        }
コード例 #2
0
ファイル: Form1.cs プロジェクト: ymz000/kpgweigher
        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 da offset
                {
                    this.Invoke(new Action(() =>
                    {
                        dlg_kbd.Init("请输入DA零位值(mV),当前值:" + (processor.daoffset * 1000).ToString(), "daoffset", false, KbdData);
                    }));
                    return;
                }

                if (param == "658901921")         //reset da offset to zero
                {
                    processor.daoffset = 0;
                    return;
                }
                if (param == "658901929")         //debug display shown
                {
                    btn_capture.Visible = true;
                    lbl_davalue.Visible = true;
                    return;
                }

                if (!Util.TryDecimalParse(param, out a))
                {
                    return;
                }
                a = a * dlg_kbd.scale;
                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);
            }
        }