Woonsocket: ProPresenter's MIDI session connected to Lights, and watched
ProPresenter (on the Companion Mac) now reaches Lighting at 10.2.2.2:5004; Lights sees ProPresenter at 10.2.2.210:5004, both running. The MIDI key watches it (PROP LIGHTS). Auto-setup counts a link to the Companion Mac's own session once (it had listed it from both ends). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -294,17 +294,20 @@ def items(inv, nets):
|
||||
# Network MIDI: every peer in the sessions here and on the other Macs, at its wired address.
|
||||
midi_checks = []
|
||||
# Whose session a peer is, by its name: a peer joined by name or by an IPv6 address gets that Mac's wired address.
|
||||
owner = {sname: alias for alias, sessions in (inv.get("midi") or {}).items() if alias for sname in (sessions or {})}
|
||||
owner = {sname: (alias or "ingest") for alias, sessions in (inv.get("midi") or {}).items() for sname in (sessions or {})}
|
||||
ing = inv.get("ingest") or {}
|
||||
ing_ips = [ip for ip in [(ing.get("wired") or {}).get("ip")] + list(ing.get("ips") or []) if ip]
|
||||
for host, sessions in (inv.get("midi") or {}).items():
|
||||
for sname, sess in (sessions or {}).items():
|
||||
for p in sess.get("peers") or []:
|
||||
addr = p.get("address") or ""
|
||||
if not in_nets(nets, addr):
|
||||
alias = owner.get(p.get("name")) or computer_named(inv, p.get("name"))
|
||||
ip = alias and next((i for i in comps[alias].get("ips") or [] if in_nets(nets, i)), None)
|
||||
ips = ing_ips if alias == "ingest" else (comps.get(alias) or {}).get("ips") or [] if alias else []
|
||||
ip = next((i for i in ips if in_nets(nets, i)), None)
|
||||
if not ip:
|
||||
continue # no wired address known: the wired check will name it
|
||||
port = (((inv.get("midi") or {}).get(alias) or {}).get(p.get("name")) or {}).get("port") or 5004
|
||||
port = (((inv.get("midi") or {}).get("" if alias == "ingest" else alias) or {}).get(p.get("name")) or {}).get("port") or 5004
|
||||
addr = "%s:%d" % (ip, port)
|
||||
chk = {"type": "midi_peer", "session": sname, "peer": p["name"], "address": addr, "fix": "midi_reconnect",
|
||||
"tag": tag_for(p["name"])}
|
||||
@@ -320,7 +323,8 @@ def items(inv, nets):
|
||||
return any("state" in p for p in (((inv.get("midi") or {}).get(host) or {}).get(sname) or {}).get("peers") or [])
|
||||
by_pair = {}
|
||||
for ident, c in midi_checks:
|
||||
other = owner.get(c["peer"]) or computer_by_ip(inv, ip_of(c["address"])) or c["peer"]
|
||||
ip = ip_of(c["address"])
|
||||
other = owner.get(c["peer"]) or ("ingest" if ip and ip in ing_ips else None) or computer_by_ip(inv, ip) or c["peer"]
|
||||
pair = frozenset((end_of(c.get("host", "")), other))
|
||||
best = by_pair.get(pair)
|
||||
if best is None or (reports_state(c.get("host", ""), c["session"]) and not reports_state(best[1].get("host", ""), best[1]["session"])):
|
||||
|
||||
+457
-449
File diff suppressed because it is too large
Load Diff
@@ -133,6 +133,16 @@ class TestBuild(unittest.TestCase):
|
||||
cfg, _ = ac.build(BASE, inv, {"id": "ws", "name": "Woonsocket"}, "1234")
|
||||
midi = next(t for t in cfg["tiles"] if t["label"] == "MIDI")
|
||||
got = sorted((c.get("host"), c["peer"], c["address"]) for c in midi["checks"] if c["type"] == "midi_peer")
|
||||
inv["midi"][""] = {"ProPresenter": {"port": 5004, "peers": [{"name": "Lighting", "address": "10.4.2.2:5006", "state": "running"}]}}
|
||||
inv["midi"]["lights"]["Lighting"]["peers"].append({"name": "ProPresenter", "address": "10.4.1.1:5004", "state": "running"})
|
||||
cfg, _ = ac.build(BASE, inv, {"id": "ws", "name": "Woonsocket"}, "1234")
|
||||
midi = next(t for t in cfg["tiles"] if t["label"] == "MIDI")
|
||||
pairs = [(c.get("host"), c["peer"]) for c in midi["checks"] if c["type"] == "midi_peer"]
|
||||
self.assertEqual(len([p for p in pairs if "ProPresenter" in p or ("lights" not in p and "Lighting" in p and None in p)]), 1) # the Companion Mac's link counted once
|
||||
inv["midi"][""] = {}
|
||||
inv["midi"]["lights"]["Lighting"]["peers"].pop()
|
||||
cfg, _ = ac.build(BASE, inv, {"id": "ws", "name": "Woonsocket"}, "1234")
|
||||
midi = next(t for t in cfg["tiles"] if t["label"] == "MIDI")
|
||||
# One check per link: Tracks-Lights from Lights (it reports the state), Tracks-FOH from one end only.
|
||||
self.assertEqual(got, [("lights", "WS Tracks", "10.4.1.219:5004"), ("tracks", "WS FOH Mac mini", "10.4.1.12:5004")])
|
||||
self.assertEqual(schema.validate(cfg)[0], [])
|
||||
|
||||
Reference in New Issue
Block a user