/// <summary> /// Disconnect from device. /// </summary> public void Disconnect() { StopAcquisition(); if (stream != null) { // If streaming, stop streaming if (stream.IsOpen) { StopStreaming(); stream.Close(); stream = null; } } if (device != null) { if (device.IsConnected) { device.Disconnect(); device = null; } } }
/// <summary> /// Disconnects from the device /// </summary> private void Disconnect() { // Close all configuration child windows mDeviceBrowser.Browser.GenParameterArray = null; CloseGenWindow(mDeviceBrowser); mStreamBrowser.Browser.GenParameterArray = null; CloseGenWindow(mStreamBrowser); if (mStream != null) { // If streaming, stop streaming if (mStream.IsOpen) { StopStreaming(); mStream.Close(); mStream = null; } } if (mDevice != null) { if (mDevice.IsConnected) { // Disconnect events. mDevice.OnLinkDisconnected -= new OnLinkDisconnectedHandler(OnLinkDisconnected); foreach (PvGenParameter lP in mDevice.Parameters) { lP.OnParameterUpdate -= new OnParameterUpdateHandler(OnParameterChanged); } if (serial.IsOpened) { serial.Close(); } mDevice.Disconnect(); mDevice = null; } } display.Clear(); UpdateAttributes(null); statusControl.Warning = ""; // Sync the UI with our new status EnableInterface(); }