Пример #1
0
        private void button_Export_Click(object sender, EventArgs e)
        {
            SaveFileDialog sfd = new SaveFileDialog
            {
                Filter           = "csv file|*.csv",
                FilterIndex      = 1,
                RestoreDirectory = true,
                DefaultExt       = ".csv"
            };

            if (sfd.ShowDialog() == DialogResult.OK)
            {
                var             fpath     = sfd.FileName;
                CsvStreamWriter csvWriter = new CsvStreamWriter(fpath);
                ReaderWrapper.SaveData(csvWriter);
            }
        }
Пример #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);
                    }
                }
            }
        }