Ejemplo n.º 1
0
        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);
            }
        }
Ejemplo n.º 2
0
        private plotData GetPlotdata(SNP snp, string itemName, TaskSnp taskSnp, ConsumerParams cpParams, plotData offset)
        {
            plotData        dataSeries = new plotData();
            List <TdrParam> tdrParams  = cpParams.TestConfigs[0].TdrParams;

            switch (taskSnp.ItemType)
            {
            case   ItemType.Loss:

                if (itemName.StartsWith("S"))
                {
                    itemName = GetReverseItem(itemName, !taskSnp.FirstHalf && taskSnp.Srevert);
                    // cpParams.FormUi.AddStatus("analyze:"+itemName);
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetfreData(itemName, out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                else if (itemName.StartsWith("TDD"))
                {
                    itemName = GetReverseItem(itemName, !taskSnp.FirstHalf && taskSnp.Trevert);
                    // cpParams.FormUi.AddStatus("analyze:" + itemName);
                    TdrParam tdrParam = tdrParams[int.Parse(itemName.Substring(3, 1)) - 1];
                    string[] outPairs = new string[1];
                    double   timeStep = (tdrParam.EndTime - tdrParam.StartTime) / (tdrParam.Points - 1);
                    var      data     = snp.EasyGetTimeData(itemName, out outPairs, tdrParam.RiseTime, timeStep, tdrParam.Points, tdrParam.Offset);
                    float[]  x        = SConvert.indexArray(data.resistance, 0, false);
                    dataSeries.xData = data.time;
                    dataSeries.yData = x;
                }
                else if (itemName.Equals("ILD", StringComparison.OrdinalIgnoreCase))
                {
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetILD(cpParams.TestConfigs[0].IldSpec, out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                break;

            case ItemType.Next:
                if (itemName.StartsWith("NEXT"))
                {
                    // cpParams.FormUi.AddStatus("analyze:" + itemName);
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetfreData("SDD21", out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                break;

            case ItemType.Fext:
                if (itemName.StartsWith("FEXT"))
                {
                    // cpParams.FormUi.AddStatus("analyze:" + itemName);
                    string[] outPairs = new string[1];
                    var      data     = snp.EasyGetfreData("SDD21", out outPairs);
                    float[]  x        = SConvert.indexArray(data.dB, 0, false);
                    dataSeries.xData = data.fre;
                    dataSeries.yData = x;
                }
                break;
            }

            if (offset.yData != null)
            {
                int length = dataSeries.yData.Length < offset.yData.Length
                    ? dataSeries.yData.Length
                    : offset.yData.Length;
                for (int i = 0; i < length; i++)
                {
                    dataSeries.yData[i] = dataSeries.yData[i] + offset.yData[i];
                }
            }

            return(dataSeries);
        }