Example #1
0
        private IList <Section> GetSections(int productId)
        {
            var results = new List <Section>();

            using (var connection = new SqlConnection(_connectionString))
            {
                var commandText = @"SELECT [Sections].[Id] AS 'Id', [Sections].[Name] AS 'Name'
					FROM [Properties]
					JOIN [Sections] ON [SectionId] = [Sections].[Id]
					WHERE [ProductId] = @productId
					GROUP BY [Sections].[Name], [Sections].[Id]
				"                ;
                var command     = new SqlCommand(commandText, connection);
                command.AddParameter("@productId", SqlDbType.Int, productId);

                try
                {
                    connection.Open();

                    var reader = command.ExecuteReader();

                    while (reader.Read())
                    {
                        var sectionId = 0; if (!reader.IsDBNull("Id"))
                        {
                            sectionId = reader.GetInt32("Id");
                        }
                        var sectionName = ""; if (!reader.IsDBNull("Name"))
                        {
                            sectionName = reader.GetString("Name");
                        }

                        var section = new Section(sectionName);
                        section.AddRange(GetProperties(productId, sectionId));

                        results.Add(section);
                    }
                }
                catch (Exception)
                {
                    throw;
                }
            }

            return(results);
        }
        // split a list of sections into smaller sections
        public static List <Section> SplitAll(List <Section> sections, out List <Edge> edges)
        {
            edges = new List <Edge> ();
            List <Section> nsections = new List <Section> ();

            for (int i = 0; i < sections.Count; i++)
            {
                int   s1      = 0;
                int   s2      = 0;
                float maxlen1 = 0;
                float maxlen2 = 0;
                float minlen  = float.PositiveInfinity;

                for (int j = 0; j < sections[i].Count; j++)
                {
                    float l = EdgeTool.EstLen(sections [i] [j]);
                    if (l > maxlen1)
                    {
                        s1      = j;
                        maxlen1 = l;
                    }
                    else if (l > maxlen2)
                    {
                        s2      = j;
                        maxlen2 = l;
                    }
                    if (l < minlen)
                    {
                        minlen = l;
                    }
                }

                if (EstArea(sections[i]) < 100 || minlen < 5)
                {
                    nsections.Add(sections [i]);
                    continue;
                }

                if (s2 < s1)
                {
                    int temp = s2;
                    s2 = s1;
                    s1 = temp;
                }

                Edge e1   = sections [i] [s1];
                Edge e2   = sections [i] [s2];
                int  mid1 = (int)Mathf.Floor(e1.Count / 2);
                int  mid2 = (int)Mathf.Floor(e2.Count / 2);

                Vector2 p1 = Vector2.Lerp(e1[mid1], e1[(mid1 + 1) % e1.Count], 0.5f);
                Vector2 p2 = Vector2.Lerp(e2[mid2], e2[(mid2 + 1) % e2.Count], 0.5f);

                Edge e11 = e1.GetRange(0, mid1);
                Edge e12 = e1.GetRange(mid1 + 1, e1.Count - mid1 - 1);
                Edge e21 = e2.GetRange(0, mid2);
                Edge e22 = e2.GetRange(mid2 + 1, e2.Count - mid2 - 1);

                e11.Add(p1);
                e12.Insert(0, p1);
                e21.Add(p2);
                e22.Insert(0, p2);

                //Edge en1 = new List<Vector2>(new Vector2[]{p1,p2});
                Edge en1 = EdgeTool.MakeCurve(p1, p2);
                edges.Add(en1);
                Edge en2 = new List <Vector2> ();
                en2.AddRange(en1);
                en2.Reverse();

                int len = sections [i].Count;

                Section left = new Section();

                left.Add(en2);
                left.Add(e12);
                left.AddRange(sections [i].GetRange((s1 + 1) % len, s2 - s1 - 1));
                left.Add(e21);

                Section right = new Section();
                right.Add(en1);
                right.Add(e22);
                right.AddRange(sections [i].GetRange((s2 + 1) % len, len - (s2 + 1)));
                right.AddRange(sections [i].GetRange(0, s1));
                right.Add(e11);

                Clean(left);
                Clean(right);

                nsections.Add(left);
                nsections.Add(right);
            }
            return(nsections);
        }
Example #3
0
        protected Section ConstructReportSection(ReportSections section, CycleList cycles)
        {
            Section sec = null;
            if (!(bool)selectedReportSections.GetValue((int)section))
                return sec;
            try
            {
                switch (section)
                {
                    // these have multiple rows based on the report content
                    case ReportSections.CycleSource:
                        sec = new Section(typeof(CycleSource), 1, 1, 1, "Cycle");
                        sec[1].Add(0, "Cycle source");
                        break;
                    case ReportSections.MultiplicityDistributions:
                        sec = DoAcrossForManyMults("Cycle multiplicity distributions", typeof(eMultiplicityDistributions), true);
                        break;
                    case ReportSections.ChannelCounts:
                        break;
                    case ReportSections.ChannelRates:
                        break;
                    case ReportSections.ComputedMultiplicityIntermediates:
                        sec = DoAcrossForManyMults("Cycle moments (NNV)", typeof(ComputedMultiplicityIntermediates), true);
                        break;
                    case ReportSections.RawCycles:
                    {
                        ConstructedSource src = ConstructedSource.Unknown;
                        InstrType inst = InstrType.Unknown;
                        if (cycles.Count > 0)
                        {
                            src = cycles[0].DataSourceId.source;
                            inst = cycles[0].DataSourceId.SRType;
                        }
                        if (cycles.Count > 0 && src.MightHaveScalerData(inst)) // anything that might have Scaler data
                            sec = DoAcrossForManyMults("Cycle raw data", typeof(INCCCycles), true);
                        else
                            sec = DoAcrossForManyMults("Cycle raw data", typeof(RawCycles), true);
                    }
                        break;
                    case ReportSections.DTCRateCycles:
                        sec = DoAcrossForManyMults("Cycle DTC rate data", typeof(DTCRateCycles), true);
                        break;
                    case ReportSections.RateCycles:
                        sec = DoAcrossForManyMults("Cycle rate data", typeof(RateCycles), true);
                        break;
                    case ReportSections.RepResults:
                        break;
                    case ReportSections.RepDytlewskiResults:

                        break;
                }
                if (sec == null) // no mult-based data
                    return sec;
                Row[] temp = null;
                foreach (Cycle cyc in cycles)
                {
                    switch (section)
                    {
                        // these have multiple rows based on the report content
                        case ReportSections.MultiplicityDistributions:
                            int repeat = meas.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity));
                            temp = GenMultDistRows(cyc.CountingAnalysisResults, cyc.seq); // done: uses # of analyzers and goes across
                            Section sec2 = new Section(typeof(eMultiplicityDistributions), 0, 0, temp.Length, "Cycle " + cyc.seq, repeat);
                            sec.AddRange(sec2);
                            sec.AddRange(temp);
                            break;
                        case ReportSections.ChannelCounts:
                            //    sec.Add(GenChannelCountsRows(cyc));
                            break;
                        case ReportSections.ChannelRates:
                            //    sec.Add(GenChannelCountsRows(cyc));
                            break;
                        case ReportSections.ComputedMultiplicityIntermediates:
                            temp = GenMultiplicityIntermediatesRow(cyc.CountingAnalysisResults, cyc); // alpha and beta are only in the summary because they do not change (gatelength-based)
                            sec.AddRange(temp);
                            break;
                        case ReportSections.RawCycles:
                            if (cyc.DataSourceId.source.SRDAQ(cyc.DataSourceId.SRType))
                                sec.Add(GenINCCCycleRow(cyc));
                            else
                                sec.Add(GenRawCycleRow(cyc)); // done: uses # of analyzers and goes across
                            break;
                        case ReportSections.DTCRateCycles:
                            sec.Add(GenRateCycleRow(cyc, dtc:true));  // # of analyzers and goes across
                            break;
                        case ReportSections.RateCycles:
                            sec.Add(GenRateCycleRow(cyc));
                            break;
                        case ReportSections.RepResults:
                            //    sec.Add(GenResultsCycleRow(cyc));
                            break;
                        case ReportSections.RepDytlewskiResults:
                            //    sec.Add(GenDytlewskiResultsCycleRow(cyc));
                            break;
                        case ReportSections.CycleSource:
                            sec.Add(GenCycleSourceRow(cyc));
                            break;
                    }
                }
            }
            catch (Exception e)
            {
                ctrllog.TraceException(e);
            }
            return sec;
        }
Example #4
0
        /*
         * call ConstructReportSections with a cycle to
         *   gen empty row
         *   gen header row
         *   gen data row(s)
         */
        protected Section ConstructReportSection(ReportSections section)
        {
            Section sec = null;
            if (!(bool)selectedReportSections.GetValue((int)section))
                return sec;
            try
            {
                Row[] temp;
                switch (section)
                {
                    case ReportSections.SofwareContext:
                        temp = GenSoftwareConfigRows();
                        sec = new Section(null, 1, 1, temp.Length);
                        sec[1].Add(0, "Software application configuration details");
                        sec.InsertRange(sec.dataidx, temp);
                        break;
                    case ReportSections.DescriptiveSummary:
                        sec = new Section(typeof(DescriptiveSummary), 0, 1, 1);
                        sec.Add(GenDescriptiveSummaryRow());
                        break;
                    case ReportSections.MeasurementDetails:
                        sec = new Section(typeof(MeasurementDetails), 0, 1, 1);
                        sec.Add(GenMeasurementDetailsRow(meas.CountingAnalysisResults.HasMultiplicity));
                        break;
                    case ReportSections.DetectorCalibration:

                        sec = new Section(typeof(DetectorCalibration), 0, 1, 1);
                        Row hcrow = sec[sec.Count - 1];
                        hcrow.Clear();
                        hcrow.TS = DetectorCalibrationHeader;
                        if (meas.CountingAnalysisResults.HasMultiplicity)
                        {
                            hcrow.GenFromEnum(typeof(DetectorCalibration), null, 0);
                            // there is a disconnect between the detector list and the Instrument list,
                            // there is disconnect between the detector and the subordinate SR analyzer param sets;
                            IEnumerator iter = meas.CountingAnalysisResults.GetMultiplicityEnumerator(true);
                            while (iter.MoveNext())
                            {
                                Multiplicity mkey = (Multiplicity)((KeyValuePair<SpecificCountingAnalyzerParams, object>)(iter.Current)).Key;
                                sec.Add(GenDetectorCalibrationRow(meas.Detector, mkey));
                            }
                        }
                        else
                        {
                            hcrow.GenFromEnum(typeof(BaseDetectorCalibration), null, 0);
                            sec.Add(GenDetectorCalibrationRow(meas.Detector));
                        }

                        break;
                    case ReportSections.ComputedMultiplicityIntermediates:
                        // RA, A, alpha, beta
                        // 0...3 rows
                        //sec = DoAcrossForManyMults("Averaged moments (NNV)", typeof(ComputedMultiplicityIntermediates), false);
                        //temp = GenMultiplicityIntermediatesRow(m.CountingAnalysisResults);
                        //sec.AddRange(temp);
                        break;
                    case ReportSections.ChannelCounts:
                        temp = GenChannelCountsRows();
                        sec = new Section(typeof(ChannelCounts), 1, 1, temp.Length);
                        sec[1].Add(0, "Hits per channel sums");
                        sec.InsertRange(sec.dataidx, temp);
                        break;
                    case ReportSections.ChannelRates:
                        temp = GenChannelRatesRows();
                        sec = new Section(typeof(ChannelCounts), 1, 1, temp.Length);
                        sec[1].Add(0, "Channel hits per second (averaged over the cycles)");
                        sec.InsertRange(sec.dataidx, temp);
                        break;
                    case ReportSections.RawAndMultSums:
                        sec = DoAcrossForManyMults("Summed cycle data", typeof(RawSums), false);
                        if (sec != null)
                        {
                            sec.Add(GenRawSumsRow(meas.CountingAnalysisResults));  // done: uses # of analyzers and goes across
                            temp = GenMultDistRows(meas.CountingAnalysisResults, 0); //done: sum for all analyzers, see method comments
                            Section sec2 = new Section(typeof(DistributionsAndAlphaBeta), 0, 0, temp.Length, "Bin", meas.CountingAnalysisResults.GetResultsCount(typeof(Multiplicity)));
                            sec.AddRange(sec2);
                            sec.AddRange(temp);
                        }
                        break;
                }
            }
            catch (Exception e)
            {
                ctrllog.TraceException(e);
            }
            return sec;
        }