public async Task <bool> Sync(TelescopePosition position) { int deg, hour, min, sec; AsyncAutoResetEvent doneEvent = new AsyncAutoResetEvent(); bool success = false; FloatToHMS(Math.Abs(position.Declination), out deg, out min, out sec); string sign = position.Declination < 0 ? "-" : "+"; SendCommand($":Sd{sign}{deg:00}*{min:00}:{sec:00}#,n", (decResult) => { success = decResult.Success && decResult.Data == "1"; }); FloatToHMS(Math.Abs(position.RightAscension), out hour, out min, out sec); SendCommand($":Sr{hour:00}:{min:00}:{sec:00}#,n", (raResult) => { success = success && raResult.Success && raResult.Data == "1"; }); SendCommand($":CM#,#", (syncResult) => { success = success && syncResult.Success && syncResult.Data == "1"; doneEvent.Set(); }); await doneEvent.WaitAsync(); return(success); }
public async Task <bool> Slew(TelescopePosition position) { int deg, hour, min, sec; AsyncAutoResetEvent doneEvent = new AsyncAutoResetEvent(); bool success = false; FloatToHMS(Math.Abs(position.Declination), out deg, out min, out sec); string sign = position.Declination < 0 ? "-" : "+"; SendCommand(string.Format(":Sd{0}{1:00}*{2:00}:{3:00}#,n", sign, deg, min, sec), (decResult) => { success = decResult.Success && decResult.Data == "1"; }); FloatToHMS(Math.Abs(position.RightAscension), out hour, out min, out sec); SendCommand(string.Format(":Sr{0:00}:{1:00}:{2:00}#,n", hour, min, sec), (raResult) => { success = success && raResult.Success && raResult.Data == "1"; }); SendCommand($":MS#,n", (moveResult) => { success = success && moveResult.Success && moveResult.Data == "1"; }); await doneEvent.WaitAsync(); return(success); }
public async Task <bool> Sync(TelescopePosition position) { int deg, hour, min, sec; FloatToHMS(Math.Abs(position.Declination), out deg, out min, out sec); string sign = position.Declination < 0 ? "-" : "+"; var result = await SendCommand(string.Format(":Sd{0}{1:00}*{2:00}:{3:00}#,n", sign, deg, min, sec)); if (!result.Success || result.Data != "1") { return(false); } FloatToHMS(Math.Abs(position.RightAscension), out hour, out min, out sec); result = await SendCommand(string.Format(":Sr{0:00}:{1:00}:{2:00}#,n", hour, min, sec)); if (!result.Success || result.Data != "1") { return(false); } result = await SendCommand($":CM#"); return(result.Success); }