Ejemplo n.º 1
0
    def __init__(self, serialno, polling=200, home=False):
        self._serialno = c_char_p(bytes(str(serialno), "utf-8"))

        # Get and store device info
        self._device_info = kcdc.TLI_DeviceInfo()
        kcdc.TLI_GetDeviceInfo(self._serialno, byref(self._device_info))

        # Open communication with the device
        kcdc.CC_Open(self._serialno)
        kcdc.CC_StartPolling(self._serialno, c_int(polling))

        # Sleep while device initialization occurs
        time.sleep(3)

        # Clear the message queue
        kcdc.CC_ClearMessageQueue(self._serialno)

        # Is this necessary?
        self.wait_for_completion()

        if home:
            if not kcdc.CC_CanHome(self._serialno).value:
                self.homed = False
                raise RuntimeError("Device '{}' is not homeable.")
            else:
                status = kcdc.CC_Home(self._serialno)
                check_error(status)
                self.homed = True
        else:
            self.homed = False

        # The following are in device units
        self._max_pos = kcdc.CC_GetStageAxisMaxPosition(self._serialno)
        self._min_pos = kcdc.CC_GetStageAxisMinPosition(self._serialno)
Ejemplo n.º 2
0
    def go_home(self):
        """
        Takes the device home and sets self.homed to true

        go_home() will always ignore the software limits from soft_limits_mode 
        and min_pos and max_pos.

        FIXME: This function shouldn't exist; it's provided by HomingMixin
        """
        log.debug(f"Homing KDC101 device '{self.serialno}'")
        status = kcdc.CC_Home(self._serialno)
        check_error(status)
        self.homed = True
        self.wait_for_completion()
        log.debug(f"Homed: KDC101 device '{self.serialno}'")
Ejemplo n.º 3
0
 def home(self):
     kcdc.CC_Home(self._serialno)
     self.wait_for_completion()
Ejemplo n.º 4
0
 def home(self, block=True):
     log.debug(f"Homing KDC101 device '{self.serialno}'")
     status = kcdc.CC_Home(self._serialno)
     check_error(status)
     if block:
         self.wait_for_completion()