From: ian Date: Wed, 14 Apr 2004 23:32:10 +0000 (+0000) Subject: counting X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ijackson/git?a=commitdiff_plain;h=a82edd830cdabc87a647eb56362476a0483c7e87;p=trains.git counting --- diff --git a/farnell/circuit.partlist b/farnell/circuit.partlist index 1a436fe..1fb7410 100644 --- a/farnell/circuit.partlist +++ b/farnell/circuit.partlist @@ -74,6 +74,7 @@ Segment sense std 100k 1 per Segment-sil8 148-988 1/8 100k x8 sil network + per Segment-sil9 148-999 1/9 100k x9 sil network Serial Port diff --git a/farnell/control.partlist b/farnell/control.partlist index 42cbdfe..e0e398f 100644 --- a/farnell/control.partlist +++ b/farnell/control.partlist @@ -7,3 +7,15 @@ suppress 432-9363 # psu connectors: suppress 149-323 suppress 149-324 + +count 1 PIC +count 1 SR +count 2 Half-point +count 2 Half-point-discrete +count 0 Half-point-dil7 +count 0 Half-point-dil8 +count 1 Region +count 1 Segment +count 1 Segment-discrete +count 0 Segment-sil8 +count 0 Segment-sil9 diff --git a/farnell/farnell-find b/farnell/farnell-find index 0c73682..3a395d5 100755 --- a/farnell/farnell-find +++ b/farnell/farnell-find @@ -54,6 +54,10 @@ # Suppresses all processing for all parts matching the # glob. # +# count +# include ) use only one of +# exclude ) include and exclude +# # end # Ends the file. Optional. @@ -70,16 +74,16 @@ our(%pkinddesc); # $pkinddesc{'a b c'} => 'y' after `a b c ? = y' our(%parts); -# $parts{"$circuit\n$sper"}[]{Part} or item -# $parts{"$circuit\n$sper"}[]{Qty} -# $parts{"$circuit\n$sper"}[]{Use} -# $parts{"$circuit\n$sper"}[]{FileLine} +# $parts{"$circuit\n$iteratable"}[]{Part} or item +# $parts{"$circuit\n$iteratable"}[]{Qty} +# $parts{"$circuit\n$iteratable"}[]{Use} +# $parts{"$circuit\n$iteratable"}[]{FileLine} our(%partdef); # $partdef{"part name"}= $item; our(%count); -# $count{"$sper"} is number of times sper is instantiated +# $count{"$iteratable"} is number of times iteratable is instantiated # (no syntax for specifying this atm) our(%iteminstances); @@ -103,6 +107,9 @@ our(%show); our(%suppress_item); our(@suppress_partre); +our($incexc); # 'include' or 'exclude' +our(%incexc); # $incexc{$circuit}= 1; for those mentioned + our(@sorthow); # list of desc price avail @@ -220,6 +227,13 @@ sub read_spec ($) { $& eq '?' ? '.' : "\\$&") /ge; push @suppress_partre, $_; + } elsif (m/^count\s+(\d+)\s+([A-Z].*)$/) { + $count{$2}= $1; + } elsif (m/^(include|exclude)\s+([A-Z].*)$/) { + die "both include and exclude\n" if + defined $incexc && $incexc ne $1; + $incexc= $1; + $incexc{$2}= 1; } else { die "$_ ?"; } @@ -263,9 +277,10 @@ sub iteminstanceprint ($) { if ($ql =~ s/\D\d+$//) { $qr= $&; } if ($ql =~ s,(\d+)/[a-z]+$,,) { $qr= "$1/"; } if ($ql =~ s/\=//) { $qr .= $&; } - return sprintf("%*s %5s%-2s %s\n", + return sprintf("%*s %5s%-2s %s%s\n", (4+1+4),'', $ql,$qr, + $ii->{Mult} != 1 ? "(x$ii->{Mult}) " : '', $ii->{Use}); } @@ -297,6 +312,9 @@ sub analyse_spec () { $sp =~ m/\n/ or die "$sp ?"; $circuit= $`; $iteratable= $'; + next if + (defined $incexc && $incexc eq 'include') + xor exists $incexc{$circuit}; if (exists $count{$iteratable}) { $count= $count{$iteratable}; } else { @@ -346,6 +364,7 @@ sub analyse_spec () { $bi= $iteminfo{$item}; next unless $bi; ($toorder,$notechar)= calcorder($totalqty, $bi); + next unless $toorder > 0; $price= $toorder * $bi->{Price}; $avail= $bi->{Avail}; $avail{$avail}= 1; @@ -380,7 +399,6 @@ sub analyse_spec () { $total) or die $!; print "\n" or die $!; - dump_warnerrs(); if (keys %suppress) { print "---------- suppressed ----------\n" or die $!; foreach $item (sort { itemsortmap($a) cmp itemsortmap($b); } @@ -398,7 +416,9 @@ sub analyse_spec () { print $ii or die $!; } } + print "\n" or die $!; } + dump_warnerrs(); hrule(); } @@ -413,6 +433,7 @@ sub addqty ($$$$) { $totalqty->{Inexact}= 1; } $denom=1 if !defined $denom; + $numer *= $m2; if (defined $uniq) { die if exists $totalqty->{Uniques}{$uniq}; $totalqty->{Uniques}{$uniq}{Numer}= $numer; @@ -444,13 +465,13 @@ sub calcorder ($$) { $need += calcneed($totalqty->{Uniques}{$uniq}, undef); } $need += calcneed($totalqty, \$notechar) if exists $totalqty->{Numer}; - $need++ if !$exact; + $need++ if $need && !$exact; if ($need % $bi->{Multiple}) { $need= floor(($need + $bi->{Multiple} - 1) / $bi->{Multiple}) * $bi->{Multiple}; $notechar= '*'; } - if ($need < $bi->{MinOrder}) { + if ($need && $need < $bi->{MinOrder}) { $need= $bi->{MinOrder}; $notechar= '>'; }