From 77637e6a2bd075a251daf02821ddf18f5ac771b0 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 24 Nov 2025 14:54:07 +0530 Subject: [PATCH 01/28] timing addition --- .../main-sweep/main-sweep.component.html | 1 + .../plot-container.component.html | 2 - .../plot-container.component.ts | 224 ++++-------------- .../components/utils/timing-calculation.ts | 43 ++++ 4 files changed, 94 insertions(+), 176 deletions(-) create mode 100644 script-gen-ui/src/app/components/utils/timing-calculation.ts diff --git a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html index 7a15b95..b5cd9b6 100644 --- a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html +++ b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html @@ -360,6 +360,7 @@

Sweep

[sweepChannels]="sweepChannels" [stepGlobalParameters]="stepGlobalParameters" [sweepGlobalParameters]="sweepGlobalParameters" + [sweepTimingConfig]="sweepTimingConfig" [colorMap]="colorMap" [activeComponent]="activeComponent" [activeIndex]="activeIndex" diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html index c267775..20ce83d 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html @@ -17,7 +17,6 @@ (); // Accept colorMap from MainSweepComponent @Input() activeComponent: 'bias' | 'step' | 'sweep' | null = null; // Accept active component @@ -65,142 +67,62 @@ export class PlotContainerComponent implements OnInit, AfterViewInit, OnDestroy numberOfSteps: ParameterInt | undefined; plotDataX: number[] = []; - plotLayout = { - xaxis: { - visible: true, - ticksuffix: ' s', - rangemode: 'nonnegative', - separatethousands: false, - tickfont: { family: 'Times New Roman', color: 'white' }, - dtick: 1, - tick0: 0, - showtickprefix: 'none', - showticksuffix: 'all', - tickwidth: 0, - showline: true, - layer: 'below traces', - zeroline: false, - zerolinecolor: 'gray', - zerolinewidth: 1, - showgrid: true, - gridcolor: 'lightgrey', - gridwidth: 0.5, - griddash: 'dot', - type: 'linear', - position: 20, - }, - yaxis: { - visible: true, - ticksuffix: ' V', - range: [0, 2], - tickfont: { family: 'Times New Roman', color: 'white' }, - dtick: 0.5, - tick0: 0, - tickwidth: 0, - linewidth: 1, - layer: 'below traces', - showline: false, - showticklabels: false, - showgrid: true, - gridcolor: 'lightgrey', - gridwidth: 0.3, - type: 'linear', - griddash: 'dot', - }, - yaxis2: { - title: { - font: { color: 'white' }, - }, - tickfont: { color: 'white' }, - anchor: 'x', - overlaying: 'y', - side: 'left', - position: -3, - showline: false, - showlegend: false, - showticklabels: true, - zerolinewidth: 0, - showgrid: true, - gridcolor: 'lightgrey', - gridwidth: 0.3, - type: 'linear', - griddash: 'dot', - // position: 20, - visible: true, - ticksuffix: ' mV', - range: [0, 2], // Adjust the range as needed - separatethousands: false, - // tickfont: { family: 'Times New Roman', color: 'white' }, - dtick: 2, - tick0: 0, - showtickprefix: 'all', - showticksuffix: 'all', - tickwidth: 0, - linecolor: 'black', - linewidth: 1, - layer: 'below traces', - }, - // grid: {rows: 1, columns: 1, pattern: 'independent'}, - paper_bgcolor: 'black', - plot_bgcolor: 'black', - hovermode: 'closest', - dragmode: false, - autosize: false, - height: 150, - width: 700, - margin: { - l: 40, - r: 20, - b: 25, - t: 20, - pad: 4, - }, - shapes: [ - { - type: 'line', - x0: 0, // Start of the line on the x-axis - x1: 10, // End of the line on the x-axis - y0: 2, // Y-axis value where the line starts - y1: 2, // Y-axis value where the line ends (same as y0 for a horizontal line) - line: { - color: 'grey', // Color of the line - width: 2, // Thickness of the line - dash: 'solid', // Line style: 'solid', 'dot', 'dash', etc. - }, - }, - ], - }; plotConfig: { staticPlot: boolean; responsive: boolean } | undefined; - originalBackgroundColor = ''; - activeBackgroundColor = ''; - mutationObserver: MutationObserver | undefined; + totalTimePerStep: number | undefined; - constructor(public elementRef: ElementRef) {} + constructor(public elementRef: ElementRef) { } ngOnInit(): void { - this.plotDataX = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; this.plotConfig = { staticPlot: true, responsive: true }; + this.calculateTimePerStep(); + this.plotdataXCalculation(); + console.log("plodataX", this.plotDataX); if (this.stepGlobalParameters) { - this.numberOfSteps = this.stepGlobalParameters.step_points; // Assuming step_points has a 'value' property containing the number + this.numberOfSteps = this.stepGlobalParameters.step_points; } + } - console.log('Bias Channels:', this.biasChannels); - console.log('Step Channels:', this.stepChannels); - console.log('Sweep Channels:', this.sweepChannels); - console.log('Step Global Parameters:', this.stepGlobalParameters); - console.log('Sweep Global Parameters:', this.sweepGlobalParameters); - console.log('plot bias list', this.plotBiasComponents); + ngOnChanges(changes: SimpleChanges){ + if(changes['sweepGlobalParameters'] || changes['stepGlobalParameters']){ + this.calculateTimePerStep(); + this.plotdataXCalculation(); + } } - ngAfterViewInit(): void { - this.plotBiasComponents.changes.subscribe(() => { - console.log( - 'Updated plotBiasComponents:', - this.plotBiasComponents.toArray() - ); - }); + calculateTimePerStep(): void { + if (this.sweepTimingConfig) { + const numMeas = this.sweepGlobalParameters?.sweep_points.value; + const lineFreq = 60; + const overhead = 78e-6; + const sourceDelay = this.sweepTimingConfig.smu_timing.source_delay.value; + const measDelay = this.sweepTimingConfig.smu_timing.measure_delay.value; + const mode = "nplc"; + const value = this.sweepTimingConfig.smu_timing.nplc.value; + + const timingCalc = new TimingCalculation({ + numMeas, + lineFreq, + overhead, + sourceDelay, + measDelay + }); + this.totalTimePerStep = timingCalc.calculateTotalTime(mode, overhead, lineFreq, value, sourceDelay, measDelay); + console.log("totaltime", this.totalTimePerStep); + } + } + + plotdataXCalculation(): void { + if (this.totalTimePerStep) { + const points = 11; + const xData: number[] = []; + const interval = this.totalTimePerStep / (points - 1); + for (let i = 0; i < points; i++) { + xData.push(i * interval); + } + this.plotDataX = xData; + } } getColor(uuid: string): string { @@ -225,11 +147,6 @@ export class PlotContainerComponent implements OnInit, AfterViewInit, OnDestroy }; } - listOfSweepPointsUpdate(newPoints: ParameterFloat[][]) { - // This creates a new reference, triggering ngOnChanges in the child - this.listofSweepPoints = [...newPoints]; - } - scrollToPlot(componentType: 'bias' | 'step' | 'sweep', index: number): void { let plotComponent: | PlotBiasComponent @@ -254,45 +171,4 @@ export class PlotContainerComponent implements OnInit, AfterViewInit, OnDestroy } } - getCssVariableValue(variableName: string): string { - const root = document.documentElement; - const value = getComputedStyle(root).getPropertyValue(variableName).trim(); - return value; - } - - rgbToHex(rgb: string): string { - const match = rgb.match(/\d+/g); - if (!match) return rgb; - const [r, g, b] = match.map(Number); - return `#${((1 << 24) + (r << 16) + (g << 8) + b).toString(16).slice(1)}`; - } - initializePlot(): void { - const backgroundColor = this.getCssVariableValue('--vscode-editor-background'); - const backgroundColorHex = backgroundColor.startsWith('rgb') - ? this.rgbToHex(backgroundColor) - : backgroundColor; - this.originalBackgroundColor = backgroundColorHex; - // Subclasses should set plotLayout.paper_bgcolor and plotLayout.plot_bgcolor - const activeBg = this.getCssVariableValue('--vscode-activityErrorBadge-foreground'); - this.activeBackgroundColor = activeBg.startsWith('rgb') - ? this.rgbToHex(activeBg) - : activeBg; - } - observeThemeChanges(onThemeChange: () => void): void { - const root = document.documentElement; - this.mutationObserver = new MutationObserver(() => { - this.initializePlot(); - onThemeChange(); - }); - this.mutationObserver.observe(root, { - attributes: true, - attributeFilter: ['style'], - }); - } - - ngOnDestroy(): void { - if (this.mutationObserver) { - this.mutationObserver.disconnect(); - } - } } diff --git a/script-gen-ui/src/app/components/utils/timing-calculation.ts b/script-gen-ui/src/app/components/utils/timing-calculation.ts new file mode 100644 index 0000000..ce9ee58 --- /dev/null +++ b/script-gen-ui/src/app/components/utils/timing-calculation.ts @@ -0,0 +1,43 @@ +export class TimingCalculation { + numMeas: number = 0; + lineFreq: number = 0; + overhead: number = 0; + sourceDelay: number = 0; + measDelay: number = 0; + measTime: number = 0; // measurement time + + constructor(params: { + numMeas?: number, + lineFreq?: number, + overhead?: number, + sourceDelay?: number, + measDelay?: number + }) { + if (params.numMeas !== undefined) this.numMeas = params.numMeas; + if (params.lineFreq !== undefined) this.lineFreq = params.lineFreq; + if (params.overhead !== undefined) this.overhead = params.overhead; + if (params.sourceDelay !== undefined) this.sourceDelay = params.sourceDelay; + if (params.measDelay !== undefined) this.measDelay = params.measDelay; + } + + /** + * Calculates total time + * + * @param mode 'aperture' or 'nplc' + * @param value aperture (number) or nplc (number) + * @param overhead overhead time (s) + * @param lineFreq line frequency (Hz) + * @param sourceDelay source delay (s) + * @param measDelay measure delay (s) + */ + calculateTotalTime(mode: 'aperture' | 'nplc', overhead: number, lineFreq: number, value: number, sourceDelay: number, measDelay: number): number { + this.overhead = overhead; + this.lineFreq = lineFreq; + if (mode === 'aperture') { + this.measTime = this.numMeas * (value + measDelay) + sourceDelay; + } else if (mode === 'nplc') { + this.measTime = (this.numMeas * ((1 / this.lineFreq) * value) + measDelay) + sourceDelay; + } + return this.overhead + this.measTime; + } +} \ No newline at end of file From b256d45c8585ccb20e4cefcd2c80081ebeafb8f3 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 24 Nov 2025 18:09:14 +0530 Subject: [PATCH 02/28] cargo fmt --- .../plot-bias/plot-bias.component.ts | 20 ++++++++++--------- .../plot-container.component.ts | 3 ++- .../components/utils/timing-calculation.ts | 5 +++-- 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index 739ebea..efba71c 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -32,8 +32,7 @@ import { StepGlobalParameters } from '../../../../model/sweep_data/stepSweepConf styleUrl: './plot-bias.component.scss', }) export class PlotBiasComponent - implements AfterViewInit, OnInit, OnDestroy, OnChanges -{ + implements AfterViewInit, OnInit, OnDestroy, OnChanges { @Input() biasChannel: BiasChannel | undefined; // @Input() plotData: any; // @Input() plotLayout: any; @@ -190,7 +189,7 @@ export class PlotBiasComponent measRange: ChannelRange | undefined; bias: ParameterFloat | undefined; - constructor(public elementRef: ElementRef) {} + constructor(public elementRef: ElementRef) { } ngOnInit(): void { if (this.biasChannel) { @@ -205,6 +204,7 @@ export class PlotBiasComponent this.bias = this.biasChannel.bias; this.plotDivID = `plotDiv${this.biasChannel.common_chan_attributes.chan_name}`; + this.plotData1.x = this.plotDataX; } // Generate x-axis data if stepGlobalParameters are available @@ -218,6 +218,7 @@ export class PlotBiasComponent // Set constant y-values for bias const biasValue = this.bias?.value ?? 0; this.plotData1.y = new Array(this.plotData1.x.length).fill(biasValue); + // this.generateXAxisData(); this.updatePlotLayout(); this.plotData1.line.color = this.color; @@ -239,6 +240,7 @@ export class PlotBiasComponent } this.observeThemeChanges(); + this.plotData1.x = this.plotDataX; } // the plots are rendered only after the DOM is created, so we need to render them after the DOM is loaded @@ -279,12 +281,12 @@ export class PlotBiasComponent const delayTime = this.stepGlobalParameters.step_to_sweep_delay?.value ?? 0; // Generate x-axis data using the same formula as step and sweep components - const xData: number[] = []; - for (let i = 0; i <= numSteps; i++) { - xData.push(i * (1 + delayTime)); - } + // const xData: number[] = []; + // for (let i = 0; i <= numSteps; i++) { + // xData.push(i * (1 + delayTime)); + // } - this.plotData1.x = xData; + this.plotData1.x = this.plotDataX; // Calculate total time and dtick (same as step/sweep components) const totalTime = numSteps * (1 + delayTime); @@ -308,7 +310,7 @@ export class PlotBiasComponent max = Math.max(...range); } } else { - max = parseToDecimal(this.sourceRange.value,(this.plotLayout.yaxis2.ticksuffix).trim()); + max = parseToDecimal(this.sourceRange.value, (this.plotLayout.yaxis2.ticksuffix).trim()); } if (typeof max === 'number' && !isNaN(max)) { const maxRange = PlotUtils.computeMaxRange(-max, max); diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 677ecc1..bdd29d3 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -100,6 +100,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { const measDelay = this.sweepTimingConfig.smu_timing.measure_delay.value; const mode = "nplc"; const value = this.sweepTimingConfig.smu_timing.nplc.value; + const stepToSweepDelay = this.stepGlobalParameters?.step_to_sweep_delay?.value ?? 0; const timingCalc = new TimingCalculation({ numMeas, @@ -108,7 +109,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { sourceDelay, measDelay }); - this.totalTimePerStep = timingCalc.calculateTotalTime(mode, overhead, lineFreq, value, sourceDelay, measDelay); + this.totalTimePerStep = timingCalc.calculateTotalTime(mode, overhead, lineFreq, value, sourceDelay, measDelay, stepToSweepDelay); console.log("totaltime", this.totalTimePerStep); } } 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 ce9ee58..6d60e9b 100644 --- a/script-gen-ui/src/app/components/utils/timing-calculation.ts +++ b/script-gen-ui/src/app/components/utils/timing-calculation.ts @@ -29,8 +29,9 @@ export class TimingCalculation { * @param lineFreq line frequency (Hz) * @param sourceDelay source delay (s) * @param measDelay measure delay (s) + * @param stepToSweepDelay step to sweep delay (s) */ - calculateTotalTime(mode: 'aperture' | 'nplc', overhead: number, lineFreq: number, value: number, sourceDelay: number, measDelay: number): number { + calculateTotalTime(mode: 'aperture' | 'nplc', overhead: number, lineFreq: number, value: number, sourceDelay: number, measDelay: number, stepToSweepDelay: number): number { this.overhead = overhead; this.lineFreq = lineFreq; if (mode === 'aperture') { @@ -38,6 +39,6 @@ export class TimingCalculation { } else if (mode === 'nplc') { this.measTime = (this.numMeas * ((1 / this.lineFreq) * value) + measDelay) + sourceDelay; } - return this.overhead + this.measTime; + return stepToSweepDelay + this.overhead + this.measTime; } } \ No newline at end of file From 4033cf6e76898c1944b3f4d7e9994beb72dbbf6a Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 24 Nov 2025 19:04:17 +0530 Subject: [PATCH 03/28] tick difference --- .../plot-bias/plot-bias.component.ts | 21 ++++++++++++------- .../plot-container.component.html | 1 + 2 files changed, 15 insertions(+), 7 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index efba71c..e03550c 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -38,6 +38,7 @@ export class PlotBiasComponent // @Input() plotLayout: any; @Input() plotDataX: number[] = []; @Input() plotConfig: { staticPlot: boolean } | undefined; + @Input() tickDifference: number | undefined; @Input() stepGlobalParameters: StepGlobalParameters | undefined; plotDivID = ''; @@ -204,9 +205,12 @@ export class PlotBiasComponent this.bias = this.biasChannel.bias; this.plotDivID = `plotDiv${this.biasChannel.common_chan_attributes.chan_name}`; - this.plotData1.x = this.plotDataX; + } + this.plotData1.x = this.plotDataX; + console.log("biasplotdata x", this.plotDataX, this.plotData1.x); + // Generate x-axis data if stepGlobalParameters are available if (this.stepGlobalParameters) { this.generateXAxisData(); @@ -275,10 +279,10 @@ export class PlotBiasComponent } private generateXAxisData(): void { - if (!this.stepGlobalParameters) return; + // if (!this.stepGlobalParameters) return; - const numSteps = this.stepGlobalParameters.step_points?.value ?? 1; - const delayTime = this.stepGlobalParameters.step_to_sweep_delay?.value ?? 0; + // const numSteps = this.stepGlobalParameters.step_points?.value ?? 1; + // const delayTime = this.stepGlobalParameters.step_to_sweep_delay?.value ?? 0; // Generate x-axis data using the same formula as step and sweep components // const xData: number[] = []; @@ -289,9 +293,12 @@ export class PlotBiasComponent this.plotData1.x = this.plotDataX; // Calculate total time and dtick (same as step/sweep components) - const totalTime = numSteps * (1 + delayTime); - this.plotLayout.xaxis.dtick = totalTime / 10; - this.plotLayout.xaxis2.dtick = totalTime / 10; + // const totalTime = numSteps * (1 + delayTime); + if (this.tickDifference) { + this.plotLayout.xaxis.dtick = this.tickDifference/10; + this.plotLayout.xaxis2.dtick = this.tickDifference/10; + } + } private updatePlotLayout(): void { diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html index 20ce83d..8984d70 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html @@ -4,6 +4,7 @@ [biasChannel]="biasChannel" [plotDataX]="plotDataX" [plotConfig]="plotConfig" + [tickDifference]="totalTimePerStep" [stepGlobalParameters]="stepGlobalParameters" [isActive]="activeComponent === 'bias' && activeIndex === i" [activeStyle]="getActiveStyle(biasChannel.common_chan_attributes.uuid, 'bias', i)" From 3c75a07352c62a1f18e7730a61e3b8c5cc1f9614 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 24 Nov 2025 19:15:25 +0530 Subject: [PATCH 04/28] ng lint --- .../plot-container/plot-container.component.ts | 3 +-- .../src/app/components/utils/timing-calculation.ts | 12 ++++++------ 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index bdd29d3..24fe353 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -7,7 +7,7 @@ import { OnChanges, SimpleChanges, ViewChildren, - QueryList, OnDestroy, + QueryList, } from '@angular/core'; import { BiasChannel } from '../../../model/chan_data/biasChannel'; import { StepChannel } from '../../../model/chan_data/stepChannel'; @@ -20,7 +20,6 @@ import { PlotBiasComponent } from './plot-bias/plot-bias.component'; import { PlotStepComponent } from './plot-step/plot-step.component'; import { PlotSweepComponent } from './plot-sweep/plot-sweep.component'; import { - ParameterFloat, ParameterInt, SweepTimingConfig, } from '../../../model/sweep_data/SweepTimingConfig'; 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 6d60e9b..39142aa 100644 --- a/script-gen-ui/src/app/components/utils/timing-calculation.ts +++ b/script-gen-ui/src/app/components/utils/timing-calculation.ts @@ -1,10 +1,10 @@ export class TimingCalculation { - numMeas: number = 0; - lineFreq: number = 0; - overhead: number = 0; - sourceDelay: number = 0; - measDelay: number = 0; - measTime: number = 0; // measurement time + numMeas = 0; + lineFreq = 0; + overhead = 0; + sourceDelay = 0; + measDelay = 0; + measTime = 0; // measurement time constructor(params: { numMeas?: number, From 5f1fccf09ada983db827df3287cc0c6e70191648 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 25 Nov 2025 22:29:25 +0530 Subject: [PATCH 05/28] working with nplc/aperture --- .../plot-bias/plot-bias.component.ts | 4 +- .../plot-container.component.ts | 41 +++++++++---------- .../components/utils/timing-calculation.ts | 21 ++-------- 3 files changed, 26 insertions(+), 40 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index e03550c..136d607 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -295,8 +295,8 @@ export class PlotBiasComponent // Calculate total time and dtick (same as step/sweep components) // const totalTime = numSteps * (1 + delayTime); if (this.tickDifference) { - this.plotLayout.xaxis.dtick = this.tickDifference/10; - this.plotLayout.xaxis2.dtick = this.tickDifference/10; + this.plotLayout.xaxis.dtick = this.tickDifference; + this.plotLayout.xaxis2.dtick = this.tickDifference; } } diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 24fe353..431746e 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -79,47 +79,46 @@ export class PlotContainerComponent implements OnInit, OnChanges { console.log("plodataX", this.plotDataX); if (this.stepGlobalParameters) { - this.numberOfSteps = this.stepGlobalParameters.step_points; + this.numberOfSteps = this.stepGlobalParameters.step_points; } } - ngOnChanges(changes: SimpleChanges){ - if(changes['sweepGlobalParameters'] || changes['stepGlobalParameters']){ + ngOnChanges(changes: SimpleChanges) { + if (changes['sweepGlobalParameters'] || changes['stepGlobalParameters']) { this.calculateTimePerStep(); this.plotdataXCalculation(); } } calculateTimePerStep(): void { - if (this.sweepTimingConfig) { - const numMeas = this.sweepGlobalParameters?.sweep_points.value; + if (this.sweepTimingConfig && this.stepGlobalParameters) { + const numMeas = this.sweepTimingConfig.measure_count.value; const lineFreq = 60; const overhead = 78e-6; const sourceDelay = this.sweepTimingConfig.smu_timing.source_delay.value; const measDelay = this.sweepTimingConfig.smu_timing.measure_delay.value; - const mode = "nplc"; - const value = this.sweepTimingConfig.smu_timing.nplc.value; - const stepToSweepDelay = this.stepGlobalParameters?.step_to_sweep_delay?.value ?? 0; - - const timingCalc = new TimingCalculation({ - numMeas, - lineFreq, - overhead, - sourceDelay, - measDelay - }); - this.totalTimePerStep = timingCalc.calculateTotalTime(mode, overhead, lineFreq, value, sourceDelay, measDelay, stepToSweepDelay); - console.log("totaltime", this.totalTimePerStep); + const stepToSweepDelay = this.stepGlobalParameters.step_to_sweep_delay.value; + + const mode = this.sweepTimingConfig.smu_timing.nplc_type.value; + const modeString = mode as 'Aperture' | 'NPLC'; // Made same as JSON string + let value: number; + if (mode === 'NPLC') { + value = this.sweepTimingConfig.smu_timing.nplc.value; + } else { + value = this.sweepTimingConfig.smu_timing.aperture.value; + } + + const timingCalc = new TimingCalculation(); + this.totalTimePerStep = timingCalc.calculateTotalTime(modeString, numMeas, overhead, lineFreq, value, sourceDelay, measDelay, stepToSweepDelay); } } plotdataXCalculation(): void { if (this.totalTimePerStep) { const points = 11; - const xData: number[] = []; - const interval = this.totalTimePerStep / (points - 1); + const xData: number[] = [0]; for (let i = 0; i < points; i++) { - xData.push(i * interval); + xData.push(i * this.totalTimePerStep); } this.plotDataX = xData; } 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 39142aa..2a2226c 100644 --- a/script-gen-ui/src/app/components/utils/timing-calculation.ts +++ b/script-gen-ui/src/app/components/utils/timing-calculation.ts @@ -6,20 +6,6 @@ export class TimingCalculation { measDelay = 0; measTime = 0; // measurement time - constructor(params: { - numMeas?: number, - lineFreq?: number, - overhead?: number, - sourceDelay?: number, - measDelay?: number - }) { - if (params.numMeas !== undefined) this.numMeas = params.numMeas; - if (params.lineFreq !== undefined) this.lineFreq = params.lineFreq; - if (params.overhead !== undefined) this.overhead = params.overhead; - if (params.sourceDelay !== undefined) this.sourceDelay = params.sourceDelay; - if (params.measDelay !== undefined) this.measDelay = params.measDelay; - } - /** * Calculates total time * @@ -31,12 +17,13 @@ export class TimingCalculation { * @param measDelay measure delay (s) * @param stepToSweepDelay step to sweep delay (s) */ - calculateTotalTime(mode: 'aperture' | 'nplc', overhead: number, lineFreq: number, value: number, sourceDelay: number, measDelay: number, stepToSweepDelay: number): number { + calculateTotalTime(mode: 'Aperture' | 'NPLC', numMeas: number, overhead: number, lineFreq: number, value: number, sourceDelay: number, measDelay: number, stepToSweepDelay: number): number { this.overhead = overhead; this.lineFreq = lineFreq; - if (mode === 'aperture') { + this.numMeas = numMeas; + if (mode === 'Aperture') { this.measTime = this.numMeas * (value + measDelay) + sourceDelay; - } else if (mode === 'nplc') { + } else if (mode === 'NPLC') { this.measTime = (this.numMeas * ((1 / this.lineFreq) * value) + measDelay) + sourceDelay; } return stepToSweepDelay + this.overhead + this.measTime; From 641329540cc07e0a4eb7cd8b96847067aedac09e Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 25 Nov 2025 23:11:50 +0530 Subject: [PATCH 06/28] line_frequency --- kic-script-gen/src/back_end/client_server.rs | 9 +++++++++ .../src/model/sweep_data/global_parameters.rs | 8 ++++++++ .../plot-container/plot-container.component.ts | 2 +- 3 files changed, 18 insertions(+), 1 deletion(-) diff --git a/kic-script-gen/src/back_end/client_server.rs b/kic-script-gen/src/back_end/client_server.rs index 40195d3..7e27459 100644 --- a/kic-script-gen/src/back_end/client_server.rs +++ b/kic-script-gen/src/back_end/client_server.rs @@ -364,6 +364,15 @@ pub async fn start(mut script_model: ScriptModel) -> anyhow::Result<()> { if let Some(session) = session.as_mut() { session.text(response).await.unwrap(); } + } else if trimmed_line.contains("lineFrequency") { + println!("line frequency received"); + if let Ok(freq) = trimmed_line.replace("lineFrequency", "").trim().parse::() { + let mut data_model = app_state.data_model.lock().await; + data_model.sweep_model.sweep_config.global_parameters.set_line_frequency(freq); + println!("Set line frequency to {}", freq); + } else { + println!("Failed to parse line frequency value: {}", trimmed_line); + } } else if trimmed_line.contains("refresh") { println!("instrument data requested"); // refreshing by initiating session again does not affect the JSON state } else if trimmed_line.contains("reset") { diff --git a/script-gen-manager/src/model/sweep_data/global_parameters.rs b/script-gen-manager/src/model/sweep_data/global_parameters.rs index 13af24e..5768fa4 100644 --- a/script-gen-manager/src/model/sweep_data/global_parameters.rs +++ b/script-gen-manager/src/model/sweep_data/global_parameters.rs @@ -5,16 +5,24 @@ use super::sweep_timing_config::SweepTimingConfig; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct GlobalParameters { pub sweep_timing_config: SweepTimingConfig, + pub line_frequency: f64, + pub overhead_time: f64, } impl GlobalParameters { pub fn new() -> Self { GlobalParameters { sweep_timing_config: SweepTimingConfig::new(), + line_frequency: 0.0, + overhead_time: 78e-6, } } pub fn evaluate(&mut self) { self.sweep_timing_config.evaluate(); } + + pub fn set_line_frequency(&mut self, frequency: f64) { + self.line_frequency = frequency; + } } diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 431746e..26339dd 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -76,7 +76,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { this.plotConfig = { staticPlot: true, responsive: true }; this.calculateTimePerStep(); this.plotdataXCalculation(); - console.log("plodataX", this.plotDataX); + // console.log("plodataX", this.plotDataX); if (this.stepGlobalParameters) { this.numberOfSteps = this.stepGlobalParameters.step_points; From de9855f698552c5ce7b944e40091c3fbef9b17d3 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Wed, 26 Nov 2025 10:05:38 +0530 Subject: [PATCH 07/28] setting line_frequency --- kic-script-gen/src/back_end/client_server.rs | 21 +++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) diff --git a/kic-script-gen/src/back_end/client_server.rs b/kic-script-gen/src/back_end/client_server.rs index 7e27459..8cf76ec 100644 --- a/kic-script-gen/src/back_end/client_server.rs +++ b/kic-script-gen/src/back_end/client_server.rs @@ -365,13 +365,20 @@ pub async fn start(mut script_model: ScriptModel) -> anyhow::Result<()> { session.text(response).await.unwrap(); } } else if trimmed_line.contains("lineFrequency") { - println!("line frequency received"); - if let Ok(freq) = trimmed_line.replace("lineFrequency", "").trim().parse::() { - let mut data_model = app_state.data_model.lock().await; - data_model.sweep_model.sweep_config.global_parameters.set_line_frequency(freq); - println!("Set line frequency to {}", freq); - } else { - println!("Failed to parse line frequency value: {}", trimmed_line); + println!("line frequency received {}", trimmed_line); + match serde_json::from_str::(trimmed_line) { + Ok(json_obj) => { + if let Some(freq) = json_obj.get("lineFrequency").and_then(|v| v.as_f64()) { + let mut data_model = app_state.data_model.lock().await; + data_model.sweep_model.sweep_config.global_parameters.set_line_frequency(freq); + println!("Set line frequency to {}", freq); + } else { + println!("'lineFrequency' key not found or not a number in JSON: {}", trimmed_line); + } + } + Err(e) => { + println!("Failed to parse line frequency JSON: {} | Error: {}", trimmed_line, e); + } } } else if trimmed_line.contains("refresh") { println!("instrument data requested"); // refreshing by initiating session again does not affect the JSON state From 1c66209c6b89bccd5e38b0bcf6fb70e51e88900e Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Wed, 26 Nov 2025 17:40:15 +0530 Subject: [PATCH 08/28] global parameters --- .../app/components/main-sweep/main-sweep.component.html | 1 + .../src/app/components/main-sweep/main-sweep.component.ts | 5 ++++- .../main-sweep/plot-container/plot-container.component.ts | 8 +++++--- script-gen-ui/src/app/model/interface.ts | 2 ++ script-gen-ui/src/app/model/sweep_data/sweepConfig.ts | 4 ++++ 5 files changed, 16 insertions(+), 4 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html index b5cd9b6..529365e 100644 --- a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html +++ b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.html @@ -361,6 +361,7 @@

Sweep

[stepGlobalParameters]="stepGlobalParameters" [sweepGlobalParameters]="sweepGlobalParameters" [sweepTimingConfig]="sweepTimingConfig" + [globalParameters]="globalParameters" [colorMap]="colorMap" [activeComponent]="activeComponent" [activeIndex]="activeIndex" diff --git a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts index aadd2b4..6e1d519 100644 --- a/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/main-sweep.component.ts @@ -11,7 +11,7 @@ import { BiasComponent } from './bias/bias.component'; import { StepComponent } from './step/step.component'; import { SweepComponent } from './sweep/sweep.component'; import { WebSocketService } from '../../websocket.service'; -import { SweepConfig } from '../../model/sweep_data/sweepConfig'; +import { GlobalParameters, SweepConfig } from '../../model/sweep_data/sweepConfig'; import { ParameterFloat, ParameterInt, @@ -108,6 +108,7 @@ export class MainSweepComponent implements OnChanges { showPopupBox = false; showTiming = false; sweepTimingConfig: SweepTimingConfig | undefined; + globalParameters: GlobalParameters | undefined; showList = false; //Sweep list popup box deviceList: Device[] = []; showBiasTooltip = false; @@ -222,12 +223,14 @@ export class MainSweepComponent implements OnChanges { if (this.sweepConfig) { this.sweepTimingConfig = this.sweepConfig.global_parameters.sweep_timing_config; + this.deviceList = this.sweepConfig.device_list; this.biasChannels = this.sweepConfig.bias_channels; this.stepChannels = this.sweepConfig.step_channels; this.sweepChannels = this.sweepConfig.sweep_channels; this.stepGlobalParameters = this.sweepConfig.step_global_parameters; this.sweepGlobalParameters = this.sweepConfig.sweep_global_parameters; + this.globalParameters = this.sweepConfig.global_parameters; this.sweepPoints = this.sweepGlobalParameters.sweep_points; this.isListSweep = this.sweepGlobalParameters.list_sweep; diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 26339dd..ec38547 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -28,6 +28,7 @@ import { FormsModule } from '@angular/forms'; import { MatIconModule } from '@angular/material/icon'; import { BrowserModule } from '@angular/platform-browser'; import { TimingCalculation } from '../../utils/timing-calculation'; +import { GlobalParameters } from '../../../model/sweep_data/sweepConfig'; @Component({ selector: 'app-plot-container', @@ -52,6 +53,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { @Input() stepGlobalParameters: StepGlobalParameters | undefined; @Input() sweepGlobalParameters: SweepGlobalParameters | undefined; @Input() sweepTimingConfig: SweepTimingConfig | undefined; + @Input() globalParameters: GlobalParameters | undefined; @Input() colorMap = new Map(); // Accept colorMap from MainSweepComponent @Input() activeComponent: 'bias' | 'step' | 'sweep' | null = null; // Accept active component @@ -91,10 +93,10 @@ export class PlotContainerComponent implements OnInit, OnChanges { } calculateTimePerStep(): void { - if (this.sweepTimingConfig && this.stepGlobalParameters) { + if (this.sweepTimingConfig && this.stepGlobalParameters && this.globalParameters) { const numMeas = this.sweepTimingConfig.measure_count.value; - const lineFreq = 60; - const overhead = 78e-6; + const lineFreq = this.globalParameters.line_frequency; + const overhead = this.globalParameters.overhead_time; const sourceDelay = this.sweepTimingConfig.smu_timing.source_delay.value; const measDelay = this.sweepTimingConfig.smu_timing.measure_delay.value; const stepToSweepDelay = this.stepGlobalParameters.step_to_sweep_delay.value; diff --git a/script-gen-ui/src/app/model/interface.ts b/script-gen-ui/src/app/model/interface.ts index ea2cb92..b1472db 100644 --- a/script-gen-ui/src/app/model/interface.ts +++ b/script-gen-ui/src/app/model/interface.ts @@ -50,6 +50,8 @@ export interface ISweepTimingConfig { export interface IGlobalParameters { sweep_timing_config: ISweepTimingConfig; + overhead_time: number; + line_frequency: number; } export interface ICommonChanAttributes { diff --git a/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts b/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts index 9d283d8..954e8bc 100644 --- a/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts +++ b/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts @@ -16,9 +16,13 @@ import { SweepTimingConfig } from './SweepTimingConfig'; export class GlobalParameters { sweep_timing_config: SweepTimingConfig; + line_frequency: number; + overhead_time: number; constructor(data: IGlobalParameters) { this.sweep_timing_config = new SweepTimingConfig(data.sweep_timing_config); + this.line_frequency = data.line_frequency; + this.overhead_time = data.overhead_time; } toJSON() { From 8692e4523cd2d3b70dc5d0051ab87a7dc9adbfa6 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Thu, 27 Nov 2025 09:30:54 +0530 Subject: [PATCH 09/28] line_frequency and overhead done --- .../src/model/sweep_data/global_parameters.rs | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/script-gen-manager/src/model/sweep_data/global_parameters.rs b/script-gen-manager/src/model/sweep_data/global_parameters.rs index 5768fa4..ee71de0 100644 --- a/script-gen-manager/src/model/sweep_data/global_parameters.rs +++ b/script-gen-manager/src/model/sweep_data/global_parameters.rs @@ -2,27 +2,47 @@ use serde::{Deserialize, Serialize}; use super::sweep_timing_config::SweepTimingConfig; +fn default_overhead_time() -> f64 { 78e-6 } + #[derive(Serialize, Deserialize, Debug, Clone)] +#[serde(default)] pub struct GlobalParameters { pub sweep_timing_config: SweepTimingConfig, pub line_frequency: f64, + #[serde(default = "default_overhead_time")] pub overhead_time: f64, } -impl GlobalParameters { - pub fn new() -> Self { +impl Default for GlobalParameters { + fn default() -> Self { GlobalParameters { sweep_timing_config: SweepTimingConfig::new(), - line_frequency: 0.0, + line_frequency: 60.0, overhead_time: 78e-6, } } +} + +impl GlobalParameters { + pub fn new() -> Self { + GlobalParameters::default() + } pub fn evaluate(&mut self) { self.sweep_timing_config.evaluate(); + + // Ensure defaults if zero + // if self.line_frequency == 0.0 { + // self.line_frequency = 60.0; + // } + // if self.overhead_time == 0.0 { + // self.overhead_time = 78e-6; + // } } pub fn set_line_frequency(&mut self, frequency: f64) { self.line_frequency = frequency; } } + + From d9a6dc511a5e3f5c044b971468956fe12849d8a1 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Thu, 27 Nov 2025 15:20:55 +0530 Subject: [PATCH 10/28] adding aperture in psu timing --- .../src/model/sweep_data/global_parameters.rs | 18 ++++-------------- .../model/sweep_data/sweep_timing_config.rs | 3 +++ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/script-gen-manager/src/model/sweep_data/global_parameters.rs b/script-gen-manager/src/model/sweep_data/global_parameters.rs index ee71de0..b3db638 100644 --- a/script-gen-manager/src/model/sweep_data/global_parameters.rs +++ b/script-gen-manager/src/model/sweep_data/global_parameters.rs @@ -2,7 +2,9 @@ use serde::{Deserialize, Serialize}; use super::sweep_timing_config::SweepTimingConfig; -fn default_overhead_time() -> f64 { 78e-6 } +fn default_overhead_time() -> f64 { + 78e-6 +} #[derive(Serialize, Deserialize, Debug, Clone)] #[serde(default)] @@ -22,27 +24,15 @@ impl Default for GlobalParameters { } } } - -impl GlobalParameters { +impl GlobalParameters { pub fn new() -> Self { GlobalParameters::default() } pub fn evaluate(&mut self) { self.sweep_timing_config.evaluate(); - - // Ensure defaults if zero - // if self.line_frequency == 0.0 { - // self.line_frequency = 60.0; - // } - // if self.overhead_time == 0.0 { - // self.overhead_time = 78e-6; - // } } - pub fn set_line_frequency(&mut self, frequency: f64) { self.line_frequency = frequency; } } - - diff --git a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs index cbe8dff..00ba6c9 100644 --- a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs +++ b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs @@ -139,12 +139,14 @@ impl SmuTiming { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct PsuTiming { rate: ParameterString, + aperture_value: Vec, } impl PsuTiming { pub fn new() -> Self { let mut psu_timing = PsuTiming { rate: ParameterString::new("rate"), + aperture_value: vec![], }; psu_timing.set_defaults(); psu_timing @@ -156,6 +158,7 @@ impl PsuTiming { BaseMetadata::RATE_FAST.to_string(), ]; self.rate.value = BaseMetadata::RATE_NORMAL.to_string(); + self.aperture_value = vec![0.066667, 0.016667]; // 66.667ms, 16.667ms } pub fn evaluate(&mut self) { From 67ec55991916266f848acb8a951482990d875cc7 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Thu, 27 Nov 2025 15:21:07 +0530 Subject: [PATCH 11/28] cargo fmt --- kic-script-gen/src/back_end/client_server.rs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/kic-script-gen/src/back_end/client_server.rs b/kic-script-gen/src/back_end/client_server.rs index 8cf76ec..f4a411e 100644 --- a/kic-script-gen/src/back_end/client_server.rs +++ b/kic-script-gen/src/back_end/client_server.rs @@ -370,14 +370,24 @@ pub async fn start(mut script_model: ScriptModel) -> anyhow::Result<()> { Ok(json_obj) => { if let Some(freq) = json_obj.get("lineFrequency").and_then(|v| v.as_f64()) { let mut data_model = app_state.data_model.lock().await; - data_model.sweep_model.sweep_config.global_parameters.set_line_frequency(freq); + data_model + .sweep_model + .sweep_config + .global_parameters + .set_line_frequency(freq); println!("Set line frequency to {}", freq); } else { - println!("'lineFrequency' key not found or not a number in JSON: {}", trimmed_line); + println!( + "'lineFrequency' key not found or not a number in JSON: {}", + trimmed_line + ); } } Err(e) => { - println!("Failed to parse line frequency JSON: {} | Error: {}", trimmed_line, e); + println!( + "Failed to parse line frequency JSON: {} | Error: {}", + trimmed_line, e + ); } } } else if trimmed_line.contains("refresh") { From d376e5084a5fdd59f89648776ef7ae1ebd159148 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Thu, 27 Nov 2025 15:39:28 +0530 Subject: [PATCH 12/28] psdu timing update --- .../src/app/components/main-sweep/timing/timing.component.ts | 1 + script-gen-ui/src/app/model/interface.ts | 1 + script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts | 3 +++ script-gen-ui/src/app/model/sweep_data/sweepConfig.ts | 2 ++ 4 files changed, 7 insertions(+) diff --git a/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts b/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts index 38809f5..75436be 100644 --- a/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts @@ -119,6 +119,7 @@ export class TimingComponent implements OnDestroy, OnChanges { }); const psu_timing = new PsuTiming({ rate: this.rate!, + aperture_value: this.sweepTimingConfig?.psu_timing.aperture_value || [], }); return new SweepTimingConfig({ measure_count: this.measureCount!, diff --git a/script-gen-ui/src/app/model/interface.ts b/script-gen-ui/src/app/model/interface.ts index b1472db..d73f121 100644 --- a/script-gen-ui/src/app/model/interface.ts +++ b/script-gen-ui/src/app/model/interface.ts @@ -39,6 +39,7 @@ export interface ISmuTiming { } export interface IPsuTiming { + aperture_value: number[]; rate: IParameterString; } diff --git a/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts b/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts index 74f2474..b1cb8f4 100644 --- a/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts +++ b/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts @@ -118,14 +118,17 @@ export class SmuTiming { export class PsuTiming { rate: ParameterString; + aperture_value: number[]; constructor(data: IPsuTiming) { this.rate = new ParameterString(data.rate); + this.aperture_value = data.aperture_value; } toJSON() { return { rate: this.rate.toJSON(), + aperture_value: this.aperture_value, }; } } diff --git a/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts b/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts index 954e8bc..c16229a 100644 --- a/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts +++ b/script-gen-ui/src/app/model/sweep_data/sweepConfig.ts @@ -28,6 +28,8 @@ export class GlobalParameters { toJSON() { return { sweep_timing_config: this.sweep_timing_config.toJSON(), + line_frequency: this.line_frequency, + overhead_time: this.overhead_time, }; } } From 767e651ca2ec0429dde7e33978c1f84bb3cc8940 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 1 Dec 2025 10:24:47 +0530 Subject: [PATCH 13/28] psu and smu changes --- .../plot-container.component.ts | 79 ++++++++++++++++--- 1 file changed, 66 insertions(+), 13 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index ec38547..2e795d3 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -76,7 +76,8 @@ export class PlotContainerComponent implements OnInit, OnChanges { ngOnInit(): void { this.plotConfig = { staticPlot: true, responsive: true }; - this.calculateTimePerStep(); + // this.calculateTimePerStep(); + this.calculateTime(); this.plotdataXCalculation(); // console.log("plodataX", this.plotDataX); @@ -86,13 +87,65 @@ export class PlotContainerComponent implements OnInit, OnChanges { } ngOnChanges(changes: SimpleChanges) { - if (changes['sweepGlobalParameters'] || changes['stepGlobalParameters']) { - this.calculateTimePerStep(); + if (changes['sweepGlobalParameters'] || changes['stepGlobalParameters'] && changes['sweepTimingConfig']) { + // this.calculateTimePerStep(); + this.calculateTime(); this.plotdataXCalculation(); } } - calculateTimePerStep(): void { + calculateTime(): void { + let modeString: 'Aperture' | 'NPLC'; + let modeValue: number | undefined; + let ID: string = ''; + if (this.sweepChannels && this.sweepChannels.length > 0) { + const sweepId = this.sweepChannels[0].start_stop_channel.common_chan_attributes.device_id; + ID = sweepId; + } + else if (this.stepChannels && this.stepChannels.length > 0) { + const stepId = this.stepChannels[0].start_stop_channel.common_chan_attributes.device_id; + ID = stepId; + } + else if (this.biasChannels && this.biasChannels.length > 0) { + const biasId = this.biasChannels[0].common_chan_attributes.device_id; + ID = biasId; + } + else { + this.plotDataX = [0, 1e-6, 2e-6, 3e-6, 4e-6, 5e-6, 6e-6, 7e-6, 8e-6, 9e-6, 10e-6]; + } + const result = this.checkDeviceType(ID); + modeString = result.modeString; + modeValue = result.modeValue; + this.calculateTimePerStep(modeString, modeValue); + } + + checkDeviceType(ID: string): {modeString: 'Aperture' | 'NPLC'; modeValue : number } { + let mode = this.sweepTimingConfig?.smu_timing.nplc_type.value; + let modeString = mode as 'Aperture' | 'NPLC'; + let modeValue: number = 0; + let rate = this.sweepTimingConfig?.psu_timing.rate.value; + if (ID.includes('smu') && this.sweepTimingConfig) { + mode = this.sweepTimingConfig?.smu_timing.nplc_type.value; + if (mode === 'NPLC') { + modeString = 'NPLC'; + modeValue = this.sweepTimingConfig?.smu_timing.nplc.value; + } else if (mode === 'Aperture') { + modeString = 'Aperture'; + modeValue = this.sweepTimingConfig?.smu_timing.aperture.value; + } + } else if (ID.includes('psu') && this.sweepTimingConfig) { + mode = 'Aperture'; + modeString = 'Aperture' + if (rate === 'Fast') { + modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[1]; + } else if (rate === 'Normal') { + modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[0]; + } + } + return { modeString, modeValue }; + } + + calculateTimePerStep(modeString : 'Aperture' | 'NPLC', modeValue: number): void { if (this.sweepTimingConfig && this.stepGlobalParameters && this.globalParameters) { const numMeas = this.sweepTimingConfig.measure_count.value; const lineFreq = this.globalParameters.line_frequency; @@ -101,17 +154,17 @@ export class PlotContainerComponent implements OnInit, OnChanges { const measDelay = this.sweepTimingConfig.smu_timing.measure_delay.value; const stepToSweepDelay = this.stepGlobalParameters.step_to_sweep_delay.value; - const mode = this.sweepTimingConfig.smu_timing.nplc_type.value; - const modeString = mode as 'Aperture' | 'NPLC'; // Made same as JSON string - let value: number; - if (mode === 'NPLC') { - value = this.sweepTimingConfig.smu_timing.nplc.value; - } else { - value = this.sweepTimingConfig.smu_timing.aperture.value; - } + // const mode = this.sweepTimingConfig.smu_timing.nplc_type.value; + // const modeString = mode as 'Aperture' | 'NPLC'; // Made same as JSON string + // let value: number; + // if (mode === 'NPLC') { + // value = this.sweepTimingConfig.smu_timing.nplc.value; + // } else { + // value = this.sweepTimingConfig.smu_timing.aperture.value; + // } const timingCalc = new TimingCalculation(); - this.totalTimePerStep = timingCalc.calculateTotalTime(modeString, numMeas, overhead, lineFreq, value, sourceDelay, measDelay, stepToSweepDelay); + this.totalTimePerStep = timingCalc.calculateTotalTime(modeString, numMeas, overhead, lineFreq, modeValue, sourceDelay, measDelay, stepToSweepDelay); } } From 9251fef9f0b3008a57b07c745159fb2486921680 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 1 Dec 2025 11:27:17 +0530 Subject: [PATCH 14/28] sweep points addition --- .../plot-container.component.ts | 61 ++++++++----------- .../components/utils/timing-calculation.ts | 4 +- 2 files changed, 27 insertions(+), 38 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 2e795d3..5c4f1a8 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -71,6 +71,9 @@ export class PlotContainerComponent implements OnInit, OnChanges { plotConfig: { staticPlot: boolean; responsive: boolean } | undefined; totalTimePerStep: number | undefined; + modeString: 'Aperture' | 'NPLC' = 'Aperture'; + modeValue: number = 0; + ID: string = ''; constructor(public elementRef: ElementRef) { } @@ -95,76 +98,62 @@ export class PlotContainerComponent implements OnInit, OnChanges { } calculateTime(): void { - let modeString: 'Aperture' | 'NPLC'; - let modeValue: number | undefined; - let ID: string = ''; if (this.sweepChannels && this.sweepChannels.length > 0) { - const sweepId = this.sweepChannels[0].start_stop_channel.common_chan_attributes.device_id; - ID = sweepId; + this.ID = this.sweepChannels[0].start_stop_channel.common_chan_attributes.device_id; } else if (this.stepChannels && this.stepChannels.length > 0) { - const stepId = this.stepChannels[0].start_stop_channel.common_chan_attributes.device_id; - ID = stepId; + this.ID = this.stepChannels[0].start_stop_channel.common_chan_attributes.device_id; } else if (this.biasChannels && this.biasChannels.length > 0) { - const biasId = this.biasChannels[0].common_chan_attributes.device_id; - ID = biasId; + this.ID = this.biasChannels[0].common_chan_attributes.device_id; } else { this.plotDataX = [0, 1e-6, 2e-6, 3e-6, 4e-6, 5e-6, 6e-6, 7e-6, 8e-6, 9e-6, 10e-6]; } - const result = this.checkDeviceType(ID); - modeString = result.modeString; - modeValue = result.modeValue; - this.calculateTimePerStep(modeString, modeValue); + const result = this.checkDeviceType(this.ID); + this.modeString = result.modeString; + this.modeValue = result.modeValue; + this.calculateTimePerStep(); } - checkDeviceType(ID: string): {modeString: 'Aperture' | 'NPLC'; modeValue : number } { + checkDeviceType(ID: string): { modeString: 'Aperture' | 'NPLC'; modeValue: number } { let mode = this.sweepTimingConfig?.smu_timing.nplc_type.value; - let modeString = mode as 'Aperture' | 'NPLC'; - let modeValue: number = 0; + this.modeString = mode as 'Aperture' | 'NPLC'; + this.modeValue = 0; let rate = this.sweepTimingConfig?.psu_timing.rate.value; if (ID.includes('smu') && this.sweepTimingConfig) { mode = this.sweepTimingConfig?.smu_timing.nplc_type.value; if (mode === 'NPLC') { - modeString = 'NPLC'; - modeValue = this.sweepTimingConfig?.smu_timing.nplc.value; + this.modeString = 'NPLC'; + this.modeValue = this.sweepTimingConfig?.smu_timing.nplc.value; } else if (mode === 'Aperture') { - modeString = 'Aperture'; - modeValue = this.sweepTimingConfig?.smu_timing.aperture.value; + this.modeString = 'Aperture'; + this.modeValue = this.sweepTimingConfig?.smu_timing.aperture.value; } } else if (ID.includes('psu') && this.sweepTimingConfig) { mode = 'Aperture'; - modeString = 'Aperture' + this.modeString = 'Aperture'; if (rate === 'Fast') { - modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[1]; + this.modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[1]; } else if (rate === 'Normal') { - modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[0]; + this.modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[0]; } } - return { modeString, modeValue }; + return { modeString: this.modeString, modeValue: this.modeValue }; } - calculateTimePerStep(modeString : 'Aperture' | 'NPLC', modeValue: number): void { - if (this.sweepTimingConfig && this.stepGlobalParameters && this.globalParameters) { + calculateTimePerStep(): void { + if (this.sweepTimingConfig && this.stepGlobalParameters && this.globalParameters && this.sweepGlobalParameters) { const numMeas = this.sweepTimingConfig.measure_count.value; const lineFreq = this.globalParameters.line_frequency; const overhead = this.globalParameters.overhead_time; const sourceDelay = this.sweepTimingConfig.smu_timing.source_delay.value; const measDelay = this.sweepTimingConfig.smu_timing.measure_delay.value; const stepToSweepDelay = this.stepGlobalParameters.step_to_sweep_delay.value; - - // const mode = this.sweepTimingConfig.smu_timing.nplc_type.value; - // const modeString = mode as 'Aperture' | 'NPLC'; // Made same as JSON string - // let value: number; - // if (mode === 'NPLC') { - // value = this.sweepTimingConfig.smu_timing.nplc.value; - // } else { - // value = this.sweepTimingConfig.smu_timing.aperture.value; - // } + const sweepPoints = this.sweepGlobalParameters.sweep_points.value; const timingCalc = new TimingCalculation(); - this.totalTimePerStep = timingCalc.calculateTotalTime(modeString, numMeas, overhead, lineFreq, modeValue, sourceDelay, measDelay, stepToSweepDelay); + this.totalTimePerStep = timingCalc.calculateTotalTime(this.modeString, numMeas, overhead, lineFreq, this.modeValue, sourceDelay, measDelay, stepToSweepDelay, sweepPoints); } } 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 2a2226c..76e4a3c 100644 --- a/script-gen-ui/src/app/components/utils/timing-calculation.ts +++ b/script-gen-ui/src/app/components/utils/timing-calculation.ts @@ -17,7 +17,7 @@ export class TimingCalculation { * @param measDelay measure delay (s) * @param stepToSweepDelay step to sweep delay (s) */ - calculateTotalTime(mode: 'Aperture' | 'NPLC', numMeas: number, overhead: number, lineFreq: number, value: number, sourceDelay: number, measDelay: number, stepToSweepDelay: number): number { + calculateTotalTime(mode: 'Aperture' | 'NPLC', numMeas: number, overhead: number, lineFreq: number, value: number, sourceDelay: number, measDelay: number, stepToSweepDelay: number, sweepPoints: number): number { this.overhead = overhead; this.lineFreq = lineFreq; this.numMeas = numMeas; @@ -26,6 +26,6 @@ export class TimingCalculation { } else if (mode === 'NPLC') { this.measTime = (this.numMeas * ((1 / this.lineFreq) * value) + measDelay) + sourceDelay; } - return stepToSweepDelay + this.overhead + this.measTime; + return sweepPoints*(stepToSweepDelay + this.overhead + this.measTime); } } \ No newline at end of file From 826fe98d532fd083a092290502fce35871a960b1 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 1 Dec 2025 12:05:50 +0530 Subject: [PATCH 15/28] rate changes --- .../model/sweep_data/sweep_timing_config.rs | 9 ++++-- .../plot-container.component.ts | 32 ++++++++++--------- .../main-sweep/timing/timing.component.ts | 3 +- script-gen-ui/src/app/model/interface.ts | 3 +- .../app/model/sweep_data/SweepTimingConfig.ts | 9 ++++-- 5 files changed, 33 insertions(+), 23 deletions(-) diff --git a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs index 00ba6c9..47b9714 100644 --- a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs +++ b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs @@ -139,14 +139,16 @@ impl SmuTiming { #[derive(Serialize, Deserialize, Debug, Clone)] pub struct PsuTiming { rate: ParameterString, - aperture_value: Vec, + rate_normal: f64, + rate_fast: f64, } impl PsuTiming { pub fn new() -> Self { let mut psu_timing = PsuTiming { rate: ParameterString::new("rate"), - aperture_value: vec![], + rate_normal: 0.066667, + rate_fast: 0.016667, }; psu_timing.set_defaults(); psu_timing @@ -158,7 +160,8 @@ impl PsuTiming { BaseMetadata::RATE_FAST.to_string(), ]; self.rate.value = BaseMetadata::RATE_NORMAL.to_string(); - self.aperture_value = vec![0.066667, 0.016667]; // 66.667ms, 16.667ms + // self.rate_normal = 0.066667; + // self.rate_fast = 0.016667; } pub fn evaluate(&mut self) { diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 5c4f1a8..4fde8f1 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -121,22 +121,24 @@ export class PlotContainerComponent implements OnInit, OnChanges { this.modeString = mode as 'Aperture' | 'NPLC'; this.modeValue = 0; let rate = this.sweepTimingConfig?.psu_timing.rate.value; - if (ID.includes('smu') && this.sweepTimingConfig) { - mode = this.sweepTimingConfig?.smu_timing.nplc_type.value; - if (mode === 'NPLC') { - this.modeString = 'NPLC'; - this.modeValue = this.sweepTimingConfig?.smu_timing.nplc.value; - } else if (mode === 'Aperture') { + if (this.sweepTimingConfig) { + if (ID.includes('smu')) { + mode = this.sweepTimingConfig.smu_timing.nplc_type.value; + if (mode === 'NPLC') { + this.modeString = 'NPLC'; + this.modeValue = this.sweepTimingConfig.smu_timing.nplc.value; + } else if (mode === 'Aperture') { + this.modeString = 'Aperture'; + this.modeValue = this.sweepTimingConfig.smu_timing.aperture.value; + } + } else if (ID.includes('psu')) { + mode = 'Aperture'; this.modeString = 'Aperture'; - this.modeValue = this.sweepTimingConfig?.smu_timing.aperture.value; - } - } else if (ID.includes('psu') && this.sweepTimingConfig) { - mode = 'Aperture'; - this.modeString = 'Aperture'; - if (rate === 'Fast') { - this.modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[1]; - } else if (rate === 'Normal') { - this.modeValue = this.sweepTimingConfig?.psu_timing.aperture_value[0]; + if (rate === 'Fast') { + this.modeValue = this.sweepTimingConfig.psu_timing.rate_fast; + } else if (rate === 'Normal') { + this.modeValue = this.sweepTimingConfig.psu_timing.rate_normal; + } } } return { modeString: this.modeString, modeValue: this.modeValue }; diff --git a/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts b/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts index 75436be..0c8d554 100644 --- a/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/timing/timing.component.ts @@ -119,7 +119,8 @@ export class TimingComponent implements OnDestroy, OnChanges { }); const psu_timing = new PsuTiming({ rate: this.rate!, - aperture_value: this.sweepTimingConfig?.psu_timing.aperture_value || [], + rate_normal: this.sweepTimingConfig?.psu_timing.rate_normal || 0, + rate_fast: this.sweepTimingConfig?.psu_timing.rate_fast || 0, }); return new SweepTimingConfig({ measure_count: this.measureCount!, diff --git a/script-gen-ui/src/app/model/interface.ts b/script-gen-ui/src/app/model/interface.ts index d73f121..d5a6d60 100644 --- a/script-gen-ui/src/app/model/interface.ts +++ b/script-gen-ui/src/app/model/interface.ts @@ -39,7 +39,8 @@ export interface ISmuTiming { } export interface IPsuTiming { - aperture_value: number[]; + rate_normal: number; + rate_fast: number; rate: IParameterString; } diff --git a/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts b/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts index b1cb8f4..2db1448 100644 --- a/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts +++ b/script-gen-ui/src/app/model/sweep_data/SweepTimingConfig.ts @@ -118,17 +118,20 @@ export class SmuTiming { export class PsuTiming { rate: ParameterString; - aperture_value: number[]; + rate_normal: number; + rate_fast: number; constructor(data: IPsuTiming) { this.rate = new ParameterString(data.rate); - this.aperture_value = data.aperture_value; + this.rate_normal = data.rate_normal; + this.rate_fast = data.rate_fast; } toJSON() { return { rate: this.rate.toJSON(), - aperture_value: this.aperture_value, + rate_normal: this.rate_normal, + rate_fast: this.rate_fast, }; } } From aea5862b82d3e25c9ffd3115655d91a057d9917e Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 1 Dec 2025 16:18:54 +0530 Subject: [PATCH 16/28] plot step changes --- .../plot-bias/plot-bias.component.ts | 11 --- .../plot-container.component.html | 1 + .../plot-container.component.ts | 2 +- .../plot-step/plot-step.component.ts | 67 +++++-------------- 4 files changed, 20 insertions(+), 61 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index 136d607..9df931d 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -279,17 +279,6 @@ export class PlotBiasComponent } private generateXAxisData(): void { - // if (!this.stepGlobalParameters) return; - - // const numSteps = this.stepGlobalParameters.step_points?.value ?? 1; - // const delayTime = this.stepGlobalParameters.step_to_sweep_delay?.value ?? 0; - - // Generate x-axis data using the same formula as step and sweep components - // const xData: number[] = []; - // for (let i = 0; i <= numSteps; i++) { - // xData.push(i * (1 + delayTime)); - // } - this.plotData1.x = this.plotDataX; // Calculate total time and dtick (same as step/sweep components) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html index 8984d70..73aaba9 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html @@ -20,6 +20,7 @@ [stepGlobalParameters]="stepGlobalParameters" [plotDataX]="plotDataX" [plotConfig]="plotConfig" + [tickDifference]="totalTimePerStep" [isActive]="activeComponent === 'step' && activeIndex === i" [activeStyle]="getActiveStyle(stepChannel.start_stop_channel.common_chan_attributes.uuid, 'step', i)" [color]="getColor(stepChannel.start_stop_channel.common_chan_attributes.uuid)" diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 4fde8f1..ab7b523 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -162,7 +162,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { plotdataXCalculation(): void { if (this.totalTimePerStep) { const points = 11; - const xData: number[] = [0]; + const xData: number[] = []; for (let i = 0; i < points; i++) { xData.push(i * this.totalTimePerStep); } diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts index e3b7688..fb1bcc7 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts @@ -38,6 +38,7 @@ export class PlotStepComponent @Input() stepGlobalParameters: StepGlobalParameters | undefined; @Input() plotDataX: number[] = []; + @Input() tickDifference: number | undefined; @Input() plotConfig: { staticPlot: boolean } | undefined; @Input() stepPointsList: ParameterFloat[][] = []; @@ -262,27 +263,26 @@ export class PlotStepComponent onResize(): void { this.windowHeight = window.innerHeight; this.windowWidth = window.innerWidth; - console.log('Window resized'); + // console.log('Window resized'); this.plotLayout.width = (this.windowWidth * 58) / 100; this.renderPlot(); - console.log('Plot resized to:', this.plotLayout.width); + // console.log('Plot resized to:', this.plotLayout.width); } private generatePlotData(yData: number[], type: string): void { - if (this.stepPoints && this.stepToSweepDelay) { + if (this.stepPoints && this.stepToSweepDelay && this.tickDifference) { const delayTime = this.stepToSweepDelay?.value ?? 0; const targetLength = this.plotWidth; let processedYData = [...yData]; - let processedXData: number[] = []; - const numberofSteps: number = this.stepPoints.value; - processedXData = Array.from({ length: processedYData.length }, (_, i) => (i / (processedYData.length - 1) * numberofSteps)).concat(numberofSteps).flat(); + // let processedXData: number[] = []; + // const numberofSteps: number = this.stepPoints.value; + // processedXData = Array.from({ length: processedYData.length }, (_, i) => (i / (processedYData.length - 1) * numberofSteps)).concat(numberofSteps).flat(); // Adding delay first if its exists - if (delayTime > 0) { - const { x, y } = this.generateDataWithDelay(processedYData, processedXData, delayTime); - processedXData = x; - processedYData = y; - } + // if (delayTime > 0) { + // const { y } = this.generateDataWithDelay(processedYData, delayTime); + // processedYData = y; + // } if (processedYData.length > targetLength) { if (type == 'LIN' || type == 'LOG' || type == 'LIST') { @@ -296,58 +296,27 @@ export class PlotStepComponent // Interpolate by sampling the delay-generated data at calculated indices processedYData = indices.map(i => processedYData[i]); - processedXData = indices.map(i => processedXData[i]); + // processedXData = indices.map(i => processedXData[i]); } else { // Without delay, use original interpolation method const interpolated = PlotUtils.minMaxInterpolation(processedYData, targetLength); processedYData = interpolated.y; - processedXData = Array.from({ length: processedYData.length }, (_, i) => (i / (processedYData.length - 1) * numberofSteps)).concat(numberofSteps).flat(); + // processedXData = Array.from({ length: processedYData.length }, (_, i) => (i / (processedYData.length - 1) * numberofSteps)).concat(numberofSteps).flat(); } } } - this.plotData1.x = processedXData; + this.plotData1.x = this.plotDataX; this.plotData1.y = processedYData; - const totalTime = this.stepPoints.value * (1 + delayTime); // Each step now takes (1 + delayTime) units + // const totalTime = this.stepPoints.value * (1 + delayTime); // Each step now takes (1 + delayTime) units - this.plotLayout.xaxis.dtick = totalTime / 10; - this.plotLayout.xaxis.range = [0, totalTime]; + this.plotLayout.xaxis.dtick = this.tickDifference; + this.plotLayout.xaxis.range = [0, this.tickDifference * 10]; + console.log('plotdata', this.plotData1); } } - private generateDataWithDelay(yData: number[], xData: number[], delayTime: number): { x: number[], y: number[] } { - const finalX: number[] = []; - const finalY: number[] = []; - const delayPoints = Math.max(5, Math.floor(delayTime * 10)); - const numSteps = yData.length - 1; // Exclude the final repeated point - - // Generate data for each step with delay - for (let step = 0; step < numSteps; step++) { - const stepStartTime = step * (1 + delayTime); - const currentYValue = yData[step]; - - // Add delay period (repeat current y value) at the beginning of each step - for (let d = 0; d < delayPoints; d++) { - finalX.push(stepStartTime + (d * delayTime) / delayPoints); - finalY.push(currentYValue); - } - - // Add the actual step point after delay - finalX.push(stepStartTime + delayTime); - finalY.push(currentYValue); - } - - // Add final point - if (yData.length > 0) { - const finalStepTime = numSteps * (1 + delayTime); - finalX.push(finalStepTime); - finalY.push(yData[yData.length - 1]); - } - - return { x: finalX, y: finalY }; - } - private stepListPlot() { if (this.listStep && this.stepPoints && this.stop) { const stepValues = this.listStep From 967877ea9411894dca61473d96dc5f37749b2b58 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 1 Dec 2025 16:22:24 +0530 Subject: [PATCH 17/28] ng lint --- .../main-sweep/plot-container/plot-container.component.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index ab7b523..943ad7c 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -72,8 +72,8 @@ export class PlotContainerComponent implements OnInit, OnChanges { totalTimePerStep: number | undefined; modeString: 'Aperture' | 'NPLC' = 'Aperture'; - modeValue: number = 0; - ID: string = ''; + modeValue = 0; + ID = ''; constructor(public elementRef: ElementRef) { } @@ -120,7 +120,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { let mode = this.sweepTimingConfig?.smu_timing.nplc_type.value; this.modeString = mode as 'Aperture' | 'NPLC'; this.modeValue = 0; - let rate = this.sweepTimingConfig?.psu_timing.rate.value; + const rate = this.sweepTimingConfig?.psu_timing.rate.value; if (this.sweepTimingConfig) { if (ID.includes('smu')) { mode = this.sweepTimingConfig.smu_timing.nplc_type.value; From 8c6c41e27765f4297c84b0494917acce287eda08 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 1 Dec 2025 16:28:08 +0530 Subject: [PATCH 18/28] commented code removed --- .../src/model/sweep_data/sweep_timing_config.rs | 2 -- .../plot-container/plot-bias/plot-bias.component.ts | 4 ---- 2 files changed, 6 deletions(-) diff --git a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs index 47b9714..c416de7 100644 --- a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs +++ b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs @@ -160,8 +160,6 @@ impl PsuTiming { BaseMetadata::RATE_FAST.to_string(), ]; self.rate.value = BaseMetadata::RATE_NORMAL.to_string(); - // self.rate_normal = 0.066667; - // self.rate_fast = 0.016667; } pub fn evaluate(&mut self) { diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index 9df931d..69c557e 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -280,14 +280,10 @@ export class PlotBiasComponent private generateXAxisData(): void { this.plotData1.x = this.plotDataX; - - // Calculate total time and dtick (same as step/sweep components) - // const totalTime = numSteps * (1 + delayTime); if (this.tickDifference) { this.plotLayout.xaxis.dtick = this.tickDifference; this.plotLayout.xaxis2.dtick = this.tickDifference; } - } private updatePlotLayout(): void { From 1e01daf3235d90252e26b6b3c59aded8fa2048c6 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 2 Dec 2025 11:48:17 +0530 Subject: [PATCH 19/28] tick difference changes --- .../plot-container.component.html | 4 +- .../plot-container.component.ts | 6 ++- .../plot-step/plot-step.component.ts | 45 +++++++++++-------- 3 files changed, 33 insertions(+), 22 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html index 73aaba9..41debe6 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html @@ -4,7 +4,7 @@ [biasChannel]="biasChannel" [plotDataX]="plotDataX" [plotConfig]="plotConfig" - [tickDifference]="totalTimePerStep" + [tickDifference]="tickDifference" [stepGlobalParameters]="stepGlobalParameters" [isActive]="activeComponent === 'bias' && activeIndex === i" [activeStyle]="getActiveStyle(biasChannel.common_chan_attributes.uuid, 'bias', i)" @@ -20,7 +20,7 @@ [stepGlobalParameters]="stepGlobalParameters" [plotDataX]="plotDataX" [plotConfig]="plotConfig" - [tickDifference]="totalTimePerStep" + [tickDifference]="tickDifference" [isActive]="activeComponent === 'step' && activeIndex === i" [activeStyle]="getActiveStyle(stepChannel.start_stop_channel.common_chan_attributes.uuid, 'step', i)" [color]="getColor(stepChannel.start_stop_channel.common_chan_attributes.uuid)" diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 943ad7c..7764384 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -74,6 +74,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { modeString: 'Aperture' | 'NPLC' = 'Aperture'; modeValue = 0; ID = ''; + tickDifference = 0; constructor(public elementRef: ElementRef) { } @@ -160,13 +161,14 @@ export class PlotContainerComponent implements OnInit, OnChanges { } plotdataXCalculation(): void { - if (this.totalTimePerStep) { - const points = 11; + if (this.totalTimePerStep && this.stepGlobalParameters) { + const points = this.stepGlobalParameters.step_points.value; const xData: number[] = []; for (let i = 0; i < points; i++) { xData.push(i * this.totalTimePerStep); } this.plotDataX = xData; + this.tickDifference = xData.length / 10; } } diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts index fb1bcc7..0fbe604 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts @@ -318,28 +318,38 @@ export class PlotStepComponent } private stepListPlot() { - if (this.listStep && this.stepPoints && this.stop) { - const stepValues = this.listStep - .map((pf) => pf?.value ?? 0) - .concat(this.listStep[this.listStep.length - 1]?.value ?? 0); + if (this.listStep && this.plotDataX && this.plotDataX.length > 0) { + // Generate y values to match plotDataX length + let stepValues = this.listStep.map((pf) => pf?.value ?? 0); + // If not enough values, pad or interpolate + if (stepValues.length < this.plotDataX.length) { + // Pad with last value + const padValue = stepValues[stepValues.length - 1] ?? 0; + stepValues = stepValues.concat(Array(this.plotDataX.length - stepValues.length).fill(padValue)); + } else if (stepValues.length > this.plotDataX.length) { + // Truncate + stepValues = stepValues.slice(0, this.plotDataX.length); + } this.generatePlotData(stepValues, 'LIST'); } this.renderPlot(); } private stepValues() { - if (this.start && this.stop && this.stepPoints) { - document.body.classList.add('wait-cursor'); // Force wait cursor everywhere - const stepSize = - (this.stop.value - this.start.value) / (this.stepPoints.value - 1); - const yData = Array.from( - { length: this.stepPoints.value }, - (_, i) => (this.start?.value ?? 0) + i * stepSize - ).concat(this.stop?.value ?? 0); - + if (this.start && this.stop && this.plotDataX && this.plotDataX.length > 0 && this.stepPoints) { + const numberOfSteps = this.stepPoints.value; + const stepWidth = Math.floor(this.plotDataX.length / numberOfSteps); + // const remainder = this.plotDataX.length % numberOfSteps; + const stepSize = (this.stop.value - this.start.value) / (numberOfSteps - 1); + let yData: number[] = []; + for (let step = 0; step < numberOfSteps; step++) { + const value = (this.start.value) + step * stepSize; + const width = stepWidth; + yData = yData.concat(Array(width).fill(value)); + } + yData = yData.concat(this.stop.value); this.generatePlotData(yData, 'LIN'); } - document.body.classList.remove('wait-cursor'); // Restore cursor after rendering } private updatePlotLayout(): void { @@ -391,10 +401,10 @@ export class PlotStepComponent // this.plotLayout.xaxis.type = 'log'; // this.plotData1.line.shape = 'vh'; - if (this.start && this.stop && this.stepPoints) { + if (this.start && this.stop && this.plotDataX && this.plotDataX.length > 0) { const startValue = this.start.value > 0 ? this.start.value : 1e-12; const stopValue = this.stop.value > 0 ? this.stop.value : 1e-12; - const numPoints = this.stepPoints.value; + const numPoints = this.plotDataX.length; const stepFactor = Math.pow( stopValue / startValue, 1 / (numPoints - 1) @@ -403,8 +413,7 @@ export class PlotStepComponent const yData = Array.from( { length: numPoints }, (_, i) => startValue * Math.pow(stepFactor, i) - ).concat(this.stop.value); - + ); this.generatePlotData(yData, 'LOG'); } } else { From 0b96f37d1b7b5e907c66b5cd64287c3752b885ca Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 2 Dec 2025 12:31:37 +0530 Subject: [PATCH 20/28] working plot-step and plot-bias --- .../plot-container/plot-bias/plot-bias.component.ts | 2 ++ .../plot-container/plot-container.component.ts | 9 +++++---- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index 69c557e..f8ce848 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -83,6 +83,7 @@ export class PlotBiasComponent type: 'linear', position: 20, linewidth: 1, + range: [0,1], }, xaxis2: { visible: true, @@ -283,6 +284,7 @@ export class PlotBiasComponent if (this.tickDifference) { this.plotLayout.xaxis.dtick = this.tickDifference; this.plotLayout.xaxis2.dtick = this.tickDifference; + this.plotLayout.xaxis.range = [0, this.tickDifference * 10]; } } diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts index 7764384..97f5e53 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.ts @@ -82,7 +82,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { this.plotConfig = { staticPlot: true, responsive: true }; // this.calculateTimePerStep(); this.calculateTime(); - this.plotdataXCalculation(); + // this.plotdataXCalculation(); // console.log("plodataX", this.plotDataX); if (this.stepGlobalParameters) { @@ -94,7 +94,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { if (changes['sweepGlobalParameters'] || changes['stepGlobalParameters'] && changes['sweepTimingConfig']) { // this.calculateTimePerStep(); this.calculateTime(); - this.plotdataXCalculation(); + // this.plotdataXCalculation(); } } @@ -157,6 +157,7 @@ export class PlotContainerComponent implements OnInit, OnChanges { const timingCalc = new TimingCalculation(); this.totalTimePerStep = timingCalc.calculateTotalTime(this.modeString, numMeas, overhead, lineFreq, this.modeValue, sourceDelay, measDelay, stepToSweepDelay, sweepPoints); + this.plotdataXCalculation(); } } @@ -164,11 +165,11 @@ export class PlotContainerComponent implements OnInit, OnChanges { if (this.totalTimePerStep && this.stepGlobalParameters) { const points = this.stepGlobalParameters.step_points.value; const xData: number[] = []; - for (let i = 0; i < points; i++) { + for (let i = 0; i < points + 1; i++) { xData.push(i * this.totalTimePerStep); } this.plotDataX = xData; - this.tickDifference = xData.length / 10; + this.tickDifference = xData[points]/10; } } From 3390e15eca5738ba54dcbaa20b5e61484dea87ed Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 2 Dec 2025 14:23:03 +0530 Subject: [PATCH 21/28] plot-step working for all cases --- .../plot-step/plot-step.component.ts | 37 ++++--------------- .../main-sweep/plot-container/plot-utils.ts | 8 +--- 2 files changed, 9 insertions(+), 36 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts index 0fbe604..463252c 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts @@ -274,43 +274,20 @@ export class PlotStepComponent const delayTime = this.stepToSweepDelay?.value ?? 0; const targetLength = this.plotWidth; let processedYData = [...yData]; - // let processedXData: number[] = []; - // const numberofSteps: number = this.stepPoints.value; - // processedXData = Array.from({ length: processedYData.length }, (_, i) => (i / (processedYData.length - 1) * numberofSteps)).concat(numberofSteps).flat(); - - // Adding delay first if its exists - // if (delayTime > 0) { - // const { y } = this.generateDataWithDelay(processedYData, delayTime); - // processedYData = y; - // } + let processedXData: number[] = this.plotDataX; if (processedYData.length > targetLength) { if (type == 'LIN' || type == 'LOG' || type == 'LIST') { - // If we have delay, we need to interpolate X,Y pairs together to maintain timing - // This was suggested to be better than interpolation in this case so the graph is continous in all places and works well in our use case - if (delayTime > 0) { - // Create indices for interpolation based on target length - const indices = Array.from({ length: targetLength }, (_, i) => - Math.floor((i / (targetLength - 1)) * (processedYData.length - 1)) - ); - - // Interpolate by sampling the delay-generated data at calculated indices - processedYData = indices.map(i => processedYData[i]); - // processedXData = indices.map(i => processedXData[i]); - } else { - // Without delay, use original interpolation method - const interpolated = PlotUtils.minMaxInterpolation(processedYData, targetLength); - processedYData = interpolated.y; - // processedXData = Array.from({ length: processedYData.length }, (_, i) => (i / (processedYData.length - 1) * numberofSteps)).concat(numberofSteps).flat(); - } + const interpolatedy = PlotUtils.minMaxInterpolation(processedYData, targetLength); + processedYData = interpolatedy.y; + const interpolatedx = PlotUtils.minMaxInterpolation(this.plotDataX, targetLength); + processedXData = interpolatedx.y; } } - this.plotData1.x = this.plotDataX; + this.plotData1.x = processedXData; this.plotData1.y = processedYData; - // const totalTime = this.stepPoints.value * (1 + delayTime); // Each step now takes (1 + delayTime) units - this.plotLayout.xaxis.dtick = this.tickDifference; this.plotLayout.xaxis.range = [0, this.tickDifference * 10]; console.log('plotdata', this.plotData1); @@ -347,7 +324,7 @@ export class PlotStepComponent const width = stepWidth; yData = yData.concat(Array(width).fill(value)); } - yData = yData.concat(this.stop.value); + yData = yData.concat(this.stop.value); this.generatePlotData(yData, 'LIN'); } } diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-utils.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-utils.ts index c3f9ec3..7bd7806 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-utils.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-utils.ts @@ -96,15 +96,13 @@ export class PlotUtils { static minMaxInterpolation( data: number[], targetLength: number - ): { x: number[]; y: number[] } { + ): { y: number[] } { const n = data.length; if (targetLength >= n) { return { - x: Array.from({ length: n }, (_, i) => i), y: data.slice(), }; } - const x: number[] = []; const y: number[] = []; const binSize = n / targetLength; for (let i = 0; i < targetLength; i++) { @@ -114,10 +112,8 @@ export class PlotUtils { if (bin.length > 0) { y.push(Math.min(...bin)); y.push(Math.max(...bin)); - x.push(i); - x.push(i); } } - return { x, y }; + return { y }; } } From c38858fa176df9bc16db0906931366fda38752d3 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 2 Dec 2025 18:31:37 +0530 Subject: [PATCH 22/28] plot-sweep changes --- .../plot-container.component.html | 2 + .../plot-sweep/plot-sweep.component.ts | 205 +++++++++--------- 2 files changed, 110 insertions(+), 97 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html index 41debe6..d48f39e 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html @@ -36,6 +36,8 @@ [stepGlobalParameters]="stepGlobalParameters" [plotDataX]="plotDataX" [plotConfig]="plotConfig" + [tickDifference]="tickDifference" + [totalTimePerStep]="totalTimePerStep" [isActive]="activeComponent === 'sweep' && activeIndex === i" [activeStyle]="getActiveStyle(sweepChannel.start_stop_channel.common_chan_attributes.uuid, 'sweep', i)" [color]="getColor(sweepChannel.start_stop_channel.common_chan_attributes.uuid)" 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 5c1059a..747cc6d 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 @@ -8,6 +8,7 @@ import { OnChanges, SimpleChanges, HostListener, + input, } from '@angular/core'; import { SweepChannel } from '../../../../model/chan_data/sweepChannel'; import { CommonChanAttributes } from '../../../../model/chan_data/defaultChannel'; @@ -42,7 +43,8 @@ export class PlotSweepComponent @Input() stepGlobalParameters: StepGlobalParameters | undefined; @Input() plotDataX: number[] = []; @Input() plotConfig: { staticPlot: boolean } | undefined; - @Input() sweepPointsList: ParameterFloat[][] = []; + @Input() tickDifference: number | undefined; + @Input() totalTimePerStep: number | undefined; @Input() isActive = false; @Input() activeStyle: { backgroundColor: string; color: string } = { @@ -294,110 +296,119 @@ export class PlotSweepComponent } } - private generatePlotDataxy(sweepValues: number[], xData?: number[]) { - if (this.numPoints && this.numSteps) { - const numSteps = this.numSteps; - const numberOfPoints = this.numPoints?.value; - const delayTime = this.stepToSweepDelay?.value ?? 0; - - if (delayTime > 0) { - const { x, y } = this.generateDataWithDelay(sweepValues, numSteps, numberOfPoints, delayTime, xData); - this.plotData1.x = x; - this.plotData1.y = y; - } else { - this.generateDataWithoutDelay(sweepValues, numSteps, numberOfPoints, xData); - } - } - } + // private generatePlotDataxy(sweepValues: number[], xData?: number[]) { + // if (this.numPoints && this.numSteps) { + // const numSteps = this.numSteps; + // const numberOfPoints = this.numPoints?.value; + // const delayTime = this.stepToSweepDelay?.value ?? 0; + + // // if (delayTime > 0) { + // // const { x, y } = this.generateDataWithDelay(sweepValues, numSteps, numberOfPoints, delayTime, xData); + // // this.plotData1.x = x; + // // this.plotData1.y = y; + // // } else { + // // this.generateDataWithoutDelay(sweepValues, numSteps, numberOfPoints, xData); + // // } + // } + // } + + // private generateDataWithDelay( + // sweepValues: number[], + // numSteps: number, + // numberOfPoints: number, + // delayTime: number, + // xData?: number[] + // ): { x: number[], y: number[] } { + // const finalX: number[] = []; + // const finalY: number[] = []; + // const delayPoints = Math.max(5, Math.floor(delayTime * 10)); + + // // Generate data for each step with delay + // for (let step = 0; step < numSteps; step++) { + // const stepStartTime = step * (1 + delayTime); + + // // Add delay period (zeros) at the beginning of each step + // for (let d = 0; d < delayPoints; d++) { + // finalX.push(stepStartTime + (d * delayTime) / delayPoints); + // finalY.push(0); + // } + + // // Add the actual sweep data for this step + // for (let j = 0; j < numberOfPoints; j++) { + // if (xData) { + // const originalIndex = step * numberOfPoints + j; + // if (originalIndex < xData.length) { + // finalX.push(stepStartTime + delayTime + (j / numberOfPoints)); + // } + // } else { + // finalX.push(stepStartTime + delayTime + (j / numberOfPoints)); + // } + // finalY.push(sweepValues[j]); + // } + // } + + // // Add final point + // if (sweepValues.length > 0) { + // const finalStepTime = numSteps * (1 + delayTime); + // finalX.push(finalStepTime); + // finalY.push(sweepValues[sweepValues.length - 1]); + // } + + // return { x: finalX, y: finalY }; + // } + + // private generateDataWithoutDelay(sweepValues: number[], numSteps: number, numberOfPoints: number, xData?: number[]) { + // this.plotData1.y = Array.from({ length: numSteps }, () => sweepValues) + // .flat() + // .concat(sweepValues[sweepValues.length - 1]); + + // if (xData) { + // this.plotData1.x = xData; + // } else { + // this.plotData1.x = Array.from({ length: numSteps }, (_, i) => + // Array.from({ length: numberOfPoints }, (_, j) => i + j / numberOfPoints) + // ) + // .flat() + // .concat(numSteps); + // } + // } - private generateDataWithDelay( - sweepValues: number[], - numSteps: number, - numberOfPoints: number, - delayTime: number, - xData?: number[] - ): { x: number[], y: number[] } { - const finalX: number[] = []; - const finalY: number[] = []; - const delayPoints = Math.max(5, Math.floor(delayTime * 10)); - - // Generate data for each step with delay - for (let step = 0; step < numSteps; step++) { - const stepStartTime = step * (1 + delayTime); - - // Add delay period (zeros) at the beginning of each step - for (let d = 0; d < delayPoints; d++) { - finalX.push(stepStartTime + (d * delayTime) / delayPoints); - finalY.push(0); - } - - // Add the actual sweep data for this step - for (let j = 0; j < numberOfPoints; j++) { - if (xData) { - const originalIndex = step * numberOfPoints + j; - if (originalIndex < xData.length) { - finalX.push(stepStartTime + delayTime + (j / numberOfPoints)); + private generatePlotData(sweepValues: number[], type: string) { + if (this.numPoints && this.numSteps && this.stepToSweepDelay && this.tickDifference && this.totalTimePerStep) { + const targetLength = this.plotWidth / this.numSteps; + let processedXData: number[] = []; + let processedYData: number[] = []; + + // Interpolate numPoints between each consecutive value in plotDataX + if (this.plotDataX && this.plotDataX.length > 1 && this.numPoints?.value) { + const numPoints = this.numPoints.value; + 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)); } - } else { - finalX.push(stepStartTime + delayTime + (j / numberOfPoints)); } - finalY.push(sweepValues[j]); + processedXData.push(this.plotDataX[this.plotDataX.length - 1]); + } else { + processedXData = this.plotDataX; } - } - - // Add final point - if (sweepValues.length > 0) { - const finalStepTime = numSteps * (1 + delayTime); - finalX.push(finalStepTime); - finalY.push(sweepValues[sweepValues.length - 1]); - } - - return { x: finalX, y: finalY }; - } - private generateDataWithoutDelay(sweepValues: number[], numSteps: number, numberOfPoints: number, xData?: number[]) { - this.plotData1.y = Array.from({ length: numSteps }, () => sweepValues) - .flat() - .concat(sweepValues[sweepValues.length - 1]); - - if (xData) { - this.plotData1.x = xData; - } else { - this.plotData1.x = Array.from({ length: numSteps }, (_, i) => - Array.from({ length: numberOfPoints }, (_, j) => i + j / numberOfPoints) - ) - .flat() - .concat(numSteps); - } - } - - private generatePlotData(sweepValues: number[], type: string) { - if (this.numPoints && this.numSteps && this.stepToSweepDelay) { - const targetLength = this.plotWidth / this.numSteps; - - if (this.numPoints?.value > targetLength) { - let xData: number[] = []; - if (type == 'LIN' || type == 'LOG' || type == 'LIST') { - const interpolated = PlotUtils.minMaxInterpolation( - sweepValues, - targetLength - ); - sweepValues = interpolated.y; - } - xData = Array.from({ length: this.numSteps }, (_, i) => - Array.from({ length: sweepValues.length }, (_, j) => i + j / sweepValues.length)).flat().concat(this.numSteps) - this.generatePlotDataxy(sweepValues, xData); + processedYData = PlotUtils.minMaxInterpolation( + sweepValues, + targetLength + ).y; } else { - this.generatePlotDataxy(sweepValues); + processedYData = sweepValues; } - - // Update x-axis range to include delay time for each step - const delayTime = this.stepToSweepDelay.value; - const totalTime = this.numSteps * (1 + delayTime); // Each step now takes (1 + delayTime) units - - this.plotLayout.xaxis.dtick = totalTime / 10; - this.plotLayout.xaxis.range = [0, totalTime]; + this.plotData1.x = processedXData; + this.plotData1.y = Array.from({ length: this.numSteps }, () => sweepValues) + .flat() + .concat(sweepValues[sweepValues.length - 1]); + + this.plotLayout.xaxis.dtick = this.tickDifference; + this.plotLayout.xaxis.range = [0, this.tickDifference * 10]; } } From a131302e83ceae91bc74e4ddc57cafd37409ff12 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 2 Dec 2025 19:24:03 +0530 Subject: [PATCH 23/28] ng lint --- .../plot-step/plot-step.component.ts | 1 - .../plot-sweep/plot-sweep.component.ts | 89 ++----------------- 2 files changed, 6 insertions(+), 84 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts index 463252c..5e19906 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts @@ -271,7 +271,6 @@ export class PlotStepComponent private generatePlotData(yData: number[], type: string): void { if (this.stepPoints && this.stepToSweepDelay && this.tickDifference) { - const delayTime = this.stepToSweepDelay?.value ?? 0; const targetLength = this.plotWidth; let processedYData = [...yData]; let processedXData: number[] = this.plotDataX; 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 747cc6d..b563f91 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 @@ -7,8 +7,7 @@ import { OnInit, OnChanges, SimpleChanges, - HostListener, - input, + HostListener } from '@angular/core'; import { SweepChannel } from '../../../../model/chan_data/sweepChannel'; import { CommonChanAttributes } from '../../../../model/chan_data/defaultChannel'; @@ -292,88 +291,11 @@ export class PlotSweepComponent (_, i) => startValue + i * stepSize ).flat(); - this.generatePlotData(sweepValues, 'LIN'); + this.generatePlotData(sweepValues); } } - // private generatePlotDataxy(sweepValues: number[], xData?: number[]) { - // if (this.numPoints && this.numSteps) { - // const numSteps = this.numSteps; - // const numberOfPoints = this.numPoints?.value; - // const delayTime = this.stepToSweepDelay?.value ?? 0; - - // // if (delayTime > 0) { - // // const { x, y } = this.generateDataWithDelay(sweepValues, numSteps, numberOfPoints, delayTime, xData); - // // this.plotData1.x = x; - // // this.plotData1.y = y; - // // } else { - // // this.generateDataWithoutDelay(sweepValues, numSteps, numberOfPoints, xData); - // // } - // } - // } - - // private generateDataWithDelay( - // sweepValues: number[], - // numSteps: number, - // numberOfPoints: number, - // delayTime: number, - // xData?: number[] - // ): { x: number[], y: number[] } { - // const finalX: number[] = []; - // const finalY: number[] = []; - // const delayPoints = Math.max(5, Math.floor(delayTime * 10)); - - // // Generate data for each step with delay - // for (let step = 0; step < numSteps; step++) { - // const stepStartTime = step * (1 + delayTime); - - // // Add delay period (zeros) at the beginning of each step - // for (let d = 0; d < delayPoints; d++) { - // finalX.push(stepStartTime + (d * delayTime) / delayPoints); - // finalY.push(0); - // } - - // // Add the actual sweep data for this step - // for (let j = 0; j < numberOfPoints; j++) { - // if (xData) { - // const originalIndex = step * numberOfPoints + j; - // if (originalIndex < xData.length) { - // finalX.push(stepStartTime + delayTime + (j / numberOfPoints)); - // } - // } else { - // finalX.push(stepStartTime + delayTime + (j / numberOfPoints)); - // } - // finalY.push(sweepValues[j]); - // } - // } - - // // Add final point - // if (sweepValues.length > 0) { - // const finalStepTime = numSteps * (1 + delayTime); - // finalX.push(finalStepTime); - // finalY.push(sweepValues[sweepValues.length - 1]); - // } - - // return { x: finalX, y: finalY }; - // } - - // private generateDataWithoutDelay(sweepValues: number[], numSteps: number, numberOfPoints: number, xData?: number[]) { - // this.plotData1.y = Array.from({ length: numSteps }, () => sweepValues) - // .flat() - // .concat(sweepValues[sweepValues.length - 1]); - - // if (xData) { - // this.plotData1.x = xData; - // } else { - // this.plotData1.x = Array.from({ length: numSteps }, (_, i) => - // Array.from({ length: numberOfPoints }, (_, j) => i + j / numberOfPoints) - // ) - // .flat() - // .concat(numSteps); - // } - // } - - private generatePlotData(sweepValues: number[], type: string) { + private generatePlotData(sweepValues: number[]) { if (this.numPoints && this.numSteps && this.stepToSweepDelay && this.tickDifference && this.totalTimePerStep) { const targetLength = this.plotWidth / this.numSteps; let processedXData: number[] = []; @@ -402,6 +324,7 @@ export class PlotSweepComponent } else { processedYData = sweepValues; } + console.log(processedYData); this.plotData1.x = processedXData; this.plotData1.y = Array.from({ length: this.numSteps }, () => sweepValues) .flat() @@ -472,7 +395,7 @@ export class PlotSweepComponent (_, i) => startValue * Math.pow(stepFactor, i) ); - this.generatePlotData(sweepValues, 'LOG'); + this.generatePlotData(sweepValues); } } } @@ -480,7 +403,7 @@ export class PlotSweepComponent private sweepListPlot(): void { if (this.listSweep) { const sweepValues = this.listSweep.map((pf) => pf?.value ?? 0); - this.generatePlotData(sweepValues, 'LIST'); + this.generatePlotData(sweepValues); } } From b29ce19f93bcecc2acbc14de18aa3a4f584ed3c9 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Thu, 4 Dec 2025 12:03:07 +0530 Subject: [PATCH 24/28] displaying values in engineering notations and displaying timeperstep above step plot --- .../plot-container/plot-bias/plot-bias.component.ts | 4 +++- .../plot-container/plot-container.component.html | 1 + .../plot-container/plot-step/plot-step.component.html | 4 ++-- .../plot-container/plot-step/plot-step.component.ts | 11 +++++++++-- .../plot-container/plot-sweep/plot-sweep.component.ts | 2 ++ 5 files changed, 17 insertions(+), 5 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index f8ce848..d511f86 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -83,7 +83,9 @@ export class PlotBiasComponent type: 'linear', position: 20, linewidth: 1, - range: [0,1], + range: [0, 1], + tickformat: '.3~s', + exponentformat: 'SI' }, xaxis2: { visible: true, diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html index d48f39e..977b30e 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-container.component.html @@ -21,6 +21,7 @@ [plotDataX]="plotDataX" [plotConfig]="plotConfig" [tickDifference]="tickDifference" + [totalTimePerStep]="totalTimePerStep" [isActive]="activeComponent === 'step' && activeIndex === i" [activeStyle]="getActiveStyle(stepChannel.start_stop_channel.common_chan_attributes.uuid, 'step', i)" [color]="getColor(stepChannel.start_stop_channel.common_chan_attributes.uuid)" diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.html b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.html index bb67dba..754b966 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.html +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.html @@ -14,8 +14,8 @@

{{ chanName }}

{{ deviceID }}

- + +

Time Per Step: {{ totalTimePerStepConverted }}

diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts index 5e19906..199b0f1 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts @@ -24,6 +24,7 @@ import { FormsModule } from '@angular/forms'; import { MatIconModule } from '@angular/material/icon'; import { BrowserModule } from '@angular/platform-browser'; import { PlotUtils } from '../plot-utils'; +import { parseScientificInput } from '../../../controls/input-parser.util'; @Component({ selector: 'app-plot-step', @@ -40,7 +41,9 @@ export class PlotStepComponent @Input() plotDataX: number[] = []; @Input() tickDifference: number | undefined; @Input() plotConfig: { staticPlot: boolean } | undefined; - @Input() stepPointsList: ParameterFloat[][] = []; + @Input() totalTimePerStep: number | undefined; + totalTimePerStepConverted: string | undefined; + private _isActive = false; @@ -112,6 +115,8 @@ export class PlotStepComponent type: 'linear', position: 20, linewidth: 1, + tickformat: '.3~s', + exponentformat: 'SI' }, xaxis2: { visible: true, @@ -218,7 +223,7 @@ export class PlotStepComponent } ngOnInit() { - if (this.stepChannel && this.stepGlobalParameters) { + if (this.stepChannel && this.stepGlobalParameters && this.totalTimePerStep) { this.commonChanAttributes = this.stepChannel.start_stop_channel.common_chan_attributes; @@ -239,12 +244,14 @@ export class PlotStepComponent this.stepPoints = this.stepGlobalParameters.step_points; this.stepToSweepDelay = this.stepGlobalParameters.step_to_sweep_delay; + this.totalTimePerStepConverted = parseScientificInput(this.totalTimePerStep.toString(), 's'); } this.plotData1.x = this.plotDataX; this.plotData1.line.color = this.color; this.updatePlotLayout(); this.initializePlot(); this.observeThemeChanges(); + } // the plots are rendered only after the DOM is created, so we need to render them after the DOM is loaded 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 b563f91..b083291 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 @@ -110,6 +110,8 @@ export class PlotSweepComponent type: 'linear', position: 20, linewidth: 1, + tickformat: '.3~s', + exponentformat: 'SI' }, xaxis2: { visible: true, From 07ada754e5a377c9cfa380afb7b3ce48bc75e87b Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Thu, 4 Dec 2025 12:22:55 +0530 Subject: [PATCH 25/28] missed a zero in fast mode --- script-gen-manager/src/model/sweep_data/sweep_timing_config.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs index c416de7..e75ebc9 100644 --- a/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs +++ b/script-gen-manager/src/model/sweep_data/sweep_timing_config.rs @@ -148,7 +148,7 @@ impl PsuTiming { let mut psu_timing = PsuTiming { rate: ParameterString::new("rate"), rate_normal: 0.066667, - rate_fast: 0.016667, + rate_fast: 0.0016667, }; psu_timing.set_defaults(); psu_timing From b9d2015a9ca06892449b01d09b7044d82652959b Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 8 Dec 2025 09:53:08 +0530 Subject: [PATCH 26/28] ticksuffix changes --- .../plot-container/plot-bias/plot-bias.component.ts | 5 +++-- .../plot-container/plot-step/plot-step.component.ts | 2 +- .../plot-container/plot-sweep/plot-sweep.component.ts | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index d511f86..ef98340 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -58,7 +58,7 @@ export class PlotBiasComponent plotLayout = { xaxis: { visible: true, - ticksuffix: ' s', + ticksuffix: 's', rangemode: 'nonnegative', separatethousands: false, tickfont: { @@ -85,7 +85,8 @@ export class PlotBiasComponent linewidth: 1, range: [0, 1], tickformat: '.3~s', - exponentformat: 'SI' + exponentformat: 'SI', + // ticksuffix: ' W', // adding space }, xaxis2: { visible: true, diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts index 199b0f1..574dafc 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-step/plot-step.component.ts @@ -89,7 +89,7 @@ export class PlotStepComponent plotLayout = { xaxis: { visible: true, - ticksuffix: ' s', + ticksuffix: 's', rangemode: 'nonnegative', separatethousands: false, tickfont: { 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 b083291..4163461 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 @@ -84,7 +84,7 @@ export class PlotSweepComponent plotLayout = { xaxis: { visible: true, - ticksuffix: ' s', + ticksuffix: 's', rangemode: 'nonnegative', separatethousands: false, tickfont: { From 3909cd00d9c983d29bb78d3e77003f9d1a2f24f0 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Mon, 8 Dec 2025 18:37:46 +0530 Subject: [PATCH 27/28] removed duplicate ticksuffix --- .../main-sweep/plot-container/plot-bias/plot-bias.component.ts | 1 - 1 file changed, 1 deletion(-) diff --git a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts index ef98340..d1a9638 100644 --- a/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts +++ b/script-gen-ui/src/app/components/main-sweep/plot-container/plot-bias/plot-bias.component.ts @@ -86,7 +86,6 @@ export class PlotBiasComponent range: [0, 1], tickformat: '.3~s', exponentformat: 'SI', - // ticksuffix: ' W', // adding space }, xaxis2: { visible: true, From 312b6ffabe50b9aaed34106999ef9812dfa6b960 Mon Sep 17 00:00:00 2001 From: rajeshwari-kiwad Date: Tue, 9 Dec 2025 18:43:06 +0530 Subject: [PATCH 28/28] timing and plot-sweep changes --- .../plot-sweep/plot-sweep.component.ts | 40 +++++++++++++------ .../components/utils/timing-calculation.ts | 2 +- 2 files changed, 29 insertions(+), 13 deletions(-) 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