Initial move to app, scanning and reading basic part info works, updating info starting to work
This commit is contained in:
55
jobs.py
Normal file
55
jobs.py
Normal file
@@ -0,0 +1,55 @@
|
||||
from dataclasses import dataclass
|
||||
from typing import Optional, List
|
||||
from parsers.values import e_series_values, value_to_code
|
||||
|
||||
def rc0805fr_mpn_from_ohms(value: float) -> str:
|
||||
if value == 0: return "RC0805JR-070RL"
|
||||
return f"RC0805FR-07{value_to_code(value)}L"
|
||||
|
||||
def rc0603fr_mpn_from_ohms(value: float) -> str:
|
||||
if value == 0: return "RC0603JR-070RL"
|
||||
return f"RC0603FR-07{value_to_code(value)}L"
|
||||
|
||||
def generate_rc0805fr_e32() -> List[str]:
|
||||
values = [0.0] + e_series_values(32, rmin=1.0, rmax=1e7)
|
||||
return [rc0805fr_mpn_from_ohms(v) for v in values]
|
||||
|
||||
def generate_rc0603fr_e32() -> List[str]:
|
||||
values = [0.0] + e_series_values(32, rmin=1.0, rmax=1e7)
|
||||
return [rc0603fr_mpn_from_ohms(v) for v in values]
|
||||
|
||||
CAP_PLAN = [
|
||||
("1pF","X7R","10%","50V"), ("2.2pF","X7R","10%","50V"), ("4.7pF","X7R","10%","50V"),
|
||||
("10pF","X7R","10%","50V"), ("22pF","X7R","10%","50V"), ("47pF","X7R","10%","50V"),
|
||||
("100pF","X7R","10%","50V"),("220pF","X7R","10%","50V"),("470pF","X7R","10%","50V"),
|
||||
("1nF","X7R","10%","50V"), ("2.2nF","X7R","10%","50V"),("4.7nF","X7R","10%","50V"),
|
||||
("10nF","X7R","10%","50V"), ("22nF","X7R","10%","50V"), ("47nF","X7R","10%","50V"),
|
||||
("100nF","X7R","10%","50V"),("220nF","X7R","10%","50V"),("470nF","X7R","10%","50V"),
|
||||
("1uF","X7R","10%","50V"), ("2.2uF","X7R","10%","25V"),("4.7uF","X5R","10%","10V"),
|
||||
("10uF","X5R","10%","6.3V"),
|
||||
]
|
||||
|
||||
def _mk_cap_query(case: str, val: str, diel: str, tol: str, volt: str) -> str:
|
||||
return f"{case} {diel} {tol} {volt} {val}"
|
||||
|
||||
def generate_caps_0805_queries() -> List[str]:
|
||||
return [_mk_cap_query("0805", v, d, t, u) for (v,d,t,u) in CAP_PLAN]
|
||||
|
||||
def generate_caps_1206_dupes_for_low_v(threshold_v: float, target_v: str|None) -> List[str]:
|
||||
out = []
|
||||
def _volt_to_float(vs: str) -> float:
|
||||
try: return float(vs.lower().replace("v","").strip())
|
||||
except: return 0.0
|
||||
for (v,d,t,u) in CAP_PLAN:
|
||||
if _volt_to_float(u) < threshold_v:
|
||||
new_u = target_v or u
|
||||
out.append(_mk_cap_query("1206", v, d, t, new_u))
|
||||
return out
|
||||
|
||||
@dataclass
|
||||
class Job:
|
||||
category: str
|
||||
manufacturer: str
|
||||
footprint: Optional[str]
|
||||
seeds: List[str]
|
||||
kind: str # "resistor" | "capacitor"
|
||||
Reference in New Issue
Block a user