阅读更多
#!/usr/bin/perl
#use warnings;
use DBI;
use File::Copy;
use POSIX qw(strftime);
use lib "./Uniscan";
local $bindefFile="G1466_CP3.bindef";
local $mapFile="T01_MAP.TXT";
local $outMapFile="map_result.TXT";
local $outMap2File="map2_result.TXT";
local @bin_map;
local @raw_map;
local $gi_xMax=0;
local $gi_yMax=0;
local $gi_good_bin=0;
local $gi_bin_count=0;
local $all_x_row_count=0;
#get_bin();
open (InFile,"<$mapFile")||die print LogFile "FAIL$gsRawFile Could not open raw file\n";
open (OutFile, ">$outMapFile") || die print LogFile "FAIL:$outMapFile Could not open std file $outMapFile\n";
open (Map2OutFile, ">$outMap2File") || die print LogFile "FAIL:$outMap2File Could not open std file $outMap2File\n";
local $row_count=0;
@Bin_map = qw();
@bin_map = qw();
@raw_map = qw();
get_bin();
while($line =)
{
chomp($line);
if ($line eq "") {
next;
}
###
if($row_count > 2 && index($line, "+---+") < 0){
get_map2();
}
$row_count++;
#print "$line\n";
}
map_spin();
#print $wafer_map[50][111];
print "\n";
$gi_xMax=$gi_xMax * 2;
print "X MAX is $gi_xMax\n";
print "Y MAX is $gi_yMax\n";
print "GOOD BIN COUNT is $gi_good_bin\n";
print "TOTAL BIN COUNT is $gi_bin_count\n";
print "OutFile is $outMapFile\n";
close(OutFile);
close(InFile);
### x= x(max)-x(当前下标),y= x(当前下标)
sub map_spin{
$row_count = scalar($#wafer_map)+1;
$col_count = $#{$wafer_map[0]}+1;
print "old row count: ".$row_count.",colum: $col_count"."\n";
# for (my $i = 0; $i < $row_count; $i++) {
# $map_spin_str="";
# for (my $j = 0; $j < $col_count; $j++) {
# $map_spin_str=$map_spin_str.$wafer_map[$i][$j];
# }
# print $map_spin_str;
# }
for (my $i = 0; $i < $row_count; $i++) {
for (my $j = 0; $j < $col_count; $j++) {
# $spin_map[$j][$row_count - 1 - $i] = $wafer_map[$i][$j];
$x_new=$col_count-$j;
$y_new = $i;
#顺时针90°
# $x_new=$j;
# $y_new=$row_count-$i;
# print "new: $x_new,$y_new ~ "."$i,$j\n";
$spin_map[$x_new][$y_new] = $wafer_map[$i][$j];
}
}
$col_count=$row_count;
$row_count = scalar($#spin_map)+1;
# $col_count = $#{$spin_map[0]}+1;
print "new row count: ".$row_count.",colum: $col_count"."\n";
for (my $i = 0; $i < $row_count; $i++) {
$map_spin_str="";
for (my $j = 0; $j < $col_count; $j++) {
$map_spin_str=$map_spin_str.$spin_map[$i][$j];
}
if(length($map_spin_str)>0){
print Map2OutFile $map_spin_str."\n";
}
}
}
sub get_map2{ ###one by one line extract data
my @arr;
my $mbin="";
my $mbin_no="";
my $temp_x;
my @arr_2;
if (length($line)>0){
@arr=split(" ",$line);
$map_str="";
$gi_yMax++; ###Y value increase
for(my $counter =1; $counter < $#arr+1; $counter++)
{
$mbin=$arr[$counter];
# print "$mbin-------";
if ($mbin eq "."){
###default value is "--"
###$map_str=$map_str."--";
$map_str=$map_str."---,"; ###for 3 digtials bin no
}else{
$mbin_no=hex($mbin);
$mbin_no="00".$mbin_no;
convert2binno(substr($mbin_no,length($mbin_no)-2));
###2 digitals
$mbin_no=substr($mbin_no,length($mbin_no)-3);
$map_str=$map_str.$mbin_no.",";
###%map_raw = ("x" => $l_no,"y" => $counter,"bin_no" => "$mbin_no");
%map_raw = ("x" => $counter,"y" => $gi_yMax,"bin_no" => "$mbin_no");
push(@raw_map,{%map_raw});
}
}
$temp_x=$#arr/2;
$gi_xMax=$$gi_xMax<$temp_x?$temp_x:$gi_xMax; $gi_xMax++; ###compare X value & get Max value
# $map_str=$map_str.">";
$map_str=$map_str."\n";
print OutFile $map_str;
# $map_str=$map_str.",";
@arr_2=split(",",$map_str);
for(my $i =0; $i < $#arr_2+1; $i++)
{
$wafer_map[$all_x_row_count][$i] = $arr_2[$i];
}
$all_x_row_count++;
}
}
sub get_bin{
my $line1;
my @array;
my %bin_str;
$gsBinFile=$bindefFile;
###$gsBinFile="G1152_CP.bindef";
#print "binFile: $gsBinFile\n";
open (BinFile,"<$gsBinFile")||die print LogFile "FAIL:$gsBinFile Could not open bin file:$gsBinFile!\n";
#$line1 = ;
while($line1 = )
{
chomp($line1);
# $line1 =~ tr/ //d;
@array = split(",",$line1);
$array[0] =~ tr/ //d;
$array[1] =~ tr/ //d;
$array[2] =~ tr/ //d;
$array[3] =~ tr/ //d;
#print $array[3]."\n";
# $array[1]="0".$array[1];
# use %bin_str to build a struct to storage every bin_desc
%bin_str = (
bin_no => $array[0],
bin_name => &trim($array[1]),
bin_spec => &trim($array[2]),
bin_count => 0,
bin_desc => &trim($array[3]));
# use @bin_map to storage all %bin_str
push(@bin_map,{%bin_str});
}
close(BinFile);
###foreach $cur_bin(@bin_map){
### print "BIN:::$cur_bin->{bin_no}:$cur_bin->{bin_name}:$cur_bin->{bin_spec}:$cur_bin->{bin_desc}\n";
###
###}
}
sub convert2binno(){
my($mbin_name) = @_;
my $mbin_no="---";
###print "get param value in convert function: $mbin_name\n";
foreach $cur_bin(@bin_map){
if($cur_bin->{bin_name} eq $mbin_name){
# print $cur_bin->{bin_name}."~~" .$mbin_name ."\n";
$cur_bin->{bin_count}++;
# print $cur_bin->{bin_spec};
if($cur_bin->{bin_spec} eq "G"){
++$gi_good_bin;
}
#$mbin_no="00".$cur_bin->{bin_no};
###2 digitals
#$mbin_no=substr($mbin_no,length($mbin_no)-2);
###3 digitals
###$mbin_no=substr($mbin_no,length($mbin_no)-1);
$gi_bin_count++;
last;
}
}
return $mbin_no;
}
sub trim{
my @array = @_ ;
for(@array){
s/^\s+|\s+$//g ;
}
return @array ;
}