Centralized VMs

Suppose that there are several PCs at a beamline and a particular virtual motor macro is used at each of these PCs. Instead of copying the virtual motor macro to the each /online_dir, it is preferable to maintain the macro at a central place on a network file system and let the local virtual motor macros invoke the central script.

This is a solution. Each /online_dir contains the script vm1.pl:

#!/usr/bin/perl -w
#
# file name: /online_dir/vm1.pl
#
$status = eval `cat /centralPlace/vm1_central.pl`;

And on /centralPlace we have the script vm1_central.pl which happens to be exactly the former vm1.pl:

#!/usr/bin/perl -w
#
# file name: /online_dir/vm1.pl
#
# This script is a template for a virtual motor. 
# 

my ($method, $value_new) = @ARGV; 

Util::log( "this is vm1_central, $method $value_new"); 
my $status = 1; 

if( $method eq "set_position")
{
    $status = Spectra::move( exp_mot15 => $value_new); 
}
elsif( $method eq "get_position")
{
    $SYM{RETURN_VALUE} = Spectra::gmup( "exp_mot15"); 
}
elsif( $method eq "get_limit_min")
{
    $SYM{RETURN_VALUE} = Spectra::gmuli( "exp_mot15");
}
elsif( $method eq "get_limit_max")
{
    $SYM{RETURN_VALUE} = Spectra::gmula( "exp_mot15");
}
elsif( $method eq "exec_stop")
{
    Spectra::stop_move( "exp_mot15"); 
}
elsif( $method eq "calibration")
{
    $status = Spectra::calibrate( name => "exp_mot15",
				  unit => $value_new,
				  noconfirm => 1); 
}
else
{
    Spectra::error( "vm1: failed to identify $method"); 
    $status = 0;
    goto finish;
} 
finish:
 $status;