function getN(yval) {
const ystr = sprintf('%0.12e', yval);
const [A, B] = ystr.split('e');
return [parseFloat(A), parseInt(B)];
}
// Example usage:
const yval = 12345.6789;
const result = getN(yval);
console.log(result); // Output: [1.23456789, 4]
// Make sure you have the required functions getN and bestVal defined earlier.
function makeNice(ylow, yhig) {
const ydif = yhig - ylow;
const eps = ydif * 1e-6;
const [YA, YB] = getN(ydif);
const NA = parseInt(YA * 1000);
const SC = 1000 * 10 ** (-YB);
const [pcount, dval, sval] = bestVal(NA);
const dh = dval / SC;
const NH = parseInt(ylow / dh);
let ys = NH * dh;
if (ys > ylow + eps) {
NH -= 1;
ys = NH * dh;
}
let YS = NH * dval;
ys = NH * dh;
let ysMin = ys;
const ysList = [];
let icnt = 0;
let done = false;
while (!done) {
done = icnt < 1000 && ys > yhig - eps;
if (YS % sval === 0) {
ysList.push([ys, true]);
} else {
ysList.push([ys, false]);
}
NH += 1;
YS = NH * dval;
ys = NH * dh;
icnt += 1;
}
let ysMax = ys;
return [ysMin, ysMax, ysList];
}
// Example usage:
const ylow = 1000;
const yhigh = 2000;
const result = makeNice(ylow, yhigh);
console.log(result);
// * ********************************************************************************
// * ********************************************************************************
// * * plotChart function ***********************************************************
// * ********************************************************************************
function plotChart() {
// * ***********************************************************
// * Get the Line Style - ptypeType
// * ***********************************************************
let ptypeType = "";
if (plotgRadio_line.checked) {
ptypeType = plotgRadio_line.value;
} else if (plotgRadio_pnts.checked) {
ptypeType = plotgRadio_pnts.value;
} else if (plotgRadio_both.checked) {
ptypeType = plotgRadio_both.value;
}
// * ***********************************************************
// * ***********************************************************
// * Get the Linear or Log Type - plotYType
// * ***********************************************************
let plotYType = "";
if (plot1Radio_lin.checked) {
plotYType = plot1Radio_lin.value;
} else if (plot1Radio_log.checked) {
plotYType = plot1Radio_log.value;
}
// * ***********************************************************
// * ***********************************************************
// * Get the Linear or Log Type - plotZType
// * ***********************************************************
let plotZType = "";
if (plot2Radio_lin.checked) {
plotZType = plot2Radio_lin.value;
} else if (plot2Radio_log.checked) {
plotZType = plot2Radio_log.value;
}
// * ***********************************************************
console.log('Dogs');
console.log(ptypeType);
console.log(plotYType);
console.log(plotZType);
console.log('Cats');
// * ***********************************************************
// * Get the plot limits
// * ***********************************************************
const valXList = [];
const labXList = [];
const valYList = [];
const labYList = [];
const valZList = [];
const labZList = [];
let numYs, numZs;
let rangeYmin, rangeYmax;
let rangeZmin, rangeZmax;
let jval = 0.0;
let jval_next = 0.0;
let jstr = "";
let dx = 0.0;
let dy = 0.0;
let dz = 0.0;
const xminStr = document.getElementById("xmingInput").value;
const xmaxStr = document.getElementById("xmaxgInput").value;
const xdivStr = document.getElementById("xticgInput").value
const [xticStr, xsubStr] = getStr2(xdivStr);
const yminStr = document.getElementById("ymin1Input").value;
const ymaxStr = document.getElementById("ymax1Input").value;
const ydivStr = document.getElementById("ytic1Input").value
const [yticStr, ysubStr] = getStr2(ydivStr);
const zminStr = document.getElementById("ymin2Input").value;
const zmaxStr = document.getElementById("ymax2Input").value;
const zdivStr = document.getElementById("ytic2Input").value
const [zticStr, zsubStr] = getStr2(zdivStr);
// * ***********************************************************
// * Set up the x-axis labels
// * ***********************************************************
let [xminVal, xminSet] = gregFloat(xminStr);
let [xmaxVal, xmaxSet] = gregFloat(xmaxStr);
let [xticVal, xticSet] = gregInt(xticStr);
let [xsubVal, xsubSet] = gregInt(xsubStr);
let rangeXmin = (xminSet) ? xminVal : xmin;
let rangeXmax = (xmaxSet) ? xmaxVal : xmax;
const xfmt = (xmaxSet) ? getFmt(xmaxStr) : (xminSet) ? getFmt(xminStr) : '%0.3f';
const subX = (xsubSet) ? xsubVal : 1;
const numX = (xticSet) ? xticVal : 10;
const numXs = subX * numX;
dx = (rangeXmax - rangeXmin) / numXs;
jval = rangeXmin;
jstr = "";
for (let i = 0; i < numX; i++) {
for (let j = 0; j < subX; j++) {
jstr = (j === 0) ? sprintf(xfmt, jval) : "";
labXList.push(jstr);
valXList.push(jval);
jval += dx;
}
}
jstr = sprintf(xfmt, jval);
labXList.push(jstr);
valXList.push(jval);
console.log("LABELS X : BEGIN");
console.log(labXList);
console.log(valXList);
console.log("LABELS X : END");
// * ***********************************************************
// * ***********************************************************
// * Create myPlotY
// * ***********************************************************
if (true) {
// * ***********************************************************
// * Set up the y-axis labels
// * ***********************************************************
let [yminVal, yminSet] = gregFloat(yminStr);
let [ymaxVal, ymaxSet] = gregFloat(ymaxStr);
let [yticVal, yticSet] = gregInt(yticStr);
let [ysubVal, ysubSet] = gregInt(ysubStr);
rangeYmin = (yminSet) ? yminVal : ymin;
rangeYmax = (ymaxSet) ? ymaxVal : ymax;
const yfmt = (ymaxSet) ? getFmt(ymaxStr) : (yminSet) ? getFmt(yminStr) : '%0.4e';
const subY = (ysubSet) ? ysubVal : 1;
let numY = (yticSet) ? yticVal : 10;
numYs = subY * numY;
if (plotYType === 'log') {
let nmax = Math.floor(Math.log10(ymax)) - 1.0;
let ymax_log = Math.pow(10.0, nmax);
while (ymax_log < (rangeYmax * 0.99999)) {
ymax_log *= 10.0;
nmax += 1;
}
rangeYmax = Math.pow(10.0, nmax);
let nmin = nmax - 2;
let ymin_log = Math.pow(10.0, nmin);
if (yminSet) {
while ((ymin_log > (rangeYmin * 1.00001)) && ((nmax - nmin) < 15)) {
ymin_log /= 10.0;
nmin -= 1;
}
} else {
while ((ymin_log > (rangeYmin * 1.00001)) && ((nmax - nmin) < numY)) {
ymin_log /= 10.0;
nmin -= 1;
}
}
rangeYmin = Math.pow(10.0, nmin);
numY = nmax - nmin;
let alpha = Math.pow(rangeYmax / rangeYmin, 1.0/numY);
jval = rangeYmin;
for (let i = 0; i < numY; i++) {
for (let j = 0; j < subY; j++) {
if (j === 0) {
jstr = sprintf(yfmt, jval);
jval_next = jval * alpha;
dy = jval_next / subY;
labYList.push(jstr);
valYList.push(jval);
jval = 0.0;
} else {
jstr = "";
labYList.push(jstr);
valYList.push(jval);
}
jval += dy;
}
}
jstr = sprintf(yfmt, jval);
labYList.push(jstr);
valYList.push(jval);
rangeYmax = Math.log10(rangeYmax);
rangeYmin = Math.log10(rangeYmin);
} else {
dy = (rangeYmax - rangeYmin) / numYs;
jval = rangeYmin;
jstr = "";
for (let i = 0; i < numY; i++) {
for (let j = 0; j < subY; j++) {
jstr = (j === 0) ? sprintf(yfmt, jval) : "";
labYList.push(jstr);
valYList.push(jval);
jval += dy;
}
}
jstr = sprintf(yfmt, jval);
labYList.push(jstr);
valYList.push(jval);
}
console.log("LABELS Y : BEGIN");
console.log(labYList);
console.log(valYList);
console.log("LABELS Y : END");
// * ***********************************************************
// * ***********************************************************
// * Create dataYsets to hold multiple traces
// * ***********************************************************
const dataY = [];
let namstr = octv1Name;
// Loop through yarr and create a trace for each row
for (let i = 0; i < yarr.length; i++) {
if (yarr.length > 1) {
namstr = octv1Name + "(" + fixv1Name + "=" + parr[i].toFixed(3) + ")";
}
const trace = {
x: xarr,
y: yarr[i],
mode: ptypeType,
name: namstr,
marker: {
size: 6,
line: {
width: 2,
},
},
};
dataY.push(trace);
}
dataY.reverse();
// * ***********************************************************
// * ***********************************************************
// * Create layoutY to configure myPlotY
// * ***********************************************************
// Define layoutY options, including tickformat for the y-axis
const layoutY = {
margin: {
l: 120,
b: 100,
r: 80,
t: 100,
},
title: {
text: modName + ' : ' + plot1Name + ' vs ' + sweepName,
font: {
size: 20, // Adjust the font size of the title
},
},
xaxis: {
nticks: numXs,
tickmode: 'array',
tickvals: valXList,
ticktext: labXList,
linewidth: 2,
title: {
text: sweepName,
font: {
size: 20, // Adjust the font size of the title
},
standoff: 20,
},
type: 'linear', // You can specify the type of the x-axis
range: [rangeXmin, rangeXmax], // Set the x-axis range
fixedrange : true,
tickwidth: 2,
ticklen: 2,
},
yaxis: {
nticks: numYs,
tickmode: 'array',
tickvals: valYList,
ticktext: labYList,
linewidth: 2,
position: 0,
title: {
text: plot1Name,
font: {
size: 20, // Adjust the font size of the title
},
standoff: 0,
},
range: [rangeYmin, rangeYmax],
// autorange: true,
type: plotYType,
fixedrange: true,
tickwidth: 2,
ticklen: 2,
},
showlegend: true,
height: 500,
dragmode: false,
};
// * ***********************************************************
Plotly.newPlot('myPlotY', dataY, layoutY);
}
// * ***********************************************************
// * ***********************************************************
// * Create myPlotZ
// * ***********************************************************
if (plot2Name !== '---') {
// * ***********************************************************
// * Set up the z-axis labels
// * ***********************************************************
let [zminVal, zminSet] = gregFloat(zminStr);
let [zmaxVal, zmaxSet] = gregFloat(zmaxStr);
let [zticVal, zticSet] = gregInt(zticStr);
let [zsubVal, zsubSet] = gregInt(zsubStr);
rangeZmin = (zminSet) ? zminVal : zmin;
rangeZmax = (zmaxSet) ? zmaxVal : zmax;
const zfmt = (zmaxSet) ? getFmt(zmaxStr) : (zminSet) ? getFmt(zminStr) : '%0.4e';
const subZ = (zsubSet) ? zsubVal : 1;
let numZ = (zticSet) ? zticVal : 10;
numZs = subZ * numZ;
if (plotZType === 'log') {
let nmax = Math.floor(Math.log10(zmax)) - 1.0;
let zmax_log = Math.pow(10.0, nmax);
while (zmax_log < (rangeZmax * 0.99999)) {
zmax_log *= 10.0;
nmax += 1;
}
rangeZmax = Math.pow(10.0, nmax);
let nmin = nmax - 2;
let zmin_log = Math.pow(10.0, nmin);
if (zminSet) {
while ((zmin_log > (rangeZmin * 1.00001)) && ((nmax - nmin) < 15)) {
zmin_log /= 10.0;
nmin -= 1;
}
} else {
while ((zmin_log > (rangeZmin * 1.00001)) && ((nmax - nmin) < numZ)) {
zmin_log /= 10.0;
nmin -= 1;
}
}
rangeZmin = Math.pow(10.0, nmin);
numZ = nmax - nmin;
let alpha = Math.pow(rangeZmax / rangeZmin, 1.0/numZ);
jval = rangeZmin;
for (let i = 0; i < numZ; i++) {
for (let j = 0; j < subZ; j++) {
if (j === 0) {
jstr = sprintf(zfmt, jval);
jval_next = jval * alpha;
dz = jval_next / subZ;
labZList.push(jstr);
valZList.push(jval);
jval = 0.0;
} else {
jstr = "";
labZList.push(jstr);
valZList.push(jval);
}
jval += dz;
}
}
jstr = sprintf(zfmt, jval);
labZList.push(jstr);
valZList.push(jval);
rangeZmax = Math.log10(rangeZmax);
rangeZmin = Math.log10(rangeZmin);
} else {
dz = (rangeZmax - rangeZmin) / numZs;
jval = rangeZmin;
jstr = "";
for (let i = 0; i < numZ; i++) {
for (let j = 0; j < subZ; j++) {
jstr = (j === 0) ? sprintf(zfmt, jval) : "";
labZList.push(jstr);
valZList.push(jval);
jval += dz;
}
}
jstr = sprintf(zfmt, jval);
labZList.push(jstr);
valZList.push(jval);
}
console.log("LABELS Z : BEGIN");
console.log(labZList);
console.log(valZList);
console.log("LABELS Z : END");
// * ***********************************************************
// * ***********************************************************
// * Create dataZsets to hold multiple traces
// * ***********************************************************
const dataZ = [];
let namstr = octv2Name;
// Loop through zarr and create a trace for each row
for (let i = 0; i < zarr.length; i++) {
if (zarr.length > 1) {
namstr = octv2Name + "(" + fixv1Name + "=" + parr[i].toFixed(3) + ")";
}
const trace = {
x: xarr,
y: zarr[i],
mode: ptypeType,
name: namstr,
marker: {
size: 6,
line: {
width: 2,
},
},
};
dataZ.push(trace);
}
dataZ.reverse();
// * ***********************************************************
// * ***********************************************************
// * Create layoutZ to configure myPlotZ
// * ***********************************************************
// Define layoutZ options, including tickformat for the z-axis
const layoutZ = {
margin: {
l: 120,
b: 100,
r: 80,
t: 100,
},
title: {
text: modName + ' : ' + plot2Name + ' vs ' + sweepName,
font: {
size: 20, // Adjust the font size of the title
},
},
xaxis: {
nticks: numXs,
tickmode: 'array',
tickvals: valXList,
ticktext: labXList,
linewidth: 2,
title: {
text: sweepName,
font: {
size: 20, // Adjust the font size of the title
},
standoff: 20,
},
type: 'linear', // You can specify the type of the x-axis
range: [rangeXmin, rangeXmax], // Set the x-axis range
fixedrange : true,
tickwidth: 2,
ticklen: 2,
},
yaxis: {
nticks: numZs,
tickmode: 'array',
tickvals: valZList,
ticktext: labZList,
linewidth: 2,
position: 0,
title: {
text: plot2Name,
font: {
size: 20, // Adjust the font size of the title
},
standoff: 0,
},
range: [rangeZmin, rangeZmax],
// autorange: true,
type: plotZType,
fixedrange: true,
tickwidth: 2,
ticklen: 2,
},
showlegend: true,
height: 500,
dragmode: false,
};
// * ***********************************************************
Plotly.newPlot('myPlotZ', dataZ, layoutZ);
} else {
Plotly.purge('myPlotZ');
}
// * ***********************************************************
console.log("Hi Greg");
// * ***********************************************************
// * Create myPlotW
// * ***********************************************************
if (plot3Name !== '---') {
console.log("Hi Greg 1");
// * ***********************************************************
// * Grab Y and Z --> U and V
// * ***********************************************************
let octvVName;
let plotVName;
let titleV;
let numVs;
let valVList;
let labVList;
let plotVType;
let rangeVmin, rangeVmax;
let varr;
let plotUName;
let titleU;
let numUs;
let valUList;
let labUList;
let plotUType;
let rangeUmin, rangeUmax;
let uarr;
if (plot3Name === "P1VSP2") {
console.log("Hi Greg A");
octvVName = octv1Name;
console.log("Hi Greg AY1");
plotVName = plot1Name;
titleV = plotVName;
console.log("Hi Greg AY2");
numVs = numYs;
console.log("Hi Greg AY3");
valVList = valYList;
labVList = labYList;
console.log("Hi Greg AY4");
plotVType = plotYType;
console.log("Hi Greg AX1");
[rangeVmin, rangeVmax] = [rangeYmin, rangeYmax];
console.log("Hi Greg AX2");
plotUName = plot2Name;
titleU = plotUName;
numUs = numZs;
valUList = valZList;
labUList = labZList;
plotUType = plotZType;
[rangeUmin, rangeUmax] = [rangeZmin, rangeZmax];
varr = yarr;
uarr = zarr;
console.log("Hi Greg AX3");
} else if (plot3Name === "P2VSP1") {
console.log("Hi Greg B");
octvVName = octv2Name;
plotVName = plot2Name;
titleV = plotVName;
numVs = numZs;
valVList = valZList;
labVList = labZList;
plotVType = plotZType;
[rangeVmin, rangeVmax] = [rangeZmin, rangeZmax];
plotUName = plot1Name;
titleU = plotUName;
numUs = numYs;
valUList = valYList;
labUList = labYList;
plotUType = plotYType;
[rangeUmin, rangeUmax] = [rangeYmin, rangeYmax];
varr = zarr;
uarr = yarr;
} else {
console.log("Hi Greg C");
putmsg(1, 'Error : Unexpected plot3name\nNo Plot Submitted');
return;
}
// * ***********************************************************
console.log("Hi Greg D");
// * ***********************************************************
// * Create dataWsets to hold multiple traces
// * ***********************************************************
const dataW = [];
let namstr = octvVName;
// Loop through varr and create a trace for each row
for (let i = 0; i < varr.length; i++) {
if (varr.length > 1) {
namstr = fixv1Name + "=" + parr[i].toFixed(3);
}
const trace = {
x: uarr[i],
y: varr[i],
mode: ptypeType,
name: namstr,
marker: {
size: 6,
line: {
width: 2,
},
},
};
dataW.push(trace);
}
console.log("Hi Greg E");
dataW.reverse();
console.log("Hi Greg K1");
// * ***********************************************************
// * ***********************************************************
// * Create layoutW to configure myPlotW
// * ***********************************************************
// Define layoutW options, including tickformat for the z-axis
const layoutW = {
margin: {
l: 120,
b: 100,
r: 80,
t: 100,
},
title: {
text: modName + ' : ' + plotVName + ' vs ' + plotUName,
font: {
size: 20, // Adjust the font size of the title
},
},
xaxis: {
nticks: numUs,
tickmode: 'array',
tickvals: valUList,
ticktext: labUList,
linewidth: 2,
title: {
text: plotUName,
font: {
size: 20, // Adjust the font size of the title
},
standoff: 20,
},
type: plotUType, // You can specify the type of the x-axis
range: [rangeUmin, rangeUmax], // Set the x-axis range
fixedrange : true,
tickwidth: 2,
ticklen: 2,
},
yaxis: {
nticks: numVs,
tickmode: 'array',
tickvals: valVList,
ticktext: labVList,
linewidth: 2,
position: 0,
title: {
text: plotVName,
font: {
size: 20, // Adjust the font size of the title
},
standoff: 0,
},
range: [rangeVmin, rangeVmax],
// autorange: true,
type: plotVType,
fixedrange: true,
tickwidth: 2,
ticklen: 2,
},
showlegend: true,
height: 500,
dragmode: false,
};
console.log("Hi Greg K2");
// * ***********************************************************
Plotly.newPlot('myPlotW', dataW, layoutW);
} else {
Plotly.purge('myPlotW');
}
// * ***********************************************************
console.log("Hi Greg 2");
}
// * ********************************************************************************
// * ********************************************************************************
// * * mosGetData function **********************************************************
// * ********************************************************************************
function mosGetData(mod_str, out_str, vds_str, vgs_str, vsb_str, cmd_str) {
const requestData = {
mod_str: mod_str,
out_str: out_str,
vds_str: vds_str,
vgs_str: vgs_str,
vsb_str: vsb_str,
cmd_str: cmd_str,
};
return fetch('/runOctave', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify(requestData),
})
.then(response => {
console.log('Response received:', response);
return response.json();
})
.then(data => {
console.log('Data received:', data);
return {
syserr: data.syserr,
stdout: data.stdout,
stderr: data.stderr
};
})
.catch(error => {
console.log('JavaScript Catch : ', error);
return {
syserr: "error - Octave Error" + "\n" + data.syserr,
stdout: data.stdout,
stderr: "error - Octave Error" + "\n" + data.stderr,
};
});
}
// * ********************************************************************************
let globalData1 = [];
let globalData2 = [];
let vds_set;
let vgs_set;
let vsb_set;
let l_set;
// * ********************************************************************************
// * * doIt function (submit fetch request / receive data / plot chart) ***********
// * ********************************************************************************
async function doIt() {
let jsonData;
let parsData;
try {
vds_set = false;
vgs_set = false;
vsb_set = false;
l_set = false;
vds_str = "";
vgs_str = "";
vsb_str = "";
l_str = "";
if (sweepName === 'VDS') {
vds_set = true;
vds_str = sweepInput.value;
} else if (sweepName === 'VGS') {
vgs_set = true;
vgs_str = sweepInput.value;
} else if (sweepName === 'VSB') {
vsb_set = true;
vsb_str = sweepInput.value;
} else if (sweepName === 'L') {
l_set = true;
l_str = sweepInput.value;
}
if (fixv1Name === 'VDS') {
vds_set = true;
vds_str = fixv1Input.value;
} else if (fixv1Name === 'VGS') {
vgs_set = true;
vgs_str = fixv1Input.value;
} else if (fixv1Name === 'VSB') {
vsb_set = true;
vsb_str = fixv1Input.value;
} else if (fixv1Name === 'L') {
l_set = true;
l_str = fixv1Input.value;
}
if (fixv2Name === 'VDS') {
vds_set = true;
vds_str = fixv2Input.value;
} else if (fixv2Name === 'VGS') {
vgs_set = true;
vgs_str = fixv2Input.value;
} else if (fixv2Name === 'VSB') {
vsb_set = true;
vsb_str = fixv2Input.value;
} else if (fixv2Name === 'L') {
l_set = true;
l_str = fixv2Input.value;
}
if (fixv3Name === 'VDS') {
vds_set = true;
vds_str = fixv3Input.value;
} else if (fixv3Name === 'VGS') {
vgs_set = true;
vgs_str = fixv3Input.value;
} else if (fixv3Name === 'VSB') {
vsb_set = true;
vsb_str = fixv3Input.value;
} else if (fixv3Name === 'L') {
l_set = true;
l_str = fixv3Input.value;
}
if (!vds_set) {
console.log('Error : VDS not set');
putmsg(1, 'Error : VDS not set\nNo Plot Submitted');
return;
}
if (!vgs_set) {
console.log('Error : VGS not set');
putmsg(1, 'Error : VGS not set\nNo Plot Submitted');
return;
}
if (!vsb_set) {
console.log('Error : VSB not set');
putmsg(1, 'Error : VSB not set\nNo Plot Submitted');
return;
}
if (!l_set) {
console.log('Error : L not set');
putmsg(1, 'Error : L not set\nNo Plot Submitted');
return;
}
let numv;
numv = checkRange(vds_str, 'VDS')
if (numv === -1) {
putmsg(1, 'Error : VDS numeric format\nNo Plot Submitted');
return;
} else if (numv === -2) {
putmsg(1, 'Error : VDS out of range\nNo Plot Submitted');
return;
}
numv = checkRange(vgs_str, 'VGS')
if (numv === -1) {
putmsg(1, 'Error : VGS numeric format\nNo Plot Submitted');
return;
} else if (numv === -2) {
putmsg(1, 'Error : VGS out of range\nNo Plot Submitted');
return;
}
numv = checkRange(vsb_str, 'VSB')
if (numv === -1) {
putmsg(1, 'Error : VSB numeric format\nNo Plot Submitted');
return;
} else if (numv === -2) {
putmsg(1, 'Error : VSB out of range\nNo Plot Submitted');
return;
}
numv = checkRange(l_str, 'L')
if (numv === -1) {
putmsg(1, 'Error : L numeric format\nNo Plot Submitted');
return;
} else if (numv === -2) {
putmsg(1, 'Error : L out of range\nNo Plot Submitted');
return;
}
vds_str = '[' + vds_str + ']';
vgs_str = '[' + vgs_str + ']';
vsb_str = '[' + vsb_str + ']';
l_str = '[' + l_str + ']';
console.log('OUTA : ', octv1Name);
console.log('OUTB : ', octv2Name);
console.log('VDS : ', vds_str);
console.log('VGS : ', vgs_str);
console.log('VSB : ', vsb_str);
console.log('L : ', l_str);
const gregResponse = await mosGetData(modName, octv1Name, vds_str, vgs_str, vsb_str, l_str);
const { stdout: gregData, stderr: gregError, syserr: gregSyserr } = gregResponse;
console.log('* *****************************');
console.log('* * ', plot1Name, ' --> ', octv1Name);
console.log('* *****************************');
console.log(gregData);
console.log(gregError);
console.log(gregSyserr);
console.log('');
if (gregError && gregError.includes("error")) {
console.error('Octave Error:', gregError);
putmsg(1, "Octave Error - No Plot " + octv1Name + "\n" + gregError + "\n" + gregSyserr);
return;
}
jsonData = gregData;
parsData = JSON.parse(jsonData);
console.log('* ****88888********************');
console.log(parsData);
console.log('* ****88888********************');
console.log('* ****99999********************');
console.log(sweepName);
console.log(parsData['VDS']);
xarr = parsData[sweepName];
parr = parsData[fixv1Name];
console.log("Hi B");
yarr = [];
console.log("Hi C");
for (let i = 0; i < parr.length; i++) {
const key = "row" + (i + 1);
yarr.push(parsData[key]);
}
console.log("Hello");
console.log(xarr);
console.log(yarr[0]);
console.log("World");
xmin = Math.min(...xarr);
xmax = Math.max(...xarr);
const flatYarr = yarr.flat();
ymin = Math.min(...flatYarr);
ymax = Math.max(...flatYarr);
console.log('JSON RawD : ', jsonData);
console.log('JSON Data : ', parsData); // Parse the JSON data
console.log('* *****************************');
putmsg(0, "HI Greg " + xmin.toFixed(3));
if (plot2Name !== '---') {
const zoutResponse = await mosGetData(modName, octv2Name, vds_str, vgs_str, vsb_str, l_str);
const { stdout: zoutData, stderr: zoutError, syserr: zoutSyserr } = zoutResponse;
console.log('* *****************************');
console.log('* * ', plot2Name, ' --> ', octv2Name);
console.log('* *****************************');
console.log(zoutData);
console.log(zoutError);
console.log(zoutSyserr);
console.log('');
if (zoutError && zoutError.includes("error")) {
console.error('Octave Error:', zoutError);
putmsg(1, "Octave Error - No Plot " + octv2Name + "\n" + zoutError + "\n" + zoutSyserr);
return;
}
jsonData = zoutData;
parsData = JSON.parse(jsonData);
console.log('* ****8zout********************');
console.log(parsData);
console.log('* ****8zout********************');
console.log('* ****9zout********************');
zarr = [];
console.log("Hi Czout");
for (let i = 0; i < parr.length; i++) {
const key = "row" + (i + 1);
zarr.push(parsData[key]);
}
console.log("Hello_zout");
console.log(xarr);
console.log(zarr[0]);
console.log("World_zout");
const flatZarr = zarr.flat();
zmin = Math.min(...flatZarr);
zmax = Math.max(...flatZarr);
console.log('JSON RawD zout : ', jsonData);
console.log('JSON Data zout : ', parsData); // Parse the JSON data
console.log('* *****************************');
}
await plotChart();
console.log('Warnings : ', warnings.trim());
} catch (error) {
putmsg(1, "Ouch");
// Handle errors here
}
console.log('* *****************************');
console.log('GLB1 Data : ', globalData1);
console.log('GLB2 Data : ', globalData2);
console.log('* *****************************');
var xstr = sweepInput.value;
console.log('xstr : ', xstr);
var result = expandRange(xstr);
console.log(result.xarr);
console.log(result.numx);
putmsg(2, "Success!\nCheck out plots below!");
}
// * ********************************************************************************
// * Plot Button *******************************************************************
// * ********************************************************************************
plotgButton.addEventListener("click", doIt);
// * ********************************************************************************
// * ****************************************************************************
// * * event listeners for show/hide dropdown menus *****************************
// * ****************************************************************************
document.addEventListener("click", (event) => {
if (!event.target.matches('.dropbtn')) {
buttonList.forEach(({ button, content }) => {
if (content.classList.contains('show')) {
content.classList.remove('show');
}
});
}
});
buttonList.forEach(({ button, content }) => {
button.addEventListener("click", () => {
buttonList.forEach(({ content }) => {
if (content.classList.contains('show')) {
content.classList.remove("show");
}
});
content.classList.toggle("show");
});
});
// * ****************************************************************************