chiark / gitweb /
counting
authorian <ian>
Wed, 14 Apr 2004 23:32:10 +0000 (23:32 +0000)
committerian <ian>
Wed, 14 Apr 2004 23:32:10 +0000 (23:32 +0000)
farnell/circuit.partlist
farnell/control.partlist
farnell/farnell-find

index 1a436fe9780ced8596105c0fbd649de3e3acdc34..1fb7410d0a9ea2b71d83826aa668b133e7c6d549 100644 (file)
@@ -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
index 42cbdfe00a76f9c1ac0bdfad831c075ab092dfe9..e0e398fc4201502751687819f10c29a3c4063d6d 100644 (file)
@@ -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
index 0c73682c790e325916e562aa79ae830a98f7dd26..3a395d5c106c3ba85c35dee14d235fbc2eb814a7 100755 (executable)
 #        Suppresses all processing for all parts matching the
 #        glob.
 #
+#   count <count> <iteratable>
+#   include <circuit>        ) use only one of
+#   exclude <circuit>        )  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= '>';
     }