void arduino_OnSensorInfoReady(object sender, ArduinoSlam.SensorInfoArgs e)
 {
     if (tcpServer.Status == TCPSlamServer.ServerStatus.Connected)
     {
         tcpServer.SendData(TCPSlamBase.MessageType.XForce, BitConverter.GetBytes(e.XForce));
         tcpServer.SendData(TCPSlamBase.MessageType.YForce, BitConverter.GetBytes(e.YForce));
         tcpServer.SendData(TCPSlamBase.MessageType.ZForce, BitConverter.GetBytes(e.ZForce));
         tcpServer.SendData(TCPSlamBase.MessageType.Temperature, BitConverter.GetBytes(e.Temperature));
     }
 }
 void arduino_OnStatusChanged(object sender, ArduinoSlam.StatusArgs e)
 {
     SendArduinoStatus();
     if (e.Status == ArduinoSlam.ArduinoStatus.Connected)
     {
         lblArduinoStatus.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { lblArduinoStatus.Content = "Connected"; }));
         btnArduinoConnect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { btnArduinoConnect.Content = "Disconnect"; }));
     }
     else if (e.Status == ArduinoSlam.ArduinoStatus.Connecting)
     {
         lblArduinoStatus.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { lblArduinoStatus.Content = "Connecting"; }));
         btnArduinoConnect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { btnArduinoConnect.Content = "Disconnect"; }));
     }
     else if (e.Status == ArduinoSlam.ArduinoStatus.NotConnected)
     {
         lblArduinoStatus.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { lblArduinoStatus.Content = "Disconnected"; }));
         btnArduinoConnect.Dispatcher.Invoke(DispatcherPriority.Normal, new Action(delegate() { btnArduinoConnect.Content = "Connect"; }));
     }
 }
        private void Window_Loaded(object sender, RoutedEventArgs e)
        {
            arduino = new ArduinoSlam();
            arduino.OnStatusChanged += new EventHandler<ArduinoSlam.StatusArgs>(arduino_OnStatusChanged);
            arduino.OnSensorInfoReady += new EventHandler<ArduinoSlam.SensorInfoArgs>(arduino_OnSensorInfoReady);
            arduino.Connect();

            kinectManager = new KinectSlam();
            kinectManager.OnAudioReady += new EventHandler<KinectSlam.AudioStreamArgs>(kinectManager_OnAudioReady);

            tcpServer = new TCPSlamServer();
            tcpServer.Port = 9988;
            tcpServer.OnConnectionStatusChanged += new EventHandler<TCPSlamServer.ServerStatusArgs>(tcpServer_OnConnectionStatusChanged);
            tcpServer.OnDataReceived += new EventHandler<TCPSlamBase.MessageArgs>(tcpServer_OnDataReceived);
            txtIP.Text = Common.GetIP();
            try
            {
                tcpServer.IPAddress = IPAddress.Parse(txtIP.Text);
                tcpServer.StartServer();
            }
            catch
            {
                Console.WriteLine("Invalid IP: " + txtIP.Text);
            }
        }