def createPVScannable( name, pv, addToNameSpace=True, hasUnits=True, getAsString=False):
    """
    utility function to create a scannable from a PV
    arguments:
    name - of scannable
    pv - pv 
    addToNameSpace = if True the scannable is accessible from the commandline after the call
    hasUnits - default True. The value is a number  and support is given for setUserUnits
    getAsString - default False. Useful if the PV is an enum as it returns the string representation. 
                 If true also set hasUnits to False 
    
    e.g.
    createPVScannable("acoll_average_size", "BL13J-OP-ACOLL-01:AVERAGESIZE", True)
    """
    sc = EpicsScannable()
    sc.setName(name)
    sc.setPvName(pv)
    sc.setUseNameAsInputName(True)
    sc.setHasUnits(hasUnits)
    sc.setGetAsString(getAsString)
    sc.afterPropertiesSet()
    sc.configure()
    if addToNameSpace:
        commandServer = InterfaceProvider.getJythonNamespace()    
        commandServer.placeInJythonNamespace(name,sc)
    return sc
def createPVScannable(name,
                      pv,
                      addToNameSpace=True,
                      hasUnits=True,
                      getAsString=False):
    """
    utility function to create a scannable from a PV
    arguments:
    name - of scannable
    pv - pv 
    addToNameSpace = if True the scannable is accessible from the commandline after the call
    hasUnits - default True. The value is a number  and support is given for setUserUnits
    getAsString - default False. Useful if the PV is an enum as it returns the string representation. 
                 If true also set hasUnits to False 
    
    e.g.
    createPVScannable("acoll_average_size", "BL13J-OP-ACOLL-01:AVERAGESIZE", True)
    """
    sc = EpicsScannable()
    sc.setName(name)
    sc.setPvName(pv)
    sc.setUseNameAsInputName(True)
    sc.setHasUnits(hasUnits)
    sc.setGetAsString(getAsString)
    sc.afterPropertiesSet()
    sc.configure()
    if addToNameSpace:
        commandServer = InterfaceProvider.getJythonNamespace()
        commandServer.placeInJythonNamespace(name, sc)
    return sc
def createScannableFromPV( name, pv, addToNameSpace=True, getAsString=True, hasUnits=False):
    """
    Description:
        utility function to create a scannable from a given PV
    Arguments:
        name - user-specified name of a scannable to be created, e.g. pixium10_DataType
        pv - EPICS identifier of pv to be used by the scannable, e.g. BL12I-EA-DET-10:CAM:DataType
        addToNameSpace = if True, the scannable is accessible from the commandline after the call
        getAsString - If True, output value is a string (useful for enum pv, in which case set getAsString=True, and set hasUnits=False)
        hasUnits - If False, output value is not converted to units - useful for enum pv with getAsString=True
    
    For example,
        createScannableFromPV("pixium10_DataType", "BL12I-EA-DET-10:CAM:DataType", True, True, False)
    creates a scannable for pv with the following enums:
    caget -d 31 BL12I-EA-DET-10:CAM:DataType
        BL12I-EA-DET-10:CAM:DataType
        Native data type: DBF_ENUM
        Request type:     DBR_CTRL_ENUM
        Element count:    1
        Value:            UInt32
        Status:           NO_ALARM
        Severity:         NO_ALARM
        Enums:            ( 8)
                          [ 0] Int8
                          [ 1] UInt8
                          [ 2] Int16
                          [ 3] UInt16
                          [ 4] Int32
                          [ 5] UInt32
                          [ 6] Float32
                          [ 7] Float64
    """
    sc = EpicsScannable()
    sc.setName(name)
    sc.setPvName(pv)
    sc.setUseNameAsInputName(True)
    sc.setGetAsString(getAsString)
    sc.setHasUnits(hasUnits)
    sc.afterPropertiesSet()
    sc.configure()
    if addToNameSpace:
        commandServer = InterfaceProvider.getJythonNamespace()
        commandServer.placeInJythonNamespace(name,sc)
    return sc
Beispiel #4
0
from gda.device.scannable import PVScannable, ScannableMotionBase,\
    EpicsScannable
from peem.leem_instances import FOV
from scisoftpy.jython.jymaths import nan
from gdaserver import s4ygap

print "-"*100
print "create KB Rastering control scannables: raster, beamsize, vrastamplitude, hrastamplitude, vrastoffset, hrastoffset, rastperiod, vraststatus, hraststatus"

#Low Level Scannables
vrastamplitude=PVScannable("vrastamplitude","BL06I-EA-SGEN-01:CH2:AMP"); vrastamplitude.configure()
hrastamplitude=PVScannable("hrastamplitude","BL06I-EA-SGEN-01:CH1:AMP"); hrastamplitude.configure()
vrastoffset=PVScannable("vrastoffset","BL06I-EA-SGEN-01:CH2:OFF"); vrastoffset.configure()
hrastoffset=PVScannable("hrastoffset","BL06I-EA-SGEN-01:CH1:OFF"); hrastoffset.configure()
rastperiod=PVScannable("rastperiod","BL06I-EA-SGEN-01:PERIOD"); rastperiod.configure()
vraststatus=EpicsScannable(); vraststatus.setName("vraststatus"); vraststatus.setHasUnits(False); 
vraststatus.setPvName("BL06I-EA-SGEN-01:CH2:OUT"); vraststatus.setGetAsString(True); 
vraststatus.setUseNameAsInputName(True); vraststatus.configure()
hraststatus=EpicsScannable(); hraststatus.setName("hraststatus"); hraststatus.setHasUnits(False); 
hraststatus.setPvName("BL06I-EA-SGEN-01:CH1:OUT"); hraststatus.setGetAsString(True); 
hraststatus.setUseNameAsInputName(True); hraststatus.configure()


KEYSIGHT_OUTPUT_STATUS={0:'Off',1:'On'}
KEYSIGHT_OUTPUT_VALUE={'Off':0,'On':1}

vert,horiz,roff,undefined=['vert','horiz','roff','undefined']

class KBMirrorRasteringStateControl(ScannableMotionBase):
    '''
    control Rastering state and direction: vert,horiz,roff,undefined