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
        private void WeatherManagement(DeviceControl ss_hwp, bool IsActive)
        {
            //Check weather conditions, if enabled
            //  if unsafe then spin until it is safe or endingtime occurs.
            Configuration cfg = new Configuration();

            if (WatchWeatherCheckBox.Checked)
            {
                LogEventHandler("Checking Weather");
                if (!IsWeatherSafe())
                {
                    if (IsActive)
                    {
                        LogEventHandler("Waiting on unsafe weather conditions...");
                        LogEventHandler("Parking telescope");
                        if (ss_hwp.TelescopeShutDown())
                        {
                            LogEventHandler("Mount parked");
                        }
                        else
                        {
                            LogEventHandler("Mount park failed");
                        }

                        LogEventHandler("Closing Dome");
                        if (Convert.ToBoolean(cfg.UsesDome))
                        {
                            DomeControl.CloseDome();
                        }
                    }
                    else
                    {
                        LogEventHandler("Waiting on unsafe weather conditions...");
                    }
                    do
                    {
                        System.Threading.Thread.Sleep(10000);  //ten second wait loop
                        if (Convert.ToBoolean(Launcher.CheckEnd()))
                        {
                            break;
                        }
                        ;
                    } while (!IsWeatherSafe());
                    if (Convert.ToBoolean(Launcher.CheckEnd()))
                    {
                        return;
                    }
                    ;
                    if (IsWeatherSafe())
                    {
                        if (IsActive)
                        {
                            LogEventHandler("Weather conditions safe");
                            LogEventHandler("Opening Dome");
                            if (Convert.ToBoolean(cfg.UsesDome))
                            {
                                DomeControl.OpenDome();
                            }
                            LogEventHandler("Unparking telescope");
                            if (ss_hwp.TelescopeStartUp())
                            {
                                LogEventHandler("Mount unparked");
                            }

                            //Wait for 30 seconds for everything to settle
                            LogEventHandler("Waiting for dome to settle");
                            System.Threading.Thread.Sleep(30000);
                            //Recouple dome
                            if (Convert.ToBoolean(cfg.UsesDome))
                            {
                                DomeControl.IsDomeCoupled = true;
                            }
                        }
                        else
                        {
                            LogEventHandler("Weather conditions safe");
                        }
                    }
                }
                return;
            }
        }
Beispiel #3
0
        //Find the coordinates of the object targetName and perform a slew, then CLS to it.
        private bool SeekTarget()
        {
            sky6StarChart         tsx_sc  = new sky6StarChart();
            ClosedLoopSlew        tsx_cl  = new ClosedLoopSlew();
            sky6RASCOMTele        tsx_mt  = new sky6RASCOMTele();
            sky6Raven             tsx_rv  = new sky6Raven();
            sky6ObjectInformation tsx_obj = new sky6ObjectInformation();

            //Clear any camera set up stuff that might be hanging around
            //  and there has been some on occasion
            //Removed subframe on request for cameras with long download times
            ccdsoftCamera tsx_cc = new ccdsoftCamera()
            {
                Subframe = 0,
                Delay    = 0
            };

            LogEntry("Finding coordinates for " + freshImageName);
            tsx_sc.Find(this.freshImageRA.ToString() + "," + this.freshImageDec.ToString());

            //Make sure that the mount commands are synchronous
            tsx_mt.Asynchronous = 0;
            //LogEntry("Initial slew to target");
            ////Slew the mount and dome should follow before completion...
            // try { tsx_mt.SlewToRaDec(tRA, tDec, freshImageName); }
            //catch (Exception ex) { LogEntry("Slew error: " + ex.Message); }

            //Test to see if a dome tracking operation is underway.
            // If so, doing a IsGotoComplete will throw an Error 212.
            //  Ignore it a wait a few seconds for stuff to clear

            //If using dome, toggle dome coupling:  this appears to clear most Error 123 problems
            Configuration cfg     = new Configuration();
            bool          hasDome = Convert.ToBoolean(cfg.UsesDome);

            if (hasDome)
            {
                sky6Dome tsx_dm = new sky6Dome();
                tsx_dm.IsCoupled = 0;
                System.Threading.Thread.Sleep(1000);
                tsx_dm.IsCoupled = 1;
            }

            //Wait for any Error 123//s to clear

            LogEntry("Precision slew (CLS) to target");
            DeviceControl dctl      = new DeviceControl();
            int           clsStatus = dctl.ReliableClosedLoopSlew(freshImageRA, freshImageDec, freshImageName, hasDome);

            LogEntry("Precision Slew Complete:  ");
            if (clsStatus == 0)
            {
                LogEntry("    CLS successful");
                return(true);
            }
            else
            {
                LogEntry("    CLS unsucessful: Error: " + clsStatus.ToString());
                return(false);
            }
        }