[Author Prev][Author Next][Thread Prev][Thread Next][Author Index][Thread Index]

gEDA-user: (hierarchy-uref-mangle "disabled") doesn't seem to work when generting a bom



Hello group

I am doing my first hierarchial design.  In my local gnetlistrc I have
(hierarchy-uref-mangle "disabled") un-commented as I don't want the Sn_
in the front of the uref.

gsch2pcb does what I desire and correctly drops the "Sn_" prefix.

When generating a bom.  The prefix is not dropped which is NOT what I
want.

If I change from
(hierarchy-uref-order "append")
to
(hierarchy-uref-order "prepend")

The Sn_ value is placed at the end, so gnetlistrc seem to be picked up,
but I'm not sure where as I don't see it in the .scm that I'm using. 

My command line syntax is
gnetlist -g xmlbom circuit.sch -o circuit-bom.xml

I tried the nomunge option, but it didn't seem to have any effect.

gnetlist --nomunge -g xmlbom circuit.sch -o circuit-bom.xml

Yes, I am using a scheme that I hacked from gnet-bom(2?).scm  (see
attached).  So I'm probably at fault, but I don't know where.  

Could anyone give me some pointers as to what I'm doing wrong?

Thanks in advance
Mike







;;; gEDA - GPL Electronic Design Automation
;;; gnetlist - gEDA Netlist
;;; Copyright (C) 1998-2007 Ales Hvezda
;;; Copyright (C) 1998-2007 gEDA Contributors (see ChangeLog for details)
;;;
;;; This program is free software; you can redistribute it and/or modify
;;; it under the terms of the GNU General Public License as published by
;;; the Free Software Foundation; either version 2 of the License, or
;;; (at your option) any later version.
;;;
;;; This program is distributed in the hope that it will be useful,
;;; but WITHOUT ANY WARRANTY; without even the implied warranty of
;;; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
;;; GNU General Public License for more details.
;;;
;;; You should have received a copy of the GNU General Public License
;;; along with this program; if not, write to the Free Software
;;; Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.


;; --------------------------------------------------------------------------
;;
;; Bill of Material backend written by Matt Ettus starts here
;;

;;; Bill Of Materials Generator
;;; You must have a file called attribs in the pwd
;;; The file should be a text list of attributes you want listed,
;;; One per line.  No comments are allowed in the file.
;;; Questions? Contact matt@xxxxxxxxx
;;; This software is released under the terms of the GNU GPL

;;  Xml Bill of Materials backend written by Mike Crowe starts here
;; shamelessly changed to format output as an xml document
;; question on xml changes should go to mcrowe@xxxxxxxxxxxxxxxxxx
;; converts a bill of materials to a simple bom where the QNames are the 
;; schematic attribute names and the geda values are xml CText
;; from here one should be able to .xsl to parse the xml bom 
;; to ones own needs.

(use-modules (ice-9 rdelim)) ;; guile-1.8 fix

(define xmlbom
  (lambda (output-filename)
    (let ((port (if (string=? "-" output-filename)
		      (current-output-port)
		      (open-output-file output-filename)))
	  (attriblist (xmlbomparseconfig (open-input-file "attribs"))))
;      (xmlbomprintlist (cons 'refdes attriblist) port #\:)
;      (newline port)
	(display "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" port)
	(display "<bom>\n" port)
	  (display "<part>\n\t<refdes>" port)

		(xmlbomprintbom port (xmlbomcomponents packages attriblist) attriblist)
	(display "\n</bom>\n" port)
      (close-output-port port)
    )
  )
)



(define xmlbomprintbom
  (lambda (port bomlist attriblist)
    (if (not (null? bomlist))
      (if (not (null? (caar bomlist)))
; here if a reference designator
        (begin
          (display (caaar bomlist) port)
          (if (not (null? (cdaar bomlist)))
            (write-char #\, port)
          )
          (xmlbomprintbom port (cons (cons (cdaar bomlist)(cdar bomlist))(cdr bomlist)) attriblist)
        )
; else if anything else
        (begin
	  (display "</refdes>\n" port)
          (xmlbomprintlist (cdar bomlist) port #\: attriblist)
	  ( if (not (null? (cdr bomlist)))
	  	(display "\n<part>\n\t<refdes>" port)
	  )
          (xmlbomprintbom port (cdr bomlist) attriblist)
        )
      )
    )
  )
)


(define (string-insert s i t) (string-replace s t i i))

(define (xmlsearchandappend s1 sstring rstring spos)
	(let ((fpos1 (string-contains s1 sstring spos)))
	(if fpos1
		(xmlsearchandappend
		(string-insert s1 (+ 1 fpos1) rstring)
		sstring rstring
		(+ fpos1 (string-length rstring)))
		s1)))

(define xmlbomprintlist
  (lambda (ls port delimiter attriblist)
    (if (null? ls)
        #f
	(begin
	  (display "\t<" port)
	  (display (car attriblist) port)
	  (display ">" port)
	(display (xmlsearchandappend (car ls) "&" "amp;" 0) port)
;	  (display (car ls) port)
	  (display "\t</" port)
	  (display (car attriblist) port)
	  (display ">\n" port)
          (if (null? (cdr ls))
		  (display "</part>" port)
	  )
	  (xmlbomprintlist (cdr ls) port delimiter (cdr attriblist)))
    )
  )
)


; Parses attrib file. Returns a list of read attributes.
(define xmlbomparseconfig
  (lambda (port)
    (let ((read-from-file (read-delimited " \n\t" port)))
      (cond ((eof-object? read-from-file)
	     '())
	    ((= 0 (string-length read-from-file))
	     (xmlbomparseconfig port))
	    (else
	     (cons read-from-file (xmlbomparseconfig port)))
      )
    )
  )
)

(define xmlbommatch-list?
  (lambda (l1 l2)
    (cond
      ((and (null? l1)(null? l2))#t)
      ((null? l1) #f)
      ((null? l2) #f)
      ((not (string=? (car l1)(car l2)))#f)
      (#t (xmlbommatch-list? (cdr l1)(cdr l2))))))

(define xmlbommatch?
  (lambda (uref attriblist bomlist)
    (if (null? bomlist)
      (list (cons (list uref) attriblist))
      (if (xmlbommatch-list? attriblist (cdar bomlist))
;;        (cons (cons (cons uref (caar bomlist)) (cdar bomlist))(cdr bomlist))
        (cons (cons (merge (list uref) (caar bomlist) string<? ) (cdar bomlist))(cdr bomlist))
        (cons (car bomlist)(xmlbommatch? uref attriblist (cdr bomlist)))))))

(define xmlbomcomponents
  (lambda (ls attriblist)
    (if (null? ls)
      '()
      (let ((package (car ls))
            (bomlist (xmlbomcomponents (cdr ls) attriblist))
            (attribs (xmlbomfind-attribs (car ls) attriblist)))
        (if (not (string=? "unknown" (gnetlist:get-package-attribute package "nobom")))
          bomlist
          (xmlbommatch? package attribs bomlist)))
    )
  )
)

(define xmlbomfind-attribs
  (lambda (package attriblist)
    (if (null? attriblist)
	'()
	(cons (gnetlist:get-package-attribute package (car attriblist))
	      (xmlbomfind-attribs package (cdr attriblist))))))

;;
;; Bill of Material backend written by Matt Ettus ends here
;;
;; --------------------------------------------------------------------------


_______________________________________________
geda-user mailing list
geda-user@xxxxxxxxxxxxxx
http://www.seul.org/cgi-bin/mailman/listinfo/geda-user