Here is a script that moves 2 motors uniformly. The distance between the motors is kept fixed. When using this script, think about the unit limits.
#!/usr/bin/perl -w
#
# file name: /online_dir/vm1.pl
#
# This script is a template for a virtual motor.
#
use Spectra;
my ($method, $value_new) = @ARGV;
my $status = 1;
if( "$method" eq "set_position")
{
my $m1 = Spectra::gmup( "mot1");
my $m2 = Spectra::gmup( "mot2");
my $current = ($m1 + $m2)/2.;
my $diff = $value_new - $current;
$status = move( mot1 => ($m1 + $diff),
mot2 => ($m2 + $diff));
}
elsif( "$method" eq "get_position")
{
$SYM{RETURN_VALUE} = (Spectra::gmup( "mot1") + Spectra::gmup("mot2"))/2.;
}
elsif( "$method" eq "get_limit_min")
{
$SYM{RETURN_VALUE} = Spectra::gmuli( "mot1");
}
elsif( "$method" eq "get_limit_max")
{
$SYM{RETURN_VALUE} = Spectra::gmula( "mot1");
}
elsif( "$method" eq "calibration")
{
;
}
elsif( $method eq "exec_stop")
{
Spectra::stop_move("mot1");
Spectra::stop_move("mot2");
}
else
{
Spectra::error( "vm1: failed to identify $method");
$status = 0;
goto finish;
}
finish:
$status;