Example #1
0
        private void Start()
        {
            if (!ModbusAdapters.IsItemSelected)
            {
                return;
            }

            var dialog = new SaveFileDialog()
            {
                Filter = CaptureConstants.CaptureFilter
            };

            if (dialog.ShowDialog() != true)
            {
                return;
            }

            CaptureViewer = null;

            BytesReceived = 0;

            //Save the filename
            _capturePath = dialog.FileName;

            _captureHost = new CaptureHost(dialog.FileName, ModbusAdapters.GetFactory().CreateStreamResource());

            _captureHost.SampleReceived += OnSampleReceived;

            Status = "Capturing...";
        }
Example #2
0
        private void Stop()
        {
            try
            {
                Status = "Idle";

                if (_captureHost != null)
                {
                    _captureHost.SampleReceived -= OnSampleReceived;
                    _captureHost.Dispose();
                    _captureHost = null;
                }

                Refresh();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString(), ex.Source);
            }
        }