getDiff(Dictionary <string, string[]> testItems, string snpFilepath, SNPPort snpPort, Dictionary <string, plotData> spec, ref bool action, ref string msg) { //System.GC.Collect(); Dictionary <string, plotData[]> ret = new Dictionary <string, plotData[]>(); try { SNP snpClass = new SNP(snpFilepath, snpPort); foreach (var item in testItems) { formatedData fData = snpClass.getDiff(item.Value); int columns = fData.dB.GetLength(1); int rows = fData.dB.GetLength(0); float[] offset = new float[rows]; if (spec.ContainsKey(item.Key + "_OFFSET")) { for (int row = 0; row < rows; row++) { offset[row] = spec[item.Key + "_OFFSET"].yData[row]; } } plotData[] singleItem = new plotData[columns]; for (int curveNo = 0; curveNo < columns; curveNo++) { float[] y = new float[rows]; for (int row = 0; row < rows; row++) { y[row] = fData.dB[row, curveNo] + offset[row]; } singleItem[curveNo].yData = y; singleItem[curveNo].xData = fData.fre; y = null; } ret.Add(item.Key, singleItem); singleItem = null; fData = new formatedData(); } snpClass = null; //System.GC.Collect(); action = true; return(ret); } catch (Exception ex) { action = false; msg = ex.Message; //MessageBoxEx.Show(ex.Message); return(null); } }
getAnalyzedData(List <TestItem> testItems, string snpFilepath, SNPPort snpPort, Dictionary <string, plotData> spec, TDD[] tdds, ref bool action, ref string msg, ref Dictionary <string, string[]> pairNameDictionary) { int pairNum = 8; pairNameDictionary.Clear(); string[] pairNames = new string[pairNum]; Dictionary <string, plotData[]> ret = new Dictionary <string, plotData[]>(); try { SNP snpClass = new SNP(snpFilepath, snpPort); foreach (var testItem in testItems) { string item = testItem.testName.ToUpper(); if (item.StartsWith("T")) { TDD tdd = item.Equals("TDD11") ? tdds[0] : tdds[1]; timeDomainData tData = snpClass.EasyGetTimeData(item, out pairNames, double.Parse(tdd.riseTime), (double.Parse(tdd.stopTime) - double.Parse(tdd.startTime)) / (tdd.points - 1), tdd.points, double.Parse(tdd.offset)); int tColumns = tData.resistance.GetLength(1); int tRows = tData.resistance.GetLength(0); float[] offset = new float[tRows]; if (spec.ContainsKey(item + "_OFFSET")) { for (int row = 0; row < tRows; row++) { offset[row] = spec[item + "_OFFSET"].yData[row]; } } plotData[] tItem = new plotData[tColumns]; for (int curveNo = 0; curveNo < tColumns; curveNo++) { float[] y = new float[tRows]; for (int row = 0; row < tRows; row++) { y[row] = tData.resistance[row, curveNo] + offset[row]; } tItem[curveNo].yData = y; tItem[curveNo].xData = tData.time; y = null; } ret.Add(item, tItem); pairNameDictionary.Add(item, pairNames); } else if (item.Equals("SINGLE")) { string[] pairNameSingles = new[] { "S1_17", "S2_18", "S3_19", "S4_20", "S5_21", "S6_22", "S7_23", "S8_24", "S9_25", "S10_26", "S11_27", "S12_28", "S13_29", "S14_30", "S15_31", "S16_32" }; formatedData sfData = snpClass.getSingle(pairNameSingles); int sColumns = sfData.dB.GetLength(1); int sRows = sfData.dB.GetLength(0); plotData[] singleItem = new plotData[sColumns]; for (int curveNo = 0; curveNo < sColumns; curveNo++) { float[] y = new float[sRows]; for (int row = 0; row < sRows; row++) { y[row] = sfData.dB[row, curveNo]; } singleItem[curveNo].yData = y; singleItem[curveNo].xData = sfData.fre; y = null; } ret.Add(item, singleItem); pairNameDictionary.Add(item, pairNameSingles); } else if (item.Equals("ILD")) { formatedData fData = snpClass.EasyGetILD(testItem.IldSpec, out pairNames); int columns = fData.dB.GetLength(1); int rows = fData.dB.GetLength(0); float[] offset = new float[rows]; if (spec.ContainsKey(item + "_OFFSET")) { for (int row = 0; row < rows; row++) { offset[row] = spec[item + "_OFFSET"].yData[row]; } } plotData[] diffItem = new plotData[columns]; for (int curveNo = 0; curveNo < columns; curveNo++) { float[] y = new float[rows]; for (int row = 0; row < rows; row++) { y[row] = fData.dB[row, curveNo] + offset[row]; } diffItem[curveNo].yData = y; diffItem[curveNo].xData = fData.fre; y = null; } ret.Add(item, diffItem); diffItem = null; fData = new formatedData(); pairNameDictionary.Add(item, pairNames); } else { formatedData fData = snpClass.EasyGetfreData(item, out pairNames); int columns = fData.dB.GetLength(1); int rows = fData.dB.GetLength(0); float[] offset = new float[rows]; if (spec.ContainsKey(item + "_OFFSET")) { for (int row = 0; row < rows; row++) { offset[row] = spec[item + "_OFFSET"].yData[row]; } } plotData[] diffItem = new plotData[columns]; for (int curveNo = 0; curveNo < columns; curveNo++) { float[] y = new float[rows]; for (int row = 0; row < rows; row++) { if (!float.IsNaN(offset[row])) { y[row] = fData.dB[row, curveNo] + offset[row]; } else { y[row] = fData.dB[row, curveNo]; } } diffItem[curveNo].yData = y; diffItem[curveNo].xData = fData.fre; y = null; } ret.Add(item, diffItem); diffItem = null; fData = new formatedData(); pairNameDictionary.Add(item, pairNames); } } snpClass = null; //System.GC.Collect(); action = true; return(ret); } catch (Exception ex) { action = false; msg = ex.Message; //MessageBoxEx.Show(ex.Message); return(null); } }