aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2016-12-28 18:23:58 +0100
committerTrygve Laugstøl <trygvis@inamo.no>2017-01-05 09:24:41 +0100
commitb6333fc452775fa9b2ec001d72691eba541b549c (patch)
treefe22b84851de2290a6739a51225d4d68216cb053
parent73d58e1c256110a557a591cc95cf8df73dfef9a8 (diff)
downloadeda-rdf-b6333fc452775fa9b2ec001d72691eba541b549c.tar.gz
eda-rdf-b6333fc452775fa9b2ec001d72691eba541b549c.tar.bz2
eda-rdf-b6333fc452775fa9b2ec001d72691eba541b549c.tar.xz
eda-rdf-b6333fc452775fa9b2ec001d72691eba541b549c.zip
o Adding footprint check to make-bom.
-rwxr-xr-xtrygvis/eda/cli/make_bom.py48
1 files changed, 46 insertions, 2 deletions
diff --git a/trygvis/eda/cli/make_bom.py b/trygvis/eda/cli/make_bom.py
index 8d8c9f1..7805ead 100755
--- a/trygvis/eda/cli/make_bom.py
+++ b/trygvis/eda/cli/make_bom.py
@@ -1,4 +1,5 @@
from trygvis.eda import cli
+import trygvis.eda.digikey.rdf as digikey_rdf
import rdflib
@@ -74,7 +75,7 @@ ORDER BY ?ref ?field_name
cli.info("Loading Digi-Key parts for schematic")
res = cli.sparql(g, """
SELECT
-?ref ?part_number ?type ?value
+?ref ?part_number ?type ?value ?attr_type
WHERE {
?schematic kicad:component ?cmp .
?cmp a kicad-type:schematic_component ;
@@ -104,4 +105,47 @@ ORDER BY ?ref ?attr_type ?attr_value
part = dk_parts[pn]
part.set_attribute(row.type, row.value)
- cli.info('%-30s %-50s %s' % (pn, row.type + ':', row.value))
+ cli.info('%-30s %-50s %-50s %s' % (pn, row.type, row.value, row.attr_type))
+
+ cli.info("Footprint check:")
+ res = cli.sparql(g, """
+SELECT
+?ref ?footprint ?part_number ?package_value ?case_value
+# *
+WHERE {
+ ?schematic kicad:component ?cmp .
+ ?cmp a kicad-type:schematic_component ;
+ rdfs:label ?ref ;
+ kicad:field ?dk_field .
+ optional {
+ ?cmp kicad:footprint ?footprint_url .
+ ?footprint_url rdfs:label ?footprint .
+ } .
+ ?dk_field kicad:field_name "digikey" ;
+ kicad:field_value ?part_number .
+ ?part a dk:part ;
+ dk:partNumber ?part_number .
+
+ optional {
+ ?part dk:attribute-value ?package_url .
+ ?package_url rdfs:label ?package_value .
+ ?package_type a dk:attributeType ; dk:value ?package_url .
+ } .
+
+# optional {
+# ?part dk:attribute-value ?case_url .
+# ?case_url rdfs:label ?case_value .
+# ?case_type a dk:attributeType ; dk:value ?case_url .
+# } .
+
+# VALUES (?schematic_url) { (<https://trygvis/purl/kicad-board#SweetZpot+Sensor>) } .
+# VALUES (?package_type) { (dk-attr-type:pv16) } .
+# VALUES (?case_type) { (dk-attr-type:pv1291) } .
+}
+ORDER BY ?ref
+""", init_bindings={"schematic": rdflib.URIRef(schematic_url),
+ "package_type": digikey_rdf.DIGIKEY_ATTRIBUTE_TYPE["pv16"],
+ "cast_type": digikey_rdf.DIGIKEY_ATTRIBUTE_TYPE["pv1291"]})
+
+ for row in res:
+ cli.info("%-5s %-50s %-50s %s %s" % (row.ref, row.part_number, row.footprint, row.package_value, row.case_value))