@@ -4,6 +4,51 @@ use crate::model::{
44
55use super :: base_metadata:: { BaseMetadata , Metadata } ;
66
7+ // Epsilon for floating-point comparisons
8+ const EPSILON : f64 = 1e-15 ;
9+
10+ // Voltage range constants for MSMU60
11+ const VOLTAGE_AUTO : & str = "AUTO" ;
12+ const VOLTAGE_200_MV : & str = "200 mV" ;
13+ const VOLTAGE_2_V : & str = "2 V" ;
14+ const VOLTAGE_6_V : & str = "6 V" ;
15+ const VOLTAGE_20_V : & str = "20 V" ;
16+ const VOLTAGE_60_V : & str = "60 V" ;
17+
18+ // Current range constants for MSMU60
19+ const CURRENT_AUTO : & str = "AUTO" ;
20+ const CURRENT_100_NA : & str = "100 nA" ;
21+ const CURRENT_1_UA : & str = "1 \u{00B5} A" ; // Unicode character for micro (µ)
22+ const CURRENT_10_UA : & str = "10 \u{00B5} A" ;
23+ const CURRENT_100_UA : & str = "100 \u{00B5} A" ;
24+ const CURRENT_1_MA : & str = "1 mA" ;
25+ const CURRENT_10_MA : & str = "10 mA" ;
26+ const CURRENT_100_MA : & str = "100 mA" ;
27+ const CURRENT_1_A : & str = "1 A" ;
28+ const CURRENT_1_5_A : & str = "1.5 A" ;
29+
30+ // Range arrays built from constants
31+ const VOLTAGE_RANGES : & [ & str ] = & [
32+ VOLTAGE_AUTO ,
33+ VOLTAGE_200_MV ,
34+ VOLTAGE_2_V ,
35+ VOLTAGE_6_V ,
36+ VOLTAGE_20_V ,
37+ VOLTAGE_60_V ,
38+ ] ;
39+ const CURRENT_RANGES : & [ & str ] = & [
40+ CURRENT_AUTO ,
41+ CURRENT_100_NA ,
42+ CURRENT_1_UA ,
43+ CURRENT_10_UA ,
44+ CURRENT_100_UA ,
45+ CURRENT_1_MA ,
46+ CURRENT_10_MA ,
47+ CURRENT_100_MA ,
48+ CURRENT_1_A ,
49+ CURRENT_1_5_A ,
50+ ] ;
51+
752#[ derive( Debug , Clone ) ]
853pub struct Msmu60Metadata {
954 base : BaseMetadata ,
@@ -14,26 +59,8 @@ impl Msmu60Metadata {
1459 pub fn new ( ) -> Self {
1560 let mut base = BaseMetadata :: new ( ) ;
1661 // Add additional key-value pairs for MSmu60Metadata
17- base. add_option (
18- "source_meas.rangev" ,
19- vec ! [ "AUTO" , "200 mV" , "2 V" , "6 V" , "20 V" , "60 V" ] ,
20- ) ;
21- // "\u{00B5}"" - Unicode character for micro (µ)
22- base. add_option (
23- "source_meas.rangei" ,
24- vec ! [
25- "AUTO" ,
26- "100 nA" ,
27- "1 \u{00B5} A" ,
28- "10 \u{00B5} A" ,
29- "100 \u{00B5} A" ,
30- "1 mA" ,
31- "10 mA" ,
32- "100 mA" ,
33- "1 A" ,
34- "1.5 A" ,
35- ] ,
36- ) ;
62+ base. add_option ( "source_meas.rangev" , VOLTAGE_RANGES . to_vec ( ) ) ;
63+ base. add_option ( "source_meas.rangei" , CURRENT_RANGES . to_vec ( ) ) ;
3764
3865 base. add_default ( "source_meas.range.defaultv" , "AUTO" ) ;
3966 base. add_default ( "source_meas.range.defaulti" , "AUTO" ) ;
@@ -42,19 +69,47 @@ impl Msmu60Metadata {
4269 base. add_range ( "source.levelv" . to_string ( ) , -60.6 , 60.6 ) ;
4370 base. add_range ( "source.leveli" . to_string ( ) , -1.515 , 1.515 ) ;
4471
45- base. add_range ( "source.limiti" . to_string ( ) , -1e-8 , 1.515 ) ;
46- base. add_range ( "source.limitv" . to_string ( ) , -0.02 , 60.6 ) ;
72+ base. add_range ( "source.limiti" . to_string ( ) , -1.515 , 1.515 ) ;
73+ base. add_range ( "source.limitv" . to_string ( ) , -60.6 , 60.6 ) ;
4774
4875 base. add_range ( "source.step_to_sweep_delay" . to_string ( ) , 0.0 , 100.0 ) ;
4976
5077 // Add region maps
5178 // when pulse mode is off
5279 let exclude_v = Some ( NumberLimit :: new ( -0.01 , 0.01 , false , None ) ) ;
5380 let exclude_i = NumberLimit :: new ( -10.0e-9 , 10.0e-9 , false , None ) ;
54- let mut region_map_metadata = RegionMapMetadata :: new ( exclude_v, exclude_i) ;
55- region_map_metadata. add_region ( 1 , -60.0 , -0.1 , 60.0 , 0.1 ) ;
56- region_map_metadata. add_region ( 1 , -20.0 , -1.5 , 20.0 , 1.5 ) ;
57- base. add_region_map ( "smu.region" , region_map_metadata) ;
81+
82+ let mut inner_region = RegionMapMetadata :: new ( exclude_v. clone ( ) , exclude_i. clone ( ) ) ;
83+ inner_region. add_region (
84+ 1 ,
85+ -60.6 - EPSILON ,
86+ -0.1 - EPSILON ,
87+ 60.6 + EPSILON ,
88+ 0.1 + EPSILON ,
89+ ) ;
90+ base. add_region_map ( VOLTAGE_60_V , inner_region. clone ( ) ) ;
91+ base. add_region_map ( CURRENT_100_NA , inner_region. clone ( ) ) ;
92+ base. add_region_map ( CURRENT_1_UA , inner_region. clone ( ) ) ;
93+ base. add_region_map ( CURRENT_10_UA , inner_region. clone ( ) ) ;
94+ base. add_region_map ( CURRENT_100_UA , inner_region. clone ( ) ) ;
95+ base. add_region_map ( CURRENT_1_MA , inner_region. clone ( ) ) ;
96+
97+ let mut outer_region = RegionMapMetadata :: new ( exclude_v. clone ( ) , exclude_i. clone ( ) ) ;
98+ outer_region. add_region (
99+ 1 ,
100+ -20.0 - EPSILON ,
101+ -1.515 - EPSILON ,
102+ 20.0 + EPSILON ,
103+ 1.515 + EPSILON ,
104+ ) ;
105+ base. add_region_map ( VOLTAGE_200_MV , outer_region. clone ( ) ) ;
106+ base. add_region_map ( VOLTAGE_2_V , outer_region. clone ( ) ) ;
107+ base. add_region_map ( VOLTAGE_6_V , outer_region. clone ( ) ) ;
108+ base. add_region_map ( VOLTAGE_20_V , outer_region. clone ( ) ) ;
109+ base. add_region_map ( CURRENT_10_MA , outer_region. clone ( ) ) ;
110+ base. add_region_map ( CURRENT_100_MA , outer_region. clone ( ) ) ;
111+ base. add_region_map ( CURRENT_1_A , outer_region. clone ( ) ) ;
112+ base. add_region_map ( CURRENT_1_5_A , outer_region. clone ( ) ) ;
58113
59114 base. add_overrange_scale ( 1.01 ) ;
60115
0 commit comments