dlgjydzxsbtest.frm
来自「电力机车牵引变压器试验站总控程序」· FRM 代码 · 共 967 行 · 第 1/3 页
FRM
967 行
Case 0
strCommand = "54"
strTest = "54"
strTemp2 = "绝缘电阻"
Case 1
strCommand = "55"
strTest = "55"
strTemp2 = "吸收比"
Case 2
strCommand = "56"
strTest = "56"
strTemp2 = "极化指数"
Case Else
MsgBox "您未选择试验类型,程序将按默认的绝缘电阻试验进行试验!", vbOKOnly, "提示"
strCommand = "54"
strTest = "54"
End Select
Label4.Caption = ""
Call controlCommand1(strCommand, 0)
Timer1.Interval = 500
Timer1.Enabled = True
Frame1.Enabled = False
Frame2.Enabled = False
Text2.Text = "选择了" & strTemp2 & "试验" + Chr(13) + Chr(10) + Text2.Text
End Sub
Private Sub Form_Load()
On Error GoTo ErrHandler
Dim strCommand As String
Dim count As Long
Timer1.Interval = 100
Timer1.Enabled = True
Timer2.Interval = 3000
Timer2.Enabled = True
Exit Sub
ErrHandler:
Select Case Err.Number
Case Else
Err.Clear
MsgBox "unknown error"
Exit Sub
End Select
Resume
End Sub
Private Sub MSComm1_OnComm(Index As Integer)
Dim bytInput() As Byte
Dim intInputLen As Integer
Dim x As Integer
Dim n As Integer
Select Case MSComm1(Index).CommEvent
Case comEvReceive
If Not MSComm1(Index).PortOpen Then
strSet = "4800,n,8,1"
' frmMain.MSComm1(Index).commPort = intPort
MSComm1(Index).Settings = strSet
MSComm1(Index).PortOpen = True
End If
'此处添加处理接收的代码
strHex(Index) = ""
strAscii(Index) = ""
MSComm1(Index).InputMode = comInputModeBinary
intInputLen = MSComm1(Index).InBufferCount
ReDim bytInput(intInputLen)
bytInput = MSComm1(Index).Input
Call InputManage(bytInput, intInputLen)
Call GetReceiveText(Index)
Call InputManageTotal(bytInput, intInputLen)
Call GetReceiveTextTotal(Index)
Debug.Print Index & ": " & strHexAll(Index)
Debug.Print Index & ": " & strAsciiAll(Index)
If Index = 0 Then
If strHex(Index) = "90" Then
Label3.Caption = "500V"
Frame1.Enabled = True
Frame2.Enabled = True
Option1(0).Value = True
strHex(Index) = ""
strAscii(Index) = ""
ElseIf strHex(Index) = "91" Then
Label3.Caption = "1000V"
Frame1.Enabled = True
Frame2.Enabled = True
Option1(1).Value = True
strHex(Index) = ""
strAscii(Index) = ""
ElseIf strHex(Index) = "92" Then
Label3.Caption = "2.5KV"
Frame1.Enabled = True
Frame2.Enabled = True
Option1(2).Value = True
strHex(Index) = ""
strAscii(Index) = ""
ElseIf strHex(Index) = "93" Then
Label3.Caption = "5KV"
Frame1.Enabled = True
Frame2.Enabled = True
Option1(3).Value = True
strHex(Index) = ""
strAscii(Index) = ""
ElseIf strHex(Index) = "94" Then
Label4.Caption = "绝缘电阻"
Frame1.Enabled = True
Frame2.Enabled = True
Option2(0).Value = True
strHex(Index) = ""
strAscii(Index) = ""
ElseIf strHex(Index) = "95" Then
Label4.Caption = "吸收比"
Label7.Caption = "Xr="
Frame1.Enabled = True
Frame2.Enabled = True
Option2(1).Value = True
strHex(Index) = ""
strAscii(Index) = ""
ElseIf strHex(Index) = "96" Then
Label4.Caption = "极化指数"
Label7.Caption = "Jr="
Frame1.Enabled = True
Frame2.Enabled = True
Option2(2).Value = True
strHex(Index) = ""
strAscii(Index) = ""
ElseIf strHex(Index) = "97" Then
Label6.Caption = ">2000"
Label8.Caption = "合格"
strHex(Index) = ""
strAscii(Index) = ""
Command4.Enabled = True
ElseIf strHex(Index) = "99" Then
Text2.Text = "开始输出高压,请注意!" + Chr(13) + Chr(10) & Text2.Text
strHex(Index) = ""
strAscii(Index) = ""
CancelButton.Enabled = True
Else
' If PorQ = 1 And strAscii(Index) <> "Q" And strAscii(Index) <> "P" Then
' Label6.Caption = Label6.Caption + strAscii(Index)
' ElseIf PorQ = 2 And strAscii(Index) <> "P" And strAscii(Index) <> "Q" Then
' Label8.Caption = Label8.Caption + strAscii(Index)
' End If
' If strAscii(Index) = "P" Then
' Label6.Caption = ""
' PorQ = 1
' ElseIf strAscii(Index) = "Q" Then
' Label8.Caption = ""
' PorQ = 2
' End If
Recordcount = Recordcount + 1
If Recordcount > 0 Then
Dim length As Long
length = Len(strAsciiAll(Index))
If length > 5 Then
Command4.Enabled = True
x = InStr(length - 5, strAsciiAll(Index), "P", vbTextCompare)
n = InStr(length - 5, strAsciiAll(Index), "Q", vbTextCompare)
If x <> 0 And n = 0 Then
Label6.Caption = numPatternChange(Mid(strAsciiAll(Index), x + 1, 5))
ElseIf x <> 0 And n <> 0 And n < length - 3 Then
Label15.Caption = numPatternChange(Mid(strAsciiAll(Index), n + 1, 4))
Label6.Caption = numPatternChange(Mid(strAsciiAll(Index), x + 1, 5))
ElseIf x = 0 And n <> 0 And n < length - 3 Then
Label15.Caption = numPatternChange(Mid(strAsciiAll(Index), n + 1, 4))
End If
End If
End If
If ttrain = "500" And ttype = "6" Then
If Label6.Caption <> "" And Label15.Caption <> "" Then
If tobj = " 0" Then
If Val(Label6.Caption) >= 1000 Then
Label8.Caption = "合格"
Else
Label8.Caption = "不合格"
End If
Else
If Val(Label6.Caption) >= 500 Then
Label8.Caption = "合格"
Else
Label8.Caption = "不合格"
End If
End If
End If
ElseIf ttrain = "500" And ttype = "20" Then
If Label6.Caption <> "" Then
If Val(Label6.Caption) >= 500 Then
Label8.Caption = "合格"
Else
Label8.Caption = "不合格"
End If
End If
ElseIf ttrain = "500" And ttype = "25" Then '要找大纲看看,没有标准
ElseIf ttrain = "500" And ttype = "31" Then
If Label6.Caption <> "" Then
If Val(Label6.Caption) >= 10 Then
Label8.Caption = "合格"
Else
Label8.Caption = "不合格"
End If
End If
ElseIf ttrain = "200" And ttype = "6" Then
If Label6.Caption <> "" And Label15.Caption <> "" Then
If tobj = " 0" Then
If Val(Label6.Caption) >= 1000 And Val(Label15.Caption) >= 1.3 Then
Label8.Caption = "合格"
Else
Label8.Caption = "不合格"
End If
ElseIf tobj = " 4" Or tobj = " 5" Then
If Val(Label6.Caption) >= 200 And Val(Label15.Caption) >= 1.3 Then
Label8.Caption = "合格"
Else
Label8.Caption = "不合格"
End If
Else
If Val(Label6.Caption) >= 500 And Val(Label15.Caption) >= 1.3 Then
Label8.Caption = "合格"
Else
Label8.Caption = "不合格"
End If
End If
End If
End If
strAsciiAll(Index) = ""
strAscii(Index) = ""
strHex(Index) = ""
End If
ElseIf Index = 1 Then
x = InStr(1, strHexAll(Index), "0A", vbTextCompare)
Dim Y As Integer
Dim strMonitorVal As String
Y = x / 2
If Y <> 0 And Y >= 6 Then
strMonitorVal = Mid(strAsciiAll(Index), Y - 7, 7)
Label10.Caption = numPatternChange(Val(strMonitorVal))
intReceiveLenAll = 0
End If
End If
' Dim ANum As Long
' ANum = "&H" + strHex
End Select
End Sub
Private Sub OKButton_Click()
Unload Me
End Sub
Private Sub Timer1_Timer()
Timer1.Enabled = False
If Label3.Caption = "" Then
Call controlCommand1("59", 0)
Timer1.Enabled = True
ElseIf Label3.Caption <> "" And Label4.Caption = "" Then
Call controlCommand1("5A", 0)
Timer1.Enabled = True
ElseIf Label3.Caption <> "" And Label4.Caption <> "" Then
Timer1.Enabled = False
Frame1.Enabled = True
Frame2.Enabled = True
End If
End Sub
Private Sub Timer2_Timer()
Call controlCommand1("580A", 1)
End Sub
Sub controlCommand1(ByVal strCommand As String, ByVal Index As Integer)
On Error GoTo ErrorHandler
Dim strTemp As String
strTemp = strCommand
Dim longth As Integer
longth = strHexToByteArray(strTemp, bytSendByte())
If longth <> 0 Then
If Not MSComm1(Index).PortOpen Then
MSComm1(Index).PortOpen = True
MSComm1(Index).Output = bytSendByte()
' frmMain.MSComm1(commPort).PortOpen = False
Else
MSComm1(Index).Output = bytSendByte()
' frmMain.MSComm1(commPort).PortOpen = False
End If
End If
Exit Sub
ErrorHandler:
Select Case Err.Number
Case 8005
MsgBox "串口3已被占用,请检查!", vbOKOnly, "警告"
Err.Clear
Exit Sub
Case 8002
MsgBox "串口" & MSComm1(Index).commPort & "不存在,请检查!", vbOKOnly, "警告"
Err.Clear
Unload frmProcessing
Exit Sub
Case Else
MsgBox "未知错误", vbOKOnly, "警告"
Err.Clear
Exit Sub
End Select
Resume
End Sub
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?