예제 #1
0
        void controller_OnButtonsChanged(object sender, ControllerSlam.ButtonArgs e)
        {
            if (tcpClient != null && tcpClient.Status == TCPSlamClient.ClientStatus.Connected)
            {
                if (e.CameraMove != 0)
                {
                    if (cameraWindow != null)
                    {
                        cameraWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { cameraWindow.SetCameraAngle(e.CameraMove); }));
                        cameraWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { cameraWindow.SetTemperatureValue(e.CameraMove); }));
                    }
                }

                if (e.LeftStickChanged)
                {
                    tcpClient.SendData(TCPSlamBase.MessageType.LeftMotor, BitConverter.GetBytes(e.LeftStick));
                    if (cameraWindow != null)
                    {
                        cameraWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { cameraWindow.SetLeftWheelPower(e.LeftStick); }));
                        cameraWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { cameraWindow.UpdateLineGraphs(); }));
                    }
                }

                if (e.RightStickChanged)
                {
                    tcpClient.SendData(TCPSlamBase.MessageType.RightMotor, BitConverter.GetBytes(e.RightStick));
                    if (cameraWindow != null)
                    {
                        cameraWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { cameraWindow.SetRightWheelPower(e.RightStick); }));
                        cameraWindow.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { cameraWindow.UpdateLineGraphs(); }));
                    }
                }
            }
        }
예제 #2
0
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     controller = new ControllerSlam();
     controller.OnButtonsChanged += new EventHandler<ControllerSlam.ButtonArgs>(controller_OnButtonsChanged);
     tcpClient = new TCPSlamClient();
     tcpClient.Port = 9988;
     tcpClient.OnConnectionStatusChanged += new EventHandler<TCPSlamClient.ClientStatusArgs>(tcpClient_OnConnectionStatusChanged);
     tcpClient.OnDataReceived += new EventHandler<TCPSlamBase.MessageArgs>(tcpClient_OnDataReceived);
     txtIP.Text = Common.GetIP();
 }
 private void Window_Loaded(object sender, RoutedEventArgs e)
 {
     skeleton = new SkeletonSlam();
     skeleton.onHandHeightChanged += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onHandHeightChanged);
     skeleton.onRightAngleTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightAngleTurn);
     skeleton.onLeftQuarterTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onLeftQuarterTurn);
     skeleton.onRightQuarterTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightQuarterTurn);
     skeleton.onLeftHalfTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onLeftHalfTurn);
     skeleton.onLeftFullTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onLeftFullTurn);
     skeleton.onRightHalfTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightHalfTurn);
     skeleton.onRightFullTurn += new EventHandler<SkeletonSlam.SkeletonArgs>(skeleton_onRightFullTurn);
     controller = new ControllerSlam();
     controller.OnButtonsChanged += new EventHandler<ControllerSlam.ButtonArgs>(controller_OnButtonsChanged);
     tcpClient = new TCPSlamClient();
     tcpClient.Port = 9988;
     tcpClient.OnConnectionStatusChanged += new EventHandler<TCPSlamClient.ClientStatusArgs>(tcpClient_OnConnectionStatusChanged);
     tcpClient.OnDataReceived += new EventHandler<TCPSlamBase.MessageArgs>(tcpClient_OnDataReceived);
     txtIP.Text = Common.GetIP();
 }