Example #1
0
        public static bool PlateSolveIt()
        {
            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);
            AstroImage     asti        = new AstroImage
            {
                Exposure       = tPlan.PlateSolveExposureTime,
                Filter         = tPlan.ClearFilter,
                ImageReduction = AstroImage.ReductionType.AutoDark,
                Delay          = 0
            };

            lg.LogIt("Plate Solve: Imaging");
            Imaging imgo = new Imaging();

            string path = imgo.TakeLightFrame(asti);

            lg.LogIt("Plate Solve: Image Linking");
            //tsxl.scale = 1.70;
            //tsxl.unknownScale = true;
            TSXLink.PlateSolution dSolve = TSXLink.ImageSolution.PlateSolve(path);
            if (dSolve == null)
            {
                lg.LogIt("Plate Solve: Image Link Failed: ");
                return(false);
            }
            lg.LogIt("Plate Solve: Image Link Successful");
            ImagePA  = dSolve.ImagePA;
            ImageRA  = dSolve.ImageRA;
            ImageDec = dSolve.ImageDec;

            if (tPlan.RotatorEnabled)
            {
                //RotatorOffset = ImagePA - NHUtil.ReduceTo360( RealRotatorPA);
                RotatorOffset = AstroMath.Transform.NormalizeDegreeRange(ImagePA - RealRotatorPA);
            }
            return(true);
        }
Example #2
0
        public static bool CalibrateRotator()
        {
            ///Calibration procedure for rotator
            ///The purpose is to determine the direction of rotation for positive
            ///  angular input, and the degree the absolute position angle of the rotator
            ///  is offset from the position angle of the camera.
            ///
            ///Plate-solve for the image position angle of the current rotator position
            ///  save the rotator position angle
            ///Rotate +10 degrees (add 10 to current angle reading)
            ///Platesolve the image position angle for this new rotator angle.
            ///  if the new image position angle is 10 greater than the old position angle (mod 360)
            ///    then set the rotator direction vector to 1 (Clockwise), otherwise it's -1 (Counterclockwise).
            ///Rotate -10 degrees to get back to the original position
            ///Plate-solve again to get another image position angle
            ///Average the two angle changes and save the result as the rotator offset value.

            //At this point, the PlateSolve should have "set" the position angle of the rotator

            const double TestAngle = 10;

            //Turn on the logger
            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            lg.LogIt("Plate solving current rotator position");
            if (!PlateSolveIt())
            {
                return(false);
            }

            //double rotatorOffset = NHUtil.ReduceTo360(ImagePA - RealRotatorPA);
            double rotatorOffset    = ImagePA - RealRotatorPA;
            int    rotatorDirection = Math.Sign(RealRotatorPA);

            lg.LogIt("Current rotator position solved");

            StartRotatorAngle = RealRotatorPA;
            StartImagePA      = ImagePA;
            //Rotate by +X degrees
            lg.LogIt("Rotating by +" + TestAngle.ToString("0") + " Degrees");
            RotateToRotatorPA(StartRotatorAngle + TestAngle);
            lg.LogIt("Plate solving new position");
            if (!PlateSolveIt())
            {
                return(false);
            }
            lg.LogIt("Rotated position successfully solved");
            EndRotatorAngle = RealRotatorPA;
            EndImagePA      = ImagePA;
            //endImagePA = pSolve2.ImagePA;
            //endRotatorAngle = pSolve2.RotatorPositionAngle;

            //Rotate by -X degrees
            lg.LogIt("Rotating by " + (-TestAngle).ToString("0") + " Degrees");
            RotateToRotatorPA(StartRotatorAngle);
            TSXLink.PlateSolution pSolve3 = new TSXLink.PlateSolution();
            if (pSolve3 == null)
            {
                return(false);
            }

            rotatorOffset = (StartImagePA - StartRotatorAngle);
            if (StartImagePA + TestAngle < 360)
            {
                if (StartImagePA > EndImagePA)
                {
                    rotatorDirection = -1;
                }
                else
                {
                    rotatorDirection = 1;
                }
            }
            else if (StartImagePA < EndImagePA)
            {
                rotatorDirection = -1;
            }
            else
            {
                rotatorDirection = 1;
            }

            RotatorDirection             = rotatorDirection;
            openSession.RotatorDirection = rotatorDirection;
            lg.LogIt("Rotator behavior successfully calibrated");
            return(true);
        }
Example #3
0
        } = 1;                                 // 1=1x1, 2=2x2, 3=3x3, 4=4x4

        private void StartButton_Click(object sender, EventArgs e)
        {
            //Initialize stuff
            //Verify camera orientation near 0 degrees

            //Repeat
            //      Move to target area:  Dec =0, HA = .1;
            //      Find nearest guide star with magnitude <8 and positive HA (DBQ PEC_Collect.dbq)
            //      Center on target star
            //      Find star
            //      Set Exposure
            //      Find star again
            //      Run Autoguide for 20 minutes
            //      Abort
            //Loop

            //Abort autoguiding, if on
            AutoGuide.AutoGuideStop();

            //Set Binning
            AutoGuide.GuiderXBinning = Binning;
            AutoGuide.GuiderYBinning = Binning;

            //Check orientation
            //slew to west side near meridian at 0 deg declination
            double altAtZeroDec = 90 - GetLocationLatitude();

            TSXLink.ReliableAzAltSlew(183, altAtZeroDec, "");

            //  Take image, image link it and get Position Angle
            AstroImage asti = new AstroImage
            {
                Camera         = AstroImage.CameraType.Imaging,
                Frame          = AstroImage.ImageType.Light,
                Delay          = 0,
                Exposure       = 10,
                ImageReduction = AstroImage.ReductionType.AutoDark,
                BinX           = Binning,
                BinY           = Binning
            };

            if (PACheckBox.Checked)
            {
                TSXLink.Camera gCam = new TSXLink.Camera(asti)
                {
                    AutoSaveOn = 1
                };
                int tstat = gCam.GetImage();
                TSXLink.PlateSolution psln = TSXLink.ImageSolution.PlateSolve(gCam.LastImageFilename());
                //Check for failed image solution.  If so, just return as an error message will have bee3n posted already.
                if (psln == null)
                {
                    return;
                }
                //Check for the image PA to be 0 +/- 3 degrees
                //  if not then give option to opt out.
                InsertImagePAinLog(psln.ImagePA);
                ImagePA = psln.ImagePA;

                if (!PAValid)
                {
                    DialogResult dr = MessageBox.Show(("PA " + (int)psln.ImagePA + "is not near 0 or 180.  Continue?"),
                                                      "Camera Orientation Error",
                                                      MessageBoxButtons.YesNo);
                    if (dr == DialogResult.No)
                    {
                        return;
                    }
                }
                else
                {
                    bool checkWest = PADirection ^ psln.ImageIsMirrored ^ TargetIsWest;
                    //Add info to text output:
                    if (psln.ImageIsMirrored)
                    {
                        OutputTextBox.Text += "\n\r\n\r" + "  --> Plate Solved PA = " + ((int)psln.ImagePA).ToString() + " degrees and image is mirrored.";
                    }
                    else
                    {
                        OutputTextBox.Text += "\n\r\n\r" + "  -->Plate Solved PA = " + ((int)psln.ImagePA).ToString() + " degrees and image is not mirrored.";
                    }
                    if (checkWest)
                    {
                        OutputTextBox.Text += "  Check West in TCS.";
                    }
                    else
                    {
                        OutputTextBox.Text += "  Do not check West in TCS.";
                    }
                }
                //Passed the orientation test, west side
            }

            CompletionTime.Text = (DateTime.Now.AddMinutes((double)LoopsCounter.Value * (double)DurationMinutes.Value + 2)).ToString("HH:mm:ss");

            //Loops
            do
            {
                //Set loop number and time left
                TimeLeft.Text = (TimeSpan.FromMinutes((int)DurationMinutes.Value).ToString("T"));

                //Reset Camera
                AstroImage nasti = new AstroImage
                {
                    Camera         = AstroImage.CameraType.Imaging,
                    Frame          = AstroImage.ImageType.Light,
                    Delay          = 0,
                    Exposure       = 10,
                    SubFrame       = 0,
                    ImageReduction = AstroImage.ReductionType.AutoDark,
                    BinX           = Binning,
                    BinY           = Binning
                };
                TSXLink.Camera ngCam = new TSXLink.Camera(asti)
                {
                    AutoSaveOn = 1
                };

                //Slew to just west of the meridian at 0 deg Declination
                sky6StarChart tsxsc = new sky6StarChart();
                TSXLink.ReliableAzAltSlew(183, altAtZeroDec, "");
                //find a target star here
                //check the focus using this star
                // selected value = 0 for @focus2
                // selected value = 1 for @focus3
                // selected value = 2 for none
                switch (FocusComboBox.SelectedIndex)
                {
                case 0:
                    AutoFocus.Check(false);
                    break;

                case 1:
                    AutoFocus.Check(true);
                    break;

                case 2:
                    break;

                default:
                    break;
                }
                //*** TSXLink.ReliableAzAltSlew(183, altAtZeroDec, "");
                StarList.TargetStarSearch();
                //slew to and center on the found star
                int cls1 = TSXLink.ReliableClosedLoopSlew(StarList.TargetRA, StarList.TargetDec, StarList.TargetName);
                if (cls1 != 0)
                {
                    return;
                }
                //return to base position, assuming that maybe @focus2 went to the wrong side

                AutoGuide.GuiderXBinning = Binning;
                AutoGuide.GuiderYBinning = Binning;
                //Center up the target star as guide star
                // ** For tracking log purposes, pick the brightest star.
                //AutoGuide.SetBestAutoGuideStar();
                AutoGuide.PickAutoGuideStar(AutoGuide.GuideStarCriteria.Bright);
                //Optimize it's exposure level
                AutoGuide.GuideExposure = AutoGuide.OptimizeExposure();
                //Start tracking
                bool gsStatus = AutoGuide.AutoGuideStart();

                //Wait for the duration, checking for abort (e.g. End)
                int durationSecs = (60 * (int)DurationMinutes.Value);
                for (int i = 0; i < durationSecs; i++)
                {
                    System.Threading.Thread.Sleep(1000);
                    TimeLeft.Text = (TimeSpan.FromSeconds(durationSecs - i).ToString("T"));
                    this.Show();
                    System.Windows.Forms.Application.DoEvents();
                    if (abortFlag)
                    {
                        break;
                    }
                }
                //Wait is over, kill the autoguiding/tracking, increment the loop counter and loop
                AutoGuide.AutoGuideStop();
                LoopsCounter.Value -= 1;

                //Correct log PA if PA as been checked.  TSX will not do this for you.
                if (PACheckBox.Checked)
                {
                    FixLog.FixImagePA(ImagePA);
                }

                //Check for pause -- used for changing PEC Curves when experimenting
                if (PauseCheckBox.Checked)
                {
                    MessageBox.Show("Pausing for configuration changes, if any.");
                }
            } while ((abortFlag == false) && (LoopsCounter.Value > 0));
        }