Skip to content

Commit 8597c6a

Browse files
committed
Use abs values to evaluate source limit i values
1 parent 033046e commit 8597c6a

File tree

4 files changed

+32
-12
lines changed

4 files changed

+32
-12
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,8 @@ impl BiasChannel {
2626

2727
pub fn evaluate(&mut self) {
2828
self.common_chan_attributes.evaluate();
29-
self.common_chan_attributes.evaluate_source_limits(&self.bias, &self.bias); //Use the bias value for both start and stop as the absolute max is used
29+
self.common_chan_attributes
30+
.evaluate_source_limits(&self.bias, &self.bias); //Use the bias value for both start and stop as the absolute max is used
3031
self.determine_bias_value();
3132
}
3233

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -286,13 +286,13 @@ impl CommonChanAttributes {
286286
stop_value: &ParameterFloat,
287287
) {
288288
//Use region map to further limit the source limits based on the source function and range
289-
let mut limit_value = start_value.value;
289+
let mut limit_value = start_value.value.abs();
290290
if let Some(region_map) =
291291
self.get_region_map(&self.device.metadata, &self.source_range.value)
292292
{
293293
if stop_value.value.abs() > limit_value.abs() {
294294
//Use the largest absolute value
295-
limit_value = stop_value.value;
295+
limit_value = stop_value.value.abs();
296296
}
297297
match &self.source_function.value[..] {
298298
s if s == BaseMetadata::FUNCTION_VOLTAGE => {

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

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -57,16 +57,33 @@ impl StartStopChannel {
5757
}
5858
}
5959

60-
pub fn evaluate(&mut self, list_size: usize) {
60+
pub fn evaluate(&mut self, list_size: usize, is_list_enabled: bool) {
6161
self.common_chan_attributes.evaluate();
6262
self.determine_start_value();
6363
self.determine_stop_value();
6464

6565
//List evaluation
6666

6767
self.update_list(list_size);
68-
self.common_chan_attributes
69-
.evaluate_source_limits(&self.start, &self.stop);
68+
69+
if is_list_enabled {
70+
let min_value = self
71+
.list
72+
.iter()
73+
.min_by(|a, b| a.value.partial_cmp(&b.value).unwrap())
74+
.unwrap();
75+
let max_value = self
76+
.list
77+
.iter()
78+
.max_by(|a, b| a.value.partial_cmp(&b.value).unwrap())
79+
.unwrap();
80+
81+
self.common_chan_attributes
82+
.evaluate_source_limits(min_value, max_value);
83+
} else {
84+
self.common_chan_attributes
85+
.evaluate_source_limits(&self.start, &self.stop);
86+
}
7087
}
7188

7289
fn update_list(&mut self, list_size: usize) {

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -393,14 +393,16 @@ impl SweepConfig {
393393
}
394394

395395
for step_channel in &mut self.step_channels {
396-
step_channel
397-
.start_stop_channel
398-
.evaluate(self.step_global_parameters.step_points.value as usize);
396+
step_channel.start_stop_channel.evaluate(
397+
self.step_global_parameters.step_points.value as usize,
398+
self.step_global_parameters.list_step,
399+
);
399400
}
400401
for sweep_channel in &mut self.sweep_channels {
401-
sweep_channel
402-
.start_stop_channel
403-
.evaluate(self.sweep_global_parameters.sweep_points.value as usize);
402+
sweep_channel.start_stop_channel.evaluate(
403+
self.sweep_global_parameters.sweep_points.value as usize,
404+
self.sweep_global_parameters.list_sweep,
405+
);
404406
}
405407
}
406408

0 commit comments

Comments
 (0)