protected virtual PortLevel.PortStates Connect() { PortLevel.PortStates res = port.Open(Config.Port, Config.BaudRate); switch (res) { case PortLevel.PortStates.Opening: realizer.Undo += undoProgramState; realizer.Connect(); DeviceIsConnected = true; break; case PortLevel.PortStates.Opened: DeviceIsConnected = true; break; case PortLevel.PortStates.ErrorOpening: break; default: // фигня break; } return(res); }
protected virtual void Disconnect() { realizer.Disconnect(); realizer.Undo -= undoProgramState; PortLevel.PortStates res = port.Close(); switch (res) { case PortLevel.PortStates.Closing: DeviceIsConnected = false; break; case PortLevel.PortStates.Closed: DeviceIsConnected = false; break; case PortLevel.PortStates.ErrorClosing: break; default: // фигня break; } }