diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-sweep/plot-sweep.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-sweep/plot-sweep.component.ts index 4163461..dbb7e39 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-sweep/plot-sweep.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-sweep/plot-sweep.component.ts @@ -302,15 +302,31 @@ export class PlotSweepComponent const targetLength = this.plotWidth / this.numSteps; let processedXData: number[] = []; let processedYData: number[] = []; + let processedSweepValues = [...sweepValues]; - // Interpolate numPoints between each consecutive value in plotDataX - if (this.plotDataX && this.plotDataX.length > 1 && this.numPoints?.value) { - const numPoints = this.numPoints.value; + if(this.stepToSweepDelay.value > 0 && this.totalTimePerStep > 0 ){ + processedSweepValues = [0, ...sweepValues]; + } + + if (this.plotDataX && this.plotDataX.length > 1) { + const hasDelay = this.stepToSweepDelay.value > 0; + for (let i = 0; i < this.plotDataX.length - 1; i++) { - const x0 = this.plotDataX[i]; - const x1 = this.plotDataX[i + 1]; - for (let j = 0; j < numPoints; j++) { - processedXData.push(x0 + (x1 - x0) * (j / numPoints)); + const stepStart = this.plotDataX[i]; + const stepEnd = this.plotDataX[i + 1]; + + if (hasDelay) { + processedXData.push(stepStart); + processedXData.push(stepStart + this.stepToSweepDelay.value); + for (let j = 1; j < this.numPoints.value; j++) { + const sweepProgress = j / (this.numPoints.value - 1); + const sweepDuration = stepEnd - (stepStart + this.stepToSweepDelay.value); + processedXData.push(stepStart + this.stepToSweepDelay.value + sweepProgress * sweepDuration); + } + } else { + for (let j = 0; j < this.numPoints.value; j++) { + processedXData.push(stepStart + (stepEnd - stepStart) * (j / this.numPoints.value)); + } } } processedXData.push(this.plotDataX[this.plotDataX.length - 1]); @@ -320,17 +336,17 @@ export class PlotSweepComponent if (this.numPoints?.value > targetLength) { processedYData = PlotUtils.minMaxInterpolation( - sweepValues, + processedSweepValues, targetLength ).y; } else { - processedYData = sweepValues; + processedYData = processedSweepValues; } - console.log(processedYData); + console.log(processedYData, processedSweepValues, sweepValues); this.plotData1.x = processedXData; - this.plotData1.y = Array.from({ length: this.numSteps }, () => sweepValues) + this.plotData1.y = Array.from({ length: this.numSteps }, () => processedSweepValues) .flat() - .concat(sweepValues[sweepValues.length - 1]); + .concat(processedSweepValues[processedSweepValues.length - 1]); this.plotLayout.xaxis.dtick = this.tickDifference; this.plotLayout.xaxis.range = [0, this.tickDifference * 10]; diff --git a/script-gen-ui/src/app/components/utils/timing-calculation.ts b/script-gen-ui/src/app/components/utils/timing-calculation.ts index 76e4a3c..0d5ad7d 100644 --- a/script-gen-ui/src/app/components/utils/timing-calculation.ts +++ b/script-gen-ui/src/app/components/utils/timing-calculation.ts @@ -26,6 +26,6 @@ export class TimingCalculation { } else if (mode === 'NPLC') { this.measTime = (this.numMeas * ((1 / this.lineFreq) * value) + measDelay) + sourceDelay; } - return sweepPoints*(stepToSweepDelay + this.overhead + this.measTime); + return stepToSweepDelay + sweepPoints*(this.overhead + this.measTime); } } \ No newline at end of file