If the gap of the undulator has to be moved/scanned, a virtual motors needs to be installed:
#!/usr/bin/perl -w
#
my ($method, $value_new) = @ARGV;
my $status = 1;
if( $method eq "set_position")
{
$status = Spectra::tng_attrFloatWrt( "Undulator", "Gap", $value_new);
#
# takes some time for the undulator to change state to MOVING (6)
#
sleep(2);
my $startTime = Spectra::Secnds();
while( Spectra::tng_state( "Undulator") == 6)
{
Spectra::wait( 0.1);
#
# refresh motor positions and sense 'Stop' clicks
#
Util::refresh();
if( (Spectra::secnds() - $startTime) > 20)
{
$status = Spectra::error( "vm1: move didn't finish within 20s");
goto finish;
}
}
}
elsif( $method eq "get_position")
{
$SYM{RETURN_VALUE} = Spectra::tng_attrFloatRd( "Undulator", "Gap");
}
elsif( $method eq "get_limit_min")
{
$SYM{RETURN_VALUE} = 11.1;
}
elsif( $method eq "get_limit_max")
{
$SYM{RETURN_VALUE} = 220.
}
elsif( $method eq "exec_stop")
{
$status = Spectra::tng_inout( "Undulator", "StopMove");
}
finish:
$status;