void UpdateStatusLeds()
        {
            //UR
            URConnected.Fill       = App.Current.URController.IsUniversalRobotConnected ? App.Current.ThemeColor : Brushes.Gray;
            URReady.Fill           = App.Current.URController.URRobotStatus.RobotMode == 7 ? App.Current.ThemeColor : Brushes.Gray;
            URDistanceInRange.Fill = !double.IsNaN(UniversalRobotHelperFunctions.GetCurrentZDistance()) ? App.Current.ThemeColor : Brushes.Gray;
            URHomed.Fill           = App.Current.MachineHomed ? App.Current.ThemeColor : Brushes.Gray;
            URFault.Fill           = App.Current.URSecondController.GetCurrentSafetyStatus() != URSecondaryController.SafetyType.Normal ? Brushes.Tomato : Brushes.Gray;
            URFreedrive.Fill       = App.Current.URController.GetFreeDriveStatus() ? App.Current.ThemeColor : Brushes.Gray;
            URErrorMessageBox.Text = App.Current.URSecondController.GetCurrentSafetyStatus().ToString();
            SettingsOn.Content     = App.Current.URController.URRobotStatus.RobotMode == 7 ? "Off" : "On";
            double currentDistanceMM = UniversalRobotHelperFunctions.GetCurrentZDistance();

            if (double.IsNaN(currentDistanceMM))
            {
                URDistanceValue.Text = "Out of range.";
            }
            else
            {
                double roundedDistance = Math.Round(currentDistanceMM);
                URDistanceValue.Text = roundedDistance.ToString() + " mm";
            }
            //polaris
            PolarisConnected.Fill         = App.Current.PolarisController.IsPolarisConnected ? App.Current.ThemeColor : Brushes.Gray;
            RobotMarkerVisible.Fill       = App.Current.PolarisController.GetURRobotRigidBody().isInRange ? App.Current.ThemeColor : Brushes.Gray;
            Patientent1MarkerVisible.Fill = App.Current.PolarisController.GetUserRigidBodyOne().isInRange ? App.Current.ThemeColor : Brushes.Gray;
            PatientMarker2Visible.Fill    = App.Current.PolarisController.GetUserRigidBodyTwo().isInRange ? App.Current.ThemeColor : Brushes.Gray;

            //force sensor
            ForceOverLimit.Fill   = UniversalRobotHelperFunctions.IsForceOverLimit() ? Brushes.Tomato : Brushes.Gray;
            TrackButton.IsEnabled = App.Current.MachineHomed;
        }
        Point3D TrackZAndUpdateStartPoint(Point3D inputPoint, double mmToAddToDistance)
        {
            double analogConverted = UniversalRobotHelperFunctions.GetCurrentZDistance();

            double currentZDistance = coilToTargetDistance + mmToAddToDistance;

            if (double.IsNaN(analogConverted) ||
                double.IsNaN(currentZDistance))
            {
                string errorMessage = "Cannot read a valid distance from the laser. Unable to perform move!";
                if (CheckRunThroughAll())
                {
                    errorMessage += " The Run Through All moves will now be cancelled.";
                }
                MessageBox.Show(errorMessage, "Unable to perform move!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(new Point3D(
                           App.Current.URController.URRobotStatus.ToolVectorActual_1,
                           App.Current.URController.URRobotStatus.ToolVectorActual_2,
                           App.Current.URController.URRobotStatus.ToolVectorActual_3));
            }

            if (analogConverted < currentZDistance)
            {
                startPoint = UniversalRobotHelperFunctions.AdjustLocationToLaser(startPoint, lookDirection, analogConverted, currentZDistance);
            }
            return(UniversalRobotHelperFunctions.AdjustLocationToLaser(inputPoint, lookDirection, analogConverted, currentZDistance));
        }
        private void MoveToZ_Click(object sender, RoutedEventArgs e)
        {
            double analogConverted = UniversalRobotHelperFunctions.GetCurrentZDistance();

            double currentZDistance = App.Current.ApplicationSettings.CoilToTargetDistanceMM;

            if (double.IsNaN(analogConverted) ||
                double.IsNaN(currentZDistance))
            {
                MessageBox.Show("Cannot read a valid distance from the laser. Unable to perform move!", "Unable to perform move!", MessageBoxButton.OK, MessageBoxImage.Error);
            }
            else
            {
                Point3D move = UniversalRobotHelperFunctions.AdjustLocationToLaser(GetCurrentPoint(), GetCurrentLookDirection(), analogConverted, currentZDistance);
                MoveToPoint(move, GetCurrentLookDirectionAsPoint(), false);
            }
        }
        Point3D TrackZ(Point3D inputPoint, double mmToAddToDistance)
        {
            double analogConverted = UniversalRobotHelperFunctions.GetCurrentZDistance();

            double currentZDistance = coilToTargetDistance + mmToAddToDistance;

            if (double.IsNaN(analogConverted) ||
                double.IsNaN(currentZDistance))
            {
                MessageBox.Show("Cannot read a valid distance from the laser. Unable to perform move!", "Unable to perform move!", MessageBoxButton.OK, MessageBoxImage.Error);
                return(new Point3D(
                           App.Current.URController.URRobotStatus.ToolVectorActual_1,
                           App.Current.URController.URRobotStatus.ToolVectorActual_2,
                           App.Current.URController.URRobotStatus.ToolVectorActual_3));
            }
            return(UniversalRobotHelperFunctions.AdjustLocationToLaser(inputPoint, lookDirection, analogConverted, currentZDistance));
        }