Ejemplo n.º 1
0
        public void Connect(string ip)
        {
            LogMessage($"Connecting to {ip}");
            Ip = ip;
            if (Connection == ConnectionStatus.Connected || Connection == ConnectionStatus.Online)
            {
                throw new InvalidOperationException("Already connected to an interface");
            }

            TxtCommunication?.Dispose();

            TxtCommunication = new TxtCommunication(this);
            TxtCamera        = new TxtCameraCommunication(TxtCommunication);

            try
            {
                TxtCommunication.OpenConnection();
                Connection = TxtCommunication.Connected ? ConnectionStatus.Connected : ConnectionStatus.NotConnected;
            }
            catch (Exception e)
            {
                LogMessage($"Exception while connecting: {e.Message}");
                Connection = ConnectionStatus.Invalid;
                HandleException(e);
            }


            _masterInterface.ResetValues();

            LogMessage("Connected");
            _connected?.Invoke(this, new EventArgs());
        }