public static sky6ObjectInformation GetStars() { //Runs the database query and checks results. objecty information false // else returns null sky6DataWizard tsx_dw = new sky6DataWizard(); sky6ObjectInformation tsx_oi = new sky6ObjectInformation(); ///Set query path tsx_dw.Path = StarSearchDBQPath; tsx_dw.Open(); string tst = tsx_dw.Path; try { tsx_oi = tsx_dw.RunQuery; } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } if (tsx_oi.Count == 0) { return(null); } else { return(tsx_oi); } }
/// Windows C# Sample Console Application: DataWizard /// /// ------------------------------------------------------------------------ /// /// Authored: R.McAlister 2017 /// /// /// ------------------------------------------------------------------------ /// ///This C# console application demonstrates the usage of the Data Wizard and Object Information classes. /// ///The application opens and runs a built-in Observing List search then accesses a few of the return properties, /// for no particularly good reason. /// ///The application uses the standard query "Bright objects visible now.dbq" /// public void DataWizardSample() { string sname = ""; string sRA; string sDec; ///Create object information and datawizard objects sky6DataWizard tsx_dw = new sky6DataWizard(); sky6ObjectInformation tsx_oi = new sky6ObjectInformation(); ///Set query path to a user-defined test query database for this example. If you don///t have it, make it. Best if the Messier catalog is selected. tsx_dw.Path = "C:\\Users\\Rick\\Documents\\Software Bisque\\TheSkyX Professional Edition\\Database Queries\\Bright objects visible now.dbq"; tsx_dw.Open(); tsx_oi = tsx_dw.RunQuery; /// ///tsx_oi is an array (tsx_oi.Count) of object information indexed by the tsx_oi.Index property /// ///For each object information in the list, get the name, perform a "Find" and look for the catalog ID. If there is one, print it. for (int i = 0; i <= (tsx_oi.Count - 1); i++) { tsx_oi.Index = i; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); sname = tsx_oi.ObjInfoPropOut; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); sRA = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); sDec = tsx_oi.ObjInfoPropOut.ToString(); MessageBox.Show("Name: " + sname + " RA: " + sRA + " Dec: " + sDec); } return; }
public ObjectList() { //Create the object list //Need to make this a bunch more robust later, including installing search database file, if not already installed // //Determine if search database file exists, if not, create it if (!DBQFileManagement.DBQInstalled()) { DBQFileManagement.InstallDBQ(); } sky6DataWizard tsxdw = new sky6DataWizard(); tsxdw.Path = DBQFileManagement.QuickPickDestinationPath; System.Threading.Thread.Sleep(1000); string testw1 = tsxdw.Path; System.Threading.Thread.Sleep(100); string testw2 = tsxdw.Path; tsxdw.Open(); //sky6ObjectInformation tsxoi = new sky6ObjectInformation(); sky6ObjectInformation tsxoi = tsxdw.RunQuery; //Fill in data arrays (for speed purposes) for (int i = 0; i < tsxoi.Count; i++) { tsxoi.Index = i; tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); oname = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_OBJECTTYPE); otype = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS); osize = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME); orise = (DateTime.Now - DateTime.Now.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME); oset = (DateTime.Now - DateTime.Now.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT); oaltitude = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_AZM); oazimuth = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); oDec = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); oRA = (tsxoi.ObjInfoPropOut); dbqList.Add(new DBQObject(oname, otype, osize, oset, orise, oaltitude, oazimuth, oDec, oRA)); } return; }
public StarProspects(double searchAreaDeg) { //Creates a list of star prospects from the associated observing list //Set StarChart FOV to something reasonable for this search sky6StarChart tsxsc = new sky6StarChart { FieldOfView = searchAreaDeg }; //Determine if search database file exists, if not, create it //if (!IsDBQInstalled()) //{ InstallDBQ(); } //Load the path, open and run the selected search database query sky6DataWizard tsxdw = new sky6DataWizard(); tsxdw.Path = GetDBQPath(); tsxdw.Open(); sky6ObjectInformation tsxoi = tsxdw.RunQuery; //Create a star list array for population of data //Fill in data arrays (for speed purposes) for (int i = 0; i < tsxoi.Count; i++) { tsxoi.Index = i; tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); string starName = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); double starRA = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); double starDec = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG); double starMag = (tsxoi.ObjInfoPropOut); DBQStar newStar = new DBQStar { StarName = starName, StarRA = starRA, StarDec = starDec, StarMag = starMag }; starProspectList.Add(newStar); } return; }
double MinGalAlt = 30; //Minimum altitude will default to 30 degrees if not set public GalaxyList() //Upon instantiation... //Open empty working XML file for galaxy list //Create connection to TSX DataWizard //Get the path to the query files, then set the path to SuperScanQuery.sdb //Run the DataWizard //Create an XML datastructure for the Observing List and load it with Observing LIst entries //Replace the current working Galaxy List file with the new XML data list //Close the file { string gname = ""; string gRA; string gDec; string gMag; string gMajorAxis; string gMinorAxis; string gAltitude; string gHA; string gSide; XElement gXgalaxies = new XElement("TargetGalaxies"); XElement gXrec; Configuration ss_cfg = new Configuration(); //if targets are to be refreshed, then run a new observing list query and save the results in the gXgalaxies XML list if (Convert.ToBoolean(ss_cfg.RefreshTargets)) { ///Create object information and datawizard objects sky6DataWizard tsx_dw = new sky6DataWizard(); ///Set query path tsx_dw.Path = ss_cfg.QueryPath; tsx_dw.Open(); string tst = tsx_dw.Path; sky6ObjectInformation tsx_oi = new sky6ObjectInformation(); tsx_oi = tsx_dw.RunQuery; /// ///tsx_oi is an array (tsx_oi.Count) of object information indexed by the tsx_oi.Index property /// ///For each object information in the list, get the name, perform a "Find" and look for the catalog ID. If there is one, print it. for (int i = 0; i <= (tsx_oi.Count - 1); i++) { tsx_oi.Index = i; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); gname = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); gRA = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); gDec = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG); gMag = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS); gMajorAxis = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MIN_AXIS_MINS); gMinorAxis = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT); gAltitude = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_HA_HOURS); gHA = tsx_oi.ObjInfoPropOut.ToString(); if (System.Convert.ToDouble(gHA) < 0) { gSide = "East"; } else { gSide = "West"; }; gXrec = new XElement("Galaxy", new XElement("Name", gname), new XElement("RA", gRA), new XElement("Dec", gDec), new XElement("Magnitude", gMag), new XElement("MajorAxis", gMajorAxis), new XElement("MinorAxis", gMinorAxis), new XElement("Altitude", gAltitude), new XElement("HA", gHA), new XElement("Side", gSide)); //check for galaxy size, if less than the configured minimum, then discard if (Convert.ToDouble(gMajorAxis) >= Convert.ToDouble(ss_cfg.MinGalaxySize)) { gXgalaxies.Add(gXrec); } } gXgalaxies.Save(ss_cfg.GalaxyListPath); return; } else { //List is not to be refreshed. Look for the "SuperScanObservingList" in the SuperScan directory. // if one, then parse it into an XML tree if (File.Exists(ss_cfg.ObservingListPath)) { ObservingListLoader oLoad = new ObservingListLoader(ss_cfg.ObservingListPath); XElement oListX = oLoad.TSXtoXML(); //The XML doc may or may not have all the galaxy information that we need, so use the Find function to go through the //targets and capture all the information TheSky64Lib.sky6StarChart tsxsc = new sky6StarChart(); sky6ObjectInformation tsx_oi = new sky6ObjectInformation(); foreach (XElement galaxyXList in oListX.Elements("target")) { string gName = galaxyXList.Element("name").Value; tsxsc.Find(gName); tsx_oi.Index = 0; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); gname = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); gRA = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); gDec = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAG); gMag = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS); gMajorAxis = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MIN_AXIS_MINS); gMinorAxis = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALT); gAltitude = tsx_oi.ObjInfoPropOut.ToString(); tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_HA_HOURS); gHA = tsx_oi.ObjInfoPropOut.ToString(); if (System.Convert.ToDouble(gHA) < 0) { gSide = "East"; } else { gSide = "West"; }; gXrec = new XElement("Galaxy", new XElement("Name", gname), new XElement("RA", gRA), new XElement("Dec", gDec), new XElement("Magnitude", gMag), new XElement("MajorAxis", gMajorAxis), new XElement("MinorAxis", gMinorAxis), new XElement("Altitude", gAltitude), new XElement("HA", gHA), new XElement("Side", gSide)); //check for galaxy size, if less than the configured minimum, then discard if (Convert.ToDouble(gMajorAxis) >= Convert.ToDouble(ss_cfg.MinGalaxySize)) { gXgalaxies.Add(gXrec); } } gXgalaxies.Save(ss_cfg.GalaxyListPath); } } }
public static string TargetStarSearch() { //Upon instantiation... //Open empty working XML file for Star list //Create connection to TSX DataWizard //Get the path to the query files, then set the path to SuperScanQuery.sdb //Run the DataWizard //Create an XML datastructure for the Observing List and load it with Observing LIst entries //Replace the current working Star List file with the new XML data list //Close the file string gName; double gRA; double gDec; //Locate current position on star chart and set FOV to 3 degrees sky6StarChart tsxsc = new sky6StarChart(); double centerRA = tsxsc.RightAscension; double centerDec = tsxsc.Declination; tsxsc.FieldOfView = 3.0; //Look for closest member of list //Note the Hour Angle should always be greater than zero // and the search area witin 3 degrees of the center of the chart // Also only uses HIP stars because "Find" doesn't work on all names, like Tycho double bestSeparation = 100.0; double tSeparation; TargetRA = centerRA; TargetDec = centerDec; sky6ObjectInformation tsx_oi = new sky6ObjectInformation(); do { //tsx_oi = GetStars(); // will return null if null tsx_oi (including exception thrown) or count = 0; //Runs the database query and checks results. objecty information false // else returns null sky6DataWizard tsx_dw = new sky6DataWizard(); ///Set query path tsx_dw.Path = StarSearchDBQPath; tsx_dw.Open(); string tst = tsx_dw.Path; try { tsx_oi = tsx_dw.RunQuery; } catch (Exception ex) { MessageBox.Show(ex.Message); return(null); } if (tsx_oi.Count == 0) { return(null); } // // if (tsx_oi == null) { MessageBox.Show("Waiting half a minute for a better target star"); System.Threading.Thread.Sleep(30000); //sleep for thirty seconds then try again } } while (tsx_oi == null); int oiCount = tsx_oi.Count; for (int i = 0; i < oiCount; i++) { tsx_oi.Index = i; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); gName = (string)tsx_oi.ObjInfoPropOut; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); gRA = (double)tsx_oi.ObjInfoPropOut; tsx_oi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); gDec = (double)tsx_oi.ObjInfoPropOut; if (gName.Contains("HIP")) { tSeparation = ComputeDistance(centerRA, centerDec, gRA, gDec); if (tSeparation < bestSeparation) { bestSeparation = tSeparation; TargetName = gName; TargetRA = gRA; TargetDec = gDec; } } } tsxsc.Find(TargetName); return(TargetName); }
public ObjectList(DBQFileManagement.SearchType searchDB, DateTime duskDateLocal, DateTime dawnDateLocal) { //Determine if search database file exists, if not, create it if (!DBQFileManagement.DBQsInstalled()) { DBQFileManagement.InstallDBQs(); } //Load the path to the selected search database query sky6DataWizard tsxdw = new sky6DataWizard(); tsxdw.Path = DBQFileManagement.GetDBQPath(searchDB); //Set the search date for the dusk query sky6StarChart tsxs = new sky6StarChart(); tsxs.DocumentProperty(Sk6DocumentProperty.sk6DocProp_Latitude); oLat = tsxs.DocPropOut; tsxs.DocumentProperty(Sk6DocumentProperty.sk6DocProp_Longitude); oLong = tsxs.DocPropOut; double jdate = Celestial.DateToJulian(duskDateLocal.ToUniversalTime()); tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, jdate); tsxdw.Open(); //sky6ObjectInformation tsxoi = new sky6ObjectInformation(); sky6ObjectInformation tsxoi = tsxdw.RunQuery; //Fill in data arrays (for speed purposes) int tgtcount = tsxoi.Count; for (int i = 0; i < tgtcount; i++) { tsxoi.Index = i; //tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_ALL_INFO); //var AllInfo = tsxoi.ObjInfoPropOut; tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); oname = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_OBJECTTYPE); otype = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS); osize = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME); orise = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME); oset = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); oDec = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); oRA = (tsxoi.ObjInfoPropOut); //compute the duration oduration = Celestial.IntervalOverlap(duskDateLocal, dawnDateLocal, orise, oset); //compute the maximum altitude omaxaltitude = ComputeMaxAltitude(duskDateLocal, dawnDateLocal, oRA, oDec, oLat, oLong); // if the duration is greater than zero, then add it if (oduration > 0) { dbqList.Add(new DBQObject(oname, otype, osize, oset, orise, oDec, oRA, oLat, oLong, oduration, omaxaltitude)); } } //Note that all these entries should have at least some duration //Set the search date for the dawn query jdate = Celestial.DateToJulian(dawnDateLocal.ToUniversalTime()); tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_JulianDateNow, jdate); tsxdw.Open(); tsxoi = tsxdw.RunQuery; //check each entry to see if it is already in the dusk list // if so, just ignor, if not get the resf of the info and add it for (int i = 0; i < tsxoi.Count; i++) { tsxoi.Index = i; tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_NAME1); oname = (tsxoi.ObjInfoPropOut); bool newEntry = true; foreach (DBQObject tgt in dbqList) { if (tgt.Name == oname) { newEntry = false; break; } } if (newEntry) { tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_OBJECTTYPE); otype = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_MAJ_AXIS_MINS); osize = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RISE_TIME); orise = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_SET_TIME); oset = (duskDateLocal - duskDateLocal.TimeOfDay).AddHours(tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_DEC_2000); oDec = (tsxoi.ObjInfoPropOut); tsxoi.Property(Sk6ObjectInformationProperty.sk6ObjInfoProp_RA_2000); oRA = (tsxoi.ObjInfoPropOut); //compute the duration oduration = Celestial.IntervalOverlap(duskDateLocal, dawnDateLocal, orise, oset); //compute the maximum altitude omaxaltitude = ComputeMaxAltitude(duskDateLocal, dawnDateLocal, oRA, oDec, oLat, oLong); // if the duration is greater than zero, then add it if (oduration > 0) { dbqList.Add(new DBQObject(oname, otype, osize, oset, orise, oDec, oRA, oLat, oLong, oduration, omaxaltitude)); } } } //Now clear out all the entries that have no duration between //Reset tsx to computer clock tsxs.SetDocumentProperty(Sk6DocumentProperty.sk6DocProp_UseComputerClock, 1); tsxs = null; tsxoi = null; return; }