const p1TerminalId = "0ef7e2aa-1f49-907f-be7f-b1952b36e6ea";
const p2TerminalId = "fae6d947-edae-f0a6-9bed-83b1e3724faa";
const p1Terminal = flux.getNodeById(p1TerminalId, "elementTerminal");
const p2Terminal = flux.getNodeById(p2TerminalId, "elementTerminal");
let fuseState = true;
flux.on("setup", () => {
flux.simulationModel = simModel(fuseState);
});
flux.on("inputChange", (e) => {
if (e.control_name === "Fuse") {
fuseState = true;
flux.currentSymbol = "good";
}
});
flux.on("beforeStep", () => {
flux.simulationModel = simModel(fuseState);
});
flux.on("afterStep", () => {
const current = Number(p1Terminal?.current);
const currentRating = Number(flux.properties.find((prop) => prop.name === "Current Rating")?.value);
if (Math.abs(current) > currentRating) {
fuseState = false;
}