/// <summary> /// Close the old interface device and open a new one. /// </summary> protected async Task <bool> ResetDevice() { if (this.vehicle != null) { this.vehicle.Dispose(); this.vehicle = null; } Device device = DeviceFactory.CreateDeviceFromConfigurationSettings(this); if (device == null) { this.NoDeviceSelected(); this.DisableUserInput(); this.EnableInterfaceSelection(); return(false); } Protocol protocol = new Protocol(); this.vehicle = new Vehicle( device, protocol, this, new ToolPresentNotifier(device, protocol, this)); if (!await this.InitializeCurrentDevice()) { this.vehicle = null; return(false); } return(true); }
/// <summary> /// Close the old interface device and open a new one. /// </summary> private async Task ResetDevice() { if (this.vehicle != null) { this.vehicle.Dispose(); this.vehicle = null; } Device device = DeviceFactory.CreateDeviceFromConfigurationSettings(this); if (device == null) { this.deviceDescription.Text = "None selected."; this.DisableUserInput(); this.interfaceBox.Enabled = true; return; } this.deviceDescription.Text = device.ToString(); Protocol protocol = new Protocol(); this.vehicle = new Vehicle( device, protocol, this, new ToolPresentNotifier(device, protocol, this)); await this.InitializeCurrentDevice(); }
/// <summary> /// Close the old interface device and open a new one. /// </summary> private async Task ResetDevice() { if (this.vehicle != null) { this.vehicle.Dispose(); this.vehicle = null; } Device device = DeviceFactory.CreateDeviceFromConfigurationSettings(this); if (device == null) { this.deviceDescription.Text = "None selected."; return; } this.deviceDescription.Text = device.ToString(); this.vehicle = new Vehicle(device, new MessageFactory(), new MessageParser(), this); await this.InitializeCurrentDevice(); }
/// <summary> /// Test the user's selections. /// </summary> private async void testButton_Click(object sender, EventArgs e) { Device device; if (this.DeviceCategory == Configuration.Constants.DeviceCategorySerial) { device = DeviceFactory.CreateSerialDevice(this.SerialPort, this.SerialPortDeviceType, this.logger); } else if (this.DeviceCategory == Configuration.Constants.DeviceCategoryJ2534) { device = DeviceFactory.CreateJ2534Device(this.J2534DeviceType, this.logger); } else { this.status.Text = "No device specified."; return; } if (device == null) { this.status.Text = "Device not found."; return; } this.status.Text = device.ToString() + " created."; bool initialized = await device.Initialize(); if (initialized) { this.status.Text = device.ToString() + " initialized successfully."; } else { this.status.Text = "Unable to initalize " + device.ToString(); } device.Dispose(); }