def init(self, timeout=10.0) :
        """
        Initialize motor
        """
        
        # Initialize motor
        self.__logger.info("%s initializing...please be patient"%self.__basepv)
        self.__intialize()
        
        # Wait 0.2 seconds for log PVs to update
        time.sleep(0.2)
                
        # Check motor initialized
        motor_initialized = False 
        logbytes = None
        for letter in string.uppercase[0:8][::-1] :

            # time-now
            time_now = datetime.datetime.now()
            
            # Extract log messages
            logbytes = list(caget(self.__basepv + ".LOG" + letter))
            firstZero = logbytes.index(0L)            
            logbytes = logbytes[:firstZero]
            log = "".join(map(chr,logbytes))        
            self.__logger.debug("%s %s"%(self.__basepv,log))


            # Reject empty log mesages
            if not log:
                self.__logger.debug("empty message")
                continue

            # Split into time-stamp and log message
            timestamp = log[:8]
            logmessage = log[8:]
        
            # convert timestamp to datetime object
            log_ts = datetime.datetime.strptime(timestamp,"%H:%M:%S")

            # time difference [seconds]
            time_diff = min((time_now - log_ts).seconds,
                            (log_ts - time_now).seconds)

            # reject old log messages
            # Defined as message older than 1 minute
            if (time_diff > 60) :
                self.__logger.debug("Old message")
                continue
                        
            if "Initialization completed" in logmessage :
                motor_initialized = True
                break
        
        if motor_initialized == False :
            self.__logger.info("%s failed initialization" %self.__basepv)
        else:
            self.__logger.info("%s passed initialization" %self.__basepv)

        return motor_initialized
Пример #2
0
    def __init__(self, camerapv) :
        """
        camerapv: Base EPICS PV for the camera
        """        
        # Set up logger
        self.__logger = logging.getLogger(__name__)

        # Set up camera PVs 
        self.__basepv = camerapv

        # Get row and columns, bit-depth, and model
        # Using caget as we only need these values once
        self.__nrow = caget(self.__basepv + ":N_OF_ROW")
        self.__ncol = caget(self.__basepv + ":N_OF_COL")
        self.__nbit = caget(self.__basepv + ":N_OF_BITS")
        self.__model = caget(self.__basepv + ":Model")

        # Print out status
        print self.__basepv,self.__model
        print self.__nrow,"by",self.__ncol,"@",self.__nbit

        # Create PV to LIVE_IMAGE_FAST and average image
        # Using Pv class, as we'll be wanting these PVs all the time
        self.__liveimage_pv = Pv(self.__basepv + ":LIVE_IMAGE_FULL")
        self.__avgimage_pv = Pv(self.__basepv + ":AVG_IMAGE")
        self.__navgimage_pv = Pv(self.__basepv + ":AVERAGER.A")

        # Create PV to get horizontal projection
        self.__hproj_pv = Pv(self.__basepv + ":IMAGE_CMPX:HPrj")
                
        
        # Create Threading Event objects to signal when new images are
        # available  
        self.__new_liveimage = threading.Event()
        self.__new_avgimage = threading.Event()
        self.__new_hproj = threading.Event()


        # Connect to PVs
        self.connect()


        # Start monitors to asynchronously update Live Image, Average
        # Image, and horizontal projection
        self.__start_monitors()
    def pn(self) :
        """
        Get motor part number
        """
        motor_pn = caget(self.__basepv + ".PN")
        if motor_pn is "" :
            motor_pn = None

        self.__logger.debug("%s Part Number: %s"%(self.__basepv,motor_pn))

        return motor_pn
    def sn(self) :
        """
        Get motor serial number
        """
        motor_sn = caget(self.__basepv + ".SN")
        if motor_sn is "" :
            motor_sn = None

        self.__logger.debug("%s Serial Number: %s"%(self.__basepv,motor_sn))

        return motor_sn
Пример #5
0
    def display(self, motors, *fields):
        from caget import caget
        from pyca import pyexc
        fc = len(fields)
        mc = len(motors)
        lines = [["motor name"] + list(fields)]
        cw = [0] * (fc + 1)
        for fi in range(fc):
            cw[fi] = len(fields[fi])

        for mi in range(mc):
            m = motors[mi]
            line = [m.name] + [""] * fc
            try:
                pvname = m.pvname
                try:
                    for fi in range(fc):
                        v = repr(
                            caget(pvname + "." +
                                  motor.motor_params[fields[fi]][0]))
                        line[fi + 1] = v
                        pass
                    pass
                except pyexc, e:
                    pass
                finally:
                    for i in range(len(line)):
                        vw = len(line[i])
                        if vw > cw[i]:
                            cw[i] = vw
                            pass
                        pass
                    pass
                lines.append(line)
                pass
            finally:
Пример #6
0
 def get(self, refresh=False):
     if refresh:
         self.value = caget(self.get_pv_name())
     return self.value
Пример #7
0
import pyca
from caget import caget

sxr_beamline = ["SPS","TSS","MON","EXS","FLX","KBO","DFP","LIN","MNT","EXP"]
#amo_beamline = ["SAS","KBO","LMP","PPL"]

for dev in sxr_beamline :
    for mnt in range(1,50) :
        basepv = "SXR:%s:MMS:%02d"%(dev,mnt)
        sn_pv = basepv + ".SN"
        pn_pv = basepv + ".PN"
        
        try:
            sn = caget(sn_pv)
            pn = caget(pn_pv)
            print basepv,"MODEL:",pn," SERIAL NUMBER:",sn
        except pyca.pyexc, e:
            print basepv," --> DOES NOT EXIST"
        except pyca.caexc, e:
            print basepv," --> CHANNEL ACCESS ERROR"

        

Пример #8
0
 def get_position(self):
     return caget(self.__get_pv_name('.RBV'))
Пример #9
0
 def __get(self, pv_field):
     return caget(self.__get_pv_name(pv_field))