private static double TestIsolation(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算ISO所需测试数据"); } var data = testData.GetDataList(temp, port); if (data.Count < 1) { throw new MeasuringException("没有计算ISO所需测试数据"); } var list = GetSettingData(data.ToList(), pSetting, 1); if (list.Count < 1) { return(double.MinValue); } var iso = list.Max(); if (iso == double.MinValue) { return(double.MinValue); } var minIL = data.Select(q => GetPointItemValue(q, 0)).Max(); iso = Math.Round(Math.Abs(iso - minIL), 3); return(iso); }
private static double TestPointIL(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var pointTestData = testDataCollection.GetTestData(testType, "Point", "PointPDL"); if (pointTestData == null) { throw new MeasuringException("没有计算IL所需测试数据"); } var wl = pSetting.CastTo(double.MinValue); if (wl == double.MinValue) { throw new MeasuringException("波长设置错误"); } var item = pointTestData.GetDataItem(temp, port, wl); if (item == null) { throw new MeasuringException("没有计算IL所需测试数据"); } var value = item == null ? double.MinValue : Math.Round(Math.Abs(item.IL), 3); return(value); }
private static double TestPeakIL(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算IL所需测试数据"); } var data = testData.GetDataList(temp, port); if (data.Count < 1) { throw new MeasuringException("没有计算IL所需测试数据"); } var list = GetSettingData(data.ToList(), pSetting, 0); if (list.Count < 1) { return(double.MinValue); } var il = list.Max(); if (il == double.MinValue) { return(double.MinValue); } il = Math.Round(Math.Abs(il), 3); return(il); }
private static double TestCWLAccuracy(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算CWL所需测试数据"); } var list = testData.GetDataList(temp, port); if (list.Count < 1) { throw new MeasuringException("没有计算CWL所需测试数据"); } var items = MeasuringManager.GetItemSettings(pSetting); var type = GetSettingType(items); var cw = GetSettingCenterWaveLength(items); var db = GetSettingDB(items); var wl = GetCenterWaveLength(list.ToList(), type, cw, db, bwSetting); if (cw < 1 || wl == double.MinValue) { return(double.MinValue); } return(Math.Round(Math.Abs(wl - cw), 3)); }
private static double TestReturnLoss(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算RL所需测试数据"); } var data = testData.GetData(temp, port).Values.ToList(); if (data.Count < 1) { throw new MeasuringException("没有计算RL所需测试数据"); } var list = GetSettingData(data, pSetting, 2); if (list.Count < 1) { return(double.MinValue); } var rl = list.Max(); if (rl == double.MinValue) { return(double.MinValue); } rl = Math.Round(Math.Abs(rl) + Windows.IniProfile <BusinessLogic.Setting.SystemSetting> .Instance.Profile.RetrunLosssCompensation, 3); return(rl); }
private static double TestRipple(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算Ripple所需测试数据"); } var data = testData.GetDataList(temp, port); if (data.Count < 1) { throw new MeasuringException("没有计算Ripple所需测试数据"); } var list = GetSettingData(data.ToList(), pSetting, 0); if (list.Count < 1) { return(double.MinValue); } var maxIL = list.Max(); var minIL = list.Min(); if (maxIL == double.MinValue || minIL == double.MinValue) { return(double.MinValue); } return(Math.Round((maxIL - minIL), 3)); }
private static double TestPointRL(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var rlTestData = testDataCollection.GetTestData(testType, "Point"); if (rlTestData == null) { throw new MeasuringException("没有计算RL所需测试数据"); } var wl = pSetting.CastTo(double.MaxValue); if (wl == double.MinValue) { throw new MeasuringException("波长设置错误"); } var item = rlTestData.GetDataItem(temp, port, wl); var refR = referenceData.GetReference(2, 1, wl); if (item == null || refR == null) { throw new MeasuringException("没有计算RL所需测试数据"); } var value = double.MinValue; //回损结果 var valueR = item.IL; //读取回损 var valueS = refR.IL; //系统回损 var AbsS = Math.Abs(valueS); //系统回损绝对值 if (Math.Abs(valueR) > AbsS) { //RL读取值小于系统值时候, if (AbsS >= 60D) { value = 60d; } else if (AbsS >= 58D) { value = 58d; } else { value = Math.Round(AbsS, 1); } } else { var cR = MeasuringManager.Convert_dBm2mW(valueR + Windows.IniProfile <BusinessLogic.Setting.SystemSetting> .Instance.Profile.RetrunLosssCompensation); var cS = MeasuringManager.Convert_dBm2mW(valueS + Windows.IniProfile <BusinessLogic.Setting.SystemSetting> .Instance.Profile.RetrunLosssCompensation); var rl = MeasuringManager.Convert_mW2dBm(cR - cS); value = Math.Round( Math.Min(Math.Abs(rl), AbsS), 1); } return(value); }
private static double TestPointUniformity(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var pointTestData = testDataCollection.GetTestData(testType, "Point", "PointPDL"); if (pointTestData == null) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } var wl = pSetting.CastTo(double.MaxValue); if (wl == double.MinValue) { throw new MeasuringException("波长设置错误"); } var testData = pointTestData.GetTestData(); if (!testData.ContainsKey(temp)) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } var data = testData[temp]; var setting = TestPortSetting.Get(port); var powers = new List <double>(); foreach (var item in data) { var ch = item.Key; if (ch < 1 || !item.Value.ContainsKey(wl)) { continue; } var chSetting = TestPortSetting.Get(ch); if (chSetting.DataID != setting.DataID) { continue; } var testItem = item.Value[wl]; if (testItem.IL == double.MinValue) { continue; } powers.Add(testItem.IL); } var value = powers.Count < 1 ? double.MinValue : Math.Round(powers.Max() - powers.Min(), 3); return(value); }
private static double TestTotalIsolation(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算ISO所需测试数据"); } var tdata = testData.GetTestData(); if (!tdata.ContainsKey(temp)) { throw new MeasuringException("没有计算ISO所需测试数据"); } var data = tdata[temp]; if (data.Count < 1) { throw new MeasuringException("没有计算ISO所需测试数据"); } var totaliso = double.MaxValue; foreach (var portData in data) { if (portData.Key == port) { continue; } var pdata = portData.Value.Values.ToList(); var list = GetSettingData(pdata, pSetting, 1); if (list.Count < 1) { continue; } var iso = list.Max(); if (iso == double.MinValue) { continue; } var minIL = pdata.Select(q => GetPointItemValue(q, 0)).Max(); iso = Math.Round(Math.Abs(iso - minIL), 3); totaliso = Math.Min(totaliso, iso); } if (totaliso == double.MaxValue) { return(double.MinValue); } return(totaliso); }
private static double TestPointTDL(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var pointTestData = testDataCollection.GetTestData(testType, "Point", "PointPDL"); if (pointTestData == null) { throw new MeasuringException("没有计算TDL所需测试数据"); } var testData = pointTestData.GetTestData(); if (!testData.ContainsKey(temp)) { throw new MeasuringException("没有计算TDL所需测试数据"); } var wl = pSetting.CastTo(double.MaxValue); if (wl == double.MinValue) { throw new MeasuringException("波长设置错误"); } var max = double.MinValue; var min = double.MaxValue; foreach (var data in testData.Values) { if (!data.ContainsKey(port)) { throw new MeasuringException("没有计算TDL所需测试数据"); } var item = data[port]; if (!item.ContainsKey(wl)) { continue; } var testItem = item[wl]; if (testItem.Power == double.MinValue || testItem.IL == double.MinValue) { continue; } max = Math.Max(max, testItem.Power); min = Math.Min(min, testItem.Power); } var value = max == double.MinValue || min == double.MinValue ? double.MinValue : Math.Round(max - min, 3); return(value); }
private static double TestChannelUniformity(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } var list = new List <double>(); var parallels = MeasuringManager.GetParallelSettings(pSetting); foreach (var parallel in parallels) { var items = MeasuringManager.GetItemSettings(parallel); var sport = GetSetingPort(items); var data = testData.GetData(temp, sport).Values.ToList(); if (data.Count < 1) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } var tempData = GetRangeData(data, items, 0); if (tempData.Count < 1) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } list.Add(tempData.Min()); } if (list.Count < 1) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } var max = list.Max(); var min = list.Min(); if (max == double.MinValue || min == double.MinValue) { return(double.MinValue); } return(Math.Abs(Math.Round(max - min, 3))); }
private static double TestBandwidth(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算Bandwidth所需测试数据"); } var list = testData.GetDataList(temp, port); if (list.Count < 1) { throw new MeasuringException("没有计算Bandwidth所需测试数据"); } var items = MeasuringManager.GetItemSettings(pSetting); var type = GetSettingType(items); var cw = GetSettingCenterWaveLength(items); var db = GetSettingDB(items); var wl = GetBandwidth(list.ToList(), type, cw, db, bwSetting); return(wl); }
private static double TestPointWDL(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var pointTestData = testDataCollection.GetTestData(testType, "Point", "PointPDL"); if (pointTestData == null) { throw new MeasuringException("没有计算WDL所需测试数据"); } var testData = pointTestData.GetTestData(); if (!testData.ContainsKey(temp)) { throw new MeasuringException("没有计算WDL所需测试数据"); } if (!testData[temp].ContainsKey(port)) { throw new MeasuringException("没有计算WDL所需测试数据"); } var data = testData[temp][port]; var max = double.MinValue; var min = double.MaxValue; foreach (var item in data) { var testItem = item.Value; if (testItem.IL == double.MinValue) { continue; } max = Math.Max(max, testItem.IL); min = Math.Min(min, testItem.IL); } var value = max == double.MinValue || min == double.MinValue ? double.MinValue : Math.Round(max - min, 3); return(value); }
/// <summary> /// 计算测试 /// </summary> /// <param name="referenceData"></param> /// <param name="testData"></param> /// <param name="calculateType"></param> /// <param name="testType"></param> /// <param name="testTemp"></param> /// <param name="testPort"></param> /// <param name="testSetting"></param> /// <returns></returns> public static MeasurementTestResult Calculate(ReferenceData referenceData, TestDataCollection testData, string calculateType, string testType, string testTemp, int testPort, string testSetting) { try { var method = default(CalculateDelegate); if (!Calculates.TryGetValue(calculateType, out method)) { throw new MeasuringException("未支持的计算方法"); } var value = method( referenceData, testData, testType, testTemp, testPort, testSetting); return(new MeasurementTestResult() { Result = 1, Data = value, Message = "计算成功" }); } catch (Exception ex) { Incht.Common.Log.LogHelper.WriteLog("MeasuringManager", ex); return(new MeasurementTestResult() { Result = -1, Message = ex.Message, Data = double.MinValue, }); } }
public virtual bool Start( MeasurementJobInformation job, Guid batchID, string sn, int order, int saveType) { MeasurementJob = job; TestOrderID = order; TestData = new TestDataCollection( job.SpecData.TestSystemGroups.Where(q => job.SpecData.WorkInfoSpecItems.Any(a => a.TestGroupID == q.TestGroupID)).Select(q => q.TestGroupTestType).ToArray(), job.SpecData.TempSetting, job.SpecData.Ports); testInfo.WorkInfoID = job.WorkInfo.WorkInfoID; testInfo.SN = sn; testInfo.TestItemSetting = batchID.ToString(); testInfo.TempSetting = string.Join(",", job.SpecData.TempSetting); testInfo.TestSaveType = saveType; testInfo.StartTestDateTime = DateTime.Now; testInfo.TestResult = -1; return(true); }
private static double TestPointCR(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var pointTestData = testDataCollection.GetTestData(testType, "Point", "PointPDL"); if (pointTestData == null) { throw new MeasuringException("没有计算CR所需测试数据"); } /* * var wl = pSetting.CastTo(double.MinValue); * if (wl == double.MinValue) * throw new MeasuringException("波长设置错误"); * * var item = pointTestData.GetDataItem(temp, port, wl); * if (item == null) * { * throw new MeasuringException("没有计算CR所需测试数据"); * } * var refpower = referenceData.GetReference(1, port, wl); * var power = item.Power + Windows.IniProfile<BusinessLogic.Setting.SystemSetting>.Instance.Profile.ExtraLosssCompensation; * var cr = MeasuringManager.Convert_dBm2mW(power - refpower.Power); * cr = Math.Round(cr * 100D, 2); */ var wl = pSetting.CastTo(double.MaxValue); if (wl == double.MinValue) { throw new MeasuringException("波长设置错误"); } var testData = pointTestData.GetTestData(); if (!testData.ContainsKey(temp)) { throw new MeasuringException("没有计算CL所需测试数据"); } var data = testData[temp]; var inPower = 0D; var allPower = 0D; var setting = TestPortSetting.Get(port); foreach (var item in data) { var ch = item.Key; if (ch < 1 || !item.Value.ContainsKey(wl)) { continue; } var chSetting = TestPortSetting.Get(ch); if (chSetting.DataID != setting.DataID) { continue; } var testItem = item.Value[wl]; if (testItem.Power == double.MinValue) { continue; } var power = MeasuringManager.Convert_dBm2mW(testItem.IL); if (port == ch) { inPower = power; } allPower += power; } var cr = allPower == 0D ? 0D : inPower / allPower; cr = Math.Round(cr * 100D, 2); return(cr); }
public bool SetData( TestInfoData data1, Dictionary <string, string> data2) { if (data1 == null) { ErrorString = "测试数据为空"; return(false); } tempSetting = data1.TestInfo.TempSetting.Split(","); if (data2 != null) { foreach (var item in data2) { exData.Add(item.Key, item.Value); } } testInfo = data1.TestInfo; classID = data1.ProductInfo.ProductClassID; var ports = BaseSettingsManager.Get <SystemGroupSetting>().GetPorts(classID); var types = new List <string>(); foreach (var source in data1.TestSources) { var type = source.SourceType; if (!BaseSettingsManager.Get <TestTypeSetting>().ContainsType(type)) { continue; } types.Add(type); } collection = new TestDataCollection(types.ToArray(), tempSetting, ports); foreach (var source in data1.TestSources) { var type = source.SourceType; if (!types.Contains(type)) { continue; } foreach (var tempData in source.SourceData) { var temp = tempData.Key; foreach (var portData in tempData.Value) { var port = portData.Key; var list = new SortedList <double, PointTestItem>(); foreach (var wlData in portData.Value) { var wl = wlData.Key; var item = wlData.Value; list.Add(wl, new PointTestItem(item)); } collection.Add(type, temp, port, list); } } } referenceData = new ReferenceData(Guid.Empty, false); for (int i = 0; i < data1.ReferenceData.Count; i++) { foreach (var portTemp in data1.ReferenceData[i]) { var port = portTemp.Key; foreach (var item in portTemp.Value) { var d = new PointTestItem(item.Value); referenceData.AddReference(i, port, d); } } } exData["sn"] = data1.TestInfo.SN; exData["csn"] = data1.CustomerSN; exData["workorder"] = data1.WorkInfo.WorkOrderID; exData["id"] = data1.WorkInfo.WorkOrderID; exData["workorderid"] = data1.WorkInfo.WorkOrderID; exData["productcode"] = data1.ProductInfo.ProductCode; exData["productname"] = data1.ProductInfo.ProductName; exData["stationname"] = data1.StationInfo.StationName; exData["operator"] = data1.WorkInfo.WorkInfoOperator; exData["room"] = tempSetting.Length > 0 ? tempSetting[0] : ""; exData["low"] = tempSetting.Length > 1 ? tempSetting[1] : ""; exData["high"] = tempSetting.Length > 2 ? tempSetting[2] : ""; exData["productremark"] = data1.ProductInfo.ProductRemark; var remarks = data1.ProductInfo.ProductRemark.Split("\r\n"); for (int i = 0; i < remarks.Length; i++) { exData[$"productremark[{i}]"] = remarks[i]; } return(true); }
private static double TestChipUniformity(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } if (uniformity == null) { if (System.IO.File.Exists(uniformityFile)) { var data = System.IO.File.ReadAllText(uniformityFile); try { uniformity = data.FromJsonString <Dictionary <string, List <double> > >(); } catch { } } if (uniformity == null) { uniformity = new Dictionary <string, List <double> >(); } } if (!uniformity.ContainsKey(pSetting)) { uniformity[pSetting] = new List <double>(); } var list = uniformity[pSetting]; if (list.Count >= Windows.IniProfile <BusinessLogic.Setting.SystemSetting> .Instance.Profile.ChipCount) { list.RemoveAt(0); } var parallels = MeasuringManager.GetParallelSettings(pSetting); foreach (var parallel in parallels) { var items = MeasuringManager.GetItemSettings(parallel); var sport = GetSetingPort(items); var data = testData.GetData(temp, sport).Values.ToList(); if (data.Count < 1) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } var tempData = GetRangeData(data, items, 0); if (tempData.Count < 1) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } list.Add(tempData.Min()); } if (list.Count < 1) { throw new MeasuringException("没有计算Uniformity所需测试数据"); } try { System.IO.File.WriteAllText(uniformityFile, uniformity.ToJsonString()); } catch { } var max = list.Max(); var min = list.Min(); if (max == double.MinValue || min == double.MinValue) { return(double.MinValue); } return(Math.Abs(Math.Round(max - min, 3))); }
private static double TestPointEL(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var pointTestData = testDataCollection.GetTestData(testType, "Point", "PointPDL"); if (pointTestData == null) { throw new MeasuringException("没有计算EL所需测试数据"); } var wl = pSetting.CastTo(double.MaxValue); if (wl == double.MinValue) { throw new MeasuringException("波长设置错误"); } var testData = pointTestData.GetTestData(); if (!testData.ContainsKey(temp)) { throw new MeasuringException("没有计算EL所需测试数据"); } var data = testData[temp]; var allPower = 0D; var inPower = 0D; var count = 0; var setting = TestPortSetting.Get(port); foreach (var item in data) { var ch = item.Key; if (ch < 1 || !item.Value.ContainsKey(wl)) { continue; } var chSetting = TestPortSetting.Get(ch); if (chSetting.DataID != setting.DataID) { continue; } var testItem = item.Value[wl]; if (testItem.Power == double.MinValue) { continue; } var refpower = referenceData.GetReference(1, ch % TestPortSetting.DataDivide, wl); allPower += MeasuringManager.Convert_dBm2mW(testItem.Power); inPower += refpower.Power; count++; } allPower = MeasuringManager.Convert_mW2dBm(allPower) + Windows.IniProfile <BusinessLogic.Setting.SystemSetting> .Instance.Profile.ExtraLosssCompensation; inPower = inPower / count; var value = inPower == double.MinValue ? double.MinValue : Math.Abs(Math.Round(allPower - inPower, 3)); return(value); }
private static double TestPolarizationDependentLoss(ReferenceData referenceData, TestDataCollection testDataCollection, string testType, string temp, int port, string pSetting) { var testData = testDataCollection.GetTestData(testType, "Swept", "SweptPDL"); if (testData == null) { throw new MeasuringException("没有计算PDL所需测试数据"); } var data = testData.GetData(temp, port).Values.ToList(); if (data.Count < 1) { throw new MeasuringException("没有计算PDL所需测试数据"); } var list = GetSettingData(data, pSetting, 3); if (list.Count < 1) { return(double.MinValue); } var pdl = list.Max(); if (pdl == double.MinValue) { return(double.MinValue); } pdl = Math.Round(Math.Abs(pdl), 3); return(pdl); }