//读取设备数据 private void btnGetValue_Click(object sender, RoutedEventArgs e) { try { if (Hp8153A == null || Hp8156A == null || Mp2100A == null) { MessageBox.Show("请将所有设备初始化", "系统提示"); return; } if (Port == null || Port.IsOpen == false) { MessageBox.Show("请先初始化COM口", "系统提示"); } else { Hp8156A.SetAtt("10"); //I2C获取数据 this.GetParas(); //温度 tbTemp.Text = ParaModel.Temperature; //Bais tbBais.Text = ParaModel.Bais; //RX@10 tbRx1.Text = ParaModel.RxPower; //读取HP8153光功率计功率 tbTxPower.Text = Hp8153A.ReadData(); Thread.Sleep(200); //RX@19 Hp8156A.SetAtt("19"); Thread.Sleep(200); this.GetRxPower(); tbRx2.Text = ParaModel.RxPower; //Rx@28 Hp8156A.SetAtt("28"); Thread.Sleep(200); tbRx3.Text = ParaModel.RxPower; //ER tbER.Text = Mp2100A.GetER(); Thread.Sleep(200); //Crossing tbCrossing.Text = Mp2100A.GetCrossing(); } } catch (Exception ex) { MessageBox.Show(ex.Message, "系统设置"); } }
static void Main(string[] args) { string supplyCurrent; string outputPower; double voltage = 0; double ini = 28.0; double span = 0.2; double sd_Desserted = 0, sd_Asserted = 0, hysis = 0; string crossing; string extiRatio; string jitter; string maskMargin; string sensitivity; bool saturation; bool txDisable; try { AgE3631 = new AglientE3631A("9"); Keith = new Keithley("24"); Hp8156 = new HP8156A("22"); Mp = new MP2100A("16"); Hp8153 = new HP8153A("5"); Console.WriteLine(Keith.GetIdn()); Console.WriteLine(Hp8156.GetIdn()); Console.WriteLine(Mp.GetIdn()); Console.WriteLine(Hp8153.GetIdn()); Console.WriteLine(AgE3631.GetIdn()); AgE3631.Open(); Hp8156.Open(); supplyCurrent = AgE3631.GetCurrent(); outputPower = Hp8153.ReadPower("2"); Console.WriteLine("Supply Current:{0}", supplyCurrent); Console.WriteLine("Output Power:{0}", outputPower); Console.WriteLine(); Mp.AutoScale(); Keith.SetMeasureVoltageOnlyPara("10"); Keith.Open(); //SD_Desserted, SD_High for (int i = 0; i <= 40; i++) { Hp8156.SetAtt(ini.ToString()); Thread.Sleep(300); voltage = GetKeithData(); Thread.Sleep(200); if (voltage >= 2.0) { sd_Desserted = ini; break; } else { ini += span; } } Console.WriteLine("SDHigh:{0}", voltage); Console.WriteLine("SdDesserted:{0}", sd_Desserted); Console.WriteLine(); //SD_Asserted,SD_Low for (int i = 0; i < 40; i++) { Hp8156.SetAtt(ini.ToString()); Thread.Sleep(300); voltage = GetKeithData(); Thread.Sleep(300); if (voltage <= 0.5) { sd_Asserted = ini; break; } else { ini -= 0.1; } } Console.WriteLine("SdLow:{0}", voltage); Console.WriteLine("SdAsserted:{0}", sd_Asserted); hysis = sd_Desserted - sd_Asserted; Console.WriteLine("Hys:{0}", hysis); Console.WriteLine(); Hp8156.SetAtt("28"); Thread.Sleep(2000); #region Mp2100 crossing = Mp.GetCrossing(); extiRatio = Mp.GetER(); Console.WriteLine("Crossing:{0}", crossing); Console.WriteLine("Extinction Ratio:{0}", extiRatio); jitter = Mp.GetJitter(); maskMargin = Mp.GetMaskMargin(); Console.WriteLine("Jitter:{0}", jitter); Console.WriteLine("Mask Margin:{0}", maskMargin); Console.WriteLine(); //Sensitivity GetSensitivity(); sensitivity = SenPara.Sensitive.ToString(); Console.WriteLine("Sensitivity:{0}", sensitivity); #endregion //Saturation Hp8156.SetAtt("9"); Thread.Sleep(2000); Console.WriteLine(); for (int i = 0; i < 5; i++) { Console.WriteLine("Saturation:{0}", Mp.GetErrorRate()); Thread.Sleep(1000); } Hp8156.Close(); Hp8156.SetAtt("28"); AgE3631.SetOutput("25", "2.0", "0.5"); Thread.Sleep(1000); Console.WriteLine("TxDisable:{0}", Hp8153.ReadPower("2")); Console.WriteLine("测试完成"); Console.ReadKey(); Keith.Close(); AgE3631.Close(); Dispose(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.ReadKey(); } }