Esempio n. 1
0
        /// <summary>
        /// Opens the dome slit after rotating the dome to dome home position
        /// to align power connections
        /// </summary>
        /// <param name="domeHomeAz">Home aximuth of dome in degrees</param>
        public static void OpenDome(int domeHomeAz)
        {
            //Method for opening the TSX dome
            // use exception handlers to check for dome commands, opt out if none
            //  couple the dome to telescope if everything works out
            sky6Dome tsxd = new sky6Dome();

            //Decouple the dome from the telescope
            IsDomeCoupled = false;
            //Move dome to 20 degrees short of home position
            tsxd.GotoAzEl(domeHomeAz - 20, 0);
            System.Threading.Thread.Sleep(5000);
            //Wait until complete (Sync mode doesn//t seem to work)
            while (tsxd.IsGotoComplete == 0)
            {
                System.Threading.Thread.Sleep(5000);
            }
            ;
            //Home the dome,wait for the command to propogate, then wait until the dome reports it is homed
            tsxd.FindHome();
            System.Threading.Thread.Sleep(5000);
            while (tsxd.IsFindHomeComplete == 0)
            {
                System.Threading.Thread.Sleep(5000);
            }
            ;
            // open the dome shutter
            tsxd.OpenSlit();
            System.Threading.Thread.Sleep(10000);  //Wait for close command to clear TSX and ASCOM driver
            while (tsxd.IsOpenComplete == 0)
            {
                System.Threading.Thread.Sleep(5000);
            }                                        //five second wait loop
            return;
        }
Esempio n. 2
0
        public static bool OpenDome(int domeHomeAz)
        {
            //Method to open dome
            //Assume the dome is properly positioned for power
            //Position the dome with at home (wipers on pads)
            // open the dome shutter
            sky6RASCOMTele tsxt = new sky6RASCOMTele();

            //Make sure dome is connected and decoupled
            IsDomeCoupled = false;
            //Disconnect the mount
            tsxt.Disconnect();

            sky6Dome tsxd = new sky6Dome();

            try { tsxd.Connect(); }
            catch { return(false); }
            //Stop whatever the dome might have been doing, if any and wait a few seconds for it to clear
            try { tsxd.Abort(); }
            catch { }
            System.Threading.Thread.Sleep(10);
            //Goto home position using goto rather than home
            ReliableGoTo(domeHomeAz);
            //Open Slit
            tsxd.OpenSlit();
            System.Threading.Thread.Sleep(10);  //Workaround for problme in TSX
            while (tsxd.IsOpenComplete == 0)
            {
                System.Threading.Thread.Sleep(1000);
            }                                                                         //one second wait loop
            IsDomeCoupled = true;
            return(true);
        }
Esempio n. 3
0
        /// <summary>
        /// Rotates the dome to the target Azimuth
        /// </summary>
        /// <param name="domeHomeAz"></param>
        /// <returns></returns>
        public static bool GoToDomeAz(int domeHomeAz)
        {
            //Method for opening the TSX dome
            // use exception handlers to check for dome commands, opt out if none
            //  couple the dome to telescope if everything works out
            sky6Dome tsxd = new sky6Dome();

            //Park Mount
            TSXLink.Mount.Park();
            //Abort any dome commands
            AbortDome();
            //Wait for command to clear
            System.Threading.Thread.Sleep(1000);
            try
            { tsxd.GotoAzEl(domeHomeAz - 20, 0); }
            catch (Exception ex)
            { return(false); }
            System.Threading.Thread.Sleep(1000); // Wait for dome controller to catch up
            while (tsxd.IsGotoComplete == 0)
            {
                System.Threading.Thread.Sleep(1000);
            }
            System.Threading.Thread.Sleep(1000);
            return(true);
        }
Esempio n. 4
0
        /// <summary>
        /// Aborts any outstanding dome operation
        /// </summary>
        /// <returns></returns>
        public static bool AbortDome()
        {
            sky6Dome tsxd = new sky6Dome();

            try { tsxd.Abort(); }
            catch (Exception ex) { return(false); }
            System.Threading.Thread.Sleep(1000);  //Wait for abort command to clear
            return(true);
        }
Esempio n. 5
0
        /// <summary>
        /// Parks the mount and decouples the dome (if not automatic)
        /// </summary>
        /// <returns>true if successful</returns>
        public static bool ParkAndDecouple()
        {
            //Decouple the dome from the mount position and park the mount
            sky6RASCOMTele tsxt = new sky6RASCOMTele();
            sky6Dome       tsxd = new sky6Dome();

            IsDomeCoupled = false;
            TSXLink.Mount.Park();
            return(true);
        }
Esempio n. 6
0
        public static bool DomeStartUp()
        {
            //Method for connecting and initializing the TSX dome, if any
            // use exception handlers to check for dome commands, opt out if none
            //  couple the dome to telescope if everything works out
            sky6Dome tsxd = new sky6Dome();

            try { tsxd.Connect(); }
            catch { return(false); }
            return(true);
        }
Esempio n. 7
0
        public void DomeCouplingOff()
        {
            //Uncouple dome tracking, then recouple dome tracking (synchronously)
            sky6Dome tsxd = new sky6Dome();

            tsxd.IsCoupled = 0;
            System.Threading.Thread.Sleep(500);
            while (IsDomeTrackingUnderway())
            {
                System.Threading.Thread.Sleep(1000);
            }
            return;
        }
Esempio n. 8
0
        public void ToggleDomeCoupling()
        {
            //Uncouple dome tracking, then recouple dome tracking (synchronously)
            sky6Dome tsxd = new sky6Dome();

            tsxd.IsCoupled = 0;
            System.Threading.Thread.Sleep(1000);
            tsxd.IsCoupled = 1;
            //Wait for all dome activity to stop
            while (IsDomeTrackingUnderway())
            {
                System.Threading.Thread.Sleep(1000);
            }
            return;
        }
Esempio n. 9
0
        /// <summary>
        /// Opens the dome slit after rotating the dome to dome home position
        /// to align power connections
        /// </summary>
        /// <param name="domeHomeAz">Home aximuth of dome in degrees</param>
        public static void OpenDome()
        {
            //Method for opening the TSX dome that ensures that wipers for power to the dome
            //  are lined up correctly at the home position so power can flow!
            // use exception handlers to check for dome commands, opt out if none
            //  couple the dome to telescope if everything works out
            sky6Dome tsxd = new sky6Dome();

            //Decouple the dome from the telescope
            IsDomeCoupled = false;
            //Move dome to 20 degrees short of home position
            //  then come back to make sure the home switch is activated accurately

            //Get the az of the current postion -- probably home
            tsxd.GetAzEl();
            double azHome = tsxd.dAz;

            //Move to 20 degrees CCW of current position
            tsxd.GotoAzEl(azHome - 20, 0);
            System.Threading.Thread.Sleep(1000);
            //Wait until complete (Sync mode doesn//t seem to work)
            while (tsxd.IsGotoComplete == 0)
            {
                System.Threading.Thread.Sleep(5000);
            }
            ;
            //Home the dome,wait for the command to propogate, then wait until the dome reports it is homed
            System.Threading.Thread.Sleep(6000);
            tsxd.FindHome();
            System.Threading.Thread.Sleep(1000);
            while (tsxd.IsFindHomeComplete == 0)
            {
                System.Threading.Thread.Sleep(5000);
            }
            ;
            // open the dome shutter
            tsxd.OpenSlit();
            System.Threading.Thread.Sleep(10000);  //Wait for close command to clear TSX and ASCOM driver
            while (tsxd.IsOpenComplete == 0)
            {
                System.Threading.Thread.Sleep(5000);
            }                                        //five second wait loop
            return;
        }
Esempio n. 10
0
        private static void ReliableGoTo(double az)
        {
            //Slews dome to azimuth while avoiding lockup if already there
            sky6Dome tsxd = new sky6Dome();

            tsxd.GetAzEl();
            double currentAz = tsxd.dAz;

            if (currentAz - az > 1)
            {
                tsxd.GotoAzEl(az, 0);
                System.Threading.Thread.Sleep(10);
                while (tsxd.IsGotoComplete == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            return;
        }
Esempio n. 11
0
        private bool IsDomeTrackingUnderway()
        {
            //Test to see if a dome tracking operation is underway.
            // If so, doing a IsGotoComplete will throw an Error 212.
            // return true
            // otherwise return false
            sky6Dome tsxd = new sky6Dome();
            int      testDomeTrack;

            try { testDomeTrack = tsxd.IsGotoComplete; }
            catch { return(true); }
            if (testDomeTrack == 0)
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Esempio n. 12
0
        /// <summary>
        /// Brings the dome to the home position after resetting to azimuth home-20
        /// -- will Park the mount
        /// </summary>
        /// <param name="domeHomeAz"></param>
        /// <returns></returns>
        public static bool HomeDome(int domeHomeAz)
        {
            // use exception handlers to check for dome commands, opt out if none
            //Decouple the dome from the mount position and park the mount
            ParkAndDecouple();

            //Connect to the dome and abort any dome commands
            sky6Dome tsxd = new sky6Dome();

            try { tsxd.Connect(); }
            catch { return(false); }
            //Stop whatever the dome is doing, if any and wait a few seconds for it to clear
            if (!AbortDome())
            {
                return(false);
            }
            //Move dome to 20 degrees short of home position
            try
            {
                tsxd.GotoAzEl(domeHomeAz - 20, 0);
                System.Threading.Thread.Sleep(1); // Release task thread so TSX can start FindHome -- Command in Progress exception otherwise
                while (tsxd.IsGotoComplete == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            catch { return(false); };
            //Find Home
            try
            {
                tsxd.FindHome();
                System.Threading.Thread.Sleep(1); // Release task thread so TSX can start FindHome -- Command in Progress exception otherwise
                while (tsxd.IsFindHomeComplete == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            catch { return(false); }
            System.Threading.Thread.Sleep(1000);
            return(true);
        }
Esempio n. 13
0
    /// Windows C# Sample Console Application: Dome
    ///
    /// ------------------------------------------------------------------------
    ///               Adapted from Dome.vbs  (Visual Basic Script)
    ///               Copyright (C) Software Bisque (2013)
    ///
    ///				Converted 2017, R.McAlister
    ///
    /// ------------------------------------------------------------------------
    ///
    /// This C# console application demonstrates how to access dome control.
    ///
    ///  Note:  The Dome add-on was not available for testing this script. Use at your own risk.
    ///

    public void DomeSample()
    {
        ///Create the dome object, connect and get it///s targeting
        sky6Dome tsx_do = new sky6Dome();

        tsx_do.Connect();
        tsx_do.GetAzEl();

        double DomeAz = tsx_do.dAz;
        double DomeEl = tsx_do.dEl;

        MessageBox.Show("Dome Azimuth at: " + DomeAz.ToString() + "  Dome Elevation at: " + DomeEl.ToString());
        MessageBox.Show("Moving to Azimuth 0 degrees, Elevation 0 Degrees.");

        ///Target the dome at az = 0, alt = 0
        tsx_do.GotoAzEl(0, 0);

        ///Disconnect the dome
        tsx_do.Disconnect();

        return;
    }
Esempio n. 14
0
        public static bool CloseDome(int domeHomeAz)
        {
            //Method for closing the TSX dome
            // use exception handlers to check for dome commands, opt out if none
            //Park Mount, if not parked already
            sky6RASCOMTele tsxt = new sky6RASCOMTele();

            //Connect dome and decouple the dome from the mount position
            IsDomeCoupled = false;
            //Disconnect the mount
            tsxt.Disconnect();

            sky6Dome tsxd = new sky6Dome();

            try { tsxd.Connect(); }
            catch { return(false); }
            //Stop whatever the dome is doing, if any and wait a few seconds for it to clear
            try { tsxd.Abort(); }
            catch { }
            //Goto home position using goto rather than home
            ReliableGoTo(domeHomeAz);
            tsxd.CloseSlit();
            System.Threading.Thread.Sleep(10); // Release task thread so TSX can start Close Slit -- Command in Progress exception otherwise
            while (tsxd.IsCloseComplete == 0)
            {
                System.Threading.Thread.Sleep(1000);
            }
            //Check to see if slit got closed, if not, then try one more time
            //if (tsxd.SlitState() != SlitState.Closed)
            //{
            //    tsxd.CloseSlit();
            //    System.Threading.Thread.Sleep(1); // Release task thread so TSX can start FindHome -- Command in Progress exception otherwise
            //    while (tsxd.IsCloseComplete == 0) { System.Threading.Thread.Sleep(1000); }
            //}
            //disconnect dome controller
            tsxd.Disconnect();
            return(true);
        }
Esempio n. 15
0
        //Find the coordinates of the object galaxyName and perform a slew, then CLS to it.
        private bool SeekGalaxy()
        {
            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(freshImageName);

            // Perform slew to new location before starting CLS -- TSX does not wait for dome rotation.
            tsx_obj.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000);
            double tRA = tsx_obj.ObjInfoPropOut;

            tsx_obj.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000);
            double tDec = tsx_obj.ObjInfoPropOut;;

            //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 ss_cfg  = new Configuration();
            bool          hasDome = Convert.ToBoolean(ss_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");
            //Now try the CLS, but if an Error 123 is thrown, keep trying
            //  every five seconds until the dome slew catches up.
            //int clsStatus = 123;
            //while (clsStatus == 123)
            //{
            //    try { clsStatus = tsx_cl.exec(); }
            //    catch (Exception ex)
            //    {
            //        clsStatus = ex.HResult - 1000;
            //        LogEntry("CLS Error: " + ex.Message);
            //    };
            //}
            DeviceControl dctl      = new DeviceControl();
            int           clsStatus = dctl.ReliableClosedLoopSlew(tRA, tDec, freshImageName, hasDome);

            LogEntry("Precision Slew Complete:  ");
            if (clsStatus == 0)
            {
                LogEntry("    CLS successful");
                return(true);
            }
            else
            {
                LogEntry("    CLS unsucessful: Error: " + clsStatus.ToString());
                return(false);
            }
        }
Esempio n. 16
0
        public static bool CLSToTarget(string tgtName, SpeedVector sv, bool IsPrecision = false)
        {
            //first, couple dome to telescope, if there is one
            sky6Dome tsxd = new sky6Dome();

            try
            {
                tsxd.Connect();
                tsxd.IsCoupled = 1;
            }
            catch (Exception ex)
            {
                //do nothing
            }

            int            clsStatus = 123;
            sky6RASCOMTele tsxmt     = new sky6RASCOMTele();
            ClosedLoopSlew tsx_cl    = new ClosedLoopSlew();
            sky6StarChart  tsxsc     = new sky6StarChart();
            sky6Utils      tsxu      = new sky6Utils();
            //Check to see if target is above horizon
            double tgtRAH  = Transform.DegreesToHours(sv.RA_Degrees);
            double tgtDecD = sv.Dec_Degrees;

            tsxu.ConvertRADecToAzAlt(tgtRAH, tgtDecD);
            double tgtAzmD = tsxu.dOut0;
            double tgtAltD = tsxu.dOut1;

            if (tgtAltD <= 0)
            {
                MessageBox.Show("Slew failure: Target is below the horizon");
                return(false);
            }
            //Clear any image reduction, otherwise full reduction might cause a problem
            ccdsoftCamera tsxcam = new ccdsoftCamera()
            {
                ImageReduction = ccdsoftImageReduction.cdNone,
                Asynchronous   = 1 //make sure nothing else happens while setting this up
            };

            //Abort any ongoing imaging
            tsxcam.Abort();

            bool returnStatus = true;
            // diagnostic
            string strRA  = Utils.HourString(tgtRAH, false);
            string strDec = Utils.DegreeString(tgtDecD, false);

            //
            tsxsc.Find(tgtRAH.ToString() + ", " + tgtDecD.ToString());
            tsxmt.Connect();
            tsxu.Precess2000ToNow(tgtRAH, tgtDecD);
            double jnRAH  = tsxu.dOut0;
            double jnDecD = tsxu.dOut1;

            //tsxmt.Asynchronous = 0;
            try
            {
                tsxmt.SlewToRaDec(jnRAH, jnDecD, tgtName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Slew Failure: " + ex.Message);
                returnStatus = false;
            }
            if (IsPrecision && returnStatus)
            {
                //***  precision slew
                try
                {
                    clsStatus = tsx_cl.exec();
                }
                catch (Exception ex)
                {
                    returnStatus = false;
                }
            }
            try
            {
                tsxsc.Find(tgtName);
            }
            catch (Exception ex)
            {
                returnStatus = true;
            }
            return(returnStatus);
        }
Esempio n. 17
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);
            }
        }
Esempio n. 18
0
        /// <summary>
        /// Closes the dome slit and disconnects by
        /// decoupling the dome slews from the mount
        /// then slewing the dome to home to align power strips
        /// then closing the dome slit, leaving the dome control disconnected
        /// </summary>
        /// <param name="domeHomeAz">Azimuth of home position of dome</param>
        public static void CloseDome()
        {
            //Method for closing the TSX dome
            // use exception handlers to check for dome commands, opt out if none
            //Park Mount, if not parked already
            sky6RASCOMTele tsxt = new sky6RASCOMTele();

            //Decouple the dome from the mount position
            IsDomeCoupled = false;
            //Disconnect the mount
            tsxt.Disconnect();

            sky6Dome tsxd = new sky6Dome();

            try { tsxd.Connect(); }
            catch { return; }
            //Stop whatever the dome is doing, if any and wait a few seconds for it to clear
            try { tsxd.Abort(); }
            catch { return; }
            //Wait for a second for the command to clear
            System.Threading.Thread.Sleep(5000);
            //Close up the dome:  Connect, Home (so power is to the dome), Close the slit
            if (tsxd.IsConnected == 1)
            {
                //Move the dome to 20 degrees short of home
                tsxd.FindHome();
                System.Threading.Thread.Sleep(1000);
                while (tsxd.IsFindHomeComplete == 0)
                {
                    System.Threading.Thread.Sleep(5000);
                }
                ;
                System.Threading.Thread.Sleep(6000);
                //Close slit
                //Standard false stop avoidance code
                bool slitClosed = false;
                try
                {
                    tsxd.CloseSlit();
                    System.Threading.Thread.Sleep(10000);
                    while (tsxd.IsCloseComplete == 0)
                    {
                        System.Threading.Thread.Sleep(5000);
                    }
                    //Report success
                    slitClosed = true;
                }
                catch
                {
                    slitClosed = false;
                }

                //Check to see if slit got closed, if not, then try one more time
                if (!slitClosed)
                {
                    tsxd.CloseSlit();
                    System.Threading.Thread.Sleep(10000);
                    try
                    {
                        while (tsxd.IsCloseComplete == 0)
                        {
                            System.Threading.Thread.Sleep(5000);
                        }
                        //Report success
                    }
                    catch
                    {
                    }
                }
            }
            //disconnect dome controller
            tsxd.Disconnect();
        }