aboutsummaryrefslogtreecommitdiff
path: root/demo/thirdparty/olinuxino/py
diff options
context:
space:
mode:
authorTrygve Laugstøl <trygvis@inamo.no>2019-05-23 13:17:38 +0200
committerTrygve Laugstøl <trygvis@inamo.no>2019-08-01 14:54:07 +0200
commit40da2eb8bc5cad1170d689c135e53c6c180ed965 (patch)
treed1458aa8decb0d6511faddae70db5c48bda99236 /demo/thirdparty/olinuxino/py
parentb4eeed35d78f82ea988d70de177d522ca20257ea (diff)
downloadee-python-40da2eb8bc5cad1170d689c135e53c6c180ed965.tar.gz
ee-python-40da2eb8bc5cad1170d689c135e53c6c180ed965.tar.bz2
ee-python-40da2eb8bc5cad1170d689c135e53c6c180ed965.tar.xz
ee-python-40da2eb8bc5cad1170d689c135e53c6c180ed965.zip
Updating all demos.
Diffstat (limited to 'demo/thirdparty/olinuxino/py')
-rw-r--r--demo/thirdparty/olinuxino/py/olinuxino.py110
1 files changed, 0 insertions, 110 deletions
diff --git a/demo/thirdparty/olinuxino/py/olinuxino.py b/demo/thirdparty/olinuxino/py/olinuxino.py
deleted file mode 100644
index 49b634f..0000000
--- a/demo/thirdparty/olinuxino/py/olinuxino.py
+++ /dev/null
@@ -1,110 +0,0 @@
-import re
-
-from ee import EeException, EeVal
-from ee.kicad import Component
-from ee.kicad.make_bom import MakeBomStrategy
-from ee.xml import types
-from ee.part import fact_keys, Part
-
-c_value_re = re.compile("([0-9]+\\.?[0-9]*[mupn]F)/([0-9]+\\.?[0-9]*[k]?V)/([0-9]+)%(?:/([A-Z][0-9][A-Z]))?")
-r_value_re = re.compile(r"([^/]+)(?:/([^/]+)(?:/([^/]+))?)?")
-
-
-class OlinuxinoMakeBomStrategy(MakeBomStrategy):
-
- @staticmethod
- def set_default(part: Part, fact_key: str, value):
- fact = part.find_fact(fact_key)
- if fact:
- return
-
- part.get_facts().append(types.Fact(key=fact_key, value=value))
-
- def process_part(self, component: Component, part: Part):
- debug = False
-
- print(component.ref)
- print(" value={}".format(component.value))
- print(" footprint={}".format(component.footprint))
-
- v = component.value
-
- fp_lib, fp_part = None, None
- if component.footprint:
- s = component.footprint.split(":")
- fp_lib, fp_part = s[0], s[1]
-
- fs = part.get_facts()
-
- na = v.startswith("NA(") and v.endswith(")") or v == "NA"
- if na:
- v = v[3:-1]
-
- if v == "":
- pass
- elif component.ref_type == "C":
- m = c_value_re.match(v)
-
- if not m:
- raise EeException("Bad value: {}".format(v))
-
- capacitance = m.group(1)
- voltage = m.group(2)
- tolerance = str(int(m.group(3))) + "%"
- rs_198_class_2 = m.group(4)
-
- if debug:
- print(" capacitance {}".format(capacitance))
- print(" voltage {}".format(voltage))
- print(" tolerance {}".format(tolerance))
- if rs_198_class_2:
- print(" rs_198_class_2 {}".format(rs_198_class_2))
- if na:
- print(" NA".format())
-
- fs.append(types.Fact(key=fact_keys.capacitance, value=capacitance))
- fs.append(types.Fact(key=fact_keys.max_voltage, value=voltage))
- fs.append(types.Fact(key=fact_keys.value_tolerance, value=tolerance))
- if rs_198_class_2:
- fs.append(types.Fact(key=fact_keys.rs_198_class_2, value=rs_198_class_2))
-
- elif component.ref_type == "R":
- # NA
- # NA(510R)
- # NA(243R/1%)
- # 4.7k
- # 8.25k/1%
- # 120R
- # 0R(Board_Mounted)
- # 0.01R/1%/1206
-
- match = r_value_re.match(v)
- if not match:
- return part
-
- resistance, tolerance, size = match.groups()
- if resistance.endswith("R"):
- resistance = resistance[:-1]
-
- resistance = str(EeVal.parse(resistance))
-
- fs.append(types.Fact(key=fact_keys.resistance, value=resistance))
- if tolerance:
- fs.append(types.Fact(key=fact_keys.value_tolerance, value=tolerance))
- if size:
- fs.append(types.Fact(key=fact_keys.imperial_footprint_size, value=size))
-
- self.set_default(part, fact_keys.value_tolerance, "10%")
- else:
- fs.append(types.Fact(key=fact_keys.value, value=v))
-
- if na:
- fs.append(types.Fact(key=fact_keys.place_part, value="no"))
-
- # raise EeException("Unknown component kind: ref={}, ref type:{}, value={}, fp_lib={}, fp_part={}".
- # format(component.ref, component.ref_type, v, fp_lib, fp_part))
- return part
-
-
-def make_bom_strategy():
- return OlinuxinoMakeBomStrategy()