Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 21 additions & 21 deletions packages/extension/src/inspector_bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,22 +10,22 @@ import * as vscode from "vscode";
// ============================================================================

export type RunBridgeMessage =
| { type: "run:iteration"; runId: string; iter: number; objective: number; inf_pr: number; inf_du: number }
| { type: "run:pulse-meta"; runId: string; drives: number; knots: number; labels: string[]; bounds: [number, number][]; interp?: string }
| { type: "run:pulse"; runId: string; iter: number; dt: number; values: number[][] }
| { type: "run:completion"; runId: string; fidelity: number; iterations: number; status: string }
| { type: "run:activate"; runId: string }
| { type: "run:timing"; runId: string; elapsed: number }
| { type: "run:label"; runId: string; label: string };
| { kind: "run:iteration"; runId: string; iter: number; objective: number; inf_pr: number; inf_du: number }
| { kind: "run:pulse-meta"; runId: string; drives: number; knots: number; labels: string[]; bounds: [number, number][]; interp?: string }
| { kind: "run:pulse"; runId: string; iter: number; dt: number; values: number[][] }
| { kind: "run:completion"; runId: string; fidelity: number; iterations: number; status: string }
| { kind: "run:activate"; runId: string }
| { kind: "run:timing"; runId: string; elapsed: number }
| { kind: "run:label"; runId: string; label: string };

export type DeviceBridgeMessage =
| { type: "device:status"; device: string; status: unknown }
| { type: "device:actions"; device: string; actions: unknown[] }
| { type: "device:activate"; device: string };
| { kind: "device:status"; device: string; status: unknown }
| { kind: "device:actions"; device: string; actions: unknown[] }
| { kind: "device:activate"; device: string };

export type InspectorBridgeMessage = RunBridgeMessage | DeviceBridgeMessage;
export type InspectorReverse =
| { type: "device:refresh"; device: string };
| { kind: "device:refresh"; device: string };

type Poster = (msg: unknown) => void;
const posters = new Set<Poster>();
Expand All @@ -50,48 +50,48 @@ function broadcast(msg: InspectorBridgeMessage): void {
// -------- run surface (called by RunsManager) --------

export function postRunIteration(runId: string, iter: number, objective: number, inf_pr: number, inf_du: number): void {
broadcast({ type: "run:iteration", runId, iter, objective, inf_pr, inf_du });
broadcast({ kind: "run:iteration", runId, iter, objective, inf_pr, inf_du });
}

export function postRunPulseMeta(
runId: string,
meta: { drives: number; knots: number; labels: string[]; bounds: [number, number][]; interp?: string },
): void {
broadcast({ type: "run:pulse-meta", runId, ...meta });
broadcast({ kind: "run:pulse-meta", runId, ...meta });
}

export function postRunPulse(runId: string, iter: number, dt: number, values: number[][]): void {
broadcast({ type: "run:pulse", runId, iter, dt, values });
broadcast({ kind: "run:pulse", runId, iter, dt, values });
}

export function postRunCompletion(runId: string, fidelity: number, iterations: number, status: string): void {
broadcast({ type: "run:completion", runId, fidelity, iterations, status });
broadcast({ kind: "run:completion", runId, fidelity, iterations, status });
}

export function postRunActivate(runId: string): void {
broadcast({ type: "run:activate", runId });
broadcast({ kind: "run:activate", runId });
}

export function postRunLabel(runId: string, label: string): void {
broadcast({ type: "run:label", runId, label });
broadcast({ kind: "run:label", runId, label });
}

export function postRunTiming(runId: string, elapsed: number): void {
broadcast({ type: "run:timing", runId, elapsed });
broadcast({ kind: "run:timing", runId, elapsed });
}

// -------- device surface (called by extension.ts poll) --------

export function postDeviceStatus(device: string, status: unknown): void {
broadcast({ type: "device:status", device, status });
broadcast({ kind: "device:status", device, status });
}

export function postDeviceActions(device: string, actions: unknown[]): void {
broadcast({ type: "device:actions", device, actions });
broadcast({ kind: "device:actions", device, actions });
}

export function postDeviceActivate(device: string): void {
broadcast({ type: "device:activate", device });
broadcast({ kind: "device:activate", device });
}

/** Test seam: how many posters are registered. */
Expand Down
Loading