jeffwilde

/

Files

Pins

Symbol

PCB

Open in Flux
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
const p1TerminalId = "9bda98af-5d5b-f366-b01d-91b6f6a3cd65";
const p2TerminalId = "c2b4734b-a628-262f-9275-fb35dc60ebf7";
const p1Terminal = flux.getNodeById(p1TerminalId, "elementTerminal");
const p2Terminal = flux.getNodeById(p2TerminalId, "elementTerminal");
const mySwitch = flux.controls.find(control => control.name === "Switch State");
if (mySwitch?.value) {
    flux.currentSymbol = "closed";
    flux.simulationModel = simModel(true);
} else {
    flux.currentSymbol = "open";
    flux.simulationModel = simModel(false);
}
flux.on("inputChange", (e: InputControlChangeEvent) => {
    if (e.control_name === "Switch State") {
        if (e.value) {
            flux.currentSymbol = "closed";
            flux.simulationModel = simModel(true);
        } else {
            flux.currentSymbol = "open";
            flux.simulationModel = simModel(false);
        }
    }
});
function simModel(stateVariable: boolean): SwitchSimulationModelConfig {
    return {
        type: "switch",
Enter to Rename, Shift+Enter to Preview

Reviews