Exemplo n.º 1
0
        public MainPresenter(IMainView view)
        {
            this.view = view;
            view.StopDecodingSerialPort += StopDecodingSerialPortEvent;
            view.ComPortConnection      += ComPortConnectionEvent;
            view.OpenDataFile           += OpenDataFileEvent;
            ComPortNamesUpdate();
            view.ComPortName          = Program.settings.SerialPort.PortName;
            view.UpdateChart         += UpdateChartMainEvent;
            view.ExitProgramm        += ExitProgrammEvent;
            view.ComPortNamesUpdate  += ComPortNamesUpdateEvent;
            view.SynchronizationTime += SynchronizationTimeEvent;

            serialPort.DataReceived += DataReceivesEvent;

            if (serialPort.IsOpen)
            {
                DecodStreamPSP = new StreamDecoding(serialPort.BaseStream, new PackagePSP1NStructure(StartBit.ZERO, 32, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12));
            }
        }
Exemplo n.º 2
0
        private void OpenDataFileEvent(object sender, EventArgs e)
        {
            using (OpenFileDialog openFileDialog = new OpenFileDialog())
            {
                if (serialPort.IsOpen)
                {
                    serialPort.Close();
                }
                openFileDialog.Filter = "Binary voltage recoder file (*.bvr)|*.bvr";
                if (openFileDialog.ShowDialog() == DialogResult.Cancel)
                {
                    return;
                }
                PathFileNameBvr       = openFileDialog.FileName;
                view.ValueScrollChart = 0;
                fileStreamRead        = File.OpenRead(PathFileNameBvr);
                DecodStreamPSP        = new StreamDecoding(fileStreamRead, new PackagePSP1NStructure(StartBit.ZERO, 32, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12));

                UpdateChartMainEvent(sender, e);
                UpdateChartPreview();
            }
        }
Exemplo n.º 3
0
        private void ComPortConnectionEvent(object sender, EventArgs e)
        {
            if (serialPort.IsOpen)
            {
                serialPort.Close();
            }

            serialPort.PortName = view.ComPortName;
            try
            {
                serialPort.Open();
                if (serialPort.IsOpen)
                {
                    DecodStreamPSP = new StreamDecoding(serialPort.BaseStream, new PackagePSP1NStructure(StartBit.ZERO, 32, 10, 12, 12, 12, 12, 12, 12, 12, 12, 12, 12));
                }
            }
            catch (Exception)
            {
                MessageBox.Show("Не верный COM порт!");
                return;
            }
            Program.settings.SerialPort.PortName = serialPort.PortName;
        }