public ASCOMCommunicationHandler(string device) { Log.WriteLine($"COMMFACTORY: Creating ASCOM handler for {device} ..."); _oat = new ASCOM.DriverAccess.Telescope("ASCOM.OpenAstroTracker.Telescope"); foreach (var action in _oat.SupportedActions) { Log.WriteLine($"COMMFACTORY: ASCOM handler supported action: {action} ..."); } _oat.Action("Serial:PassThroughCommand", "I#"); }
public string Action(string actionName, string actionParameters) { CheckConnected(); return(m_mount.Action(actionName, actionParameters)); }
protected override void RunJob(Job job) { CommandResponse response = null; if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Processing Job", job.Number, job.Command); } if (Connected) { if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Connected! Discarding any bytes in input buffer", job.Number, job.Command); } string reply; try { if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Sending command", job.Number, job.Command); } string command = job.Command; switch (job.ResponseType) { case ResponseType.NoResponse: if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Expecting no response for command", job.Number, job.Command); } break; case ResponseType.DigitResponse: if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Expecting single digit response for command", job.Number, job.Command); } command += ",n"; break; case ResponseType.FullResponse: if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Expecting #-delimited response for Command...", job.Number, job.Command); } command += ",#"; break; case ResponseType.DoubleFullResponse: command += ",##"; if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Expecting two #-delimited responses for Command...", job.Number, job.Command); } break; } reply = _oat.Action("Serial:PassThroughCommand", command); if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Received reply: '{2}'", job.Number, job.Command, reply); } response = new CommandResponse(reply, true); } catch (Exception ex) { Log.WriteLine("ASCOM: {0:0000}: [{1}] Failed to send command. {2}", job.Number, job.Command, ex.Message); job.OnFulFilled(new CommandResponse(string.Empty, false, $"Unable to execute command. " + ex.Message)); return; } } else { Log.WriteLine("ASCOM: {0:0000}: Telescope is not connected!", job.Number); response = new CommandResponse(string.Empty, false, $"Unable to connect to telescope"); } if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: Calling OnFulFilled lambda", job.Number); } job.OnFulFilled(response); job.Succeeded = response.Success; if (_logJobs) { Log.WriteLine("ASCOM: {0:0000}: Job completed", job.Number); } }