jharwinbarrozo / SPST Switch

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 = "58eb6a95-3953-bffe-86e2-2c7e2e9b99ca";
const p2TerminalId = "74e51029-88a2-2e6a-47f8-4f3ad5f6afaf";
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