[WORK] Вкладка «Матрица и порты» (25 хостов × 47 аксессуаров), комплектация и ограничения из даташитов; не дублировать кабели в BOM
This commit is contained in:
1 parent
daffbe41dd
commit
b234740dcc
6 files changed
+431
No files matched your search
@@ -58,6 +58,8 @@ class Data:
|
||||
self.mounts = load_yaml("mounts.yaml")
|
||||
self.iface = load_yaml("interfaces_verified.yaml")
|
||||
self.iface_auto = load_yaml("interfaces.yaml")
|
||||
self.pkg = load_yaml("package.yaml")
|
||||
self.limits = load_yaml("limitations.yaml")
|
||||
self.dante = load_yaml("dante.yaml")
|
||||
self.devices = {norm(d["name"]): {"name": d["name"], "role": d.get("role", "unknown")}
|
||||
for d in self.cat.get("devices") or []}
|
||||
@@ -316,6 +318,54 @@ class Data:
|
||||
return {"host": host, "host_ports": {"in": h_in, "out": h_out, "source": h_src},
|
||||
"links": links}
|
||||
|
||||
# ── матрица: хосты × аксессуары + порты ──
|
||||
def matrix(self):
|
||||
hosts = [h for h in self.hosts()]
|
||||
accs = {}
|
||||
for hk in [h["key"] for h in hosts]:
|
||||
for e in self.edges.get(hk, []):
|
||||
if not e.get("supported") or not e.get("usable", True):
|
||||
continue
|
||||
accs[norm(e["to"])] = e["to"]
|
||||
acc_list = sorted(accs.values())
|
||||
rows = []
|
||||
for h in hosts:
|
||||
hk = h["key"]
|
||||
cells = {}
|
||||
for e in self.edges.get(hk, []):
|
||||
if not e.get("supported") or not e.get("usable", True):
|
||||
continue
|
||||
k = norm(e["to"])
|
||||
q = e.get("max_qty")
|
||||
cells[k] = q if q else 1
|
||||
ins, outs, src = self.device_ports(h["name"])
|
||||
rows.append({"host": h["name"], "cells": cells,
|
||||
"ports": {"in": ins, "out": outs, "source": src}})
|
||||
return {"hosts": [r["host"] for r in rows],
|
||||
"rows": rows,
|
||||
"accessories": acc_list}
|
||||
|
||||
# ── порты всех устройств ──
|
||||
def ports_table(self):
|
||||
out = []
|
||||
for k, v in sorted(self.devices.items(), key=lambda x: x[1]["name"]):
|
||||
name = v["name"]
|
||||
ins, outs, src = self.device_ports(name)
|
||||
pkg = []
|
||||
for x in (self.pkg.get("devices") or []):
|
||||
if norm(x["device"]) == k:
|
||||
pkg = x.get("items") or []
|
||||
break
|
||||
lim = []
|
||||
for x in (self.limits.get("devices") or []):
|
||||
if norm(x["device"]) == k:
|
||||
lim = x.get("limits") or []
|
||||
break
|
||||
out.append({"device": name, "role": v["role"],
|
||||
"in": ins, "out": outs, "source": src,
|
||||
"package": pkg, "limits": lim})
|
||||
return out
|
||||
|
||||
# ── проверка ёмкости хоста ──
|
||||
def capacity(self, host_key, items):
|
||||
"""items: [[model, qty], ...]. Проверяет порты VCH, лимиты, питание."""
|
||||
@@ -577,6 +627,10 @@ class H(BaseHTTPRequestHandler):
|
||||
if p == "/api/positions":
|
||||
return self._out(D.positions(q.get("host", [""])[0],
|
||||
[x for x in q.get("need", []) if x]))
|
||||
if p == "/api/matrix":
|
||||
return self._out(D.matrix())
|
||||
if p == "/api/ports":
|
||||
return self._out(D.ports_table())
|
||||
if p == "/api/links":
|
||||
items = [x for x in q.get("item", []) if x]
|
||||
return self._out(D.link_plan(q.get("host", [""])[0], items))
|
||||
|
||||
Reference in new issue
Block a user