示例#1
0
        public void pc_cmd(string cmd)
        {
            DeviceMgr.SysLog(cmd);
            if (cmd == "ECHO")
            {
                DeviceMgr.Resend();
                return;
            }
            if (cmd == "S")
            {
                if (task.bRunning)
                {
                    statusBar1_StartStopClick(null, null); //click stop
                }
                return;
            }

            if (cmd == "H")
            {
                if ((!task.bRunning) && (!DeviceMgr.IsInAction()))
                {
                    DeviceMgr.Reset();//reset
                }
                return;
            }
            Match m;

            m = reg_mode.Match(cmd);
            if (m.Success)
            {
                oper_mode = m.Groups[1].Value;
                return;
            }
            m = reg_statistic.Match(cmd);
            if (m.Success)
            {
                syscfg.iFilter = Convert.ToInt32(m.Groups[1].Value);
                return;
            }
            m = reg_filter.Match(cmd);
            if (m.Success)
            {
                if (m.Groups[1].Value == "2")
                {
                    syscfg.sFilterType = "filtertype3";
                }
                else if (m.Groups[1].Value == "1")
                {
                    syscfg.sFilterType = "filtertype2";
                }
                else if (m.Groups[1].Value == "3")
                {
                    syscfg.sFilterType = "filtertype4";
                }
                else
                {
                    syscfg.sFilterType = "filtertype1";
                }
                return;
            }
            m = reg_ix.Match(cmd);
            if (m.Success)
            {
                #region current convert
                double myIx = double.Parse(m.Groups[1].Value) / 1000;
                if (myIx >= 5.5)
                {
                    Program.lst_rxinfo[0].iIx   = 5; //5A x 2
                    Program.lst_rxinfo[0].bSqrt = true;
                    return;
                }
                if (myIx >= 2.2)
                {
                    Program.lst_rxinfo[0].iIx   = 5; //5A
                    Program.lst_rxinfo[0].bSqrt = false;
                    return;
                }
                if (myIx >= 1.1)
                {
                    Program.lst_rxinfo[0].iIx   = 4; //1A x 2
                    Program.lst_rxinfo[0].bSqrt = true;
                    return;
                }
                if (myIx >= 0.66)
                {
                    Program.lst_rxinfo[0].iIx   = 4; //1A x 2
                    Program.lst_rxinfo[0].bSqrt = false;
                    return;
                }
                if (myIx >= 0.33)
                {
                    Program.lst_rxinfo[0].iIx   = 3; //0.3A x 2
                    Program.lst_rxinfo[0].bSqrt = true;
                    return;
                }
                if (myIx >= 0.22)
                {
                    Program.lst_rxinfo[0].iIx   = 3; //0.3A
                    Program.lst_rxinfo[0].bSqrt = false;
                    return;
                }
                if (myIx >= 0.11)
                {
                    Program.lst_rxinfo[0].iIx   = 2; //0.1A x 2
                    Program.lst_rxinfo[0].bSqrt = true;
                    return;
                }
                if (myIx >= 0.022)
                {
                    Program.lst_rxinfo[0].iIx   = 2; //0.1A
                    Program.lst_rxinfo[0].bSqrt = false;
                    return;
                }
                if (myIx >= 0.011)
                {
                    Program.lst_rxinfo[0].iIx   = 1; //10mA x 2
                    Program.lst_rxinfo[0].bSqrt = true;
                    return;
                }
                if (myIx >= 0.0022)
                {
                    Program.lst_rxinfo[0].iIx   = 1; //10mA
                    Program.lst_rxinfo[0].bSqrt = false;
                    return;
                }

                if (myIx >= 0.0011)
                {
                    Program.lst_rxinfo[0].iIx   = 0; //1mA x 2
                    Program.lst_rxinfo[0].bSqrt = true;
                    return;
                }
                if (myIx >= 0.00022)
                {
                    Program.lst_rxinfo[0].iIx   = 0; //1mA
                    Program.lst_rxinfo[0].bSqrt = false;
                    return;
                }
                if (myIx >= 0.00011)
                {
                    Program.lst_rxinfo[0].iIx   = -1; //0.1mA x 2
                    Program.lst_rxinfo[0].bSqrt = true;
                    return;
                }
                {
                    Program.lst_rxinfo[0].iIx   = -1; //0.1mA
                    Program.lst_rxinfo[0].bSqrt = false;
                    return;
                }
                #endregion
            }
            m = reg_delay.Match(cmd);
            if (m.Success)
            {
                syscfg.iMeasDelay = Convert.ToInt32(m.Groups[1].Value);
                return;
            }
            m = reg_meastimes.Match(cmd);
            if (m.Success)
            {
                syscfg.iMeasTimes = Convert.ToInt32(m.Groups[1].Value);
                return;
            }
            m = reg_switch.Match(cmd);
            if (m.Success)
            {
                syscfg.iKTT = Convert.ToInt32(m.Groups[1].Value);
                return;
            }
            m = reg_measure.Match(cmd);
            if (m.Success)
            {
                syscfg.iMeasTimes = Convert.ToInt32(m.Groups[1].Value);
                RsInfo rs = Program.lst_rsinfo[Program.mainwnd.selectedRs];
                RxInfo rx = Program.lst_rxinfo[Program.mainwnd.selectedRx];
                if (!task.bRunning)
                {
                    statusBar1_StartStopClick(null, null); //click start
                }
                return;
            }
            m = reg_sampletimes.Match(cmd);
            if (m.Success)
            {
                syscfg.iSampleTimes = Convert.ToInt32(m.Groups[1].Value);
                return;
            }
            m = reg_alpha.Match(cmd);
            if (m.Success)
            {
                Program.lst_rsinfo[0].iRRange = ActionMgr.RNG_INVALID;
                Program.lst_rsinfo[0].dAlpha  = Convert.ToDouble(m.Groups[1].Value);
                return;
            }
            m = reg_beta.Match(cmd);
            if (m.Success)
            {
                Program.lst_rsinfo[0].iRRange = ActionMgr.RNG_INVALID;
                Program.lst_rsinfo[0].dBeta   = Convert.ToDouble(m.Groups[1].Value);

                return;
            }
            m = reg_temp.Match(cmd);
            if (m.Success)
            {
                syscfg.dTemp = Convert.ToDouble(m.Groups[1].Value);
                return;
            }
            m = reg_rsa.Match(cmd);
            if (m.Success)
            {
                Program.lst_rsinfo[0].iRRange  = ActionMgr.RNG_INVALID;
                Program.lst_rsinfo[0].dValue   = Convert.ToDouble(m.Groups[1].Value);
                Program.lst_rxinfo[0].cStdChan = 'A';
                return;
            }
            m = reg_rsid.Match(cmd);
            if (m.Success)
            {
                Program.lst_rsinfo[0].iRRange = ActionMgr.RNG_INVALID;
                Program.lst_rsinfo[0].sSerial = m.Groups[1].Value;
                return;
            }
            m = reg_rxid.Match(cmd);
            if (m.Success)
            {
                Program.lst_rxinfo[0].sSerial = m.Groups[1].Value;
                return;
            }

            m = reg_rsb.Match(cmd);
            if (m.Success)
            {
                Program.lst_rxinfo[0].dRxInput = Convert.ToDouble(m.Groups[1].Value);
                ActionMgr.SetIxRange(0, Program.lst_rxinfo[0].dRxInput, false);
                Program.lst_rxinfo[0].cStdChan = 'B';
                return;
            }
        }