// These are the unique ids of the terminal P1 and P2
// How to get a uid value of terminal
// 1. Select the terminal on the canvas
// 2. Copy the terminal to your clipboard (cmd+c or control+c)
// 3. Go to https://jsonformatter.curiousconcept.com/#, then cmd+v or control+v
// 4. Click process, then look for the field uid: XXXXXXXXX.....
const anodeTerminalElement = flux.getNodeById("de29592a-63c1-9711-6835-bb4f755b0749"); //P1
const cathodeTerminalElement = flux.getNodeById("226694b2-810c-337e-3ef8-4123591acc82"); //P2
// We need to create flux.createOutNode that we will be using in the afterStep event
const voltagePeakToPeak = flux.createOutputNode("vptop");
const currentA = flux.createOutputNode("current");
const rmsOutput = flux.createOutputNode("vrms");
// We all know this 3.14159 :D
const pi = Math.PI;
flux.on("inputChange", (e) => {
//listen for any input change on the control with name Waveform Type
if (e.control_name === "Waveform Type") {
switch (e.value) {
case 'Sinusoid': typeActive = "A"; break;