Beispiel #1
0
        public void UpdateFormFromPlan()
        {//Update form fields with the content of a new target plan from the session control file
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            if (tPlan.TargetName == "Default")
            {
                TargetBox.Text = "";
            }
            else
            {
                TargetBox.Text = tPlan.TargetName;
            }

            StartTimeBox.Value        = tPlan.SequenceStartTime;
            TargetRABox.Text          = tPlan.TargetRA.ToString();
            TargetDecBox.Text         = tPlan.TargetDec.ToString();
            TargetPABox.Text          = tPlan.TargetPA.ToString();
            AutoDarkCheck.Checked     = tPlan.AutoDarkEnabled;
            MakeFlatsCheckBox.Checked = tPlan.MakeFlatsEnabled;
            ExposureVal.Value         = (decimal)tPlan.ImageExposureTime;
            LoopsVal.Value            = tPlan.Loops;
            LRGBRatioBox.Value        = tPlan.LRGBRatio;
            DelayVal.Value            = (decimal)tPlan.Delay;
            if (tPlan.TargetAdjustEnabled)
            {
                AdjustedTargetLabel.Visible = true;
            }
            else
            {
                AdjustedTargetLabel.Visible = false;
            }
        }
Beispiel #2
0
        private void AutoGuideOnButton_Click(object sender, EventArgs e)
        {
            //Execute TSX_AutoGuide class
            //  Open and connect to autoguider
            //  if (not calibrated,) { abort
            //  Find guidestar
            //  Turn on Autoguide
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            if (NHUtil.IsButtonRed(AutoGuideOnButton))
            {
                AutoGuide.AutoGuideStop();
                AutoGuideOnButton.Text = "Start\r\nAutoguiding";
                NHUtil.ButtonGreen(AutoGuideOnButton);
            }
            else
            {
                //First, save the guider cycle time and anything else in the future that might be hanging around
                tPlan.GuiderCycleTime = (double)GuiderCycleTimeNum.Value;
                if (tPlan.DitherEnabled)
                {
                    AutoGuide.DitherAndStart();
                }
                else
                {
                    AutoGuide.AutoGuideStart();
                }
                AutoGuideOnButton.Text = "Stop\r\nAutoguiding";
                NHUtil.ButtonRed(AutoGuideOnButton);
            }
        }
Beispiel #3
0
        public void UploadDevicesConfiguration()
        {
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
            {
                AutoGuideEnabled      = AutoguideCheck.Checked,
                RotatorEnabled        = RotatorCheckBox.Checked,
                DitherEnabled         = DitherCheck.Checked,
                GuiderAutoDarkEnabled = GuiderAutoDarkCheckBox.Checked,
                AutoFocusEnabled      = AutofocusCheck.Checked,
                CalibrateEnabled      = CalibrateCheck.Checked,
                ResyncEnabled         = ResyncCheck.Checked,
                CameraTemperatureSet  = (double)CameraTemperatureSet.Value
            };

            openSession.RefocusAtTemperatureDifference = (double)RefocustTemperatureChangeBox.Value;
            if (AtFocus2RadioButton.Checked)
            {
                tPlan.AtFocusSelect = 2;
            }
            else
            {
                tPlan.AtFocusSelect = 3;
            }
        }
Beispiel #4
0
        private void ToTSXButton_Click(object sender, EventArgs e)
        {
            //Tries to look up the name in the target box.  If found, then a new target plan is
            //opened.  Disconnect the telescope (in case centering is forced), use the target box to find
            //and and center the star chart and FOV on the target.
            //If not throw a log entry and return;
            //Remove spaces from target name if any
            //PlanTargetBox.Text = PlanTargetBox.Text.Replace(" ", "");
            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();

            NHUtil.ButtonRed(SelectButton);
            TSXLink.Target tgt = TSXLink.StarChart.FindTarget(PlanTargetBox.Text);
            if (tgt != null)
            {
                TSXLink.Connection.DisconnectDevice(TSXLink.Connection.Devices.Mount);
                TargetPlan newtPlan = new TargetPlan(tgt.Name);
                newtPlan.TargetPA            = TSXLink.FOVI.GetFOVPA;
                newtPlan.TargetAdjustEnabled = false;
                PlanTargetBox.Text           = newtPlan.TargetName;
                TSXLink.StarChart.SetFOV(2);
                LoadTargetPlanList();
                openSession.CurrentTargetName = newtPlan.TargetName;
                lg.LogIt("A new target plan has been created for " + newtPlan.TargetName);
            }
            else
            {
                lg.LogIt(PlanTargetBox.Text + ": target not found.");
            }
            NHUtil.ButtonGreen(SelectButton);
            Show();
        }
Beispiel #5
0
        public void LoadNewTargetPlan(string tname)
        {
            //sets up a target plan for the session.
            //If that target plan file does not have enough entries (e.g. from Image Planner)
            //then merge the default target file into it.  Update the other forms with the new
            //target plan fields.  lthen reload the target plan list.

            SessionControl openSession = new SessionControl();

            openSession.CurrentTargetName = tname;
            TargetPlan tPlan = new TargetPlan(tname);

            if (tPlan.IsSparsePlan())
            {
                tPlan.FlushOutFromDefaultPlan();
            }

            UpdateHumasonSequencer();
            try //If there are problems in the target plan file, this is where they show up
            {
                FormHumason.fDeviceForm.ResetConfiguration();
                FormHumason.fFocusForm.ResetConfiguration();
                FormHumason.fGuideForm.ResetConfiguration();
            }
            catch { } //ignore them
            PlanTargetBox.Text = tname;
            //Update the small solar system enabled field, if any
            SolarSystemBodyCheckBox.Checked = tPlan.SmallSolarSystemBodyEnabled;
            //Reload the target plan list
            LoadTargetPlanList();
        }
Beispiel #6
0
        public static void SaveFlatImage(string targetName, string filterName, string targetPA, string sidePoint)
        {
            //The NH image directory originates from the SetUp form and stored in the
            //Configuration file.
            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);
            //Get Humason directory name, create image directory if it doesn't exist yet
            string nhDirName      = openSession.HumasonDirectoryPath;
            string nhImageDirName = nhDirName + "\\Images";

            if (!Directory.Exists(nhImageDirName))
            {
                Directory.CreateDirectory(nhImageDirName);
            }
            //Create date name for image sub-directory, create if it doesn't exist yet
            DateTime sequenceStartDate = tPlan.SequenceStartTime;
            string   targetImageDir    = nhImageDirName + "\\" + sequenceStartDate.ToString("yyyyMMdd");

            if (!Directory.Exists(targetImageDir))
            {
                Directory.CreateDirectory(targetImageDir);
            }
            //Create Data Files directory if it doesn't exit yet
            string targetImageDataDir = targetImageDir + "\\Calibration Files";

            if (!Directory.Exists(targetImageDataDir))
            {
                Directory.CreateDirectory(targetImageDataDir);
            }

            //Reduce target PA to integer string, i.e. scrape off the decimal
            targetPA = (Convert.ToDouble(targetPA)).ToString("0");
            string targetImageDataPath = targetImageDataDir + "\\" +
                                         filterName +
                                         targetName +
                                         "_" +
                                         targetPA +
                                         "PA" +
                                         sidePoint +
                                         "." +
                                         openSession.SequentialFileNumber.ToString() +
                                         ".fit";
            //open TSX camera and get the last image
            ccdsoftImage tsxi      = new ccdsoftImage();
            int          camStatus = tsxi.AttachToActiveImager();

            //save handling an exception here until some future date
            tsxi.setFITSKeyword("OBJECT", "Humason Flat Field");
            AstroImage tsxc = new AstroImage();

            if (tPlan.RotatorEnabled)
            {
                tsxi.setFITSKeyword("ROTATOR", Rotator.RealRotatorPA.ToString());
            }
            //Set save path and save
            tsxi.Path = targetImageDataPath;
            tsxi.Save();
            lg.LogIt("Flat saved: " + targetImageDataPath);
        }
Beispiel #7
0
        private void FindStarButton_Click(object sender, EventArgs e)
        {
            NHUtil.ButtonRed(FindStarButton);

            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            bool fsbresult = AutoGuide.SetAutoGuideStar();

            //if there is an error, then assume that the exposure is just too low
            // reset the guide exposure to maximum and try again
            if (!fsbresult)
            {
                tPlan.GuideExposure        = tPlan.MaximumGuiderExposure;
                GuideExposureTimeBox.Value = (decimal)tPlan.MaximumGuiderExposure;
                fsbresult = AutoGuide.SetAutoGuideStar();
            }
            //If it worked this time then update the guide star position, otherwise just leave it
            if (fsbresult)
            {
                GuideStarXBox.Text = Convert.ToInt32(tPlan.GuideStarX).ToString();
                GuideStarYBox.Text = Convert.ToInt32(tPlan.GuideStarY).ToString();
            }
            NHUtil.ButtonGreen(FindStarButton);
        }
Beispiel #8
0
        public static bool RotateToImagePA(double tgtImagePA)
        {
            //Move the rotator to a position that gives an image position angle of tImagePA
            //  Assumes that a plate solve has been performed, and/or rotator position angle variables
            //  are current
            //Returns false if failure, true if good

            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            TSXLink.Rotator trot   = new TSXLink.Rotator();
            int             rotDir = Convert.ToInt32(openSession.RotatorDirection);

            //Plate solve for current PA
            if (!PlateSolveIt())
            {
                return(false);
            }
            //target rotation PA = current image PA + current rotator PA - target image PA
            // double tgtRotationPA = ((startImagePA - endImagePA) * rotdir) + rotPA;
            double destRotationPA           = ((ImagePA - tgtImagePA) * -rotDir) + AstroMath.Transform.NormalizeDegreeRange(RealRotatorPA);
            double destRotationPAnormalized = AstroMath.Transform.NormalizeDegreeRange(destRotationPA);

            trot.SetRotatorPositionAngle(destRotationPAnormalized);
            //Plate solve for current PA
            if (!PlateSolveIt())
            {
                return(false);
            }
            return(true);
        }
Beispiel #9
0
 private void AOCheck_CheckedChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         AOEnabled = AOCheckBox.Checked
     };
 }
Beispiel #10
0
 private void MinimumGuideExposureTimeBox_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         MinimumGuiderExposure = (double)MinimumGuideExposureTimeBox.Value
     };
 }
Beispiel #11
0
 private void GuideStarADUNum_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuideStarADU = (Int32)GuideStarADUNum.Value
     };
 }
Beispiel #12
0
 private void Binning2x2RadioButton_CheckedChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuiderBinning = 2
     };
 }
Beispiel #13
0
 private void YAxisMoveTime_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         YAxisMoveTime = (double)YAxisMoveTime.Value
     };
 }
Beispiel #14
0
 private void SubframeCheckBox_CheckedChanged_1(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuiderSubframeEnabled = SubframeCheckBox.Checked
     };
 }
Beispiel #15
0
 private void ClearFilterNum_ValueChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         ClearFilter = (int)ClearFilterNum.Value
     };
 }
Beispiel #16
0
 private void GuiderAutoDarkCheckBox_CheckedChanged(object sender, EventArgs e)
 {
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         GuiderAutoDarkEnabled = GuiderAutoDarkCheckBox.Checked
     };
 }
Beispiel #17
0
        private void StartTimeBox_ValueChanged(object sender, EventArgs e)
        {
            //Save to Session
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            tPlan.SequenceStartTime = StartTimeBox.Value;
        }
Beispiel #18
0
 private void CameraTemperatureSet_ValueChanged(object sender, EventArgs e)
 {
     //Store it in the configuration and move on
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         CameraTemperatureSet = (double)CameraTemperatureSet.Value
     };
 }
Beispiel #19
0
 private void ResyncCheck_CheckedChanged(object sender, EventArgs e)
 {
     //Store it in the configuration and move on
     SessionControl openSession = new SessionControl();
     TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
     {
         ResyncEnabled = ResyncCheck.Checked
     };
 }
Beispiel #20
0
        private void UpdateHumasonSequencer()
        {
            //Causes the sequencer form to be updated with new values
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);
            //Raise target event so target sequence form can update its fields accordingly
            TargetEvent reTarget = FormTarget.targetreset;

            reTarget.TargetEntry(tPlan.TargetName);
        }
Beispiel #21
0
        private void FocusExposureBox_ValueChanged(object sender, EventArgs e)
        {
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
            {
                FocusExposure = (double)FocusExposureBox.Value
            };

            return;
        }
Beispiel #22
0
        private void PlateSolveExposure_ValueChanged(object sender, EventArgs e)
        {
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName)
            {
                PlateSolveExposureTime = (double)PlateSolveExposure.Value
            };

            return;
        }
Beispiel #23
0
        //Class encapsulates autofocus
        // Note that @Focus must be already configured for:
        //   1. Automatically slew to appropriate focus star or already centered on an appropriate focus star
        //   2. Automatically setting exposure time

        public static void FocusIt(int aftype)
        {
            //Execute TSX @Focus2 (ftype = 2) or @Focus3 (ftype = 3)
            //  Save current object information
            //  Open and connect Autofocus
            //  Turn on temperature compensation
            //  Move filter to clear filter
            //  Run Focus@2 or AtFocus 3 for all five filters

            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            lg.LogIt("Initiating Auto Focus" + aftype.ToString());
            //Get current temperature and focus position
            double nowTemp = TSXLink.Focus.GetTemperature();

            lg.LogIt("Current focuser temperature is " + nowTemp.ToString("0.0") + "C");
            double nowPos = TSXLink.Focus.GetPosition();

            lg.LogIt("Current focuser position is " + nowPos.ToString("0"));
            AstroImage asti = new Humason.AstroImage
            {
                Camera         = AstroImage.CameraType.Imaging,
                ImageReduction = AstroImage.ReductionType.AutoDark,
                Frame          = AstroImage.ImageType.Light,
                Filter         = tPlan.FocusFilter,
                Exposure       = tPlan.FocusExposure,
                Delay          = 0
            };

            TSXLink.Focus.RunTempComp();
            lg.LogIt("Focusing with filter " + asti.Filter.ToString());
            switch (aftype)
            {
            case 2:
                TSXLink.Focus.RunAtFocusAny(asti, 2);
                if (!TSXLink.DataWizard.Clear_Observing_List(tPlan.TargetName))
                {
                    lg.LogIt("Clear Observing List Failed");
                }
                break;

            case 3:
                TSXLink.Focus.RunAtFocusAny(asti, 3);
                break;

            default:
                lg.LogIt("Unknown AtFocus selection -- focus failed");
                break;
            }
            lg.LogIt("@Focus" + aftype.ToString() + " complete");
            nowPos = TSXLink.Focus.GetPosition();
            lg.LogIt("New focuser position is " + nowPos.ToString("0"));
        }
Beispiel #24
0
        private void SaveDefaultButton_Click(object sender, EventArgs e)
        {
            //Saves the current active target file as the default file
            SessionControl openSession = new SessionControl();

            NHUtil.ButtonRed(SaveDefaultButton);
            TargetPlan tPlan = new TargetPlan(openSession.CurrentTargetName);

            tPlan.SavePlanAsDefaultPlan();
            NHUtil.ButtonGreen(SaveDefaultButton);
        }
Beispiel #25
0
        private void AtFocus3RadioButton_CheckedChanged(object sender, EventArgs e)
        {
            //Update the configuration file when this button changes
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            if (AtFocus3RadioButton.Checked)
            {
                tPlan.AtFocusSelect = 3;
            }
        }
Beispiel #26
0
        //Grease slick to check if autoguiding is already running
        public static bool IsAutoGuideOn()
        {
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);
            AstroImage     asti        = new AstroImage {
                Camera = AstroImage.CameraType.Guider
            };

            TSXLink.Camera gCam = new TSXLink.Camera(asti);
            return(gCam.IsAutoGuideOn());
        }
Beispiel #27
0
        private void Presetbutton_Click(object sender, EventArgs e)
        {
            //Moves focuser to critical focus position for current temperature based on "Current.foc" focus training file:
            //   Checks for focuser connection
            //   Gets current temperature from focuser
            //   Calls function to compute new position from a selected focus training data file and current temperature
            //   Moves focuser to new position from current position

            NHUtil.ButtonRed(Presetbutton);
            LogEvent       lg          = new LogEvent();
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            //Get a filter focus file path from the configuration file, then validate/change via dialog
            FilterFileDialog.InitialDirectory = openSession.FocuserDataFolder;
            FilterFileDialog.FileName         = "";

            DialogResult focusfilelist = FilterFileDialog.ShowDialog();

            //Check for a null return (e.g. no file selected)
            //  just log it and return if nothing there
            if (focusfilelist != DialogResult.OK)
            {
                lg.LogIt("No focus preset file selected");
                NHUtil.ButtonGreen(Presetbutton);
                return;
            }
            //Else...
            string focusfile = FilterFileDialog.FileNames[0];

            //Save the new (or unchanged) file path
            int baseFilterId = tPlan.FocusFilter;

            lg.LogIt("Presetting focus position");

            double currenttemp      = TSXLink.Focus.GetTemperature();
            double newfocusposition = AutoFocus.ComputeNewFocusPosition(focusfile, currenttemp, baseFilterId);

            if (newfocusposition == 0)
            {
                //Insufficient data to compute new position so, just leave it.
                lg.LogIt("Focus preset aborted -- insufficient data to compute new position");
                NHUtil.ButtonGreen(Presetbutton);
                return;
            }
            else
            {
                TSXLink.Focus.MoveTo(newfocusposition);
            }
            lg.LogIt("Focus preset completed");
            NHUtil.ButtonGreen(Presetbutton);
            return;
        }
Beispiel #28
0
        private void OptimizeExposureButton_Click(object sender, EventArgs e)
        {
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            NHUtil.ButtonRed(OptimizeExposureButton);
            double optExposure = AutoGuide.OptimizeExposure();

            GuideExposureTimeBox.Value = (decimal)optExposure;
            tPlan.GuideExposure        = optExposure;
            NHUtil.ButtonGreen(OptimizeExposureButton);
        }
Beispiel #29
0
        private void MosaicButton_Click(object sender, EventArgs e)
        {
            //Reads and constructs mosaic entry as a set of target plans after a mosaic has
            //  been constructed and copied to the clipboard in TSX
            //
            // Button will be held red until the user has prepared mosaic in TSX and
            //  copied to clipboard
            SessionControl openSession = new SessionControl();

            if (NHUtil.IsButtonGreen(MosaicButton))
            {
                //Verify that a target has been loaded, if not, post error and return
                //  otherwise, set the button color to read, change the text and zero the FOVI
                //  in anticipation of loading a mosaic target set
                TargetPlan tPlan = new TargetPlan(openSession.CurrentTargetName);
                if (TSXLink.StarChart.IsValidTarget(tPlan))
                {
                    NHUtil.ButtonRed(MosaicButton);
                    MosaicButton.Text = "Clipboard Ready";
                    TSXLink.FOVI.SetFOVPA(0);
                }
            }
            else
            {
                Mosaic nhms = new Mosaic();
                List <Mosaic.MosaicTarget> nhmtgts = nhms.ReadTSXMosaic();
                //Just return if no targets are found
                if (nhmtgts != null)
                {
                    //Save the mosaic entries as versions of the current configuration file
                    // For each of the entries in the mosaic,
                    //  Load the values into the configuration file
                    //  Save the configuration file with a prefix tName-Set-Frame
                    string tName = openSession.CurrentTargetName;
                    foreach (Mosaic.MosaicTarget mt in nhmtgts)
                    {
                        string     prefixName = tName + "-" + mt.Set + "-" + mt.Frame;
                        TargetPlan tPlan      = new TargetPlan(prefixName)
                        {
                            TargetName          = prefixName,
                            TargetRA            = mt.RA,
                            TargetDec           = mt.Dec,
                            TargetPA            = mt.PositionAngle,
                            TargetAdjustEnabled = true
                        };
                    }
                }
                LoadTargetPlanList();
                MosaicButton.Text = "Build Mosaic";
                NHUtil.ButtonGreen(MosaicButton);
            }
        }
Beispiel #30
0
        public FormAutoGuide()
        {
            InitializeComponent();
            ColorButtonsGreen();
            //Populate entries with stored entries, if any
            SessionControl openSession = new SessionControl();
            TargetPlan     tPlan       = new TargetPlan(openSession.CurrentTargetName);

            if (tPlan.TargetPlanPath != null)
            {
                try { ResetConfiguration(); } catch { };  //ignore problems in target plan file, fix later
            }
        }