Exemple #1
0
        private void SelectTargetListBox_Click(object sender, EventArgs e)
        {
            currentTargetIndex = SelectTargetListBox.SelectedIndex;
            if (!CurveOnlyBox.Checked)
            {
                //close the current tsx image if one is open
                if (TSX_Image != null)
                {
                    VariScanFileManager.CloseImageFile(TSX_Image);
                }
                //Get the directory name that was chosen
                string targetChoice = SelectTargetListBox.SelectedItem.ToString();
                //Load the variable list entry info for that choice of targets, if none -- return
                TargetList varList = new TargetList();
                IEnumerable <TargetList.TargetXDescriptor> tgtList = varList.GetTargetList();
                TargetList.TargetXDescriptor tgtDef = tgtList.FirstOrDefault(name => name.Name == targetChoice);
                if (tgtDef == null)
                {
                    return;
                }

                FitsIsOpen           = VariScanFileManager.DialogOpenImageFile(TSX_Image, tgtDef.Name);
                OpenFileNameBox.Text = TSX_Image.Path;
                if (FitsIsOpen)
                {
                    TargetedNameBox.Text   = tgtDef.Name;
                    TargetedRABox.Text     = Utility.SexidecimalRADec(tgtDef.RA, true);
                    TargetedDecBox.Text    = Utility.SexidecimalRADec(tgtDef.Dec, false);
                    TargetedFilterBox.Text = tgtList.ElementAt(SelectTargetListBox.SelectedIndex).Filter.ToString();
                    TargetData tstar = Analyze(tgtDef.Name, tgtDef.RA, tgtDef.Dec);
                    if (tstar.IsImageLinked)
                    {
                        ManageTSXProcess.MinimizeTSX();
                        SourceRATextBox.Text  = Utility.SexidecimalRADec(tstar.SourceRA, true);
                        SourceDecTextBox.Text = Utility.SexidecimalRADec(tstar.SourceDec, false);
                        tstar = GraphMagnitudes(tstar);
                        tstar = GraphSource(tstar);
                        FillPhotometrySummary(tstar);
                        PlotPhotometryHistory(tgtDef.Name);
                        ManageTSXProcess.NormalizeTSX();
                    }
                    Show();
                    System.Windows.Forms.Application.DoEvents();
                }
            }
            else
            {
                string targetChoice = SelectTargetListBox.SelectedItem.ToString();
                PlotPhotometryHistory(targetChoice);
                Show();
                System.Windows.Forms.Application.DoEvents();
            }
        }
Exemple #2
0
        //private double freshImageScale = 0;

        public FreshImage(TargetList.TargetXDescriptor targetX)
        {
            //populate freshimage info
            Configuration agncf = new Configuration();

            freshImageName     = targetX.Name;
            freshImageRA       = targetX.RA;
            freshImageDec      = targetX.Dec;
            freshImageFilter   = targetX.Filter;
            freshImageExposure = targetX.Exposure;
            string imageDir = agncf.ImageBankFolder + "\\" + freshImageName;

            if (!Directory.Exists(imageDir))
            {
                Directory.CreateDirectory(imageDir);
            }
            return;
        }
Exemple #3
0
        private void SingleButton_Click(object sender, EventArgs e)
        {
            //DialogResult odr = OrphanFileDialog.ShowDialog();

            //close the current tsx image if one is open
            if (TSX_Image != null)
            {
                VariScanFileManager.CloseImageFile(TSX_Image);
            }

            TargetList.TargetXDescriptor tgtDef = new TargetList.TargetXDescriptor("Orphan", 0, 0, 0);

            FitsIsOpen           = VariScanFileManager.DialogOrphanImageFile(TSX_Image, tgtDef.Name);
            OpenFileNameBox.Text = TSX_Image.Path;
            if (FitsIsOpen)
            {
                Fits fits = new Fits(TSX_Image);
                tgtDef.Name            = fits.FitsTarget;
                tgtDef.RA              = (double)(fits.FitsRA ?? 0);
                tgtDef.Dec             = (double)(fits.FitsDec ?? 0);
                tgtDef.Filter          = 3;
                tgtDef.LastImagingDate = fits.FitsUTCDateTime;

                TargetedNameBox.Text   = tgtDef.Name;
                TargetedRABox.Text     = Utility.SexidecimalRADec(tgtDef.RA, true);
                TargetedDecBox.Text    = Utility.SexidecimalRADec(tgtDef.Dec, false);
                TargetedFilterBox.Text = fits.Filter;
                TargetData tstar = Analyze(tgtDef.Name, tgtDef.RA, tgtDef.Dec);
                if (tstar.IsImageLinked)
                {
                    ManageTSXProcess.MinimizeTSX();
                    SourceRATextBox.Text  = Utility.SexidecimalRADec(tstar.SourceRA, true);
                    SourceDecTextBox.Text = Utility.SexidecimalRADec(tstar.SourceDec, false);
                    tstar = GraphMagnitudes(tstar);
                    tstar = GraphSource(tstar);
                    FillPhotometrySummary(tstar);
                    PlotPhotometryHistory(tgtDef.Name);
                    ManageTSXProcess.NormalizeTSX();
                }
            }
            Show();
            System.Windows.Forms.Application.DoEvents();
            return;
        }
Exemple #4
0
        //Creates a new instance of a FreshImage and sets the filepath for storing it
        public bool Acquire(TargetList.TargetXDescriptor currentTarget)
        {
            Configuration cfg = new Configuration();

            if (!SeekTarget())
            {
                return(false);
            }
            if (Convert.ToBoolean(cfg.AutoADU))
            {
                if (!OptimizeExposure(Convert.ToDouble(cfg.Exposure)))
                {
                    return(false);
                }
            }
            if (!ShootTarget(currentTarget))
            {
                return(false);
            }
            return(true);
        }
Exemple #5
0
        private void StartScan()
        {
            //REad through the AGN entries, least recent first,
            // until either every target is up to date, or time runs out

            //Check to see if scan already underway, if so, then just ignore
            //save current color of start scan button
            if (StartScanButton.BackColor == Color.LightCoral)
            {
                return;
            }
            Color scanbuttoncolorsave = StartScanButton.BackColor;

            StartScanButton.BackColor = Color.LightCoral;

            Configuration cfg    = new Configuration();
            DeviceControl ss_hwp = new DeviceControl();

            //AutoStart section
            //If AutoStart is enabled, then wait for 15 seconds for the user to disable, if desired
            //  Otherwise, initiate the scan
            if (AutoRunCheckBox.Checked)
            {
                LogEventHandler("\r\n" + "********** AutoRun Initiated **********" + "\r\n" + "Unless unchecked, AutoRun will begin in 15 seconds!\r\n");
                for (int i = 0; i < 60; i++)
                {
                    Show();
                    System.Windows.Forms.Application.DoEvents();
                    System.Threading.Thread.Sleep(250);
                    if (!AutoRunCheckBox.Checked)
                    {
                        LogEventHandler("\r\n" + "********** AutoRun Suspended **********" + "\r\n");
                        break;
                    }
                }
                //If AutoStart is still enabled, initiate PreScan, then StartScan, then PostScan
                //  while watching the weather
                //   Otherwise, exit on out
                if (AutoRunCheckBox.Checked)
                {
                    if (WatchWeatherCheckBox.Checked)
                    {
                        WeatherManagement(ss_hwp, false);
                    }
                    LogEventHandler("Awaiting System Staging Time at " + cfg.StageSystemTime.ToString() + "\r\n");
                    Launcher.WaitStage();
                    if (WatchWeatherCheckBox.Checked)
                    {
                        WeatherManagement(ss_hwp, false);
                    }
                    LogEventHandler("Running System Staging Program **********" + "\r\n");
                    Launcher.RunStageSystem();
                    if (WatchWeatherCheckBox.Checked)
                    {
                        WeatherManagement(ss_hwp, false);
                    }
                    LogEventHandler("Awaiting Start Up Time at " + cfg.StartUpTime.ToString() + "\r\n");
                    Launcher.WaitStart();
                    LogEventHandler("Running Start Up Program **********" + "\r\n");
                    if (WatchWeatherCheckBox.Checked)
                    {
                        WeatherManagement(ss_hwp, false);
                    }
                    Launcher.RunStartUp();
                }
            }

            varList = new TargetList();
            CurrentTargetCount.Text = varList.TargetCount.ToString();

            LogEventHandler("\r\n" + "********** Beginning Survey Run **********");
            LogEventHandler("Found " + CurrentTargetCount.Text + " prospective targets -- not all will be qualified.");

            // Scan Running...
            // Connect telescope mount and camera, and dome, if any
            if (ss_hwp.TelescopeStartUp())
            {
                LogEventHandler("Initializing Mount");
            }
            else
            {
                LogEventHandler("Mount initialization failed");
            }
            if (ss_hwp.CameraStartUp())
            {
                LogEventHandler("Initializing Camera");
            }
            else
            {
                LogEventHandler("Camera initialization failed");
            }
            if (Convert.ToBoolean(cfg.UsesDome))
            {
                if (DomeControl.DomeStartUp())
                {
                    LogEventHandler("Initializing Dome");
                }
                else
                {
                    LogEventHandler("Dome initialization failed");
                }
            }
            ;
            Show();

            //Start the sequence on the west side.
            //Theoretically, nearly all targets on west side will be scanned before setting below limit,
            //  and all targets that have transited during that time.  Then all targets on the list which are east
            //  will be scanned.  Lastly, the scan will return to the west to pick up any targets that transited
            //  during the scan on the east side.  Get it?
            ss_hwp.TelescopePrePosition("West");
            //Let's do an autofocus to start out.  Set the temperature to -100 to fake out the temperature test
            //  and force an initial autofocus.
            if (!AFNoneRadioButton.Checked)
            {
                //One stop shopping
                LogEventHandler("Initializing focus");
                string preSet = AutoFocus.PresetFocus();
                LogEventHandler(preSet);
                string focStat = AutoFocus.Check(AF2RadioButton.Checked);
                LogEventHandler(focStat);
            }

            LogEventHandler("Starting Scan");
            LogEventHandler("Bringing camera to temperature");
            ss_hwp.SetCameraTemperature(Convert.ToDouble(CCDTemperatureSetting.Value));

            int gTriedCount      = 0;
            int gSuccessfulCount = 0;
            //
            //
            //Main Loop on the list of targets =================
            //
            //Load the first (least recent) target
            // Loop
            //  If the next target's date is earlier than "today" then
            //  1. Check the weather, if enabled
            //  2. Check the focus (1 degree diff), if enabled
            //  3. Take an image and detect, if enabled
            //  4. Repeat if required.
            //  5. Get the next target
            //
            //Set a bogus target to the lowest altitude at west azimuth
            double lowestAlt = Convert.ToDouble(cfg.MinAltitude);
            double westAz    = 270;

            TargetList.TargetXDescriptor currentTarget = varList.NextClosestTarget(westAz, lowestAlt);
            //Load iteration count for this target
            while ((currentTarget != null) && (DateTime.Now.Date - currentTarget.LastImagingDate.Date > TimeSpan.FromHours(12)))
            {
                LogEventHandler("Target queued: " + currentTarget.Name);
                currentTarget.LastImagingDate = DateTime.Now;
                //Check weather conditions, if enabled
                //  if unsafe then spin until it is safe or endingtime occurs.
                if (WatchWeatherCheckBox.Checked)
                {
                    WeatherManagement(ss_hwp, true);
                }

                //Check for autofocus selection.  If so then run the autofocus check.
                if (!AFNoneRadioButton.Checked)
                {
                    //One stop shopping
                    LogEventHandler("Checking Focus");
                    string focStat = AutoFocus.Check(AF2RadioButton.Checked);
                    LogEventHandler(focStat);
                }
                //Load target form fields
                CurrentTargetName.Text   = currentTarget.Name;
                CurrentTargetFilter.Text = currentTarget.Filter.ToString();

                //Take fresh image
                currentTarget.Exposure = Convert.ToDouble(ExposureTimeSetting.Value);

                FreshImage fso = new FreshImage(currentTarget);

                fso.LogUpdate += LogEventHandler;
                //Seek location of next target
                //Ignor return value
                if (fso.Acquire(currentTarget))
                {
                    LogEventHandler(currentTarget.Name + " Image capture complete.");
                    LogEventHandler(currentTarget.Name + ":" + " Banking new image in " + cfg.ImageBankFolder);
                    //Increment the target count for reporting purposes
                    gSuccessfulCount++;
                    //check for a reference image
                    //  if so then move on to detecting any prospects
                    //  if not, then just log the situation and move on
                }
                else
                {
                    LogEventHandler(currentTarget.Name + ": " + " Image capture failed -- check log for problem.");
                    LogEventHandler("");
                }

                //Update tries counter
                gTriedCount++;
                //Clear target from list and decrement targets left to image
                CurrentTargetCount.Text = (varList.TargetCount - gTriedCount).ToString();
                Show();
                //Check for time to shut down
                LogEventHandler("Checking for ending time");
                if (Convert.ToBoolean(Launcher.CheckEnd()))
                {
                    LogEventHandler("Scan is past end time.  Shutting down.");
                    break;
                }
                //Get next target
                varList.UpdateTargetDate(currentTarget);
                currentTarget = varList.NextClosestTarget(currentTarget);
            }

            LogEventHandler("Session Completed");
            LogEventHandler("Successfully imaged " + gSuccessfulCount + " out of " + gTriedCount + " qualified targets.");

            //Park the telescope so it doesn't drift too low
            ss_hwp.TelescopeShutDown();
            LogEventHandler("AutoRun Running Shut Down Program **********" + "\r\n");
            Launcher.RunShutDown();
            StartScanButton.BackColor = scanbuttoncolorsave;
            return;
        }
Exemple #6
0
        private bool ShootTarget(TargetList.TargetXDescriptor currentTarget)
        {
            Configuration cfg         = new Configuration();
            int           repetitions = Convert.ToInt32(cfg.ImagesPerSample);
            ccdsoftCamera tsx_cc      = new ccdsoftCamera
            {
                AutoSaveOn           = 0, //Autosave Off
                FilterIndexZeroBased = freshImageFilter,
                ExposureTime         = freshImageExposure,
                Subframe             = 0,
                Frame        = ccdsoftImageFrame.cdLight,
                Asynchronous = 1        //Asynchronous on
            };

            //Set up for noise reduction, if any
            switch (cfg.CalibrationType)
            {
            case "None":
            {
                tsx_cc.ImageReduction = ccdsoftImageReduction.cdNone;
                LogEntry("No image calibration.");
                break;
            }

            case "Auto":
            {
                tsx_cc.ImageReduction = ccdsoftImageReduction.cdAutoDark;
                LogEntry("Auto Dark image calibration set");
                break;
            }

            case "Full":
            {
                tsx_cc.ImageReduction = ccdsoftImageReduction.cdBiasDarkFlat;
                Reduction calLib  = new Reduction();
                string    binning = "1X1";
                int       camTemp = (int)tsx_cc.TemperatureSetPoint;
                if (!calLib.SetReductionGroup(freshImageFilter, freshImageExposure, camTemp, binning))
                {
                    LogEntry("No calibration library found: " + "B_" + binning + "T_" + camTemp + "E_" + freshImageFilter.ToString("0") + "F_" + freshImageFilter.ToString("0"));
                    return(false);

                    break;
                }
                LogEntry("Full image calibration set: " + calLib.ReductionGroupName);
                break;
            }
            }
            //Loop on repetitions of image
            do
            {
                SetNextImagePath(cfg.ImageBankFolder + "\\" + freshImageName);
                ccdsoftImage tsx_im = new ccdsoftImage
                {
                    Path = freshImagePath
                };

                LogEntry("Imaging " + currentTarget.Name + " at RA: " + Utility.SexidecimalRADec(freshImageRA, true) +
                         " / Dec: " + Utility.SexidecimalRADec(freshImageDec, false));
                LogEntry("Filter set to " + freshImageFilter.ToString("0"));
                LogEntry("Imaging target for " + freshImageExposure.ToString("0.0") + " secs");
                tsx_cc.TakeImage();
                //Wait for completion
                while (tsx_cc.State != ccdsoftCameraState.cdStateNone)
                {
                    System.Threading.Thread.Sleep(1000);
                    System.Windows.Forms.Application.DoEvents();
                }
                tsx_im.AttachToActiveImager();
                tsx_im.setFITSKeyword("OBJECT", freshImageName);
                tsx_im.Save();
                repetitions--;
            } while (repetitions > 0);
            LogEntry("Imaging target Complete");
            return(true);
        }