private void timer1_Tick(object sender, EventArgs e)
        {
            Entities.Orientation currentOrienation = controlRoom.RadioTelescopeControllers[rtId - 1].GetCurrentOrientation();
            Coordinate           ConvertedPosition = CoordCalc.OrientationToCoordinate(currentOrienation, DateTime.UtcNow);

            SetActualRAText(ConvertedPosition.RightAscension.ToString("0.##"));
            SetActualDecText(ConvertedPosition.Declination.ToString("0.##"));
        }
Exemplo n.º 2
0
        private void editButton_Click(object sender, EventArgs e)
        {
            logger.Info(Utilities.GetTimeStamp() + ": Edit Button Clicked");
            save_state = !save_state;

            formData.freeControlEnabled = save_state;
            if (!save_state)
            {
                editButton.Text               = "Edit Position";
                editButton.BackColor          = System.Drawing.Color.Red;
                freeControlGroupbox.BackColor = System.Drawing.Color.DarkGray;
                manualControlButton.BackColor = System.Drawing.Color.Red;
                decIncGroupbox.BackColor      = System.Drawing.Color.DarkGray;
                RAIncGroupbox.BackColor       = System.Drawing.Color.DarkGray;
                double newRA;
                double newDec;
                double.TryParse(TargetRATextBox.Text, out newRA);
                double.TryParse(TargetDecTextBox.Text, out newDec);
                Coordinate           new_coord        = new Coordinate(newRA, newDec);
                Entities.Orientation test_orientation = CoordCalc.CoordinateToOrientation(new_coord, DateTime.UtcNow);
                if (test_orientation.Azimuth >= 0 && test_orientation.Elevation >= 0)
                {
                    TargetCoordinate = new_coord;
                    CoordMove();
                }
                else
                {
                    errorLabel.Text = "Invalid Coordinate: orienation out of range";
                }
            }
            else
            {
                editButton.Text = "Save Position";
                manualControlButton.BackColor = System.Drawing.Color.DarkGray;
                editButton.BackColor          = System.Drawing.Color.LimeGreen;
                freeControlGroupbox.BackColor = System.Drawing.Color.Gainsboro;
                decIncGroupbox.BackColor      = System.Drawing.Color.Gray;
                RAIncGroupbox.BackColor       = System.Drawing.Color.Gray;
            }

            PosDecButton.Enabled      = save_state;
            NegDecButton.Enabled      = save_state;
            PosRAButton.Enabled       = save_state;
            NegRAButton.Enabled       = save_state;
            oneForthButton.Enabled    = save_state;
            oneForthButtonDec.Enabled = save_state;
            oneButton.Enabled         = save_state;
            oneButtonDec.Enabled      = save_state;
            fiveButton.Enabled        = save_state;
            fiveButtonDec.Enabled     = save_state;
            tenButton.Enabled         = save_state;
            tenButtonDec.Enabled      = save_state;
            TargetRATextBox.ReadOnly  = save_state;
            TargetDecTextBox.ReadOnly = save_state;

            manualControlButton.Enabled = !save_state;
        }
Exemplo n.º 3
0
        private void timer1_Tick(object sender, EventArgs e)
        {
            Entities.Orientation currentOrienation = rtController.GetCurrentOrientation();
            Coordinate           ConvertedPosition = CoordCalc.OrientationToCoordinate(currentOrienation, DateTime.UtcNow);

            Utilities.WriteToGUIFromThread(this, () => {
                label4.Text = String.Format("{0:N2}", currentOrienation.Azimuth);
                label5.Text = String.Format("{0:N2}", currentOrienation.Elevation);

                ActualRATextBox.Text  = ConvertedPosition.RightAscension.ToString("0.##");
                ActualDecTextBox.Text = ConvertedPosition.Declination.ToString("0.##");
            });
        }
Exemplo n.º 4
0
        private void PosRAButton_Click(object sender, EventArgs e)
        {
            logger.Info(Utilities.GetTimeStamp() + ": Positive Right Ascension Button Clicked");
            Coordinate new_coord = new Coordinate(TargetCoordinate.RightAscension + Increment, TargetCoordinate.Declination);

            Entities.Orientation test_orientation = CoordCalc.CoordinateToOrientation(new_coord, DateTime.UtcNow);
            if (test_orientation.Azimuth >= 0 && test_orientation.Elevation >= 0)
            {
                TargetCoordinate = new_coord;
                CoordMove();
            }
            else
            {
                errorLabel.Text = "Invalid Coordinate: orienation out of range";
            }
        }
        private void NegDecButton_Click(object sender, EventArgs e)
        {
            logger.Info("Negitive Declination Button Clicked");
            Coordinate new_coord = new Coordinate(TargetCoordinate.RightAscension, TargetCoordinate.Declination - Increment);

            Entities.Orientation test_orientation = CoordCalc.CoordinateToOrientation(new_coord, DateTime.UtcNow);
            if (test_orientation.Azimuth > 0 && test_orientation.Elevation > 0)
            {
                TargetCoordinate = new_coord;
                CoordMove();
            }
            else
            {
                errorLabel.Text = "Invalid Coordinate: orienation out of range";
            }
        }
        private void editButton_Click(object sender, EventArgs e)
        {
            logger.Info("Edit Button Clicked");
            bool save_state = (editButton.Text == "Save Position");

            if (save_state)
            {
                editButton.Text = "Edit Position";
                double newRA;
                double newDec;
                double.TryParse(TargetRATextBox.Text, out newRA);
                double.TryParse(TargetDecTextBox.Text, out newDec);
                Coordinate           new_coord        = new Coordinate(newRA, newDec);
                Entities.Orientation test_orientation = CoordCalc.CoordinateToOrientation(new_coord, DateTime.UtcNow);
                if (test_orientation.Azimuth >= 0 && test_orientation.Elevation >= 0)
                {
                    TargetCoordinate = new_coord;
                    CoordMove();
                }
                else
                {
                    errorLabel.Text = "Invalid Coordinate: orienation out of range";
                }
            }
            else
            {
                editButton.Text = "Save Position";
            }

            PosDecButton.Enabled      = save_state;
            NegDecButton.Enabled      = save_state;
            PosRAButton.Enabled       = save_state;
            NegRAButton.Enabled       = save_state;
            CalibrateButton.Enabled   = save_state;
            TargetRATextBox.ReadOnly  = save_state;
            TargetDecTextBox.ReadOnly = save_state;
        }
Exemplo n.º 7
0
        //Run Script Button Functionality
        //Case Depends on which script is currently selected
        private async void runControlScript_Click(object sender, EventArgs e)
        {
            int    index     = controlScriptsCombo.SelectedIndex + 0;
            string indexName = controlScriptsCombo.SelectedItem.ToString();

            // We must run this async so it doesn't hold up the UI
            await Task.Run(() => {
                logger.Info($"{Utilities.GetTimeStamp()}: Starting script {indexName}.");

                MovementResult movementResult = MovementResult.None;

                switch (index)
                {
                case 1:
                    movementResult = rtController.MoveRadioTelescopeToOrientation(MiscellaneousConstants.Stow, MovementPriority.Manual);
                    break;

                case 2:
                    movementResult = rtController.FullElevationMove(MovementPriority.Manual);
                    break;

                case 3:
                    movementResult = rtController.MoveRadioTelescopeByXDegrees(new Entities.Orientation(360, 0), MovementPriority.Manual);
                    break;

                case 4:
                    movementResult = rtController.MoveRadioTelescopeByXDegrees(new Entities.Orientation(-360, 0), MovementPriority.Manual);
                    break;

                case 5:
                    movementResult = rtController.ThermalCalibrateRadioTelescope(MovementPriority.Manual);
                    break;

                case 6:
                    movementResult = rtController.SnowDump(MovementPriority.Manual);
                    break;

                case 7:
                    movementResult = rtController.HomeTelescope(MovementPriority.Manual);
                    break;

                case 8:
                    double azimuthPos   = 0;
                    double elevationPos = 0;
                    string input        = "";
                    string[] values;
                    Entities.Orientation currentOrientation = rtController.GetCurrentOrientation();

                    // Get validated user input for azimuth position
                    do
                    {
                        input = Interaction.InputBox("The Radio Telescope is currently set to be type " + rtController.RadioTelescope.teleType + "." +
                                                     " This script is best run with a telescope type of SLIP_RING.\n\n" +
                                                     "Please type an a custom orientation containing azimuth between 0 and 360 degrees," +
                                                     " and elevation between " + Constants.SimulationConstants.LIMIT_LOW_EL_DEGREES + " and " + Constants.SimulationConstants.LIMIT_HIGH_EL_DEGREES +
                                                     " degrees. Format the entry as a comma-separated list in the format " +
                                                     "azimuth, elevation. Ex: 55,80",
                                                     "Azimuth Orientation", currentOrientation.Azimuth.ToString() + "," + currentOrientation.Elevation.ToString());
                        values = input.Split(',');

                        if (values.Length == 2 && !input.Equals(""))
                        {
                            Double.TryParse(values[0], out azimuthPos);
                            Double.TryParse(values[1], out elevationPos);
                        }

                        // check to make sure the entered values are valid, that there are not too many values entered, and that the entry was formatted correctly
                    }while ((azimuthPos > 360 || azimuthPos < 0) || (elevationPos > Constants.SimulationConstants.LIMIT_HIGH_EL_DEGREES || elevationPos <= Constants.SimulationConstants.LIMIT_LOW_EL_DEGREES) &&
                            (!input.Equals("") && values.Length <= 2));

                    // Only run script if cancel button was not hit
                    if (!input.Equals(""))
                    {
                        Entities.Orientation moveTo = new Entities.Orientation(azimuthPos, elevationPos);
                        movementResult = rtController.MoveRadioTelescopeToOrientation(moveTo, MovementPriority.Manual);
                    }
                    else
                    {
                        MessageBox.Show("Custom Orientation script cancelled.", "Script Cancelled");
                    }
                    break;

                case 9:
                    rtController.StartRadioTelescopeJog(1, RadioTelescopeDirectionEnum.ClockwiseOrNegative, RadioTelescopeAxisEnum.AZIMUTH);
                    MessageBox.Show("Currently spinning Azimuth. Press OK to stop spinning.", "Azimuth Moving");
                    ExecuteCorrectStop();
                    movementResult = MovementResult.Success;
                    break;

                default:
                    // Script does not exist
                    break;
                }

                if (movementResult == MovementResult.Success)
                {
                    logger.Info($"{Utilities.GetTimeStamp()}: Successfully finished script {indexName}.");
                }
                else if (movementResult != MovementResult.None)
                {
                    logger.Info($"{Utilities.GetTimeStamp()}: Script {indexName} FAILED with error message: {movementResult.ToString()}");
                    pushNotification.sendToAllAdmins("Script Failed", $"Script {indexName} FAILED with error message: {movementResult.ToString()}");
                    EmailNotifications.sendToAllAdmins("Script Failed", $"Script {indexName} FAILED with error message: {movementResult.ToString()}");
                }
            });
        }
Exemplo n.º 8
0
 private void timer1_Tick(object sender, EventArgs e)
 {
     Entities.Orientation currentOrienation = rt_controller.GetCurrentOrientation();
     SetActualAZText(currentOrienation.Azimuth.ToString("0.##"));
     SetActualELText(currentOrienation.Elevation.ToString("0.##"));
 }