public bool AxisCanMoveAtRate(TelescopeAxes axis, double rate) { bool ret = false; Slewers.Type otherSlewer = (axis == TelescopeAxes.axisPrimary) ? Slewers.Type.Dec : Slewers.Type.Ra; if (!WiseTele.Instance.slewers.Active(otherSlewer)) { return(true); // the other axis has finished its slew, this axis can use any rate } if (rate == Const.rateSlew) { ret = (Interlocked.Read(ref primaryReadyForSlew) == Interlocked.Read(ref secondaryReadyForSlew)); } else if (rate == Const.rateSet) { ret = (Interlocked.Read(ref primaryReadyForSet) == Interlocked.Read(ref secondaryReadyForSet)); } else if (rate == Const.rateGuide) { ret = (Interlocked.Read(ref primaryReadyForGuide) == Interlocked.Read(ref secondaryReadyForGuide)); } #region debug //debugger.WriteLine(Debugger.DebugLevel.DebugAxes, "AxisCanMoveAtRate: {0} at {1} => {2}", // axis, WiseTele.RateName(rate), ret); #endregion return(ret); }
public bool Active(Slewers.Type type) { bool ret = false; lock (_lock) foreach (var a in _active) { if (a.type == type) { ret = true; break; } } return(ret); }
public bool Delete(Slewers.Type type) { string before; lock (_lock) { before = ToString(); int index = _active.FindIndex((s) => s.type == type); if (index == -1) { #region debug debugger.WriteLine(Debugger.DebugLevel.DebugLogic, "ActiveSlewers: Could not find a slewer of type {0} in _active", type.ToString()); #endregion return(false); } _active.RemoveAt(index); if (_active.Count == 0) { activityMonitor.EndActivity(ActivityMonitor.ActivityType.TelescopeSlew, new Activity.TelescopeSlewActivity.EndParams() { endState = Activity.State.Succeeded, endReason = "Reached target", end = new Activity.TelescopeSlewActivity.Coords { ra = WiseTele.Instance.RightAscension, dec = WiseTele.Instance.Declination, } }); } } #region debug debugger.WriteLine(Common.Debugger.DebugLevel.DebugAxes, "ActiveSlewers: deleted {0}, \"{1}\" => \"{2}\" ({3})", type.ToString(), before, this.ToString(), _active.GetHashCode()); #endregion return(true); }