BNMR: Scripts: Difference between revisions

From DaqWiki
Jump to navigation Jump to search
m (11 revisions imported)
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
{{Pagelinks}}
{{Pagelinks}}
== Links ==
<div style="column-count:3;-moz-column-count:3;-webkit-column-count:3">
* [[BNMR]]
* [[BNMR: Experimental Setup#Environment Variables|Environment variables]]
* [[BNMR: Experimental Modes|Experimental Modes]]
* [[BNMR: Getting Started|Getting Started]]
* [[BNMR: Perlscripts]]
* [[BNMR#Nomenclature|Nomenclature]]
</div>


== Introduction ==
== Introduction ==
Line 16: Line 5:
Unless otherwise noted, the scripts described here can be found in directory {{Filepath|path=~/online/[[BNMR#Nomenclature|<beamline>]]/bin}}.  
Unless otherwise noted, the scripts described here can be found in directory {{Filepath|path=~/online/[[BNMR#Nomenclature|<beamline>]]/bin}}.  


Another important group of scripts are the perlscripts found in directory {{Filepath|path=~/online/[[BNMR#Nomenclature|<beamline>]]/perl}}. These
== .bashrc ==
are described under [[BNMR: Perlscripts]].
This important script in $HOME is the '''bash script executed on log in'''. This sets up the path, the aliases and [[BNMR: Experimental Setup#Environment Variables|environment variables]] required for running the DAQ system. This file is shared by all the machines in the NIS cluster with ''isdaq00'' as master. This includes ''isdaq01, isdaq06, lxbnmr, lxbnqr''. This script therefore checks the $HOST environment variable before setting up the DAQ system. See [[BNMR: Experimental Setup]] for details.
 
 
== .cshrc ==
This important script in $HOME is the '''c-shell script executed on log in'''. This sets up the path, the aliases and [[BNMR: Experimental Setup#Environment Variables|environment variables]] required for running the DAQ system. This file is shared by all the machines in the NIS cluster with ''isdaq00'' as master. This includes ''isdaq01, isdaq06, lxbnmr, lxbnqr''. This script therefore checks the $HOST environment variable before setting up the DAQ system. See [[BNMR: Experimental Setup]] for details.




Line 31: Line 16:
=== start-all ===
=== start-all ===
''start-all'' is an alias to the script  {{File|name=start-all-daq-bn[mq]r}} (see [[BNMR#Nomenclature|Nomenclature]]). This script is run by the experimenter to start all the MIDAS clients needed for the DAQ system. It checks to see if each client is already running, and if not, starts it either by calling another script, or directly. It can be run at any time during the run to restart missing clients.
''start-all'' is an alias to the script  {{File|name=start-all-daq-bn[mq]r}} (see [[BNMR#Nomenclature|Nomenclature]]). This script is run by the experimenter to start all the MIDAS clients needed for the DAQ system. It checks to see if each client is already running, and if not, starts it either by calling another script, or directly. It can be run at any time during the run to restart missing clients.
[[BNMR: Experimental Setup#Environment Variables|Environment variable]]  EXPERIM_DIR must be defined (in .cshrc). This script calls [[#check-host-bnmr or check-host-bnqr]].


=== kill-all ===
=== kill-all ===
''kill-all'' is an alias to the script  {{File|name=kill-all}}. This script kills all DAQ related clients. When there is some problem with the DAQ that cannot be otherwise resolved, users often do a ''' ''kill-all'' followed by a ''start-all'' ''' to ensure a clean restart.   
''kill-all'' is an alias to the script  {{File|name=kill-all}}. This script kills all DAQ related clients. When there is some problem with the DAQ that cannot be otherwise resolved, users often do a ''' ''kill-all'' followed by a ''start-all'' ''' to ensure a clean restart.   


Recently (June 2016) an extra feature has been added to the script {{File|name=kill-all}}. This is the execution of the file {{File|name=init_odb.com}}. This file is an [https://midas.triumf.ca/MidasWiki/index.php/Odbedit odbedit] command file containing a list of ODB keys to initialize to their default state.
=== restart_frontend ===
The script {{File|name=restart_frontend}} is run when the [[BNMR: Programs page]] button restart is pressed. This script is run on the host computer. It opens an ssh session on the VMIC and runs the script {{File|name=start_frontend}}.
=== start_frontend ===
=== start_frontend ===
The script {{File|name=start_frontend}} must be run on the VMIC (not the host computer). It is may be run directly, but is usually called by the script {{File|name=restart_frontend}}.  It starts the frontend program for {{bnmqr|join=or}} experiment under the '''screen program''' (see [[#show-windows|show-windows]]).
The script {{File|name=start_frontend}} must be run on the VMIC (not the host computer). It is may be run directly, but is usually called by the script {{File|name=start-all}}.  It starts the frontend program for {{bnmqr|join=or}} experiment under the '''screen program''' (see [[#show-windows|show-windows]]).


=== start_mheader ===
=== start_bnxr_logger ===
The script {{File|name=start_mheader}} is run when the [[BNMR: Programs page]] button restart for client mheader is pressed. This script is run on the host computer.  Because mheader is or can be run under the '''screen program''' (see [[#show-windows|show-windows]]).
The script {{File|name=start_mdarc}} is run when the Programs page button restart for client bnxr_logger is pressed. This script is run on the host computer. This script restarts the MUD logger under the '''screen program''' (see [[#show-windows|show-windows]]).
 
=== start_mdarc ===
The script {{File|name=start_mdarc}} is run when the [[BNMR: Programs page]] button restart for client mdarc is pressed. This script is run on the host computer. This script restarts the client mdarc under the '''screen program''' (see [[#show-windows|show-windows]]).




Line 84: Line 58:
|-
|-
| style="font-style:italic"|show-windows || '''frontend '''   
| style="font-style:italic"|show-windows || '''frontend '''   
|-
|  style="font-style:italic"|show-windows || '''mdarc''' || to show mdarc window
|-
|  style="font-style:italic"|show-windows || '''mheader''' || to show mheader window
|}
|}


== Scripts to check environment variables ==
== Run transition scripts ==
These scripts are often included in other scripts to check that important environment variables are set up and
the script is being run on the correct computer (i.e. host computer or VMIC)
 
=== check-host-bnmr or check-host-bnqr ===
The appropriate script check-host-bn[mq]r (see [[BNMR#Nomenclature|Nomenclature]]) is called by [[#start-all]].
 
It checks that the following [[BNMR: Experimental Setup#Environment Variables|environment variables]] are defined:
: DAQ_HOST MIDASSYS MIDAS_EXPTAB MIDAS_EXPT_NAME DAQ_HOST MSERVER_PORT BEAMLINE
It further checks that the user is logged onto the correct computer for DAQ (i.e. HOST matches DAQ_HOST) and that MIDAS_EXPT_NAME and BEAMLINE match the username ( {{bnmqr|join=or}}).
 
=== check-host-vmic  ===
The script {{File|name=check-host-vmic}} checks that the script is being run on the VMIC rather than the MIDAS host machine (i.e. HOST matches VMIC_HOST) It is called by start-frontend.
 
== Scripts run at start or end of run ==
 
=== at_start_run.pl ===
The script {{File|name=at_start_run.pl}} is executed at the start of every run by the MIDAS system (see [[#NOTE]] below). Depending on the supplied parameter, it checks the experiment can access [[BNMR: CAMP|CAMP]] or [[BNMR: Epics Logging|EPICS ]]logged variables or both.
 
When checking access to the CAMP slow control system, it calls the script {{File|name=do_camp.csh}} to check that the CAMP logged variables (including automatic logged variables) can be accessed, and zeroes the CAMP statistics. Similarly, when checking EPICS access, it also checks that the EPICS logged variables (if enabled) exist and can be accessed. If an error occurs, it sets alarms in the ODB to inform the experimenters by means of an alarm banner on the custom status page.


;NOTE
Midas has a feature where programs can be automatically run at the start/end of each run (see the [https://midas.triumf.ca/MidasWiki/index.php//Programs_ODB_tree /Programs ODB tree] documentation).
This script performs two functions - it is called at start of run, and hence is located with the other scripts
in {{Filepath|path=~/online/[[BNMR#Nomenclature|<beamline>]]/bin}}. It is also a [[BNMR: Perlscripts#Customscript|customscript]] which is called from the  {{bnmqr|join=and}} [[BNMR: Custom Status page|main status page]] when the custom
buttons {{Button|name=ResetCampLog}} or {{Button|name=ResetEpicsLog}} are pressed, 
in order to reinitialize CAMP or EPICS logging. See  [[BNMR: Perlscripts#at_start_run.pl]].


=== do_camp.csh ===
For {{bnmqr|join=and}} we only define an end-of-run program. All logic for the start of run is handled by clients that are always running.
The script {{File|name=do_camp.csh}} is called from script [[#at_start_run.pl|at_start_run.pl]], and performs various checks on the CAMP parameters,


* checks the automatic header variables, making sure they are set as logging variables within CAMP.
=== End of run - elog_every_run.py ===
*  ensures all logging variables are being polled.
*  zeroes the statistics on *ALL* camp variables. 
* for type-1 experiments, retrieves the list of logged variables from Camp and copies the list into the ODB.


 
The {{Odbpath|path=/Programs/Execute on stop run}} is set to run the python program <code>bnxr_common/elog_every_run.py</code>.  
=== at_end_run.csh ===
This program reads the {{Odbpath|path=/Experiment/Edit on start}} parameters (i.e. the parameters entered by the experimenter on starting a run), other ODB parameters including the Experimental (PPG) Mode of the run and whether it is run in dual or single channel mode, reads the statistics of the CAMP logged devices, and
The script {{File|name=at_end_run.csh}} is executed at the end of every run (see [[#NOTE]]). This script runs a script  {{File|name=elog_every_run.csh}},  and calls a script to clear some alarm conditions.
 
=== elog_every_run.csh ===
This script reads the {{Odbpath|path=/Experiment/Edit on start}} parameters (i.e. the parameters entered by the experimenter on starting a run), other ODB parameters including the Experimental (PPG) Mode of the run and whether it is run in dual or single channel mode, reads the statistics of the CAMP logged devices, and
sends them all to the appropriate elog  {{bnmqr|join=or}}. Automatic elog entries are identified in the  [[BNMR: Elog#Introduction|Elog]] by the Type ("Automatic Elog").  The System parameter is set to the PPG Mode of the run.
sends them all to the appropriate elog  {{bnmqr|join=or}}. Automatic elog entries are identified in the  [[BNMR: Elog#Introduction|Elog]] by the Type ("Automatic Elog").  The System parameter is set to the PPG Mode of the run.
<div id=NOTE></div>
;NOTE
The MIDAS system provides a means whereby users' scripts can be automatically executed at the start or end of the run, by means of keys in the ODB {{Odbpath|path=/programs}} tree. The key {{Odbpath|path=Execute on start run}} contains the name and path of a script to be executed at the start of every run,
and the key {{Odbpath|path=Execute on stop run}} contains the name and path of a script to be executed at the end of every run. For example,
[local:bnqr:Stopped]/>ls "/programs/Execute on start run"
    Execute on start run            /home/bnqr/online/bnqr/bin/at_start_run.pl /home/bnqr/online/perl bnqr >/home/bnqr/tmp/at_start_run_pl.log
[local:bnqr:Stopped]/>ls "/programs/Execute on stop run"
    Execute on stop run            /home/bnqr/online/bnqr/bin/at_end_run.csh
For more information see MIDAS [https://midas.triumf.ca/MidasWiki/index.php//Programs_ODB_tree /Programs ODB tree].






[[Category:BNMR]] [[Category:Scripts]]
[[Category:BNMR]] [[Category:Scripts]]

Latest revision as of 12:37, 28 April 2022

Introduction

A number of important scripts are used in the bnmr and bnqr experiments. Some of the most important are described here. Unless otherwise noted, the scripts described here can be found in directory ~/online/<beamline>/bin.

.bashrc

This important script in $HOME is the bash script executed on log in. This sets up the path, the aliases and environment variables required for running the DAQ system. This file is shared by all the machines in the NIS cluster with isdaq00 as master. This includes isdaq01, isdaq06, lxbnmr, lxbnqr. This script therefore checks the $HOST environment variable before setting up the DAQ system. See BNMR: Experimental Setup for details.


Scripts to restart MIDAS clients

A number of scripts are provided to start or restart the MIDAS clients needed for the data acquisition system. The most important of these is start-all which starts any missing clients. Scripts are also provided to start individual clients. These scripts are usually accessed from the Programs page when the user presses the restart button.

A script kill-all is provided to shut down all the clients.

start-all

start-all is an alias to the script start-all-daq-bn[mq]r (see Nomenclature). This script is run by the experimenter to start all the MIDAS clients needed for the DAQ system. It checks to see if each client is already running, and if not, starts it either by calling another script, or directly. It can be run at any time during the run to restart missing clients.

kill-all

kill-all is an alias to the script kill-all. This script kills all DAQ related clients. When there is some problem with the DAQ that cannot be otherwise resolved, users often do a kill-all followed by a start-all to ensure a clean restart.

start_frontend

The script start_frontend must be run on the VMIC (not the host computer). It is may be run directly, but is usually called by the script start-all. It starts the frontend program for bnmr or bnqr experiment under the screen program (see show-windows).

start_bnxr_logger

The script start_mdarc is run when the Programs page button restart for client bnxr_logger is pressed. This script is run on the host computer. This script restarts the MUD logger under the screen program (see show-windows).


Script to show screen program windows

show-windows

show-windows is an alias to the script show-windows. This script attaches to and displays (in an xterm, if possible) one or all midas clients that were started and managed under the screen program. This includes clients mdarc,mheader and the frontend (client name febn[mq]r_vmic - see Nomenclature).


The advantage of the screen program is that the terminal does not disappear when the client fails. Also it can be accessed from another terminal, and killing the window does not kill the client.

Previously each of these clients was started in an xterm by start-all, so that progress could be monitored, and any errors :displayed. The xterms appeared on the screen where start-all was executed, and were inaccessible to any other terminal. If the
client failed, the xterm promptly disappeared, so only the error messages sent to the MIDAS logger could be read.


  • To display all windows, give no argument, or the word "all".
  • To display a specific window, give the parameter in Table 1 :
Table 1 show-windows parameters
Command Parameter Action
show-windows to show all windows
show-windows all
show-windows vmic to show frontend window
show-windows frontend

Run transition scripts

Midas has a feature where programs can be automatically run at the start/end of each run (see the /Programs ODB tree documentation).

For bnmr and bnqr we only define an end-of-run program. All logic for the start of run is handled by clients that are always running.

End of run - elog_every_run.py

The /Programs/Execute on stop run is set to run the python program bnxr_common/elog_every_run.py. This program reads the /Experiment/Edit on start parameters (i.e. the parameters entered by the experimenter on starting a run), other ODB parameters including the Experimental (PPG) Mode of the run and whether it is run in dual or single channel mode, reads the statistics of the CAMP logged devices, and sends them all to the appropriate elog bnmr or bnqr. Automatic elog entries are identified in the Elog by the Type ("Automatic Elog"). The System parameter is set to the PPG Mode of the run.