private int ShowFailMessage(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, string tipMsg, string showMsg) { tipCallback?.Invoke(testTask.TestOrderID, 2, tipMsg, 0); var msg = ShowMessage(2, $"{showMsg}\r\n按[重新测试]对项目重新测试,按[继续测试]进行下一测试。", "测试失败"); if (msg == 3) { TestSpecItem(testTask, temp, systemGroup, item, true); } return(msg); }
private void AddPointPDLTestData(IMeasurementTask testTask, string type, string temp, int ch, double wl, List <double> pws) { var data = new SortedList <double, PointTestItem>(); var max = Math.Round(pws.Max(), 3); var min = Math.Round(pws.Min(), 3); var avg = Math.Round(pws.Average(), 3); var pdl = Math.Round(max - min, 3); if (pdl < 0.01D) { pdl = 0.01D; } var p = max; if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.CalculateILType > 0) { switch (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.CalculateILType) { case 1: p = max; break; case 2: p = min; break; case 3: p = avg; break; } } var rf = MeasurementJob.ReferenceData.GetReference(1, ch % TestPortSetting.DataDivide, wl); if (rf == null) { throw new Exception("找不到归零值"); } var il = Math.Round(p - rf.Power, 3); data[wl] = new PointTestItem(wl, 0D, p, il, pdl, max, min, avg); testTask.AddTestData(type, temp, ch, data); }
private void GetPointRLTestData(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain) { if (!item.TestSetting.IsDouble()) { return; } var wl = item.TestSetting.CastTo(1550D); var type = "RL"; if (!testAgain && testTask.ContainsTestData(type, temp, item.PortSetting, wl)) { return; } currentChannel = 1; currentWavelength = wl; testInfoCallback?.Invoke(currentWavelength, currentChannel, currentUnit); var pw = new List <double>(); if (!MeasurementController.RunPointTest( false, currentWavelength, () => { return(!IsStop); }, () => { var readTime = Framework.MeasurementSystemSetting.SystemData.Setting.Profile.RetrunLosssTime; pw = GetMeterPowers(1, readTime); })) { throw new Exception(MeasurementController.ErrorString); } if (pw.Count < 1) { throw new Exception("读取功率失败"); } AddPointRLTestData(testTask, type, temp, item.PortSetting, currentWavelength, pw); return; }
private void AddPointTestData(IMeasurementTask testTask, string type, string temp, int ch, double wl, double pw) { var data = new SortedList <double, PointTestItem>(); var rf = MeasurementJob.ReferenceData.GetReference(1, ch % TestPortSetting.DataDivide, wl); if (rf == null) { throw new Exception("找不到归零值"); } var il = pw - rf.Power; if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.CheckInsertionLoss && il < Framework.MeasurementSystemSetting.SystemData.Setting.Profile.InsertionLossThreshold) { AppFramework.Context.MainForm.Invoke(new Action(() => { AppFramework.Context.ShowError("光源可能已经跑零"); })); } data[wl] = new PointTestItem(wl, 0D, pw, il, 0D, pw, pw, pw); testTask.AddTestData(type, temp, ch, data); }
private void AddPointRLTestData(IMeasurementTask testTask, string type, string temp, int ch, double wl, List <double> pws) { var data = new SortedList <double, PointTestItem>(); var max = Math.Round(pws.Max(), 3); var min = Math.Round(pws.Min(), 3); var avg = Math.Round(pws.Average(), 3); var pdl = Math.Round(max - min, 3); var p = min; var rf = MeasurementJob.ReferenceData.GetReference(1, ch % TestPortSetting.DataDivide, wl); if (rf == null) { throw new Exception("找不到归零值"); } var il = Math.Round(p - rf.Power, 3); var comp = Framework.MeasurementSystemSetting.SystemData.Setting.Profile.RetrunLosssCompensation; data[wl] = new PointTestItem(wl, 0D, p, il, pdl, max, min, avg, comp); testTask.AddTestData(type, temp, ch, data); }
private void GetPointTestData(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain) { if (!item.TestSetting.IsDouble()) { return; } var wl = item.TestSetting.CastTo(1550D); if (item.PortSetting == 0) { return; } var type = "Point"; if (!testAgain && testTask.ContainsTestData(type, temp, item.PortSetting, wl)) { return; } currentChannel = MeasurementController.GetSimultaneityPort(testTask.TestOrderID, item.PortSetting); currentWavelength = wl; testInfoCallback?.Invoke(currentWavelength, currentChannel, currentUnit); var pws = default(Dictionary <int, double>); if (!MeasurementController.RunPointTest( false, currentWavelength, () => { return(!IsStop); }, () => { var setting = TestPortSetting.Get(currentChannel); pws = MeasurementController.GetMeterAllChannelPower(setting.DeviceID, setting.SwitchID); })) { throw new Exception(MeasurementController.ErrorString); } if (pws == null || pws.Count < 1) { throw new Exception($"读取功率失败,{MeasurementController.ErrorString}"); } var items = MeasurementJob.SpecData.GetTestGroupWorkInfoSpecItems(systemGroup.TestGroupID); foreach (var testItem in items) { var pw = 0D; var c = TestPortSetting.Get(testItem.PortSetting).ChannelID; if (!pws.TryGetValue(c, out pw)) { continue; } if (pw == double.MinValue) { throw new Exception($"读取功率失败,{MeasurementController.ErrorString}"); } AddPointTestData(testTask, type, temp, testItem.PortSetting, currentWavelength, pw); } }
private void GetManualPointPDLPointPDLTestData(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain) { if (!item.TestSetting.IsDouble()) { return; } var wl = item.TestSetting.CastTo(1550D); if (item.PortSetting == 0) { return; } var type = "PointPDL"; if (!testAgain && testTask.ContainsTestData(type, temp, item.PortSetting, wl)) { return; } currentChannel = MeasurementController.GetSimultaneityPort(testTask.TestOrderID, item.PortSetting); currentWavelength = wl; testInfoCallback?.Invoke(currentWavelength, currentChannel, currentUnit); var pws = new Dictionary <int, List <double> >(); if (!MeasurementController.ChangeWaveLength(currentWavelength)) { throw new Exception($"切换波长失败,{MeasurementController.ErrorString}"); } FormMessageBox.SetShow(null, "正在测试", "请摇动手摇偏振控制器,完成后点击[继续测试]进行测试", 0); var setting = TestPortSetting.Get(currentChannel); while (FormMessageBox.MessageBoxResult == 0) { if (IsStop) { FormMessageBox.SetClose(2); break; } var powers = MeasurementController.GetMeterAllChannelPower(setting.DeviceID, setting.SwitchID); if (powers.Count < 1) { continue; } var max = new StringBuilder(); var min = new StringBuilder(); foreach (var pw in powers) { if (!pws.ContainsKey(pw.Key)) { pws[pw.Key] = new List <double>(); } if (pw.Value != double.MinValue) { pws[pw.Key].Add(pw.Value); } var maxP = pws[pw.Key].Max(); var minP = pws[pw.Key].Min(); if (maxP == double.MinValue || minP == double.MinValue) { max.Append($"{pw.Key}: -\r\n"); min.Append("-\r\n"); } else { max.Append($"{pw.Key}: {maxP:F3}\r\n"); min.Append($"{minP:F3}\r\n"); } } readingCallback?.Invoke( "-", max.ToString(), min.ToString() ); } readingCallback?.Invoke("-", "-", "-"); if (FormMessageBox.MessageBoxResult != 1) { IsStop = true; return; } if (pws == null || pws.Count < 1) { throw new Exception($"读取功率失败,{MeasurementController.ErrorString}"); } var items = MeasurementJob.SpecData.GetTestGroupWorkInfoSpecItems(systemGroup.TestGroupID); foreach (var testItem in items) { var pw = default(List <double>); var c = TestPortSetting.Get(testItem.PortSetting).ChannelID; if (!pws.TryGetValue(c, out pw)) { continue; } if (pw.Count < 2) { throw new Exception($"读取功率失败,{MeasurementController.ErrorString}"); } AddPointPDLTestData(testTask, type, temp, testItem.PortSetting, currentWavelength, pw); } }
private void TestSpecItem(IMeasurementTask testTask, string temp, TestSystemGroup systemGroup, WorkInfoSpecItem item, bool testAgain = false) { if (IsStop) { return; } testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "正在测试", "", 3); try { switch (systemGroup.TestGroupTestType) { case "None": //计算 break; case "Swept": //扫描 throw new Exception("系统禁用了扫描功能"); case "PDLSwept": //扫描 throw new Exception("系统禁用了扫描功能"); case "RL": //回损 GetPointRLTestData(testTask, temp, systemGroup, item, testAgain); break; case "Point": //点测 GetPointTestData(testTask, temp, systemGroup, item, testAgain); break; case "PointPDL": GetPointPDLTestData(testTask, temp, systemGroup, item, testAgain); break; case "ManualPointPDL": GetManualPointPDLPointPDLTestData(testTask, temp, systemGroup, item, testAgain); break; } } catch (Exception ex) { lastGroupResult = -1; testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, ex.Message, "", 2); IsStop = true; return; } if (IsStop) { testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, -1, "", item.SpecItemID, "停止测试", "", 2); return; } var value1 = ""; var value2 = ""; var result = testTask.MeasurementTest(item.SpecItemID); var failString = new List <string>(); lastGroupResult = Math.Min(lastGroupResult, result.Result); if (result.Result < 1) { failString.Add(item.ItemName); value1 = result.Result < 0 ? "-" : result.Data.ToString("F2"); } else { value1 = result.Data.ToString("F2"); } testCallback?.Invoke(testTask.StartTime, testTask.TestOrderID, item.PortSetting, item.SystemTypeID, item.SpecItemID, value1, value2, result.Result > 0 ? 1 : 2); if (failString.Count > 0 && Framework.MeasurementSystemSetting.SystemData.Setting.Profile.TestFailTreatmentType > 0) { if (Framework.MeasurementSystemSetting.SystemData.Setting.Profile.TestFailTreatmentType == 2) { IsStop = true; return; } ShowFailMessage(testTask, temp, systemGroup, item, result.Message, $"项目测试结果失败: \r\n{string.Join("\r\n", failString)}"); } }