Exemple #1
0
 private void SendCommand(char cmd, int receiveCnt, ReceiveDelegate receiveDelegate)
 {
     if (connection_ != null)
     {
         connection_.SendReceiveRequest(new byte[] { (byte)cmd }, receiveCnt, new BaseConnectionHandler(this, receiveDelegate));
     }
 }
Exemple #2
0
 private void SendCommand(SerialConnection connection, byte[] cmd, int receiveCnt, ReceiveDelegate receiveDelegate)
 {
     if (connection_ != null)
     {
         connection_.SendReceiveRequest(cmd, receiveCnt, new BaseConnectionHandler(this, receiveDelegate, connection));
     }
 }
Exemple #3
0
        private void buttonConnection_Click(object sender, EventArgs e)
        {
            ConnectionForm form = new ConnectionForm(nightMode_, portName_, baudRate_, swapAzmAltEncoders_);

            if (form.ShowDialog() != DialogResult.OK)
            {
                return;
            }

            if (form.DisconnectAll)
            {
                CloseAllConnections();
                UpdateUI();
                return;
            }

            CloseReconnected(form.PortName);

            portName_       = form.PortName;
            baudRate_       = form.BaudRate;
            positionsValid_ = false;

            if (portName_ != null)
            {
                SerialConnection connection = null;
                try
                {
                    connection = new SerialConnection(portName_, baudRate_);
                }
                catch (Exception)
                {
                }

                if (connection != null)
                {
                    ConnectionData data = new ConnectionData(connection, form.SwapAzmAltEncoders);
                    connectionList_.Add(data);
                    connection.SendReceiveRequest(new byte[] { (byte)'s' }, 2, new InitConnectionHandler(this, data));
                }
                UpdateUI();
            }
        }