⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 clsateresult.cls

📁 应用串口通讯, 获取产品信息, 并与SAMPLE信息比较, 自动判断产品是否合格
💻 CLS
字号:
VERSION 1.0 CLASS
BEGIN
  MultiUse = -1  'True
  Persistable = 0  'NotPersistable
  DataBindingBehavior = 0  'vbNone
  DataSourceBehavior  = 0  'vbNone
  MTSTransactionMode  = 0  'NotAnMTSObject
END
Attribute VB_Name = "clsAteResult"
Attribute VB_GlobalNameSpace = False
Attribute VB_Creatable = True
Attribute VB_PredeclaredId = False
Attribute VB_Exposed = False
Option Explicit

Private m_ModelName As String, m_StationName As String, m_PCBNumber As String, m_TestVersion As String
Private m_TrialCount As Long, m_BreakLoopOnError As Boolean
Private m_ResultFile As String
Private m_StartTime As Variant, m_EndTime As Variant, m_Duration As Long
Private m_colItems As Collection, m_colResults As Collection, m_colRemarks As Collection
Private Const ATE_VERSION_MARK = "ATE-GenX"

Const CONFIG_INI = "chkeprom.ini"

Public Property Get ModelName() As String
    ModelName = m_ModelName
End Property

Public Property Get StationName() As String
    StationName = m_StationName
End Property

Public Property Get TestDuration() As Long
    TestDuration = m_Duration
End Property

Public Property Get PcbNumber() As String
    PcbNumber = m_PCBNumber
End Property

Public Property Get TestVersion() As String
    TestVersion = m_TestVersion
End Property

Public Property Get TrialCount() As Integer
    TrialCount = m_TrialCount
End Property

Public Property Get BreakLoopOnError() As Boolean
    BreakLoopOnError = m_BreakLoopOnError
End Property

Public Property Let PcbNumber(Value As String)
    m_PCBNumber = Value
End Property

Public Property Get TestDurationInMmSs() As String
Dim sResult As String
    sResult = (m_Duration \ 60) & ":" & PadL(m_Duration Mod 60, 2, "0")
    TestDurationInMmSs = sResult
End Property

Public Property Get ResultFile() As String
    ResultFile = m_ResultFile
End Property

Public Property Get StartTime() As Variant
    StartTime = m_StartTime
End Property

Public Property Get EndTime() As Variant
    EndTime = m_EndTime
End Property

Public Sub ClearResults()
    Do While m_colItems.Count > 0
        m_colItems.Remove 1
    Loop
    
    Do While m_colResults.Count > 0
        m_colResults.Remove 1
    Loop

    Do While m_colRemarks.Count > 0
        m_colRemarks.Remove 1
    Loop
End Sub

Public Sub StartMeasurement()
    m_StartTime = Now
    m_EndTime = Empty
    m_Duration = 0
    ClearResults
End Sub

Public Sub EndMeasurement()
    m_EndTime = Now
    m_Duration = DateDiff("s", m_StartTime, m_EndTime) + 1
End Sub

Private Sub Class_Initialize()
Dim sCfgFile As String

    sCfgFile = App.Path & "\" & CONFIG_INI
    m_ModelName = ReadParam(sCfgFile, "model")
    m_StationName = ReadParam(sCfgFile, "station")
    m_ResultFile = ReadParam(sCfgFile, "result_file")
    m_TestVersion = ReadParam(sCfgFile, "test_version")
    m_TrialCount = ReadParam(sCfgFile, "trials_count")
    m_BreakLoopOnError = IIf(ReadParam(sCfgFile, "break_loop_on_error") = 1, True, False)
    
    Set m_colItems = New Collection
    Set m_colResults = New Collection
    Set m_colRemarks = New Collection
End Sub

Public Sub AddResult(ByVal ItemName As String, ByVal Result As String, Optional ByVal Remarks As String)
    m_colItems.Add ItemName
    m_colResults.Add Result
    If Remarks <> "" Then m_colRemarks.Add Remarks
End Sub


Public Sub ProduceResultFile()
Dim iFH As Integer, sLine As String, i As Integer

    On Error GoTo ProduceResultFile_Error
    iFH = FreeFile
    Open m_ResultFile For Append As #iFH
    
    Print #iFH, ""  'blank line
    Print #iFH, "ATE Version Mark : " & ATE_VERSION_MARK
    Print #iFH, "Model : " & PadR(m_ModelName, 40, , True) & " Station : " & PadR(m_StationName, 40, , True)
    Print #iFH, "Test Version : " & m_TestVersion
    Print #iFH, "PCB : " & m_PCBNumber
    Print #iFH, "Start : " & Format(m_StartTime, "d mmm yyyy hh:mm:ss") _
        & "      End : " & Format(m_EndTime, "d mmm yyyy hh:mm:ss") _
        & "      Duration : " & TestDurationInMmSs
    
    ' 60 15 15 5 4
    Print #iFH, PadR("Test Items", 60) & PadR("Lower limit", 15) & PadR("Upper limit", 15) & PadR("Unit", 5) & "Result"
    Print #iFH, String(101, "=")
    
    For i = 1 To m_colItems.Count
        Print #iFH, PadR(i, 3) & PadR(m_colItems(i), 57, , True) & String(35, " ") & m_colResults(i)
    Next
    
    Print #iFH, "Remarks :"
    For i = 1 To m_colRemarks.Count
        Print #iFH, m_colRemarks(i)
    Next
    Close #iFH
    iFH = 0
    
ProduceResultFile_Error:
    If Err <> 0 Then
        MsgBox "Cannot write result to '" & m_ResultFile & "' !" _
            & "Err: " & Err.Description _
            , vbCritical, "Result File Error"
        Err.Clear
    End If
    On Error GoTo 0
    If iFH > 0 Then Close #iFH
End Sub

⌨️ 快捷键说明

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