Add getSolvedVariablesForComponent helper for UI inspection.
Some checks failed
CI / check (push) Has been cancelled

Lets the properties panel read free actuators like z_dp from the solve payload per component.

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
2026-07-19 16:55:11 +02:00
parent 586d28c745
commit 7ae7ebfc09

View File

@@ -6,7 +6,7 @@
import type { Edge, Node } from "@xyflow/react";
import type { EntropykNodeData } from "./configBuilder";
import { COMPONENT_BY_TYPE, isSecondaryPort } from "./componentMeta";
import type { SimulationResult } from "./api";
import type { SimulationResult, SolvedVariable } from "./api";
export interface PortVariable {
port: string;
@@ -225,3 +225,21 @@ function streamDutyKw(
function fmt(v: number, digits: number): string {
return Number.isFinite(v) ? v.toFixed(digits) : "—";
}
/**
* Returns the solver-computed unknowns (free actuators + calibration factors)
* attached to a given component, filtered out of `result.solved_variables`.
*
* Returns an empty array when there is no result or the component owns no
* solved variable. Globals (component === null) are excluded here — they are
* not tied to a specific diagram node.
*/
export function getSolvedVariablesForComponent(
result: SimulationResult | null,
componentName: string,
): SolvedVariable[] {
if (!result?.solved_variables?.length) return [];
return result.solved_variables.filter(
(sv) => sv.component != null && sv.component === componentName,
);
}