Skip to content

Commit 8b7866e

Browse files
RajeshwriKrajeshwari-kiwad
andauthored
Timing and Plot sweep changes (#64)
Timing calculation update and Step to sweep delay addition to sweep plot --------- Co-authored-by: rajeshwari-kiwad <[email protected]>
1 parent f4690c5 commit 8b7866e

File tree

2 files changed

+29
-13
lines changed

2 files changed

+29
-13
lines changed

script-gen-ui/src/app/components/main-sweep/plot-container/plot-sweep/plot-sweep.component.ts

Lines changed: 28 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -302,15 +302,31 @@ export class PlotSweepComponent
302302
const targetLength = this.plotWidth / this.numSteps;
303303
let processedXData: number[] = [];
304304
let processedYData: number[] = [];
305+
let processedSweepValues = [...sweepValues];
305306

306-
// Interpolate numPoints between each consecutive value in plotDataX
307-
if (this.plotDataX && this.plotDataX.length > 1 && this.numPoints?.value) {
308-
const numPoints = this.numPoints.value;
307+
if(this.stepToSweepDelay.value > 0 && this.totalTimePerStep > 0 ){
308+
processedSweepValues = [0, ...sweepValues];
309+
}
310+
311+
if (this.plotDataX && this.plotDataX.length > 1) {
312+
const hasDelay = this.stepToSweepDelay.value > 0;
313+
309314
for (let i = 0; i < this.plotDataX.length - 1; i++) {
310-
const x0 = this.plotDataX[i];
311-
const x1 = this.plotDataX[i + 1];
312-
for (let j = 0; j < numPoints; j++) {
313-
processedXData.push(x0 + (x1 - x0) * (j / numPoints));
315+
const stepStart = this.plotDataX[i];
316+
const stepEnd = this.plotDataX[i + 1];
317+
318+
if (hasDelay) {
319+
processedXData.push(stepStart);
320+
processedXData.push(stepStart + this.stepToSweepDelay.value);
321+
for (let j = 1; j < this.numPoints.value; j++) {
322+
const sweepProgress = j / (this.numPoints.value - 1);
323+
const sweepDuration = stepEnd - (stepStart + this.stepToSweepDelay.value);
324+
processedXData.push(stepStart + this.stepToSweepDelay.value + sweepProgress * sweepDuration);
325+
}
326+
} else {
327+
for (let j = 0; j < this.numPoints.value; j++) {
328+
processedXData.push(stepStart + (stepEnd - stepStart) * (j / this.numPoints.value));
329+
}
314330
}
315331
}
316332
processedXData.push(this.plotDataX[this.plotDataX.length - 1]);
@@ -320,17 +336,17 @@ export class PlotSweepComponent
320336

321337
if (this.numPoints?.value > targetLength) {
322338
processedYData = PlotUtils.minMaxInterpolation(
323-
sweepValues,
339+
processedSweepValues,
324340
targetLength
325341
).y;
326342
} else {
327-
processedYData = sweepValues;
343+
processedYData = processedSweepValues;
328344
}
329-
console.log(processedYData);
345+
console.log(processedYData, processedSweepValues, sweepValues);
330346
this.plotData1.x = processedXData;
331-
this.plotData1.y = Array.from({ length: this.numSteps }, () => sweepValues)
347+
this.plotData1.y = Array.from({ length: this.numSteps }, () => processedSweepValues)
332348
.flat()
333-
.concat(sweepValues[sweepValues.length - 1]);
349+
.concat(processedSweepValues[processedSweepValues.length - 1]);
334350

335351
this.plotLayout.xaxis.dtick = this.tickDifference;
336352
this.plotLayout.xaxis.range = [0, this.tickDifference * 10];

script-gen-ui/src/app/components/utils/timing-calculation.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,6 @@ export class TimingCalculation {
2626
} else if (mode === 'NPLC') {
2727
this.measTime = (this.numMeas * ((1 / this.lineFreq) * value) + measDelay) + sourceDelay;
2828
}
29-
return sweepPoints*(stepToSweepDelay + this.overhead + this.measTime);
29+
return stepToSweepDelay + sweepPoints*(this.overhead + this.measTime);
3030
}
3131
}

0 commit comments

Comments
 (0)