Esempio n. 1
0
        public void AddListItem(ref TagStatus tagStatus)
        {
            var epc     = tagStatus.Epc;
            var antenna = tagStatus.Antenna;
            var channel = tagStatus.ChannelIndex;
            var key     = new TagInfos.Key(epc, antenna, channel);

            if (_keySet.Contains(key))
            {
                foreach (ListViewItem item in listView_Data.Items)
                {
                    if (item.SubItems[0].Text != epc || Convert.ToUInt16(item.SubItems[1].Text) != antenna)
                    {
                        continue;
                    }
                    item.SubItems[2].Text = tagStatus.TimeStamp.ToString();                               // time
                    item.SubItems[3].Text = tagStatus.Rssi.ToString(CultureInfo.InvariantCulture);        // rssi
                    item.SubItems[4].Text = tagStatus.PhaseRadian.ToString(CultureInfo.InvariantCulture); // phase
                    item.SubItems[5].Text = tagStatus.DopplerShift.ToString();                            // Doppler
                    item.SubItems[6].Text = tagStatus.Velocity.ToString(CultureInfo.InvariantCulture);    // velocity
                    item.SubItems[7].Text = tagStatus.TagSeenCount.ToString();                            // count
                }
            }
            else
            {
                var lvi = new ListViewItem(epc);
                lvi.SubItems.Add(antenna.ToString());
                lvi.SubItems.Add(ConvertTime(tagStatus.TimeStamp).ToString());
                lvi.SubItems.Add(tagStatus.Rssi.ToString(CultureInfo.InvariantCulture));
                lvi.SubItems.Add(tagStatus.PhaseRadian.ToString(CultureInfo.InvariantCulture));
                lvi.SubItems.Add(tagStatus.DopplerShift.ToString());
                lvi.SubItems.Add(tagStatus.Velocity.ToString(CultureInfo.InvariantCulture));
                lvi.SubItems.Add(tagStatus.TagSeenCount.ToString());

                listView_Data.Items.Add(lvi);
                _keySet.Add(key);
            }
        }
Esempio n. 2
0
        public void UpdateChart(ref TagStatus tagStatus)
        {
            var epc     = tagStatus.Epc;
            var antenna = tagStatus.Antenna;
            var channel = tagStatus.ChannelIndex;
            var key     = new TagInfos.Key(epc, antenna, channel);
            var time    = tagStatus.TimeStamp;

            if (!_map.ContainsKey(key))
            {
                _isClearButtonClicked = false;
                if (_startTime == 0)
                {
                    _startTime = time;
                    var dt = new DateTime(1970, 1, 1, 0, 0, 0, 0);
                    _startTimeDateTime = dt.AddSeconds(Convert.ToDouble(_startTime / 1000000)).ToLocalTime();
                }

                var s = new Series
                {
                    ChartType = SeriesChartType.FastLine,
                    Name      = epc + "_" + antenna
                };
                chart_Rssi.Series.Add(s);

                var s1 = new Series
                {
                    ChartType = SeriesChartType.FastLine,
                    Name      = epc + "_" + antenna
                };
                chart_Phase.Series.Add(s1);

                var s2 = new Series
                {
                    ChartType = SeriesChartType.FastLine,
                    Name      = epc + "_" + antenna
                };
                chart_Doppler.Series.Add(s2);

                _map.Add(key, _map.Count); // save index
            }
            var seriesId = _map[key];

            chart_Rssi.Series[seriesId].Points.AddXY(ConvertTime(time), tagStatus.Rssi);
            chart_Rssi.Series[seriesId].LegendText = epc.Substring(epc.Length - 4, 4) + "_" + antenna;

            chart_Phase.Series[seriesId].Points.AddXY(ConvertTime(time), tagStatus.PhaseRadian);
            chart_Phase.Series[seriesId].LegendText = epc.Substring(epc.Length - 4, 4) + "_" + antenna;

            chart_Doppler.Series[seriesId].Points.AddXY(ConvertTime(time), tagStatus.DopplerShift);
            chart_Doppler.Series[seriesId].LegendText = epc.Substring(epc.Length - 4, 4) + "_" + antenna;

            if (SettingsWindow.IsTimerModeActied)
            {
                int t = ConvertTime(time);
                Invoke(new Action(() =>
                {
                    UpdateStatusBar_ProgressBar(ref t);
                }));

                if (t >= ReaderWrapper.ReaderParameters.Duration)
                {
                    StopReceive();

                    if (SettingsWindow.IsAutoSaveChecked)
                    {
                        var fpath = @"C:\Users\Marin\Desktop\";
                        if (!Directory.Exists(fpath))
                        {
                            Directory.CreateDirectory(fpath);
                        }

                        var dt             = DateTime.Now;
                        var strCurrentTime = dt.ToString("yyyyMMdd_HHmmss");
                        var fname          = strCurrentTime + ".csv";
                        var csvWriter      = new CsvStreamWriter(fpath + fname);
                        ReaderWrapper.SaveData(csvWriter);
                    }
                }
            }
        }