aboutsummaryrefslogtreecommitdiff
path: root/src/ee/part
diff options
context:
space:
mode:
Diffstat (limited to 'src/ee/part')
-rw-r--r--src/ee/part/common_fact_types.py1
-rw-r--r--src/ee/part/fact_keys.py1
-rw-r--r--src/ee/part/requirement.py30
3 files changed, 24 insertions, 8 deletions
diff --git a/src/ee/part/common_fact_types.py b/src/ee/part/common_fact_types.py
index 10ba1eb..7474437 100644
--- a/src/ee/part/common_fact_types.py
+++ b/src/ee/part/common_fact_types.py
@@ -5,5 +5,6 @@ footprint = FactType(fact_keys.footprint, "Footprint")
resistance = EeValueFactType(fact_keys.resistance, "Resistance", ee.resistance_type)
capacitance = EeValueFactType(fact_keys.capacitance, "Capacitance", ee.capacitance_type)
+inductance = EeValueFactType(fact_keys.inductance, "Inductance", ee.inductance_type)
ee_component_type = EeValueFactType(fact_keys.ee_component_type, "EE component type", ee.capacitance_type)
diff --git a/src/ee/part/fact_keys.py b/src/ee/part/fact_keys.py
index 9617b9c..668a197 100644
--- a/src/ee/part/fact_keys.py
+++ b/src/ee/part/fact_keys.py
@@ -1,5 +1,6 @@
ee_component_type = "http://purl.org/ee/fact-type/ee-component-type"
capacitance = "http://purl.org/ee/fact-type/capacitance"
+inductance = "http://purl.org/ee/fact-type/inductance"
max_voltage = "http://purl.org/ee/fact-type/voltage"
# https://en.wikipedia.org/wiki/Ceramic_capacitor#Class_2_ceramic_capacitors
rs_198_class_2 = "http://purl.org/ee/fact-type/rs-198 class 2"
diff --git a/src/ee/part/requirement.py b/src/ee/part/requirement.py
index a9381df..297727b 100644
--- a/src/ee/part/requirement.py
+++ b/src/ee/part/requirement.py
@@ -1,6 +1,20 @@
from typing import List
-from ee.part import Part, fact_keys, FactType, common_fact_types
+from ee import EeVal
+from ee.part import Part, FactType, common_fact_types, EeValueFactType
+
+
+def to_str(part, fact_type, value, op):
+ v = None
+ if isinstance(fact_type, EeValueFactType):
+ eeft: EeValueFactType=fact_type
+ ev = EeVal.try_parse(value, eeft.ee_type.symbol)
+ v = str(ev)
+
+ if not v:
+ v = value
+
+ return "{}.{} {} {}".format(part.printable_reference, fact_type.label or fact_type.uri, op, v)
class Requirement(object):
@@ -15,7 +29,7 @@ class EqualRequirement(Requirement):
self.value = value
def __str__(self):
- return "{}.{} == {}".format(self.part.printable_reference, self.fact_type, self.value)
+ return to_str(self.part, self.fact_type, self.value, "==")
class MinRequirement(Requirement):
@@ -25,7 +39,7 @@ class MinRequirement(Requirement):
self.value = value
def __str__(self):
- return "{}.{} == {}".format(self.part.printable_reference, self.fact_type, self.value)
+ return to_str(self.part, self.fact_type, self.value, ">")
class MaxRequirement(Requirement):
@@ -35,7 +49,7 @@ class MaxRequirement(Requirement):
self.value = value
def __str__(self):
- return "{}.{} == {}".format(self.part.printable_reference, self.fact_type, self.value)
+ return to_str(self.part, self.fact_type, self.value, "<")
class PartAnalysis(object):
@@ -47,12 +61,12 @@ class PartAnalysis(object):
def analyze_requirements(part: Part) -> PartAnalysis:
rs = []
- resistance = part.find_fact(common_fact_types.resistance.uri)
+ resistance = part.facts.get_value(common_fact_types.resistance)
if resistance:
- rs.append(EqualRequirement(part, common_fact_types.resistance, resistance.valueProp))
+ rs.append(EqualRequirement(part, common_fact_types.resistance, resistance))
- capacitance = part.find_fact(common_fact_types.capacitance.uri)
+ capacitance = part.facts.get_value(common_fact_types.capacitance)
if capacitance:
- rs.append(EqualRequirement(part, common_fact_types.capacitance, capacitance.valueProp))
+ rs.append(EqualRequirement(part, common_fact_types.capacitance, capacitance))
return PartAnalysis(part, rs)