А какая это программа? Я поглядел-интерфейс тот-же.......
Олег.
Я и сам интерфейсу удивлялся - кто то что то взял за основу!
Hello,
Here is the code in my ASCOM driver.
Public Property Let Connected(ByVal newVal As Boolean)
Dim buf As String, sRA As String, sDEC As String
Dim bits() As String, rx As RegExp, mt As MatchCollection
Dim tmo As Long
Dim sRA_backflash As String, sDEC_backflash As String
If newVal Then ' CONNECTING
'
' (1) Set up the communications link. Default to COM1.
'
buf = m_Profile.GetValue(ID, "COM Port")
If buf = "" Then ' Default to COM1
buf = "1"
m_Profile.WriteValue ID, "COM Port", buf
End If
m_serial.port = CInt(buf) ' Set port
m_serial.Speed = ps9600 ' LX200 uses 9600
m_serial.ReceiveTimeout = 5 ' 5 second timeout
m_serial.Connected = True
sRA_backflash = m_Profile.GetValue(ID, "RA Back Flash")
sDEC_backflash = m_Profile.GetValue(ID, "DEC Back Flash")
RA_backflash = CInt(sRA_backflash)
DEC_backflash = CInt(sDEC_backflash)
MountSide = m_Profile.GetValue(ID, "SIDE")
sRA = m_Profile.GetValue(ID, "Last RA")
If sRA = "" Then sRA = "11:04:00"
sDEC = m_Profile.GetValue(ID, "Last DEC")
If sDEC = "" Then sDEC = "61:43:00"
Call display
' Grab the serial port
'
' (2) Determine that there is an LX200 scope there, initialize
' some variables for below...
'
On Error GoTo NO_SCOPE ' -- error trap --
m_serial.Transmit "qa"
'sRA = "11:04:00" '初始位置
m_dPrevRA = m_util.HMSToHours(sRA)
RA_NOW = m_util.HMSToHours(sRA)
'sDec = "61:43:00"
m_dPrevDec = m_util.DMSToDegrees(sDEC)
DEC_NOW = m_util.DMSToDegrees(sDEC)
null_EW = True
null_SN = True
If MountSide = "E" Then '默认为平台在极轴的东边
DECcw = &HFF
DECccw = &HFE
Else
DECcw = &HFE
DECccw = &HFF
End If
On Error GoTo 0 ' -- end trap --
m_serial.ClearBuffers ' Toss any junk remaining in buffers
'
' (3) Final timeout & try for long format.
'
m_serial.ReceiveTimeout = 10 ' Switch to 10 sec timeout
m_bLongFormat = SetLongFormat(True) ' Try for long format
'
' (4) Initialize slew detection parameters. The registry values may be
' missing if the SetupDialog() had not yet been used. We default
' to 60 arcsec. Avoid use of decimal values for international use.
'
m_bSlewing = False
m_bAbortSlew = False
'
' (5) Get the delimiters that this implementation uses. Re-read the
' RA and Dec now that we might have Long Format set!
'
Else ' DISCONNECTING
On Error Resume Next ' Best efforts...
If m_serial.Connected Then Me.CommandBlind "q" ' Stop all motion
m_bSlewing = False ' No longer slewing
Call display_off
m_Profile.WriteValue ID, "Last RA", m_util.HoursToHMS(RA_NOW) '将最后的位置记录
m_Profile.WriteValue ID, "Last DEC", m_util.DegreesToDMS(DEC_NOW)
If m_serial.Connected Then SetLongFormat False
m_serial.ClearBuffers ' Clear serial buffers
m_serial.Connected = False ' Release COM port
End If
Exit Property
NO_SCOPE:
m_serial.ClearBuffers
m_serial.Connected = False ' Release the port
Err.Raise SCODE_NO_SCOPE, ERR_SOURCE, MSG_NO_SCOPE
End Property
' *******************************************************
Public Sub PulseGuide(ByVal direction As GuideDirections, ByVal Duration As Long)
Dim d As String
' Assure we're in Guide rate
Select Case direction
Case guideNorth: d = "^"
Case guideSouth: d = "Y"
Case guideEast: d = ">"
Case guideWest: d = "o"
End Select
m_serial.Transmit d
m_util.WaitForMilliseconds Duration
m_serial.Transmit "jj"
m_util.WaitForMilliseconds 100
m_serial.Transmit "jj"
End Sub