Exemple #1
0
 public static void pi1Port2ConnectionEnabler()
 {
     ConnectorOne.pi1Port2AddressUpdater();
     RoverConsole.ArcEyeContentThreadSafe("Checking Pi1 Connection via Port2");
     try
     {
         pi1Port2Tcp = new TcpClient();
         pi1Port2Tcp.Connect(pi1Ip, pi1Port2);
         pi1Port2NetworkStream = pi1Port2Tcp.GetStream();
         pi1Port2SrReciever    = new StreamReader(pi1Port2NetworkStream);
         pi1Port2SwSender      = new StreamWriter(pi1Port2NetworkStream);
         RoverConsole.ArcEyeContentThreadSafe("Pi1 via Port2 Connection Successful");
         if (ConnectorOne.pi1Port2ConnectedStatusEvent != null)
         {
             ConnectorOne.pi1Port2ConnectedStatusEvent(new object(), new EventArgs());
         }
     }
     catch (Exception ex)
     {
         RoverConsole.ArcEyeAiContentThreadSafe(ex.ToString());
         if (ConnectorOne.pi1Port2DisconnectedStatusEvent != null)
         {
             ConnectorOne.pi1Port2DisconnectedStatusEvent(new object(), new EventArgs());
         }
     }
 }
Exemple #2
0
        private void initialize_btn_Click(object sender, RoutedEventArgs e)
        {
            _RoverVisualization.initialize_btn.Visibility = Visibility.Hidden;
            _RoverVisualization.rvr_mdl_plc.Visibility    = Visibility.Visible;

            ConnectorOne.pi3Port1ConnectionEnabler();
        }
Exemple #3
0
 public static void pi3Port1ConnectionEnabler()
 {
     ConnectorOne.pi3Port1AddressUpdater();
     RoverConsole.ArcEyeContentThreadSafe("Checking Pi3 Connection via Port1");
     try
     {
         pi3Port1Tcp = new TcpClient();
         pi3Port1Tcp.Connect(pi3Ip, pi3Port1);
         pi3Port1NetworkStream = pi3Port1Tcp.GetStream();
         pi3Port1SrReciever    = new StreamReader(pi3Port1NetworkStream);
         pi3Port1SwSender      = new StreamWriter(pi3Port1NetworkStream);
         RoverConsole.ArcEyeContentThreadSafe("Pi3 via Port1 Connection Successful");
         if (ConnectorOne.pi3Port1ConnectedStatusEvent != null)
         {
             ConnectorOne.pi3Port1ConnectedStatusEvent(new object(), new EventArgs());
         }
         Thread imuDataHandlerThread = new Thread(() => imuInputHandler());
         imuDataHandlerThread.Name         = "imuDataHandlerThread";
         imuDataHandlerThread.IsBackground = true;
         imuDataHandlerThread.Start();
     }
     catch (Exception ex)
     {
         RoverConsole.ArcEyeAiContentThreadSafe(ex.ToString());
         if (ConnectorOne.pi3Port1DisconnectedStatusEvent != null)
         {
             ConnectorOne.pi3Port1DisconnectedStatusEvent(new object(), new EventArgs());
         }
     }
 }
        private void roverVisualizationSyncronizerThreadFunction()
        {
            string datas;

            while (true)
            {
                datas = ConnectorOne.getImuData();
                try
                {
                    string[] words = datas.Split(',');
                    _RoverVisualization.rvr_mdl_plc.Dispatcher.Invoke((Action)(() =>
                    {
                        _RoverVisualization.rtn_x.Angle = Convert.ToDouble(words[0]);
                        _RoverVisualization.rtn_y.Angle = Convert.ToDouble(words[1]);
                        _RoverVisualization.rtn_z.Angle = Convert.ToDouble(words[2]);
                        //_RoverVisualization.axs.OffsetX = Convert.ToDouble(words[3]);
                        //_RoverVisualization.axs.OffsetX = Convert.ToDouble(words[4]);
                        //_RoverVisualization.axs.OffsetX = Convert.ToDouble(words[5]);
                    }));
                }
                catch (Exception ex)
                {
                    ARC_EYE.RoverConsole.ArcEyeAiContentThreadSafe(ex.ToString());
                }
            }
        }
Exemple #5
0
 public void RoverMovementStatusUpdater()
 {
     if (_RoverMovement != null)
     {
         RoverConsole.ArcEyeAiContentThreadSafe("Rover Movement Command : Direction-" + roverMovement.ToString() + ", Speed-" + pwm.ToString());
         ConnectorOne.RoverMovementStatusUpdater(roverMovement, pwm);
     }
 }
Exemple #6
0
 private static void imuInputHandler()
 {
     try
     {
         pi3Port1SwSender.AutoFlush = true;
         while (true)
         {
             imuData = pi3Port1SrReciever.ReadLine();
             //RoverConsole.ArcEyeAiContentThreadSafe("IMU Data Received : " + ConnectorOne.imuData);
         }
     }
     catch (Exception ex)
     {
         RoverConsole.ArcEyeAiContentThreadSafe(ex.ToString());
         RoverConsole.ArcEyeAiContentThreadSafe("Trying To Reconnect");
         if (ConnectorOne.pi3Port1DisconnectedStatusEvent != null)
         {
             ConnectorOne.pi3Port1DisconnectedStatusEvent(new object(), new EventArgs());
         }
     }
 }
Exemple #7
0
 public static void RoveArmStatusUpdater(MotorName motorName, HandMovement handMovement)
 {
     try
     {
         RoverConsole.ArcEyeAiContent("Uploading Rover Arm Command : Motor Name-" + motorName.ToString() + ", Hand Movement-" + handMovement.ToString());
         pi1Port2SwSender.AutoFlush = true;
         pi1Port2SwSender.Write(Convert.ToString(Convert.ToInt32(motorName)) + "," + Convert.ToInt32(handMovement));
         RoverConsole.ArcEyeAiContent("Command Uploaded to Pi1 via port2");
         if (ConnectorOne.pi1Port2ConnectedStatusEvent != null)
         {
             ConnectorOne.pi1Port2ConnectedStatusEvent(new object(), new EventArgs());
         }
     }
     catch (Exception ex)
     {
         RoverConsole.ArcEyeAiContentThreadSafe(ex.ToString());
         RoverConsole.ArcEyeAiContentThreadSafe("Trying To Reconnect");
         if (ConnectorOne.pi1Port2DisconnectedStatusEvent != null)
         {
             ConnectorOne.pi1Port2DisconnectedStatusEvent(new object(), new EventArgs());
         }
     }
 }
Exemple #8
0
 public static void RoverMovementStatusUpdater(RoverAndArmRoverMovement roverMovement, double pwm)
 {
     try
     {
         RoverConsole.ArcEyeAiContent("Uploading Rover Movement Command : Direction-" + roverMovement.ToString() + ", Speed-" + pwm.ToString());
         pi1Port1SwSender.AutoFlush = true;
         pi1Port1SwSender.Write(Convert.ToString(Convert.ToInt32(roverMovement)) + "," + Convert.ToString(pwm));
         RoverConsole.ArcEyeAiContent("Command Uploaded to Pi1 via port1");
         if (ConnectorOne.pi1Port1ConnectedStatusEvent != null)
         {
             ConnectorOne.pi1Port1ConnectedStatusEvent(new object(), new EventArgs());
         }
     }
     catch (Exception ex)
     {
         RoverConsole.ArcEyeAiContentThreadSafe(ex.ToString());
         RoverConsole.ArcEyeAiContentThreadSafe("Trying To Reconnect");
         if (ConnectorOne.pi1Port1DisconnectedStatusEvent != null)
         {
             ConnectorOne.pi1Port1DisconnectedStatusEvent(new object(), new EventArgs());
         }
     }
 }
 private void pi_1_port_2_btn_Click(object sender, RoutedEventArgs e)
 {
     ConnectorOne.pi1Port2ConnectionEnabler();
 }
 private void pi_3_port_1_btn_Click(object sender, RoutedEventArgs e)
 {
     ConnectorOne.pi3Port1ConnectionEnabler();
 }
Exemple #11
0
 public void RoverMovementStatusUpdater(RoverAndArmRoverMovement roverMovement, double pwm)
 {
     RoverConsole.ArcEyeAiContent("Rover Movement Command : Direction-" + roverMovement.ToString() + ", Speed-" + pwm.ToString());
     ConnectorOne.RoverMovementStatusUpdater(roverMovement, pwm);
 }