aboutsummaryrefslogtreecommitdiff
path: root/trygvis/eda
diff options
context:
space:
mode:
Diffstat (limited to 'trygvis/eda')
-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))