frmwiretest.frm

来自「电梯检测系统是对电梯性能进行检测的系统。是一个用来学习的程序。」· FRM 代码 · 共 1,274 行 · 第 1/3 页

FRM
1,274 行
字号
     WireTestOn = False
     TestFinishCmd_Click
     Exit Sub
  End If
  cTime = Timer
  CurSendSucc = False
  Do Until Timer - cTime > 2
    If bolWritePlcB_05(iDeviceID, XPOWER1, &H0) Then
      Exit Do
    End If
  Loop
  TestResult.Text = "XPOWER1 wire passed." & Chr(10) & TestResult.Text
  '''''''''''''''''''''''''''''''''''''
  WireTstPass(0) = True

  'Test XPOWER2
  WireInput.Text = "Now test XPOWER2." & Chr(10)
  ''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 9
  WireInput.SelLength = 7
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
    
  WireNum = WireNum + 1
  TestLineNumLable.Caption = WireNum
    
  WireInput.Text = "Send XPOWER2 signal." & Chr(10) & WireInput.Text
  ''''''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 5
  WireInput.SelLength = 7
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
  
  
  'set XPOWER2 to 1
  CurSendSucc = False
  cTime = Timer
  Do Until Timer - cTime > 2
     If bolWritePlcB_05(iDeviceID, XPOWER2, &HFF) Then
       CurSendSucc = True
       Exit Do
     End If
  Loop
  If Not CurSendSucc Then
     TestResult.Text = "Handshake failed! Exit test!" & Chr(10) & TestResult.Text
     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     WireTestOn = False
     Exit Sub
  End If
  cTime = Timer
  Do Until Timer - cTime > 1
   DoEvents
  Loop
  'read iXPOWER2
  WireInput.Text = "Now check iXPOWER2 signals." & Chr(10) & WireInput.Text
  ''''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 10
  WireInput.SelLength = 8
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
  
  cTime = Timer
  Do Until Timer - cTime > 1
   DoEvents
  Loop
   
  If bolReadPlcB_03(0, CountAddr, 9, LngVRetAryB) Then
  Else
    TestResult.Text = "Signal read error." & Chr(10) & TestResult.Text
    ''''''''''''''''''''''''''''''''''''
    CurSendSucc = False
    cTime = Timer
    Do Until Timer - cTime > 2
      If bolWritePlcB_05(iDeviceID, XPOWER2, &H0) Then
        CurSendSucc = True
        Exit Do
      End If
    Loop
    WireTestOn = False
    Exit Sub
  End If
   If Not (SignalBitRight(LngVRetAryB, iXPOWER1 - 16, 0) And SignalBitRight(LngVRetAryB, iXPOWER2 - 16, 1) And SignalBitRight(LngVRetAryB, iXLight1 - 16, 0) And SignalBitRight(LngVRetAryB, iXLight2 - 16, 0)) Then
     TestResult.Text = "XPOWER2 test error." & Chr(10) & TestResult.Text
     '''''''''''''''''''''''''''''''
     Open App.Path & "\ErrReport\" & TempFileName & "Err.txt" For Output As #1
     Print #1, "TEST XPOWER2           test signal:  iXPOWER2"
     Print #1, " Following signals are in error:"
     Close #1
     ShowErrorText 2
     cTime = Timer
     CurSendSucc = False
     Do Until Timer - cTime > 2
       If bolWritePlcB_05(iDeviceID, XPOWER2, &H0) Then
         Exit Do
       End If
     Loop
     WireTestOn = False
     TestFinishCmd_Click
     Exit Sub
  End If
  cTime = Timer
  CurSendSucc = False
  Do Until Timer - cTime > 2
    If bolWritePlcB_05(iDeviceID, XPOWER2, &H0) Then
      Exit Do
    End If
  Loop
  TestResult.Text = "XPOWER2 wire passed." & Chr(10) & TestResult.Text
  '''''''''''''''''''''''''''''''''''''
  WireTstPass(1) = True

  'Test XLight1
  WireInput.Text = "Now test XLight1." & Chr(10)
  ''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 9
  WireInput.SelLength = 7
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
    
  WireNum = WireNum + 1
  TestLineNumLable.Caption = WireNum
    
  WireInput.Text = "Send XLight1 signal." & Chr(10) & WireInput.Text
  ''''''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 5
  WireInput.SelLength = 7
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
  
  
  'set XLight1 to 1
  CurSendSucc = False
  cTime = Timer
  Do Until Timer - cTime > 2
     If bolWritePlcB_05(iDeviceID, XLight1, &HFF) Then
       CurSendSucc = True
       Exit Do
     End If
  Loop
  If Not CurSendSucc Then
     TestResult.Text = "Handshake failed! Exit test!" & Chr(10) & TestResult.Text
     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     WireTestOn = False
     Exit Sub
  End If
  cTime = Timer
  Do Until Timer - cTime > 1
   DoEvents
  Loop
  'read iXLight1
  WireInput.Text = "Now check iXLight1 signals." & Chr(10) & WireInput.Text
  ''''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 10
  WireInput.SelLength = 8
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
  
  cTime = Timer
  Do Until Timer - cTime > 1
   DoEvents
  Loop
   
  If bolReadPlcB_03(0, CountAddr, 9, LngVRetAryB) Then
  Else
    TestResult.Text = "Signal read error." & Chr(10) & TestResult.Text
    ''''''''''''''''''''''''''''''''''''
    CurSendSucc = False
    cTime = Timer
    Do Until Timer - cTime > 2
      If bolWritePlcB_05(iDeviceID, XLight1, &H0) Then
        CurSendSucc = True
        Exit Do
      End If
    Loop
    WireTestOn = False
    Exit Sub
  End If
   If Not (SignalBitRight(LngVRetAryB, iXPOWER1 - 16, 0) And SignalBitRight(LngVRetAryB, iXPOWER2 - 16, 0) And SignalBitRight(LngVRetAryB, iXLight1 - 16, 1) And SignalBitRight(LngVRetAryB, iXLight2 - 16, 0)) Then
     TestResult.Text = "XLight1 test error." & Chr(10) & TestResult.Text
     '''''''''''''''''''''''''''''''
     Open App.Path & "\ErrReport\" & TempFileName & "Err.txt" For Output As #1
     Print #1, "TEST XLight1           test signal:  iXLight1"
     Print #1, " Following signals are in error:"
     Close #1
     ShowErrorText 3
     cTime = Timer
     CurSendSucc = False
     Do Until Timer - cTime > 2
       If bolWritePlcB_05(iDeviceID, XLight1, &H0) Then
         Exit Do
       End If
     Loop
     WireTestOn = False
     TestFinishCmd_Click
     Exit Sub
  End If
  cTime = Timer
  CurSendSucc = False
  Do Until Timer - cTime > 2
    If bolWritePlcB_05(iDeviceID, XLight1, &H0) Then
      Exit Do
    End If
  Loop
  TestResult.Text = "XLight1 wire passed." & Chr(10) & TestResult.Text
  '''''''''''''''''''''''''''''''''''''
  WireTstPass(2) = True

  'Test XLight2
  WireInput.Text = "Now test XLight2." & Chr(10)
  ''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 9
  WireInput.SelLength = 7
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
    
  WireNum = WireNum + 1
  TestLineNumLable.Caption = WireNum
    
  WireInput.Text = "Send XLight2 signal." & Chr(10) & WireInput.Text
  ''''''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 5
  WireInput.SelLength = 7
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
  
  
  'set XLight2 to 1
  CurSendSucc = False
  cTime = Timer
  Do Until Timer - cTime > 2
     If bolWritePlcB_05(iDeviceID, XLight2, &HFF) Then
       CurSendSucc = True
       Exit Do
     End If
  Loop
  If Not CurSendSucc Then
     TestResult.Text = "Handshake failed! Exit test!" & Chr(10) & TestResult.Text
     ''''''''''''''''''''''''''''''''''''''''''''''''''''''''''''
     WireTestOn = False
     Exit Sub
  End If
  cTime = Timer
  Do Until Timer - cTime > 1
   DoEvents
  Loop
  'read iXLight2
  WireInput.Text = "Now check iXLight2 signals." & Chr(10) & WireInput.Text
  ''''''''''''''''''''''''''''''''
      '====set color begin
  WireInput.SelStart = 10
  WireInput.SelLength = 8
  WireInput.SelColor = vbRed
  WireInput.SelBold = True
  WireInput.SelLength = 0
    '=====set color end
  
  cTime = Timer
  Do Until Timer - cTime > 1
   DoEvents
  Loop
   
  If bolReadPlcB_03(0, CountAddr, 9, LngVRetAryB) Then
  Else
    TestResult.Text = "Signal read error." & Chr(10) & TestResult.Text
    ''''''''''''''''''''''''''''''''''''
    CurSendSucc = False
    cTime = Timer
    Do Until Timer - cTime > 2
      If bolWritePlcB_05(iDeviceID, XLight2, &H0) Then
        CurSendSucc = True
        Exit Do
      End If
    Loop
    WireTestOn = False
    Exit Sub
  End If
   If Not (SignalBitRight(LngVRetAryB, iXPOWER1 - 16, 0) And SignalBitRight(LngVRetAryB, iXPOWER2 - 16, 0) And SignalBitRight(LngVRetAryB, iXLight1 - 16, 0) And SignalBitRight(LngVRetAryB, iXLight2 - 16, 1)) Then
     TestResult.Text = "XLight2 test error." & Chr(10) & TestResult.Text
     '''''''''''''''''''''''''''''''
     Open App.Path & "\ErrReport\" & TempFileName & "Err.txt" For Output As #1
     Print #1, "TEST XLight2           test signal:  iXLight2"
     Print #1, " Following signals are in error:"
     Close #1
     ShowErrorText 4
     cTime = Timer
     CurSendSucc = False
     Do Until Timer - cTime > 2
       If bolWritePlcB_05(iDeviceID, XLight2, &H0) Then
         Exit Do
       End If
     Loop
     WireTestOn = False
     TestFinishCmd_Click
     Exit Sub
  End If
  cTime = Timer
  CurSendSucc = False
  Do Until Timer - cTime > 2
    If bolWritePlcB_05(iDeviceID, XLight2, &H0) Then
      Exit Do
    End If
  Loop
  TestResult.Text = "XLight2 wire passed." & Chr(10) & TestResult.Text
  '''''''''''''''''''''''''''''''''''''
  WireTstPass(3) = True

  DbMsgShow.Text1.Text = ""
  DbMsgShow.Text1.FileName = App.Path & ("\showmsg\WireInfo2.txt")
  SetWindowPos DbMsgShow.hwnd, HWND_TOPMOST, 200, 100, 500, 350, SWP_SHOWWINDOW
  FillComp = False
  FillSucc = False
  Do Until FillComp
    DoEvents
  Loop
  If Not FillSucc Then
    WireTestOn = False
    TestFinishCmd_Click
    Exit Sub
  End If
  
  WireTestOn = False
  frmWireOK.Show 1
  TestFinishCmd_Click
  Exit Sub
Err:
  TestResult.Text = "Wire" & WireNum & "do not pass the test.Click Continue to test another." & Chr(10) & TestResult.Text
''''''''''''''''''''''''''''''''''''''''''''''''''''''''

End Sub



Private Sub TestFinishCmd_Click()
  Dim fso
  Dim TestFullPass As Boolean
  If WireTestOn Then
    DefMsgBox.Text1.Text = "Can not exit when wiring test is still running."
    SetWindowPos DefMsgBox.hwnd, HWND_TOPMOST, 200, 100, 400, 185, SWP_SHOWWINDOW
    Exit Sub
  End If
  
  
  TestFullPass = True
  If ReadCom.PortOpen Then
    ReadCom.PortOpen = False
  End If
  Set fso = CreateObject("Scripting.FileSystemObject")

  If WireTstBegin Then
    WireTstBegin = False
    Open App.Path & "\ResultFiles\" & TempFileName & "Wire.txt" For Append As #1
    Print #1, "---------------------------------------------"
    Print #1, "Test-Pass Wire:"
    If WireTstPass(0) Then
      Print #1, , "XPOWER1"
    Else
      TestFullPass = False
    End If
    If WireTstPass(1) Then
      Print #1, , "XPOWER2"
    Else
      TestFullPass = False
    End If
    If WireTstPass(2) Then
      Print #1, , "XLight1"
    Else
      TestFullPass = False
    End If
    If WireTstPass(3) Then
      Print #1, , "XLight2"
    Else
      TestFullPass = False
    End If

    Print #1, "---------------------------------------------"
    Print #1, "Test complete date and time:" & Format$(Now, "MM-DD-YYYY HH:MM")
    If TestFullPass Then
      Print #1, "Wiring Test PASSED."
    Else
      Print #1, "Wiring Test Failed."
    End If
    Close #1
    
    If TestFullPass Then
        fso.copyfile App.Path & "\resultfiles\" & TempFileName & "wire.txt", App.Path & "\resUltfiles\" & TempFileName & ".wir"
        fso.deletefile App.Path & "\resultfiles\" & TempFileName & "wire.txt"
    Else
        fso.deletefile App.Path & "\resultfiles\" & TempFileName & "wire.txt"
    End If
  End If
  
  Unload Me
End Sub

Private Sub WireTestMenu_Click()
  FrmFuncTest.Show
End Sub


⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?