You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Environment Setup

Three C++ library extensions to Python have been written which allow scripting of interactions with the data acquisition and online monitoring system.  The necessary environment changes to pickup these extensions are

#!/bin/csh
setenv DAQREL /reg/g/pcds/dist/pds/2.10.6/build
setenv PYTHONPATH ${PYTHONPATH}:${DAQREL}/pdsapp/lib/x86_64-linux:${DAQREL}/ami/lib/x86_64-linux
setenv LD_LIBRARY_PATH ${LD_LIBRARY_PATH}:${DAQREL}/pdsdata/lib/x86_64-linux:${DAQREL}/pdsapp/lib/x86_64-linux:${DAQREL}/ami/lib/x86_64-linux

Editing Configurations

An example script for editing DAQ configurations follows:

import pycdb

def upgradeIpimbConfig(cfg):
    dat = cfg.get()          # retrieve the contents in a Python dictionary object
    dat['trigPsDelay'] = 0   # reset the presampling delay
    cfg.set(dat)             # store the change

if __name__ == "__main__":
    db = pycdb.Db('/reg/g/pcds/dist/pds/xpp/configdb/current') # set the target database
    xtclist = db.get(alias="BEAM",typeid=0x10017)              # retrieve all IPIMB configurations for BEAM runs (0x1 = version, 0x0017 = IPIMB)
    for x in xtclist:                                          # loop over the retrieved configurations
        upgradeIpimbConfig(x)                                  # modify the configuration
        db.set("BEAM",x)                                       # write the configuration back to the database
    db.commit()                                                # update the database with the changes

A complete pycdb module programmer's description follows:

 --- pycdb module ---

class pycdb.Db(path)

        Initializes access to the configuration database residing at 'path'.

Members:

        get(key=<Integer> or alias=<string>,
            src=<Integer> or level=<Integer>, typeid=<Integer>) or
        get(key=<Integer> or alias=<string>,
            typeid=<Integer>)
                Returns a tuple of configuration datum which satisfies the
                search criteria.  The search criteria is composed of either
                a particular database key number (integer) or alias name
                (for example, "BEAM"), an integer detector id 'src' or level
                (for example, 0=control), and an integer typeid
                (for example, 0x00050008 = Evr configuration version 5).
                The Python type of each returned object is specific to the
                datum returned { pycdb.DiodeFexConfig, pycdb.CspadConfig, ... }.

        set(alias, datum)
                Inserts the configuration 'datum' into the database for the
                global entry 'alias' (for example, "BEAM").

        commit()
                Updates all current run keys with the data inserted via calls to 'set'.

        clone(key)
                Returns a new database key created as a copy of the existing key 'key'.
                The returned key is suitable for modifying via calls to 'substitute'.

        substitute(key, datum)
                Insert the configuration 'datum' only for the given database 'key'.
  • No labels