//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"); }
/// 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; }