| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- """Product-specific regression checks for FCB V2.0 and FCB_FAN V2.0."""
- from __future__ import annotations
- from collections.abc import Mapping
- from .data import validate_resistor_index
- from .regression import BoardRegressionError, _pin_index
- V20_EXPECTED_COUNTS = {
- "footprints": 1457,
- "touchpoints": 74,
- "pads": 493,
- "resistors": 730,
- "resistor_pads": 1460,
- }
- V20_EXPECTED_CATEGORIES = {"CON": 41, "J": 18, "PL": 3, "TP": 12}
- V20_EXPECTED_RESISTORS = 730
- def validate_v20_mainboard_regression(payload: Mapping[str, object]) -> None:
- """Regression checks for FCB FPGA+MCU V2.0 (6400 20260914)."""
- counts = payload.get("counts")
- if not isinstance(counts, Mapping):
- raise BoardRegressionError("counts missing")
- for name, expected in V20_EXPECTED_COUNTS.items():
- if counts.get(name) != expected:
- raise BoardRegressionError(f"{name}={counts.get(name)} expected {expected}")
- categories = counts.get("categories")
- if not isinstance(categories, Mapping):
- raise BoardRegressionError("category counts missing")
- for name, expected in V20_EXPECTED_CATEGORIES.items():
- if categories.get(name) != expected:
- raise BoardRegressionError(f"{name}={categories.get(name)} expected {expected}")
- if categories.get("R") != V20_EXPECTED_RESISTORS:
- raise BoardRegressionError(f"R={categories.get('R')} expected {V20_EXPECTED_RESISTORS}")
- raw_touchpoints = payload.get("touchpoints", [])
- touchpoints = [item for item in raw_touchpoints if isinstance(item, Mapping)] if isinstance(raw_touchpoints, list) else []
- by_reference = {str(item.get("reference")): item for item in touchpoints}
- for required in ("CON12", "CON134", "CON77", "CON147", "CON148", "CON149", "CON150", "CON154", "CON155", "CON165"):
- if required not in by_reference:
- raise BoardRegressionError(f"{required} missing on V2.0 board")
- # Check CON12 (Host TTL)
- con12 = by_reference["CON12"]
- pins = _pin_index(con12)
- if "3" not in pins or (pins["3"].get("fpga") or {}).get("ball") != "K2":
- raise BoardRegressionError("CON12.3 must map to CPLD ball K2 (TX)")
- if "4" not in pins or (pins["4"].get("fpga") or {}).get("ball") != "J4":
- raise BoardRegressionError("CON12.4 must map to CPLD ball J4 (RX)")
- # Check CON134 (Host RS232)
- con134 = by_reference["CON134"]
- pins134 = _pin_index(con134)
- if "1" not in pins134 or (pins134["1"].get("fpga") or {}).get("ball") != "T14":
- raise BoardRegressionError("CON134.1 must map to CPLD ball T14 (TX)")
- if "2" not in pins134 or (pins134["2"].get("fpga") or {}).get("ball") != "R13":
- raise BoardRegressionError("CON134.2 must map to CPLD ball R13 (RX)")
- # Check CON77 (BMC RS232)
- con77 = by_reference["CON77"]
- pins77 = _pin_index(con77)
- if "1" not in pins77 or (pins77["1"].get("fpga") or {}).get("ball") != "L10":
- raise BoardRegressionError("CON77.1 must map to CPLD ball L10 (TX)")
- if "2" not in pins77 or (pins77["2"].get("fpga") or {}).get("ball") != "M9":
- raise BoardRegressionError("CON77.2 must map to CPLD ball M9 (RX)")
- try:
- validate_resistor_index(payload)
- except ValueError as exc:
- raise BoardRegressionError(str(exc)) from exc
- V20_FAN_EXPECTED_COUNTS = {
- "footprints": 33,
- "touchpoints": 7,
- "pads": 66,
- "resistors": 0,
- "resistor_pads": 0,
- }
- V20_FAN_EXPECTED_CATEGORIES = {"CON": 7, "J": 0, "PL": 0, "TP": 0}
- def validate_v20_fan_regression(payload: Mapping[str, object]) -> None:
- """Regression checks for FCB_FAN V2.0 (20260914)."""
- counts = payload.get("counts")
- if not isinstance(counts, Mapping):
- raise BoardRegressionError("counts missing")
- for name, expected in V20_FAN_EXPECTED_COUNTS.items():
- if counts.get(name) != expected:
- raise BoardRegressionError(f"{name}={counts.get(name)} expected {expected}")
- categories = counts.get("categories")
- if not isinstance(categories, Mapping):
- raise BoardRegressionError("category counts missing")
- for name, expected in V20_FAN_EXPECTED_CATEGORIES.items():
- if categories.get(name) != expected:
- raise BoardRegressionError(f"{name}={categories.get(name)} expected {expected}")
- if categories.get("R") != 0:
- raise BoardRegressionError(f"R={categories.get('R')} expected 0")
- raw_touchpoints = payload.get("touchpoints", [])
- touchpoints = [item for item in raw_touchpoints if isinstance(item, Mapping)] if isinstance(raw_touchpoints, list) else []
- by_reference = {str(item.get("reference")): item for item in touchpoints}
- for required in ("CON168", "CON8", "CON169", "CON170", "CON171", "CON2", "CON172"):
- if required not in by_reference:
- raise BoardRegressionError(f"{required} missing on FCB_FAN V2.0 board")
- try:
- validate_resistor_index(payload)
- except ValueError as exc:
- raise BoardRegressionError(str(exc)) from exc
- def validate_v2_product_regression(payload: Mapping[str, object]) -> None:
- board = payload.get("board")
- identity = f"{(board.get('id') if isinstance(board, Mapping) else '')} {(board.get('name') if isinstance(board, Mapping) else '')}".lower()
- if "fan" in identity:
- validate_v20_fan_regression(payload)
- else:
- validate_v20_mainboard_regression(payload)
|