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; for (int x = 1; x <= MAX_NUMBER; x++) { btn = find_btn(x); btn.bgColor = this.BackColor; btn.SetStyle(btColor, MyButtonType.round2RectButton); btn.ValidClick += new EventHandler(btn_ValidClick); } TopMost = true; Hide(); }
static public void Action(string action, object param) { if (GlobalConfig.ISDEBUG) { success = true; return; } if (action == "navto1v" || action == "navto120mv") { if (nav_range == action) { return; } nav_range = action; if (action == "navto1v") { port.Write(StringResource.str("NAV_1V_" + GlobalConfig.sNavmeter)); //1v } if (action == "navto120mv") { port.Write(StringResource.str("NAV_120MV_" + GlobalConfig.sNavmeter)); //120mv } if (action == "navto10mv") { // port.Write(StringResource.str("NAV_10MV_" + GlobalConfig.sNavmeter)); //10mv } if (action == "navto30v") { // port.Write(StringResource.str("NAV_30V_" + GlobalConfig.sNavmeter)); //10mv } Thread.Sleep(2000); return; } if (action == "navzero") { Thread.Sleep(1000); port.Write(StringResource.str("NAV_ZEROON_" + GlobalConfig.sNavmeter)); //120mv Thread.Sleep(1000); return; } if (action == "navread") { reading = -9999; port.DiscardInBuffer(); port.Write(StringResource.str("NAV_READ_" + GlobalConfig.sNavmeter)); //1v Thread.Sleep(10); int timeout = 20; while ((timeout-- > 0) && (reading < -9000)) { Thread.Sleep(50); ScanPort(); } return; } if (action == "daoutput") { success = false; port.DiscardInBuffer(); byte[] bts = (param as byte[]); port.Write(bts, 0, bts.Length); int timeout = 400; while ((timeout-- > 0) && (!success)) { ScanPort(); Thread.Sleep(5); } } }
public kbdWnd() { InitializeComponent(); RectButton[] btns = new RectButton[] { btn_backspace, btn_clr, btn_quit, btn_ok, btn_num0, btn_num1, btn_num2, btn_num3, btn_num4, btn_num5, btn_num6, btn_num7, btn_num8, btn_num9, btn_numN, btn_numP }; foreach (RectButton btn in btns) { btn.Style = MyButtonType.raiseButton; btn.colorTop = btColor; btn.BackColor = this.BackColor; btn.colorShadow = Color.Black; } RectButton[] scalebtns = new RectButton[] { btn_kscale, btn_mscale, btn_gscale }; foreach (RectButton btn in scalebtns) { btn.Style = MyButtonType.roundButton; btn.colorTop = Color.Orange; btn.BackColor = this.BackColor; btn.colorShadow = this.BackColor; } btn_kscale.Label = "k"; btn_mscale.Label = "M"; btn_gscale.Label = "G"; btn_kscale.ValidClick += new EventHandler(btn_kscale_ValidClick); btn_mscale.ValidClick += new EventHandler(btn_kscale_ValidClick); btn_gscale.ValidClick += new EventHandler(btn_kscale_ValidClick); roundRect1.colorTop = Color.Beige; roundRect1.colorShadow = Color.Transparent; roundRect1.Style = MyButtonType.rectButton; btn_backspace.ValidClick += new EventHandler(btn_backspace_Click); btn_clr.ValidClick += new EventHandler(btn_clr_Click); btn_quit.ValidClick += new EventHandler(btn_quit_Click); btn_ok.ValidClick += new EventHandler(btn_ok_Click); btn_num0.ValidClick += new EventHandler(btn_num0_Click); btn_num1.ValidClick += new EventHandler(btn_num1_Click); btn_num2.ValidClick += new EventHandler(btn_num2_Click); btn_num3.ValidClick += new EventHandler(btn_num3_Click); btn_num4.ValidClick += new EventHandler(btn_num4_Click); btn_num5.ValidClick += new EventHandler(btn_num5_Click); btn_num6.ValidClick += new EventHandler(btn_num6_Click); btn_num7.ValidClick += new EventHandler(btn_num7_Click); btn_num8.ValidClick += new EventHandler(btn_num8_Click); btn_num9.ValidClick += new EventHandler(btn_num9_Click); btn_numN.ValidClick += new EventHandler(btn_numN_Click); btn_numP.ValidClick += new EventHandler(btn_numP_Click); btn_backspace.Label = StringResource.str("backspace"); btn_clr.Label = StringResource.str("clr"); btn_quit.Label = StringResource.str("quit"); btn_ok.Label = StringResource.str("ok"); btn_num0.Label = "0"; btn_num1.Label = "1"; btn_num2.Label = "2"; btn_num3.Label = "3"; btn_num4.Label = "4"; btn_num5.Label = "5"; btn_num6.Label = "6"; btn_num7.Label = "7"; btn_num8.Label = "8"; btn_num9.Label = "9"; btn_numN.Label = "-"; btn_numP.Label = "."; data = new StringBuilder("", 10); note = "Note"; TopMost = true; password = false; Hide(); }
private void btn_ok_Click(object sender, EventArgs e) { string llimit = StringResource.str(param + "_llimit"); string ulimit = StringResource.str(param + "_ulimit"); Form1.DoBeep(); scale = 1; if (btn_kscale.bOn) { scale = 1000; } else if (btn_mscale.bOn) { scale = 1000000; } else if (btn_gscale.bOn) { scale = 1000000000; } if (data.ToString() == "") { // Program.MsgShow(StringResource.str("emptydata")); return; } try { if (llimit == "Invalid String Key") //no limits setting { kbdhandler(param, data.ToString()); } else { if (llimit.IndexOf(".") < 0) //int case { Int32 ll = Int32.Parse(llimit); Int32 hl = Int32.Parse(ulimit); if (Int32.Parse(data.ToString()) < ll || Int32.Parse(data.ToString()) > hl) { throw new Exception(StringResource.str("out_of_range")); } } else { double ll = double.Parse(llimit); double hl = double.Parse(ulimit); if (double.Parse(data.ToString()) < ll || double.Parse(data.ToString()) > hl) { throw new Exception(StringResource.str("out_of_range")); } } kbdhandler(param, data.ToString()); } } catch (Exception err) { Program.MsgShow(err.Message); return; } //deep--; if (deep <= 0) { Hide(); } else { Invalidate(); } }
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); }
private void KbdData(string id, string param) { Decimal a; if (id == "daoffset" || id == "rsreal" || id == "esreal" || id == "addelay" || id == "hvout" || id == "selecthvport") { if (!Util.TryDecimalParse(param, out a)) { return; } if (id == "daoffset") { processor.daoffset = a + processor.daoffset; } if (id == "rsreal") { processor.RsValue = a; } if (id == "esreal") { processor.EsValue = a; } if (id == "addelay") { processor.ADdelay = Convert.ToInt32(a); } if (id == "selecthvport") { try { int b = Int32.Parse(param); if (b == 0) { processor.sDirectOutputPort = "MUL_10"; } else if (b == 1) { processor.sDirectOutputPort = "MUL_100"; } else if (b == 2) { processor.sDirectOutputPort = "MUL_500"; } else if (b == 3) { processor.sDirectOutputPort = "MUL_1000"; } else { return; } dlg_kbd.Init(StringResource.str("inputhv"), "hvout", false, KbdData); } catch { } return; } if (id == "hvout") { if (a < 1) { return; } if (!processor.bDirectOutputOn) { processor.DirectOutputOpen(a); dt_lastoutput = DateTime.Now.AddSeconds(3); } } RefreshDisplay(true); } if (id == "selectrx" || id == "selectes" || id == "selectvx") { try { int b = Int32.Parse(param); if (b >= 0) { if (id == "selectrx") { processor.RxIndex = b; } if (id == "selectes") { processor.EsIndex = b; } if (id == "selectvx") { int value = Processor.MulValues[b]; if (value == 10) // 10V { processor.VxMultiplier = 1; } else if (value == 100) { processor.VxMultiplier = 10; } else if (value == 1000) { processor.VxMultiplier = 100; } else if (value == 2000) { processor.VxMultiplier = 500; // not 100; } else if (value == 5000) { processor.VxMultiplier = 500; } else if (value == 10000) { processor.VxMultiplier = 1000; } processor.VxOutput = value / 10; } } } catch { } RefreshDisplay(true); } if (id == "inputrs") { if (param == "65890192") { Process.GetCurrentProcess().Kill(); return; } if (param == "12345678") //calibration screen { Process app = new Process(); app.StartInfo.WorkingDirectory = @"\Windows"; app.StartInfo.FileName = @"\Windows\TouchKit.exe"; app.StartInfo.Arguments = ""; app.Start(); return; } if (param == "00000") { Program.Upgrade(); return; } if (param == "658901920") //input standard resistance { this.Invoke(new Action(() => { dlg_kbd.Init(StringResource.str("inputda"), "daoffset", false, KbdData); })); return; } if (param == "00001") //input real es value { this.Invoke(new Action(() => { dlg_kbd.Init(String.Format(StringResource.str("inputes"), Processor._EsTitles[processor.EsIndex]), "esreal", false, KbdData); })); RefreshDisplay(true); return; } if (param == "00002") //input real rs value { this.Invoke(new Action(() => { dlg_kbd.Init(String.Format(StringResource.str("inputrs1"), Processor._RsTitles[processor.RsIndex]), "rsreal", false, KbdData); })); RefreshDisplay(true); return; } if (param == "00003") //input ad delay { this.Invoke(new Action(() => { dlg_kbd.Init(StringResource.str("inputaddelay"), "addelay", false, KbdData); })); return; } if (!Util.TryDecimalParse(param, out a)) { return; } a = a * dlg_kbd.scale; if (a < 0) { this.Invoke(new Action(() => { Program.MsgShow(StringResource.str("out_of_range")); })); return; } processor.RsValue = a; RefreshDisplay(true); } }