public void UpdateTargetDate(TargetXDescriptor varTgt) { var newTgt = new XElement(TargetListRecordX, new XElement(NameX, varTgt.Name, new XElement(RAX, varTgt.RA.ToString()), new XElement(DecX, varTgt.Dec.ToString()), new XElement(FilterX, varTgt.Filter.ToString()), new XElement(LastDateX, varTgt.LastImagingDate.ToString()))); Configuration cfg = new Configuration(); //Load xml list and update data on target XElement acnL = XElement.Load(cfg.TargetListPath); acnL.Elements(TargetListRecordX).FirstOrDefault(t => ((string)t.Element(NameX) == varTgt.Name) && (string)t.Element(FilterX) == varTgt.Filter.ToString()).SetElementValue(LastDateX, DateTime.Now.ToString()); //acnT.Element(VariableTargetLastDateX).ReplaceWith(new XElement(VariableTargetLastDateX, DateTime.Now.ToString())); acnL.Save(cfg.TargetListPath); return; }
public TargetXDescriptor NextClosestTarget(double az, double alt) { //Sets the first target for the session at alt/az and gets the closest target sky6Utils tsxu = new sky6Utils(); tsxu.ConvertAzAltToRADec(az, alt); double ra = (double)tsxu.dOut0; double dec = (double)tsxu.dOut1; XElement bogusTargetX = new XElement(TargetListRecordX, new XElement(NameX, "Bogus"), new XElement(RAX, ra.ToString()), new XElement(DecX, dec.ToString()), new XElement(FilterX, "0"), new XElement(LastDateX, DateTime.Now)); TargetXDescriptor bogusTarget = new TargetXDescriptor(bogusTargetX); TargetXDescriptor firstTgt = NextClosestTarget(bogusTarget); return(firstTgt); }
public TargetXDescriptor NextClosestTarget(TargetXDescriptor lastTgt) { // Gets the next target for targeting // Based on finding the closest target to the last target // that is above the minimum altitude // Note that a target with a different filter is a separate entry // such that multiple filters can be taken on the same session. { //Set access to configuration information about minimum altitude Configuration cfg = new Configuration(); double minAlt = Convert.ToDouble(cfg.MinAltitude); double minRetake = Convert.ToDouble(cfg.MinRetakeInterval); DateTime lastTime = DateTime.Now; double minSeparation = 1000.0; foreach (XElement tDesc in targetListRecordX.Elements()) { TargetXDescriptor xTarget = new TargetXDescriptor(tDesc); if (lastTime.Date - xTarget.LastImagingDate.Date > TimeSpan.FromHours(minRetake)) { if (IsUp(xTarget.RA, xTarget.Dec, minAlt)) { double targetSeparation = TargetSeparation(lastTgt.RA, lastTgt.Dec, xTarget.RA, xTarget.Dec); if (targetSeparation < minSeparation) { lastTgt = xTarget; minSeparation = targetSeparation; } } } } ////By now, either we have a target name or not. Make sure the calling function checks for a null name. return(lastTgt); } }