The next example shows part of the monochromator widget of X1:
$Spc::res_h{ blsc} = "mc"; $Spc::res_h{ mc_title} = { text => "Monochromator"}; $Spc::res_h{ mc_help} = sub { Util::display_text( "Help MC", ' Si111 Si311 Si511 - Change MC setup ... ' )}; $Spc::res_h{ mc_io1} = { label => { name => "Crystal spacing", get => sub {$Spectra::SYM{ d_crystal};}}}; $Spc::res_h{ mc_io2} = { label => { name => "Crystal type", get => \&type_crystal}}; # # the motors # $Spc::res_h{ mc_m1} = { name => "Mot1", alias => "Theta", unit => "Deg"}; $Spc::res_h{ mc_m2} = { name => "Mot2", alias => "Table", unit => "mm"}; $Spc::res_h{ mc_m3} = { name => "Mot3", alias => "C1_Theta", unit => "mm"}; $Spc::res_h{ mc_m4} = { name => "Mot4", alias => "Hor", unit => "mm"}; $Spc::res_h{ mc_m9} = { name => "Mot9", alias => "C2_trans", unit => "mm"}; $Spc::res_h{ mc_m10} = { name => "Mot10", alias => "C2_Rho", unit => "Deg."}; $Spc::res_h{ mc_m11} = { name => "Mot11", alias => "Top", unit => "mm"}; $Spc::res_h{ mc_m12} = { name => "Mot12", alias => "Bottom", unit => "mm"}; # # the buttons # $Spc::res_h{ mc_b1} = { name => "E to 9400 eV", command => sub { Spectra::move( energy => 9400);}}; $Spc::res_h{ mc_b2} = { name => "E to 18000 eV", command => sub { Spectra::move( energy => 18000);}}; $Spc::res_h{ mc_b3} = { name => "Si111", command => sub { change_crystal ( "Si111");}}; $Spc::res_h{ mc_b4} = { name => "Si311", command => sub { change_crystal ( "Si311");}}; $Spc::res_h{ mc_b5} = { name => "Si511", command => sub { change_crystal ( "Si511");}}; # # the options # $Spc::res_h{ mc_option1} = { name => "Calc Offset", command => \&new_hhe_offset}; # # a function which is executed after the calibration # $Spc::res_h{ mc_post_calibration} = \&new_hhe_offset; # # the callback functions # sub type_crystal { my $ret = "unknown"; my $temp = Spectra::gmup( $SYM{ mc_hor}); if( ($temp < 0.5) && ($temp > -0.5)) { $ret = "Si111"; } ... $ret; } sub change_crystal { my ( $type_new) = @_; print "change the crystal to $type_new\n"; } sub new_hhe_offset { print "calculated offset\n"; }
The title and io widgets have already been explained. The new items are:
$Spc::res_h{ mc_help} = sub { Util::display_text( 'title', 'help text');};
Creates an additional item in the Help popup menu. |
$Spc::res_h{ mc_option1} = { name => '...', command => '...'};
Creates an entry in the Options pop-up menu. |
$Spc::res_h{ mc_post_calibration} = \&new_hhe_offset;
This function is called after the calibration completed successfully. Here it means that a new encoder offset is calculated automatically.
|