Option Explicit
Public Type HEADTYPE
tester As String
probcard As String
pgm As String
start As Date
end As Date
customer As String
flow As String
lotnum As String
wafernum As String
od As String
unitclean As String
unitcleandie As String
unitcleanwafer As String
unitcleanod As String
unitcleantd As String
waferclean As String
wafercleandie As String
wafercleanwafer As String
wafercleanod As String
wafercleantd As String
PosX As String
PosY As String
End Type
Dim HEAD As HEADTYPE
Public Type WMAPTYPE
X As Integer
Y As Integer
Sbin As Integer
hbin As Integer
site As Integer
retest As Integer
indextime As Double
testtime As Double
failno As Long
End Type
Dim WMAP(250000) As WMAPTYPE
Public FirstPass As Long
Public RetestPass As Long
Public GrossDie As Long
Public MinX As Integer
Public MaxX As Integer
Public MinY As Integer
Public MaxY As Integer
Public TestQTY As Long
Public LineBin As Long
Public Summaryline%
Public Mapline%, Bmapline%, Amapline%
Public X_Max%, Y_Max%, X_min%, Y_min%
Public Summary_idx As Long
Public Map_idx As Long
'--------------------------------
'--------------------------------
'----------20190509--------------
'--------------------------------
'--------bin1passbin2fail--------
Public Function funPaiXu(arr As Variant)
Dim MaxV As Variant, i As Integer, j As Integer, n As Integer, b As Integer
n = UBound(arr) - 1
For j = 0 To n - 1
For i = 0 To n - j
If arr(i) > arr(i + 1) Then
MaxV = arr(i)
arr(i) = arr(i + 1)
arr(i + 1) = MaxV
End If
Next i
Next j
funPaiXu = arr
End Function
Public Function GetBinsummary(file As String) As Boolean
Dim filenum As Integer: Dim DosTempFile As String: DosTempFile = "D:\DosTempFile"
Dim line&, summarybin As Object, Alltestbin As Object
Dim coordX&, coordY&, Sbinvalue&, sitevalue&, maxsite&, minisite&, i&, m&, n&, sitenum&, Hbinvalue&
Dim retestcord As Boolean
Dim sbinGroup(), binvalue_all&
maxsite = 0: minisite = 1: X_Max = 1: Y_Max = 1: X_min = 1: Y_min = 1
Dim str As String: Dim Linestr As String ' str:line.value
Dim strarray() As String 'strarray:arr(line.value)
Set summarybin = CreateObject("scripting.dictionary") 'use to save the Sbin and All mount
Set Alltestbin = CreateObject("scripting.dictionary")
'allnoretestbin use to get after retest data
Dim Sbin(2, -100 To 300, -100 To 300) 'Sbin.value = Sbin(1,coordY,coordX)
Dim site(-100 To 300, -100 To 300) 'site.value = site(2,coordY,coordX)
'Sbin(1, -100 To 300, -100 To 300) 'befor retest Map
'Sbin(2, -100 To 300, -100 To 300) 'after retest Map
Dim headinfo(21)
'---------------------------------
'strarray(0) coordX : strarray(1) coordY
'strarray(2) Sbin : strarray(3) Hbin
'strarray(4) site : strarray(5) Retest
'---------------------------------
LineBin = LineBin + 6
filenum = FreeFile()
Open file For Input As #filenum
Do While Not EOF(filenum)
Line Input #filenum, str
Loop
Close #filenum
str = Replace(str, Chr(10), vbCrLf)
Open DosTempFile For Output As #filenum
Print #filenum, str
Close #filenum
Open DosTempFile For Input As #filenum
Do While Not EOF(filenum)
Line Input #filenum, Linestr
line = line + 1
If 0 < line And line < 21 Then
headinfo(line) = Linestr
End If
If line > 21 And Linestr <> "" Then
strarray() = Split(Linestr, ",")
coordX = strarray(0): coordY = strarray(1)
Sbinvalue = strarray(2):: Hbinvalue = strarray(3): sitevalue = strarray(4)
Sbin(0, coordY, coordX) = Sbinvalue
site(coordY, coordX) = sitevalue
If strarray(5) = 0 Then Sbin(1, coordY, coordX) = Sbinvalue
If strarray(5) = 1 Then Sbin(2, coordY, coordX) = Sbinvalue
If sitevalue > maxsite Then maxsite = sitevalue
If sitevalue < minisite Then minisite = sitevalue
If coordX > X_Max Then X_Max = coordX
If coordX < X_min Then X_min = coordX
If coordY > Y_Max Then Y_Max = coordY
If coordY < Y_min Then Y_min = coordY
If summarybin.exists(Sbinvalue) = False Then summarybin.Add Sbinvalue, Sbinvalue
End If
Loop
Close #filenum
'Debug.Print X_Max & " " & Y_Max & " " & X_min & " " & Y_min
'X_min -12 : X_Max 24 : Y_min 0 : Y_max 35
'X-ray = 24-(-12) Y-ray = 35-0 ,offset Abs(num) 絕對值
Call MAPmake(Sbin, site, file, Mapline)
Call Bmapmake(Sbin, site, file, Bmapline)
Call Amapmake(Sbin, site, file, Amapline)
sbinGroup = summarybin.keys ' all Sbin
sbinGroup = funPaiXu(sbinGroup)
For i = 0 To UBound(sbinGroup)
Sheets("Bintable").Cells(LineBin + i, 1) = sbinGroup(i)
Next i
'-------------------------
For sitenum = minisite To maxsite
Sheets("Bintable").Cells(LineBin - 1, sitenum + 4) = "Site" & sitenum
For m = -100 To 300
For n = -100 To 300
If site(n, m) = sitenum Then
Alltestbin(Sbin(Val(Sheets("SETUP").Range("b9").Value), n, m)) = Alltestbin(Sbin(Val(Sheets("SETUP").Range("b9").Value), n, m)) + 1 '!!!!!!!
End If
Next n
Next m
For i = 0 To UBound(sbinGroup)
If Alltestbin.exists(Val(Sheets("Bintable").Cells(LineBin + i, 1))) Then
Sheets("Bintable").Cells(LineBin + i, sitenum + 4) = Alltestbin(Val(Sheets("Bintable").Cells(LineBin + i, 1)))
Else
Sheets("Bintable").Cells(LineBin + i, sitenum + 4) = 0
End If
binvalue_all = binvalue_all + Alltestbin(Val(Sheets("Bintable").Cells(LineBin + i, 1)))
Next i
Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 1, sitenum + 4) = binvalue_all
Sheets("Bintable").Cells(LineBin - 1, 1) = "Sbin"
Sheets("Bintable").Cells(LineBin - 1, 2) = "Total"
Sheets("Bintable").Cells(LineBin - 1, 3) = "Yeild"
Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 1, 1) = "aMount"
Alltestbin.RemoveAll
binvalue_all = 0
Next sitenum
'-------------------------
Dim totalbin&, sbinnummount&, sbinyeild#, siteyeild#
For i = 0 To UBound(sbinGroup) + 1
For sitenum = minisite To maxsite
sbinnummount = sbinnummount + Sheets("Bintable").Cells(LineBin + i, sitenum + 4).Value
Next sitenum
Sheets("Bintable").Cells(LineBin + i, 2) = sbinnummount
sbinnummount = 0
Next i
For i = 0 To UBound(sbinGroup)
sbinyeild = Sheets("Bintable").Cells(LineBin + i, 2) / Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 1, 2)
Sheets("Bintable").Cells(LineBin + i, 3) = sbinyeild
Sheets("Bintable").Cells(LineBin + i, 3).NumberFormatLocal = "0.00%"
Sheets("Bintable").Cells(LineBin + i, 3).Interior.ColorIndex = 35
Next i
Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 2, 1) = "Site Yeild"
For sitenum = minisite To maxsite
siteyeild = Sheets("Bintable").Cells(LineBin, sitenum + 4) / Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 1, sitenum + 4)
Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 2, sitenum + 4) = siteyeild
Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 2, sitenum + 4).NumberFormatLocal = "0.00%"
Sheets("Bintable").Cells(LineBin + UBound(sbinGroup) + 2, sitenum + 4).Interior.ColorIndex = 34
Next sitenum
Sheets("Bintable").Cells(LineBin - 2, 3) = file
LineBin = LineBin + UBound(sbinGroup)
'-----------------------------------------------------------------
'----call summary(headinfo as string)
Sheets("SUMMARY").Cells(Summaryline + 2, 1).Value = headinfo(5)
Sheets("SUMMARY").Cells(Summaryline + 2, 2).Value = headinfo(8)
Sheets("SUMMARY").Cells(Summaryline + 2, 3).Value = headinfo(6)
Sheets("SUMMARY").Cells(Summaryline + 2, 4).Value = headinfo(7)
Sheets("SUMMARY").Cells(Summaryline + 2, 5).Value = CDate(headinfo(7)) - CDate(headinfo(6))
Sheets("SUMMARY").Cells(Summaryline + 2, 6).Value = headinfo(1)
Sheets("SUMMARY").Cells(Summaryline + 2, 7).Value = headinfo(9)
Sheets("SUMMARY").Cells(Summaryline + 2, 13).Value = Split(headinfo(3))(0)
Summaryline = Summaryline + 1
' Erase Sbin
' Erase site
'
' summarybin.RemoveAll
End Function
'--------------------------------
'-----------------------------------------------------------------------------------
Function MyTrim(str As String) As String
Dim lenth As Integer
str = Trim(str)
Do
lenth = Len(str)
str = Replace(str, " ", " ")
Loop While lenth <> Len(str)
MyTrim = str
End Function
'-----------------------------------------------------------------------------------
Public Function MAPmake(Bin As Variant, site As Variant, file As String, Mapline As Integer) As Boolean
'X_min -12 : X_Max 24 : Y_min 0 : Y_max 35
'X-ray = 24-(-12) Y-ray = 35-0 ,offset Abs(num) 絕對值
'map 需要offset 1,1---> 2,2
Dim i%, j%
For i = 0 To X_Max - X_min
Sheets("MAP").Cells(Mapline + 1, i + 2).Value = i + X_min
Next i
For j = 0 To Y_Max - Y_min
Sheets("MAP").Cells(j + Mapline + 2, 1).Value = j - Y_min
Next j
For i = 0 To X_Max - X_min
For j = 0 To Y_Max - Y_min
If Bin(0, X_min + i, Y_min + j) <> " " And site(Y_min + j, X_min + i) <> "" Then
Sheets("MAP").Cells(j + Mapline + 2, i + 2).Value = Bin(0, Y_min + j, X_min + i) ' & "[" & site(Y_min + j, X_min + i) & "]"
End If
Next j
Next i
Sheets("MAP").Cells(Y_Max + Mapline + 3, 5).Value = file
Mapline = Mapline + Y_Max + 5
End Function
'-----------------------------------------------------------------------------------
Public Function Bmapmake(Bin As Variant, site As Variant, file As String, Bmapline As Integer)
Dim i%, j%
For i = 0 To X_Max - X_min
Sheets("BeferMAP").Cells(Bmapline + 1, i + 2).Value = i + X_min
Next i
For j = 0 To Y_Max - Y_min
Sheets("BeferMAP").Cells(j + Bmapline + 2, 1).Value = j - Y_min
Next j
For i = 0 To X_Max - X_min
For j = 0 To Y_Max - Y_min
If Bin(1, X_min + i, Y_min + j) <> " " Then
Sheets("BeferMAP").Cells(j + Bmapline + 2, i + 2).Value = Bin(1, Y_min + j, X_min + i) ' & "[" & site(Y_min + j, X_min + i) & "]"
End If
Next j
Next i
Sheets("BeferMAP").Cells(Y_Max + Bmapline + 3, 5).Value = file
Bmapline = Bmapline + Y_Max + 5
End Function
'-----------------------------------------------------------------------------------
Public Function Amapmake(Bin As Variant, site As Variant, file As String, Amapline As Integer)
Dim i%, j%
For i = 0 To X_Max - X_min
Sheets("AfterMAP").Cells(Amapline + 1, i + 2).Value = i + X_min
Next i
For j = 0 To Y_Max - Y_min
Sheets("AfterMAP").Cells(j + Amapline + 2, 1).Value = j - Y_min
Next j
For i = 0 To X_Max - X_min
For j = 0 To Y_Max - Y_min
If Bin(2, X_min + i, Y_min + j) <> " " Then
Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2).Value = Bin(2, Y_min + j, X_min + i)
If Val(Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2).Value) = 1 Then
Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2).Interior.ColorIndex = 33
Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2).Value = Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2) & "[" & site(Y_min + j, X_min + i) & "]"
End If
If Val(Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2).Value) > 1 Then
Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2).Interior.ColorIndex = 22
Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2).Value = Sheets("AfterMAP").Cells(j + Amapline + 2, i + 2) & "[" & site(Y_min + j, X_min + i) & "]"
End If
End If
Next j
Next i
Sheets("AfterMAP").Cells(Y_Max + Amapline + 3, 5).Value = file
Amapline = Amapline + Y_Max + 5
End Function