private readonly cVision vision; //接收视觉结果

        public void ConectToVision()
        {
            string notes;

            vision.initRcv();
            RcvThread = new Thread(new ThreadStart(delegate
            {
                while (true)
                {
                    vision.ReciveData();
                    notes = " X  = " + vision.hitPar[1].ToString() +
                            "\n Y  = " + vision.hitPar[2].ToString() +
                            "\n Z  = " + vision.hitPar[3].ToString() +
                            "\n Vx = " + vision.hitPar[4].ToString() +
                            "\n Vy = " + vision.hitPar[5].ToString() +
                            "\n Vz = " + vision.hitPar[6].ToString() +
                            "\n tg = " + vision.hitPar[12].ToString();
                    if (vision.hitPar[0] == 1)
                    {
                        double[] padPar;
                        SlovePadPram(vision.hitPar, out padPar);
                        notes += "\n PadV = " + padPar[3].ToString() +
                                 "\n PadS = " + padPar[4].ToString();
                        SetNotes(notes);


                        Control_Arm.Recv4Vision(vision.hitPar);
                        ZSPCt.SetZSP((int)vision.hitPar[3], (int)(padPar[4]), 127);
                    }
                    Thread.Sleep(50);
                }
            }
                                                   ));
            RcvThread.Start();
        }
        void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target)
        {
            switch (connectionId)
            {
            case 1:

            #line 5 "..\..\MainWindow.xaml"
                ((TabletennisCln.MainWindow)(target)).Closed += new System.EventHandler(this.Window_Closed);

            #line default
            #line hidden
                return;

            case 2:
                this.Control_Arm = ((PMAC_Communicate.UserControl1)(target));
                return;

            case 3:

            #line 14 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);

            #line default
            #line hidden
                return;

            case 4:
                this.TBK_VisionOut = ((System.Windows.Controls.TextBlock)(target));
                return;

            case 5:
                this.ZSPCt = ((TabletennisCln.ZSPCt)(target));
                return;

            case 6:
                this.TB_lambda = ((System.Windows.Controls.TextBox)(target));
                return;

            case 7:

            #line 18 "..\..\MainWindow.xaml"
                ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);

            #line default
            #line hidden
                return;
            }
            this._contentLoaded = true;
        }
        //=======================================

        private void Window_Closed(object sender, EventArgs e)
        {
            if (RcvThread != null && RcvThread.IsAlive)
            {
                if (vision != null)
                {
                    vision.newsock.Close();
                }
                RcvThread.Abort();
            }


            ZSPCt.UserControl_Unloaded(this, null);
            Thread.Sleep(100);
        }
 public MainWindow()
 {
     InitializeComponent();
     vision = new cVision();
     ZSPCt.BTC_WaitZSP(this, null);//自动打开端口,等待ZSP连接
 }
 void System.Windows.Markup.IComponentConnector.Connect(int connectionId, object target) {
     switch (connectionId)
     {
     case 1:
     
     #line 5 "..\..\MainWindow.xaml"
     ((TabletennisCln.MainWindow)(target)).Closed += new System.EventHandler(this.Window_Closed);
     
     #line default
     #line hidden
     return;
     case 2:
     this.Control_Arm = ((PMAC_Communicate.UserControl1)(target));
     return;
     case 3:
     
     #line 14 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click);
     
     #line default
     #line hidden
     return;
     case 4:
     this.TBK_VisionOut = ((System.Windows.Controls.TextBlock)(target));
     return;
     case 5:
     this.ZSPCt = ((TabletennisCln.ZSPCt)(target));
     return;
     case 6:
     this.TB_lambda = ((System.Windows.Controls.TextBox)(target));
     return;
     case 7:
     
     #line 18 "..\..\MainWindow.xaml"
     ((System.Windows.Controls.Button)(target)).Click += new System.Windows.RoutedEventHandler(this.Button_Click_1);
     
     #line default
     #line hidden
     return;
     }
     this._contentLoaded = true;
 }