Ejemplo n.º 1
0
        private void btnSimulationStart_Click(object sender, EventArgs e)
        {
            if ((int)nudTagIndexForHologram.Value >= dgvSimulationTagPosition.RowCount - 1)
            {
                MessageBox.Show("Tag Index is out of range!");

                btnHolographicsConfirm.Enabled = true;
                btnSimulationStart.Enabled     = false;

                cbAlgorithms.Enabled   = true;
                gbHologram.Enabled     = true;
                gbSearchRegion.Enabled = true;
                gbAntennaTrack.Enabled = true;

                return;
            }

            SARParameter.Simulation.Tags  = new List <string>();
            SARParameter.Simulation.TagXs = new List <double>();
            SARParameter.Simulation.TagYs = new List <double>();
            SARParameter.Simulation.TagZs = new List <double>();

            if (dgvSimulationTagPosition.RowCount == 1)
            {
                MessageBox.Show("Please at least input one tag information!");
                return;
            }

            for (int i = 0; i < dgvSimulationTagPosition.RowCount; i++)
            {
                string tagEPC = (string)dgvSimulationTagPosition.Rows[i].Cells[0].Value;
                if (tagEPC != null)
                {
                    SARParameter.Simulation.Tags.Add(tagEPC);

                    SARParameter.Simulation.TagXs.Add(Convert.ToDouble(dgvSimulationTagPosition.Rows[i].Cells[1].Value));
                    SARParameter.Simulation.TagYs.Add(Convert.ToDouble(dgvSimulationTagPosition.Rows[i].Cells[2].Value));
                    SARParameter.Simulation.TagZs.Add(Convert.ToDouble(dgvSimulationTagPosition.Rows[i].Cells[3].Value));

                    SyntheticApertureRadar sar = new SyntheticApertureRadar();
                    _sar.Add(tagEPC, sar);
                }
            }


            // Define a timer to simulate the online situation
            _timers          = new System.Timers.Timer();
            _timers.Enabled  = true;
            _timers.Interval = Convert.ToDouble(tbxSimulationSamplingTime.Text.Trim()) * 1000;
            _timers.Elapsed += new System.Timers.ElapsedEventHandler(Timers_Elapsed);
            _timers.Start();

            _th = new Thread(SARThread);
            _th.IsBackground = true;
            _th.Start();

            gbSimulationTagPosition.Enabled = false;
            gbSimulationFrequncy.Enabled    = false;

            btnSimulationStart.Enabled = false;
            btnSimulationStop.Enabled  = true;
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Update basic information ListView Once receiving a new tag report from RFID reader
        /// </summary>
        /// <param name="tagInfo">an object containing all information of a tag in one tag report</param>
        public void UpdateListView(TagInfo tagInfo)
        {
            //Update counter in status strip
            tsslblCounter.Text = tagInfo.TotalTagCount.ToString();
            //Update run time in status strip
            UpdateRunTime();

            _tagsTable.AddTagInfo(tagInfo);

            ListViewItem foundItem = lvBasicInfo.FindItemWithText(tagInfo.EPC);

            if (foundItem != null)
            {
                // Tag already exists
                foundItem.SubItems[2].Text = tagInfo.Antenna.ToString();
                foundItem.SubItems[3].Text = tagInfo.ChannelIndex.ToString();
                foundItem.SubItems[4].Text = tagInfo.RSSI.ToString();
                foundItem.SubItems[5].Text = tagInfo.AcutalPhaseInRadian.ToString();
                foundItem.SubItems[6].Text = tagInfo.DopplerShift.ToString();
                foundItem.SubItems[7].Text = tagInfo.Velocity.ToString();
                foundItem.SubItems[8].Text = Convert.ToString(Convert.ToInt32(foundItem.SubItems[8].Text) + 1);
                //if (tabControlChart.SelectedTab.Text != "Holographics")

                chartRSSI.Series[foundItem.Index].Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.RSSI);
                chartPhase.Series[foundItem.Index].Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.AcutalPhaseInRadian);
            }
            else
            {
                // New tag is coming
                if (tagInfo.TotalTagCount == 1)
                {
                    _firstReportTime = tagInfo.FirstSeenTime;
                }

                // Update Listview
                ListViewItem lvi = new ListViewItem(Convert.ToString(_index++));
                lvi.SubItems.Add(tagInfo.EPC);
                lvi.SubItems.Add(tagInfo.Antenna.ToString());
                lvi.SubItems.Add(tagInfo.ChannelIndex.ToString());
                lvi.SubItems.Add(tagInfo.RSSI.ToString());
                lvi.SubItems.Add(tagInfo.AcutalPhaseInRadian.ToString());
                lvi.SubItems.Add(tagInfo.DopplerShift.ToString());
                lvi.SubItems.Add(tagInfo.Velocity.ToString());
                lvi.SubItems.Add(Convert.ToString(1));
                lvBasicInfo.Items.Add(lvi);

                //Update Chart
                if (lvBasicInfo.Items.Count == 1)
                {
                    //Chart title for RSSI
                    Title titleRSSI = new Title("RSSI", Docking.Top);
                    titleRSSI.Alignment = System.Drawing.ContentAlignment.MiddleCenter;
                    titleRSSI.Font      = new System.Drawing.Font("Microsoft Sans Serif", 20, System.Drawing.FontStyle.Bold);
                    chartRSSI.Titles.Add(titleRSSI);

                    Title titlePhase = new Title("Phase", Docking.Top);
                    titlePhase.Alignment = System.Drawing.ContentAlignment.MiddleCenter;
                    titlePhase.Font      = new System.Drawing.Font("Microsoft Sans Serif", 20, System.Drawing.FontStyle.Bold);
                    chartPhase.Titles.Add(titlePhase);
                }

                //------RSSI------
                //Create a new curve
                Series seriesRSSI = new Series("RSSI:" + tagInfo.EPC);
                //Set chart type
                seriesRSSI.ChartType = SeriesChartType.FastLine;
                //Set different curve colors
                seriesRSSI.BorderDashStyle = (ChartDashStyle)lvBasicInfo.Items.Count;
                //Set curve width
                seriesRSSI.BorderWidth = 3;
                chartRSSI.Series.Add(seriesRSSI);

                //Create a new legend
                Legend legendRSSI = new Legend("RSSI:" + tagInfo.EPC);
                //Set legend propertities
                legendRSSI.Title     = "EPC";
                legendRSSI.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold);
                legendRSSI.Font      = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Bold);

                legendRSSI.LegendStyle             = LegendStyle.Table;
                legendRSSI.Alignment               = System.Drawing.StringAlignment.Center;
                legendRSSI.IsDockedInsideChartArea = false;
                legendRSSI.Docking = Docking.Bottom;

                legendRSSI.BorderDashStyle = ChartDashStyle.Dash;
                legendRSSI.BorderColor     = System.Drawing.Color.LightBlue;
                legendRSSI.BorderWidth     = 3;
                chartRSSI.Legends.Add(legendRSSI);
                //Set Docking of the legend chart to the Default Chart Area
                chartRSSI.Legends["RSSI:" + tagInfo.EPC].DockedToChartArea = "RSSI";
                seriesRSSI.Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.RSSI);
                //------RSSI------

                //------Phase------
                //Create a new curve
                Series seriesPhase = new Series("Phase:" + tagInfo.EPC);
                //Set chart type
                //seriesPhase.ChartType = SeriesChartType.FastPoint;
                seriesPhase.ChartType = SeriesChartType.FastLine;
                //Set different curve colors
                seriesPhase.BorderDashStyle = (ChartDashStyle)lvBasicInfo.Items.Count;
                //Set curve width
                seriesPhase.BorderWidth = 3;
                //seriesPhase.MarkerSize = 5;
                chartPhase.Series.Add(seriesPhase);

                //Create a new legend
                Legend legendPhase = new Legend("Phase:" + tagInfo.EPC);
                //Set legend propertities
                legendPhase.Title     = "EPC";
                legendPhase.Font      = new System.Drawing.Font("Microsoft Sans Serif", 10, System.Drawing.FontStyle.Bold);
                legendPhase.TitleFont = new System.Drawing.Font("Microsoft Sans Serif", 12, System.Drawing.FontStyle.Bold);

                legendPhase.LegendStyle             = LegendStyle.Table;
                legendPhase.Alignment               = System.Drawing.StringAlignment.Center;
                legendPhase.IsDockedInsideChartArea = false;
                legendPhase.Docking = Docking.Bottom;

                legendPhase.BorderDashStyle = ChartDashStyle.Dash;
                legendPhase.BorderColor     = System.Drawing.Color.LightBlue;
                legendPhase.BorderWidth     = 3;

                chartPhase.Legends.Add(legendPhase);

                chartPhase.Legends["Phase:" + tagInfo.EPC].DockedToChartArea = "Phase";
                seriesPhase.Points.AddXY((tagInfo.FirstSeenTime - _firstReportTime) / 1000, tagInfo.AcutalPhaseInRadian);

                //------Phase------

                //Update Tag Filter
                if (!cbMask.Items.Contains(tagInfo.EPC))
                {
                    cbMask.Items.Add(tagInfo.EPC);
                }
                if (!cbExtraMask.Items.Contains(tagInfo.EPC))
                {
                    cbExtraMask.Items.Add(tagInfo.EPC);
                }

                SyntheticApertureRadar sar = new SyntheticApertureRadar();
                _sar.Add(tagInfo.EPC, sar);
            }

            SARParameter sarPara = new SARParameter();

            sarPara.AntennaX = Convert.ToDouble(tbxAntXStart.Text.Trim()) +
                               _simulationIndex * Convert.ToDouble(tbxSamplingAntennaSpeed.Text.Trim()) * Convert.ToDouble(tbxSimulationSamplingTime.Text.Trim());
            sarPara.AntennaY = Convert.ToDouble(tbxAntYStart.Text.Trim());

            sarPara.TagInformation                     = new TagInfo();
            sarPara.TagInformation.EPC                 = tagInfo.EPC;
            sarPara.TagInformation.Frequency           = 1000000 * RFIDReaderParameter.ReaderCapabilities.FrequencyDic[tagInfo.ChannelIndex];
            sarPara.TagInformation.AcutalPhaseInRadian = tagInfo.AcutalPhaseInRadian;
            sarPara.TagInformation.TotalTagCount       = tagInfo.TotalTagCount;

            _sarParaQueue.Enqueue(sarPara);
        }