private void StartClick(object sender, RoutedEventArgs e) { try { var sensorDataModel = new SensorDataModel(); ThirdEyeApplicationContext.SetCurrentSensorModel(sensorDataModel); var comunicationModel = ThirdEyeApplicationContext.GetCommunicationConfigViewModel(); this.currentGlobalSerialPort = new SerialPort(); currentGlobalSerialPort.PortName = comunicationModel.SelectedComPort; currentGlobalSerialPort.Parity = (Parity)Enum.Parse(typeof(Parity), comunicationModel.SelectedParity); currentGlobalSerialPort.BaudRate = int.Parse(comunicationModel.SelectedBaudRate); currentGlobalSerialPort.DataBits = int.Parse(comunicationModel.SelectedDataBit); currentGlobalSerialPort.StopBits = (StopBits)Enum.Parse(typeof(StopBits), comunicationModel.SelectedStopBit); this.currentGlobalSerialIO = new SerialIoLayer(currentGlobalSerialPort); currentGlobalSerialIO.LogData += (serialIo_LogData); currentGlobalSerialIO.Start(); this.lblArchive.Visibility = System.Windows.Visibility.Collapsed; this.lblDetail.Visibility = System.Windows.Visibility.Collapsed; this.lblDetailName.Visibility = System.Windows.Visibility.Collapsed; this.lblFilePath.Visibility = System.Windows.Visibility.Visible; this.lblFilePath.Content = string.Format("Reading from {0}, at {1} baudrate", currentGlobalSerialPort.PortName, currentGlobalSerialPort.BaudRate.ToString()); currentCommunicationState = CommunicationState.Reading; } catch (Exception exception) { MessageBox.Show(exception.Message + exception.InnerException); } }
public Scanner(ISerialIo serialIo) { this.SerialIo = serialIo; }