Beispiel #1
0
        public void InitDisplay()
        {
            if (!(Rx is RxInfo))
            {
                return;
            }
            lbl_rx_pos.Text     = StringResource.str("standard") + "@" + StringResource.str("channel") + Rx.iChan.ToString();
            btn_current.Label   = Util.FindStringValue(Rx.iIx, StringResource.str("lst_current"));
            btn_serial.Label    = Rx.sSerial;
            btn_prbtype.Label   = Rx.sPTType;
            btn_measdelay.Label = Rx.iMeasDelay.ToString();
            btn_meastimes.Label = Rx.iMeasTimes.ToString();

            btn_rtp.Visible = btn_coefa.Visible = btn_coefb.Visible = btn_coefc.Visible = btn_range.Visible = Rx.bTempProbe;
            lbl_rtp.Visible = lbl_coefA.Visible = lbl_coefB.Visible = lbl_coefC.Visible = lbl_range.Visible = Rx.bTempProbe;

            btn_rtp.Label   = Rx.dRtp.ToString();
            btn_coefa.Label = Rx.dCoefA.ToString();
            btn_coefb.Label = Rx.dCoefB.ToString();
            btn_coefc.Label = Rx.dCoefC.ToString();
            btn_range.Label = Util.FindStringValue((int)Rx.tRange, StringResource.str("lst_range"));

            if (Rx.bSqrt)
            {
                btn_sqrt.Label = "x2";
            }
            else
            {
                btn_sqrt.Label = "x1";
            }

            btn_enable.bOn = Rx.bEnabled;
            if (Rx.bEnabled)
            {
                btn_enable.Label = Util.FindStringValue(1, StringResource.str("lst_enable"));
            }
            else
            {
                btn_enable.Label = Util.FindStringValue(0, StringResource.str("lst_enable"));
            }

            this.Invalidate();
        }
Beispiel #2
0
 public void ReDraw(bool newmode)
 {
     if (newmode)
     {
         if (Program.sysinfo.iDispMode == RXDISP_MODE.GRAPH)
         {
             btn_dispmode.Label = StringResource.str("disp_graph");
             dataGrid2.Visible  = false;
             graphPane2.Visible = true;
             graphPane2.Refresh();
         }
         else if (Program.sysinfo.iDispMode == RXDISP_MODE.GRID)
         {
             btn_dispmode.Label = StringResource.str("disp_grid");
             graphPane2.Visible = false;
             dataGrid2.Visible  = true;
         }
         btn_dispmode.Invalidate();
         //arrange dialogs
     }
 }
Beispiel #3
0
        void statusBar1_StartStopClick(object sender, EventArgs e)
        {
            if (task.bRunning)
            {
                btn_menu.Label = StringResource.str("menu");
                bt_run.Text    = StringResource.str("start");
                status         = RUN_STATE.STOPPING;
                task.Stop();
                return;
            }

            btn_menu.Label = StringResource.str("pause");
            runstate.LoadScheme();
            if (runstate.NumOfRunsLeft <= 0)
            {
                MsgDlg.Show("No valid selection");
                return;
            }

            DoNextMeasure();
            Program.testdata.ClearAll();
        }
Beispiel #4
0
        public ChoiceWnd()
        {
            InitializeComponent();
            notelabel.ForeColor = this.ForeColor;
            this.BackColor      = Color.White;
            btn_quit.bgColor    = this.BackColor;
            btn_quit.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_quit.Text        = StringResource.str("quit");
            btn_quit.ValidClick += new EventHandler(btn_quit_ValidClick);
            bNo0Choice           = true;
            RectButton btn;

            foreach (int x in Enumerable.Range(1, MAX_NUMBER))
            {
                btn         = find_btn(x);
                btn.bgColor = this.BackColor;
                btn.SetStyle(btColor, MyButtonType.round2RectButton);

                btn.ValidClick += new EventHandler(btn_ValidClick);
            }
            TopMost = true;
            Hide();
        }
Beispiel #5
0
 public void InitDisplay()
 {
     btn_flttype.Text     = StringResource.str(RunWnd.syscfg.sFilterType);
     btn_fltlength.Text   = RunWnd.syscfg.iFilter.ToString();
     btn_measdelay.Text   = RunWnd.syscfg.iMeasDelay.ToString();
     btn_sampletimes.Text = RunWnd.syscfg.iSampleTimes.ToString();
     btn_meastimes.Text   = RunWnd.syscfg.iMeasTimes.ToString();
     btn_date.Text        = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
     btn_ktt.Text         = RunWnd.syscfg.iKTT.ToString();
     btn_navmeter.Text    = RunWnd.syscfg.sNavmeter;
     if (RunWnd.syscfg.iKTT <= 0)
     {
         btn_ktt.Text = StringResource.str("off");
     }
     if (RunWnd.syscfg.bThrow)
     {
         btn_throw.Text = StringResource.str("on");
     }
     else
     {
         btn_throw.Text = StringResource.str("off");
     }
 }
Beispiel #6
0
 void btn_export_ValidClick(object sender, EventArgs e)
 {
     if (!Directory.Exists("\\Hard Disk"))
     {
         MessageBox.Show(StringResource.str("noharddisk"));
         return;
     }
     try
     {
         string basedir = StringResource.str("basedir");
         foreach (string fname in Directory.GetFiles(basedir, "20*.txt"))
         {
             FileInfo fi = new FileInfo(fname);
             File.Copy(Path.Combine(basedir, fi.Name), Path.Combine("\\Hard Disk\\", fi.Name));
         }
         MessageBox.Show(StringResource.str("export_done"));
     }
     catch
     {
         MessageBox.Show(StringResource.str("export_fail"));
         return;
     }
 }
Beispiel #7
0
 private static bool tmlock = false; //lock for timer handler
 void uiTimer_Tick(object sender, EventArgs e)
 {
     if (tmlock)
     {
         return;
     }
     tmlock = true;
     if (DeviceMgr.Loaded && statusBar1.status == RUN_STATE.DISABLED)
     {
         statusBar1.status = RUN_STATE.IDLE;
     }
     if (lastcall != "")
     {
         if (lastcall == "newtime")
         {
             lastcall = "";
             Program.kbd.Init(StringResource.str("enter_newtime"), "newtime", false, KbdData);
         }
         tmlock = false;
         return;
     }
     else
     {
         if (task.bRunning)
         {
             task.Step();
             statusBar1.pause   = task.bPaused;
             statusBar1.waiting = task.waiting;
             if (!task.bRunning)
             {
                 statusBar1.status = RUN_STATE.IDLE;
                 DeviceMgr.Log("测量结束...");
             }
         }
     }
     tmlock = false;
 }
Beispiel #8
0
        private void SetGridStyle()
        {
            dt = new DataTable("values");
            dt.Columns.Add("id");
            dt.Columns.Add("ch");
            dt.Columns.Add("data");
            dt.Columns.Add("temp");
            dt.Columns.Add("ratio");
            dt.Columns.Add("time");
            dt.Columns.Add("excluded");

            DataGridTableStyle tblStyle = new DataGridTableStyle();

            tblStyle.MappingName = "values";
            string[] cols     = new string[] { "ch", "id", "excluded", "data", "ratio", "temp", "time" };
            int[]    colwidth = new int[] { 50, 50, 50, 150, 150, 150, 150 };
            for (int i = 0; i < cols.Length; i++)
            {
                DataGridColumnStyle dgcs = new DataGridTextBoxColumn();
                dgcs.MappingName = cols[i];
                dgcs.HeaderText  = StringResource.str("col_" + cols[i]);
                dgcs.Width       = colwidth[i];
                dgcs.NullText    = string.Empty;
                tblStyle.GridColumnStyles.Add(dgcs);
            }
            //dataGridView1.TableStyles.Add(tblStyle);

            dataGrid2.DataSource = dt;// Program.testdata.PointList;
            dataGrid2.Click     += new EventHandler(dataGrid2_Click);

            graphPane2.XAxisTicCount = 10;
            graphPane2.YAxisTicCount = 4;
            graphPane2.YAxisMax      = 5;
            graphPane2.YAxisMin      = -5;
            graphPane2.YAxisTitle    = "PPM";
            graphPane2.XAxisTicCount = 10;
        }
Beispiel #9
0
        public void InitDisplay()
        {
            if (!(Rs is RsInfo))
            {
                return;
            }
            lbl_rs_pos.Text   = StringResource.str("standard") + "@" + StringResource.str("channel") + Rs.iChan.ToString();
            btn_rvalue.Label  = Util.FormatData(Rs.dValue, 7);
            btn_ralpha.Label  = Rs.dAlpha.ToString("F2");
            btn_rbeta.Label   = Rs.dBeta.ToString("F2");
            btn_maxcurr.Label = Rs.dMaxCurr.ToString("F2");
            btn_serial.Label  = Rs.sSerial;

            btn_prbtype.Label = Rs.sPTType;

            btn_rtp.Visible = btn_coefa.Visible = btn_coefb.Visible = btn_coefc.Visible = btn_range.Visible = Rs.bTempProbe;
            lbl_rtp.Visible = lbl_coefA.Visible = lbl_coefB.Visible = lbl_coefC.Visible = lbl_range.Visible = Rs.bTempProbe;

            btn_rtp.Label   = Rs.dRtp.ToString();
            btn_coefa.Label = Rs.dCoefA.ToString();
            btn_coefb.Label = Rs.dCoefB.ToString();
            btn_coefc.Label = Rs.dCoefC.ToString();
            btn_range.Label = Util.FindStringValue((int)Rs.tRange, StringResource.str("lst_range"));

            btn_enable.bOn = Rs.bEnabled;
            if (Rs.bEnabled)
            {
                btn_enable.Label = Util.FindStringValue(1, StringResource.str("lst_enable"));
            }
            else
            {
                btn_enable.Label = Util.FindStringValue(0, StringResource.str("lst_enable"));
            }

            this.Invalidate();
        }
Beispiel #10
0
 void btn_date_ValidClick(object sender, EventArgs e)
 {
     Program.kbd.Init(StringResource.str("enter_newdate"), "newdate", false, KbdData);
 }
Beispiel #11
0
        public RunWnd()
        {
            InitializeComponent();

            runstate            = new RunState();
            task                = new TaskMachine();
            task.StatusChanged += new StrEventHandler(UpdateStatusBar);
            uiTimer             = new System.Windows.Forms.Timer();
            uiTimer.Tick       += new EventHandler(uiTimer_Tick);
            uiTimer.Interval    = 250; //250ms for UI update
            uiTimer.Enabled     = true;;

            #region set status bar style
            SetButtonType(btn_aux1, StringResource.str("val_" + aux1_mode.ToString().ToLower()));
            SetButtonType(btn_aux2, StringResource.str("val_" + aux2_mode.ToString().ToLower()));
            SetButtonType(btn_bigdisp, StringResource.str("val_" + bigdisp_mode.ToString().ToLower()));
            btn_menu.Enabled = true;
            SetButtonType(btn_menu, "menu");
            btn_menu.ValidClick += new EventHandler((o, e) => {
                if (task.bRunning || task.bPaused)
                {
                    statusBar1_PauseResumeClick(o, e);
                }
                else
                {
                    Program.SwitchWindow("mainconfig");
                }
            });

            btn_dispchan.Enabled = true;
            SetButtonType(btn_dispchan, "CH1");
            graphPane2.channels      = new string[] { "1" };
            btn_dispchan.ValidClick += new EventHandler((o, e) => {
                if (StringResource.str("lst_rxchan").Trim(new char[] { '|' }).IndexOf('|') > 0)
                {
                    ChoiceWnd.Init(StringResource.str("choose") + StringResource.str("channel"),
                                   "dispchan",
                                   StringResource.str("lst_rxchan").Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries),
                                   -1,
                                   null,
                                   KbdData);
                }
            });

            btn_dispmode.Enabled = true;
            SetButtonType(btn_dispmode, StringResource.str("disp_graph"));
            btn_dispmode.ValidClick += new EventHandler((o, e) =>
            {
                if (Program.sysinfo.iDispMode == RXDISP_MODE.GRID)
                {
                    Program.sysinfo.iDispMode = RXDISP_MODE.GRAPH;
                }
                else
                {
                    Program.sysinfo.iDispMode = RXDISP_MODE.GRID;
                }
                btn_dispmode.Invalidate();
                ReDraw(true);
            });
            #endregion
            bt_run.Text   = StringResource.str("start");
            bt_run.Click += new EventHandler((o, e) =>
            {
                statusBar1_StartStopClick(o, e);
            });


            SetGridStyle();

            AddValue("1", 1, 1.000000, 0, 0);
            AddValue("1", 2, 1.000002, 0, 0);
            AddValue("1", 3, 1.000001, 0, 0);
            PointPair.datamode = RXDATA_MODE.RX;
            graphPane2.Invalidate();

            this.Load += new EventHandler(RunWnd_Load);
        }
Beispiel #12
0
 void btn_ktt_ValidClick(object sender, EventArgs e)
 {
     Program.kbd.Init(StringResource.str("enter_ktt"), "ktt", false, KbdData);
 }
Beispiel #13
0
 static void SetConnection()
 {
     sql_con = new SQLiteConnection("Data Source=" + Path.Combine(StringResource.str("basedir"), "Config.db2") + ";Version=3;New=False;Compress=True;");
 }
Beispiel #14
0
        void input_GotFocus(object sender, EventArgs e)
        {
            string regname = (sender as RectButton).Name.Replace("btn_", ""); //remove btn_

            Program.kbd.Init(StringResource.str("enter_" + regname), regname, false, KbdData);
        }
Beispiel #15
0
        public void KbdData(string param, string data)
        {
            try
            {
                if (param == "newtime")
                {
                    if (!Regex.IsMatch(newdate, "^\\d\\d\\d\\d\\d\\d\\d\\d$"))
                    {
                        MsgDlg.Show("日期格式不正确, 请按格式20120131输入");
                        return;
                    }

                    if (!Regex.IsMatch(data, "^\\d\\d\\d\\d\\d\\d$"))
                    {
                        MsgDlg.Show("时间格式不正确, 请按格式235959输入");
                        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")
                {
                    newdate = data;
                    this.Invoke(new Action(() =>
                    {
                        kbdWnd.Init(StringResource.str("enter_newdate"), "newdata", false, KbdData);
                    }));
                    return;
                }
                if (param == "ktt")
                {
                    Program.sysinfo.iKTT = Convert.ToInt32(data);
                }
                if (param == "measdelay")
                {
                    Program.sysinfo.iMeasDelay = Convert.ToInt32(data);
                }
                if (param == "sampletimes")
                {
                    Program.sysinfo.iSampleTimes = Convert.ToInt32(data);
                }
                if (param == "meastimes")
                {
                    Program.sysinfo.iMeasTimes = Convert.ToInt32(data);
                }
                if (param == "shifttimes")
                {
                    Program.sysinfo.iShiftTimes = Convert.ToInt32(data);
                }
                if (param == "fltlength")
                {
                    Program.sysinfo.iFilter = Convert.ToInt32(data);
                }
                if (param == "flttype")
                {
                    Program.sysinfo.sFilterType = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }
                if (param == "navmeter")
                {
                    Program.sysinfo.sNavmeter = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }
                if (param == "rsscanner")
                {
                    Program.sysinfo.sRsscanner = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }
                if (param == "rxscanner")
                {
                    Program.sysinfo.sRxscanner = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
                }

                if (param == "throw")
                {
                    Program.sysinfo.bThrow = !Program.sysinfo.bThrow;
                }
                InitDisplay();
            }
            catch
            {
                MsgDlg.Show("数据格式不正确。");
            }
        }
Beispiel #16
0
        public RxConfigWnd()
        {
            InitializeComponent();


            btn_quit.Text        = StringResource.str("quit");
            btn_quit.BackColor   = this.BackColor;
            btn_quit.Style       = MyButtonType.roundButton;
            btn_quit.ValidClick += new EventHandler((s, e) =>
            {
                if (!Rx.bEnabled)
                {
                    Rx.bSelected = false;
                }
                Program.SwitchWindow("mainconfig");
                //Program.mainwnd.Invoke(new Action<bool>(Program.mainwnd.ReDraw), new object[] { false });
            });


            RectButton[] kbdbtns = new RectButton[] { btn_measdelay, btn_meastimes, btn_rtp, btn_coefa, btn_coefb, btn_coefc, btn_serial };
            //keyboard input buttons
            foreach (RectButton rb in kbdbtns)
            {
                rb.Style     = MyButtonType.rectButton;
                rb.BackColor = this.BackColor;

                Label lbl = this.Controls.Find(rb.Name.Replace("btn_", "lbl_"), true)[0] as Label;
                lbl.Text = StringResource.str(lbl.Name.Replace("lbl_", ""));

                rb.ValidClick += new EventHandler((s, e) =>
                {
                    string regname = (s as Control).Name.Remove(0, 4);
                    kbdWnd.Init(StringResource.str("input") + StringResource.str(regname), regname, false, KbdData);
                });
            }

            //choice buttons
            RectButton[] choicebtns = new RectButton[] { btn_prbtype, btn_current, btn_range, btn_serial_select };
            foreach (RectButton rb in choicebtns)
            {
                rb.Style     = MyButtonType.rectButton;
                rb.BackColor = this.BackColor;

                Label lbl = this.Controls.Find(rb.Name.Replace("btn_", "lbl_"), true)[0] as Label;
                lbl.Text = StringResource.str(lbl.Name.Replace("lbl_", ""));

                rb.ValidClick += new EventHandler((s, e) =>
                {
                    string regname = (s as Control).Name.Remove(0, 4);
                    ChoiceWnd.Init(StringResource.str("choose") + StringResource.str(regname),
                                   regname,
                                   StringResource.str("lst_" + regname).Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries),
                                   0, null, KbdData);
                });
            }

            //toggle buttons
            RectButton[] togglebtns = new RectButton[] { btn_sqrt, btn_enable };
            foreach (RectButton rb in togglebtns)
            {
                rb.Style     = MyButtonType.rectButton;
                rb.BackColor = this.BackColor;

                //Label lbl = this.Controls.Find(rb.Name.Replace("btn_", "lbl_"), true)[0] as Label;
                //lbl.Text = StringResource.str(lbl.Name.Replace("lbl_", ""));

                rb.ValidClick += new EventHandler((s, e) =>
                {
                    string regname = (s as Control).Name.Remove(0, 4);
                    KbdData(regname, "");
                });
            }

            InitDisplay();
        }
Beispiel #17
0
 public void enterscale(string type)
 {
     Program.kbd.Init(StringResource.str("enter_" + type + "B") + "," + RunWnd.syscfg.GetScaleAdjust(ActionMgr.ConvertToRange(type)).ToString("F3"), "scale" + type, false, KbdData);
 }
Beispiel #18
0
        static public void MessageHandler()
        {
            Reset();
            Loaded = true;
            while (true)
            {
                if (msg_action == "")
                {
                    Thread.Sleep(10);
                    continue;
                }
                if (DateTime.Now > msg_deaddate)
                {
                    IsTimeOut  = true;
                    msg_action = "";
                    continue;
                }
                if (msg_action == "navread" && reading > MIN_READING)
                {
                    msg_action = "";
                    continue;
                }
                try
                {
                    #region navmeter action

                    if (msg_action == "navto1v" || msg_action == "navto120mv" || msg_action == "navto10mv")
                    {
                        if (msg_action == "navto1v")
                        {
//                            port.Write(NAV_INIT); //init
                            port.Write(StringResource.str("NAV_1V_" + Program.sysinfo.sNavmeter)); //1v
//                            DelayWrite(NAV_AFLTON); //slowmode and aflton
                        }
                        if (msg_action == "navto120mv")
                        {
                            port.Write(StringResource.str("NAV_120MV_" + Program.sysinfo.sNavmeter)); //120mv
                        }
                        if (msg_action == "navto10mv")
                        {
                            port.Write(StringResource.str("NAV_10MV_" + Program.sysinfo.sNavmeter)); //10mv
                        }
                        continue;
                    }
                    if (msg_action == "navread")
                    {
                        reading = INVALID_READING;
                        port.DiscardInBuffer();
                        port.Write(StringResource.str("NAV_READ_" + Program.sysinfo.sNavmeter)); //1v
                        continue;
                    }
                    if (msg_action == "turnk")
                    {
                        KState(msg_value);
                        continue;
                    }
                    if (msg_action.StartsWith("MEAS"))
                    {
                        string[] cmd = msg_action.Split(new char[] { '|' });
                        if (cmd.Length >= 6)
                        {
                            RelayState(cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5]);
                        }
                        continue;
                    }
                    #endregion
                    throw new Exception("Invalide command " + msg_action);
                }
                catch (Exception ex)
                {
                    Debug.WriteLine(ex.Message);
                    IsTimeOut  = true;
                    msg_action = "";
                }
            }
        }
Beispiel #19
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
            {
            }
        }
Beispiel #20
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 #21
0
        public RxConfigWnd()
        {
            InitializeComponent();
            btn_current.SetStyle(Color.White, MyButtonType.round2RectButton);
            btn_serial.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_stdchan.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_sqrt.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_vmode.SetStyle(Color.White, MyButtonType.round2RectButton);
            btn_last.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_next.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_vname.SetStyle(Color.Beige, MyButtonType.round2RectButton);

            btn_vname.ValidClick += new EventHandler(input_GotFocus);

            btn_vmode.Visible = false;
            lbl_vmode.Visible = false;

            lbl_vname.Text = StringResource.str("vname");

//          btn_current.ValidClick += new EventHandler(input_GotFocus);
            btn_serial.ValidClick  += new EventHandler(input_GotFocus);
            btn_stdchan.ValidClick += new EventHandler(input_GotFocus);
//          btn_vmode.ValidClick += new EventHandler(btn_vmode_ValidClick);
            btn_sqrt.ValidClick += new EventHandler(btn_sqrt_ValidClick);

            btn_last.ValidClick += new EventHandler(btn_last_ValidClick);
            btn_next.ValidClick += new EventHandler(btn_next_ValidClick);

            lbl_current.Text = StringResource.str("current");
            lbl_serial.Text  = StringResource.str("serial");
            lbl_stdchan.Text = StringResource.str("stdchan");
            lbl_vmode.Text   = StringResource.str("vmode");

            btn_last.Text = "<";
            btn_next.Text = ">";

            //no channel select for Rx channel
            selectedRx          = 0;
            btn_last.Visible    = false;
            btn_next.Visible    = false;
            btn_stdchan.Visible = false;
            lbl_stdchan.Visible = false;
            btn_enable.Visible  = false;

            btn_chan.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_chan.ValidClick += new EventHandler(btn_dummy);

            btn_enable.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_enable.ValidClick += new EventHandler(btn_enable_ValidClick);

            btn_quit.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_quit.Text        = StringResource.str("quit");
            btn_quit.ValidClick += new EventHandler(btn_quit_ValidClick);

            btn_RsConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_RsConfig.Text        = StringResource.str("rsconfig");
            btn_RsConfig.ValidClick += new EventHandler(btn_RsConfig_ValidClick);

            btn_RxConfig.SetStyle(Color.LightBlue, MyButtonType.round2RectButton);
            btn_RxConfig.Text        = StringResource.str("rxconfig");
            btn_RxConfig.ValidClick += new EventHandler(btn_RxConfig_ValidClick);

            btn_SysConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_SysConfig.Text        = StringResource.str("sysconfig");
            btn_SysConfig.ValidClick += new EventHandler(btn_SysConfig_ValidClick);
        }
Beispiel #22
0
        public static extern bool SetLocalTime(ref SystemTime sysTime); //设置本地时

        public SysConfigWnd()
        {
            InitializeComponent();
            lbl_sysconfig.Text   = StringResource.str("sysconfig");
            btn_quit.Text        = StringResource.str("quit");
            btn_quit.BackColor   = this.BackColor;
            btn_quit.Style       = MyButtonType.roundButton;
            btn_quit.ValidClick += new EventHandler((s, e) =>
            {
                Program.SwitchWindow("mainwnd");
                Program.mainwnd.Invoke(new Action <bool>(Program.mainwnd.ReDraw), new object[] { false });
            });
            RectButton[] kbdbtns = new RectButton[] { btn_ktt, btn_measdelay, btn_meastimes, btn_shifttimes, btn_newdate, btn_sampletimes, btn_fltlength };
            //keyboard input buttons
            foreach (RectButton rb in kbdbtns)
            {
                rb.Style     = MyButtonType.rectButton;
                rb.colorTop  = Color.Beige;
                rb.BackColor = this.BackColor;

                Label lbl = this.Controls.Find(rb.Name.Replace("btn_", "lbl_"), true)[0] as Label;
                lbl.Text = StringResource.str(lbl.Name.Replace("lbl_", ""));

                rb.ValidClick += new EventHandler((s, e) =>
                {
                    string regname = (s as Control).Name.Remove(0, 4);
                    kbdWnd.Init(StringResource.str("input") + StringResource.str(regname), regname, false, KbdData);
                });
            }

            //choice buttons
            RectButton[] choicebtns = new RectButton[] { btn_flttype, btn_navmeter, btn_rxscanner, btn_rsscanner };
            foreach (RectButton rb in choicebtns)
            {
                rb.Style     = MyButtonType.rectButton;
                rb.colorTop  = Color.Beige;
                rb.BackColor = this.BackColor;

                Label lbl = this.Controls.Find(rb.Name.Replace("btn_", "lbl_"), true)[0] as Label;
                lbl.Text = StringResource.str(lbl.Name.Replace("lbl_", ""));

                rb.ValidClick += new EventHandler((s, e) => {
                    string regname = (s as Control).Name.Remove(0, 4);
                    ChoiceWnd.Init(StringResource.str("choose") + StringResource.str(regname),
                                   regname,
                                   StringResource.str("lst_" + regname).Split(new char[] { '|' }, StringSplitOptions.RemoveEmptyEntries),
                                   0, null, KbdData);
                });
            }

            //toggle buttons
            RectButton[] togglebtns = new RectButton[] { btn_throw };
            foreach (RectButton rb in togglebtns)
            {
                rb.Style     = MyButtonType.rectButton;
                rb.colorTop  = Color.Beige;
                rb.BackColor = this.BackColor;

                Label lbl = this.Controls.Find(rb.Name.Replace("btn_", "lbl_"), true)[0] as Label;
                lbl.Text = StringResource.str(lbl.Name.Replace("lbl_", ""));

                rb.ValidClick += new EventHandler((s, e) =>
                {
                    string regname = (s as Control).Name.Remove(0, 4);
                    KbdData(regname, "");
                });
            }

            InitDisplay();
        }
Beispiel #23
0
 public void EnterNewTime()
 {
     Program.kbd.Init(StringResource.str("enter_newtime"), "newtime", false, KbdData);
 }
Beispiel #24
0
 public void KbdData(string param, string data)
 {
     try
     {
         if (param == "current")
         {
             Rx.iIx = Convert.ToInt32(data);
         }
         if (param == "serial")
         {
             Rx.sSerial = data;
         }
         if (param == "serial_select")
         {
             //todo
         }
         if (param == "enable")
         {
             Rx.bEnabled = !Rx.bEnabled;
         }
         if (param == "sqrt")
         {
             Rx.bSqrt = !Rx.bSqrt;
         }
         if (param == "prbtype")
         {
             Rx.sPTType = Util.FindStringValue(Int32.Parse(data), StringResource.str("lst_" + param));
         }
         if (param == "range")
         {
             Rx.tRange = (TempRange)Convert.ToInt32(data);
         }
         if (param == "measdelay")
         {
             Rx.iMeasDelay = Convert.ToInt32(data);
         }
         if (param == "meastimes")
         {
             Rx.iMeasTimes = Convert.ToInt32(data);
         }
         if (param == "rtp")
         {
             Rx.dRtp = Convert.ToDouble(data);
         }
         if (param == "ceofa")
         {
             Rx.dCoefA = Convert.ToDouble(data);
         }
         if (param == "ceofb")
         {
             Rx.dCoefB = Convert.ToDouble(data);
         }
         if (param == "ceofc")
         {
             Rx.dCoefC = Convert.ToDouble(data);
         }
         InitDisplay();
     }
     catch
     {
     }
 }
Beispiel #25
0
 public void entercurrent(string type)
 {
     Program.kbd.Init(StringResource.str("enter_" + type + "A"), type, false, KbdData);
 }
Beispiel #26
0
        public RxConfigWnd()
        {
            InitializeComponent();

            /*
             * btn_current.SetStyle(Color.White, MyButtonType.round2RectButton);
             * btn_serial.SetStyle(Color.Beige, MyButtonType.roundRectButton);
             * btn_stdchan.SetStyle(Color.Beige, MyButtonType.roundRectButton);
             * btn_sqrt.SetStyle(Color.Beige, MyButtonType.roundRectButton);
             * btn_vmode.SetStyle(Color.White, MyButtonType.round2RectButton);
             * btn_last.SetStyle(Color.Beige, MyButtonType.round2RectButton);
             * btn_next.SetStyle(Color.Beige, MyButtonType.round2RectButton);
             *
             * btn_ch1.SetStyle(Color.Beige, MyButtonType.round2Button);
             * btn_ch2.SetStyle(Color.Beige, MyButtonType.round2Button);
             * btn_ch3.SetStyle(Color.Beige, MyButtonType.round2Button);
             * btn_ch4.SetStyle(Color.Beige, MyButtonType.round2Button);
             */
            btn_vmode.Visible  = false;
            lbl_vmode.Visible  = false;
            lbl_range.Text     = StringResource.str("rrange");
            btn_rangeP001.Text = "0.001";
            btn_rangeP01.Text  = "0.01";
            btn_rangeP1.Text   = "0.1";
            btn_range1.Text    = "1";
            btn_range10.Text   = "10";
            btn_range100.Text  = "100";
            btn_range1k.Text   = "1k";
            btn_range10k.Text  = "10k";
            btn_range100k.Text = "100k";

/*
 *          btn_rangeP001.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_rangeP01.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_rangeP1.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_range1.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_range10.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_range100.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_range1k.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_range10k.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_range100k.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 */
            btn_rangeP001.ValidClick += new EventHandler(btn_rangeP001_ValidClick);
            btn_rangeP01.ValidClick  += new EventHandler(btn_rangeP01_ValidClick);
            btn_rangeP1.ValidClick   += new EventHandler(btn_rangeP1_ValidClick);
            btn_range1.ValidClick    += new EventHandler(btn_range1_ValidClick);
            btn_range10.ValidClick   += new EventHandler(btn_range10_ValidClick);
            btn_range100.ValidClick  += new EventHandler(btn_range100_ValidClick);
            btn_range1k.ValidClick   += new EventHandler(btn_range1k_ValidClick);
            btn_range10k.ValidClick  += new EventHandler(btn_range10k_ValidClick);
            btn_range100k.ValidClick += new EventHandler(btn_range100k_ValidClick);


//            btn_current.ValidClick += new EventHandler(input_GotFocus);
            btn_serial.ValidClick  += new EventHandler(input_GotFocus);
            btn_stdchan.ValidClick += new EventHandler(input_GotFocus);
//            btn_vmode.ValidClick += new EventHandler(btn_vmode_ValidClick);
            btn_sqrt.ValidClick += new EventHandler(btn_sqrt_ValidClick);

            btn_last.ValidClick += new EventHandler(btn_last_ValidClick);
            btn_next.ValidClick += new EventHandler(btn_next_ValidClick);

            lbl_current.Text = StringResource.str("current");
            lbl_serial.Text  = StringResource.str("serial");
            lbl_stdchan.Text = StringResource.str("stdchan");
            lbl_vmode.Text   = StringResource.str("vmode");

            btn_last.Text = "<";
            btn_next.Text = ">";

            //no channel select for Rx channel
            selectedRx          = 0;
            btn_last.Visible    = false;
            btn_next.Visible    = false;
            btn_stdchan.Visible = false;
            lbl_stdchan.Visible = false;
            btn_enable.Visible  = false;

/*
 *          btn_chan.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_chan.ValidClick += new EventHandler(btn_dummy);
 *
 *          btn_enable.SetStyle(Color.Beige, MyButtonType.roundRectButton);
 *          btn_enable.ValidClick +=new EventHandler(btn_enable_ValidClick);
 *
 *          btn_quit.SetStyle(Color.Beige, MyButtonType.round2Button);
 *          btn_quit.Text = StringResource.str("quit");
 *          btn_quit.ValidClick += new EventHandler(btn_quit_ValidClick);
 *
 *          btn_RsConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_RsConfig.Text = StringResource.str("rsconfig");
 *          btn_RsConfig.ValidClick += new EventHandler(btn_RsConfig_ValidClick);
 *
 *          btn_RxConfig.SetStyle(Color.LightBlue, MyButtonType.round2RectButton);
 *          btn_RxConfig.Text = StringResource.str("rxconfig");
 *          btn_RxConfig.ValidClick += new EventHandler(btn_RxConfig_ValidClick);
 *
 *          btn_SysConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
 *          btn_SysConfig.Text = StringResource.str("sysconfig");
 *          btn_SysConfig.ValidClick += new EventHandler(btn_SysConfig_ValidClick);
 */
        }
Beispiel #27
0
        public RsConfigWnd()
        {
            InitializeComponent();
            btn_RsConfig.SetStyle(Color.LightBlue, MyButtonType.round2RectButton);
            btn_RsConfig.Text        = StringResource.str("rsconfig");
            btn_RsConfig.ValidClick += new EventHandler(btn_RsConfig_ValidClick);

            btn_RxConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_RxConfig.Text        = StringResource.str("rxconfig");
            btn_RxConfig.ValidClick += new EventHandler(btn_RxConfig_ValidClick);

            btn_quit.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_chan.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_next.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_last.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_serial.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_rvalue.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_ralpha.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_rbeta.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_temp.SetStyle(Color.Beige, MyButtonType.roundRectButton);

            btn_quit.Text   = StringResource.str("quit");
            lbl_serial.Text = StringResource.str("serial");
            lbl_rvalue.Text = StringResource.str("rvalue");
            lbl_alpha.Text  = StringResource.str("ralpha");
            lbl_beta.Text   = StringResource.str("rbeta");
            lbl_temp.Text   = StringResource.str("temp");
            btn_last.Text   = "<";
            btn_next.Text   = ">";

            btn_quit.ValidClick   += new EventHandler(btn_quit_ValidClick);
            btn_chan.ValidClick   += new EventHandler(btn_dummy);
            btn_serial.ValidClick += new EventHandler(input_GotFocus);
            btn_rvalue.ValidClick += new EventHandler(input_GotFocus);
            btn_ralpha.ValidClick += new EventHandler(input_GotFocus);
            btn_rbeta.ValidClick  += new EventHandler(input_GotFocus);
            btn_temp.ValidClick   += new EventHandler(input_GotFocus);
            btn_last.ValidClick   += new EventHandler(btn_last_ValidClick);
            btn_next.ValidClick   += new EventHandler(btn_next_ValidClick);

            btn_SysConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_SysConfig.Text        = StringResource.str("sysconfig");
            btn_SysConfig.ValidClick += new EventHandler(btn_SysConfig_ValidClick);

            //no channel select for Rs channel
            selectedRs       = 0;
            btn_last.Visible = false;
            btn_next.Visible = false;

            btn_rs100k.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rs100k.Text        = "100k";
            btn_rs100k.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_100K); });

            btn_rs10k.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rs10k.Text        = "10k";
            btn_rs10k.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_10K); });

            btn_rs1k.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rs1k.Text        = "1k";
            btn_rs1k.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_1K); });

            btn_rs100.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rs100.Text        = "100";
            btn_rs100.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_100); });

            btn_rs10.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rs10.Text        = "10";
            btn_rs10.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_10); });

            btn_rs1.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rs1.Text        = "1";
            btn_rs1.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_1); });

            btn_rsp1.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rsp1.Text        = "0.1";
            btn_rsp1.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_P1); });

            btn_rsp01.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rsp01.Text        = "0.01";
            btn_rsp01.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_P01); });

            btn_rsp001.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_rsp001.Text        = "0.001";
            btn_rsp001.ValidClick += new EventHandler((o, e) => { SelectRange(ActionMgr.RNG_P001); });

            /*
             * rs_dt = new DataTable("RsInfo");
             * rs_dt.Columns.Add(StringResource.str("serial"));
             * rs_dt.Columns.Add(StringResource.str("rvalue"));
             * rs_dt.Columns.Add(StringResource.str("ralpha"));
             * rs_dt.Columns.Add(StringResource.str("rbeta"));
             *
             * dataGridView1.DataSource = rs_dt;
             * dataGridView1.Font = new System.Drawing.Font("Microsoft Sans Serif", 12F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
             * dataGridView1.CellDoubleClick += new DataGridViewCellEventHandler(dataGridView1_CellDoubleClick);
             *
             *         void dataGridView1_CellDoubleClick(object sender, DataGridViewCellEventArgs e)
             * {
             * MessageBox.Show(e.RowIndex.ToString() + "," + e.ColumnIndex.ToString());
             * }
             *
             *
             *
             *             rs_dt.Rows.Clear();
             * DataRow dr;
             * foreach (RsInfo rs in Program.lst_rsinfo)
             * {
             *  dr = rs_dt.NewRow();
             *  dr[0] = rs.sSerial;
             *  dr[1] = rs.dValue.ToString();
             *  dr[2] = rs.dAlpha.ToString();
             *  dr[3] = rs.dBeta.ToString();
             *  rs_dt.Rows.Add(dr);
             * }
             */
        }
Beispiel #28
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 #29
0
        static public void MessageHandler()
        {
            Reset();
            Loaded = true;
            while (true)
            {
                if (!WaitEvent.WaitOne(10, false))
                {
                    ScanPort();
                    continue;
                }
                WaitEvent.Reset();
                try
                {
                    #region navmeter action
                    ActMessage msg = DeviceMgr.actmsg;
                    if (msg.action == "navto30v" || msg.action == "navto1v" || msg.action == "navto120mv" || msg.action == "navto10mv")
                    {
                        if (msg.action == "navto1v")
                        {
//                            port.Write(NAV_INIT); //init
                            port.Write(StringResource.str("NAV_1V_" + RunWnd.syscfg.sNavmeter)); //1v
//                            DelayWrite(NAV_AFLTON); //slowmode and aflton
                        }
                        if (msg.action == "navto120mv")
                        {
                            port.Write(StringResource.str("NAV_120MV_" + RunWnd.syscfg.sNavmeter)); //120mv
                        }
                        if (msg.action == "navto10mv")
                        {
                            port.Write(StringResource.str("NAV_10MV_" + RunWnd.syscfg.sNavmeter)); //10mv
                        }
                        if (msg.action == "navto30v")
                        {
                            port.Write(StringResource.str("NAV_30V_" + RunWnd.syscfg.sNavmeter)); //10mv
                        }
                        Thread.Sleep(4000);
                        actmsg.action = "done";
                        OverEvent.Set();
                        continue;
                    }
                    if (msg.action == "navread")
                    {
                        reading = -9999;
                        port.DiscardInBuffer();
                        port.Write(StringResource.str("NAV_READ_" + RunWnd.syscfg.sNavmeter)); //1v
                        Thread.Sleep(5);
                        int timeout = 400;
                        while ((timeout-- > 0) && (reading < -9000))
                        {
                            ScanPort();
                            Thread.Sleep(5);
                        }
                        actmsg.action = "done";
                        OverEvent.Set();
                        continue;
                    }
                    if (msg.action == "turnk")
                    {
                        KState(msg.value);
                        actmsg.action = "done";
                        OverEvent.Set();
                        continue;
                    }
                    if (msg.action.StartsWith("MEAS"))
                    {
                        string[] cmd = msg.action.Split(new char[] { '|' });
                        if (cmd.Length == 6)
                        {
                            RelayState(cmd[0], cmd[1], cmd[2], cmd[3], cmd[4], cmd[5]);
                        }
                        actmsg.action = "done";
                        OverEvent.Set();
                        continue;
                    }
                    #endregion
                    if (actmsg.action != "")
                    {
                        throw new Exception("Invalid command " + actmsg.action);
                    }
                }
                catch (Exception ex)
                {
                    SysLog(ex.Message);
                    Debug.WriteLine(ex.Message);
                    actmsg.action = "fail";
                    OverEvent.Set();
                }
            }
        }
Beispiel #30
0
        public static extern bool SetLocalTime(ref SystemTime sysTime); //设置本地时

        public SysConfigWnd()
        {
            InitializeComponent();
            lbl_fltlength.Text   = StringResource.str("fltlength");
            lbl_measdelay.Text   = StringResource.str("measdelay");
            lbl_sampletimes.Text = StringResource.str("sampletimes");
            lbl_display.Text     = StringResource.str("displaymode");
            lbl_flttype.Text     = StringResource.str("filtertype");
            lbl_meastimes.Text   = StringResource.str("meastimes");
            lbl_throw.Text       = StringResource.str("autothrow");
            lbl_date.Text        = StringResource.str("date");
            lbl_ktt.Text         = StringResource.str("ktt");
            lbl_navmeter.Text    = StringResource.str("navmeter");

            btn_quit.SetStyle(Color.Beige, MyButtonType.round2Button);
            btn_quit.Text        = StringResource.str("quit");
            btn_quit.ValidClick += new EventHandler(btn_quit_ValidClick);

            btn_flttype.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_flttype.ValidClick += new EventHandler(btn_flttype_ValidClick);

            btn_display.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_display.ValidClick += new EventHandler(btn_display_ValidClick);
            lbl_display.Visible     = false;
            btn_display.Visible     = false;

            btn_ktt.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_ktt.ValidClick += new EventHandler(btn_ktt_ValidClick);


            btn_throw.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_throw.ValidClick += new EventHandler(btn_throw_ValidClick);


            btn_navmeter.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_navmeter.ValidClick += new EventHandler(btn_navmeter_ValidClick);

            btn_measdelay.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_measdelay.ValidClick += new EventHandler(input_GotFocus);

            btn_meastimes.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_meastimes.ValidClick += new EventHandler(input_GotFocus);

            btn_date.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_date.ValidClick += new EventHandler(btn_date_ValidClick);

            btn_sampletimes.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_sampletimes.ValidClick += new EventHandler(input_GotFocus);

            btn_fltlength.SetStyle(Color.Beige, MyButtonType.roundRectButton);
            btn_fltlength.ValidClick += new EventHandler(input_GotFocus);

            btn_RsConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_RsConfig.Text        = StringResource.str("rsconfig");
            btn_RsConfig.ValidClick += new EventHandler(btn_RsConfig_ValidClick);

            btn_RxConfig.SetStyle(Color.Beige, MyButtonType.round2RectButton);
            btn_RxConfig.Text        = StringResource.str("rxconfig");
            btn_RxConfig.ValidClick += new EventHandler(btn_RxConfig_ValidClick);

            btn_SysConfig.SetStyle(Color.LightBlue, MyButtonType.round2RectButton);
            btn_SysConfig.Text        = StringResource.str("sysconfig");
            btn_SysConfig.ValidClick += new EventHandler(btn_SysConfig_ValidClick);

            btn_export.SetStyle(Color.LightSeaGreen, MyButtonType.round2RectButton);
            btn_export.Text        = StringResource.str("export");
            btn_export.ValidClick += new EventHandler(btn_export_ValidClick);

            btn_throw.Visible    = false;
            lbl_throw.Visible    = false;
            btn_navmeter.Visible = false;
            lbl_navmeter.Visible = false;
            btn_flttype.Visible  = false;
            lbl_flttype.Visible  = false;

            FileInfo fi = new FileInfo(StringResource.basedir + "\\Tsioex.exe");

            lbl_version.Text = "版本: " + fi.CreationTime.ToString("yyyyMMdd");
            InitDisplay();
        }