private void 机器人坐标ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (this.dataGridView1.SelectedRows.Count == 1)
     {
         Task.Run(() => {
             var robot = new TsRemoteS();
             robot.SetIPaddr(0, this.IpAddress, this.Port);
             robot.Connect(1);
             TsPointS p         = robot.GetPsnFbkWorld();
             DataGridViewRow dr = this.dataGridView1.SelectedRows.OfType <DataGridViewRow>().Single();
             this.CalData.Rows[dr.Index]["x"] = p.X;
             this.CalData.Rows[dr.Index]["y"] = p.Y;
             this.CalData.Rows[dr.Index]["z"] = p.Z;
             Task.Run(() => {
                 robot.Disconnect();
                 robot.Dispose();
             });
         });
     }
 }
Exemple #2
0
        public bool doConncet_Network(string IPAddress, int IPPort)
        {
            //已經開啟,直接回傳
            if ((ConnectStatus & CONNECTTYPE.CONNECTED) > 0)
            {
                return(true);
            }
            try
            {
                //P.88
                //openmode: 0=Server(not installed); 1=Client
                //destAddr: 目標IPv4位置
                //destPort: 目標Port
                if (_Robot.SetIPaddr(0, IPAddress, IPPort) == false)
                {
                    //Return value: true=Successful; false=Failed
                    return(false);
                }

                //P.31
                //int type Specify a connection type. Connection under RS-232C(COM) is not supported.
                //0:RS-232C(function not yet installed)
                //1:TCP/IP
                //Return value: true:Connect successful; false:Connect failed
                if (_Robot.Connect(1) == true)
                {
                    ConnectStatus |= CONNECTTYPE.CONNECTED;

                    checkServo();
                    return(true);
                }
            }
            catch (TsRemoteSException ex)
            {
                //Error processing
                Console.WriteLine("doConncet_Network: " + ex.Message);
            }
            return(false);
        }