Beispiel #1
0
 void statusBar1_StartStopClick(object sender, EventArgs e)
 {
     if (task.bRunning)
     {
         statusBar1.pause  = false;
         statusBar1.status = RUN_STATE.STOPPING;
         task.Stop();
     }
     else
     {
         RsInfo rs = Program.lst_rsinfo[Program.mainwnd.selectedRs];
         RxInfo rx = Program.lst_rxinfo[Program.mainwnd.selectedRx];
         statusBar1.total  = syscfg.iMeasTimes;
         statusBar1.count  = 1;
         statusBar1.status = RUN_STATE.INITIALIZING;
         DeviceMgr.Log(String.Format(@"==== New Measurement Paramter========
                                     Measure times = {0}\r\nRs ID = {1}\r\nRs Value = {2}\r\nRs Temp. Alpha = {3}\r\nRs Temp. Beta = {4}\r\n
                                     Temperature = {5}\r\nRx ID = {6}\r\nSample times = {7}\r\nSwitch delay = {8}\r\n
                                     Filter = {9}\r\nFilter Length = {10}\r\nMeasure delay = {12}\r\n
                                     AutoFilter = {13}\r\nRx curr. = {14}\r\n
                                     New Measurement Started...", syscfg.iMeasTimes.ToString(), rs.sSerial, rs.dValue.ToString("F8"), rs.dAlpha.ToString("F3"), rs.dBeta.ToString("F3"),
                                     syscfg.dTemp.ToString("F3"), rx.sSerial, syscfg.iSampleTimes, syscfg.iKTT,
                                     syscfg.sFilterType, syscfg.iFilter, syscfg.iMeasDelay, syscfg.bThrow, rx.iIx
                                     ));
         task.Start();
         Program.data.ClearAll();
         foreach (RxDisplay rxdisp in Enumerable.Range(1, 4).Select(x => findrx(x)))
         {
             rxdisp.ReDraw();
         }
     }
 }
Beispiel #2
0
        //for sorting of Rx according to channel number, and enabled channel goes first.
        public int CompareTo(object obj)
        {
            if (obj is RxInfo)
            {
                RxInfo rx = obj as RxInfo;
                if (this.bEnabled && !rx.bEnabled)
                {
                    return(1);
                }
                if (!this.bEnabled && rx.bEnabled)
                {
                    return(-1);
                }

                if (this.cChan < rx.cChan)
                {
                    return(-1);
                }
                if (this.cChan > rx.cChan)
                {
                    return(1);
                }
                return(0);
            }
            return(1);
        }
Beispiel #3
0
        public bool CheckError()
        {
            lbl_error.Text    = "";
            lbl_error.Visible = false;
            RxInfo rx = Program.lst_rxinfo[Program.mainwnd.selectedRx];
            RsInfo rs = Program.lst_rsinfo[Program.mainwnd.selectedRs];

            if ((rs.dValue / rx.dRxInput) > 1023.1)
            {
                lbl_error.Text    = StringResource.str("rs_2big") + "," + StringResource.str(String.Format("help_std{0}", rx.iRRange));
                lbl_error.Visible = true;
                return(true);
            }
            if ((rs.dValue / rx.dRxInput) < 0.000977) //=1/1023.1
            {
                lbl_error.Text    = StringResource.str("rs_2small") + "," + StringResource.str(String.Format("help_std{0}", rx.iRRange));
                lbl_error.Visible = true;
                return(true);
            }

            /*if ((rx.iRRange == ActionMgr.RNG_10K && rx.bSqrt) || (rx.iRRange == ActionMgr.RNG_100K && rx.bSqrt))
             * {
             *  lbl_error.Text = StringResource.str("nox2_4big");
             *  lbl_error.Visible = true;
             *  return true;
             * }*/
            return(false);
        }
Beispiel #4
0
        void btn_sqrt_ValidClick(object sender, EventArgs e)
        {
            RxInfo rx = Program.lst_rxinfo[selectedRx];

            rx.bSqrt = !rx.bSqrt;
            InitDisplay(selectedRx);
        }
Beispiel #5
0
        void statusBar1_StartStopClick(object sender, EventArgs e)
        {
            if (task.bRunning)
            {
                statusBar1.pause  = false;
                statusBar1.status = RUN_STATE.STOPPING;
                task.Stop();
                try
                {
                    rxDisplay1.LogComplete();
                }
                catch
                {
                }
            }
            else
            {
                RsInfo rs = Program.lst_rsinfo[Program.mainwnd.selectedRs];
                RxInfo rx = Program.lst_rxinfo[Program.mainwnd.selectedRx];
                statusBar1.total  = syscfg.iMeasTimes;
                statusBar1.count  = 1;
                statusBar1.status = RUN_STATE.INITIALIZING;

                task.Start();
                rxDisplay1.ClearAll();
                rxDisplay2.ClearAll();
                rxDisplay3.ClearAll();
                rxDisplay4.ClearAll();
            }
        }
Beispiel #6
0
        void btn_enable_ValidClick(object sender, EventArgs e)
        {
            RxInfo rx = Program.lst_rxinfo[selectedRx];

            rx.bEnabled = !rx.bEnabled;
            InitDisplay(selectedRx);
        }
Beispiel #7
0
        private ACTION_STATE InitKI(ACTION_STATE stm)
        {
            RxInfo currRx = rx;

            SetDelays();
            currRx.var.iSrc = RunWnd.syscfg.GetCurrent(currRx.iIx, currRx.bSqrt); //0.1mA
            currRx.var.rRx  = currRx.dRxInput;
            currRx.var.iK   = RX_VAR.INIT_LOOP;
            currRx.var.iK   = currRx.var.calc_capture_nextk();

            if (currRx.iRRange == RNG_P1)   //P1 ohm
            {
                currRx.var.iK = 100;        //10:1
            }
            if (currRx.iRRange == RNG_P01)  //P01 ohm
            {
                currRx.var.iK = 10;         //100:1
            }
            if (currRx.iRRange == RNG_P001) //P001 ohm
            {
                currRx.var.iK = 1;          //1000:1
            }
            DeviceMgr.Action("turnk", Convert.ToUInt32(currRx.var.iK));
            if ((currRx.iRRange == RNG_P1) || (currRx.iRRange == RNG_P01) || (currRx.iRRange == RNG_P001))
            {
                return(ACTION_STATE.INIT_FOR_RS_KTTP);
            }
            else
            {
                return(ACTION_STATE.INIT_FOR_TRACKP);
            }
        }
Beispiel #8
0
        //compose string of curr, sqr std, constv
        public static string ComposeAction(RxInfo myRx)
        {
            string ret = "";

            switch (myRx.iIx)
            {
            case -1: ret = ret + "CURR_P0001"; break; //0.1mA

            case 0: ret = ret + "CURR_P001"; break;   //1mA

            case 1: ret = ret + "CURR_P01"; break;    //10mA

            case 2: ret = ret + "CURR_P1"; break;     //0.1A

            case 3: ret = ret + "CURR_P3"; break;     //0.3A

            case 4: ret = ret + "CURR_1"; break;      //1A

            case 5: ret = ret + "CURR_5"; break;      //5A
            }
            ret = ret + "|";
            if (myRx.bSqrt)
            {
                ret = ret + "X2|";
            }
            else
            {
                ret = ret + "X1|";
            }

            if (myRx.iIx == 3) //0.3A
            {
                ret = ret + "STD_P1|VMODE_3V";
            }
            else if (myRx.iIx == 4) //1A
            {
                ret = ret + "STD_P01|VMODE_3V";
            }
            else if (myRx.iIx == 5) //5A
            {
                ret = ret + "STD_P001|VMODE_3V";
            }
            else
            {
                ret = ret + "STD_1|VMODE_3V";
            }

            return(ret);
        }
Beispiel #9
0
        public void Start()
        {
            if (!bRunning)
            {
                curr_ch        = 0;
                currRx         = Program.lst_rxinfo[curr_ch];
                currRx.var.rRs = Program.lst_rsinfo[0].dTValue;

                act_mgr.Reset();
                act_mgr.rx = currRx;
                act_mgr.rs = Program.lst_rsinfo[0];
                data_mgr.Reset();
                data_mgr.rx = currRx;
                data_mgr.rs = Program.lst_rsinfo[0];
                DeviceMgr.ReportHeader(RunWnd.syscfg.iMeasTimes);
                bRunning = true;
            }
        }
Beispiel #10
0
        public double CalibrateCurr(RxInfo rx)
        {
            double vp, vn;

            DeviceMgr.Action("turnk", rx.var.iK);
            Thread.Sleep(1000);
            while (DeviceMgr.IsInAction())
            {
                ;
            }
            DeviceMgr.Action("MEAS_RS|KTTP|" + DeviceMgr.ComposeAction(rx), 0);
            Reset();
            this.rx = rx;
            this.rs = Program.lst_rsinfo[0];
            Thread.Sleep(20000);
            bInReading = true;
            Thread.Sleep(500);
            while (IsBusy)
            {
                Thread.Sleep(1000);
            }
            vp = DeviceMgr.reading;

            DeviceMgr.Action("MEAS_RS|KTTN|" + DeviceMgr.ComposeAction(rx), 0);
            Thread.Sleep(20000);
            bInReading = true;
            Thread.Sleep(500);
            while (IsBusy)
            {
                DeviceMgr.IsInAction();
                Thread.Sleep(1000);
            }
            vn = DeviceMgr.reading;
            double val = (Math.Abs((vp - vn) / 2.0)) / rx.var.rRs;

            val = val * RX_VAR.INIT_LOOP / rx.var.iK;
            RunWnd.syscfg.SetCurrent(rx.iIx, rx.bSqrt, val);
            return(val);
        }
Beispiel #11
0
        private void DoNextMeasure()
        {
            RsInfo rs = runstate.selectedRs.Dequeue();
            RxInfo rx = runstate.selectedRx.Dequeue();

            status = RUN_STATE.INITIALIZING;

            if (false)
            {
                SysConfig syscfg = Program.sysinfo;

                DeviceMgr.Log(String.Format(@"==== New Measurement Paramter========
                                            Measure times = {0}\r\nRs ID = {1}\r\nRs Value = {2}\r\nRs Temp. Alpha = {3}\r\nRs Temp. Beta = {4}\r\n
                                            Temperature = {5}\r\nRx ID = {6}\r\nSample times = {7}\r\nSwitch delay = {8}\r\n
                                            Filter = {9}\r\nFilter Length = {10}\r\nMeasure delay = {12}\r\n
                                            AutoFilter = {13}\r\nRx curr. = {14}\r\n
                                            New Measurement Started...", syscfg.iMeasTimes.ToString(), rs.sSerial, rs.dValue.ToString("F8"), rs.dAlpha.ToString("F3"), rs.dBeta.ToString("F3"),
                                            syscfg.dTemp.ToString("F3"), rx.sSerial, syscfg.iSampleTimes, syscfg.iKTT,
                                            syscfg.sFilterType, syscfg.iFilter, syscfg.iMeasDelay, syscfg.bThrow, rx.iIx
                                            ));
            }
            task.Start(rx, rs);
        }
Beispiel #12
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;
            }
        }
Beispiel #13
0
        public double CalibrateCurr(RxInfo rx)
        {
            double vp, vn;
            DeviceMgr.Action("turnk", rx.var.iK);
            Thread.Sleep(1000);
            while (DeviceMgr.IsInAction())
                ;
            DeviceMgr.Action("MEAS_RS|KTTP|" + DeviceMgr.ComposeAction(rx), 0);
            Reset();
            this.rx = rx;
            this.rs = Program.lst_rsinfo[0];
            Thread.Sleep(20000);
            bInReading = true;
            Thread.Sleep(500);
            while (IsBusy)
            {
                Thread.Sleep(1000);
            }
            vp = DeviceMgr.reading;

            DeviceMgr.Action("MEAS_RS|KTTN|" + DeviceMgr.ComposeAction(rx), 0);
            Thread.Sleep(20000); 
            bInReading = true;
            Thread.Sleep(500);
            while (IsBusy)
            {
                DeviceMgr.IsInAction();
                Thread.Sleep(1000);
            }
            vn = DeviceMgr.reading;
            double val = (Math.Abs((vp - vn) / 2.0)) / rx.var.rRs;
            val = val * RX_VAR.INIT_LOOP / rx.var.iK;
            RunWnd.syscfg.SetCurrent(rx.iIx, rx.bSqrt,val);
            return val;
            
        }
Beispiel #14
0
        //compose string of curr, sqr std, constv
        public static string ComposeAction(RxInfo myRx)
        {
            string ret = "";
            switch (myRx.iIx)
            {
                case -1: ret = ret + "CURR_P0001"; break; //0.1mA
                case 0: ret = ret + "CURR_P001"; break; //1mA
                case 1: ret = ret + "CURR_P01"; break; //10mA
                case 2: ret = ret + "CURR_P1"; break; //0.1A
                case 3: ret = ret + "CURR_P3"; break; //0.3A
                case 4: ret = ret + "CURR_1"; break; //1A
                case 5: ret = ret + "CURR_5"; break; //5A

            }
            ret = ret + "|";
            if (myRx.bSqrt)
                ret = ret + "X2|";
            else
                ret = ret + "X1|";

            if (myRx.iIx == 3) //0.3A
                ret = ret + "STD_P1|VMODE_3V";
            else if (myRx.iIx == 4) //1A
                ret = ret + "STD_P01|VMODE_3V";
            else if (myRx.iIx == 5) //5A
                ret = ret + "STD_P001|VMODE_3V";
            else
                ret = ret + "STD_1|VMODE_3V";

            return ret;
        }
Beispiel #15
0
        public void Start()
        {
            if (!bRunning)
            {
                curr_ch = 0;
                currRx = Program.lst_rxinfo[curr_ch];
                currRx.var.rRs = Program.lst_rsinfo[0].dTValue;

                act_mgr.Reset();
                act_mgr.rx = currRx;
                act_mgr.rs = Program.lst_rsinfo[0];
                data_mgr.Reset();
                data_mgr.rx = currRx;
                data_mgr.rs = Program.lst_rsinfo[0];
                DeviceMgr.ReportHeader(RunWnd.syscfg.iMeasTimes);
                retry = 0;
                bRunning = true;
            }
        }
Beispiel #16
0
        public void InitDisplay(int iRx)
        {
            selectedRx = iRx;


            RxInfo rx = Program.lst_rxinfo[iRx];

            btn_chan.Text = "CH " + (iRx + 1).ToString();
            if (rx.bEnabled)
            {
                if (rx.iIx == -1)
                {
                    btn_current.Text = "0.1mA";
                }
                if (rx.iIx == 0)
                {
                    btn_current.Text = "1mA";
                }
                if (rx.iIx == 1)
                {
                    btn_current.Text = "10mA";
                }
                if (rx.iIx == 2)
                {
                    btn_current.Text = "0.1A";
                }
                if (rx.iIx == 3)
                {
                    btn_current.Text = "0.3A";
                }
                if (rx.iIx == 4)
                {
                    btn_current.Text = "1A";
                }
                if (rx.iIx == 5)
                {
                    btn_current.Text = "5A";
                }
                btn_vname.Text   = Util.FormatData(rx.dRxInput, 8);
                btn_serial.Text  = rx.sSerial;
                btn_stdchan.Text = rx.iStdChan.ToString();

                if ((rx.iRRange == ActionMgr.RNG_10K && rx.bSqrt) || (rx.iRRange == ActionMgr.RNG_100K && rx.bSqrt))
                {
                    rx.bSqrt = false;
                }
                if (rx.bSqrt)
                {
                    btn_sqrt.Text = "x2";
                }
                else
                {
                    btn_sqrt.Text = "x1";
                }
                btn_enable.Text = StringResource.str("enabled");
            }
            else
            {
                btn_enable.Text = StringResource.str("disabled");
            }
            btn_enable.bOn = rx.bEnabled;
            //btn_current.bOn = rx.bEnabled && (rx.iVMode == 0);
            btn_serial.bOn  = rx.bEnabled;
            btn_stdchan.bOn = rx.bEnabled;
            //btn_sqrt.bOn = rx.bEnabled && (rx.iVMode == 0);
            //btn_vmode.bOn = rx.bEnabled;
        }
Beispiel #17
0
 public RX_VAR(RxInfo rxinfo)
 {
     rx = rxinfo;
     Reset();
 }
Beispiel #18
0
        public void InitDisplay(int iRx)
        {
            selectedRx = iRx;


            RxInfo rx = Program.lst_rxinfo[iRx];

//            btn_chan.Text = "CH " + (iRx+1).ToString();
            if (rx.bEnabled)
            {
                if (rx.iIx == -1)
                {
                    btn_current.Text = "0.1mA";
                }
                if (rx.iIx == 0)
                {
                    btn_current.Text = "1mA";
                }
                if (rx.iIx == 1)
                {
                    btn_current.Text = "10mA";
                }
                if (rx.iIx == 2)
                {
                    btn_current.Text = "0.1A";
                }
                if (rx.iIx == 3)
                {
                    btn_current.Text = "0.3A";
                }
                if (rx.iIx == 4)
                {
                    btn_current.Text = "1A";
                }
                if (rx.iIx == 5)
                {
                    btn_current.Text = "5A";
                }

                btn_serial.Text  = rx.sSerial;
                btn_stdchan.Text = rx.iStdChan.ToString();

                if (rx.bSqrt)
                {
                    btn_sqrt.Text = "x2";
                }
                else
                {
                    btn_sqrt.Text = "x1";
                }
                btn_enable.Text = StringResource.str("enabled");
            }
            else
            {
                btn_enable.Text = StringResource.str("disabled");
            }
            btn_enable.bOn = rx.bEnabled;
            //btn_current.bOn = rx.bEnabled && (rx.iVMode == 0);
            btn_serial.bOn  = rx.bEnabled;
            btn_stdchan.bOn = rx.bEnabled;
            //btn_sqrt.bOn = rx.bEnabled && (rx.iVMode == 0);
            //btn_vmode.bOn = rx.bEnabled;

            btn_rangeP001.bOn = (rx.iRRange == 0);
            btn_rangeP01.bOn  = (rx.iRRange == 1);
            btn_rangeP1.bOn   = (rx.iRRange == 2);
            btn_range1.bOn    = (rx.iRRange == 3);
            btn_range10.bOn   = (rx.iRRange == 4);
            btn_range100.bOn  = (rx.iRRange == 5);
            btn_range1k.bOn   = (rx.iRRange == 6);
            btn_range10k.bOn  = (rx.iRRange == 7);
            btn_range100k.bOn = (rx.iRRange == 8);
        }
Beispiel #19
0
 public RX_VAR(RxInfo rxinfo)
 {
     rx = rxinfo;
     Reset();
 }
Beispiel #20
0
        public void KbdData(string param, string data)
        {
            try
            {
                if (param.StartsWith("scale"))
                {
                    param = param.Remove(0, "scale".Length);
                    if (ActionMgr.ConvertToRange(param) != ActionMgr.RNG_INVALID)
                    {
                        RunWnd.syscfg.SetScaleAdjust(ActionMgr.ConvertToRange(param), Convert.ToDouble(data));
                    }
                    return;
                }
                if (param == "5" || param == "10")
                {
                    RunWnd.syscfg.SetCurrent(5, (param.IndexOfAny("5".ToCharArray()) < 0), Convert.ToDouble(data));
                }
                if (param == "1" || param == "2")
                {
                    RunWnd.syscfg.SetCurrent(4, (param.IndexOfAny("1".ToCharArray()) < 0), Convert.ToDouble(data));
                }
                if (param == "0.3" || param == "0.6")
                {
                    RunWnd.syscfg.SetCurrent(3, (param.IndexOfAny("3".ToCharArray()) < 0), Convert.ToDouble(data));
                }
                if (param == "0.1" || param == "0.2")
                {
                    RunWnd.syscfg.SetCurrent(2, (param.IndexOfAny("1".ToCharArray()) < 0), Convert.ToDouble(data));
                }
                if (param == "0.01" || param == "0.02")
                {
                    RunWnd.syscfg.SetCurrent(1, (param.IndexOfAny("1".ToCharArray()) < 0), Convert.ToDouble(data));
                }
                if (param == "0.001" || param == "0.002")
                {
                    RunWnd.syscfg.SetCurrent(0, (param.IndexOfAny("1".ToCharArray()) < 0), Convert.ToDouble(data));
                }
                if (param == "0.0001" || param == "0.0002")
                {
                    RunWnd.syscfg.SetCurrent(-1, (param.IndexOfAny("1".ToCharArray()) < 0), Convert.ToDouble(data));
                }
                if (param == "exportdate")
                {
                    #region remove date log
                    if (Regex.IsMatch(data, "^820\\d\\d\\d\\d\\d\\d$"))
                    {
                        data = data.Remove(0, 1);
                        try
                        {
                            foreach (string dname in Directory.GetDirectories(StringResource.basedir, "20*"))
                            {
                                string[] todel = Directory.GetFiles(dname, "20*.txt");
                                foreach (string fname in todel)
                                {
                                    FileInfo fi = new FileInfo(fname);
                                    Match    m  = Regex.Match(fi.Name, @"(\d\d\d\d)_(\d\d)_(\d\d).*");
                                    if (m.Success)
                                    {
                                        if ((Convert.ToUInt16(data.Substring(0, 4)) <= Convert.ToUInt16(m.Groups[1].Value)) &&
                                            (Convert.ToUInt16(data.Substring(4, 2)) <= Convert.ToUInt16(m.Groups[2].Value)) &&
                                            (Convert.ToUInt16(data.Substring(6, 2)) <= Convert.ToUInt16(m.Groups[3].Value)))
                                        {
                                            //do nothing
                                        }
                                        else
                                        {
                                            File.Delete(fname);
                                        }
                                    }
                                }
                            }
                        }
                        catch
                        {
                        }
                        return;
                    }
                    #endregion

                    if (Regex.IsMatch(data, "^20\\d\\d\\d\\d\\d\\d$"))
                    {
                        export_start = data;
                        Program.kbd.Init(StringResource.str("enter_endexport"), "endexport", false, KbdData);
                    }
                    return;
                }
                if (param == "endexport")
                {
                    if (!Regex.IsMatch(data, "^20\\d\\d\\d\\d\\d\\d$"))
                    {
                        return;
                    }

                    try
                    {
                        foreach (string dname in Directory.GetDirectories(StringResource.basedir, "20*"))
                        {
                            foreach (string fname in Directory.GetFiles(dname, "20*.txt"))
                            {
                                FileInfo fi = new FileInfo(fname);
                                Match    m  = Regex.Match(fi.Name, @"(\d\d\d\d)_(\d\d)_(\d\d).*");
                                if (m.Success)
                                {
                                    if ((Convert.ToUInt16(data.Substring(0, 4)) >= Convert.ToUInt16(m.Groups[1].Value)) &&
                                        (Convert.ToUInt16(data.Substring(4, 2)) >= Convert.ToUInt16(m.Groups[2].Value)) &&
                                        (Convert.ToUInt16(data.Substring(6, 2)) >= Convert.ToUInt16(m.Groups[3].Value)) &&
                                        (Convert.ToUInt16(export_start.Substring(0, 4)) <= Convert.ToUInt16(m.Groups[1].Value)) &&
                                        (Convert.ToUInt16(export_start.Substring(4, 2)) <= Convert.ToUInt16(m.Groups[2].Value)) &&
                                        (Convert.ToUInt16(export_start.Substring(6, 2)) <= Convert.ToUInt16(m.Groups[3].Value)))
                                    {
                                        File.Copy(fname, StringResource.udiskdir + "\\" + fi.Name, true);
                                    }
                                }
                            }
                        }
                        Program.msg.Init(StringResource.str("export_done"));
                    }
                    catch
                    {
                        Program.msg.Init(StringResource.str("export_fail"));
                        return;
                    }
                }
                if (param == "newtime")
                {
                    if (!Regex.IsMatch(newdate, "^\\d\\d\\d\\d\\d\\d\\d\\d$"))
                    {
                        return;
                    }

                    if (!Regex.IsMatch(data, "^\\d\\d\\d\\d\\d\\d$"))
                    {
                        return;
                    }
                    SystemTime time = new SystemTime();
                    time.wYear        = Convert.ToUInt16(newdate.Substring(0, 4));
                    time.wMonth       = Convert.ToUInt16(newdate.Substring(4, 2));
                    time.wDay         = Convert.ToUInt16(newdate.Substring(6, 2));
                    time.wHour        = Convert.ToUInt16(data.Substring(0, 2));
                    time.wMinute      = Convert.ToUInt16(data.Substring(2, 2));
                    time.wSecond      = Convert.ToUInt16(data.Substring(4, 2));
                    time.wMiliseconds = 0;
                    SetLocalTime(ref time);
                }
                if (param == "newdate")
                {
                    if (data.StartsWith("8")) //input of scale offset
                    {
                        string sparam = data.Remove(0, 1);
                        if (ActionMgr.ConvertToRange(sparam) != ActionMgr.RNG_INVALID)
                        {
                            this.Invoke(new Action <string>(enterscale), new string[] { sparam });
                        }
                        return;
                    }
                    if (data == "00000") //do upgrade
                    {
                        Program.Upgrade();
                        return;
                    }
                    if (data == "99999") //current calibration
                    {
                        string sparam = data.Remove(0, 1);
                        RxInfo myrx   = Program.lst_rxinfo[Program.mainwnd.selectedRx];
                        myrx.var.rRs = Program.lst_rsinfo[0].dTValue;
                        if (myrx.iRRange == ActionMgr.RNG_P001)
                        {
                            myrx.var.iK = 1; //1000:1
                        }
                        else if (myrx.iRRange == ActionMgr.RNG_P01)
                        {
                            myrx.var.iK = 10; //100:1
                        }
                        else if (myrx.iRRange == ActionMgr.RNG_P1)
                        {
                            myrx.var.iK = 100; //10:1
                        }
                        else
                        {
                            myrx.var.iK = (int)Math.Floor(1000.0 / (myrx.var.rRs * RunWnd.syscfg.GetStdCurrent(myrx.iIx, myrx.bSqrt)));
                        }

                        if (myrx.var.iK > 1020)
                        {
                            Program.msg.Init("标准电阻阻值过小,无法校准。标准电阻上电压应不小于1V");
                            return;
                        }
                        Program.msg.Init(String.Format(@"电流校准完成,电流值为{0}", Util.FormatData(Program.mainwnd.task.act_mgr.CalibrateCurr(myrx), 8)));
                        return;
                    }
                    if (data == "1" || data == "2" ||
                        data == "5" || data == "10" ||
                        data == "0.3" || data == "0.6" ||
                        data == "0.1" || data == "0.2" ||
                        data == "0.01" || data == "0.02" ||
                        data == "0.001" || data == "0.002" ||
                        data == "0.0001" || data == "0.0002")
                    {
                        this.Invoke(new Action <string>(entercurrent), new string[] { data });
                        return;
                    }
                    if (data == "65890192")
                    {
                        Process.GetCurrentProcess().Kill(); //back door to exit the current program
                        return;
                    }
                    if (data == "658901920")
                    {
                        Program.OpenLog(0);
                        return;
                    }

                    if (data == "12345678")
                    {
                        Process app = new Process();
                        app.StartInfo.WorkingDirectory = @"\Windows";
                        app.StartInfo.FileName         = @"\Windows\TouchKit.exe";
                        app.StartInfo.Arguments        = "";
                        app.Start();
                        btn_quit_ValidClick(null, null);
                        return;
                    }
                    newdate = data;
                    this.Invoke(new Action(EnterNewTime));
                    return;
                }

                if (param == "ktt")
                {
                    RunWnd.syscfg.iKTT = Convert.ToInt32(data);
                }
                if (param == "measdelay")
                {
                    RunWnd.syscfg.iMeasDelay = Convert.ToInt32(data);
                }
                if (param == "sampletimes")
                {
                    RunWnd.syscfg.iSampleTimes = Convert.ToInt32(data);
                }
                if (param == "meastimes")
                {
                    RunWnd.syscfg.iMeasTimes = Convert.ToInt32(data);
                }
                if (param == "fltlength")
                {
                    RunWnd.syscfg.iFilter = Convert.ToInt32(data);
                }
                InitDisplay();
            }
            catch
            {
            }
        }