const anodeTerminalUid = "9b43137e-5678-604b-097b-07055b46b0c6";
const cathodeTerminalUid = "8d0d6e5c-9570-643c-7237-cd6c714368b5";
const anodeTerminal = flux.getNodeById(anodeTerminalUid, "elementTerminal");
const cathodeTerminal = flux.getNodeById(cathodeTerminalUid, "elementTerminal");
if (!anodeTerminal || !cathodeTerminal) {
throw new Error("Oops! Couldn't find terminals");
}
const anodeVoltageOutput = flux.createOutputNode("anode-voltage");
anodeVoltageOutput.name = "Vanode";
anodeVoltageOutput.unit = "V";
const cathodeVoltageOutput = flux.createOutputNode("cathode-voltage");
cathodeVoltageOutput.name = "Vcathode";
cathodeVoltageOutput.unit = "A";
const currentOutput = flux.createOutputNode("current");
currentOutput.name = "Current";
currentOutput.unit = "A";
function castPropertyValue(value: Readonly<PropertyValue>): number | undefined {
return value === "" ? undefined : Number(value);
}
function setModel() {
const initialAmps = Number(flux.properties.find((prop) => prop.name === "Initial Amperage")?.value ?? 0);
const pulsedAmps = Number(flux.properties.find((prop) => prop.name === "Pulsed Amperage")?.value ?? 5);
const delay = castPropertyValue(flux.properties.find((prop) => prop.name === "Delay")!.value);