Документ взят из кэша поисковой машины. Адрес оригинального документа : http://www.astro.louisville.edu/software/xmtel/archive/xmtel-3.1/docs/nexstar/GotoRA-Dec.txt
Дата изменения: Wed Dec 12 04:59:28 2001
Дата индексирования: Mon Oct 1 22:40:56 2012
Кодировка:

Поисковые слова: закон вина
Below is a Visual Basic sub-procedure which will allow sending the Goto RA-Dec command to any model of NexStar. The ScopeType argument takes one of three values: "Little", "Big" or "GPS". "Little" for the original GT models (60/80/114/4), "Big" for the N5 and N8, "GPS" for N8/11GPS and the new GT models. Examples of how to call the procedure:

To point a little NexStar at Aldebaran:
ScopeGoto 4, 35.9, "+", 16, 30, "Little")

To point a big NexStar at Aldebaran:
ScopeGoto 4, 35.9, "+", 16, 30, "Big"

To point a GPS or new GT NexStar at Aldebaran:
ScopeGoto 4, 35.9, "+", 16, 30, "GPS"

To use the following procedure, place a serial communications control on Form1 and insure it is named Comm1. You could then place text boxes on Form1 and a command button to call the procedure, passing the contents of the text boxes as the arguments.

Place the ScopeGoto and Wait procedures in a standard module and you'll be all set.

-----

Sub ScopeGoto(RAHour, RAMin, DecSign, DecDeg, DecMinute)
On Error GoTo ScopeGotoError
Dim RA1, RA2, Dec1, Dec2 As Integer
Dim RA, Dec As Long
Dim strCoord As String

If DecSign <> "-" Then DecSign = "+"
NSObserverListMain!Comm2.CommPort = Val(SerPort)
NSObserverListMain!Comm2.Settings = "9600,N,8,1"
NSObserverListMain!Comm2.InputLen = 0
NSObserverListMain!Comm2.PortOpen = True
RA = Int((((RAHour * 60 + RAMin) * 15) * 3 * 1.011358))
If DecSign = "+" Then
Dec = Int((DecDeg * 60 + DecMinute) * 3 * 1.011358)
Else
Dec = Int(((360 * 60) - (Abs(Val(DecDeg)) * 60 + DecMinute)) * 3 * 1.011358)
End If
RA1 = Int(RA / 256)
RA2 = RA Mod 256
Dec1 = Int(Dec / 256)
Dec2 = Dec Mod 256
If ScopeType = "Little" Then
NSObserverListMain!Comm2.Output = "?"
Wait 0.25
strCoord = "R" & Chr(RA1) & Chr(RA2) & Chr(0) & Chr(Dec1) & Chr(Dec2) & Chr(0)
NSObserverListMain!Comm2.Output = strCoord
Else
If ScopeType = "Big" Then
NSObserverListMain!Comm2.Output = "?"
Wait 0.25
strCoord = "R" & Chr(RA1) & Chr(RA2) & Chr(Dec1) & Chr(Dec2)
NSObserverListMain!Comm2.Output = strCoord
Else
If ScopeType = "GPS" Then
strCoord = "R" & Mid("00", 1, 2 - Len(Hex(RA1))) & Hex(RA1) & Mid("00", 1, 2 - Len(Hex(RA2))) & Hex(RA2) & "," & Mid("00", 1, 2 - Len(Hex(Dec1))) & Hex(Dec1) & Mid("00", 1, 2 - Len(Hex(Dec2))) & Hex(Dec2)
NSObserverListMain!Comm2.Output = strCoord
End If
End If
End If

NSObserverListMain!Comm2.PortOpen = False


Exit Sub
ScopeGotoError:
MsgBox "Unable to communicate with the scope.", vbOKOnly, "Error"

End Sub

-----

Sub Wait(SecondsToPause As Double)
On Error GoTo NSError
Dim Start
Screen.MousePointer = vbHourglass
Start = Timer ' Set start time.
Do While Timer < Start + SecondsToPause
'Do nothing during the loop
Loop
Screen.MousePointer = vbDefault
Exit Sub
NSError:
MsgBox Err.Description
End Sub