1. #Setup
    1. #Environment
    2. #Dependencies
    3. #Check out
  2. #Development
    1. #Create EDL Template
    2. #Generate EDM Screen
  3. #Release
    1. #Cheetah
    2. #EDL Generator

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:

  1. Using EDM (directly), create an exemplary display that features all widgets that you intend to generate.
  2. Create a master EDL file.
    1. Cut and paste all static widgets into a new master EDM display (of the same size). Save it to a master EDL file.
    2. 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
      
  3. Change the file ending of the remaining EDM display from .edl to .tmpl. This is your template.
  4. Come up with placeholders for your dynamic values (parameters).
  5. 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:
    1. Autocalling
    2. Def
    3. Echo
    4. Extends
    5. For
    6. If
    7. Import
      1. From ... Import
    8. Set
      1. Global
  6. 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.
  7. 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

  1. Import the edlgenerator module
    import edlgenerator
    
  2. Import the template class that has the same name as your Python template module
    from my_template import my_template
    
  3. Create a search list of the "placeholders-values" dictionaries (note: the list could, of course, contain just one such dictionary).
  4. Instantiate your template class, e.g.
    edl_template = my_template(searchList=mySearchList)
    
  5. 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

Release

Cheetah

  1. Download and extract Cheetah gzip file from http://www.cheetahtemplate.org/download.html
  2. Go to Cheetah's top directory (same directory as setup.py) and copy install_cheetah.bash into it
  3. If applicable, edit TAG in install_cheetah.bash
  4. Run install_cheetah.bash, e.g.
    sh install_cheetah.bash
    
  5. 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

  1. Commit the changes to CVS
  2. Go to $TOOLS/python/python2.6.4/slac-packages/edlgenerator
  3. Run CVS update
    cvs update 
    
  • No labels