Пример #1
0
        public Form1()
        {
            InitializeComponent();
            //ShowCursor(0);
            processor = new Processor();

            digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up };
            digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn };
            real_btns   = new RectButton[] { rbtn_real1, rbtn_real2, rbtn_real3, rbtn_real4, rbtn_real5, rbtn_real6, rbtn_real7, rbtn_real8, rbtn_real9, rbtn_real10,
                                             rbtn_real11, rbtn_real12, rbtn_real13, rbtn_real14, rbtn_real15 };
            dlg_choice = new ChoiceWnd();
            dlg_kbd    = new kbdWnd();
            range_btns = new RectButton[] { btn_rangeReal, btn_range0, btn_range1, btn_range2, btn_range3 };
            string[] range_string = new String[] { "实物电阻", "20mΩ", "200mΩ", "2Ω", "20Ω" };
            led_ohm.ColorLight      = Color.Red;
            led_ohm.ColorBackground = this.BackColor;
            led_ohm.ElementWidth    = 6;

            led_current.ColorLight      = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth    = 6;

            led_current.Value = "0.0000";

            btn_zeroon.BackColor   = this.BackColor;
            btn_zeroon.ForeColor   = Color.Bisque;
            btn_zeroon.Style       = MyButtonType.rectButton;
            btn_zeroon.Text        = "清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            btn_turnon.BackColor = this.BackColor;
            btn_turnon.colorTop  = Color.Green;
            btn_turnon.Style     = MyButtonType.roundButton;
            btn_turnon.Text      = "OFF";
            btn_turnon.Click    += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                {
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                }
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });


            tm          = new Timer();
            tm.Interval = 1000;
            tm.Tick    += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                processor.RefreshOutput();
                if (processor.Current > -999)
                {
                    UpdateCurrent(processor.Current);
                    processor.Current = -9999;
                }
            });
            tm.Enabled = true;
            tm.Start();
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }
Пример #2
0
        public Form1()
        {
            InitializeComponent();
            //ShowCursor(0);
            processor = new Processor();

            digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up };
            digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn };
            real_btns   = new RectButton[] { rbtn_real1, rbtn_real2, rbtn_real3, rbtn_real4, rbtn_real5, rbtn_real6, rbtn_real7, rbtn_real8, rbtn_real9, rbtn_real10,
                                             rbtn_real11, rbtn_real12, rbtn_real13, rbtn_real14, rbtn_real15 };
            dlg_choice = new ChoiceWnd();
            dlg_kbd    = new kbdWnd();
            range_btns = new RectButton[] { btn_rangeReal, btn_range0, btn_range1, btn_range2, btn_range3 };
            string[] range_string = new String[] { "实物电阻", "20mΩ", "200mΩ", "2Ω", "20Ω" };
            led_ohm.ColorLight      = Color.Red;
            led_ohm.ColorBackground = this.BackColor;
            led_ohm.ElementWidth    = 12;
            led_ohm.RecreateSegments(led_ohm.ArrayCount);
            led_current.ColorLight      = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth    = 8;
            led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value = "0.0000";

            btn_zeroon.bgColor = this.BackColor;
            btn_zeroon.SetStyle(Color.Bisque, MyButtonType.roundRectButton);
            btn_zeroon.Text        = "清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            btn_turnon.bgColor = this.BackColor;
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.triangleupButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                        RefreshDisplay(false);
                    }
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.trianglednButton);
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
                        RefreshDisplay(false);
                    }
                });
            }
            for (int i = 0; i < real_btns.Length; i++)
            {
                RectButton rb = real_btns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.roundButton);
                rb.Text        = Processor.real_title[i] + "Ω";
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    processor.iReal = NameInArray(o, real_btns);
                    RefreshDisplay(false);
                });
            }
            btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Text   = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                {
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                }
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });

            for (int i = 0; i < range_btns.Length; i++)
            {
                RectButton rb = range_btns[i];
                rb.bgColor = this.BackColor;
                rb.Text    = range_string[i];
                rb.SetStyle(Color.Green, MyButtonType.roundRectButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    int newrange = NameInArray(o, range_btns) - 1;
                    if (newrange == processor.iRange)
                    {
                        return;
                    }

                    processor.iRange = newrange;
                    RefreshDisplay(true);
                });
            }
            tm          = new Timer();
            tm.Interval = 500;
            tm.Tick    += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                processor.RefreshOutput();
                if (processor.Current > -999)
                {
                    UpdateCurrent(processor.Current);
                    processor.Current = -9999;
                }
            });
            tm.Enabled = true;
            tm.Start();
            led_ohm.Click += new EventHandler(led_ohm_Click);
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }
Пример #3
0
        public Form1()
        {
            DisablePowerSleep();
            InitializeComponent();
            label5.Text = "VERSION: 2014-09-27";
            //if(!(myBeep is Beep))
                myBeep = new Beep("PWM1:");
//          myBeep = new Beep("PWM4:");
            btn_capture.Click +=new EventHandler(btn_capture_Click);
            string mypath = Path.Combine(GlobalConfig.udiskdir2, "screen");
            if (Directory.Exists(mypath)) 
                btn_capture.Visible = true;
            Cursor.Hide();
            processor = new Processor();
            
            dlg_choice = new ChoiceWnd();
            dlg_kbd = new kbdWnd();
            led_rx.Value = "0.000000";
            led_rx.Click += new EventHandler((o,e)=>{
                DoBeep();
                dlg_choice.bNo0Choice = true;
                dlg_choice.param = "selectrx";
                dlg_choice.Init(StringResource.str("selectrx"), Processor._RxTitles, -1, null, new KbdDataHandler(KbdData));
            });

            led_rx.ColorLight = Color.Pink;
            led_rx.ColorDark = this.BackColor;
            led_rx.ColorBackground = this.BackColor;
            led_rx.ElementWidth = 12;
            led_rx.RecreateSegments(led_rx.ArrayCount);

            led_rs.ColorLight = Color.Black;
            led_rs.ColorDark = this.BackColor;
            led_rs.ColorBackground = this.BackColor;
            led_rs.ElementWidth = 10;
            led_rs.RecreateSegments(led_rs.ArrayCount);
            led_rs.Click += new EventHandler((o, e) =>
            {
                DoBeep();
                dlg_kbd.Init(String.Format(StringResource.str("inputrs"), Processor._RsTitles[processor.RsIndex]), "inputrs", false, new KbdDataHandler(KbdData));
            });

            led_vx.ColorLight = Color.Black;
            led_vx.ColorDark = this.BackColor;
            led_vx.ColorBackground = this.BackColor;
            led_vx.ElementWidth = 10;
            led_vx.RecreateSegments(led_vx.ArrayCount);
            led_vx.Value = "0.000";
            led_vx.Click += new EventHandler((o, e) =>
            {
                DoBeep();
                dlg_choice.bNo0Choice = true;
                dlg_choice.param = "selectvx";
                dlg_choice.Init(StringResource.str("selectvx"), Processor._MulTitles, - 1, null, new KbdDataHandler(KbdData));
            });

            
            led_es.ColorLight = Color.Black;
            led_es.ColorDark = this.BackColor;
            led_es.ColorBackground = this.BackColor;
            led_es.ElementWidth = 10;
            led_es.RecreateSegments(led_es.ArrayCount);
            led_es.Click += new EventHandler((o, e) =>
            {
                DoBeep();
                dlg_choice.bNo0Choice = true;
                dlg_choice.param = "selectes";
                dlg_choice.Init(StringResource.str("selectes"), Processor._EsTitles, -1, null, new KbdDataHandler(KbdData));
            });

            btn_hvout.BackColor = this.BackColor;
            btn_hvout.colorTop = Color.LightYellow;
            btn_hvout.Style = MyButtonType.rectButton;
            btn_hvout.Label = StringResource.str("hvout");
            btn_hvout.ValidClick += new EventHandler((o, e) =>
            {
                DoBeep();
                if (!processor.bDirectOutputOn)
                {
                    this.Invoke(new Action(() =>
                    {
                        dlg_choice.bNo0Choice = true;
                        dlg_choice.param = "selecthvport";
                        dlg_choice.Init(StringResource.str("selecthvport"), new string[] { "10 - 100V  端子输出", "100 - 1kV  端子输出", "500 - 5kV  端子输出", "1k - 10kV 端子输出" }, -1, null, new KbdDataHandler(KbdData));
                    }));
                }
                else
                {
                    processor.DirectOutputClose();
                    RefreshDisplay(true);
                }
                return;                
            });


            btn_zeroon.BackColor = this.BackColor;
            btn_zeroon.colorTop = Color.Bisque;
            btn_zeroon.Style = MyButtonType.rectButton;
            btn_zeroon.Label = StringResource.str("vxzero");

            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                DoBeep();
                processor.ZeroON2();
                if(btn_zeroon.colorTop != Color.LightSlateGray)
                    btn_zeroon.colorTop = Color.LightSlateGray;
                else
                    btn_zeroon.colorTop = Color.Bisque;
            });

            btn_zeroon2.BackColor = this.BackColor;
            btn_zeroon2.colorTop = Color.Bisque;
            btn_zeroon2.Style = MyButtonType.rectButton;
            btn_zeroon2.Label = StringResource.str("vgzero");

            btn_zeroon2.ValidClick += new EventHandler((o, e) =>
            {
                DoBeep();
                processor.ZeroON();
                if(btn_zeroon2.colorTop != Color.LightSlateGray)
                    btn_zeroon2.colorTop = Color.LightSlateGray;
                else
                    btn_zeroon2.colorTop = Color.Bisque;
            });


            btn_turnon.BackColor = this.BackColor;
            btn_turnon.colorTop = Color.Green;
            btn_turnon.Style = MyButtonType.roundButton;
            btn_turnon.Text = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                DoBeep();
                if (!processor.bOn)
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                processor.bOn = !processor.bOn;
                RefreshDisplay(true);
            });

            rectMeter1.BgResId = "BGMETER";
            DeviceMgr.Reset();
            processor.ToDAValue(0);
 
            tm = new Timer();
            tm.Interval = 500;
            tm.Tick += new EventHandler((o, e) =>
            {
                //lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    return;
                }
                dt_lastoutput = DateTime.Now;
                if (processor.bDirectOutputOn)
                {
                    DateTime.Now.AddSeconds(processor.RefreshDirectOutput());
                    string newv = processor.VxMeasure.ToString("F7").Substring(0, 6);
                    if (led_vx.Value != newv)
                    {
                        led_vx.Value = newv;
                        rectMeter1.Angle = processor.Percent;
                    }
                    if (processor.bDirectStable)
                    {
                        if (led_vx.ColorLight != Color.Red)
                            led_vx.ColorLight = Color.Red;
                    }
                    else
                    {
                        if (led_vx.ColorLight != Color.Orange)
                            led_vx.ColorLight = Color.Orange;
                    }


                }else if (processor.bOn)
                {
                    dt_lastoutput = DateTime.Now.AddSeconds(processor.RefreshOutput());
                    double v = Convert.ToDouble(processor.Rx) ;
                    string newv;
                    newv = Util.GMKFormat(ref v);
                    if(lbl_ohm.Text != newv)
                        lbl_ohm.Text = newv;

                    newv = v.ToString("F8").Substring(0, 7);
                    if (led_rx.Value != newv)
                    {
                        led_rx.Value = newv;
                    }
                    this.lbl_datetime.Text = processor.Vg.ToString() + "," +processor.Vx.ToString();
                    if (processor.bStable)
                    {
                        if (led_rx.ColorLight != Color.Red)
                            led_rx.ColorLight = Color.Red;
                    }
                    else
                    {
                        if (led_rx.ColorLight != Color.Pink)
                            led_rx.ColorLight = Color.Pink;
                    }


                    newv = processor.VxMeasure.ToString("F7").Substring(0, 6);
                    if(led_vx.Value != newv)
                    {
                        led_vx.Value = newv;
                        rectMeter1.Angle = processor.Percent;
                    }
                }
            });
            tm.Enabled = true;
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }
Пример #4
0
        public Form1()
        {
            InitializeComponent();
            s_scale               = this.label1.Text.Substring(0, this.label1.Text.IndexOf('A'));
            this.BackColor        = Color.LightSkyBlue;
            led_current.ColorDark = this.BackColor;
            led_setting.ColorDark = this.BackColor;
            btn_turnon.BackColor  = this.BackColor;
            rectMeter1.BackColor  = this.BackColor;
            btn_turnon.BackColor  = this.BackColor;
            rectMeter1.BgResId    = "BGMETER";
            //ShowCursor(0);
            processor = new Processor();
            data      = new StringBuilder(10);
            kbd_btns  = new RectButton[] { lbButton0, lbButton1, lbButton2, lbButton3, lbButton4, lbButton5, lbButton6, lbButton7, lbButton8, lbButton9,
                                           lbButtonCancel, lbButtonOK, lbButtonPT, lbButtonPercent };
            string[] btn_cap = "0,1,2,3,4,5,6,7,8,9,取消,确定,.,%".Split(new char[] { ',' });
            for (int i = 0; i < kbd_btns.Length; i++)
            {
                RectButton lbt = kbd_btns[i];
                lbt.BackColor   = Color.Transparent;
                lbt.colorTop    = Color.LightPink;
                lbt.colorShadow = Color.DarkGray;
                lbt.Label       = btn_cap[i];
                lbt.Style       = MyButtonType.raiseButton;
                lbt.Click      += new EventHandler((o, e) =>
                {
                    KeypadTick(NameInArray(o, kbd_btns));
                });
            }
            #region (NO USE) digi up and down

            /*
             * digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up  };
             * digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn  };
             * for (int i = 0; i < digi_upbtns.Length; i++)
             * {
             *  RectButton rb = digi_upbtns[i];
             *  rb.bgColor = this.BackColor;
             *  rb.SetStyle(Color.DarkOrange, MyButtonType.triangleupButton);
             *
             *  rb.ValidClick += new EventHandler((o, e) =>
             *  {
             *      if (processor.iRange >= 0)
             *      {
             *          TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
             *          RefreshDisplay(false);
             *      }
             *  });
             * }
             * for (int i = 0; i < digi_dnbtns.Length; i++)
             * {
             *  RectButton rb = digi_dnbtns[i];
             *  rb.bgColor = this.BackColor;
             *  rb.SetStyle(Color.DarkOrange, MyButtonType.trianglednButton);
             *  rb.ValidClick += new EventHandler((o, e) =>
             *  {
             *      if (processor.iRange >= 0)
             *      {
             *          TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
             *          RefreshDisplay(false);
             *      }
             *  });
             * }
             * */
            #endregion

            dlg_choice                  = new ChoiceWnd();
            dlg_kbd                     = new kbdWnd();
            led_setting.ColorLight      = Color.Red;
            led_setting.ColorBackground = this.BackColor;
            led_setting.ElementWidth    = 12;
//            led_setting.RecreateSegments(led_setting.ArrayCount);
            led_current.ColorLight      = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth    = 10;
//          led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value      = "0.0000";
            btn_zeroon.Style       = MyButtonType.rectButton;
            btn_zeroon.colorShadow = this.BackColor;
            btn_zeroon.colorTop    = Color.Bisque;
            btn_zeroon.Label       = "电流表清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            //btn_turnon.bgColor = this.BackColor;
            //btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Label  = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                {
                    dt_lastoutput = DateTime.Now.AddSeconds(0.5);
                }
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });

            tm          = new Timer();
            tm.Interval = 1000;
            tm.Tick    += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");

                /*
                 * if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                 * {
                 *  dt_lastoutput = DateTime.Now;
                 *  return;
                 * }*/
                if (data.Length == 0)
                {
                    processor.RefreshOutput();
                    if (processor.Current > -999)
                    {
                        UpdateCurrent(processor.Current);
                        processor.Current = -9999;
                    }
                }
            });
            tm.Enabled = true;
            tm.Start();
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }
Пример #5
0
        public Form1()
        {
            InitializeComponent();
            s_scale               = this.label1.Text.Substring(0, this.label1.Text.IndexOf("A"));
            s_scale               = s_scale.Replace("RT", "");
            scale                 = Decimal.Parse(s_scale);
            this.Load            += new EventHandler(Form1_Load);
            this.BackColor        = Color.LightSkyBlue;
            led_current.ColorDark = this.BackColor;
            led_setting.ColorDark = this.BackColor;
            btn_turnon.BackColor  = this.BackColor;
            btn_zeroon.BackColor  = this.BackColor;
            rectMeter1.BackColor  = this.BackColor;
            btn_turnon.BackColor  = this.BackColor;
            rectMeter1.BgResId    = "BGMETER";
            //ShowCursor(0);
            processor = new ProcessorPC();
            data      = new StringBuilder(10);
            kbd_btns  = new RectButton[] { lbButton0, lbButton1, lbButton2, lbButton3, lbButton4, lbButton5, lbButton6, lbButton7, lbButton8, lbButton9,
                                           lbButtonCancel, lbButtonOK, lbButtonPT, lbButtonPercent };
            string[] btn_cap = "0,1,2,3,4,5,6,7,8,9,取消,设定,.,%".Split(new char[] { ',' });
            for (int i = 0; i < kbd_btns.Length; i++)
            {
                RectButton lbt = kbd_btns[i];
                lbt.BackColor   = Color.Transparent;
                lbt.colorTop    = Color.LightPink;
                lbt.colorShadow = Color.DarkGray;
                lbt.Label       = btn_cap[i];
                lbt.Style       = MyButtonType.raiseButton;
                lbt.Click      += new EventHandler((o, e) =>
                {
                    this.Beep();
                    KeypadTick(NameInArray(o, kbd_btns));
                });
            }
            #region range switch
            rng_btns = new RectButton[] { rngbtn_1, rngbtn_10, rngbtn_100, rngbtn_300, rngbtn_600, rngbtn_1000 };

            for (int i = 0; i < rng_btns.Length; i++)
            {
                RectButton rb = rng_btns[i];
                rb.BackColor   = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop    = Color.LightGray;
                rb.Style       = MyButtonType.rectButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.bOn)
                    {
                        return;
                    }
                    processor.range = Int32.Parse((o as RectButton).Name.Remove(0, "rngbtn_".Length));
                    if (processor.setting > processor.range)
                    {
                        processor.setting = 0;
                    }
                    RefreshDisplay(false);
                    this.Beep();
                });
            }
            if (s_scale == "300")
            {
                this.rngbtn_1000.Visible = false;
                this.rngbtn_600.Visible  = false;
            }
            if (s_scale == "600")
            {
                this.rngbtn_1000.Visible = false;
            }
            if (s_scale == "1000")
            {
                this.rngbtn_1.Visible   = false;
                this.rngbtn_300.Visible = false;
                this.rngbtn_600.Visible = false;
                this.rngbtn_1000.Top    = this.rngbtn_300.Top;
            }
            #endregion
            #region digi up and down

            digi_upbtns = new RectButton[] { rbtn_up1, rbtn_up2, rbtn_up3, rbtn_up4, rbtn_up5, rbtn_up6, rbtn_up7 };
            digi_dnbtns = new RectButton[] { rbtn_dn1, rbtn_dn2, rbtn_dn3, rbtn_dn4, rbtn_dn5, rbtn_dn6, rbtn_dn7 };
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.BackColor   = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop    = Color.DarkOrange;

                rb.bgScale     = 3;
                rb.bOn         = true;
                rb.Style       = MyButtonType.triangleupButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                    RefreshDisplay(false);
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.BackColor   = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop    = Color.DarkOrange;

                rb.bgScale = 3;
                rb.bOn     = true;
                rb.Style   = MyButtonType.trianglednButton;

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
                    RefreshDisplay(false);
                });
            }

            #endregion

            dlg_choice                  = new ChoiceWnd();
            dlg_kbd                     = new kbdWnd();
            led_setting.ColorLight      = Color.DarkGreen;
            led_setting.ColorBackground = this.BackColor;
            led_setting.ElementWidth    = 10;
            //          led_setting.RecreateSegments(led_setting.ArrayCount);
            led_current.ColorLight      = Color.Red;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth    = 12;
            //          led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value      = "0.0000";
            btn_zeroon.Style       = MyButtonType.rectButton;
            btn_zeroon.colorShadow = this.BackColor;
            btn_zeroon.colorTop    = Color.Bisque;
            btn_zeroon.Label       = "电流表清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                this.Beep();
                led_current.Value = "     ";
                processor.ZeroON();
            });

            //btn_turnon.bgColor = this.BackColor;
            //btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Label  = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                this.Beep();
                dt_lastoutput       = DateTime.Now.AddSeconds(1);
                btn_turnon.colorTop = Color.LightYellow; //switching
            });

            tm          = new Timer();
            tm.Interval = 1000;
            tm.Tick    += new EventHandler((o, e) =>
            {
                foreach (RectButton btn in kbd_btns)
                {
                    if (!btn.IsButtonUp)
                    {
                        btn.IsButtonUp = true;
                    }
                }
                if (btn_turnon.colorTop == Color.LightYellow) //still booting up
                {
                    processor.bOn = !processor.bOn;
                    RefreshDisplay(true);
                    return;
                }
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                if (data.Length == 0)
                {
                    processor.RefreshOutput();
                    if (processor.Current > -999)
                    {
                        UpdateCurrent(processor.Current);
                        processor.Current = -9999;
                    }
                }
            });

            tm.Enabled = true;


            tm.Start();
            processor.Reset();
            RefreshDisplay(true);
            return;
        }
Пример #6
0
        public Form1()
        {
            InitializeComponent();
            s_scale = this.label1.Text.Substring(0, this.label1.Text.IndexOf('A'));
            this.BackColor = Color.LightSkyBlue;
            led_current.ColorDark = this.BackColor;
            led_setting.ColorDark = this.BackColor;
            btn_turnon.BackColor = this.BackColor;
            rectMeter1.BackColor = this.BackColor;
            btn_turnon.BackColor = this.BackColor;
            rectMeter1.BgResId = "BGMETER";
            //ShowCursor(0);
            processor = new Processor();
            data = new StringBuilder(10);
            kbd_btns = new RectButton[]{ lbButton0,lbButton1,lbButton2,lbButton3,lbButton4,lbButton5,lbButton6,lbButton7,lbButton8,lbButton9,
                lbButtonCancel,lbButtonOK,lbButtonPT,lbButtonPercent};
            string[] btn_cap = "0,1,2,3,4,5,6,7,8,9,取消,确定,.,%".Split(new char[] { ',' });
            for (int i = 0; i < kbd_btns.Length; i++)
            {
                RectButton lbt = kbd_btns[i];
                lbt.BackColor = Color.Transparent;
                lbt.colorTop = Color.LightPink;
                lbt.colorShadow = Color.DarkGray;
                lbt.Label = btn_cap[i];
                lbt.Style = MyButtonType.raiseButton;
                lbt.Click += new EventHandler((o, e) =>
                {
                        KeypadTick(NameInArray(o, kbd_btns));
                });
            }
            #region (NO USE) digi up and down
            /*
            digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up  };
            digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn  };
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.triangleupButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                        RefreshDisplay(false);
                    }
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.trianglednButton);
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
                        RefreshDisplay(false);
                    }
                });
            }
             * */
            #endregion

            dlg_choice = new ChoiceWnd();
            dlg_kbd = new kbdWnd();
            led_setting.ColorLight = Color.Red;
            led_setting.ColorBackground = this.BackColor;
            led_setting.ElementWidth = 12;
            //            led_setting.RecreateSegments(led_setting.ArrayCount);
            led_current.ColorLight = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth = 10;
            //          led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value = "0.0000";
            btn_zeroon.Style = MyButtonType.rectButton;
            btn_zeroon.colorShadow = this.BackColor;
            btn_zeroon.colorTop = Color.Bisque;
            btn_zeroon.Label = "电流表清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            //btn_turnon.bgColor = this.BackColor;
            //btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Label = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                    dt_lastoutput = DateTime.Now.AddSeconds(0.5);
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });

            tm = new Timer();
            tm.Interval = 1000;
            tm.Tick += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                /*
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }*/
                if (data.Length == 0)
                {
                    processor.RefreshOutput();
                    if (processor.Current > -999)
                    {
                        UpdateCurrent(processor.Current);
                        processor.Current = -9999;
                    }
                }
            });
            tm.Enabled = true;
            tm.Start();
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }
Пример #7
0
        public Form1()
        {
            InitializeComponent();
            s_scale = this.label1.Text.Substring(0, this.label1.Text.IndexOf("A"));
            s_scale = s_scale.Replace("RT", "");
            scale = Decimal.Parse(s_scale);
            this.Load += new EventHandler(Form1_Load);
            this.BackColor = Color.LightSkyBlue;
            led_current.ColorDark = this.BackColor;
            led_setting.ColorDark = this.BackColor;
            btn_turnon.BackColor = this.BackColor;
            btn_zeroon.BackColor = this.BackColor;
            rectMeter1.BackColor = this.BackColor;
            btn_turnon.BackColor = this.BackColor;
            rectMeter1.BgResId = "BGMETER";
            //ShowCursor(0);
            processor = new ProcessorPC();
            data = new StringBuilder(10);
            kbd_btns = new RectButton[]{ lbButton0,lbButton1,lbButton2,lbButton3,lbButton4,lbButton5,lbButton6,lbButton7,lbButton8,lbButton9,
                lbButtonCancel,lbButtonOK,lbButtonPT,lbButtonPercent};
            string[] btn_cap = "0,1,2,3,4,5,6,7,8,9,取消,设定,.,%".Split(new char[] { ',' });
            for (int i = 0; i < kbd_btns.Length; i++)
            {
                RectButton lbt = kbd_btns[i];
                lbt.BackColor = Color.Transparent;
                lbt.colorTop = Color.LightPink;
                lbt.colorShadow = Color.DarkGray;
                lbt.Label = btn_cap[i];
                lbt.Style = MyButtonType.raiseButton;
                lbt.Click += new EventHandler((o, e) =>
                {
                    this.Beep();
                    KeypadTick(NameInArray(o, kbd_btns));
                });
            }
            #region range switch
            rng_btns = new RectButton[] { rngbtn_1, rngbtn_10, rngbtn_100, rngbtn_300, rngbtn_600, rngbtn_1000 };

            for (int i = 0; i < rng_btns.Length; i++)
            {
                RectButton rb = rng_btns[i];
                rb.BackColor = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop = Color.LightGray;
                rb.Style = MyButtonType.rectButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.bOn)
                        return;
                    processor.range = Int32.Parse((o as RectButton).Name.Remove(0, "rngbtn_".Length));
                    if (processor.setting > processor.range)
                        processor.setting = 0;
                    RefreshDisplay(false);
                    this.Beep();
                });
            }
            if (s_scale == "300")
            {
                this.rngbtn_1000.Visible = false;
                this.rngbtn_600.Visible = false;
            }
            if (s_scale == "600")
            {
                this.rngbtn_1000.Visible = false;
            }
            if (s_scale == "1000")
            {
                this.rngbtn_1.Visible = false;
                this.rngbtn_300.Visible = false;
                this.rngbtn_600.Visible = false;
                this.rngbtn_1000.Top = this.rngbtn_300.Top;
            }
            #endregion
            #region digi up and down

            digi_upbtns = new RectButton[] { rbtn_up1, rbtn_up2, rbtn_up3, rbtn_up4, rbtn_up5, rbtn_up6, rbtn_up7 };
            digi_dnbtns = new RectButton[] { rbtn_dn1, rbtn_dn2, rbtn_dn3, rbtn_dn4, rbtn_dn5, rbtn_dn6, rbtn_dn7 };
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.BackColor = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop = Color.DarkOrange;

                rb.bgScale = 3;
                rb.bOn = true;
                rb.Style = MyButtonType.triangleupButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                    RefreshDisplay(false);
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.BackColor = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop = Color.DarkOrange;

                rb.bgScale = 3;
                rb.bOn = true;
                rb.Style = MyButtonType.trianglednButton;

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
                    RefreshDisplay(false);
                });
            }

            #endregion

            dlg_choice = new ChoiceWnd();
            dlg_kbd = new kbdWnd();
            led_setting.ColorLight = Color.DarkGreen;
            led_setting.ColorBackground = this.BackColor;
            led_setting.ElementWidth = 10;
            //          led_setting.RecreateSegments(led_setting.ArrayCount);
            led_current.ColorLight = Color.Red;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth = 12;
            //          led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value = "0.0000";
            btn_zeroon.Style = MyButtonType.rectButton;
            btn_zeroon.colorShadow = this.BackColor;
            btn_zeroon.colorTop = Color.Bisque;
            btn_zeroon.Label = "电流表清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                this.Beep();
                led_current.Value = "     ";
                processor.ZeroON();
            });

            //btn_turnon.bgColor = this.BackColor;
            //btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Label = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                this.Beep();
                dt_lastoutput = DateTime.Now.AddSeconds(1);
                btn_turnon.colorTop = Color.LightYellow; //switching
            });

            tm = new Timer();
            tm.Interval = 1000;
            tm.Tick += new EventHandler((o, e) =>
            {
                foreach (RectButton btn in kbd_btns)
                {
                    if (!btn.IsButtonUp)
                        btn.IsButtonUp = true;
                }
                if (btn_turnon.colorTop == Color.LightYellow) //still booting up
                {
                    processor.bOn = !processor.bOn;
                    RefreshDisplay(true);
                    return;
                }
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                if (data.Length == 0)
                {
                    processor.RefreshOutput();
                    if (processor.Current > -999)
                    {
                        UpdateCurrent(processor.Current);
                        processor.Current = -9999;
                    }
                }
            });

            tm.Enabled = true;

                tm.Start();
                processor.Reset();
                RefreshDisplay(true);
                return;
        }
Пример #8
0
        public Form1()
        {

            InitializeComponent();
            //ShowCursor(0);
            processor = new Processor();
            
            digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up  };
            digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn  };
            real_btns = new RectButton[] { rbtn_real1,rbtn_real2,rbtn_real3,rbtn_real4,rbtn_real5,rbtn_real6,rbtn_real7, rbtn_real8, rbtn_real9, rbtn_real10,
                                            rbtn_real11,rbtn_real12,rbtn_real13,rbtn_real14,rbtn_real15};
            dlg_choice = new ChoiceWnd();
            dlg_kbd = new kbdWnd();
            range_btns = new RectButton[] { btn_rangeReal, btn_range0, btn_range1, btn_range2, btn_range3 };
            string[] range_string = new String[] { "实物电阻", "20mΩ", "200mΩ", "2Ω", "20Ω" };
            led_ohm.ColorLight = Color.Red;
            led_ohm.ColorBackground = this.BackColor;
            led_ohm.ElementWidth = 6;
            
            led_current.ColorLight = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth = 6;
            
            led_current.Value = "0.0000";

            btn_zeroon.BackColor = this.BackColor;
            btn_zeroon.ForeColor = Color.Bisque;
            btn_zeroon.Style = MyButtonType.rectButton;            
            btn_zeroon.Text = "清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            btn_turnon.BackColor = this.BackColor;
            btn_turnon.colorTop = Color.Green;
            btn_turnon.Style = MyButtonType.roundButton;
            btn_turnon.Text = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });


            tm = new Timer();
            tm.Interval = 1000;
            tm.Tick += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                processor.RefreshOutput();
                if (processor.Current > -999)
                {
                    UpdateCurrent(processor.Current);
                    processor.Current = -9999;
                }
            });
            tm.Enabled = true;
            tm.Start();
            DeviceMgr.Reset();
            
            RefreshDisplay(true);
        }
Пример #9
0
        public Form1()
        {
            InitializeComponent();
            //ShowCursor(0);
            processor = new Processor();

            digi_upbtns = new RectButton[] { rbtn_1up, rbtn_2up, rbtn_3up, rbtn_4up, rbtn_5up, rbtn_6up  };
            digi_dnbtns = new RectButton[] { rbtn_1dn, rbtn_2dn, rbtn_3dn, rbtn_4dn, rbtn_5dn, rbtn_6dn  };
            real_btns = new RectButton[] { rbtn_real1,rbtn_real2,rbtn_real3,rbtn_real4,rbtn_real5,rbtn_real6,rbtn_real7, rbtn_real8, rbtn_real9, rbtn_real10,
                                            rbtn_real11,rbtn_real12,rbtn_real13,rbtn_real14,rbtn_real15};
            dlg_choice = new ChoiceWnd();
            dlg_kbd = new kbdWnd();
            range_btns = new RectButton[] { btn_rangeReal, btn_range0, btn_range1, btn_range2, btn_range3 };
            string[] range_string = new String[] { "实物电阻", "20mΩ", "200mΩ", "2Ω", "20Ω" };
            led_ohm.ColorLight = Color.Red;
            led_ohm.ColorBackground = this.BackColor;
            led_ohm.ElementWidth = 6;

            led_current.ColorLight = Color.DarkGreen;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth = 6;

            led_current.Value = "0.0000";

            btn_zeroon.bgColor = this.BackColor;
            btn_zeroon.SetStyle(Color.Bisque, MyButtonType.roundRectButton);
            btn_zeroon.Text = "清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                led_current.Value = "     ";
                processor.ZeroON();
            });

            btn_turnon.bgColor = this.BackColor;
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.triangleupButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                        RefreshDisplay(false);
                    }
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.trianglednButton);
                rb.ValidClick += new EventHandler((o,e)=>
                {
                    if (processor.iRange >= 0)
                    {
                        TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns) , false);
                        RefreshDisplay(false);
                    }
                });
            }
            for(int i = 0;i < real_btns.Length; i++)
            {
                RectButton rb = real_btns[i];
                rb.bgColor = this.BackColor;
                rb.SetStyle(Color.DarkOrange, MyButtonType.roundButton);
                rb.Text = Processor.real_title[i] + "Ω";
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    processor.iReal = NameInArray(o, real_btns);
                    RefreshDisplay(false);
                });
            }
            btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Text = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                if (!processor.bOn)
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                processor.bOn = !processor.bOn;
                RefreshDisplay(false);
            });

            for (int i = 0; i < range_btns.Length; i++)
            {
                RectButton rb = range_btns[i];
                rb.bgColor = this.BackColor;
                rb.Text = range_string[i];
                rb.SetStyle(Color.Green, MyButtonType.roundRectButton);

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    int newrange = NameInArray(o, range_btns)-1;
                    if( newrange == processor.iRange)
                        return;

                    processor.iRange = newrange;
                    RefreshDisplay(true);
                });
            }
            tm = new Timer();
            tm.Interval = 1000;
            tm.Tick += new EventHandler((o, e) =>
            {
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                processor.RefreshOutput();
                if (processor.Current > -999)
                {
                    UpdateCurrent(processor.Current);
                    processor.Current = -9999;
                }
            });
            tm.Enabled = true;
            tm.Start();
            led_ohm.Click += new EventHandler(led_ohm_Click);
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }
Пример #10
0
        public Form1()
        {
            DisablePowerSleep();
            text_allbtns["6000"] = new string[] { "", "", "", "", "", "" };
            text_allbtns["1000"] = new string[] { " 10 A", "100 A", "1000 A", "", "", "" };
            text_allbtns["600"]  = new string[] { "  1 A", " 10 A", "100 A", "300 A", "600 A", "" };
            text_allbtns["500"]  = new string[] { "  1 A", " 10 A", "100 A", "200 A", "300 A", "500 A" };
            text_allbtns["400"]  = new string[] { "  1 A", " 10 A", "100 A", "200 A", "300 A", "400 A" };
            text_allbtns["300"]  = new string[] { "  1 A", " 10 A", "100 A", "200 A", "300 A", "" };
            text_allbtns["200"]  = new string[] { "  1 A", " 10 A", "100 A", "200 A", "", "" };
            text_allbtns["100"]  = new string[] { "  1 A", " 10 A", "100 A", "", "", "" };
            InitializeComponent();
            myBeep = new Beep("PWM1:");

            //use a different way to check scale
            s_scale = "6000"; //default scale is 300


            if (File.Exists(Path.Combine(GlobalConfig.basedir, "1000.txt")))
            {
                s_scale = "1000";
            }
            foreach (string ss in scale_vals)
            {
                if (File.Exists(Path.Combine(GlobalConfig.basedir, ss + ".txt")))
                {
                    s_scale = ss;
                    break;
                }
            }
            string[] btn_texts = text_allbtns[s_scale];
            rngbtn_1.Label    = btn_texts[0];
            rngbtn_10.Label   = btn_texts[1];
            rngbtn_100.Label  = btn_texts[2];
            rngbtn_300.Label  = btn_texts[3];
            rngbtn_600.Label  = btn_texts[4];
            rngbtn_1000.Label = btn_texts[5];

            rngbtn_1.Visible    = (btn_texts[0] != "");
            rngbtn_10.Visible   = (btn_texts[1] != "");
            rngbtn_100.Visible  = (btn_texts[2] != "");
            rngbtn_300.Visible  = (btn_texts[3] != "");
            rngbtn_600.Visible  = (btn_texts[4] != "");
            rngbtn_1000.Visible = (btn_texts[5] != "");

            lbl_currscale.Visible = (s_scale != "6000");

            this.label3.Text = label3.Text.Replace("300", s_scale);

            /*
             * if (this.label3.Text.IndexOf("1000A") >= 0)
             *  s_scale = "1000";
             * else if (this.label3.Text.IndexOf("600A") >= 0)
             *  s_scale = "600";
             * else
             *  s_scale = "300";
             */
            scale                 = Decimal.Parse(s_scale);
            this.BackColor        = Color.LightSkyBlue;
            led_current.ColorDark = this.BackColor;
            led_setting.ColorDark = this.BackColor;
            btn_turnon.BackColor  = this.BackColor;
            btn_zeroon.BackColor  = this.BackColor;
            btn_ktt.BackColor     = this.BackColor;
            rectMeter1.BackColor  = this.BackColor;
            btn_turnon.BackColor  = this.BackColor;
            rectMeter1.BgResId    = "BGMETER";
            string mypath = Path.Combine(GlobalConfig.udiskdir2, "screen");

            if (Directory.Exists(mypath))
            {
                btn_capture.Visible = true;
            }
            Cursor.Hide();
            processor = new Processor();
            data      = new StringBuilder(10);

            kbd_btns = new RectButton[] { lbButton0, lbButton1, lbButton2, lbButton3, lbButton4, lbButton5, lbButton6, lbButton7, lbButton8, lbButton9,
                                          lbButtonCancel, lbButtonOK, lbButtonPT, lbButtonPercent };
            string[] btn_cap = "0,1,2,3,4,5,6,7,8,9,取消,设定,.,%".Split(new char[] { ',' });
            for (int i = 0; i < kbd_btns.Length; i++)
            {
                RectButton lbt = kbd_btns[i];
                lbt.BackColor   = Color.Transparent;
                lbt.colorTop    = Color.LightPink;
                lbt.colorShadow = Color.DarkGray;
                lbt.Label       = btn_cap[i];
                lbt.Style       = MyButtonType.raiseButton;
                lbt.Click      += new EventHandler((o, e) =>
                {
                    this.Beep();
                    KeypadTick(NameInArray(o, kbd_btns));
                });
            }
            #region range switch
            rng_btns = new RectButton[] { rngbtn_1, rngbtn_10, rngbtn_100, rngbtn_300, rngbtn_600, rngbtn_1000 };

            for (int i = 0; i < rng_btns.Length; i++)
            {
                RectButton rb = rng_btns[i];
                rb.BackColor   = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop    = Color.LightGray;
                rb.Style       = MyButtonType.rectButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.bOn)
                    {
                        return;
                    }

                    processor.range = Int32.Parse((o as RectButton).Label.Trim(new char[] { ' ', 'A' }));
                    if (processor.setting > processor.range)
                    {
                        processor.setting = 0;
                    }
                    RefreshDisplay(false);
                    this.Beep();
                });
            }
            #endregion
            #region digi up and down

            digi_upbtns = new RectButton[] { rbtn_up1, rbtn_up2, rbtn_up3, rbtn_up4, rbtn_up5, rbtn_up6, rbtn_up7 };
            digi_dnbtns = new RectButton[] { rbtn_dn1, rbtn_dn2, rbtn_dn3, rbtn_dn4, rbtn_dn5, rbtn_dn6, rbtn_dn7 };
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.BackColor   = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop    = Color.DarkOrange;

                rb.bgScale     = 3;
                rb.bOn         = true;
                rb.Style       = MyButtonType.triangleupButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                    RefreshDisplay(false);
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.BackColor   = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop    = Color.DarkOrange;

                rb.bgScale = 3;
                rb.bOn     = true;
                rb.Style   = MyButtonType.trianglednButton;

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
                    RefreshDisplay(false);
                });
            }

            #endregion

            dlg_choice                  = new ChoiceWnd();
            dlg_kbd                     = new kbdWnd();
            led_setting.ColorLight      = Color.DarkGreen;
            led_setting.ColorBackground = this.BackColor;
            led_setting.ElementWidth    = 10;
            //          led_setting.RecreateSegments(led_setting.ArrayCount);
            led_current.ColorLight      = Color.Red;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth    = 12;
            //          led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value      = "0.0000";
            btn_zeroon.Style       = MyButtonType.rectButton;
            btn_zeroon.colorShadow = this.BackColor;
            btn_zeroon.colorTop    = Color.Bisque;
            btn_zeroon.Label       = "电流表清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                this.Beep();
                led_current.Value = "     ";
                processor.ZeroON();
            });


            btn_ktt.Style  = MyButtonType.rectButton;
            btn_ktt.Label  = "电流换向";
            btn_ktt.bOn    = processor.bKTT;
            btn_ktt.Click += new EventHandler((o, e) =>
            {
                this.Beep();
                processor.bKTT = !processor.bKTT;
                btn_ktt.bOn    = processor.bKTT;
            });

            //btn_turnon.bgColor = this.BackColor;
            //btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Label  = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                this.Beep();
                dt_lastoutput       = DateTime.Now.AddSeconds(0.5);
                btn_turnon.colorTop = Color.LightYellow; //switching
            });

            tm          = new System.Windows.Forms.Timer();
            tm.Interval = 500;
            tm.Tick    += new EventHandler((o, e) =>
            {
                foreach (RectButton btn in kbd_btns)
                {
                    if (!btn.IsButtonUp)
                    {
                        btn.IsButtonUp = true;
                    }
                }
                if (btn_turnon.colorTop == Color.LightYellow) //still booting up
                {
                    processor.bOn = !processor.bOn;
                    RefreshDisplay(false);
                    return;
                }
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                if (data.Length == 0)
                {
                    processor.RefreshOutput();
                    if (processor.Current > -999)
                    {
                        UpdateCurrent(processor.Current);
                        processor.Current = -9999;
                    }
                }
            });
            tm.Enabled = true;
            processor.Reset();

            RefreshDisplay(true);
        }
Пример #11
0
        public Form1()
        {
            DisablePowerSleep();
            text_allbtns["6000"] = new string[] { "", "", "", "", "", "" };
            text_allbtns["1000"] = new string[] {" 10 A", "100 A", "1000 A", "","","" };
            text_allbtns["600"] = new string[] { "  1 A", " 10 A", "100 A", "300 A", "600 A", "" };
            text_allbtns["500"] = new string[] { "  1 A", " 10 A", "100 A", "200 A", "300 A", "500 A" };
            text_allbtns["400"] = new string[] { "  1 A", " 10 A", "100 A", "200 A", "300 A", "400 A" };
            text_allbtns["300"] = new string[] { "  1 A", " 10 A", "100 A", "200 A", "300 A", "" };
            text_allbtns["200"] = new string[] { "  1 A", " 10 A", "100 A", "200 A", "", "" };
            text_allbtns["100"] = new string[] { "  1 A", " 10 A", "100 A", "", "", "" };
            InitializeComponent();
            myBeep = new Beep("PWM1:");

            //use a different way to check scale
            s_scale = "6000"; //default scale is 300

            if (File.Exists(Path.Combine(GlobalConfig.basedir, "1000.txt")))
            {
                s_scale = "1000";
            }
            foreach (string ss in scale_vals)
            {
                if (File.Exists(Path.Combine(GlobalConfig.basedir, ss + ".txt")))
                {
                    s_scale = ss;
                    break;
                }
            }
            string[] btn_texts = text_allbtns[s_scale];
            rngbtn_1.Label = btn_texts[0];
            rngbtn_10.Label = btn_texts[1];
            rngbtn_100.Label = btn_texts[2];
            rngbtn_300.Label = btn_texts[3];
            rngbtn_600.Label = btn_texts[4];
            rngbtn_1000.Label = btn_texts[5];

            rngbtn_1.Visible = (btn_texts[0] != "");
            rngbtn_10.Visible = (btn_texts[1] != "");
            rngbtn_100.Visible = (btn_texts[2] != "");
            rngbtn_300.Visible = (btn_texts[3] != "");
            rngbtn_600.Visible = (btn_texts[4] != "");
            rngbtn_1000.Visible = (btn_texts[5] != "");

            lbl_currscale.Visible = (s_scale != "6000");

            this.label3.Text = label3.Text.Replace("300", s_scale);
            /*
            if (this.label3.Text.IndexOf("1000A") >= 0)
                s_scale = "1000";
            else if (this.label3.Text.IndexOf("600A") >= 0)
                s_scale = "600";
            else
                s_scale = "300";
            */
            scale = Decimal.Parse(s_scale);
            this.BackColor = Color.LightSkyBlue;
            led_current.ColorDark = this.BackColor;
            led_setting.ColorDark = this.BackColor;
            btn_turnon.BackColor = this.BackColor;
            btn_zeroon.BackColor = this.BackColor;
            btn_ktt.BackColor = this.BackColor;
            rectMeter1.BackColor = this.BackColor;
            btn_turnon.BackColor = this.BackColor;
            rectMeter1.BgResId = "BGMETER";
            string mypath = Path.Combine(GlobalConfig.udiskdir2, "screen");
            if (Directory.Exists(mypath))
                btn_capture.Visible = true;
            Cursor.Hide();
            processor = new Processor();
            data = new StringBuilder(10);

            kbd_btns = new RectButton[]{ lbButton0,lbButton1,lbButton2,lbButton3,lbButton4,lbButton5,lbButton6,lbButton7,lbButton8,lbButton9,
                lbButtonCancel,lbButtonOK,lbButtonPT,lbButtonPercent};
            string[] btn_cap = "0,1,2,3,4,5,6,7,8,9,取消,设定,.,%".Split(new char[] { ',' });
            for (int i = 0; i < kbd_btns.Length; i++)
            {
                RectButton lbt = kbd_btns[i];
                lbt.BackColor = Color.Transparent;
                lbt.colorTop = Color.LightPink;
                lbt.colorShadow = Color.DarkGray;
                lbt.Label = btn_cap[i];
                lbt.Style = MyButtonType.raiseButton;
                lbt.Click += new EventHandler((o, e) =>
                {
                    this.Beep();
                    KeypadTick(NameInArray(o, kbd_btns));
                });
            }
            #region range switch
            rng_btns = new RectButton[] { rngbtn_1, rngbtn_10, rngbtn_100, rngbtn_300, rngbtn_600, rngbtn_1000 };

            for (int i = 0; i < rng_btns.Length; i++)
            {
                RectButton rb = rng_btns[i];
                rb.BackColor = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop = Color.LightGray;
                rb.Style = MyButtonType.rectButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    if (processor.bOn)
                        return;

                    processor.range = Int32.Parse((o as RectButton).Label.Trim(new char[]{' ','A'}));
                    if (processor.setting > processor.range)
                        processor.setting = 0;
                    RefreshDisplay(false);
                    this.Beep();
                });
            }
            #endregion
            #region digi up and down

            digi_upbtns = new RectButton[] { rbtn_up1, rbtn_up2, rbtn_up3, rbtn_up4, rbtn_up5, rbtn_up6, rbtn_up7 };
            digi_dnbtns = new RectButton[] { rbtn_dn1, rbtn_dn2, rbtn_dn3, rbtn_dn4, rbtn_dn5, rbtn_dn6, rbtn_dn7 };
            for (int i = 0; i < digi_upbtns.Length; i++)
            {
                RectButton rb = digi_upbtns[i];
                rb.BackColor = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop = Color.DarkOrange;

                rb.bgScale = 3;
                rb.bOn = true;
                rb.Style = MyButtonType.triangleupButton;
                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_upbtns), true);
                    RefreshDisplay(false);
                });
            }
            for (int i = 0; i < digi_dnbtns.Length; i++)
            {
                RectButton rb = digi_dnbtns[i];
                rb.BackColor = this.BackColor;
                rb.colorShadow = this.BackColor;
                rb.colorTop = Color.DarkOrange;

                rb.bgScale = 3;
                rb.bOn = true;
                rb.Style = MyButtonType.trianglednButton;

                rb.ValidClick += new EventHandler((o, e) =>
                {
                    this.Beep();
                    TickDigit(digi_upbtns.Length - NameInArray(o, digi_dnbtns), false);
                    RefreshDisplay(false);
                });
            }

            #endregion

            dlg_choice = new ChoiceWnd();
            dlg_kbd = new kbdWnd();
            led_setting.ColorLight = Color.DarkGreen;
            led_setting.ColorBackground = this.BackColor;
            led_setting.ElementWidth = 10;
            //          led_setting.RecreateSegments(led_setting.ArrayCount);
            led_current.ColorLight = Color.Red;
            led_current.ColorBackground = this.BackColor;
            led_current.ElementWidth = 12;
            //          led_current.RecreateSegments(led_current.ArrayCount);
            led_current.Value = "0.0000";
            btn_zeroon.Style = MyButtonType.rectButton;
            btn_zeroon.colorShadow = this.BackColor;
            btn_zeroon.colorTop = Color.Bisque;
            btn_zeroon.Label = "电流表清零";
            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                this.Beep();
                led_current.Value = "     ";
                processor.ZeroON();
            });

            btn_ktt.Style = MyButtonType.rectButton;
            btn_ktt.Label = "电流换向";
            btn_ktt.bOn = processor.bKTT;
            btn_ktt.Click += new EventHandler((o, e) =>
            {
                this.Beep();
                processor.bKTT = !processor.bKTT;
                btn_ktt.bOn = processor.bKTT;

            });

            //btn_turnon.bgColor = this.BackColor;
            //btn_turnon.SetStyle(Color.Green, MyButtonType.round2Button);
            btn_turnon.Label = "OFF";
            btn_turnon.Click += new EventHandler((o, e) =>
            {
                this.Beep();
                dt_lastoutput = DateTime.Now.AddSeconds(0.5);
                btn_turnon.colorTop = Color.LightYellow; //switching
            });

            tm = new System.Windows.Forms.Timer();
            tm.Interval = 500;
            tm.Tick += new EventHandler((o, e) =>
            {
                foreach (RectButton btn in kbd_btns)
                {
                    if (!btn.IsButtonUp)
                        btn.IsButtonUp = true;
                }
                if (btn_turnon.colorTop == Color.LightYellow) //still booting up
                {
                    processor.bOn = !processor.bOn;
                    RefreshDisplay(false);
                    return;
                }
                lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    dt_lastoutput = DateTime.Now;
                    return;
                }
                if (data.Length == 0)
                {
                    processor.RefreshOutput();
                    if (processor.Current > -999)
                    {
                        UpdateCurrent(processor.Current);
                        processor.Current = -9999;
                    }
                }
            });
            tm.Enabled = true;
            processor.Reset();

            RefreshDisplay(true);
        }
Пример #12
0
        public Form1()
        {
            DisablePowerSleep();
            InitializeComponent();
            label5.Text = "VERSION: 2014-09-27";
            //if(!(myBeep is Beep))
            myBeep = new Beep("PWM1:");
//          myBeep = new Beep("PWM4:");
            btn_capture.Click += new EventHandler(btn_capture_Click);
            string mypath = Path.Combine(GlobalConfig.udiskdir2, "screen");

            if (Directory.Exists(mypath))
            {
                btn_capture.Visible = true;
            }
            Cursor.Hide();
            processor = new Processor();

            dlg_choice    = new ChoiceWnd();
            dlg_kbd       = new kbdWnd();
            led_rx.Value  = "0.000000";
            led_rx.Click += new EventHandler((o, e) => {
                DoBeep();
                dlg_choice.bNo0Choice = true;
                dlg_choice.param      = "selectrx";
                dlg_choice.Init(StringResource.str("selectrx"), Processor._RxTitles, -1, null, new KbdDataHandler(KbdData));
            });

            led_rx.ColorLight      = Color.Pink;
            led_rx.ColorDark       = this.BackColor;
            led_rx.ColorBackground = this.BackColor;
            led_rx.ElementWidth    = 12;
            led_rx.RecreateSegments(led_rx.ArrayCount);

            led_rs.ColorLight      = Color.Black;
            led_rs.ColorDark       = this.BackColor;
            led_rs.ColorBackground = this.BackColor;
            led_rs.ElementWidth    = 10;
            led_rs.RecreateSegments(led_rs.ArrayCount);
            led_rs.Click += new EventHandler((o, e) =>
            {
                DoBeep();
                dlg_kbd.Init(String.Format(StringResource.str("inputrs"), Processor._RsTitles[processor.RsIndex]), "inputrs", false, new KbdDataHandler(KbdData));
            });

            led_vx.ColorLight      = Color.Black;
            led_vx.ColorDark       = this.BackColor;
            led_vx.ColorBackground = this.BackColor;
            led_vx.ElementWidth    = 10;
            led_vx.RecreateSegments(led_vx.ArrayCount);
            led_vx.Value  = "0.000";
            led_vx.Click += new EventHandler((o, e) =>
            {
                DoBeep();
                dlg_choice.bNo0Choice = true;
                dlg_choice.param      = "selectvx";
                dlg_choice.Init(StringResource.str("selectvx"), Processor._MulTitles, -1, null, new KbdDataHandler(KbdData));
            });


            led_es.ColorLight      = Color.Black;
            led_es.ColorDark       = this.BackColor;
            led_es.ColorBackground = this.BackColor;
            led_es.ElementWidth    = 10;
            led_es.RecreateSegments(led_es.ArrayCount);
            led_es.Click += new EventHandler((o, e) =>
            {
                DoBeep();
                dlg_choice.bNo0Choice = true;
                dlg_choice.param      = "selectes";
                dlg_choice.Init(StringResource.str("selectes"), Processor._EsTitles, -1, null, new KbdDataHandler(KbdData));
            });

            btn_hvout.BackColor   = this.BackColor;
            btn_hvout.colorTop    = Color.LightYellow;
            btn_hvout.Style       = MyButtonType.rectButton;
            btn_hvout.Label       = StringResource.str("hvout");
            btn_hvout.ValidClick += new EventHandler((o, e) =>
            {
                DoBeep();
                if (!processor.bDirectOutputOn)
                {
                    this.Invoke(new Action(() =>
                    {
                        dlg_choice.bNo0Choice = true;
                        dlg_choice.param      = "selecthvport";
                        dlg_choice.Init(StringResource.str("selecthvport"), new string[] { "10 - 100V  端子输出", "100 - 1kV  端子输出", "500 - 5kV  端子输出", "1k - 10kV 端子输出" }, -1, null, new KbdDataHandler(KbdData));
                    }));
                }
                else
                {
                    processor.DirectOutputClose();
                    RefreshDisplay(true);
                }
                return;
            });


            btn_zeroon.BackColor = this.BackColor;
            btn_zeroon.colorTop  = Color.Bisque;
            btn_zeroon.Style     = MyButtonType.rectButton;
            btn_zeroon.Label     = StringResource.str("vxzero");

            btn_zeroon.ValidClick += new EventHandler((o, e) =>
            {
                DoBeep();
                processor.ZeroON2();
                if (btn_zeroon.colorTop != Color.LightSlateGray)
                {
                    btn_zeroon.colorTop = Color.LightSlateGray;
                }
                else
                {
                    btn_zeroon.colorTop = Color.Bisque;
                }
            });

            btn_zeroon2.BackColor = this.BackColor;
            btn_zeroon2.colorTop  = Color.Bisque;
            btn_zeroon2.Style     = MyButtonType.rectButton;
            btn_zeroon2.Label     = StringResource.str("vgzero");

            btn_zeroon2.ValidClick += new EventHandler((o, e) =>
            {
                DoBeep();
                processor.ZeroON();
                if (btn_zeroon2.colorTop != Color.LightSlateGray)
                {
                    btn_zeroon2.colorTop = Color.LightSlateGray;
                }
                else
                {
                    btn_zeroon2.colorTop = Color.Bisque;
                }
            });


            btn_turnon.BackColor = this.BackColor;
            btn_turnon.colorTop  = Color.Green;
            btn_turnon.Style     = MyButtonType.roundButton;
            btn_turnon.Text      = "OFF";
            btn_turnon.Click    += new EventHandler((o, e) =>
            {
                DoBeep();
                if (!processor.bOn)
                {
                    dt_lastoutput = DateTime.Now.AddSeconds(2);
                }
                processor.bOn = !processor.bOn;
                RefreshDisplay(true);
            });

            rectMeter1.BgResId = "BGMETER";
            DeviceMgr.Reset();
            processor.ToDAValue(0);

            tm          = new Timer();
            tm.Interval = 500;
            tm.Tick    += new EventHandler((o, e) =>
            {
                //lbl_datetime.Text = DateTime.Now.ToString("yyyy-MM-dd hh:mm:ss");
                if (DateTime.Now.Subtract(dt_lastoutput).TotalSeconds < 1)
                {
                    return;
                }
                dt_lastoutput = DateTime.Now;
                if (processor.bDirectOutputOn)
                {
                    DateTime.Now.AddSeconds(processor.RefreshDirectOutput());
                    string newv = processor.VxMeasure.ToString("F7").Substring(0, 6);
                    if (led_vx.Value != newv)
                    {
                        led_vx.Value     = newv;
                        rectMeter1.Angle = processor.Percent;
                    }
                    if (processor.bDirectStable)
                    {
                        if (led_vx.ColorLight != Color.Red)
                        {
                            led_vx.ColorLight = Color.Red;
                        }
                    }
                    else
                    {
                        if (led_vx.ColorLight != Color.Orange)
                        {
                            led_vx.ColorLight = Color.Orange;
                        }
                    }
                }
                else if (processor.bOn)
                {
                    dt_lastoutput = DateTime.Now.AddSeconds(processor.RefreshOutput());
                    double v      = Convert.ToDouble(processor.Rx);
                    string newv;
                    newv = Util.GMKFormat(ref v);
                    if (lbl_ohm.Text != newv)
                    {
                        lbl_ohm.Text = newv;
                    }

                    newv = v.ToString("F8").Substring(0, 7);
                    if (led_rx.Value != newv)
                    {
                        led_rx.Value = newv;
                    }
                    this.lbl_datetime.Text = processor.Vg.ToString() + "," + processor.Vx.ToString();
                    if (processor.bStable)
                    {
                        if (led_rx.ColorLight != Color.Red)
                        {
                            led_rx.ColorLight = Color.Red;
                        }
                    }
                    else
                    {
                        if (led_rx.ColorLight != Color.Pink)
                        {
                            led_rx.ColorLight = Color.Pink;
                        }
                    }


                    newv = processor.VxMeasure.ToString("F7").Substring(0, 6);
                    if (led_vx.Value != newv)
                    {
                        led_vx.Value     = newv;
                        rectMeter1.Angle = processor.Percent;
                    }
                }
            });
            tm.Enabled = true;
            DeviceMgr.Reset();

            RefreshDisplay(true);
        }