Beispiel #1
0
        /// <summary>
        /// Fills Excel with useful information about the reads process
        /// </summary>
        /// <param name="R1"></param>
        /// <param name="R2"></param>
        /// <param name="oSheetData"></param>
        /// <param name="readsDuration"></param>
        private static void FillExcelWithReadersTotals(UHFReader R1, UHFReader R2, Excel._Worksheet oSheetData, string readsDuration)
        {
            if (R1 != null && R2 != null)
            {
                #region Format Cells

                Excel.Range newRng = oSheetData.get_Range(String.Format("M1:M{0}", 18));

                newRng.Interior.Color = Excel.XlRgbColor.rgbOlive;

                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft).LineStyle   = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeRight).LineStyle  = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop).LineStyle    = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous;

                #endregion

                /// UHFReader Inventory counter for Reader 1
                UHFReaderInvCounter ric1 = R1.RIC;

                /// UHFReader Inventory counter for Reader 2
                UHFReaderInvCounter ric2 = R2.RIC;

                /// Line number on Excel
                int lineStart = 1;

                /// Column number on Excel
                int column = 13;

                oSheetData.Cells[lineStart++, column] = String.Format("Reads Duration (ms): {0}", readsDuration);

                lineStart = 11;

                oSheetData.Cells[lineStart++, column] = String.Format("Total Invs (no Tags): {0}", ric1.invsWithoutTags + ric2.invsWithoutTags);
                oSheetData.Cells[lineStart++, column] = String.Format("Total Invs (with Tags): {0}", ric1.invsWithTags + ric2.invsWithTags);

                ///Total number of Inventaries that were gotten both Reader 1 and Reader 2
                int totalInvs = ric1.invsWithoutTags + ric1.invsWithTags + ric2.invsWithoutTags + ric2.invsWithTags;

                oSheetData.Cells[lineStart++, column] = String.Format("Total Invs (Total): {0} => {1:0.00}%/{2:0.00}%",
                                                                      totalInvs,
                                                                      ((double)ric1.invsWithTags + ric2.invsWithTags) / totalInvs * 100,
                                                                      ((double)ric1.invsWithoutTags + ric2.invsWithoutTags) / totalInvs * 100);

                lineStart++;

                oSheetData.Cells[lineStart++, column] = String.Format("Total Nº tags: {0}", ric2.numTagsFound + ric2.numTagsFound);
                oSheetData.Cells[lineStart++, column] = String.Format("Total MIN tags: {0}", Math.Min(ric1.numTagsFoundMin, ric2.numTagsFoundMin));
                oSheetData.Cells[lineStart++, column] = String.Format("Total AVG tags: {0:0.00}", (ric1.GetTagsAvg() + ric2.GetTagsAvg()) / 2);
                oSheetData.Cells[lineStart++, column] = String.Format("Total MAX tags: {0}", Math.Max(ric1.numTagsFoundMax, ric2.numTagsFoundMax));
            }
        }
Beispiel #2
0
        /// <summary>
        /// Fills Excel with list os metatags of reader and other useful information about the reads process
        /// </summary>
        /// <param name="reader"></param>
        /// <param name="oSheetData"></param>
        /// <param name="columnStart"></param>
        /// <param name="readerNum"></param>
        private static void FillExcelWithReaderInfo(UHFReader reader, Excel._Worksheet oSheetData, int columnStart, int readerNum)
        {
            if (reader == null)
            {
                return;
            }

            if (readerNum == 1)
            {
                /// format Reader 1 cells

                Excel.Range newRng = oSheetData.get_Range(String.Format("A1:E{0}", reader.MetaTagsDictionary.Count + 21));

                newRng.Interior.Color = Excel.XlRgbColor.rgbOrange;

                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft).LineStyle   = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeRight).LineStyle  = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop).LineStyle    = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous;
            }
            else
            {
                /// format Reader 2 cells

                Excel.Range newRng = oSheetData.get_Range(String.Format("G1:K{0}", reader.MetaTagsDictionary.Count + 21));

                newRng.Interior.Color = Excel.XlRgbColor.rgbOrchid;

                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeLeft).LineStyle   = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeRight).LineStyle  = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeTop).LineStyle    = Excel.XlLineStyle.xlContinuous;
                newRng.Borders.get_Item(Excel.XlBordersIndex.xlEdgeBottom).LineStyle = Excel.XlLineStyle.xlContinuous;
            }

            #region Initialize local vareables

            /// UHFReader Inventory counter
            UHFReaderInvCounter ric = reader.RIC;

            /// UHFReader Inventory parameters
            UHFReaderInvParams rip = reader.InvParams;

            /// List with MetaTags
            List <MetaTag> lmt = new List <MetaTag>();

            /// Dictionary that represents the line number on Excel for the EPC of this Reader
            /// Key => EPC
            /// Value => counter
            Dictionary <string, int> dic = new Dictionary <string, int>();

            /// Represents line number on Excel
            int counter = 1;

            #endregion

            foreach (string epc in reader.MetaTagsDictionary.Keys)
            {
                /// Add MetaTag
                lmt.Add(reader.MetaTagsDictionary[epc]);

                /// Add EPC with line number on Excel
                dic.Add(epc, counter++);
            }

            lmt.Sort();

            /// Reader line number on Excel
            int rcL = 1;

            oSheetData.Cells[rcL++, columnStart - 1] = String.Format("R{0}", readerNum);

            oSheetData.Cells[rcL++, columnStart] = String.Format("Frequency min: {0} MHz", reader.MinFrequency);
            oSheetData.Cells[rcL++, columnStart] = String.Format("Frequency Max: {0} MHz", reader.MaxFrequency);
            oSheetData.Cells[rcL++, columnStart] = String.Format("Power: {0} dBm", reader.PowerDbm);

            rcL++;

            oSheetData.Cells[rcL++, columnStart] = String.Format("Q: {0}", rip.QValue);
            oSheetData.Cells[rcL++, columnStart] = String.Format("S: {0}", rip.Session);
            oSheetData.Cells[rcL++, columnStart] = String.Format("T: {0}", rip.Target);
            oSheetData.Cells[rcL++, columnStart] = String.Format("Commute: {0}", rip.ConvertTagFlagWhenFailedReads);

            rcL++;

            oSheetData.Cells[rcL++, columnStart] = String.Format("Invs (no Tags): {0}", ric.invsWithoutTags);
            oSheetData.Cells[rcL++, columnStart] = String.Format("Invs (with Tags): {0}", ric.invsWithTags);

            /// Total number of Inventaries that were gotten by Reader
            int totalInvsReader = ric.invsWithoutTags + ric.invsWithTags;

            oSheetData.Cells[rcL++, columnStart] = String.Format("Invs (Total): {0} => {1:0.00}%/{2:0.00}%",
                                                                 totalInvsReader,
                                                                 (double)ric.invsWithTags / totalInvsReader * 100,
                                                                 (double)ric.invsWithoutTags / totalInvsReader * 100);

            rcL++;

            oSheetData.Cells[rcL++, columnStart] = String.Format("Nº tags: {0}", ric.numTagsFound);
            oSheetData.Cells[rcL++, columnStart] = String.Format("MIN tags: {0}", ric.numTagsFoundMin);
            oSheetData.Cells[rcL++, columnStart] = String.Format("AVG tags: {0:0.00}", ric.GetTagsAvg());
            oSheetData.Cells[rcL++, columnStart] = String.Format("MAX tags: {0}", ric.numTagsFoundMax);

            rcL++;

            oSheetData.Cells[rcL, columnStart - 1] = "#";
            oSheetData.Cells[rcL, columnStart]     = "EPC";
            oSheetData.Cells[rcL, columnStart + 1] = "Times";
            oSheetData.Cells[rcL, columnStart + 2] = "RSSI";
            oSheetData.Cells[rcL, columnStart + 3] = "RSSI_AVG";
            oSheetData.get_Range(String.Format("A{0}:N{0}", rcL)).Columns.EntireColumn.AutoFit();
            oSheetData.get_Range(String.Format("A{0}:N{0}", rcL)).Font.Bold = true;

            rcL++;

            /// The summation of the times that each MetaTag was read
            int sumTimes = 0;

            foreach (MetaTag mt in lmt)
            {
                oSheetData.Cells[rcL, columnStart - 1] = dic[mt.EPC];
                oSheetData.Cells[rcL, columnStart]     = mt.EPC;
                oSheetData.Cells[rcL, columnStart + 1] = mt.RSSICounter;
                oSheetData.Cells[rcL, columnStart + 2] = mt.RSSI;
                oSheetData.Cells[rcL, columnStart + 3] = mt.RSSIAvg;

                sumTimes += mt.RSSICounter;

                rcL++;
            }
            oSheetData.Cells[rcL, columnStart - 1] = lmt.Count;
            oSheetData.Cells[rcL, columnStart + 1] = sumTimes;

            //-------------

            rcL += 2;

            /// newList gets all EPCs that are on dataset, but not in the lmt
            EPCsComparer.GetEpcsNotInList(lmt, out List <string> newList);

            /// EPC line number on Excel
            int newCounter = 1;

            /// Put Dataset label on Excel
            oSheetData.Cells[rcL++, columnStart] = newList[0];

            /// Remove Dataset Label
            newList.RemoveAt(0);

            foreach (string s in newList)
            {
                oSheetData.Cells[rcL, columnStart - 1] = newCounter++;
                oSheetData.Cells[rcL++, columnStart]   = s;
            }
        }