예제 #1
0
            public static bool RunAtFocusAny(AstroImage asti, int aftype)
            {
                //Run @Focus2 or 3 with filternumber.  return True if (successful, false if (not

                //   Before running this method, save the current target name and camera configuration so it can be found again
                //   Restore current target, using Name with Find method, and reload camera configuration afterwards
                //   as @Focus3 using automatic star search off, overwrites the observating list and object)
                //   Also, may want to run Closed}Slew back to target and Turn on temperature compensation (A)
                //

                //Make sure focuser is connected
                //Create camera object
                ccdsoftCamera tsxc = new ccdsoftCamera
                {
                    Asynchronous        = 0,
                    AutoSaveFocusImages = 0,
                    ImageReduction      = (ccdsoftImageReduction)asti.ImageReduction,
                    Frame = (ccdsoftImageFrame)asti.Frame,
                    FilterIndexZeroBased = asti.Filter,
                    FocusExposureTime    = asti.Exposure,
                    Delay = 0
                };

                //Run @Focus2 or 3
                //   Create a camera object
                //   Launch the autofocus watching out for an exception -- which will be posted in TSX
                switch (aftype)
                {
                case 2:
                    try
                    { int focstat = tsxc.AtFocus2(); }
                    catch
                    {
                        //Just close up, TSX will spawn error window unless this is an abort
                        //lg.LogIt("@Focus2 fails for " + ex.Message);
                        return(false);
                    }
                    //@Focus2 will generate an observing list.  Clear it.
                    break;

                case 3:
                    try
                    { int focstat = tsxc.AtFocus3(3, true); }
                    catch
                    {
                        //Just close up, TSX will spawn error window unless this is an abort
                        //lg.LogIt("@Focus3 fails for " + ex.Message);
                        return(false);
                    }
                    //lg.LogIt("@Focus3 successful");
                    break;

                default:
                    // lg.LogIt("Unknown AtFocus selection -- focus failed");
                    break;
                }
                return(true);
            }
예제 #2
0
        //Autofocus manages the TSX functions to refocus the camera
        // every change of 1 degree in temperature.
        //The first fime autofocus is called, the telescope is slewed to
        // a position with Az = 90, Alt = 80.  Then @Focus2 is called with
        // TSX providing the star to use.  the temperature at that time is recorded.
        //Subsequent calls to autofocus check to see if the current focuser temperature
        //  is more than a degree celsius different from the last @autofocus2 time.
        //  if so, @autofocus2 is called again, although the telescope is not slewed.  And so on.

        public static string Check()
        {
            //check to see if current temperature is a degree different from last temperature
            //  If so, then set up and run @focus2
            //AtFocus2 chooses to use a 15 degree x 15 degree field of view to choose a focus star
            //  If the current position is close to the meridian then a focus star on the other
            //  side of the meridian can be choosen and the mount will flip trying to get to it
            //  and, if using a dome, the slew does not wait for the dome slit to catch up (CLS flaw)
            //  so not only will an exception be thrown (Dome command in progress Error 125) the first image
            //   will be crap and the focus fail (as of DB 11360).  So, this method will point the mount to a
            //  altitude that is no more than 80 degrees at the same azimuth of the current position in order
            //  to avoid a flip and subsequent bullshit happening

            ccdsoftCamera tsxc = new ccdsoftCamera();

            tsxc.Connect();
            double currentTemp = tsxc.focTemperature;

            if (Math.Abs(currentTemp - afLastTemp) > 1)
            {
                //Going to have to refocus.

                //Move to altitude away from meridian, if need be
                sky6RASCOMTele tsxt = new sky6RASCOMTele();
                tsxt.GetAzAlt();
                double tAlt = tsxt.dAlt;
                if (tAlt > 80)
                {
                    double tAz = tsxt.dAz;
                    tAlt = 80.0;
                    //turn off tracking to avoid dome error
                    //DeviceControl dctl = new DeviceControl();
                    //dctl.DomeTrackingOff();
                    tsxt.SlewToAzAlt(tAz, tAlt, "AtFocus2ReadyPosition");
                    //dctl.DomeTrackingOn();
                }

                //reset last temp
                afLastTemp = currentTemp;
                int syncSave = tsxc.Asynchronous;
                tsxc.Asynchronous = 0;
                try
                {
                    int focStat = tsxc.AtFocus2();
                }
                catch (Exception e)
                {
                    tsxc.Asynchronous = syncSave;
                    return("Focus Check: " + e.Message);
                }
                return("Focus Check: Focus successful");
            }
            return("Focus Check: Temperature change less than 1 degree");
        }
예제 #3
0
        //Autofocus manages the TSX functions to refocus the camera
        // every change of 1 degree in temperature.
        //The first fime autofocus is called, the telescope is slewed to
        // a position with Az = 90, Alt = 80.  Then @Focus2 is called with
        // TSX providing the star to use.  the temperature at that time is recorded.
        //Subsequent calls to autofocus check to see if the current focuser temperature
        //  is more than a degree celsius different from the last @autofocus2 time.
        //  if so, @autofocus2 is called again, although the telescope is not slewed.  And so on.

        /// <summary>
        /// Checks temp and runs autofocus 2 or 3 if exceeds one degree
        /// </summary>
        /// <param name="AtFocus2"></param>
        /// <returns></returns>
        public static string Check(bool AtFocus3)
        {
            //check to see if current temperature is a degree different from last temperature
            //  If so, then set up and run @focus2
            //AtFocus2 chooses to use a 15 degree x 15 degree field of view to choose a focus star
            //  If the current position is close to the meridian then a focus star on the other
            //  side of the meridian can be choosen and the mount will flip trying to get to it
            //  and, if using a dome, the slew does not wait for the dome slit to catch up (CLS flaw)
            //  so not only will an exception be thrown (Dome command in progress Error 125) the first image
            //   will be crap and the focus fail (as of DB 11360).  So, this method will point the mount to a
            //  altitude that is no more than 80 degrees at the same azimuth of the current position in order
            //  to avoid a flip and subsequent bullshit happening

            ccdsoftCamera tsxc = new ccdsoftCamera();

            tsxc.Connect();
            double currentTemp = tsxc.focTemperature;

            if (Math.Abs(currentTemp - afLastTemp) > 1)
            {
                //Going to have to refocus.

                ////Move to altitude away from meridian, if need be
                //sky6RASCOMTele tsxt = new sky6RASCOMTele();
                //tsxt.GetAzAlt();
                //double tAlt = tsxt.dAlt;
                //if (tAlt > 80)
                //{
                //    double tAz = tsxt.dAz;
                //    tAlt = 80.0;
                //    tsxt.SlewToAzAlt(tAz, tAlt, "AtFocus2ReadyPosition");
                //}

                //reset last temp
                afLastTemp = currentTemp;
                int syncSave = tsxc.Asynchronous;
                tsxc.Asynchronous = 0;
                if (AtFocus3)
                {
                    //Set the starchart size to 3 degrees so we minimize the chance of finding a star on
                    //  the wrong side of the meridian, if auto-selecting star
                    sky6StarChart tschrt = new sky6StarChart();
                    tschrt.FieldOfView = 3.0;
                    //run either of the focusing routings
                    try
                    {
                        int focStat = tsxc.AtFocus3(3, true);
                    }
                    catch (Exception e)
                    {
                        tsxc.Asynchronous = syncSave;
                        return("Focus Check: " + e.Message);
                    }
                }
                else
                {
                    try
                    {
                        int focStat = tsxc.AtFocus2();
                    }
                    catch (Exception e)
                    {
                        tsxc.Asynchronous = syncSave;
                        return("Focus Check: " + e.Message);
                    }
                    //Throw in a 5 sec wait to see if TSX can't set the telescope crosshairs back to original condition
                    System.Threading.Thread.Sleep(5000);
                }
                return("Focus Check: Focus successful");
            }
            return("Focus Check: Temperature change less than 1 degree");
        }
예제 #4
0
/// Windows C# Sample Console Application: AutoFocus
///
/// ------------------------------------------------------------------------
///
///               Author: R.McAlister (2017)
///
/// ------------------------------------------------------------------------
///
/// This application performs the following steps:
///   Saves the current target and imaging parameters
///   Turns off Autoguiding (if on)
///   Turns on AutoFocus
///   Returns to the current target

/// Note that "Automatically slew telescope to nearest appropriate focus star" must be checked in the @Focus2 start-up window.
///

    public void AutoFocusSample()
    {
        int iFilter = 3; ///Luminescent, I hope

        ///Connect the telescope for some slewing
        sky6RASCOMTele tsx_tt = new sky6RASCOMTele();

        tsx_tt.Connect();

        ///Work around and Run @Focus2
        ///   Save current target name so it can be found again
        ///   Run @Focus2 (which preempts the observating list and object)
        ///   Restore current target, using Name with Find method
        ///   ClosedLoopSlew back to target

        ccdsoftCamera tsx_cc = new ccdsoftCamera();

        tsx_cc.Connect();
        tsx_cc.focConnect();

        ///Get current target name so we can return after running @focus2
        sky6ObjectInformation tsx_oi = new sky6ObjectInformation();

        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1);
        string sTargetName = tsx_oi.ObjInfoPropOut;

        ///TBD: Set up parameters for @Focus2, if necessary
        ///
        ///Run Autofocus
        ///   Create a camera object
        ///   Launch the autofocus watching out for an exception -- which will be posted in TSX

        ///Save current camera delay, exposure and filter
        /// then set the camera delay = 0
        /// set the delay back when done with focusing

        tsx_cc.AutoSaveFocusImages = 0;
        var dCamDelay     = tsx_cc.Delay;
        var iCamReduction = tsx_cc.ImageReduction;
        var iCamFilter    = tsx_cc.FilterIndexZeroBased;
        var dCamExp       = tsx_cc.ExposureTime;
        var iFocStatus    = 0;

        tsx_cc.ImageReduction       = ccdsoftImageReduction.cdAutoDark;
        tsx_cc.FilterIndexZeroBased = 3; ///Luminance
        tsx_cc.ExposureTime         = 10;
        tsx_cc.Delay = 0;
        tsx_cc.FilterIndexZeroBased = iFilter;

        iFocStatus = tsx_cc.AtFocus2();

        ///Restore the current target and slew back to it
        ///   Run a Find on the target -- which makes it the "observation"
        ///   Perform Closed Loop Slew to the target

        sky6StarChart tsx_sc = new sky6StarChart();

        tsx_sc.Find(sTargetName);
        ///Run a Closed Loop Slew to return
        ClosedLoopSlew tsx_cls = new ClosedLoopSlew();

        ///Set the exposure, filter to luminance and reduction, set the camera delay to 0 -- any backlash
        /// should be picked up in the mount driver
        tsx_cc.ImageReduction       = ccdsoftImageReduction.cdAutoDark;
        tsx_cc.FilterIndexZeroBased = iFilter; ///Luminance, probably
        tsx_cc.ExposureTime         = 10;
        tsx_cc.Delay = 0;
        try
        {
            var clsstat = tsx_cls.exec();
        }
        catch
        {
            ///Just close up: TSX will spawn error window
            ///System.Windows.Forms.Show("AutoFocus return failure")
        };
        ///Put back the orginal settings

        tsx_cc.ImageReduction       = iCamReduction;
        tsx_cc.FilterIndexZeroBased = iCamFilter;
        tsx_cc.ExposureTime         = dCamExp;
        tsx_cc.Delay = dCamDelay;

        return;
    }