If Network.Ping("200.200.200.190") Then
If connectinglink <> 0 Then
InternetCloseHandle(connectinglink )
InternetCloseHandle(connecttingno)
End If
'保存当前活动连接的句柄
openftpserver()
connectinglink = InternetConnect(connecttingno,"200.200.200.190",21,"anonymous","",1,0,0) '连接并取得句柄
If connecttingno = 0 Then
MessageBox.Show("InternetConnect:" & Err.LastDllError)
End If
If connectinglink = 0 Then
activeftp = False '标记为活动
Else
activeftp = True
End If
Download("job\stat.csv","/HardDisk/TEMP/state.csv")
Forms("login").TimerEnabled = False
Forms("login").Controls("label2").text = successflag
If successflag = True Then
Forms("login").Controls("label4").text = "connectno and link :" & connecttingno & "-" & connectinglink
Dim tempname As Long = CInt(Forms("login").Controls("label3").text)
Forms("login").Controls("label3").text = tempname + 1
statflag = FileSys.ReadAllText("job\stat.csv",Encoding.ASCII) '读取文件内容至字符串变量
'读取
Forms("login").Controls("labcha").text = Format(CSng(ReadStat(statflag,2)),"0.0") & "℃"
Forms("login").Controls("labpha").text = Format(CSng(ReadStat(statflag,3)),"0.0") & "℃"
Forms("login").Controls("label6").text = ReadStat(statflag,4)
'取结果文件
If ReadStat(statflag,4) <> "0" Then
If FileSys.FileExists("result\" & ReadStat(statflag,4)) Then
Else
Dim szult As String = ReadStat(statflag,4)
szult = szult.Replace("\HardDisk\result\","")
Download("result\" & szult ,ReadStat(statflag,4))
End If
End If
'如结束,返回结果文件并读取状态
Dim mstat As String = ReadStat(statflag,1)
If mstat = "0" Or mstat = "10" Or mstat = "12" Then
Select Case mstat
Case "0" '空闲 可开始
Forms("login").Controls("panel2").Enabled = True
Forms("login").Controls("cmpicplay").image = getimage("play.gif")
Forms("login").Controls("cmpicstop").image = getimage("stopstat.gif")
Forms("login").Controls("cmpicstepstop").image = getimage("stepstop.gif")
Forms("login").Controls("cmpicplay").Enabled = True
Forms("login").Controls("cmpicstop").Enabled = False
Forms("login").Controls("cmpicstepstop").Enabled = False
Forms("login").Controls("cmpicplay").Visible = True
Forms("login").Controls("cmpicstop").Visible = True
Forms("login").Controls("cmpicstepstop").Visible = True
Forms("login").Controls("laberror").text = "仪器空闲或反应结束."
Forms("login").Controls("picmmstat").Image = GetImage("mmstop.png")
StatusBar.Message1 = "Standby..."
Case "10" '运行中 可停止和暂停
Forms("login").Controls("panel2").Enabled = False
Forms("login").Controls("cmpicplay").image = getimage("playstat.gif")
Forms("login").Controls("cmpicstop").image = getimage("stop.gif")
Forms("login").Controls("cmpicstepstop").image = getimage("stepstop.gif")
Forms("login").Controls("cmpicplay").Enabled = False
Forms("login").Controls("cmpicstop").Enabled = True
Forms("login").Controls("cmpicstepstop").Enabled = True
Forms("login").Controls("cmpicplay").Visible = True
Forms("login").Controls("cmpicstop").Visible = True
Forms("login").Controls("cmpicstepstop").Visible = True
Forms("login").Controls("laberror").text = "仪器运行中....."
Forms("login").Controls("picmmstat").Image = GetImage("run.gif")
StatusBar.Message1 = "Running..."
Case "12" '暂停中 可继续或停止
Forms("login").Controls("panel2").Enabled = False
Forms("login").Controls("cmpicplay").image = getimage("play.gif")
Forms("login").Controls("cmpicstop").image = getimage("stop.gif")
Forms("login").Controls("cmpicstepstop").image = getimage("stepstopstat.gif")
Forms("login").Controls("cmpicplay").Enabled = False
Forms("login").Controls("cmpicstop").Enabled = True
Forms("login").Controls("cmpicstepstop").Enabled = True
Forms("login").Controls("cmpicplay").Visible = True
Forms("login").Controls("cmpicstop").Visible = True
Forms("login").Controls("cmpicstepstop").Visible = True
For Each ctls2 As WinForm.Control In Forms("login").Controls '遍历所有控件
If TypeOf ctls2 Is WinForm.RadioButton Then '如果此控件是RadionButton(单选框)
Dim rdos2 As WinForm.RadioButton = ctls2
rdos2.Checked = False
Forms("login").Controls("labjobing").text = ""
If Cint(ReadStat(statflag,19)) = Cint(rdos2.name.SubString(6,1))
' Forms("login").Controls("labjobing").text = ReadStat(statflag,19)
Forms("login").Controls("labjobing").text = rdos2.text
rdos2.Checked = True
End If
End If
Next
Forms("login").Controls("laberror").text = "暂停......"
Forms("login").Controls("picmmstat").Image = GetImage("mmstop.png")
StatusBar.Message1 = "暂停..."
End Select
End If
Forms("login").Controls("Panel1").Enabled = True
Forms("login").Controls("Panel1").Visible = True
Forms("login").Controls("lablinktest").text = "数据通讯正常/访问正常"
Forms("login").Controls("lablinktest").ForeColor = Color.green
Forms("login").Controls("barlib").Visible = True
Forms("login").Controls("lablib").Visible = False
If cwdtemp = True Then
Forms("login").Controls("cmpicplay").Visible = False
Forms("login").Controls("cmpicstop").Visible = False
Forms("login").Controls("cmpicstepstop").Visible = False
End If
Else
Forms("login").Controls("lablinktest").text = "数据通讯正常/访问失败/正尝试重新连接......"
Forms("login").Controls("lablinktest").ForeColor = Color.green
Forms("login").Controls("Panel1").Visible = False
End If
If connectinglink <> 0 Then
InternetCloseHandle(connectinglink)
End If
connectinglink = 0
Else
Forms("login").Controls("lablinktest").text = "数据通讯失败/访问失败/正尝试重新连接......"
Forms("login").Controls("lablinktest").ForeColor = Color.red
Forms("login").Controls("Panel1").Visible = False
Forms("login").Controls("barlib").Visible = False
Forms("login").Controls("lablib").Visible = True
End If
successflag =False