Implemented AbortSlew and did some code tidy up.
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
using System.IO.Ports;
|
||||
using System.Runtime.InteropServices;
|
||||
|
||||
namespace ASCOM.MeadeAutostar497.Controller
|
||||
{
|
||||
[ComVisible(false)]
|
||||
public interface ISerialProcessor
|
||||
{
|
||||
bool IsOpen { get; }
|
||||
bool DtrEnable { get; set; }
|
||||
bool RtsEnable { get; set; }
|
||||
int BaudRate { get; set; }
|
||||
int DataBits { get; set; }
|
||||
StopBits StopBits { get; set; }
|
||||
Parity Parity { get; set; }
|
||||
string PortName { get; set; }
|
||||
string[] GetPortNames();
|
||||
void Open();
|
||||
void Close();
|
||||
|
||||
string CommandTerminated(string command, string terminator);
|
||||
char CommandChar(string command);
|
||||
string ReadTerminated(string terminator);
|
||||
void Command(string command);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,14 @@
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
|
||||
namespace ASCOM.MeadeAutostar497.Controller
|
||||
{
|
||||
public interface ITelescopeController
|
||||
{
|
||||
ISerialProcessor SerialPort { get; set; }
|
||||
string Port { get; set; }
|
||||
bool Connected { get; set; }
|
||||
|
||||
bool Slewing { get; }
|
||||
DateTime utcDate { get; set; }
|
||||
void AbortSlew();
|
||||
}
|
||||
}
|
||||
@@ -1,31 +1,10 @@
|
||||
using System;
|
||||
using System.IO.Ports;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using System.Threading;
|
||||
|
||||
namespace ASCOM.MeadeAutostar497.Controller
|
||||
{
|
||||
[ComVisible(false)]
|
||||
public interface ISerialProcessor
|
||||
{
|
||||
bool IsOpen { get; }
|
||||
bool DtrEnable { get; set; }
|
||||
bool RtsEnable { get; set; }
|
||||
int BaudRate { get; set; }
|
||||
int DataBits { get; set; }
|
||||
StopBits StopBits { get; set; }
|
||||
Parity Parity { get; set; }
|
||||
string PortName { get; set; }
|
||||
string[] GetPortNames();
|
||||
void Open();
|
||||
void Close();
|
||||
|
||||
string CommandTerminated(string command, string terminator);
|
||||
char CommandChar(string command);
|
||||
string ReadTerminated(string terminator);
|
||||
}
|
||||
|
||||
[ComVisible(false)]
|
||||
public class SerialProcessor : ISerialProcessor
|
||||
{
|
||||
@@ -134,5 +113,18 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
serialMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
|
||||
public void Command(string command)
|
||||
{
|
||||
serialMutex.WaitOne();
|
||||
try
|
||||
{
|
||||
_serialPort.Write(command);
|
||||
}
|
||||
finally
|
||||
{
|
||||
serialMutex.ReleaseMutex();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,11 +1,6 @@
|
||||
using System;
|
||||
using System.Configuration;
|
||||
using System.Data;
|
||||
using System.IO.Ports;
|
||||
using System.Linq;
|
||||
using System.Threading;
|
||||
using ASCOM.Utilities;
|
||||
using ASCOM.Utilities.Interfaces;
|
||||
|
||||
namespace ASCOM.MeadeAutostar497.Controller
|
||||
{
|
||||
@@ -98,7 +93,7 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
|
||||
private void TestConnectionActive()
|
||||
{
|
||||
var firmwareVersionNumber = SerialPort.CommandTerminated(":GVN#", "#");
|
||||
var firmwareVersionNumber = SerialPort.CommandTerminated("#:GVN#", "#");
|
||||
if (string.IsNullOrEmpty(firmwareVersionNumber))
|
||||
{
|
||||
throw new InvalidOperationException("Failed to communicate with telescope.");
|
||||
@@ -155,10 +150,16 @@ namespace ASCOM.MeadeAutostar497.Controller
|
||||
throw new InvalidOperationException("Failed to set local time");
|
||||
}
|
||||
|
||||
SerialPort.ReadTerminated("#");
|
||||
SerialPort.ReadTerminated("#");
|
||||
//throwing away these two strings which represent
|
||||
SerialPort.ReadTerminated("#"); //Updating Planetary Data#
|
||||
SerialPort.ReadTerminated("#"); // #
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void AbortSlew()
|
||||
{
|
||||
SerialPort.Command("#:Q#");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user