Ejemplo n.º 1
0
    def pv_callback_step(self, pvname=None, value=None, char_value=None, **kw):
        """Callback function that is called by pyEpics when certain EPICS PVs are changed
        
        """

        log.debug('pv_callback_step pvName=%s, value=%s, char_value=%s',
                  pvname, value, char_value)
        if (pvname.find('StartEnergyChange') != -1) and (value == 1):
            self.energy_change()
Ejemplo n.º 2
0
 def _compute_senses(self):
     '''Computes whether this motion will be increasing or decreasing encoder counts.
     
     user direction, overall sense.
     '''
     # Encoder direction compared to dial coordinates
     encoder_dir = 1 if self.epics_pvs['PSOCountsPerRotation'].get(
     ) > 0 else -1
     # Get motor direction (dial vs. user); convert (0,1) = (pos, neg) to (1, -1)
     motor_dir = 1 if self.epics_pvs['RotationDirection'].get() == 0 else -1
     # Figure out whether motion is in positive or negative direction in user coordinates
     user_direction = 1 if self.rotation_stop > self.rotation_start else -1
     # Figure out overall sense: +1 if motion in + encoder direction, -1 otherwise
     log.debug((encoder_dir, motor_dir, user_direction))
     return user_direction * motor_dir * encoder_dir, user_direction
Ejemplo n.º 3
0
    def pv_callback(self, pvname=None, value=None, char_value=None, **kw):
        """Callback function that is called by pyEpics when certain EPICS PVs are changed

        The PVs that are handled are:

        - ``StartScan`` : Calls ``run_fly_scan()``

        - ``AbortScan`` : Calls ``abort_scan()``

        - ``MoveSampleIn`` : Runs ``MoveSampleIn()`` in a new thread.

        - ``MoveSampleOut`` : Runs ``MoveSampleOut()`` in a new thread.

        - ``ExposureTime`` : Runs ``set_exposure_time()`` in a new thread.

        - ``FilePath`` : Runs ``copy_file_path`` in a new thread.

        - ``FPFilePathExists`` : Runs ``copy_file_path_exists`` in a new thread.

        - ``FPWriteStatus``: Runs ``abort_scan()``
        """

        log.debug('pv_callback pvName=%s, value=%s, char_value=%s', pvname, value, char_value)
        if (pvname.find('MoveSampleIn') != -1) and (value == 1):
            thread = threading.Thread(target=self.move_sample_in, args=())
            thread.start()
        elif (pvname.find('MoveSampleOut') != -1) and (value == 1):
            thread = threading.Thread(target=self.move_sample_out, args=())
            thread.start()
        elif pvname.find('ExposureTime') != -1:
            thread = threading.Thread(target=self.set_exposure_time, args=(value,))
            thread.start()
        elif pvname.find('FilePathExists') != -1:
            thread = threading.Thread(target=self.copy_file_path_exists, args=())
            thread.start()
        elif pvname.find('FilePath') != -1:
            thread = threading.Thread(target=self.copy_file_path, args=())
            thread.start()
        elif (pvname.find('StartScan') != -1) and (value == 1):
            self.run_fly_scan()
        elif (pvname.find('AbortScan') != -1) and (value == 1):
            self.abort_scan()
        elif (pvname.find('WriteStatus') != -1) and (value == 1):
            self.abort_scan()