/// Windows C# Sample Console Application: ClosedLoopSlew /// /// ------------------------------------------------------------------------ /// /// Author: R.McAlister (2017) /// /// ------------------------------------------------------------------------ /// /// ClosedLoopSlew: Find a target (M39 in this case), then execute a closed loop slew to it /// /// public void CLSSample() { ///Set connection to star chart and perform a find on M39 sky6StarChart tsx_sc = new sky6StarChart(); tsx_sc.Find("M39"); ///Create connection to camera and connect ccdsoftCamera tsx_cc = new ccdsoftCamera(); tsx_cc.Connect(); ///Create closed loop slew object ClosedLoopSlew tsx_cls = new ClosedLoopSlew(); ///Set the exposure, filter to luminance and reduction, set the camera delay to 0 -- backlash /// should be picked up in the mount driver tsx_cc.ImageReduction = ccdsoftImageReduction.cdAutoDark; tsx_cc.FilterIndexZeroBased = 3; ///Luminance tsx_cc.ExposureTime = 10; tsx_cc.Delay = 0; ///Execute try { int clsstat = tsx_cls.exec(); } catch { ///Just close up: TSX will spawn error window MessageBox.Show("Closed Loop Slew failure"); }; return; }
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); }
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); }
public int ReliableClosedLoopSlew(double RA, double Dec, string name, bool hasDome) { //Tries to perform CLS without running into dome tracking race condition // //First set camera to AutoDark ccdsoftCamera tsxc = new ccdsoftCamera(); tsxc.ImageReduction = ccdsoftImageReduction.cdAutoDark; ReliableRADecSlew(RA, Dec, name, hasDome); ClosedLoopSlew tsx_cl = new ClosedLoopSlew(); int clsStatus = 123; //If dome, Turn off tracking if (hasDome) { DomeCouplingOff(); while (clsStatus == 123) { try { clsStatus = tsx_cl.exec(); } catch (Exception ex) { clsStatus = ex.HResult - 1000; }; if (clsStatus == 123) { System.Threading.Thread.Sleep(500); } } DomeCouplingOn(); } else { try { clsStatus = tsx_cl.exec(); } catch (Exception ex) { clsStatus = ex.HResult - 1000; }; } return(clsStatus); }
//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); } }
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); }
/// Windows C# Sample Console Application: AutoGuide /// /// ------------------------------------------------------------------------ /// /// Author: R.McAlister (2017) /// /// ------------------------------------------------------------------------ /// /// This application performs the following steps: /// Finds a target, M39 in this case /// Turns off Autoguiding (if on) /// Performs a Closed Loop Slew to the target /// Takes an image with the Autoguide camera /// Turns on Autoguiding /// /// public void AutoGuideSample() { ///Set connection to star chart and perform a find on M39 -- this will set the target for a CLS sky6StarChart tsx_sc = new sky6StarChart(); tsx_sc.Find("M39"); ///Create connection to autoguide camera and connect ccdsoftCamera tsx_ag = new ccdsoftCamera(); ///Attach this object to the guider camera tsx_ag.Autoguider = 1; ///Find out with the guide camera is up to. Abort if autoguiding or calibrating if (tsx_ag.Connect() == 0) { if ((tsx_ag.State == ccdsoftCameraState.cdStateAutoGuide) | (tsx_ag.State == ccdsoftCameraState.cdStateCalibrate)) { tsx_ag.Abort(); } ; } ; ///Create closed loop slew object ClosedLoopSlew tsx_cls = new ClosedLoopSlew(); ///Set the exposure, filter to luminance and reduction, set the camera delay to 0 -- backlash /// should be picked up in the mount driver ccdsoftCamera tsx_cc = new ccdsoftCamera(); tsx_cc.ImageReduction = ccdsoftImageReduction.cdAutoDark; tsx_cc.FilterIndexZeroBased = 3; ///Luminance tsx_cc.ExposureTime = 10; tsx_cc.Delay = 0; ///run CLS synchronously ///tsx_cls.Asynchronous = False ///-- this setting doesn///t appear to work (member not found) as of DB8458 ///Execute try { int clsstat = tsx_cls.exec(); } catch { ///Just close up: TSX will spawn error window MessageBox.Show("Closed Loop Slew error"); return; ///Let it go for demo purposes }; ///Connect AutoGuide camera in case it isn///t try { tsx_ag.Connect(); } catch { MessageBox.Show("Guide camera connect error"); return; }; ///Take an image to use for Autoguiding, run the function synchronously tsx_ag.ExposureTime = 2; tsx_ag.Asynchronous = 0; tsx_ag.Subframe = 0; var tstat = tsx_ag.TakeImage(); ///Just assume it works ///Turn asynchronous back on to get out of this tsx_ag.Asynchronous = 1; ///Fire off Autoguiding tsx_ag.Autoguide(); return; }
//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: 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; }