chiark / gitweb /
much improved
authorian <ian>
Wed, 14 Apr 2004 15:33:28 +0000 (15:33 +0000)
committerian <ian>
Wed, 14 Apr 2004 15:33:28 +0000 (15:33 +0000)
farnell/circuit.partlist
farnell/farnell-find

index 1f27ed676e73300a04b428b225ff55949e61d04c..d8afab456f214b78089fe046193ff8f0938ce1e6 100644 (file)
@@ -59,20 +59,20 @@ Point solenoid
  per Half-point-dil8
        476-468         1/8     330r x8 dil network
 
-Track polarity control
- per Reverse-segment
+Region polarity
+ per Region
        309-3190        1       MR82-12USR relay
        uln2803ap       1/8
        c cer 100n      1/8     decouple
 
-Block current sense
- per Sense-segment
+Segment sense
+ per Segment
        330-7578        1       CP201 bridge rectifier
        std 56r         1
        325-958         1/4     TLP521-4A optocoupler
- per Sense-segment-discrete
+ per Segment-discrete
        std 100k        1
- per Sense-segment-sil8
+ per Segment-sil8
        148-988         1/8     100k x8 sil network
        148-999         1/9     100k x9 sil network
 
@@ -97,7 +97,7 @@ Indicators
        r 0w4 390r      1
        r 0w4 180r      2
 
-Booster and power comp
+Power comp
        595-743         1       4C/W heatsink (for fet)
        167-927         1       irf5305 power fet
        287-064         1       1uF hf ceramic
index 5353b49b6c1f92775cf7848f3313f81a1bbc7bbe..040d8845fe982384bff7c62103b940a9d401275e 100755 (executable)
@@ -73,6 +73,9 @@ our($partword_re)= '\S*[^ \t0-9/=]\S*';
 our($part_re)= "$partword1_re(?: $partword_re)*";
 our($item_re)= '\d{3}\-\d{3,7}';
 
+our(%stockmap)= ('In Stock' => 'Y',
+                'Awaiting Stock' => 'A');
+
 sub by_item ($) {
     my ($itemcode) = @_;
     # looks up $itemcode (ddd-d...) at Farnell and returns
@@ -108,7 +111,6 @@ sub by_item ($) {
        $chr->{Description}= "[$partno] $chr->{Description}";
     };
     $chr->{Avail}= snarf('Stock Availability');
-    $chr->{Avail} =~ s/^Awaiting Delivery$/Awaiting/;
     $chr->{MinOrder}= snarf('Minimum Order');
     $chr->{Multiple}= snarf('Order Multiple');
     $price= snarf('Unit Price', "\n\<!--.*--\\>");
@@ -167,7 +169,8 @@ sub read_spec () {
 
 sub analyse_spec () {
     my ($part,$pd,$try,@rhs,$sp,$circuit,$iteratable,$count,$pe,$use);
-    my ($item,$qty,$ii,$bi,$toorder,$price,$total,$notechar,$desc);
+    my ($item,$qty,$ii,$bi,$toorder,$price,$total,$notechar,$desc,$ql,$qr);
+    my ($avail,%avail);
     foreach $part (keys %partdef) {
        $item= $partdef{$part};
        next if exists $itemdesc{$item};
@@ -216,6 +219,7 @@ sub analyse_spec () {
        }
     }
     $total= 0;
+    my ($desclen)= 43;
     foreach $item (sort keys %iteminstances) {
        undef $qty;
        foreach $ii (@{ $iteminstances{$item} }) {
@@ -229,9 +233,12 @@ sub analyse_spec () {
        next unless $bi;
        ($toorder,$notechar)= calcorder($qty, $bi);
        $price= $toorder * $bi->{Price};
-       printf("%5d%1s %-11s %-.35s %6.2f %6.2f %s\n",
+       $avail= $bi->{Avail};
+       $avail{$avail}= 1;
+       $avail= ' '.$stockmap{$avail} if exists $stockmap{$avail};
+       printf("%5d%1s %-11s %-.${desclen}s %6.2f %6.2f %s\n",
               $toorder, $notechar, $item, $bi->{Description},
-              $bi->{Price}, $price, $bi->{Avail})
+              $bi->{Price}, $price, $avail)
            or die $!;
        $total += $price;
        foreach $desc (@{ $itemdesc{$item} }) {
@@ -241,16 +248,25 @@ sub analyse_spec () {
                or die $!;
        }
        foreach $ii (@{ $iteminstances{$item} }) {
-           printf("%*s %11s %s\n",
+           $ql= $ii->{Qty}; $qr= '';
+           if ($ql =~ s/\D.*$//) { $qr= $&; }
+           printf("%*s %5s%-2s %s\n",
                   (5+1+5),'',
-#                 $ii->{Qty} eq '1' ? '' : $ii->{Qty},
-                  $ii->{Qty},
+                  $ql,$qr,
                   $ii->{Use})
                or die $!;
        }
+       printf "\n" or die $!;
     }
-    printf("%*s %6.2f\n", (5+1+1+11+1+35+1+6),'', $total) or die $!;
+    printf("%*s %11s %-*s %6.2f\n",
+          (5+1), 'TOTAL',
+          '',
+          ($desclen+1+6), join(' / ', sort keys %avail),
+          $total)
+       or die $!;
+    print "\n" or die $!;
     dump_warnerrs();
+    print '-'x70, "\n" or die $!;
 }
 
 sub addqty ($$$$) {