Ejemplo n.º 1
0
def checkName(name, timeout=None, retries=None):
	"""
	usage: checkName("xxx:m1.VAL", timeout=None, retries=None)
	Intended for internal use by ca_util functions.
	"""

	global cadict, defaultTimeout, defaultRetries
	if not name:
		raise ca_utilException, EXCEPTION_NULL_NAME
		return

	if ((timeout == None) and (defaultTimeout != None)): timeout = defaultTimeout
	if (timeout == "NONE"): timeout = None

	if ((retries == None) and (defaultRetries != None)): retries = defaultRetries
	if ((retries == None) or (retries == "NONE")): retries = 0

	tries = 0
	while (not cadict.has_key(name)) and (tries <= retries):
		# Make a new entry in the PV-name dictionary
		try:
			channel = CaChannel.CaChannel()
			if (timeout != None): channel.setTimeout(timeout)
			channel.searchw(name)
			cadict[name] = cadictEntry(channel)
		except CaChannel.CaChannelException, status:
			del channel
			tries += 1
Ejemplo n.º 2
0
def main():
    try:
        chan = CaChannel()
        print("search_and_connect")
        chan.search_and_connect('catest', connectCb)
        chan.flush_io()
        for i in range(20):
            chan.pend_event()
        print("put_callback")
        chan.array_put_callback(3.3, None, None, putCb)
        chan.flush_io()
        for i in range(20):
            chan.pend_event()
        print("get_callback")
        chan.array_get_callback(None, None, getCb1)
        chan.flush_io()
        for i in range(20):
            chan.pend_event()
        print("get_callback with status")
        chan.array_get_callback(ca.dbf_type_to_DBR_CTRL(chan.field_type()), None, getCb2)
        chan.flush_io()
        for i in range(20):
            chan.pend_event()
    except CaChannelException as status:
        print(ca.message(status))


    try:
        cawave = CaChannel()
        print("cawave: search_and_connect")
        cawave.search_and_connect('cawave', connectCb)
        cawave.flush_io()
        for i in range(20):
            cawave.pend_event()
        print("cawave: array_put_callback")
        l = [0,1,2,3,4,5,6,7,8,9]
        cawave.array_put_callback(l, None, None, putCb)
        cawave.flush_io()
        for i in range(20):
            cawave.pend_event()
        print("cawave: array_get_callback")
        cawave.array_get_callback(ca.dbf_type_to_DBR_CTRL(cawave.field_type()), None, getCb2)
        cawave.flush_io()
        for i in range(20):
            cawave.pend_event()
    except CaChannelException as status:
        print(ca.message(status))
Ejemplo n.º 3
0
def checkName(name):
    """usage: checkName("xxx:m1.VAL")"""
    if not cadict.has_key(name):
        # Make a new entry in the PV-name dictionary
        channel = CaChannel()
        try:
            channel.searchw(name)
        except CaChannelException, status:
            print "checkName: CaChannel exception, status=", status
            raise CaChannelException, status
            return
        cadict[name] = [channel, 0]  # [channel, callback_flag]
Ejemplo n.º 4
0
def testConnect(pv):
    '''Tests if a CaChannel connection can be established to "pv"
       @param pv:[string]
       @return: True if can connect, otherwise False'''
    result = False
    if not IMPORTED_CACHANNEL:
        return result
    try:
        #print 'testConnect:', type(pv), pv
        chan = CaChannel.CaChannel()
        chan.searchw(str(pv))
        # val = chan.getw()
        del chan
        result = True
    except (TypeError, CaChannel.CaChannelException), status:
        # python3: (TypeError, CaChannel.CaChannelException) as status
        #print 'testConnect:', status
        pass
Ejemplo n.º 5
0
def main():
    try:
        cawave = CaChannel()

        cawave.searchw('cawave')

        t = (0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18,
             19)
        l = []
        for i in range(0, 500):
            l.append(i)
        #cawave.array_put(t)
        #cawave.pend_io()

        cawave.putw(l)
        print(cawave.getw())

        cawave.add_masked_array_event(None, None, ca.DBE_VALUE, getCallback, 0)
        cawave.pend_event()
        #cawave.clear_event()

    except CaChannelException as status:
        print(ca.message(status))
Ejemplo n.º 6
0
 def connectw(self):
     '''initiate the connection with EPICS, standard wait for the connection'''
     if IMPORTED_CACHANNEL:
         if len(self.pv) > 0:
             self.chan = CaChannel.CaChannel()
             self.chan.searchw(str(self.pv))
Ejemplo n.º 7
0
 def connect(self):
     '''initiate the connection with EPICS'''
     if IMPORTED_CACHANNEL:
         if len(self.pv) > 0:
             self.chan = CaChannel.CaChannel()
             self.chan.search(str(self.pv))
Ejemplo n.º 8
0
from CaChannel import *
import time

FastScan   = 'X15U1:test:scan1'
SlowScan   = 'X15U1:test:scan2' ######this is should be changed
SISPrefix  = 'X15USIS:'
FastMotor  = 'X15U1:EH:MAN1:X'
SlowMotor  = 'X15U1:EH:MAN7:Z'
xMAPPrefix = '15UdxpXMAP:'
FileName   = 'Scan11'      ##### this is should be changed, the better way is the same as the file name of savedata 
FastSpeed  = 1.0
SlowSpeed  = 0.15


NumSlow=CaChannel()
NumFast=CaChannel()
xmapPixels=CaChannel()
sisEraseStart=CaChannel()
sisPixels=CaChannel()
sisPreScale=CaChannel()
xmapEraseStart=CaChannel()
xmapState=CaChannel()
FastScanBusy=CaChannel()
netCDFSaveMode=CaChannel()
netCDFNumCapture=CaChannel()
netCDFEnable=CaChannel()
netCDFCapture=CaChannel()
netCDFFileName=CaChannel()
netCDFFileNumber=CaChannel()
Zmotor=CaChannel()