Beispiel #1
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;
        }
Beispiel #2
0
        public void InitializeCollection()
        {
            //Initialize VariScan configuration folders, files, default data, as needed
            Configuration cfg = new Configuration();

            //Populate the form configuration parameters with the configuration entries.
            ExposureTimeSetting.Value = Convert.ToDecimal(cfg.Exposure);
            MinAltitudeSetting.Value  = Convert.ToDecimal(cfg.MinAltitude);
            AutoRunCheckBox.Checked   = Convert.ToBoolean(cfg.AutoStart);
            switch (cfg.AutoFocus)
            {
            case "None":
            {
                AFNoneRadioButton.Checked = true;
                break;
            }

            case "2":
            {
                AF2RadioButton.Checked = true;
                break;
            }

            case "3":
            {
                AF3RadioButton.Checked = true;
                break;
            }

            default:
            {
                AFNoneRadioButton.Checked = true;
                break;
            }
            }
            CollectionGroupBox.Text         = Path.GetFileName(cfg.CollectionFolderPath);
            WatchWeatherCheckBox.Checked    = Convert.ToBoolean(cfg.WatchWeather);
            DomeCheckBox.Checked            = Convert.ToBoolean(cfg.UsesDome);
            OnTopCheckBox.Checked           = Convert.ToBoolean(cfg.SurveyFormOnTop);
            CalibrationListBox.SelectedItem = cfg.CalibrationType;
            CCDTemperatureSetting.Value     = Convert.ToDecimal(cfg.CCDTemp);
            RetakeIntervalBox.Value         = Convert.ToDecimal(cfg.MinRetakeInterval);
            AutoExposureCheckBox.Checked    = Convert.ToBoolean(cfg.AutoADU);
            MaxADUBox.Value          = (int)Convert.ToInt32(cfg.ADUMax);
            ImagesPerSampleBox.Value = (int)Convert.ToInt32(cfg.ImagesPerSample);
            try
            { this.Text = ApplicationDeployment.CurrentDeployment.CurrentVersion.ToString(); }
            catch
            {
                //probably in debug mode
                this.Text = " in Debug";
            }
            this.Text = "VariScan V" + this.Text;

            //Check for number of targets
            varList = new TargetList();
            CurrentTargetCount.Text = varList.TargetCount.ToString();
            LogEventHandler("");
            LogEventHandler("\r\n" + "********** Initiating VariScan **********");
            LogEventHandler("Found " + CurrentTargetCount.Text + " prospective targets -- not all will be qualified.");
            return;
        }
Beispiel #3
0
        private void ScanImagesButton_Click(object sender, EventArgs e)
        {
            //Redden the command button
            Utility.ButtonRed(ScanImagesButton);
            Show();
            System.Windows.Forms.Application.DoEvents();

            //Get list of targets
            TargetList vList = new TargetList();
            List <TargetList.TargetXDescriptor> targetList = vList.GetTargetList();

            for (int iTgt = 0; iTgt < targetList.Count; iTgt++)
            {
                string targetDirectoryName = targetList[iTgt].Name;
                FitsNameBox.Text = targetDirectoryName;
                Show();
                System.Windows.Forms.Application.DoEvents();

                IEnumerable <string> targetImages = VariScanFileManager.TargetImageList(targetDirectoryName);
                if (targetImages != null)
                {
                    foreach (string iFile in targetImages)
                    {
                        //Use a direct fits reader to determine if the image has already been analyized, i.e. in Starchive (TSX is too slow)
                        Starchive recs  = new Starchive();
                        FitsFile  fitMe = new FitsFile(iFile);
                        FitsNameBox.Text   = targetDirectoryName;
                        FitsDateBox.Text   = fitMe.FitsUTCDateTime.ToShortDateString();
                        FitsTimeBox.Text   = fitMe.FitsUTCDateTime.ToShortTimeString();
                        FitsFilterBox.Text = fitMe.Filter.ToString();
                        Show();
                        System.Windows.Forms.Application.DoEvents();

                        if (!recs.HasMatchingPhotometryRecord(targetDirectoryName, fitMe.Filter, fitMe.FitsUTCDateTime))
                        {
                            if (TSX_Image != null)
                            {
                                VariScanFileManager.CloseImageFile(TSX_Image);
                            }
                            FitsIsOpen = VariScanFileManager.DirectOpenFitsFile(TSX_Image, iFile);
                            if (FitsIsOpen)
                            {
                                OpenFileNameBox.Text = iFile;
                                FITImage             = new Fits(TSX_Image);
                                //if (!recs.HasMatchingPhotometryRecord(targetDirectoryName, FITImage.Filter, FITImage.FitsUTCDateTime))
                                //{
                                ManageTSXProcess.MinimizeTSX();
                                TargetedNameBox.Text   = targetList[iTgt].Name;
                                TargetedRABox.Text     = Utility.SexidecimalRADec(targetList[iTgt].RA, true);
                                TargetedDecBox.Text    = Utility.SexidecimalRADec(targetList[iTgt].Dec, false);
                                TargetedFilterBox.Text = targetList[iTgt].Filter.ToString();
                                TargetData tstar = Analyze(targetList[iTgt].Name, targetList[iTgt].RA, targetList[iTgt].Dec);
                                if (tstar.IsImageLinked)
                                {
                                    SourceRATextBox.Text  = Utility.SexidecimalRADec(tstar.SourceRA, true);
                                    SourceDecTextBox.Text = Utility.SexidecimalRADec(tstar.SourceDec, false);
                                    tstar = GraphMagnitudes(tstar);
                                    tstar = GraphSource(tstar);
                                    FillPhotometrySummary(tstar);
                                    ArchiveStar(tstar);
                                    PlotPhotometryHistory(targetList[iTgt].Name);
                                    Show();
                                    System.Windows.Forms.Application.DoEvents();
                                }
                                else
                                {
                                    //Star did not image link -- archive it as is
                                    ArchiveStar(tstar);
                                }
                                ManageTSXProcess.NormalizeTSX();
                                //}
                                Show();
                                System.Windows.Forms.Application.DoEvents();
                            }
                        }
                    }
                }
            }
            breakLoop = false;
            Utility.ButtonGreen(BreakButton);
            //Green the command button
            Utility.ButtonGreen(ScanImagesButton);
            return;
        }