Skip to content

Commit 864ae77

Browse files
RajeshwriKrajeshwari-kiwad
andauthored
Timing changes for MP5000 module
Co-authored-by: rajeshwari-kiwad <[email protected]>
1 parent 02a7e43 commit 864ae77

File tree

16 files changed

+302
-394
lines changed

16 files changed

+302
-394
lines changed

kic-script-gen/src/back_end/client_server.rs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,32 @@ pub async fn start(mut script_model: ScriptModel) -> anyhow::Result<()> {
368368
if let Some(session) = session.as_mut() {
369369
session.text(response).await.unwrap();
370370
}
371+
} else if trimmed_line.contains("lineFrequency") {
372+
println!("line frequency received {}", trimmed_line);
373+
match serde_json::from_str::<serde_json::Value>(trimmed_line) {
374+
Ok(json_obj) => {
375+
if let Some(freq) = json_obj.get("lineFrequency").and_then(|v| v.as_f64()) {
376+
let mut data_model = app_state.data_model.lock().await;
377+
data_model
378+
.sweep_model
379+
.sweep_config
380+
.global_parameters
381+
.set_line_frequency(freq);
382+
println!("Set line frequency to {}", freq);
383+
} else {
384+
println!(
385+
"'lineFrequency' key not found or not a number in JSON: {}",
386+
trimmed_line
387+
);
388+
}
389+
}
390+
Err(e) => {
391+
println!(
392+
"Failed to parse line frequency JSON: {} | Error: {}",
393+
trimmed_line, e
394+
);
395+
}
396+
}
371397
} else if trimmed_line.contains("refresh") {
372398
println!("instrument data requested"); // refreshing by initiating session again does not affect the JSON state
373399
} else if trimmed_line.contains("reset") {

script-gen-manager/src/model/sweep_data/global_parameters.rs

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,37 @@ use serde::{Deserialize, Serialize};
22

33
use super::sweep_timing_config::SweepTimingConfig;
44

5+
fn default_overhead_time() -> f64 {
6+
78e-6
7+
}
8+
59
#[derive(Serialize, Deserialize, Debug, Clone)]
10+
#[serde(default)]
611
pub struct GlobalParameters {
712
pub sweep_timing_config: SweepTimingConfig,
13+
pub line_frequency: f64,
14+
#[serde(default = "default_overhead_time")]
15+
pub overhead_time: f64,
816
}
917

10-
impl GlobalParameters {
11-
pub fn new() -> Self {
18+
impl Default for GlobalParameters {
19+
fn default() -> Self {
1220
GlobalParameters {
1321
sweep_timing_config: SweepTimingConfig::new(),
22+
line_frequency: 60.0,
23+
overhead_time: 78e-6,
1424
}
1525
}
26+
}
1627

28+
impl GlobalParameters {
29+
pub fn new() -> Self {
30+
GlobalParameters::default()
31+
}
1732
pub fn evaluate(&mut self) {
1833
self.sweep_timing_config.evaluate();
1934
}
35+
pub fn set_line_frequency(&mut self, frequency: f64) {
36+
self.line_frequency = frequency;
37+
}
2038
}

script-gen-manager/src/model/sweep_data/sweep_timing_config.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -139,12 +139,16 @@ impl SmuTiming {
139139
#[derive(Serialize, Deserialize, Debug, Clone)]
140140
pub struct PsuTiming {
141141
rate: ParameterString,
142+
rate_normal: f64,
143+
rate_fast: f64,
142144
}
143145

144146
impl PsuTiming {
145147
pub fn new() -> Self {
146148
let mut psu_timing = PsuTiming {
147149
rate: ParameterString::new("rate"),
150+
rate_normal: 0.066667,
151+
rate_fast: 0.016667,
148152
};
149153
psu_timing.set_defaults();
150154
psu_timing

script-gen-ui/src/app/components/main-sweep/main-sweep.component.html

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -362,6 +362,8 @@ <h3>Sweep</h3>
362362
[sweepChannels]="sweepChannels"
363363
[stepGlobalParameters]="stepGlobalParameters"
364364
[sweepGlobalParameters]="sweepGlobalParameters"
365+
[sweepTimingConfig]="sweepTimingConfig"
366+
[globalParameters]="globalParameters"
365367
[colorMap]="colorMap"
366368
[activeComponent]="activeComponent"
367369
[activeIndex]="activeIndex"

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ import { BiasComponent } from './bias/bias.component';
1212
import { StepComponent } from './step/step.component';
1313
import { SweepComponent } from './sweep/sweep.component';
1414
import { WebSocketService } from '../../websocket.service';
15-
import { SweepConfig } from '../../model/sweep_data/sweepConfig';
15+
import { GlobalParameters, SweepConfig } from '../../model/sweep_data/sweepConfig';
1616
import {
1717
ParameterFloat,
1818
ParameterInt,
@@ -109,6 +109,7 @@ export class MainSweepComponent implements OnChanges {
109109
showPopupBox = false;
110110
showTiming = false;
111111
sweepTimingConfig: SweepTimingConfig | undefined;
112+
globalParameters: GlobalParameters | undefined;
112113
showList = false; //Sweep list popup box
113114
deviceList: Device[] = [];
114115
showBiasTooltip = false;
@@ -223,12 +224,14 @@ export class MainSweepComponent implements OnChanges {
223224
if (this.sweepConfig) {
224225
this.sweepTimingConfig =
225226
this.sweepConfig.global_parameters.sweep_timing_config;
227+
226228
this.deviceList = this.sweepConfig.device_list;
227229
this.biasChannels = this.sweepConfig.bias_channels;
228230
this.stepChannels = this.sweepConfig.step_channels;
229231
this.sweepChannels = this.sweepConfig.sweep_channels;
230232
this.stepGlobalParameters = this.sweepConfig.step_global_parameters;
231233
this.sweepGlobalParameters = this.sweepConfig.sweep_global_parameters;
234+
this.globalParameters = this.sweepConfig.global_parameters;
232235

233236
this.sweepPoints = this.sweepGlobalParameters.sweep_points;
234237
this.isListSweep = this.sweepGlobalParameters.list_sweep;

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

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,13 +32,13 @@ import { StepGlobalParameters } from '../../../../model/sweep_data/stepSweepConf
3232
styleUrl: './plot-bias.component.scss',
3333
})
3434
export class PlotBiasComponent
35-
implements AfterViewInit, OnInit, OnDestroy, OnChanges
36-
{
35+
implements AfterViewInit, OnInit, OnDestroy, OnChanges {
3736
@Input() biasChannel: BiasChannel | undefined;
3837
// @Input() plotData: any;
3938
// @Input() plotLayout: any;
4039
@Input() plotDataX: number[] = [];
4140
@Input() plotConfig: { staticPlot: boolean } | undefined;
41+
@Input() tickDifference: number | undefined;
4242
@Input() stepGlobalParameters: StepGlobalParameters | undefined;
4343
plotDivID = '';
4444

@@ -83,6 +83,7 @@ export class PlotBiasComponent
8383
type: 'linear',
8484
position: 20,
8585
linewidth: 1,
86+
range: [0,1],
8687
},
8788
xaxis2: {
8889
visible: true,
@@ -190,7 +191,7 @@ export class PlotBiasComponent
190191
measRange: ChannelRange | undefined;
191192
bias: ParameterFloat | undefined;
192193

193-
constructor(public elementRef: ElementRef) {}
194+
constructor(public elementRef: ElementRef) { }
194195

195196
ngOnInit(): void {
196197
if (this.biasChannel) {
@@ -205,8 +206,12 @@ export class PlotBiasComponent
205206
this.bias = this.biasChannel.bias;
206207

207208
this.plotDivID = `plotDiv${this.biasChannel.common_chan_attributes.chan_name}`;
209+
208210
}
209211

212+
this.plotData1.x = this.plotDataX;
213+
console.log("biasplotdata x", this.plotDataX, this.plotData1.x);
214+
210215
// Generate x-axis data if stepGlobalParameters are available
211216
if (this.stepGlobalParameters) {
212217
this.generateXAxisData();
@@ -218,6 +223,7 @@ export class PlotBiasComponent
218223
// Set constant y-values for bias
219224
const biasValue = this.bias?.value ?? 0;
220225
this.plotData1.y = new Array(this.plotData1.x.length).fill(biasValue);
226+
// this.generateXAxisData();
221227

222228
this.updatePlotLayout();
223229
this.plotData1.line.color = this.color;
@@ -239,6 +245,7 @@ export class PlotBiasComponent
239245
}
240246

241247
this.observeThemeChanges();
248+
this.plotData1.x = this.plotDataX;
242249
}
243250

244251
// the plots are rendered only after the DOM is created, so we need to render them after the DOM is loaded
@@ -273,23 +280,12 @@ export class PlotBiasComponent
273280
}
274281

275282
private generateXAxisData(): void {
276-
if (!this.stepGlobalParameters) return;
277-
278-
const numSteps = this.stepGlobalParameters.step_points?.value ?? 1;
279-
const delayTime = this.stepGlobalParameters.step_to_sweep_delay?.value ?? 0;
280-
281-
// Generate x-axis data using the same formula as step and sweep components
282-
const xData: number[] = [];
283-
for (let i = 0; i <= numSteps; i++) {
284-
xData.push(i * (1 + delayTime));
283+
this.plotData1.x = this.plotDataX;
284+
if (this.tickDifference) {
285+
this.plotLayout.xaxis.dtick = this.tickDifference;
286+
this.plotLayout.xaxis2.dtick = this.tickDifference;
287+
this.plotLayout.xaxis.range = [0, this.tickDifference * 10];
285288
}
286-
287-
this.plotData1.x = xData;
288-
289-
// Calculate total time and dtick (same as step/sweep components)
290-
const totalTime = numSteps * (1 + delayTime);
291-
this.plotLayout.xaxis.dtick = totalTime / 10;
292-
this.plotLayout.xaxis2.dtick = totalTime / 10;
293289
}
294290

295291
private updatePlotLayout(): void {
@@ -308,7 +304,7 @@ export class PlotBiasComponent
308304
max = Math.max(...range);
309305
}
310306
} else {
311-
max = parseToDecimal(this.sourceRange.value,(this.plotLayout.yaxis2.ticksuffix).trim());
307+
max = parseToDecimal(this.sourceRange.value, (this.plotLayout.yaxis2.ticksuffix).trim());
312308
}
313309
if (typeof max === 'number' && !isNaN(max)) {
314310
const maxRange = PlotUtils.computeMaxRange(-max, max);

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
[biasChannel]="biasChannel"
55
[plotDataX]="plotDataX"
66
[plotConfig]="plotConfig"
7+
[tickDifference]="tickDifference"
78
[stepGlobalParameters]="stepGlobalParameters"
89
[isActive]="activeComponent === 'bias' && activeIndex === i"
910
[activeStyle]="getActiveStyle(biasChannel.common_chan_attributes.uuid, 'bias', i)"
@@ -17,9 +18,9 @@
1718
<app-plot-step
1819
[stepChannel]="stepChannel"
1920
[stepGlobalParameters]="stepGlobalParameters"
20-
[stepPointsList]="listofStepPoints"
2121
[plotDataX]="plotDataX"
2222
[plotConfig]="plotConfig"
23+
[tickDifference]="tickDifference"
2324
[isActive]="activeComponent === 'step' && activeIndex === i"
2425
[activeStyle]="getActiveStyle(stepChannel.start_stop_channel.common_chan_attributes.uuid, 'step', i)"
2526
[color]="getColor(stepChannel.start_stop_channel.common_chan_attributes.uuid)"
@@ -33,9 +34,10 @@
3334
[sweepChannel]="sweepChannel"
3435
[sweepGlobalParameters]="sweepGlobalParameters"
3536
[stepGlobalParameters]="stepGlobalParameters"
36-
[sweepPointsList]="listofSweepPoints"
3737
[plotDataX]="plotDataX"
3838
[plotConfig]="plotConfig"
39+
[tickDifference]="tickDifference"
40+
[totalTimePerStep]="totalTimePerStep"
3941
[isActive]="activeComponent === 'sweep' && activeIndex === i"
4042
[activeStyle]="getActiveStyle(sweepChannel.start_stop_channel.common_chan_attributes.uuid, 'sweep', i)"
4143
[color]="getColor(sweepChannel.start_stop_channel.common_chan_attributes.uuid)"

0 commit comments

Comments
 (0)