File: frmWinPredictClient.frm

package info (click to toggle)
predict 2.2.3-3.1
  • links: PTS
  • area: main
  • in suites: wheezy
  • size: 4,716 kB
  • sloc: ansic: 19,433; sh: 3,342; makefile: 428; yacc: 318; perl: 82
file content (273 lines) | stat: -rw-r--r-- 7,441 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
VERSION 5.00
Object = "{248DD890-BB45-11CF-9ABC-0080C7E7B78D}#1.0#0"; "MSWINSCK.OCX"
Begin VB.Form frmWinPredictClient 
   Caption         =   "WinPredictClient"
   ClientHeight    =   5175
   ClientLeft      =   60
   ClientTop       =   345
   ClientWidth     =   6495
   LinkTopic       =   "Form1"
   ScaleHeight     =   5175
   ScaleWidth      =   6495
   StartUpPosition =   3  'Windows Default
   Begin VB.CommandButton cmdConnect 
      Caption         =   "Get List"
      Enabled         =   0   'False
      Height          =   375
      Left            =   4080
      TabIndex        =   7
      Top             =   120
      Width           =   855
   End
   Begin MSWinsockLib.Winsock wsckPredict 
      Left            =   1200
      Top             =   4200
      _ExtentX        =   741
      _ExtentY        =   741
      _Version        =   393216
      Protocol        =   1
   End
   Begin VB.Timer timRefresh 
      Enabled         =   0   'False
      Left            =   480
      Top             =   4200
   End
   Begin VB.TextBox txtAzEl 
      Height          =   2535
      Left            =   240
      MultiLine       =   -1  'True
      ScrollBars      =   2  'Vertical
      TabIndex        =   6
      Top             =   1560
      Visible         =   0   'False
      Width           =   6015
   End
   Begin VB.CommandButton cmdNextPass 
      Caption         =   "Next Pass"
      Enabled         =   0   'False
      Height          =   375
      Left            =   5040
      TabIndex        =   5
      Top             =   840
      Width           =   855
   End
   Begin VB.CommandButton cmdCurrent 
      Caption         =   "Current"
      Enabled         =   0   'False
      Height          =   375
      Left            =   4080
      TabIndex        =   4
      Top             =   840
      Width           =   855
   End
   Begin VB.ComboBox cmbSatList 
      Enabled         =   0   'False
      Height          =   315
      Left            =   1680
      TabIndex        =   2
      Top             =   840
      Width           =   1935
   End
   Begin VB.TextBox txtConnectTo 
      Height          =   375
      Left            =   1680
      TabIndex        =   1
      Text            =   "my-linux-box"
      Top             =   120
      Width           =   1935
   End
   Begin VB.Label lblSatList 
      Caption         =   "Select Satellite:"
      Height          =   375
      Left            =   360
      TabIndex        =   3
      Top             =   840
      Width           =   1215
   End
   Begin VB.Label lblConnectTo 
      Caption         =   "PREDICT host:"
      Height          =   255
      Left            =   360
      TabIndex        =   0
      Top             =   240
      Width           =   1095
   End
End
Attribute VB_Name = "frmWinPredictClient"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = False
Attribute VB_PredeclaredId = True
Attribute VB_Exposed = False
Option Explicit
' the following line must match whatever the predict server uses
Const PredictPort = 1210
Const GetSatList = "GET_LIST"
Const GetSatPos = "GET_SAT_POS" ' plus satellite name
Const GetNextPass = "PREDICT"   ' plus satellute name
Dim strWsckData As String
Dim bGettingList As Boolean
Dim bGettingNextPass As Boolean
Dim bGettingCurrent As Boolean
Dim strUnixDate As String
Dim strPredictHost As String


Private Sub cmbSatList_Click()
If cmbSatList.ListIndex >= 0 Then
   cmdCurrent.Enabled = True
   cmdNextPass.Enabled = True
End If
End Sub

Private Sub cmdConnect_Click()

strWsckData = vbLf
bGettingList = True
strUnixDate = ""
wsckPredict.SendData GetSatList

While Len(strWsckData) = 1
   DoEvents
Wend
LoadItems
cmdConnect.Enabled = False
bGettingList = False
End Sub

Private Sub cmdCurrent_Click()
   strUnixDate = ""
   If bGettingCurrent = False Then
      bGettingCurrent = True
      strWsckData = ""
      txtAzEl.Text = ""
      timRefresh.Interval = 1 'ms
      timRefresh.Enabled = True
      cmdCurrent.Caption = "Stop"
      cmdNextPass.Enabled = False
      cmbSatList.Enabled = False
   Else
      cmdCurrent.Caption = "Current"
      timRefresh.Enabled = False
      bGettingCurrent = False
      txtAzEl.Visible = False
      cmdNextPass.Enabled = True
      cmbSatList.Enabled = True
   End If
End Sub

Private Sub cmdNextPass_Click()
  If bGettingNextPass = False Then
     bGettingNextPass = True
     cmdCurrent.Enabled = False
     strWsckData = ""
     txtAzEl.Text = "Processing.......please wait"
     wsckPredict.SendData GetNextPass + " " + _
       Chr(34) + cmbSatList.Text + Chr(34) _
       + " " + strUnixDate + vbLf
     While Len(strWsckData) = 0 _
     And InStr(1, strWsckData, Chr(26)) < 1 ' wait for ctrl-z
       DoEvents
     Wend
     txtAzEl.Text = ""
     bGettingNextPass = False
     txtAzEl.Visible = True
     txtAzEl.Height = 2500
     DisplayResponse
     cmdCurrent.Enabled = True
     strWsckData = ""
  End If
End Sub

Private Sub Form_Load()
' if host is supplied on command line, we'll automatically connect
strPredictHost = Command
bGettingList = False
bGettingNextPass = False
bGettingCurrent = False
If Len(strPredictHost) > 0 Then
   txtConnectTo.Text = strPredictHost
   'cmdConnect_Click
   strWsckData = vbLf
   bGettingList = True
   strUnixDate = ""
   wsckPredict.SendData GetSatList

   While Len(strWsckData) = 1
      DoEvents
   Wend
   LoadItems
   cmdConnect.Enabled = False
   bGettingList = False
End If
End Sub

Private Sub timRefresh_Timer()
strWsckData = ""
txtAzEl.Text = ""
wsckPredict.SendData GetSatPos + " " + Chr(34) + cmbSatList.Text + Chr(34) + vbLf

While Len(strWsckData) = 0
   DoEvents
Wend
txtAzEl.Visible = True
txtAzEl.Height = 500
DisplayResponse
timRefresh.Interval = 1000 'ms
timRefresh.Enabled = True
End Sub

Private Sub txtConnectTo_Change()
If Len(txtConnectTo.Text) > 0 Then
   cmdConnect.Enabled = True
   wsckPredict.RemoteHost = txtConnectTo.Text
   wsckPredict.RemotePort = PredictPort
   wsckPredict.LocalPort = PredictPort
Else
   cmdConnect.Enabled = False
End If
End Sub

Private Sub wsckPredict_DataArrival(ByVal bytesTotal As Long)

Dim strData As String
    wsckPredict.GetData strData, vbString
    strWsckData = strWsckData & strData

End Sub
Private Sub DisplayResponse()
Dim iStrg As Integer
strUnixDate = ""
'bDoingDate = False
For iStrg = 1 To Len(strWsckData)
DoEvents
If Mid$(strWsckData, iStrg, 1) <> vbLf Then
   txtAzEl.Text = txtAzEl.Text & Mid$(strWsckData, iStrg, 1)
Else
   txtAzEl.Text = txtAzEl.Text & vbCrLf
   If Len(strWsckData) > iStrg + 11 _
   And Val(Mid$(strWsckData, iStrg + 1, 10)) > 0 Then
     strUnixDate = CStr(2 + Val(Mid$(strWsckData, iStrg + 1, 10)))
   End If
End If
Next iStrg
DoEvents
End Sub
Private Sub LoadItems()
Dim iPtr As Integer
Dim strItem As String
strItem = ""
For iPtr = 1 To Len(strWsckData)
   If Mid$(strWsckData, iPtr, 1) = vbLf Then
      If Len(strItem) > 0 Then
         cmbSatList.AddItem strItem
      End If
      strItem = ""
   Else
      strItem = strItem & Mid$(strWsckData, iPtr, 1)
   End If
Next iPtr
txtConnectTo.Enabled = False
cmbSatList.Text = "Select Satellite"
cmbSatList.Enabled = True
End Sub