The following piece of code demonstrates who devices can be selected for Sweep measurements. It is done very much in the same way as in the case of scans. A profile parameter is introduced that points to an anonymous hash which stores the selection. In our examples a timer is selected, two counters, one encoder, one virtual counter, two MCAs and two SCAs. The DORIS current is logged anyway.
#!/usr/bin/env perl
use strict;
use Spectra;
#
# the list of runs
#
my @list = (
#
# an area scan that uses the 'profile' option
#
{ w_sample_time => 0.5,
w_start_inner => 3015,
w_stop_inner => 3115,
w_delta_inner => 10,
w_start_middle => 10320,
w_stop_middle => 10330,
w_delta_middle => 10,
profile =>
{ timer => "t1",
counter => [ qw( c1 c2 hhe9 vc3)],
mca1 => { channels => 2024},
mca2 => { channels => 4048},
sca1 => { mca => "mca1", min => 500, max => 1000},
sca2 => { mca => "mca2", min => 600, max => 1000},
}},
);
#
# make sure that the Sweep menu is visible
#
Sweep::main();
my $flag_profile = 0;
foreach my $run ( @list)
{
$flag_profile = 0;
if( defined( $run->{ profile}))
{
if( !Util::setup_ssd_profile( $run->{ profile}))
{
Spectra::error( "SweepList: error from Util::setup_ssd_profile");
goto finish;
}
$flag_profile = 1;
delete $run->{ profile};
}
#
# the outer loop is disabled by default
#
$Sweep::h{ flag_outer} = 0;
$Sweep::h{ flag_outer} = 1 if( defined( $run->{ w_start_outer}));
$Sweep::h{ flag_middle} = 1;
foreach my $key ( keys %$run)
{
if( $key =~ /^w_.+/)
{
$Sweep::h{ ${key}}->delete( '0', 'end');
$Sweep::h{ ${key}}->insert( '0', $run->{ $key});
}
else
{
$Sweep::h{ $key} = $run->{ $key};
}
}
$Sweep::h{ w_test}->invoke();
goto finish if( !Spectra::yesno( "Start to measure"));
$Sweep::h{ w_start}->invoke();
Util::load_ssd_profile( "Profile-temp") if( $flag_profile);
goto finish if( $Spectra::SYM{interrupt_scan});
}
finish:
Util::load_ssd_profile( "Profile-temp") if( $flag_profile);
1;