Setup
Environment
- You can develop the EDL generator in both, development (e.g. lcls-dev2) and production (lcls-builder) environments
- Make sure you have the proper Python setup (e.g., at least, version 2.6)
- If you don't, ask Jingchen for help
Dependencies
- $TOOLS/python/python2.6.4/external-packages/Cheetah (at least version 2.4)
- $TOOLS/python/python2.6.4/external-packages/epics (at least version 3)
- Some libraries that come with Python 2.6
Check out
- You can run EDL generator scripts from the command-line
- Check out the tools/python/slac-packages/edlgenerator module
cvs co -d . tools/python/slac-packages/edlgenerator
Development
Create EDL Template
Cheetah is the Python template engine used by EDL Generator (EdlGen).
Here is the recommended work flow:
- Using EDM (directly), create an exemplary display that features all widgets that you intend to generate.
- Create a master EDL file.
- Cut and paste all static widgets into a new master EDM display (of the same size). Save it to a master EDL file.
- Open the master file in a text editor and remove the EDM header, i.e. the following lines (and between them)
4 0 1 beginScreenProperties ... endScreenProperties
- Change the file ending of the remaining EDM display from .edl to .tmpl. This is your template.
- Come up with placeholders for your dynamic values (parameters).
- Open your template in a text editor and add Cheetah directives, placeholders, comments, as well as Python code. Here are some of the features you can use:
- Autocalling
- Def
- Echo
- Extends
- For
- If
- Import
- From ... Import
- Set
- Global
- Using its full path, include the master EDM file just after the header of the template.
Note: You should use a placeholder that stores the path to your files. - Compile your EDL template to a Python template module
bash-3.00$ $TOOLS/python/python2.6.4/external-packages/Cheetah/bin/cheetah compile my_template.tmpl Compiling -> my_template.py
Generate EDM Screen
- Import the edlgenerator module
import edlgenerator
- Import the template class that has the same name as your Python template module
from my_template import my_template
- Create a search list of the "placeholders-values" dictionaries (note: the list could, of course, contain just one such dictionary).
- Instantiate your template class, e.g.
edl_template = my_template(searchList=mySearchList)
- Use display_edl_instance to run EDM
edlgenerator.display_edl_instance(edl_template, edl_file_path, edit_mode=False)
- Parameters:
- edl_template - an instance of your template class
- edl_file_path - the path to the generated EDL file
- edit_mode (optional) - a flag indicating whether to run EDM in edit mode
- Parameters:
Release
Cheetah
- Download and extract Cheetah gzip file from http://www.cheetahtemplate.org/download.html
- Go to Cheetah's top directory (same directory as setup.py) and copy install_cheetah.bash into it
- If applicable, edit TAG in install_cheetah.bash
- Run install_cheetah.bash, e.g.
sh install_cheetah.bash
- Create a Cheetah softlink in $TOOLS/python/python2.6.4/external-packages, e.g.
cd $TOOLS/python/python2.6.4/external-packages ln -s Cheetah_R2_4_2_1/ Cheetah
EDL Generator
- Commit the changes to CVS
- Go to $TOOLS/python/python2.6.4/slac-packages/edlgenerator
- Run CVS update
cvs update