Ejemplo n.º 1
0
        private UUTReport CreateReport(TDM api, XDocument xml)
        {
            XElement  testRun     = xml.Element("testrun");
            XElement  testRunInfo = testRun.Element("testruninfo");
            UUTReport uut         = api.CreateUUTReport(
                testRunInfo.Element("user").Value,
                parameters["partNumber"],
                parameters["partRevision"],
                testRunInfo.Element("serial").Value,
                parameters["operationTypeCode"],
                parameters["sequenceName"],
                parameters["sequenceVersion"]);

            uut.StartDateTime = DateTime.ParseExact(testRun.Attribute("datetime").Value, "o", CultureInfo.InvariantCulture);
            uut.Comment       = testRunInfo.Element("project-description").Value;
            if (testRunInfo.Element("xjlink-name") != null)
            {
                uut.StationName = testRunInfo.Element("xjlink-name").Value;
            }
            if (testRunInfo.Element("time-taken") != null)
            {
                uut.ExecutionTime = double.Parse(testRunInfo.Element("time-taken").Value) / 1000.0;
            }
            ReadTests(uut, testRun);
            uut.Status = testRunInfo.Element("result").Value == "Passed"?UUTStatusType.Passed:UUTStatusType.Failed; //Termiated, Error?
            return(uut);
        }
Ejemplo n.º 2
0
 private void ReadGraphHeader(UUTReport unitTestReport, string[] columns, out string measureName, out string xUnit, out string yUnit)
 {
     measureName = columns[3];
     xUnit       = columns[13];
     yUnit       = columns[14];
     ;
 }
Ejemplo n.º 3
0
        public Report ImportReport(TDM api, Stream file)
        {
            XDocument infoXml;

            using (ZipFile zipFile = new ZipFile(file))
            {
                ZipEntry zipEntry = zipFile.GetEntry("Info.xml");
                using (Stream zipStream = zipFile.GetInputStream(zipEntry))
                {
                    using (StreamReader streamReader = new StreamReader(zipStream))
                    {
                        infoXml = XDocument.Load(streamReader);
                        int testRuns = int.Parse(infoXml.Element("LogFileInfo").Element("TestRunCount").Value);
                        for (int i = 1; i <= testRuns; i++)
                        {
                            ZipEntry zipEntryRun = zipFile.GetEntry($"Run {i}.xml");
                            using (Stream zipStreamRun = zipFile.GetInputStream(zipEntryRun))
                            {
                                using (StreamReader streamReaderRun = new StreamReader(zipStreamRun))
                                {
                                    XDocument runXML = XDocument.Load(streamReaderRun);
                                    UUTReport uut    = CreateReport(api, runXML);
                                    api.Submit(uut);
                                }
                            }
                        }
                    }
                }
            }
            return(null);
        }
Ejemplo n.º 4
0
        private UUTReport CreateReportFromHeader(Dictionary <string, string> headerData, TDM api)
        {
            UUTReport uut = api.CreateUUTReport(headerData["Cfg_UserName"], parameters["partNumber"], parameters["partRevision"], headerData["Cfg_SerialNumber"],
                                                parameters["operationTypeCode"], parameters["sequenceName"], parameters["sequenceVersion"]);

            uut.AddMiscUUTInfo("Cfg_LoginMode", headerData["Cfg_LoginMode"]);
            uut.AddMiscUUTInfo("Cfg_Speaker", headerData["Cfg_Speaker"]);
            return(uut);
        }
Ejemplo n.º 5
0
        private UUTReport CreateUUTFromHeader(TDM api, string[] cols, string sn)
        {
            UUTReport uut = api.CreateUUTReport(parameters["operator"],
                                                cols[2], parameters["partRevision"],
                                                sn, parameters["operationTypeCode"],
                                                parameters["sequenceName"], parameters["sequenceVersion"]);

            uut.StartDateTime = DateTime.Parse(cols[1], cultureInfo);
            return(uut);
        }
Ejemplo n.º 6
0
        public Report ImportReport(TDM api, Stream file)
        {
            cultureInfo = new CultureInfo(parameters["cultureCode"]);

            UUTReport unitTestReport = null;

            using (TextReader reader = new StreamReader(file))
            {
                //Serial #:	Time:   Lot #:  Name	Margin	Unit	Result	Tolerance	Limits
                string   header = reader.ReadLine();
                string   line = reader.ReadLine();
                string   sn = "", measureName = "", xUnit = "", yUnit = "";
                double[] xValues = null;
                while (line != null)
                {
                    if (!string.IsNullOrEmpty(line))
                    {
                        string[] columns = line.Split(new char[] { '\t' });
                        if (columns[0] != "Serial #:")
                        {
                            sn = columns[0];
                        }
                        if (unitTestReport == null || unitTestReport.SerialNumber != sn)
                        {
                            if (unitTestReport != null)
                            {
                                api.Submit(unitTestReport);
                            }
                            unitTestReport = CreateUUTFromHeader(api, columns, sn);
                        }
                        if (columns[0] == "Serial #:")
                        {
                            ReadGraphHeader(unitTestReport, columns, out measureName, out xUnit, out yUnit);
                        }
                        else if (columns.Length > 10)
                        {
                            ReadGraphData(unitTestReport, columns, measureName, xUnit, yUnit, ref xValues);
                        }
                        else
                        {
                            ReadMeasure(unitTestReport, columns);
                        }
                    }
                    line = reader.ReadLine();
                }
                if (unitTestReport != null)
                {
                    api.Submit(unitTestReport);
                }
            }
            return(unitTestReport);
        }
Ejemplo n.º 7
0
        private void ReadMeasure(UUTReport unitTestReport, string[] columns)
        {
            NumericLimitStep numericLimitStep = unitTestReport.GetRootSequenceCall().AddNumericLimitStep(columns[3]);
            double           measure          = double.Parse(columns[4], cultureInfo);

            if (columns[8].Contains("/"))
            {
                string[] lim    = columns[8].Split(new char[] { '/' });
                double   lowLim = double.Parse(lim[1], cultureInfo);
                double   hiLim  = double.Parse(lim[0], cultureInfo);
                numericLimitStep.AddTest(measure, CompOperatorType.GELE, lowLim, hiLim, columns[5]);
            }
            else
            {
                numericLimitStep.AddTest(measure, columns[5]);
            }
            numericLimitStep.Status = StepStatus(columns[6]);
        }
Ejemplo n.º 8
0
        public Report ImportReport(TDM api, Stream file)
        {
            Dictionary <string, string> headerData = new Dictionary <string, string>();

            using (TextReader reader = new StreamReader(file))
            {
                string line = reader.ReadLine();
                while (line != null)
                {
                    if (line.Contains("="))
                    {
                        string[] keyValue = line.Split(new char[] { '=' });
                        headerData.Add(keyValue[0], keyValue[1]);
                    }
                    line = reader.ReadLine();
                }
            }
            UUTReport uut = CreateReportFromHeader(headerData, api);
            //2020-5-20-135-5-14-10-1-37-563-120-1.589E+09
            Regex regex = new Regex(@"(?<Year>\d+)-(?<Month>\d+)-(?<WeekNo>-*\d+)-(?<JDay>-*\d+)-(?<WDay>\d+)-(?<Day>\d+)-(?<Hour>\d+)-(?<Minute>\d+)-(?<Second>\d+)-(?<MSec>\d+)-(?<UTCOffset>\d+)");
            Match match = regex.Match(headerData["Cfg_DutStartTime"]);

            uut.StartDateTime = new DateTime(
                int.Parse(match.Groups["Year"].Value),
                int.Parse(match.Groups["Month"].Value),
                int.Parse(match.Groups["Day"].Value),
                int.Parse(match.Groups["Hour"].Value),
                int.Parse(match.Groups["Minute"].Value),
                int.Parse(match.Groups["Second"].Value),
                int.Parse(match.Groups["MSec"].Value)
                );
            uut.StartDateTimeUTC = uut.StartDateTime.AddMinutes(-int.Parse(match.Groups["UTCOffset"].Value));
            uut.AddMiscUUTInfo("FileName", api.ConversionSource.SourceFile.Name);
            string testDataFolderName = $"{api.ConversionSource.SourceFile.DirectoryName}\\{Path.GetFileNameWithoutExtension(api.ConversionSource.SourceFile.Name)}";

            string[] dataFileNames = Directory.GetFiles(testDataFolderName, "*.txt");
            foreach (string fileName in dataFileNames)
            {
                ReadDataFile(uut, fileName);
            }
            uut.Status = headerData["Ctrl_OverallVerdict"] == "1" ? UUTStatusType.Passed : UUTStatusType.Failed;
            //Code for overall verdict: -1: Void, no result 0: Fail, nok 1: Pass, ok 2: Warning 3: Noise 4: Invalid
            return(uut);
        }
Ejemplo n.º 9
0
 private void ReadTests(UUTReport uut, XElement testRun)
 {
     foreach (XElement testGroup in testRun.Elements("testgroup"))
     {
         SequenceCall sequence = uut.GetRootSequenceCall().AddSequenceCall(testGroup.Attribute("name").Value);
         foreach (XElement testFunction in testGroup.Elements("testfunction"))
         {
             XElement       result     = testFunction.Element("result");
             PassFailStep   step       = sequence.AddPassFailStep(testFunction.Attribute("name").Value);
             StepStatusType stepStatus = (StepStatusType)Enum.Parse(typeof(StepStatusType), result.Attribute("value").Value);
             step.AddTest(stepStatus == StepStatusType.Passed, stepStatus);
             step.ReportText = testFunction.Element("text-output").Value;
             if (testFunction.Element("time-taken") != null)
             {
                 step.StepTime = double.Parse(testFunction.Element("time-taken").Value) / 1000.0;
             }
         }
     }
 }
Ejemplo n.º 10
0
        private void ReadGraphData(UUTReport unitTestReport, string[] columns, string measureName, string xUnit, string yUnit, ref double[] xValues)
        {
            List <double> values = new List <double>();

            for (int i = 3; i < columns.Length; i++)
            {
                if (!string.IsNullOrEmpty(columns[i]))
                {
                    values.Add(double.Parse(columns[i], cultureInfo));
                }
            }

            if (xValues == null)
            {
                xValues = values.ToArray();
                return;
            }
            NumericLimitStep numericLimitStep = unitTestReport.GetRootSequenceCall().AddNumericLimitStep(measureName);
            Chart            chart            = numericLimitStep.AddChart(ChartType.LineLogY, measureName, "X", xUnit, "Y", yUnit);

            chart.AddSeries(measureName, xValues, values.ToArray());
            xValues = null;
        }
Ejemplo n.º 11
0
 private void ReadDataFile(UUTReport uut, string fileName)
 {
     string[] seqName = Path.GetFileNameWithoutExtension(fileName).Split(new char[] { '-' });
     if (currentSequence == null || currentSequence.Name != seqName[0])
     {
         currentSequence = uut.GetRootSequenceCall().AddSequenceCall(seqName[0]);
     }
     using (TextReader reader = new StreamReader(fileName))
     {
         string   line    = reader.ReadLine();
         string[] headers = line.Split(new char[] { '\t' });
         line = reader.ReadLine();
         List <double> x   = new List <double>();
         List <double> y   = new List <double>();
         List <double> min = new List <double>();
         List <double> max = new List <double>();
         while (line != null)
         {
             if (headers[0] == "name") //Single measure
             {
                 NumericLimitStep numericLimitStep = currentSequence.AddNumericLimitStep(line.Split(new char[] { '\t' }).First());
                 double[]         values           = ReadDoubles(line);
                 //Format: name	value	max	min
                 if (double.IsNaN(values[2])) //No limits
                 {
                     numericLimitStep.AddTest(values[1], "");
                 }
                 else if (!double.IsNaN(values[3]) && !double.IsNaN(values[2]))
                 {
                     numericLimitStep.AddTest(values[1], CompOperatorType.GELE, values[3], values[2], "");
                 }
                 else
                 {
                     throw new NotImplementedException("Assumed no limits or max / min");
                 }
             }
             else if (headers[0] == "frq")
             {
                 double[] values = ReadDoubles(line);
                 if (values.Length == 1)
                 {
                 }                           //No Y value, skip
                 else
                 {
                     x.Add(values[0]);
                     y.Add(values[1]);
                     if (values.Length == 4)
                     {
                         max.Add(values[2]);
                         min.Add(values[3]);
                     }
                     else if (values.Length == 3)
                     {
                         max.Add(values[2]);
                     }
                     else
                     {
                         throw new NotImplementedException("Assumed x,y,min,max or x,y,max");
                     }
                 }
             }
             else
             {
                 throw new NotImplementedException("Assumed either name or frq in header");
             }
             line = reader.ReadLine();
         }
         if (headers[0] == "frq")
         {
             NumericLimitStep numericLimitStep = currentSequence.AddNumericLimitStep(headers[1]);
             numericLimitStep.AddMultipleTest(y.Average(), "Hz", "avg");
             if (min.Count > 0)
             {
                 numericLimitStep.AddMultipleTest(y.Min(), "Hz", "min");
             }
             if (max.Count > 0)
             {
                 numericLimitStep.AddMultipleTest(y.Max(), "Hz", "max");
             }
             int errorCount = 0;
             for (int i = 0; i < y.Count; i++)
             {
                 if (i < max.Count && double.IsNaN(max[i])) //Skip if limit is Nan or not exist
                 {
                     continue;
                 }
                 if (i < min.Count && double.IsNaN(min[i]))
                 {
                     continue;
                 }
                 if (y[i] > max[i])
                 {
                     errorCount++;
                 }
                 if (min.Count > 0 && y[i] < min[i])
                 {
                     errorCount++;
                 }
             }
             numericLimitStep.AddMultipleTest(errorCount, CompOperatorType.LT, 1, "#", "OutOfBounds");
             Chart chart = numericLimitStep.AddChart(ChartType.LineLogX, headers[1], "Frequency", "Hz", "res", "");
             chart.AddSeries("values", x.ToArray(), y.ToArray());
             if (min.Count > 0)
             {
                 chart.AddSeries("min", x.ToArray(), min.ToArray());
             }
             if (max.Count > 0)
             {
                 chart.AddSeries("max", x.ToArray(), max.ToArray());
             }
         }
     }
 }