public void Open() { try { if (!_device.IsConnected) { return; } _device.Open(); _context.SetState(new OpenState(_device, _streamSplitter, _commandTranslator)); } catch (IOException ex) { Debug.WriteLine("Could not open device"); Debug.WriteLine(ex.Message); throw; } }
public void Close() { _cts.Cancel(); _device.Close(); _context.SetState(new ClosedState(_device, _streamSplitter, _commandTranslator)); }