Subversion Repositories OpenARM Single-board Computer

Rev

Rev 331 | Rev 333 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 331 Rev 332
Line 1... Line 1...
1
#!/usr/bin/perl -w
1
#!/usr/bin/perl -w
2
use strict;
2
use strict;
3
# $Id: inventory.pl 331 2008-12-29 20:05:13Z agaran $
3
# $Id: inventory.pl 332 2008-12-29 20:40:58Z agaran $
4
# Thu, 13 Nov 2008 21:06:23 +0100
4
# Thu, 13 Nov 2008 21:06:23 +0100
5
# Maciej 'agaran' Pijanka <agaran@pld-linux.org>
5
# Maciej 'agaran' Pijanka <agaran@pld-linux.org>
6
# for OpenARM SBC Project
6
# for OpenARM SBC Project
7
# license: gpl v3
7
# license: gpl v3
8
 
8
 
Line 36... Line 36...
36
# ==================================================
36
# ==================================================
37
 
37
 
38
my %Inv_By_PartNo;
38
my %Inv_By_PartNo;
39
my @Inv;
39
my @Inv;
40
my %BomData;
40
my %BomData;
-
 
41
my %Files;
41
 
42
 
42
sub err_printf($@) {
43
sub err_printf($@) {
43
	my ($format, @args) = @_;
44
	my ($format, @args) = @_;
44
 
45
 
45
	printf STDERR "-E- ".$format."\n", @args;
46
	printf STDERR "-E- ".$format."\n", @args;
Line 287... Line 288...
287
 
288
 
288
sub parse_bom ($) {
289
sub parse_bom ($) {
289
	my ($filepath) = @_;
290
	my ($filepath) = @_;
290
 
291
 
291
	open(IN, $filepath) or return 1;
292
	open(IN, $filepath) or return 1;
-
 
293
	my $fkey = substr(basename($filepath),0,length(basename($filepath))-4);
292
 
294
 
293
	#wrn_printf("GotARg: %s", shortdir($filepath));
295
	#wrn_printf("GotARg: %s", shortdir($filepath));
294
 
296
 
295
	my @Fields;
297
	my @Fields;
296
 
298
 
Line 370... Line 372...
370
				err_printf("Different footprints for same device between sheets, script cannot ".
372
				err_printf("Different footprints for same device between sheets, script cannot ".
371
					"work around this, will use first one, but expect that output file might ".
373
					"work around this, will use first one, but expect that output file might ".
372
					"have errors.");
374
					"have errors.");
373
			}
375
			}
374
		}
376
		}
375
		push @{$BomData{$id}{Files}}, substr(basename($filepath),0,length(basename($filepath))-4);
377
		push @{$BomData{$id}{Files}}, $fkey;
-
 
378
		push @{$Files{$fkey}{$id}{RefDes}}, @{$data{$id}{RefDes}};
376
		
379
		
377
#		printf "%-20s %.4f %s\n", $Inv[$id]{Manufacturer_Partno}, $cnt, $icost, join (', ', @{$data{$id}{RefDes}});
380
#		printf "%-20s %.4f %s\n", $Inv[$id]{Manufacturer_Partno}, $cnt, $icost, join (', ', @{$data{$id}{RefDes}});
378
#		%BomData{ById}{$id}{RefDes}
381
#		%BomData{ById}{$id}{RefDes}
379
	}
382
	}
380
}
383
}
Line 542... Line 545...
542
#	$bomtable->add(' '.$n.' ', $Inv[$id]{Description}.' ', $Inv[$id]{Manufacturer_Partno}.' ', $Inv[$id]{Manufacturer}.' ',
545
#	$bomtable->add(' '.$n.' ', $Inv[$id]{Description}.' ', $Inv[$id]{Manufacturer_Partno}.' ', $Inv[$id]{Manufacturer}.' ',
543
#		$Inv[$id]{Ordercode}.' ', ' '.$quant.' ', sprintf("%.3f ",$Inv[$id]{Price}), sprintf("%.3f ",$icost));
546
#		$Inv[$id]{Ordercode}.' ', ' '.$quant.' ', sprintf("%.3f ",$Inv[$id]{Price}), sprintf("%.3f ",$icost));
544
	$bomtable->add($bn++, $Inv[$id]{Description}, $Inv[$id]{Manufacturer_Partno}, $Inv[$id]{Manufacturer},
547
	$bomtable->add($bn++, $Inv[$id]{Description}, $Inv[$id]{Manufacturer_Partno}, $Inv[$id]{Manufacturer},
545
		$Inv[$id]{Ordercode},$quant, sprintf("%.3f",$Inv[$id]{Price}), sprintf("%.3f",$icost));
548
		$Inv[$id]{Ordercode},$quant, sprintf("%.3f",$Inv[$id]{Price}), sprintf("%.3f",$icost));
546
	
549
	
547
	$parttable->add($pn++, $Inv[$id]{Description}, $Inv[$id]{Manufacturer_Partno}, $BomData{$id}{Footprint}, 
550
#	$parttable->add($pn++, $Inv[$id]{Description}, $Inv[$id]{Manufacturer_Partno}, $BomData{$id}{Footprint}, 
548
		strbreak(join (', ', sort @{$BomData{$id}{RefDes}}),43), join("\n",@{$BomData{$id}{Files}}));
551
#		strbreak(join (', ', sort @{$BomData{$id}{RefDes}}),43), join("\n",@{$BomData{$id}{Files}}));
549
}
552
}
550
 
553
 
-
 
554
 
551
printf $out "file generated at %s\n\n", scalar localtime(time());
555
printf $out "file generated at %s\n\n", scalar localtime(time());
552
 
556
 
553
print $out $bomtable->rule('-','+');
557
print $out $bomtable->rule('-','+');
554
print $out $bomtable->title();
558
print $out $bomtable->title();
555
print $out $bomtable->rule('-','+');
559
print $out $bomtable->rule('-','+');
556
print $out $bomtable->body();
560
print $out $bomtable->body();
557
print $out $bomtable->rule('-','+');
561
print $out $bomtable->rule('-','+');
558
 
562
 
559
printf $out "\nTotal cost: %.3f\n\n\n", $cost;
563
printf $out "\nTotal cost: %.3f\n\n\n", $cost;
560
 
564
 
-
 
565
 
-
 
566
foreach my $fkey (sort keys %Files) {
-
 
567
	my $rowblock = 0;
-
 
568
	$pn = 1;
-
 
569
	foreach my $id ( sort {my $p = $Inv[$a]{Manufacturer} cmp $Inv[$b]{Manufacturer}; if ($p == 0) {
-
 
570
		return $Inv[$a]{Description} cmp $Inv[$b]{Description}}; return $p; }  keys %{$Files{$fkey}}) {
-
 
571
 
-
 
572
		$parttable->add($pn++, $Inv[$id]{Description}, $Inv[$id]{Manufacturer_Partno}, $BomData{$id}{Footprint}, 
-
 
573
			strbreak(join (', ', sort @{$Files{$fkey}{$id}{RefDes}}),43), $fkey);
-
 
574
 
-
 
575
 
-
 
576
	}
-
 
577
	$parttable->add('--','=========','==========','==========','==========','==========');
-
 
578
}
-
 
579
 
561
print $out $parttable->rule('-','+');
580
print $out $parttable->rule('-','+');
562
print $out $parttable->title();
581
print $out $parttable->title();
563
print $out $parttable->rule('-','+');
582
print $out $parttable->rule('-','+');
564
print $out $parttable->body();
583
print $out $parttable->body();
565
print $out $parttable->rule('-','+');
584
print $out $parttable->rule('-','+');