diff --git a/bliss/controllers/motors/icepap/__init__.py b/bliss/controllers/motors/icepap/__init__.py index d6df48d0f03a5cdd2261705c5e128e997f0c3942..8d27b0d101e0d6a9f003f5a55cdd13f2eead93ea 100644 --- a/bliss/controllers/motors/icepap/__init__.py +++ b/bliss/controllers/motors/icepap/__init__.py @@ -411,7 +411,70 @@ class Icepap(Controller): if mode == "INPOS": _ackcommand(self._cnx, "%d:POS INPOS 0" % address) _ackcommand(self._cnx,"%d:LTRACK %s" % (address,mode)) - + + @object_method(types_info=(("bool", "str", "sense"), "None")) + def activate_axis_to_sync(self, axis, activate=True, signal='MEASURE', + sense='NORMAL'): + """ + Send the given motor position to IcePAP controller + "SYNCRO" output (DB9 on controller front panel) + + Valid values for *signal* are: + - AXIS - axis nominal position + - MOTOR - axis electrical phase (MOTOR internal variable) + - MEASURE (default) - signal used as axis measurement + - SHFTENC + - CTRLENC + - ENCIN + - INPOS + - ABSENC + + Valid values for *sense* are: + - NORMAL (default) + - INVERTED + + Args: + axis (Axis): concerned axis object + + Keyword Args: + activate (bool): activate or de-activate axis to sync [default: True] + signal (str): position signal [default: MEASURE] + sense (str): position signal sense [default: NORMAL] + """ + address = axis.address + + if not activate: + # only remove pmux if the axis is active (avoid deactivating + # other axes unintentionally) + if self.is_axis_to_sync_active(axis): + self.pmux_remove() + return + + # remove any previous multiplexer rule + self.pmux_remove() + + # set the new multiplexer rule + cmd = "PMUX HARD B{0}".format(address) + _ackcommand(self._cnx, cmd) + + # set which signal the DRIVER has to send to multiplexer + cmd = '{0}:SYNCPOS {1} {2}'.format(address, signal, sense) + _ackcommand(self._cnx, cmd) + + @object_method(types_info=("None","bool")) + def is_axis_to_sync_active(self, axis): + """ + Tell if the given axis is feeding a position signal to the + "SYNCRO" output (DB9 on controller front panel) + + Returns: + bool: True if active or False otherwise + """ + return 'B{0}'.format(axis.address) in _command(self._cnx, '?PMUX') + + def pmux_remove(self): + _command(self._cnx, "PMUX REMOVE") + def reset(self): _command(self._cnx,"RESET")