Beispiel #1
0
        void Conectar()
        {
            try
            {
                string portName = cbPortNames.Items[cbPortNames.SelectedIndex].ToString(); //get value from combo box
            }
            catch
            {
                return;
            }

            portName = cbPortNames.Items[cbPortNames.SelectedIndex].ToString();  //get value from combo box

            if (btConnect.Text == "Conectar")
            {
                CoordenaDados     = new ReceiveData(portName, BaudRate);
                btPause.Enabled   = false;
                btReceive.Enabled = true;
                CoordenaDados.run("OPEN"); //comando de abir a porta serial
                btConnect.Text    = "Desconectar";
                tsStatus.Text     = "Connected to: " + portName;
                btReceive.Enabled = true;
            }
            //port is open
            else
            {
                CoordenaDados.run("CLOSE"); //comando para fechar a porta
                btReceive.Enabled = false;
                btPause.Enabled   = false;
                btConnect.Text    = "Conectar";
                tsStatus.Text     = "Desconectar";
            }
        }
Beispiel #2
0
 private void btConnect_Click(object sender, EventArgs e)
 {
     if (btConnectEMG.Text == "Connect")
     {
         CoordenaDados = new ReceiveData(portName, BaudRate);
         CoordenaDados.run("OPEN");
         btConnectEMG.Text = "Disconnect";
         tsStatus.Text     = "Connected to: " + portName;
         btReceive.Enabled = true;
     }
     //port is open
     else
     {
         CoordenaDados.run("CLOSE");
         btReceive.Enabled = false;
         btPause.Enabled   = false;
         btConnectEMG.Text = "Connect";
         tsStatus.Text     = "Disconnected";
     }
 }
Beispiel #3
0
 private void Form_calibra_FormClosing(object sender, FormClosingEventArgs e)
 {
     try
     {
         if (CoordenaDados.isOpen)
         {
             CoordenaDados.run("STOP");
             working = false;            //termina a thread
             CoordenaDados.run("CLOSE"); //fecha a porta serial
         }
     }
     catch (Exception)
     {
     }
 }