예제 #1
0
파일: Program.cs 프로젝트: opony/LinqToStdf
        static void Main(string[] args)
        {
            if ((args.Length < 1) || (args.Length > 2))
            {
                Usage();
                return;
            }

            var stdf = new StdfFile(args[0]);

            //silly query
            var query = from r in stdf.GetRecords()
                        select r;

            Console.WriteLine("There were {0} records!", query.Count());

            var testTimes = from prr in stdf.GetRecords().OfExactType <Prr>()
                            let testTime = prr.TestTime
                                           where testTime != null
                                           select testTime.Value / 1000.0;

            Console.WriteLine("Average Test Time: {0}", testTimes.Average());

            //Get PTR results from failing parts grouped by test number
            var results = from prr in stdf.GetRecords().OfExactType <Prr>()
                          where prr.Failed ?? false
                          from ptr in prr.GetChildRecords().OfExactType <Ptr>()
                          let result = ptr.Result
                                       where result != null
                                       group result.Value by ptr.TestNumber into g
                                       select new { TestNumber = g.Key, Results = g };

            foreach (var test in results)
            {
                Console.WriteLine("Test {0}:", test.TestNumber);
                foreach (var result in test.Results)
                {
                    Console.WriteLine("\t{0}", result);
                }
            }

            // Output STDF to a new file
            if (args.Length == 2)
            {
                Console.WriteLine("Writing to {0}...", args[1]);
                using (StdfFileWriter writer = new StdfFileWriter(args[1]))
                {
                    writer.WriteRecords(stdf.GetRecords());
                }
            }
        }
예제 #2
0
        static void Main(string[] args)
        {
            var            file    = new StdfFile(args[0]);
            StdfFileWriter outFile = null;

            if (args.Length > 1)
            {
                outFile = new StdfFileWriter(args[1]);
            }
            try {
                int  bytesWritten = 0;
                long bytesRead    = 0;
                foreach (var r in file.GetRecords())
                {
                    Console.WriteLine("Read Length: {0}", r.Offset - bytesRead);
                    bytesRead = r.Offset;
                    Console.WriteLine("{0}", r.GetType());
                    DumpRecord(r);
                    if (outFile != null)
                    {
                        bytesWritten = outFile.WriteRecord(r);
                        Console.WriteLine("Written Length: {0}", bytesWritten);
                    }
                }
            }
            finally {
                if (outFile != null)
                {
                    outFile.Dispose();
                }
            }
        }
예제 #3
0
        static void Main(string[] args)
        {
            StdfFile file = new StdfFile(@"c:\temp\test.stdf");
            IEnumerable <StdfRecord> records = file.GetRecords();

            int i = 0;

            foreach (var item in records)
            {
                i++;
                Console.WriteLine("STDF Record[{0}]: Type[{1}]", i, item.GetType().ToString());
            }
            Console.ReadKey();
        }
예제 #4
0
        private void Load_Click(object sender, RoutedEventArgs e)
        {
            var dialog = new OpenFileDialog();

            if (dialog.ShowDialog() ?? false)
            {
                var file = new StdfFile(new SilverlightStreamManager(dialog.SelectedFile));
                //don't throw
                file.ThrowOnFormatError = false;
                file.AddFilter(BuiltInFilters.V4ContentSpec);
                var data = new List <DisplayData>();
                var mir  = file.GetMir();
                if (mir == null)
                {
                    data.Add(new DisplayData {
                        Field = "Error",
                        Value = "No MIR found"
                    });
                }
                else
                {
                    data.Add(new DisplayData()
                    {
                        Field = "Lot ID",
                        Value = mir.LotId
                    });
                    data.Add(new DisplayData()
                    {
                        Field = "Mode Code",
                        Value = mir.ModeCode
                    });
                    data.Add(new DisplayData()
                    {
                        Field = "Setup Time",
                        Value = mir.SetupTime == null ? "NA" : mir.SetupTime.Value.ToString()
                    });
                    data.Add(new DisplayData()
                    {
                        Field = "Setup Time",
                        Value = mir.StartTime == null ? "NA" : mir.StartTime.Value.ToString()
                    });
                }
                var mrr = file.GetMrr();
                if (mrr == null)
                {
                    data.Add(new DisplayData {
                        Field = "Error",
                        Value = "No MRR found"
                    });
                }
                else
                {
                    data.Add(new DisplayData()
                    {
                        Field = "Finish Time",
                        Value = mrr.FinishTime == null ? "NA" : mrr.FinishTime.Value.ToString()
                    });
                    data.Add(new DisplayData()
                    {
                        Field = "Total Record Count",
                        Value = file.GetRecords().Count().ToString()
                    });
                }
                Data.ItemsSource = data;

                var errors = from r in file.GetRecords()
                             where r is ErrorRecord || r is UnknownRecord
                             select new ErrorData {
                    Offset = r.Offset,
                    Type   = r.GetType().Name,
                };
                Errors.ItemsSource = errors.ToList();
            }
        }
예제 #5
0
        public void ExtractStdf()
        {
            if (ParseDone)
            {
                return;
            }
            //private data
            bool[]   catchedPirFlag = null;
            TestID[] ptrLastTN      = null;
            int[]    InternalID     = null;

            _stdfFile = new StdfFile(FilePath);


            List <PinMapRecord>   listPinMaps   = new List <PinMapRecord>();
            List <PinGroupRecord> listPinGroups = new List <PinGroupRecord>();

            var rs = from r in _stdfFile.GetRecords()
                     select r;
            int siteIdx;

            foreach (var r in rs)
            {
                if (r.RecordType == StdfFile.PTR)
                {
                    if (!_sites.TryGetValue(((Ptr)r).SiteNumber, out siteIdx))
                    {
                        throw new Exception("No Site");
                    }
                    if (!catchedPirFlag[siteIdx])
                    {
                        throw new Exception("PIR Data Error");
                    }

                    TestID testID;
                    //compare with the previous test name to decide the testNO
                    if (ptrLastTN[siteIdx].CompareTestNumber(((Ptr)r).TestNumber))  //it's a sub test
                    {
                        testID = TestID.NewSubTestID(ptrLastTN[siteIdx]);
                        if (!_testItems.ExistTestItem(testID))
                        {
                            IItemInfo info = _testItems.GetItemInfo(ptrLastTN[siteIdx]);
                            info.SetTestText(((Ptr)r).TestText);
                            _testItems.AddTestItem(testID, info);
                            _rawData.AddItem();
                        }
                    }
                    else
                    {
                        testID = new TestID(((Ptr)r).TestNumber);
                        if (!_testItems.ExistTestItem(testID))
                        {
                            _testItems.AddTestItem(testID, new ItemInfo(((Ptr)r).TestText, ((Ptr)r).LowLimit, ((Ptr)r).HighLimit,
                                                                        ((Ptr)r).Units, ((Ptr)r).LowLimitScalingExponent, ((Ptr)r).HighLimitScalingExponent, ((Ptr)r).ResultScalingExponent));
                            _rawData.AddItem();
                        }
                    }
                    _rawData.Set(_testItems.GetIndex(testID), InternalID[siteIdx], _testItems.GetItemInfo(testID).GetScaledRst(((Ptr)r).Result));

                    ptrLastTN[siteIdx] = testID;
                }
                else if (r.RecordType == StdfFile.FTR)
                {
                    if (!_sites.TryGetValue(((Ftr)r).SiteNumber, out siteIdx))
                    {
                        throw new Exception("No Site");
                    }

                    if (!catchedPirFlag[siteIdx])
                    {
                        throw new Exception("PIR Data Error");
                    }

                    TestID testID;
                    //compare with the previous test name to decide the testNO
                    if (!ptrLastTN[siteIdx].CompareTestNumber(((Ftr)r).TestNumber))  //it's a unused test, ftr do not set sub test
                    {
                        testID = new TestID(((Ftr)r).TestNumber);

                        if (!_testItems.ExistTestItem(testID))
                        {
                            _testItems.AddTestItem(testID, new ItemInfo(((Ftr)r).TestText, (float)0.5, (float)1.5, "", 0, 0, 0));
                            _rawData.AddItem();
                        }

                        _rawData.Set(_testItems.GetIndex(testID), InternalID[siteIdx], ((Ftr)r).Results);

                        ptrLastTN[siteIdx] = testID;
                    }
                }
                else if (r.RecordType == StdfFile.MPR)
                {
                    if (!_sites.TryGetValue(((Mpr)r).SiteNumber, out siteIdx))
                    {
                        throw new Exception("No Site");
                    }

                    if (!catchedPirFlag[siteIdx])
                    {
                        throw new Exception("PIR Data Error");
                    }

                    TestID testItemID;
                    if (ptrLastTN[siteIdx].CompareTestNumber(((Mpr)r).TestNumber))  //it's a sub test
                    {
                        testItemID = TestID.NewSubTestID(ptrLastTN[siteIdx]);
                    }
                    else
                    {
                        testItemID = new TestID(((Mpr)r).TestNumber);
                    }

                    TestID testID = testItemID;

                    for (uint i = 0; i < ((Mpr)r).Results.Count(); i++)
                    {
                        PinMapRecord pin = new PinMapRecord();
                        if (siteIdx == 0 && ((Mpr)r).PinIndexes != null)
                        {
                            pin = listPinMaps.Find(x => x.PinIndex == ((Mpr)r).PinIndexes[i]);
                        }
                        //else
                        //    throw new Exception("MPR Pin doesn't exist");

                        if (i > 0)
                        {
                            testID = TestID.NewSubTestID(testID);
                        }

                        if (!_testItems.ExistTestItem(testID))
                        {
                            _testItems.AddTestItem(testID, new ItemInfo(((Mpr)r).TestText + "<>" + pin.LogicalName, ((Mpr)r).LowLimit, ((Mpr)r).HighLimit,
                                                                        ((Mpr)r).Units, ((Mpr)r).LowLimitScalingExponent, ((Mpr)r).HighLimitScalingExponent, ((Mpr)r).ResultScalingExponent));
                            _rawData.AddItem();
                        }

                        _rawData.Set(_testItems.GetIndex(testID), InternalID[siteIdx], _testItems.GetItemInfo(testID).GetScaledRst(((Mpr)r).Results[i]));
                    }

                    ptrLastTN[siteIdx] = testItemID;
                }
                else if (r.RecordType == StdfFile.MIR)
                {
                    BasicInfo = new FileBasicInfo((Mir)r);
                    continue;
                }
                else if (r.RecordType == StdfFile.SDR)
                {
                    for (int i = 0; i < ((Sdr)r).SiteNumbers.Length; i++)
                    {
                        _sites.Add(((Sdr)r).SiteNumbers[i], i);
                    }

                    catchedPirFlag = new bool[((Sdr)r).SiteNumbers.Count()];
                    InternalID     = new int[((Sdr)r).SiteNumbers.Count()];

                    ptrLastTN = new TestID[((Sdr)r).SiteNumbers.Count()];
                }
                else if (r.RecordType == StdfFile.PMR)
                {
                    listPinMaps.Add(new PinMapRecord((Pmr)r));
                }
                else if (r.RecordType == StdfFile.PGR)
                {
                    listPinGroups.Add(new PinGroupRecord((Pgr)r, listPinMaps));
                }
                else if (r.RecordType == StdfFile.PIR)
                {
                    if (!_sites.TryGetValue(((Pir)r).SiteNumber, out siteIdx))
                    {
                        throw new Exception("No Site");
                    }

                    if (!catchedPirFlag[siteIdx])
                    {
                        catchedPirFlag[siteIdx] = true;
                    }
                    else
                    {
                        throw new Exception("PIR Data Error");
                    }

                    ptrLastTN[siteIdx] = new TestID();

                    InternalID[siteIdx] = _rawData.AddChip();
                }
                else if (r.RecordType == StdfFile.BPS)
                {
                    //do nothing
                }
                else if (r.RecordType == StdfFile.EPS)
                {
                    //do nothing
                }
                else if (r.RecordType == StdfFile.PRR)
                {
                    if (!_sites.TryGetValue(((Prr)r).SiteNumber, out siteIdx))
                    {
                        throw new Exception("No Site");
                    }

                    if (!catchedPirFlag[siteIdx])
                    {
                        throw new Exception("PIR Data Error");
                    }
                    else
                    {
                        catchedPirFlag[siteIdx] = false;
                    }

                    _testChips.AddChip(new ChipInfo((Prr)r, InternalID[siteIdx]));
                }
                else if (r.RecordType == StdfFile.TSR)
                {
                    var v = ((Tsr)r).TestLabel;

                    if (v != null && v != "")
                    {
                        _testItems.UpdateTestText(new TestID(((Tsr)r).TestNumber), v);
                    }
                }
                else if (r.RecordType == StdfFile.MRR)
                {
                    ((FileBasicInfo)BasicInfo).AddMrr((Mrr)r);
                }
            }
            ParseDone = true;

            _testChips.UpdateSummary(ref _defaultSitesSummary);
            _defaultSummary = ChipSummary.Combine(_defaultSitesSummary);
            OnExtractDone(this);

            _stdfFile = null;
            rs        = null;

            GC.Collect();

            CreateDefaultFilters();
        }