private void cbSimulate_Click(object sender, RoutedEventArgs e) { if (cbSimulate.IsChecked == true) { _accelInstance = new Accelerometer(); _serialPortAdapter = new SerialPortAdapter(); _serialPortAdapter.SerialDataRxedHandler = _accelInstance.AccelerometerByteStreamParser; _serialPortAdapter.Simulate = true; btnStartStop.IsEnabled = true; Debug.WriteLine("Entered Simulation Mode!!"); btnConnect.IsEnabled = false; } else { if (_serialPortAdapter != null) { _serialPortAdapter.Simulate = false; } else { btnStartStop.IsEnabled = false; btnConnect.IsEnabled = true; } Debug.WriteLine("Exit Simulation Mode!!"); } }
private void btnConnect_Click(object sender, RoutedEventArgs e) { _accelInstance = new Accelerometer(); _serialPortAdapter = new SerialPortAdapter(); _serialPortAdapter.SerialDataRxedHandler = _accelInstance.AccelerometerByteStreamParser; if (_serialPortAdapter.Open(cmbxPorts.Text)) { btnStartStop.IsEnabled = true; Debug.WriteLine("Opening port to JIG:" + cmbxPorts.Text); btnConnect.IsEnabled = false; } }