Skip to content

Commit 119719a

Browse files
committed
Fix: allocation type request is not getting correct model object
Fix: script is not getting correct Device type for buffer Remove few unused imports Sense configuration has been removed for PSU UI string has been corrected
1 parent 7cbb5e5 commit 119719a

File tree

7 files changed

+108
-74
lines changed

7 files changed

+108
-74
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,8 @@ impl DataModel {
154154
// remove unused and invalid channels
155155
sweep_model.sweep_config.remove_unused_invalid_channels();
156156

157+
sweep_model.sweep_config.evaluate();
158+
157159
self.sweep_model = sweep_model.clone();
158160
self.serialize_sweep_model(
159161
&sweep_model,

script-gen-manager/src/instr_metadata/base_metadata.rs

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -48,15 +48,17 @@ impl BaseMetadata {
4848
pub const USER_DEFINED_VALUE: &'static str = "USER DEFINED";
4949
pub const MOVING_AVG: &'static str = "MOVING AVG";
5050
pub const REPEAT_AVG: &'static str = "REPEAT AVG";
51-
pub const FUNCTION_VOLTAGE: &'static str = "FUNC_DC_VOLTAGE";
52-
pub const FUNCTION_CURRENT: &'static str = "FUNC_DC_CURRENT";
53-
pub const FUNCTION_IV: &'static str = "FUNC_DC_IV_COMBINED";
51+
pub const FUNCTION_VOLTAGE: &'static str = "Voltage";
52+
pub const FUNCTION_CURRENT: &'static str = "Current";
53+
pub const FUNCTION_IV: &'static str = "Current,Voltage";
5454
pub const RANGE_FOLLOW_LIMITI: &'static str = "follow limiti";
55-
pub const SENSE_MODE_TWO_WIRE: &'static str = "SENSE_2WIRE";
56-
pub const SENSE_MODE_FOUR_WIRE: &'static str = " SENSE_4WIRE";
55+
pub const SENSE_MODE_TWO_WIRE: &'static str = "Two-wire";
56+
pub const SENSE_MODE_FOUR_WIRE: &'static str = "Four-wire";
5757
pub const RATE_NORMAL: &'static str = "Normal";
5858
pub const RATE_FAST: &'static str = "Fast";
5959

60+
pub const UNDEFINED: &'static str = "UNDEFINED";
61+
6062
pub const UNIT_VOLTS: &'static str = "V";
6163
pub const UNIT_AMPERES: &'static str = "A";
6264
pub const UNIT_SECONDS: &'static str = "s";
@@ -79,8 +81,8 @@ impl BaseMetadata {
7981
],
8082
);
8183

82-
names.insert("sense=SENSE_2WIRE", "SENSE_2WIRE");
83-
names.insert("sense=SENSE_4WIRE", "SENSE_4WIRE");
84+
names.insert("sense=Two-wire", "SENSE_2WIRE");
85+
names.insert("sense=Four-wire", "SENSE_4WIRE");
8486

8587
BaseMetadata {
8688
options,

script-gen-manager/src/instr_metadata/msmu60_metadata.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::model::{
22
chan_data::region_map::RegionMapMetadata,
3-
sweep_data::{number_limit::NumberLimit, parameters::ParameterFloat},
3+
sweep_data::number_limit::NumberLimit,
44
};
55

66
use super::base_metadata::{BaseMetadata, Metadata};

script-gen-manager/src/model/chan_data/start_stop_channel.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
use core::num;
21

32
use serde::{Deserialize, Serialize};
43

script-gen-manager/src/script_component/sweep.rs

Lines changed: 73 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
use std::{any::Any, collections::HashMap};
22

33
use crate::{
4-
instr_metadata::base_metadata::BaseMetadata,
5-
model::{
4+
device::DeviceType, instr_metadata::base_metadata::BaseMetadata, model::{
65
chan_data::channel_range::ChannelRange,
76
sweep_data::{
8-
parameters::ParameterFloat, parameters::ParameterString, sweep_config::SweepConfig,
7+
parameters::{ParameterFloat, ParameterString},
8+
sweep_config::SweepConfig,
99
},
10-
},
10+
}
1111
};
1212

1313
use super::function::FunctionModel;
@@ -107,20 +107,28 @@ impl SweepModel {
107107
bias_channel.common_chan_attributes.device.get_model(),
108108
);
109109

110+
self.val_replacement_map.insert(
111+
instr_name.clone() + ":MODEL-TYPE",
112+
bias_channel
113+
.common_chan_attributes
114+
.device.device_type.to_string(),
115+
);
116+
110117
let val = self
111118
.get_function_value(&bias_channel.common_chan_attributes.source_function)
112119
.clone();
113120
self.val_replacement_map
114121
.insert(instr_name.clone() + ":SFUNCTION", val);
115122

116-
self.val_replacement_map.insert(
117-
instr_name.clone() + ":SRANGE",
118-
self.format_range(bias_channel.common_chan_attributes.source_range.clone()),
123+
self.set_source_range(
124+
bias_channel.common_chan_attributes.source_range.clone(),
125+
&instr_name,
119126
);
120127

121128
let val = self
122129
.get_function_value(&bias_channel.common_chan_attributes.meas_function)
123130
.clone();
131+
124132
self.val_replacement_map
125133
.insert(instr_name.clone() + ":MFUNCTION", val);
126134

@@ -131,12 +139,14 @@ impl SweepModel {
131139
.common_chan_attributes
132140
.get_name_for(&sense_mode_key)
133141
{
134-
let val = self.get_sense_mode_value(&sense_mode_value);
135142
self.val_replacement_map
136-
.insert(instr_name.clone() + ":SENSE", val);
137-
} else {
138-
//TODO: error handling for sense mode value not found
143+
.insert(instr_name.clone() + ":SENSE", sense_mode_value.to_owned());
139144
}
145+
} else {
146+
self.val_replacement_map.insert(
147+
instr_name.clone() + ":SENSE",
148+
BaseMetadata::UNDEFINED.to_string(),
149+
);
140150
}
141151

142152
//source_limitv exists only for SMU
@@ -176,6 +186,17 @@ impl SweepModel {
176186
}
177187
}
178188

189+
fn set_source_range(&mut self, channel_range: ChannelRange, instr_name: &String) {
190+
let mut val = self.format_range(channel_range.clone());
191+
192+
if channel_range.is_range_auto() {
193+
val = "CONSTANTS.AUTO".to_string();
194+
}
195+
196+
self.val_replacement_map
197+
.insert(instr_name.clone() + ":SRANGE", val);
198+
}
199+
179200
//Returns the value used in the script
180201
fn get_function_value(&mut self, source_function: &ParameterString) -> String {
181202
if source_function.value.to_lowercase() == BaseMetadata::FUNCTION_VOLTAGE.to_lowercase() {
@@ -189,15 +210,6 @@ impl SweepModel {
189210
}
190211
}
191212

192-
//Returns the value used in the script
193-
fn get_sense_mode_value(&mut self, sense_mode: &str) -> String {
194-
if sense_mode.to_lowercase() == BaseMetadata::SENSE_MODE_TWO_WIRE.to_lowercase() {
195-
"SENSE_2WIRE".to_string()
196-
} else {
197-
"SENSE_4WIRE".to_string()
198-
}
199-
}
200-
201213
fn define_step_channels(&mut self, step_config: &SweepConfig) {
202214
let mut index = 1;
203215
for step_channel in step_config.step_channels.iter() {
@@ -236,6 +248,14 @@ impl SweepModel {
236248
.get_model(),
237249
);
238250

251+
self.val_replacement_map.insert(
252+
instr_name.clone() + ":MODEL-TYPE",
253+
step_channel
254+
.start_stop_channel
255+
.common_chan_attributes
256+
.device.device_type.to_string(),
257+
);
258+
239259
let val = self
240260
.get_function_value(
241261
&step_channel
@@ -247,15 +267,12 @@ impl SweepModel {
247267
self.val_replacement_map
248268
.insert(instr_name.clone() + ":SFUNCTION", val);
249269

250-
self.val_replacement_map.insert(
251-
instr_name.clone() + ":SRANGE",
252-
self.format_range(
253-
step_channel
254-
.start_stop_channel
255-
.common_chan_attributes
256-
.source_range
257-
.clone(),
258-
),
270+
self.set_source_range(
271+
step_channel
272+
.start_stop_channel
273+
.common_chan_attributes
274+
.source_range.clone(),
275+
&instr_name,
259276
);
260277

261278
let val = self
@@ -290,10 +307,14 @@ impl SweepModel {
290307
.common_chan_attributes
291308
.get_name_for(&sense_mode_key)
292309
{
293-
let val = self.get_sense_mode_value(&sense_mode_value);
294310
self.val_replacement_map
295-
.insert(instr_name.clone() + ":SENSE", val);
311+
.insert(instr_name.clone() + ":SENSE", sense_mode_value.to_owned());
296312
}
313+
} else {
314+
self.val_replacement_map.insert(
315+
instr_name.clone() + ":SENSE",
316+
BaseMetadata::UNDEFINED.to_string(),
317+
);
297318
}
298319

299320
//source_limitv exists only for SMU
@@ -437,6 +458,14 @@ impl SweepModel {
437458
.get_model(),
438459
);
439460

461+
self.val_replacement_map.insert(
462+
instr_name.clone() + ":MODEL-TYPE",
463+
sweep_channel
464+
.start_stop_channel
465+
.common_chan_attributes
466+
.device.device_type.to_string(),
467+
);
468+
440469
let val = self
441470
.get_function_value(
442471
&sweep_channel
@@ -447,15 +476,13 @@ impl SweepModel {
447476
.clone();
448477
self.val_replacement_map
449478
.insert(instr_name.clone() + ":SFUNCTION", val);
450-
self.val_replacement_map.insert(
451-
instr_name.clone() + ":SRANGE",
452-
self.format_range(
453-
sweep_channel
454-
.start_stop_channel
455-
.common_chan_attributes
456-
.source_range
457-
.clone(),
458-
),
479+
480+
self.set_source_range(
481+
sweep_channel
482+
.start_stop_channel
483+
.common_chan_attributes
484+
.source_range.clone(),
485+
&instr_name,
459486
);
460487

461488
let val = self
@@ -489,12 +516,14 @@ impl SweepModel {
489516
.common_chan_attributes
490517
.get_name_for(&sense_mode_key)
491518
{
492-
let val = self.get_sense_mode_value(&sense_mode_value);
493519
self.val_replacement_map
494-
.insert(instr_name.clone() + ":SENSE", val);
495-
} else {
496-
//TODO: error handling for sense mode value not found
520+
.insert(instr_name.clone() + ":SENSE", sense_mode_value.to_owned());
497521
}
522+
} else {
523+
self.val_replacement_map.insert(
524+
instr_name.clone() + ":SENSE",
525+
BaseMetadata::UNDEFINED.to_string(),
526+
);
498527
}
499528

500529
//source_limitv exists only for SMU

0 commit comments

Comments
 (0)