@@ -4,7 +4,8 @@ use crate::{
44 instr_metadata:: base_metadata:: BaseMetadata ,
55 model:: {
66 chan_data:: channel_range:: ChannelRange ,
7- sweep_data:: { parameters:: ParameterFloat , sweep_config:: SweepConfig } ,
7+ sweep_data:: { parameters:: ParameterFloat , sweep_config:: SweepConfig ,
8+ parameters:: ParameterString } ,
89 } ,
910} ;
1011
@@ -105,28 +106,23 @@ impl SweepModel {
105106 bias_channel. common_chan_attributes . device . get_model ( ) ,
106107 ) ;
107108
109+ let val = self . get_function_value ( & bias_channel. common_chan_attributes . source_function )
110+ . clone ( ) ;
108111 self . val_replacement_map . insert (
109112 instr_name. clone ( ) + ":SFUNCTION" ,
110- bias_channel
111- . common_chan_attributes
112- . source_function
113- . value
114- . to_lowercase ( )
115- . clone ( ) ,
113+ val,
116114 ) ;
117115
118116 self . val_replacement_map . insert (
119117 instr_name. clone ( ) + ":SRANGE" ,
120118 self . format_range ( bias_channel. common_chan_attributes . source_range . clone ( ) ) ,
121119 ) ;
122120
121+ let val = self . get_function_value ( & bias_channel. common_chan_attributes . meas_function )
122+ . clone ( ) ;
123123 self . val_replacement_map . insert (
124124 instr_name. clone ( ) + ":MFUNCTION" ,
125- bias_channel
126- . common_chan_attributes
127- . meas_function
128- . value
129- . clone ( ) ,
125+ val,
130126 ) ;
131127
132128 //sense mode exists only for SMU
@@ -136,9 +132,10 @@ impl SweepModel {
136132 . common_chan_attributes
137133 . get_name_for ( & sense_mode_key)
138134 {
135+ let val = self . get_sense_mode_value ( & sense_mode_value) ;
139136 self . val_replacement_map . insert (
140137 instr_name. clone ( ) + ":SENSE" ,
141- String :: from ( sense_mode_value ) ,
138+ val ,
142139 ) ;
143140 } else {
144141 //TODO: error handling for sense mode value not found
@@ -182,6 +179,28 @@ impl SweepModel {
182179 }
183180 }
184181
182+ //Returns the value used in the script
183+ fn get_function_value ( & mut self , source_function : & ParameterString ) -> String {
184+ if source_function. value . to_lowercase ( ) == BaseMetadata :: FUNCTION_VOLTAGE . to_lowercase ( ) {
185+ "FUNC_DC_VOLTAGE" . to_string ( )
186+ } else if source_function. value . to_lowercase ( )
187+ == BaseMetadata :: FUNCTION_CURRENT . to_lowercase ( )
188+ {
189+ "FUNC_DC_CURRENT" . to_string ( )
190+ } else {
191+ "FUNC_DC_IV_COMBINED" . to_string ( )
192+ }
193+ }
194+
195+ //Returns the value used in the script
196+ fn get_sense_mode_value ( & mut self , sense_mode : & str ) -> String {
197+ if sense_mode. to_lowercase ( ) == BaseMetadata :: SENSE_MODE_TWO_WIRE . to_lowercase ( ) {
198+ "SENSE_2WIRE" . to_string ( )
199+ } else {
200+ "SENSE_4WIRE" . to_string ( )
201+ }
202+ }
203+
185204 fn define_step_channels ( & mut self , step_config : & SweepConfig ) {
186205 let mut index = 1 ;
187206 for step_channel in step_config. step_channels . iter ( ) {
@@ -220,14 +239,16 @@ impl SweepModel {
220239 . get_model ( ) ,
221240 ) ;
222241
242+ let val = self . get_function_value (
243+ & step_channel
244+ . start_stop_channel
245+ . common_chan_attributes
246+ . source_function ,
247+ )
248+ . clone ( ) ;
223249 self . val_replacement_map . insert (
224250 instr_name. clone ( ) + ":SFUNCTION" ,
225- step_channel
226- . start_stop_channel
227- . common_chan_attributes
228- . source_function
229- . value
230- . clone ( ) ,
251+ val,
231252 ) ;
232253
233254 self . val_replacement_map . insert (
@@ -241,14 +262,16 @@ impl SweepModel {
241262 ) ,
242263 ) ;
243264
265+ let val = self . get_function_value (
266+ & step_channel
267+ . start_stop_channel
268+ . common_chan_attributes
269+ . meas_function
270+ )
271+ . clone ( ) ;
244272 self . val_replacement_map . insert (
245273 instr_name. clone ( ) + ":MFUNCTION" ,
246- step_channel
247- . start_stop_channel
248- . common_chan_attributes
249- . meas_function
250- . value
251- . clone ( ) ,
274+ val,
252275 ) ;
253276
254277 self . val_replacement_map . insert (
@@ -272,9 +295,10 @@ impl SweepModel {
272295 . common_chan_attributes
273296 . get_name_for ( & sense_mode_key)
274297 {
298+ let val = self . get_sense_mode_value ( & sense_mode_value) ;
275299 self . val_replacement_map . insert (
276300 instr_name. clone ( ) + ":SENSE" ,
277- String :: from ( sense_mode_value ) ,
301+ val ,
278302 ) ;
279303 }
280304 }
@@ -420,14 +444,16 @@ impl SweepModel {
420444 . get_model ( ) ,
421445 ) ;
422446
447+ let val = self . get_function_value (
448+ & sweep_channel
449+ . start_stop_channel
450+ . common_chan_attributes
451+ . source_function
452+ )
453+ . clone ( ) ;
423454 self . val_replacement_map . insert (
424455 instr_name. clone ( ) + ":SFUNCTION" ,
425- sweep_channel
426- . start_stop_channel
427- . common_chan_attributes
428- . source_function
429- . value
430- . clone ( ) ,
456+ val,
431457 ) ;
432458 self . val_replacement_map . insert (
433459 instr_name. clone ( ) + ":SRANGE" ,
@@ -440,14 +466,16 @@ impl SweepModel {
440466 ) ,
441467 ) ;
442468
469+ let val = self . get_function_value (
470+ & sweep_channel
471+ . start_stop_channel
472+ . common_chan_attributes
473+ . meas_function
474+ )
475+ . clone ( ) ;
443476 self . val_replacement_map . insert (
444477 instr_name. clone ( ) + ":MFUNCTION" ,
445- sweep_channel
446- . start_stop_channel
447- . common_chan_attributes
448- . meas_function
449- . value
450- . clone ( ) ,
478+ val,
451479 ) ;
452480
453481 self . val_replacement_map . insert (
@@ -470,9 +498,10 @@ impl SweepModel {
470498 . common_chan_attributes
471499 . get_name_for ( & sense_mode_key)
472500 {
501+ let val = self . get_sense_mode_value ( & sense_mode_value) ;
473502 self . val_replacement_map . insert (
474503 instr_name. clone ( ) + ":SENSE" ,
475- String :: from ( sense_mode_value ) ,
504+ val ,
476505 ) ;
477506 } else {
478507 //TODO: error handling for sense mode value not found
0 commit comments