コード例 #1
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            string test = robotAgent.ReadADebugMsg();

            if (test != string.Empty)
            {
                debugText.Text = test + debugText.Text;
            }
            if (debugText.Text.Length > 1000)
            {
                debugText.Text = "";
            }
            if (robotAgent != null)
            {
                if (robotAgent.Active)
                {
                    button1.Text = "Stop";

                    List <string> ips = new List <string>();
                    ips = robotAgent.GetConnectedAgentFromBC( );

                    for (int i = 0; i < listBox1.Items.Count; i++)
                    {
                        if (i < ips.Count)
                        {
                            var str = ips[i];
                            listBox1.Items[i] = str;
                        }
                        else
                        {
                            listBox1.Items[i] = " ";
                        }
                    }
                    for (int i = 0; i < listBox3.Items.Count; i++)
                    {
                        if (i < robotAgent.friends.Count)
                        {
                            var str = robotAgent.friends[i].localIP + ":" + robotAgent.friends[i].localPort;
                            listBox3.Items[i] = str;
                        }
                        else
                        {
                            listBox3.Items[i] = " ";
                        }
                    }

                    if (showingParamerAgent != null)
                    {
                        var par = showingParamerAgent.parameters;
                        listBox2.Items[0] = string.Format("Name:{0}", par.v_name);
                        listBox2.Items[1] = string.Format("Speed:{0},{1}", par.v_Movement[0], par.v_Movement[1]);
                        listBox2.Items[2] = string.Format("Rotation:{0}", par.v_Movement[2]);
                        listBox2.Items[3] = string.Format("DisSensor:{0}  {1} ", par.v_DisSensor[2], par.v_DisSensor[3]);
                    }
                    else
                    {
                        for (int i = 0; i < 20; i++)
                        {
                            listBox2.Items[i] = "";
                        }
                    }
                }
                else
                {
                    button1.Text = "Start";
                }
            }
        }