asw_component/__init__.py +3−0 View file@@ -0,0 +1,3 @@
1 +
from .component import execute 2 +
3 +
__all__ = ["execute"][참조 MVP] 농기계 운용 HMI — ICU 텔레메트리를 운전자용 상태·경보·진행률 View Model로 변환합니다.
https://git.agrithing.ai/tymict/agri-hmi.git 42be0a1 07d7c72 cfe9cc6 79b0483 781167f 7b0c599 781167fe8e38aa818a88704a19c246309797ef32 asw_component/__init__.py +3−0 View filefrom .component import execute__all__ = ["execute"]asw_component/component.py +13−0 View filefrom __future__ import annotationsdef execute(payload: dict) -> dict: total = max(float(payload.get("total_area_ha", 0)), 0) completed = max(float(payload.get("completed_area_ha", 0)), 0) progress = 0 if total == 0 else min(100, round(completed / total * 100)) faults = payload.get("faults", []) return { "header": {"mode": payload.get("mode", "MANUAL"), "system": "ALERT" if faults else "NORMAL"}, "motion": {"speed_mps": float(payload.get("speed_mps", 0)), "target_speed_mps": float(payload.get("target_speed_mps", 0))}, "work": {"completed_area_ha": completed, "progress_percent": progress}, "alerts": [{"code": fault, "severity": "critical"} for fault in faults], }examples/input.json +8−0 View file{ "mode": "AUTO", "speed_mps": 1.4, "target_speed_mps": 1.5, "completed_area_ha": 2.1, "total_area_ha": 3, "faults": []}pyproject.toml +8−0 View file[project]name = "agri_hmi"version = "0.1.0"description = "ICU 텔레메트리를 운전자용 상태·경보·진행률 View Model로 변환합니다."requires-python = ">=3.11"[tool.unittest]test-path = "tests"run.py +10−0 View filefrom __future__ import annotationsimport jsonimport sysfrom asw_component import executeif __name__ == "__main__": path = sys.argv[1] if len(sys.argv) > 1 else None with open(path, encoding="utf-8") if path else sys.stdin as source: payload = json.load(source) print(json.dumps(execute(payload), ensure_ascii=False, indent=2))web/index.html +1−0 View file<!doctype html><html lang="ko"><meta charset="utf-8"><title>Agricultural HMI MVP</title><style>body{margin:0;background:#09090b;color:#fafafa;font:16px system-ui}.shell{max-width:900px;margin:40px auto}.top{display:flex;justify-content:space-between}.grid{display:grid;grid-template-columns:repeat(3,1fr);gap:12px}.card{background:#18181b;border:1px solid #3f3f46;border-radius:12px;padding:24px}b{font-size:36px;color:#86efac}.ok{color:#4ade80}</style><div class="shell"><div class="top"><h1>농기계 운용 HMI</h1><strong class="ok">● NORMAL</strong></div><div class="grid"><div class="card">운전 모드<br><b>AUTO</b></div><div class="card">주행 속도<br><b>1.4</b> m/s</div><div class="card">작업 진행률<br><b>70%</b></div></div></div></html>