Quickstart Linux: Difference between revisions

From MidasWiki
Jump to navigation Jump to search
No edit summary
No edit summary
Line 1: Line 1:
{{Pagelinks}}
{{Pagelinks}}
== Introduction ==
== Introduction ==
This quickstart shows you how to install the MIDAS packages on a linux box and create a MIDAS experiment.  
This quickstart shows you how to install the MIDAS packages on a linux box and create a '''MIDAS experiment'''.  
The linux box will be called the '''MIDAS host'''.  
The linux box will be called the MIDAS ''experiment host''.


==Installation==
==Installation==
Log on to the MIDAS host and decide on a name for the experiment (the '''MIDAS experiment name''').
Log on to the ''[[#Introduction|Experiment Host]]'' and decide on a name for the MIDAS experiment (the ''experiment name'').
In this installation, the MIDAS packages and experiment will be installed under the username "johnfoo".  
In these instructions, the MIDAS packages and experiment will be installed under the username "johnfoo".  
The ODB and other shared memory buffers for the MIDAS experiment will reside on the MIDAS host (localhost).
The ODB and other shared memory buffers for the MIDAS experiment will reside on the ''experiment host'' (localhost).
MIDAS and the other required packages will be installed under directory  {{Filepath|path=$HOME/packages}}. The MIDAS ''experiment directory'' will be  {{Filepath|path=$HOME/online}} and the MIDAS ''experiment name'' will be "e777". The name of the ''experiment host'' will be "mhostpc".  


In this quickstart, MIDAS and the other required packages will be installed under $HOME/packages . The '''MIDAS experiment directory''' will be $HOME/online and the '''MIDAS experiment name''' will be "e777". The MIDAS host name will be "mhostpc"
;NOTE
 
: The user should substitute directory paths for the MIDAS packages and experiment directory as required, and names for ''experiment host'', username, ''experiment name'' appropriate to his/her own setup.
The user should substitute appropriate host name, username, MIDAS experiment name and directories appropriate to his/her own setup.


== Experimental setup ==
== Experimental setup ==
These instructions describe setting up an experiment that will run ONLY on the MIDAS host computer (i.e. '''localhost only'''). In this case, the MIDAS host has access to any hardware required, and all frontends, logger, analyzer etc. run on the one computer.  
These instructions describe setting up an experiment that will run ONLY on the MIDAS ''experiment host'' computer (i.e. '''localhost only'''). In this case, the MIDAS ''experiment host'' has access to any hardware required, and all frontends, logger, analyzer etc. run on the one computer.  


Modifications to run an experiment with additional frontend(s) running '''remotely''' (i.e. on remote cpu(s)) will also be described
Modifications to run an experiment with additional frontend(s) running '''remotely''' (i.e. on remote cpu(s)) will also be described.
below. Follow the instructions for setting up a localhost experiment until indicated.  
Follow the instructions for setting up a localhost-only experiment until indicated.  
   
   
In both cases, the main MIDAS applications (e.g. [[mlogger]], [[mhttpd]]) run on the MIDAS host.
In both cases, the main MIDAS applications (e.g. [[mlogger]], [[mhttpd]]) run on the MIDAS ''experiment host''.


==Environment Variables==
==Environment Variables==
The following Environment variables should to be added to the $HOME/.cshrc (or .bash) file depending on your shell so that they will then be defined at login. '''Substitute appropriate values for your own setup'''.
The following Environment variables should to be added to the $HOME/.cshrc or .bash file (depending on your shell), on the ''experiment host'',  so that they will be defined at login. '''Substitute appropriate values for your own setup'''.  
<small>
<small>
{| class="wikitable"
{| class="wikitable"
Line 47: Line 47:
</small>
</small>
Logout and login again, or source .cshrc (source .bashrc) for the changes to take effect.
Logout and login again, or source .cshrc (source .bashrc) for the changes to take effect.
 
;NOTE
: See [[MIDAS environment variables]] for a list of environment variables used by MIDAS.
== ROOT Package Installation ==
== ROOT Package Installation ==
For full MIDAS operation, ROOT is needed for the data logging and analysis packages. It needed to build the example analyzer in this Quickstart.  However, ROOT is not essential to run MIDAS. If ROOT is NOT installed, the environment variable ROOTSYS should be undefined.
For full MIDAS operation, ROOT is needed for the data logging and analysis packages. It needed to build the example analyzer in this Quickstart.  However, ROOT is not essential to run MIDAS. If ROOT is NOT installed, the environment variable ROOTSYS should be undefined.
Line 54: Line 55:


== MIDAS Package Installation ==
== MIDAS Package Installation ==
The MIDAS package will be installed in the directory given by MIDASSYS - see [[#Environment Variables]].
The MIDAS package will be installed on the ''experiment host'' in the directory given by MIDASSYS - see [[#Environment Variables]].


Install the MIDAS and other package(s) from the MIDAS git repository as follows:
Install the MIDAS and other package(s) from the MIDAS git repository as follows:
Line 63: Line 64:
     git clone https://bitbucket.org/tmidas/mxml
     git clone https://bitbucket.org/tmidas/mxml
</small>
</small>
Install the MSCB  package only if you will be using the MSCB system for slow-controls (see [[MSCB Page]]):
Install the MSCB  package '''only''' if you will be using the MSCB system for slow-controls (see [[MSCB Page]]):
<small>  
<small>  
     git clone https://bitbucket.org/tmidas/mscb    ## MSCB package
     git clone https://bitbucket.org/tmidas/mscb    ## MSCB package
Line 98: Line 99:


== Create the Experiment file exptab ==
== Create the Experiment file exptab ==
In this example, the experimental directory is $HOME/online.
In this example, the experimental directory is {{Filepath|path=$HOME/online}}. Create this directory on the ''experiment host'' (localhost):
  <small>mkdir $HOME/online
  <small>mkdir $HOME/online
  cd $HOME/online</small>
  cd $HOME/online</small>
Create the [[exptab]] file "$HOME/online/exptab" containing the three parameters
Then create the [[exptab]] file "$HOME/online/exptab" containing the three parameters:
# the experiment name  
# the experiment name  
# location of MIDAS shared memory buffers
# location of MIDAS shared memory buffers
Line 112: Line 113:


== Create shared memory files  ==
== Create shared memory files  ==
At this point you should be able to run [[odbedit]] on localhost. The first time odbedit is run, it will create the required .*.SHM files  in the MIDAS experiment directory $HOME/online.  
At this point you should be able to run [[odbedit]] on the ''experiment host'' (localhost). The first time {{Utility|name=odbedit}} is run, it will create the required .*.SHM files  in the MIDAS experiment directory {{Filepath|path=$HOME/online}}. These are the saved files for the MIDAS shared memory.


The default directory $HOME/online will contain the MIDAS messages file (midas.log) and
The default directory {{Filepath|path=$HOME/online}} will contain the MIDAS messages file ({{File|name=midas.log}}) and
any data files you may create. If you want an alternative location for the data files see [[#Customizing your experiment]].
any data files you may create. If you want an alternative location for the data files see [[#Customizing your experiment]].
    
    
Now run odbedit, and type the command "ls" to list the default directories.  
Now run {{Utility|name=odbedit}}, and type the command {{Odbedit cmd|cmd=ls}} to list the default directories.  
  <small>odbedit
  <small>odbedit
  [local:e777:S]/>ls
  [local:e777:S]/>ls
Line 129: Line 130:


== Run the MIDAS logger ==
== Run the MIDAS logger ==
Start the MIDAS logger [[mlogger]]
Start the MIDAS logger [[mlogger]] on the ''experiment host'' (localhost) :
  <small>mlogger</small>  
  <small>mlogger</small>  
This should start without error at this point. It is usually run as a daemon, however in this case it is run in a terminal to check for errors. Starting the midas logger [[mlogger]] will automatically create more keys in the  {{Odbpath|path=/Logger}} ODB tree.
This should start without error. It is usually run as a daemon, however in this case it is run in a terminal to check for errors. Starting the midas logger [[mlogger]] will automatically create more keys in the  {{Odbpath|path=/Logger}} ODB tree.




Line 139: Line 140:


Otherwise, the MIDAS Web Server [[mhttpd]] with HTTPS/SSL (Mongoose) will be used. This is the default.
Otherwise, the MIDAS Web Server [[mhttpd]] with HTTPS/SSL (Mongoose) will be used. This is the default.
Now start [[mhttpd]] like this:
Now start [[mhttpd]] on the ''experiment host'' (localhost) like this:
  <small> mhttpd</small>
  <small> mhttpd</small>
You will get the following messages:  
You will get the following messages:  
Line 149: Line 150:
  could not start the mongoose web server, see messages and midas.log, bye!</small>
  could not start the mongoose web server, see messages and midas.log, bye!</small>


For testing, use the SSL certificate file provided in the MIDAS package (unless your site provides one, or you wish to [[Mhttpd#Create an SSL certificate|create your own SSL certificate]].  
For testing, use the SSL certificate file provided in the MIDAS package (unless your site provides one, or you wish to [[Mhttpd#Create an SSL certificate|create your own SSL certificate]] for added security.


However, you do need to '''create a password file''' by following the above instructions. You will be asked to type in a password
However, you do need to '''create a password file''' by following the above instructions. You will be asked to type in a password
Line 159: Line 160:
  Re-type new password:
  Re-type new password:
</small>
</small>
Now restart mhttpd
It is a good idea to set the password file {{Filepath|path=htpasswd.txt}} readable and writable by owner only.
 
Now restart {{Utility|name=mhttpd}}
  <small> mhttpd
  <small> mhttpd
  Mongoose web server will listen on ports "8080r,8443s" **see note
  Mongoose web server will listen on ports "8080r,8443s" **see note
Line 175: Line 178:


;** Note  
;** Note  
: Default ports of 8080 and 8443 are used by [[mhttpd]]. If these ports are in use on your machine, start mhttpd with alternative ports, e.g.
: Default ports of 8080 and 8443 are used by [[mhttpd]]. If these ports are in use on your machine, start {{Utility|name=mhttpd}} with alternative ports, e.g.
       <small>mhttpd --https 8448 --http 8089</small>
       <small>mhttpd --https 8448 --http 8089</small>
: or see [[Mhttpd#Usage]] to change the default ports.
: or see [[Mhttpd#Usage]] to change the default ports.
Line 184: Line 187:
* If creating a MIDAS experiment with a '''REMOTE''' frontend, '''continue by following the instructions''' [[#Running with one or more REMOTE frontend(s)]].
* If creating a MIDAS experiment with a '''REMOTE''' frontend, '''continue by following the instructions''' [[#Running with one or more REMOTE frontend(s)]].


* If all clients are running on '''localhost''', continue with the following instructions:
* If all clients are running on the Experiment Host (i.e. '''localhost'''), continue with the following instructions:


=== Frontend and analyzer (localhost) ===
=== Frontend and analyzer (localhost) ===
There are several examples of [[Frontend user code]] (frontend.c) in the MIDAS package available under $MIDASSYS/examples/. Choose a suitable example from this directory that you can later modify for your own particular setup (e.g. for a slow control, choose the slowcont/ example).  
There are several examples of [[Frontend user code]] ({{File|name=frontend.c}}) in the MIDAS package available under {{Filepath|path=$MIDASSYS/examples/}}. Choose a suitable example from this directory that you can later modify for your own particular setup (e.g. for a slow control, choose the {{Filepath|path=../slowcont/}} example).  


A frontend is a program that usually reads data from the hardware and sends the data to be logged and analyzed. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]].
A '''frontend''' is a program that usually reads data from the hardware and sends it to a buffer to be logged and analyzed. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]].


The example chosen here is from $MIDASSYS/examples/experiment/. It does '''not need any hardware''' and produces simulated events.   
The example chosen here is from {{Filepath|path=$MIDASSYS/examples/experiment/}}. It does '''not need any hardware''' and produces simulated events.   


On the MIDAS host (localhost), copy the example to the experiment directory and build it.
On the MIDAS ''experiment host'' (localhost), copy the example to the experiment directory and build it.
       cd $HOME/online
       cd $HOME/online
       cp $MIDASSYS/examples/experiment/* .
       cp $MIDASSYS/examples/experiment/* .
Line 200: Line 203:
At this point the frontend and the analyzer should be ready if no errors were generated during the build. Try the frontend and analyzer by starting them in xterms.  
At this point the frontend and the analyzer should be ready if no errors were generated during the build. Try the frontend and analyzer by starting them in xterms.  
  $frontend
  $frontend
Starting the frontend will automatically create the  {{Odbpath|path=/Equipment}} ODB tree and one or more equipments. In this case, the equipments "trigger" and "scaler" have been defined by code in frontend.c and created the first time frontend runs.
$analyzer
Starting the frontend will automatically create the  {{Odbpath|path=/Equipment}} ODB tree and one or more equipments. In this case, the equipments "trigger" and "scaler" have been defined by code in {{File|name=frontend.c}} and created the first time frontend runs.


  $odbedit
  $odbedit
Line 214: Line 218:
<div style="clear: both"></div>  <!-- clear wraparound after thumbnail -->
<div style="clear: both"></div>  <!-- clear wraparound after thumbnail -->


Rather than using odbedit,  you can view the contents of these equipments by clicking on the ODB button, then on /Equipment, then Trigger or Scaler. See [[ODB Page]] for more information.
Rather than using odbedit,  you can view the contents of these equipments by clicking on the ODB button, then on {{Odbpath|path=/Equipment}}, then {{Odbpath|path=Trigger}} or {{Odbpath|path=Scaler}}. See [[ODB Page]] for more information.


Start a run by pressing the Start button on the [[Status Page]].
Start a run by pressing the Start button on the [[Status Page]].
Line 231: Line 235:
The [[Status Page]] will also show events being generated (click the refresh button if necessary).  
The [[Status Page]] will also show events being generated (click the refresh button if necessary).  


While a run is in progress, the midas application mdump will provide you an event dump of the collected data from the running frontend, e.g.
While a run is in progress, the midas application [[mdump]] will provide you an event dump of the collected data from the running frontend, e.g.
  $ mdump -l 50
  $ mdump -l 50
- MIDAS revision: Mon Nov 2 11:50:51 2015 -0800 - 3b66779 -- Enter <!> to Exit ------- Midas Dump ---
- MIDAS revision: Mon Nov 2 11:50:51 2015 -0800 - 3b66779 -- Enter <!> to Exit ------- Midas Dump ---
Line 247: Line 251:


=== Create a start_daq script (localhost) ===
=== Create a start_daq script (localhost) ===
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a start_daq script. Create $HOME/online/bin/start_daq.sh as follows, (supply the mhttpd ports if default is not used).
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a start_daq script. Create $HOME/online/bin/start_daq.sh on the ''experiment host'' as follows (supply the mhttpd ports if default is not used):


  <small>#!/bin/sh
  <small>#!/bin/sh
Line 265: Line 269:


The script will start them as daemons.  
The script will start them as daemons.  
By running the script start_daq.sh, several midas applications will be started in sequence:
By running the script start_daq.sh, several MIDAS applications will be started in sequence:
  # Cleanup previous midas application (if any).
  # Cleanup previous MIDAS application (if any).
  # Start the midas web server [mhttpd]
  # Start the MIDAS web server [mhttpd]
  # Start the frontend application in its own xterm (for debugging purpose).
  # Start the frontend application in its own xterm (for debugging purpose).
  # Start the analyzer application in its own xterm (for debugging purpose).
  # Start the analyzer application in its own xterm (for debugging purpose).
  # Start the Midas Data logger [mlogger]
  # Start the MIDAS Data logger [mlogger]


   $ sh ./start_daq
   $ sh ./start_daq
Line 277: Line 281:
      
      
== Running with one or more REMOTE frontend(s) ==
== Running with one or more REMOTE frontend(s) ==
These instructions assume you have already followed the instructions to setup an experiment running on localhost, i.e. you have setup the MIDAS Environment variables, downloaded MIDAS packages, setup the [[mhttpd]] password etc.  
These instructions assume you have already followed the instructions to setup an experiment running on the MIDAS experiment host (localhost), i.e. you have setup the MIDAS Environment variables, downloaded MIDAS packages, setup the [[mhttpd]] password and have
{{Utility|name=mhttpd}} running successfully.
 
In the case of '''remote''' frontend(s), the remote cpu(s) typically have access to some or all of the hardware. They might be VMIC cpus running in VME crates for example, connected to the MIDAS Host via Ethernet.  They read data from the hardware and send it back to the MIDAS ''experiment host'' to be logged and analyzed.


In the case of remote frontend(s), the remote cpu(s) typically have access to some or all of the hardware. They might be VMIC cpus running in VME crates for example, connected to the MIDAS Host via Ethernet.  They read data from the hardware and send it back to the MIDAS Host to be logged and analyzed.
These instructions assume that there is one '''remote''' cpu, which is a 32-bit machine which mounts the /home disk of the localhost machine, so that it has access to the MIDAS packages, the $HOME/online directory and shares the .cshrc (or .bash) script. The REMOTE Host will be called "rlxhost" in these instructions. More remote cpus can be added in the same way.  


These instructions assume that there is one '''remote''' cpu, which is a 32-bit machine which mounts the /home disk of the localhost machine, so that it has access to the MIDAS packages, the $HOME/online directory and shares the .cshrc (or .bash) script. The REMOTE Host will be called "rlxhost" in these instructions. It is assumed that the MIDAS host is a 64-bit machine.
It is assumed the MIDAS ''experiment host'' computer is 64-bit in these instructions
 
=== MIDAS ''experiment host'' computer is 32-bit ===
If the MIDAS ''experiment host'' computer is 32-bit, the same as the ''remote host'', (i.e. a simpler setup), you will have built the 32-bit MIDAS libraries already, and can skip the next section. Note however, that in the .cshrc file in the following section [[#Modify .cshrc (.bash) for remote host]] you will be able to remove the section starting "# select 64-bit or 32-bit MIDAS and ROOT". The PATH should contain  {{Filepath|path=$MIDASSYS/linux/bin}} on both experiment host and remote host. This will point to the 32-bit MIDAS libraries.  


=== Build 32-bit MIDAS libraries ===
=== Build 32-bit MIDAS libraries ===
If the MIDAS host computer (localhost) is 64-bit, you will have already built the 64-bit MIDAS libraries. If the remote frontend is 32-bit, you will need to build the 32-bit MIDAS libraries on the 64-bit machine, i.e.
If [[MIDAS ''experiment host'' computer is 32-bit]] see above.
 
Otherwise, the MIDAS host computer is 64-bit, and you will have already built the 64-bit MIDAS libraries.
In this case, if the remote frontend is 32-bit, you will need to build the 32-bit MIDAS libraries on the 64-bit machine, i.e.
     [johnfoo@mhostpc e777] cd /home/packages/midas
     [johnfoo@mhostpc e777] cd /home/packages/midas
     [johnfoo@mhostpc e777] make linux32                ### build the 32-bit MIDAS libraries on 64-bit machine
     [johnfoo@mhostpc e777] make linux32                ### build the 32-bit MIDAS libraries on 64-bit machine
Line 290: Line 303:


=== Modify .cshrc (.bash) for remote host ===
=== Modify .cshrc (.bash) for remote host ===
Add the following to the .cshrc (modified appropriately for .bash).  When running with a REMOTE Host, the application [[mserver]] will be started (using a particular port) on the MIDAS host machine only.  Note that the environment variable MIDAS_SERVER_HOST is defined on the remote machine(s) but not on the MIDAS host.  
Add the following to the .cshrc (modified appropriately for .bash).  When running with a REMOTE Host, the application [[mserver]] will be started (using a particular port) on the MIDAS ''experiment host'' machine only.  Note that the environment variable MIDAS_SERVER_HOST is defined on the remote machine(s) but not on the MIDAS host.  
  # setenv MIDAS_HOST mhostpc  # substitute your midas host name
  # setenv MIDAS_HOST mhostpc  # substitute your experiment host name
  # setenv REMOTE_HOST rlxhost  # substitute your remote host name (add more if > 1)
  # setenv REMOTE_HOST rlxhost  # substitute your remote host name (add more if > 1)
  # setup the MIDAS mserver host
  # setup the MIDAS mserver host
Line 308: Line 321:
  switch (`uname -i`)
  switch (`uname -i`)
  case i386:
  case i386:
   setenv ROOTSYS /triumfcs/trshare/olchansk/root/root_v5.28.00_SL55_32
   setenv ROOTSYS /triumfcs/trshare/olchansk/root/root_v5.28.00_SL55_32   ## or appropriate path
   setenv PATH .:$MIDASSYS/linux-m32/bin:$PATH
   setenv PATH .:$MIDASSYS/linux-m32/bin:$PATH
   breaksw
   breaksw
Line 332: Line 345:


=== Grant REMOTE host access permission ===  
=== Grant REMOTE host access permission ===  
Give permission for the remote host(s) to access the experiment. Follow the instructions [[Security#MIDAS programs on remote machines||Allow MIDAS programs on remote machines]].  If the MIDAS web server is running, use [[ODB Page]] to edit the ODB keys listed, otherwise use [[odbedit]] on the MIDAS host machine.
Give permission for the remote host(s) to access the experiment. Follow the instructions [[Security#MIDAS programs on remote machines||Allow MIDAS programs on remote machines]].  If the MIDAS web server is running, use [[ODB Page]] to edit the ODB keys listed, otherwise use [[odbedit]] on the ''experiment host'' machine.
   
   
=== Start mserver on MIDAS Host ===
=== Start mserver on MIDAS Experiment Host ===
The application [[mserver]] is not required when running on localhost only, but it IS required for access from a REMOTE frontend.
The application [[mserver]] is not required when running an experiment on localhost only, but it '''IS required''' for access from a REMOTE frontend.
Start [[mserver]] on MIDAS host (default port 1175) or use the "-p" option for a different port.
Start [[mserver]] on MIDAS host (default port 1175) or use the "-p" option for a different port.
The port must match the port defined for MIDAS_SERVER_HOST in .cshrc (or .bash) [[#Modify .cshrc (.bash) for remote host|above]].)
The port must match the port defined for MIDAS_SERVER_HOST in .cshrc (or .bash) [[#Modify .cshrc (.bash) for remote host|above]].)
Line 345: Line 358:
  MIDAS_EXPT_NAME=e777
  MIDAS_EXPT_NAME=e777
  MIDAS_SERVER_HOST=mhostpc.triumf.ca:1175
  MIDAS_SERVER_HOST=mhostpc.triumf.ca:1175
(a different port may be used - see above)


=== Check access to ODB from REMOTE host ===
=== Check access to ODB from REMOTE host ===
Run odbedit on the remote host to check access to ODB.  
Run {{Utility|name=odbedit}} on the remote host to check access to ODB.  
  [johnfoo@rlxhost e777] odbedit
  [johnfoo@rlxhost e777] odbedit
  [mhostpc.triumf.ca:1175:e777:Stopped]/>ls
  [mhostpc.triumf.ca:1175:e777:Stopped]/>ls
If it does not work correctly, check that  
If it does not work correctly, check that  
* MIDAS_SERVER_HOST is defined on REMOTE host with same port as mserver
* MIDAS_SERVER_HOST is defined on REMOTE host with same port as [[mserver]]
* mserver is running on MIDAS host with the correct port
* {{Utility|name=mserver}} is running on MIDAS host with the correct port
* MIDAS_SERVER_HOST is NOT defined on MIDAS host
* MIDAS_SERVER_HOST is NOT defined on MIDAS host
* remote access permission to REMOTE host has been granted
* remote access permission to REMOTE host has been granted as described above.
as described above.


=== Build the analyzer on the MIDAS Host ===
=== Build the analyzer on the MIDAS Experiment Host ===
The analyzer will be built on the MIDAS host machine.
The analyzer will be built and run on the MIDAS ''experiment host'' machine.
Select an example from $MIDASSYS/examples/ (see [[#Frontend and analyzer (localhost)]]) and copy it to $HOME/online on the MIDAS host machine. Since we are assuming a 64-bit MIDAS host and a 32-bit remote host, edit the example Makefile so only the analyzer will be built.  
Select an example from $MIDASSYS/examples/ (see [[#Frontend and analyzer (localhost)]]) and copy it to $HOME/online on the MIDAS host machine. Since we are assuming a 64-bit MIDAS host and a 32-bit remote host, edit the example Makefile so only the analyzer will be built.  


Line 377: Line 390:


=== Run the Analyzer ===
=== Run the Analyzer ===
Start the analyzer in an xterm on the MIDAS host
Start the analyzer in an xterm on the MIDAS ''experiment host''
[johnfoo@mhostpc e777] a$HOME/online/analyzer
[johnfoo@mhostpc e777] $HOME/online/analyzer


Continue by starting a run and dumping the data as described under [[#Frontend and analyzer (localhost)]].
Continue by starting a run and dumping the data as described under [[#Frontend and analyzer (localhost)]].


=== Create experiment startup script ===
=== Create experiment startup script ===
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a start_daq script. Create $HOME/online/bin/start_daq.sh as follows, (supply the mhttpd ports if default is not used).
It is useful to create a script that will automatically start all the required clients for the experiment. This is called a start_daq script. Create $HOME/online/bin/start_daq.sh on the ''experiment host'' as follows, (supply the mhttpd ports if default is not used) :
  #!/bin/sh
  #!/bin/sh
  # start_daq.sh
  # start_daq.sh
Line 398: Line 411:
  odbedit -c clean
  odbedit -c clean
  #  start mhttpd on default port (Mongoose https version)
  #  start mhttpd on default port (Mongoose https version)
  mhttpd  -D  # optionally restrict access to localhost and/or other specified hosts - see [[mhttpd]]
  mhttpd  -D  # optionally restrict access to localhost (i.e. ''experiment host'') and/or other specified hosts - see [[mhttpd]]
  #  start mserver on default port (use argument -p to use a different port)  
  #  start mserver on default port (use argument -p to use a different port)  
  mserver -D  # start mserver on default port (1175) or a different port using -p option - see [[mserver]]
  mserver -D  # start mserver on default port (1175) or a different port using -p option - see [[mserver]]
Line 416: Line 429:
  [local:e777:S]/>sh all
  [local:e777:S]/>sh all


Execute the new startup script start_daq.sh and check that odbedit works on the REMOTE host  
Execute the new startup script start_daq.sh and check that {{Utility|name=odbedit}} works on the REMOTE host  




Line 434: Line 447:
  exit
  exit


Check that this script works by running it on the REMOTE host.  
Check that this script works by running it on the REMOTE host
Then uncomment line in start_daq.sh, and check that start_daq.sh can start all the clients from the MIDAS host.
$ source start_daq.sh
Then uncomment line in start_daq.sh, and check that start_daq.sh can start all the clients from the MIDAS ''experiment host''.




== Customize MIDAS for your experiment ==
== Customize MIDAS for your experiment ==
Copy an example frontend and Makefile (from $MIDASSYS/examples/) to this directory and modify for your hardware as needed. The example Frontend.c is an example of [[Frontend user code]]. Use the modified Makefile to compile and build a frontend client with the 32-bit MIDAS libraries. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]].
Here are some of the more common operations users can do to customize their experiments according to their own preferences:
Here are some of the more common operations users can do to customize their experiments according to their own preferences:
=== create kill_daq script ===
=== Write frontend(s) to read out and control your hardware ===
Modify the example frontend and Makefile (from $MIDASSYS/examples/) you have already copied and built so it accesses your hardware.
 
The example Frontend.c is an example of [[Frontend user code]]. You can find documentation about the frontend structure under [[Frontend Application]], [[Frontend Operation]] and [[Frontend user code]]. You may need to set up some [[Event Notification (Hot-Link)]]s in the frontend. The MIDAS package includes device drivers for some of the more common hardware. See [[MIDAS Driver Library]] for more information. 
 
=== Modify analyzer(s) for your data ===
Modify the example analyzer code as necessary to analyze the data from your frontends.
 
=== Slow Controls ===
Control your slow-controls equipment with slow-control frontend(s) optionally using the [[MSCB]] system.
 
=== Create kill_daq script ===
Optionally create a script similar to start_daq.sh to shutdown the experiment
Optionally create a script similar to start_daq.sh to shutdown the experiment
=== data logger ===
=== Data logger ===
Set up the data logger [[mlogger]] to log data to a storage device. Many options are available - see [[Data Logging]], [[mlogger]] and
Set up the data logger [[mlogger]] to log data to a storage device. Many options are available - see [[Data Logging]], [[mlogger]] and
[[/Logger ODB tree]] for instructions.
[[/Logger ODB tree]] for instructions.
 
=== Lazy logger ===
Set up the [[lazylogger]] for archiving data for storage.
=== create edit-on-start parameters ===
=== create edit-on-start parameters ===
See [[Edit-on-start Parameters]]
See [[Edit-on-start Parameters]]
Line 453: Line 478:
=== set up the alarm system ===
=== set up the alarm system ===
See [[Alarm System]] and [[Alarm Page]]
See [[Alarm System]] and [[Alarm Page]]
=== install hot-links as needed ===
=== Suppress some of the menu buttons on the Status Page ===
See [[Event Notification (Hot-Link)]]
=== suppress some of the menu buttons on the Status Page ===
See mhttpd [[Status Page#page_switch_buttons]]
See mhttpd [[Status Page#page_switch_buttons]]
=== set up history system ===
See [[History System]] and [[History Page]]
=== set up the Sequencer ===
The [[Sequencer Page#Sequencer]] can be used to run a sequence of runs, changing parameters as needed. 
=== set up the Electronic logbook (Elog) ===
See [[Elog]] for details
=== write a webserver Custom page ===
To better control and monitor your experiment, you may want to write a [[Custom Page]].
[[Category:Installation]]

Revision as of 19:40, 5 January 2016


Introduction

This quickstart shows you how to install the MIDAS packages on a linux box and create a MIDAS experiment. The linux box will be called the MIDAS experiment host.

Installation

Log on to the Experiment Host and decide on a name for the MIDAS experiment (the experiment name). In these instructions, the MIDAS packages and experiment will be installed under the username "johnfoo". The ODB and other shared memory buffers for the MIDAS experiment will reside on the experiment host (localhost). MIDAS and the other required packages will be installed under directory $HOME/packages. The MIDAS experiment directory will be $HOME/online and the MIDAS experiment name will be "e777". The name of the experiment host will be "mhostpc".

NOTE
The user should substitute directory paths for the MIDAS packages and experiment directory as required, and names for experiment host, username, experiment name appropriate to his/her own setup.

Experimental setup

These instructions describe setting up an experiment that will run ONLY on the MIDAS experiment host computer (i.e. localhost only). In this case, the MIDAS experiment host has access to any hardware required, and all frontends, logger, analyzer etc. run on the one computer.

Modifications to run an experiment with additional frontend(s) running remotely (i.e. on remote cpu(s)) will also be described. Follow the instructions for setting up a localhost-only experiment until indicated.

In both cases, the main MIDAS applications (e.g. mlogger, mhttpd) run on the MIDAS experiment host.

Environment Variables

The following Environment variables should to be added to the $HOME/.cshrc or .bash file (depending on your shell), on the experiment host, so that they will be defined at login. Substitute appropriate values for your own setup.

csh bash comment
setenv LANG C export LANG=C
setenv GIT_EDITOR "emacs -nw" export GIT_EDITOR="emacs -nw"
setenv MIDASSYS $HOME/packages/midas export MIDASSYS=$HOME/packages/midas Base directory of the MIDAS package
setenv ROOTSYS $HOME/packages/root export ROOTSYS=$HOME/packages/root setup ROOTSYS only if using ROOT
setenv MIDAS_EXPTAB $HOME/online/exptab export MIDAS_EXPTAB=$HOME/online/exptab MIDAS experiment table
setenv MIDAS_EXPT_NAME e777 export MIDAS_EXPT_NAME=e777 MIDAS experiment name
setenv PATH .:$MIDASSYS/linux/bin:$PATH export PATH=$PATH:$MIDASSYS/linux/bin path
setenv PATH .:$HOME/online/bin:$ROOTSYS/bin:$PATH export PATH=$PATH:$HOME/online/bin:$ROOTSYS/bin if using ROOT

Logout and login again, or source .cshrc (source .bashrc) for the changes to take effect.

NOTE
See MIDAS environment variables for a list of environment variables used by MIDAS.

ROOT Package Installation

For full MIDAS operation, ROOT is needed for the data logging and analysis packages. It needed to build the example analyzer in this Quickstart. However, ROOT is not essential to run MIDAS. If ROOT is NOT installed, the environment variable ROOTSYS should be undefined.

If ROOT is needed, see Install ROOT.

MIDAS Package Installation

The MIDAS package will be installed on the experiment host in the directory given by MIDASSYS - see #Environment Variables.

Install the MIDAS and other package(s) from the MIDAS git repository as follows:

   mkdir $HOME/packages
   cd $HOME/packages
   git clone https://bitbucket.org/tmidas/midas
   git clone https://bitbucket.org/tmidas/mxml

Install the MSCB package only if you will be using the MSCB system for slow-controls (see MSCB Page):

   git clone https://bitbucket.org/tmidas/mscb    ## MSCB package
   cd mscb
   make        ## Build the MSCB package
   cd ../

The MIDAS Makefile will auto-detect whether MSCB, ROOT, MYSQL, SQLITE, ODBC etc. are available (or have been installed). If you need these features, make sure they are available before building the MIDAS package.

   cd midas
   make          ## Build the MIDAS package
   ls -l linux/bin/odbedit      ### check that odbedit has been created (do not run it yet)

In case of problems see


ROOTANA Package Installation

If ROOTANA is needed,

   cd $HOME/packages
   git clone https://bitbucket.org/tmidas/rootana
   cd rootana
   make

ROODY Package Installation

If ROODY is needed,

   cd $HOME/packages
   git clone https://bitbucket.org/tmidas/roody
   cd roody
   make
   

Create the Experiment file exptab

In this example, the experimental directory is $HOME/online. Create this directory on the experiment host (localhost):

mkdir $HOME/online
cd $HOME/online

Then create the exptab file "$HOME/online/exptab" containing the three parameters:

  1. the experiment name
  2. location of MIDAS shared memory buffers
  3. username

as follows (using parameters for your own experiment):

   cat > exptab
   e777 /home/johnfoo/online johnfoo

The path of the exptab file is given by MIDAS_EXPTAB - see #Environment Variables.

Create shared memory files

At this point you should be able to run odbedit on the experiment host (localhost). The first time odbedit is run, it will create the required .*.SHM files in the MIDAS experiment directory $HOME/online. These are the saved files for the MIDAS shared memory.

The default directory $HOME/online will contain the MIDAS messages file ( midas.log) and any data files you may create. If you want an alternative location for the data files see #Customizing your experiment.

Now run odbedit, and type the command odbedit command ls to list the default directories.

odbedit
[local:e777:S]/>ls
Experiment
System
Programs
Logger
Runinfo
Alarms 

Run the MIDAS logger

Start the MIDAS logger mlogger on the experiment host (localhost) :

mlogger 

This should start without error. It is usually run as a daemon, however in this case it is run in a terminal to check for errors. Starting the midas logger mlogger will automatically create more keys in the /Logger ODB tree.


Run the MIDAS Web Server

If you are running behind a firewall or plan to set up an HTTPS/SSL proxy, follow the instructions mhttpd using an HTTPS/SSL proxy.

Otherwise, the MIDAS Web Server mhttpd with HTTPS/SSL (Mongoose) will be used. This is the default. Now start mhttpd on the experiment host (localhost) like this:

 mhttpd

You will get the following messages:

[mhttpd,INFO] ODB subtree /Runinfo corrected successfully
Mongoose web server will listen on ports "8080r,8443s"
Mongoose web server will use SSL certificate file "/home/johnfoo/packages/midas/ssl_cert.pem"
[mhttpd,ERROR] [mhttpd.cxx:17633:mongoose,ERROR] mongoose web server cannot find password file "/home/johnfoo/online/htpasswd.txt"
[mhttpd,ERROR] [mhttpd.cxx:17634:mongoose,ERROR] please create password file: htdigest -c /home/johnfoo/online/htpasswd.txt Default midas
could not start the mongoose web server, see messages and midas.log, bye!

For testing, use the SSL certificate file provided in the MIDAS package (unless your site provides one, or you wish to create your own SSL certificate for added security.

However, you do need to create a password file by following the above instructions. You will be asked to type in a password

$htdigest -c /home/johnfoo/online/htpasswd.txt Default midas
Adding password for midas in realm Default.
New password:
Re-type new password:

It is a good idea to set the password file htpasswd.txt readable and writable by owner only.

Now restart mhttpd

 mhttpd
Mongoose web server will listen on ports "8080r,8443s" **see note
Mongoose web server will use SSL certificate file "/home/suz/packages/midas/ssl_cert.pem"
Mongoose web server will use authentication realm "Default", password file "./htpasswd.txt"

Now point a web browser running on the same host computer (localhost) to https://localhost:8443 If the web browser is running on a different computer, go to URL of the form

https://mhostpc.triumf.ca:8443  (substitute your host machine name and domain for "mhostpc.triumf.ca")

If you are using the default SSL certificate you will probably get a message: "This Connection is Untrusted". Click "I understand the risks" and add an exception. This is because the test certificate is self-signed. Then confirm an exception.

You should then see an authentication box asking you for the user name and password. The user name is "midas". Enter the password you just created. The Midas Status Page should appear with multiple buttons for run control as well as equipment listing (no equipments will be listed as yet) and application listings. Please refer to mhttpd (the MIDAS Web-based Run Control utility) for further information. You can start and stop runs from the main status page, and use the ODB Page to access the database (ODB).

    • Note
Default ports of 8080 and 8443 are used by mhttpd. If these ports are in use on your machine, start

mhttpd with alternative ports, e.g.

      mhttpd --https 8448 --http 8089
or see Mhttpd#Usage to change the default ports.


Clients run on Localhost only

NOTE
  • If all clients are running on the Experiment Host (i.e. localhost), continue with the following instructions:

Frontend and analyzer (localhost)

There are several examples of Frontend user code ( frontend.c) in the MIDAS package available under $MIDASSYS/examples/. Choose a suitable example from this directory that you can later modify for your own particular setup (e.g. for a slow control, choose the ../slowcont/ example).

A frontend is a program that usually reads data from the hardware and sends it to a buffer to be logged and analyzed. You can find documentation about the frontend structure under Frontend Application, Frontend Operation and Frontend user code.

The example chosen here is from $MIDASSYS/examples/experiment/. It does not need any hardware and produces simulated events.

On the MIDAS experiment host (localhost), copy the example to the experiment directory and build it.

     cd $HOME/online
     cp $MIDASSYS/examples/experiment/* .
     make

The analyzer will only build if ROOT has previously been installed. At this point the frontend and the analyzer should be ready if no errors were generated during the build. Try the frontend and analyzer by starting them in xterms.

$frontend
$analyzer

Starting the frontend will automatically create the /Equipment ODB tree and one or more equipments. In this case, the equipments "trigger" and "scaler" have been defined by code in frontend.c and created the first time frontend runs.

$odbedit
[local:e777:S]/>ls /equipment
Trigger                         
Scaler  

View the MIDAS main status web page (by pointing your browser to https://localhost:8443/ or appropriate port if not using the default). Observe on the Status Page that the two Equipments (Trigger, Scaler) have appeared in the Equipment section (Figure 1).
Click thumbnail to enlarge

Figure 1: Equipments shown on Status Page

Rather than using odbedit, you can view the contents of these equipments by clicking on the ODB button, then on /Equipment, then Trigger or Scaler. See ODB Page for more information.

Start a run by pressing the Start button on the Status Page.

The frontend will show an event display that will update when a run is started, e.g.

Sample Frontend connected to <local>. Press "!" to exit      18:48:2546:08
==========================================================================
Run status:   Running    Run number 2                                   |/   /
===========================================================================
Equipment     Status     Events     Events/sec Rate[B/s]  ODB->FE FE->OD
---------------------------------------------------------------------------
Trigger       OK         13948      99.0       5413.0     0          140         
  aler        OK         15         0.3         15.4      0          15    

The Status Page will also show events being generated (click the refresh button if necessary).

While a run is in progress, the midas application mdump will provide you an event dump of the collected data from the running frontend, e.g.

$ mdump -l 50

- MIDAS revision: Mon Nov 2 11:50:51 2015 -0800 - 3b66779 -- Enter <!> to Exit ------- Midas Dump ---


Event# 1 ------------------------

Evid:0001- Mask:0000- Serial:0- Time:0x567a0c5d- Dsize:40/0x28

  1. banks:2 - Bank list:-ADC0TDC0-

Bank:ADC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2

  1-> 0x0167 0x03c6 0x0069 0x0073 

Bank:TDC0 Length: 8(I*1)/2(I*4)/4(Type) Type:Unsigned Integer*2

  1-> 0x0051 0x00ff 0x004a 0x00ec 

For further data processing/analysis, either the midas analyzer or the rootana can used for data display as well.

Create a start_daq script (localhost)

It is useful to create a script that will automatically start all the required clients for the experiment. This is called a start_daq script. Create $HOME/online/bin/start_daq.sh on the experiment host as follows (supply the mhttpd ports if default is not used):

#!/bin/sh
# start_daq.sh
cd $HOME/online
odbedit -c clean
#   start mhttpd on default port. (Mongoose https version)
mhttpd  -D  # optionally restrict access to localhost and/or other specified hosts - see mhttpd
xterm -e ./frontend &
xterm -e ./analyzer &
mlogger -D
#end file

Before running this script, you will need to shutdown any running clients:

$odbedit -c "sh all"

or you can use the mhttpd Program Page to shut them down.

The script will start them as daemons. By running the script start_daq.sh, several MIDAS applications will be started in sequence:

# Cleanup previous MIDAS application (if any).
# Start the MIDAS web server [mhttpd]
# Start the frontend application in its own xterm (for debugging purpose).
# Start the analyzer application in its own xterm (for debugging purpose).
# Start the MIDAS Data logger [mlogger]
  $ sh ./start_daq


Running with one or more REMOTE frontend(s)

These instructions assume you have already followed the instructions to setup an experiment running on the MIDAS experiment host (localhost), i.e. you have setup the MIDAS Environment variables, downloaded MIDAS packages, setup the mhttpd password and have

mhttpd running successfully.

In the case of remote frontend(s), the remote cpu(s) typically have access to some or all of the hardware. They might be VMIC cpus running in VME crates for example, connected to the MIDAS Host via Ethernet. They read data from the hardware and send it back to the MIDAS experiment host to be logged and analyzed.

These instructions assume that there is one remote cpu, which is a 32-bit machine which mounts the /home disk of the localhost machine, so that it has access to the MIDAS packages, the $HOME/online directory and shares the .cshrc (or .bash) script. The REMOTE Host will be called "rlxhost" in these instructions. More remote cpus can be added in the same way.

It is assumed the MIDAS experiment host computer is 64-bit in these instructions.

MIDAS experiment host computer is 32-bit

If the MIDAS experiment host computer is 32-bit, the same as the remote host, (i.e. a simpler setup), you will have built the 32-bit MIDAS libraries already, and can skip the next section. Note however, that in the .cshrc file in the following section #Modify .cshrc (.bash) for remote host you will be able to remove the section starting "# select 64-bit or 32-bit MIDAS and ROOT". The PATH should contain $MIDASSYS/linux/bin on both experiment host and remote host. This will point to the 32-bit MIDAS libraries.

Build 32-bit MIDAS libraries

If MIDAS ''experiment host'' computer is 32-bit see above.

Otherwise, the MIDAS host computer is 64-bit, and you will have already built the 64-bit MIDAS libraries.

In this case, if the remote frontend is 32-bit, you will need to build the 32-bit MIDAS libraries on the 64-bit machine, i.e.
   [johnfoo@mhostpc e777] cd /home/packages/midas
   [johnfoo@mhostpc e777] make linux32                ### build the 32-bit MIDAS libraries on 64-bit machine
   [johnfoo@mhostpc e777] ls -l linux-m32/bin/odbedit ### check that the 32-bit odbedit has been created (do not run it)

Modify .cshrc (.bash) for remote host

Add the following to the .cshrc (modified appropriately for .bash). When running with a REMOTE Host, the application mserver will be started (using a particular port) on the MIDAS experiment host machine only. Note that the environment variable MIDAS_SERVER_HOST is defined on the remote machine(s) but not on the MIDAS host.

# setenv MIDAS_HOST mhostpc   # substitute your experiment host name
# setenv REMOTE_HOST rlxhost   # substitute your remote host name (add more if > 1)
# setup the MIDAS mserver host
#
switch (`hostname`)
case $MIDAS_HOST*:                
  unsetenv MIDAS_SERVER_HOST     ## MIDAS_SERVER_HOST not defined
  breaksw
default:
setenv MIDAS_SERVER_HOST $MIDAS_HOST.triumf.ca:1175  ## for remote host, define as hostname + domain name + default mserver port
                                                     ## port must match that of mserver used in start_daq.sh 
endsw
#
# select 64-bit or 32-bit MIDAS and ROOT
#
switch (`uname -i`)
case i386:
  setenv ROOTSYS /triumfcs/trshare/olchansk/root/root_v5.28.00_SL55_32   ## or appropriate path
  setenv PATH .:$MIDASSYS/linux-m32/bin:$PATH
  breaksw
default:
  setenv ROOTSYS $HOME/packages/root
  setenv PATH .:$MIDASSYS/linux/bin:$PATH
endsw
#
setenv PATH .:$HOME/online/bin:$HOME/packages/roody/bin:$ROOTSYS/bin:$PATH
#

After executing .cshrc (or .bash) or logging out, on the MIDAS host (mhostpc) make sure MIDAS_SERVER_HOST is NOT defined

[johnfoo@mhostpc e777] echo $MIDAS_SERVER_HOST
[johnfoo@mhostpc e777] MIDAS_SERVER_HOST: Undefined variable.

and on the REMOTE Host, make sure MIDAS_SERVER_HOST IS defined:

 [johnfoo@rlxhost e777] echo $MIDAS_SERVER_HOST
 [johnfoo@rlxhost e777] MIDAS_SERVER_HOST

Also on the REMOTE Host, make sure that the correct (32-bit) odbedit will be used (do not run it yet!)

[johnfoo@rlxhost e777] which odbedit
/home/johnfoo/packages/midas/linux-m32/bin/odbedit

Grant REMOTE host access permission

Give permission for the remote host(s) to access the experiment. Follow the instructions |Allow MIDAS programs on remote machines. If the MIDAS web server is running, use ODB Page to edit the ODB keys listed, otherwise use odbedit on the experiment host machine.

Start mserver on MIDAS Experiment Host

The application mserver is not required when running an experiment on localhost only, but it IS required for access from a REMOTE frontend. Start mserver on MIDAS host (default port 1175) or use the "-p" option for a different port. The port must match the port defined for MIDAS_SERVER_HOST in .cshrc (or .bash) above.)

 [johnfoo@mhostpc e777] mserver -D

The environment variables on the REMOTE host should be:

[johnfoo@rlxhost e777]$ printenv | grep MIDAS
MIDASSYS=/home/e777/packages/midas
MIDAS_EXPT_NAME=e777
MIDAS_SERVER_HOST=mhostpc.triumf.ca:1175

(a different port may be used - see above)

Check access to ODB from REMOTE host

Run odbedit on the remote host to check access to ODB.

[johnfoo@rlxhost e777] odbedit
[mhostpc.triumf.ca:1175:e777:Stopped]/>ls

If it does not work correctly, check that

  • MIDAS_SERVER_HOST is defined on REMOTE host with same port as mserver

mserver is running on MIDAS host with the correct port

  • MIDAS_SERVER_HOST is NOT defined on MIDAS host
  • remote access permission to REMOTE host has been granted as described above.

Build the analyzer on the MIDAS Experiment Host

The analyzer will be built and run on the MIDAS experiment host machine. Select an example from $MIDASSYS/examples/ (see #Frontend and analyzer (localhost)) and copy it to $HOME/online on the MIDAS host machine. Since we are assuming a 64-bit MIDAS host and a 32-bit remote host, edit the example Makefile so only the analyzer will be built.

Build the frontend (32bit) for REMOTE host

The frontend runs on a 32-bit remote host in this example. It therefore must either

  • be built 32-bit on the 64-bit MIDAS host with the "-m32" flag
  • or built on the REMOTE host

and in either case the 32-bit MIDAS libraries used for linking.

To avoid confusion, create a different subdirectory for the frontend, e.g.

 [johnfoo@rlxhost e777] mkdir $HOME/online/fe_32

Copy the Makefile and frontend code from the same example to this directory. Modify the Makefile as needed, and only build the frontend.

Once built, start the frontend in an xterm on the REMOTE host.

[johnfoo@rlxhost e777] $HOME/online/fe_32/frontend

Check that it connects successfully to the experiment and the Equipments appear on the Status Page as described under #Frontend and analyzer (localhost). The Equipment Status (Figure 1) should show that the Equipments are now running on the remote cpu, i.e. "SampleFrontend@rlxhost.triumf.ca" rather than "Sample Frontend@localhost".

Run the Analyzer

Start the analyzer in an xterm on the MIDAS experiment host [johnfoo@mhostpc e777] $HOME/online/analyzer

Continue by starting a run and dumping the data as described under #Frontend and analyzer (localhost).

Create experiment startup script

It is useful to create a script that will automatically start all the required clients for the experiment. This is called a start_daq script. Create $HOME/online/bin/start_daq.sh on the experiment host as follows, (supply the mhttpd ports if default is not used) :

#!/bin/sh
# start_daq.sh
cd $HOME/online
#
switch (`hostname`)
  case $MIDAS_HOST*:
     echo "Good, we are on $MIDAS_HOST"
     breaksw
  case $REMOTE_HOST*:
     echo "start_daq script should be executed on $MIDAS_HOST"
endsw
#
odbedit -c clean
#   start mhttpd on default port (Mongoose https version)
mhttpd  -D   # optionally restrict access to localhost (i.e. experiment host) and/or other specified hosts - see mhttpd
#   start mserver on default port (use argument -p to use a different port) 
mserver -D  # start mserver on default port (1175) or a different port using -p option - see mserver
            # the port must match that of MIDAS_SERVER_HOST in .cshrc (.bash) - see above
            # access must be specifically allowed - see |above
xterm -e ./analyzer &
## start frontend on remote host
#ssh $REMOTE_HOST $HOME/online/bin/start_frontend -O >& $HOME/online/bin/start_frontend.log  &
mlogger -D
#end file

Note that command to start the frontend on the remote host is commented out. It can be uncommented once the start_frontend script is written and tested.

Shut down any clients that are running already by running odbedit on the MIDAS HOST

 odbedit>
[local:e777:S]/>sh all

Execute the new startup script start_daq.sh and check that odbedit works on the REMOTE host



Create start_frontend script

The startup file start_daq.sh invoked a file start_frontend to start the remote frontend. This line was commented out (see above). Now that the frontend is working, create start_frontend script (e.g. file $HOME/online/bin/start_frontend).

#!/bin/tcsh
# Script to start frontend running on $REMOTE_HOST
#
# This script runs on the REMOTE HOST
#
echo "starting frontend for experiment $MIDAS_EXPT_NAME "
xterm -geometry 150x50+800+0 -fg white -bg blue -title "Frontend" -e  "$HOME/online/fe_32/frontend" &
echo "Frontend task has been started"
exit

Check that this script works by running it on the REMOTE host

$ source start_daq.sh

Then uncomment line in start_daq.sh, and check that start_daq.sh can start all the clients from the MIDAS experiment host.


Customize MIDAS for your experiment

Here are some of the more common operations users can do to customize their experiments according to their own preferences:

Write frontend(s) to read out and control your hardware

Modify the example frontend and Makefile (from $MIDASSYS/examples/) you have already copied and built so it accesses your hardware.

The example Frontend.c is an example of Frontend user code. You can find documentation about the frontend structure under Frontend Application, Frontend Operation and Frontend user code. You may need to set up some Event Notification (Hot-Link)s in the frontend. The MIDAS package includes device drivers for some of the more common hardware. See MIDAS Driver Library for more information.

Modify analyzer(s) for your data

Modify the example analyzer code as necessary to analyze the data from your frontends.

Slow Controls

Control your slow-controls equipment with slow-control frontend(s) optionally using the MSCB system.

Create kill_daq script

Optionally create a script similar to start_daq.sh to shutdown the experiment

Data logger

Set up the data logger mlogger to log data to a storage device. Many options are available - see Data Logging, mlogger and /Logger ODB tree for instructions.

Lazy logger

Set up the lazylogger for archiving data for storage.

create edit-on-start parameters

See Edit-on-start Parameters

allow programs to be restarted from the Programs Page

See mhttpd Programs Page and /Programs ODB tree

set up the alarm system

See Alarm System and Alarm Page

Suppress some of the menu buttons on the Status Page

See mhttpd Status Page#page_switch_buttons

set up history system

See History System and History Page

set up the Sequencer

The Sequencer Page#Sequencer can be used to run a sequence of runs, changing parameters as needed.

set up the Electronic logbook (Elog)

See Elog for details

write a webserver Custom page

To better control and monitor your experiment, you may want to write a Custom Page.