Example #1
0
        static bool SlewToPosition(double starRA, double starDec)
        {
            //Moves the mount to center the calibration star in the guider FOV
            //Async slew to target (letting dome catch up), then CLS to align (does not coordinate with dome)
            //
            sky6RASCOMTele tsxm = new sky6RASCOMTele
            {
                Asynchronous = 0
            };

            if (tsxm.IsConnected == 0)
            {
                tsxm.Connect();
            }
            tsxm.SlewToRaDec(starRA, starDec, "Target Position");

            sky6StarChart  tsxsc     = new sky6StarChart();
            string         RADecname = starRA.ToString() + "," + starDec.ToString();
            ClosedLoopSlew tsxcls    = new ClosedLoopSlew();

            tsxsc.Find(RADecname);
            try
            { tsxcls.exec(); }
            catch (Exception ex)
            { return(false); }
            return(true);
        }
Example #2
0
        /// <summary>
        /// TelescopePrePosition(side)
        /// Directs the mount to point either to the "East" or "West" side of the
        /// meridian at a location of 80 degrees altitude.  Used for autofocus routine
        /// and for starting off the target search
        /// </summary>
        /// <param name="side"></param>
        public void TelescopePrePosition(string side)
        {
            sky6RASCOMTele tsxm = new sky6RASCOMTele();

            //DeviceControl dctl = new DeviceControl();
            tsxm.Asynchronous = 0;
            tsxm.Connect();
            //dctl.DomeTrackingOff();
            if (side == "East")
            {
                tsxm.SlewToAzAlt(90.0, 80.0, "");
                while (tsxm.IsSlewComplete == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            else
            {
                tsxm.SlewToAzAlt(270.0, 80.0, "");
                while (tsxm.IsSlewComplete == 0)
                {
                    System.Threading.Thread.Sleep(1000);
                }
            }
            //dctl.DomeTrackingOn();
            return;
        }
Example #3
0
        public void ReliableRADecSlew(double RA, double Dec, string name, bool hasDome)
        {
            //
            //Checks for dome tracking underway, waits half second if so -- doesn//t solve race condition, but may avoid
            sky6RASCOMTele tsxt = new sky6RASCOMTele();

            if (hasDome)
            {
                while (IsDomeTrackingUnderway())
                {
                    System.Threading.Thread.Sleep(500);
                }
                int result = -1;
                while (result != 0)
                {
                    result = 0;
                    try { tsxt.SlewToRaDec(RA, Dec, name); }
                    catch (Exception ex) { result = ex.HResult - 1000; }
                }
            }
            else
            {
                tsxt.SlewToRaDec(RA, Dec, name);
            }
            return;
        }
Example #4
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);
        }
Example #5
0
        public static bool SetTargetTracking(SpeedVector sv, double topo_Adjustment_RA, double topo_Adjustment_Dec)
        {
            const int ionTrackingOn  = 1;
            const int ionTrackingOff = 0;
            const int ignoreRates    = 1;
            const int useRates       = 0;

            double tgtRateRA     = sv.Rate_RA_CosDec_ArcsecPerMinute;
            double tgtRateDec    = sv.Rate_Dec_ArcsecPerMinute;
            double adjtgtRateRA  = tgtRateRA * topo_Adjustment_RA;
            double adjtgtRateDec = tgtRateDec * topo_Adjustment_Dec;

            sky6RASCOMTele tsxmt = new sky6RASCOMTele();

            tsxmt.Connect();
            //double dRA1 = tsxmt.dRaTrackingRate;
            //double dDec1 = tsxmt.dDecTrackingRate;
            try
            {
                //TSX expects tracking rates in arcsec/sec: convert it from arcsec/min
                tsxmt.SetTracking(ionTrackingOn, useRates, adjtgtRateRA / 60.0, adjtgtRateDec / 60.0);
            }
            catch
            {
                return(false);
            }
            //double dRA2 = tsxmt.dRaTrackingRate;
            //double dDec2 = tsxmt.dDecTrackingRate;
            return(true);
        }
Example #6
0
    /// Windows C# Sample Console Application: Solar
    ///
    /// ------------------------------------------------------------------------
    ///               Vaguely adapted from Solar.vbs
    ///               Copyright Software Bisque
    ///
    ///               Converted by:  R.McAlister 2017
    ///
    /// ------------------------------------------------------------------------
    ///
    ///Very simple demonstration application that targets the telescope on the Sun -- careful now.
    ///
    ///  Note:  this is basically simplification of "ListSearch.vb" where the only target is the Sun.
    ///
    ///


    public void SolarSample()
    {
        ///Target Sun
        string target = "Sun";

        ///Create Objects
        sky6StarChart         tsx_sc = new sky6StarChart();
        sky6RASCOMTele        tsx_ts = new sky6RASCOMTele();
        sky6ObjectInformation tsx_oi = new sky6ObjectInformation();

        ///Connect telescope
        tsx_ts.Connect();

        tsx_sc.Find(target);
        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT);
        double dAlt = tsx_oi.ObjInfoPropOut;

        tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_AZM);
        double dAz = tsx_oi.ObjInfoPropOut;

        try {
            tsx_ts.SlewToAzAlt(dAz, dAlt, target);
        }
        catch {
            MessageBox.Show("An error has occurred running slew");
            return;
        };
        MessageBox.Show("The Sun's location is at: Altitude: " + dAlt.ToString() + "  Azimuth: " + dAz.ToString());

        ///Disconnect telesope
        tsx_ts.Disconnect();
        return;
    }
Example #7
0
    /// Windows Visual Basic Sample Console Application: PierSide
    ///
    /// ------------------------------------------------------------------------
    ///               Original Example
    ///
    ///			    Developed 2015, R.McAlister
    ///			    Ported to C# 2017
    ///
    /// ------------------------------------------------------------------------
    ///
    /// This Visual Basic console application reads the pier side position of the current
    ///   telescope and shows the value.

    public void PierSideSample()
    {
        sky6RASCOMTele tsx_tele = new sky6RASCOMTele();

        tsx_tele.DoCommand(11, "");
        string pierstring = tsx_tele.DoCommandOutput;

        MessageBox.Show("Pier Side: " + pierstring);
        return;
    }
Example #8
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);
        }
Example #9
0
        public static (double, double) GetCurrentTelePosition()
        {
            sky6RASCOMTele tsxm = new sky6RASCOMTele();

            tsxm.GetRaDec();
            sky6Utils tsxu = new sky6Utils();

            tsxu.PrecessNowTo2000(tsxm.dRa, tsxm.dDec);
            return(tsxu.dOut0, tsxu.dOut1);
        }
Example #10
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");
        }
Example #11
0
    /// ********************************************************************************

    private void TargetLoop()
    {
        string szPathToMapFile = "C:\\Users\\Rick\\Documents\\Software Bisque\\TheSkyX Professional Edition\\Exported Data\\map.txt";

        ///Set the exposure time for the image
        double dExposure = 1.0;

        string LineFromFile;
        double dAz;
        double dAlt;

        //Connect to TSX TheSky and Uility methods
        sky6Utils        tsx_util = new sky6Utils();
        sky6RASCOMTheSky tsx_sky  = new sky6RASCOMTheSky();
        sky6RASCOMTele   tsx_tele = new sky6RASCOMTele();
        ccdsoftCamera    tsx_cam  = new ccdsoftCamera();

        ///Open the observing list export file for targets
        StreamReader MyFile = File.OpenText(szPathToMapFile); ///Stream object for Export Data text file

        ///Get the first line -- headers
        ///Exit if the file is empty
        if (MyFile.EndOfStream == true)
        {
            return;
        }
        ;
        LineFromFile = MyFile.ReadLine();

        int iRAindex  = LineFromFile.IndexOf("RA");
        int iDecindex = LineFromFile.IndexOf("Dec");

        while (MyFile.EndOfStream == false)
        {
            LineFromFile = MyFile.ReadLine();
            MessageBox.Show("RA: " + LineFromFile.Substring(iRAindex, 13) + "  Dec: " + LineFromFile.Substring(iDecindex, 13));

            string sname = LineFromFile.Substring((LineFromFile.Length - 12), 12);
            tsx_util.ConvertStringToRA(LineFromFile.Substring(iRAindex, 13));
            dAz = tsx_util.dOut0;
            tsx_util.ConvertStringToDec(LineFromFile.Substring(iDecindex, 13));
            dAlt = tsx_util.dOut0;

            ///Slew to object
            tsx_tele.SlewToAzAlt(dAz, dAlt, sname);

            ///Set exposure time and try { for image, exit if error
            tsx_cam.ExposureTime = dExposure;
            tsx_cam.TakeImage();
            ///Add to T-point Model
            tsx_sky.AutoMap();
        }
        ;   //Loop
    }
Example #12
0
        public bool TelescopeShutDown()
        //Method for connecting and parking the TSX mount
        {
            sky6RASCOMTele tsxm = new sky6RASCOMTele();

            if (tsxm.IsConnected == 0)
            {
                tsxm.Connect();
            }
            try { tsxm.Park(); }
            catch (Exception ex) { return(false); }
            return(true);
        }
Example #13
0
        public static bool SlewToTarget(string tgtName, SpeedVector sv)
        {
            sky6RASCOMTele tsxmt   = new sky6RASCOMTele();
            double         tgtRAH  = Transform.DegreesToHours(sv.RA_Degrees);
            double         tgtDecD = sv.Dec_Degrees;

            tsxmt.Connect();
            try
            {
                tsxmt.SlewToRaDec(tgtRAH, tgtDecD, tgtName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Slew Failed: " + ex.Message);
                return(false);
            }
            return(true);
        }
Example #14
0
        public bool CLSToTarget(SpeedVector sv)
        {
            int            clsStatus = 123;
            sky6RASCOMTele tsxmt     = new sky6RASCOMTele();
            ClosedLoopSlew tsx_cl    = new ClosedLoopSlew();
            sky6StarChart  tsxsc     = new sky6StarChart();
            //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();

            double tgtRAH  = Transform.DegreesToHours(sv.RA_Degrees - RA_CorrectionD);
            double tgtDecD = sv.Dec_Degrees - Dec_CorrectionD;

            tsxsc.Find(tgtRAH.ToString() + ", " + tgtDecD.ToString());
            tsxmt.Connect();
            try
            {
                tsxmt.SlewToRaDec(tgtRAH, tgtDecD, TgtName);
            }
            catch (Exception ex)
            {
                MessageBox.Show("Slew to target failed: " + ex.Message);
                return(false);
            }
            //********** CLS AVOIDANCE CODE FOR SIMULATOR DEBUGGING PURPOSES
            //tsxsc.Find(TgtName);
            //return true;
            //*********************
            try
            { clsStatus = tsx_cl.exec(); }
            catch (Exception ex)
            {
                tsxsc.Find(TgtName);
                return(false);
            }
            tsxsc.Find(TgtName);
            return(true);
        }
Example #15
0
        /// <summary>
        /// TelescopePrePosition(side)
        /// Directs the mount to point either to the "East" or "West" side of the
        /// meridian at a location of 80 degrees altitude.  Used for autofocus routine
        /// and for starting off the galaxy search
        /// </summary>
        /// <param name="side"></param>
        public void TelescopePrePosition(string side)
        {
            sky6RASCOMTele tsxm = new sky6RASCOMTele();

            //DeviceControl dctl = new DeviceControl();
            tsxm.Asynchronous = 0;
            tsxm.Connect();
            //dctl.DomeTrackingOff();
            if (side == "East")
            {
                tsxm.SlewToAzAlt(90.0, 80.0, "");
            }
            else
            {
                tsxm.SlewToAzAlt(270.0, 80.0, "");
            }
            //dctl.DomeTrackingOn();
            return;
        }
Example #16
0
        public bool TelescopeStartUp()
        {
            //Method for connecting and initializing the TSX mount
            sky6RASCOMTele tsxm = new sky6RASCOMTele();

            if (tsxm.IsConnected == 0)
            {
                tsxm.Connect();
            }
            //If parked, try to unpark, if fails return false
            try { if (tsxm.IsParked())
                  {
                      tsxm.Unpark();
                  }
            }
            catch (Exception ex) { return(false); }
            //Otherwise return true;
            return(true);
        }
Example #17
0
        public static bool SetStandardTracking()
        {
            const int ionTrackingOn  = 1;
            const int ionTrackingOff = 0;
            const int ignoreRates    = 1;
            const int useRates       = 1; //Don't use rates

            sky6RASCOMTele tsxmt = new sky6RASCOMTele();

            tsxmt.Connect();
            try
            {
                tsxmt.SetTracking(ionTrackingOn, useRates, 0, 0);
            }
            catch
            {
                return(false);
            }
            return(true);
        }
Example #18
0
    /// Windows C# Sample Console Application: Tele
    ///
    /// ------------------------------------------------------------------------
    ///               Adapted from Tele.vbs  (Visual Basic Script)
    ///               Copyright (C) Software Bisque (2009?)
    ///
    ///				Converted 2017, R.McAlister
    ///
    /// ------------------------------------------------------------------------
    ///
    /// This C# console application exercises the telescope class functions
    ///

    public void TeleSample()
    {
        ///Use TheSky to generate a text file of mapping points
        string szPathToMapFile = "C:\\Users\\Rick\\Documents\\Software Bisque\\TheSkyX Professional Edition\\Exported Data\\map.txt";

        ///Set the exposure time for the image
        double dExposure = 1.0;

        ;
        ///Create the telescope object
        sky6RASCOMTele tsx_ts = new sky6RASCOMTele();

        ///Connect to the telescope
        tsx_ts.Connect();

        ///See if connection failed
        if (tsx_ts.IsConnected == 0)
        {
            MessageBox.Show("Connection failed.");
            return;
        }

        ///Get and show the current telescope ra, dec
        tsx_ts.GetRaDec();
        MessageBox.Show("Ra,Dec =" + tsx_ts.dRa.ToString() + ",  " + tsx_ts.dDec.ToString());

        ///Get and show the current telescope az, alt
        tsx_ts.GetAzAlt();
        MessageBox.Show("Az,Alt=" + tsx_ts.dAz.ToString() + ",  " + tsx_ts.dAlt.ToString());

        ///Goto an arbitrary RA and Dec
        tsx_ts.SlewToRaDec(2.0, 3.0, "Home");
        MessageBox.Show("GotoComplete");

        ///Sync on an ra dec
        tsx_ts.Sync(3.0, 3.0, "Matt");

        ///Disconnect the telscope
        tsx_ts.Disconnect();
        return;
    }
    /// Windows C# Sample Console Application: StarChartSetWW
    ///
    /// ------------------------------------------------------------------------
    ///               Adapted from TheSkySetWW.vbs  (Visual Basic Script)
    ///               Copyright (C) Software Bisque (2009?)
    ///
    ///				Converted 2014, R.McAlister
    ///
    /// ------------------------------------------------------------------------
    ///
    /// This C# console application exercises the Star Chart class functions for setting
    ///   Timne, Time Zone, Location, etc.
    ///

    public void StarChartSetWWSample()
    {
        double dJD   = 2452066.0; ///=06/05/2001, ignored if UseCompterClock=1
        double dTZ   = 7;         ///MST
        double dElev = 1000;      ///meters
        double dLat  = 39.5;
        double dLong = 105.5;
        string szLoc = "Location from script";

        ///Create Telescope Object and disconnect telescope -- time changes are not enabled with scope connected
        sky6RASCOMTele tsx_ts = new sky6RASCOMTele();

        tsx_ts.Disconnect();

        ///Create the Star Chart object
        sky6StarChart tsx_sc = new sky6StarChart();

        ///Turn off the Computer Clock
        tsx_sc.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_UseComputerClock, 0);

        ///Change the julian date
        tsx_sc.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, dJD);

        ///Change the time zone
        tsx_sc.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_Time_Zone, dTZ);

        ///Change the elevation
        tsx_sc.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_ElevationInMeters, dElev);

        ///Change the latitude
        tsx_sc.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_Latitude, dLat);

        ///Change the longitude
        tsx_sc.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_Longitude, dLong);

        ///Change the location description
        tsx_sc.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_LocationDescription, szLoc);

        return;
    }
Example #20
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);
        }
Example #21
0
    public void AutomatedSearchSample()
    {
        /// ********************************************************************************
        /// *
        /// * Below is the flow of program execution
        /// * See the subroutine TargetLoop to see where the real work is done

        ///Create Objects

        sky6RASCOMTele tsx_tele = new sky6RASCOMTele();
        ccdsoftCamera  tsx_cam  = new ccdsoftCamera();

        ///Connect Objects
        try {
            tsx_tele.Connect();
        }
        catch {
            MessageBox.Show("Telescope Connect Error");
            return;;
        };

        try {
            tsx_cam.Connect();
        }
        catch {
            MessageBox.Show("Camera Connection Error");
            return;;
        }

        ///Run the target loop
        TargetLoop();

        ///Disconnect objects
        tsx_tele.Disconnect();
        tsx_cam.Disconnect();
    }
Example #22
0
        static bool SlewToStar(string starName, double starRA, double starDec)
        {
            //Moves the mount to center the calibration star in the guider FOV
            //Async slew to target (letting dome catch up), then CLS to align (does not coordinate with dome)
            //
            //First, convert RA and Dec to topocentric (Epoch now) as that is what the slew expects
            sky6Utils tsxu = new sky6Utils();

            tsxu.Precess2000ToNow(starRA, starDec);
            starRA  = tsxu.dOut0;
            starDec = tsxu.dOut1;
            sky6RASCOMTele tsxm = new sky6RASCOMTele
            {
                Asynchronous = 0
            };

            try
            {
                tsxm.SlewToRaDec(starRA, starDec, starName);
            }
            catch (Exception ex)
            { return(false); }
            return(true);
        }
Example #23
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);
        }
Example #24
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);
            }
        }
    /// Windows C# Sample Console Application: ListSearch
    ///
    /// ------------------------------------------------------------------------
    ///               Vaguely adapted from ErrorHandling.vbs  (Visual Basic Script)
    ///               Copyright (C) Software Bisque (2013)
    ///
    ///				Converted 2015, R.McAlister
    ///
    /// ------------------------------------------------------------------------
    ///
    /// This C# console application demonstrates how to run the telescope through a list of targets as defined
    ///   by a list of names.
    ///
    ///  Note:  The gist of the orginal VBS script was entitled "ErrorHandling.vbs".  However, that
    ///  script, however labeled, performed the functions as adapted to VB herein.
    ///


    public void ListSearchSample()
    {
        ///Set the exposure time for the image
        double dExposure = 1.0;

        ///Target List
        string[] targetlist = new string[] {
            "NGC1348",
            "NGC1491",
            "NGC1708",
            "NGC179",
            "NGC1798",
            "NGC2165",
            "NGC2334",
            "NGC2436",
            "NGC2519",
            "NGC2605",
            "NGC2689",
            "NGC2666",
            "NGC4381",
            "NGC5785",
            "NGC5804",
            "NGC6895",
            "NGC6991",
            "NGC7011",
            "NGC7058",
            "M39",
            "NGC7071",
            "NGC7150",
            "NGC7295",
            "NGC7394",
            "NGC7686",
            "NGC7801"
        };

        ///Create objects

        sky6StarChart         objChrt = new sky6StarChart();
        sky6RASCOMTele        objTele = new sky6RASCOMTele();
        ccdsoftCamera         objCam  = new ccdsoftCamera();
        sky6Utils             objUtil = new sky6Utils();
        sky6ObjectInformation objInfo = new sky6ObjectInformation();

        ///Connect Objects
        objTele.Connect();
        objCam.Connect();

        ///Run loop over array of target names
        double dAlt;
        double dAz;
        bool   iError;

        foreach (string target in targetlist)
        {
            objChrt.Find(target);
            objInfo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT);
            dAlt = objInfo.ObjInfoPropOut;
            objInfo.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_AZM);
            dAz = objInfo.ObjInfoPropOut;

            try
            {
                objTele.SlewToAzAlt(dAz, dAlt, target);
            }
            catch
            {
                MessageBox.Show("An error has occurred running slew");
                return;
            };

            ///Set exposure time and try for image, exit if error
            objCam.ExposureTime = dExposure;
            try
            {
                objCam.TakeImage();
            }
            catch
            {
                MessageBox.Show("An error has occurred running image");
            };
        }

        ///Disconnect telescope and camera
        objTele.Disconnect();
        objCam.Disconnect();
        return;
    }
Example #26
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;
    }
Example #27
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);
            }
        }
Example #28
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();
        }