How to use the sardana.sardanavalue.SardanaValue function in sardana

To help you get started, we’ve selected a few sardana examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github sardana-org / sardana / src / sardana / pool / poolpseudocounter.py View on Github external
try:
            obj = self.obj
            if physical_values is None:
                physical_values = self.get_physical_values()
            else:
                l_v, l_u = len(physical_values), len(obj.get_user_elements())
                if l_v != l_u:
                    raise IndexError("CalcPseudo(%s): must give %d physical "
                                     "values (you gave %d)" % (obj.name, l_u, l_v))
            ctrl, axis = obj.controller, obj.axis
            result = ctrl.calc(axis, physical_values)
            if result.error:
                self._exc_info = result.exc_info
        except SardanaException as se:
            self._exc_info = se.exc_info
            result = SardanaValue(exc_info=se.exc_info)
        except:
            exc_info = sys.exc_info()
            result = SardanaValue(exc_info=exc_info)
            self._exc_info = exc_info
        return result
github sardana-org / sardana / src / sardana / pool / poolcontroller.py View on Github external
def calc_all_physical(self, pseudo_pos, curr_physical_pos):
        ctrl = self.ctrl
        try:
            ctrl_value = ctrl.CalcAllPhysical(pseudo_pos, curr_physical_pos)
            if ctrl_value is None:
                msg = '%s.CalcAllPhysical() return error: Expected value, ' \
                      'got None instead' % (self.name,)
                raise ValueError(msg)
            value = translate_ctrl_value(ctrl_value)
        except:
            value = SardanaValue(exc_info=sys.exc_info())
        return value
github sardana-org / sardana / src / sardana / pool / poolpseudomotor.py View on Github external
try:
            obj = self.obj
            if physical_positions is None:
                physical_positions = self.get_physical_positions()
            else:
                l_p, l_u = len(physical_positions), len(
                    obj.get_user_elements())
                if l_p != l_u:
                    raise IndexError("CalcPseudo(%s): must give %d physical "
                                     "positions (you gave %d)" % (obj.name, l_u, l_p))
            result = obj.controller.calc_pseudo(
                obj.axis, physical_positions, None)
        except SardanaException as se:
            result = SardanaValue(exc_info=se.exc_info)
        except:
            result = SardanaValue(exc_info=sys.exc_info())
        return result
github taurus-org / taurus / src / sardana / pool / poolcontroller.py View on Github external
def calc_all_physical(self, pseudo_pos, curr_physical_pos):
        ctrl = self.ctrl
        try:
            ctrl_value = ctrl.CalcAllPhysical(pseudo_pos, curr_physical_pos)
            if ctrl_value is None:
                msg = '%s.CalcAllPhysical() return error: Expected value, ' \
                      'got None instead' % (self.name,)
                raise ValueError(msg)
            value = translate_ctrl_value(ctrl_value)
        except:
            value = SardanaValue(exc_info=sys.exc_info())
        return value
github taurus-org / taurus / src / sardana / pool / poolcontroller.py View on Github external
axes = self._element_axis.keys()
        if ctrl_values is None:
            ctrl_values = {}

        ctrl = self.ctrl

        try:
            ctrl.PreReadAll()
            for axis in axes:
                ctrl.PreReadOne(axis)
            ctrl.ReadAll()
        except:
            exc_info = sys.exc_info()
            for axis in axes:
                element = self.get_element(axis=axis)
                ctrl_values[element] = SardanaValue(exc_info=exc_info)
            return ctrl_values

        for axis in axes:
            element = self.get_element(axis=axis)
            ctrl_values[element] = self._read_axis_value(element)

        return ctrl_values
github sardana-org / sardana / src / sardana / pool / poolcontroller.py View on Github external
try:
            axis = element.get_axis()
            type_ = element.get_type()
            ctrl_value = self.ctrl.ReadOne(axis)
            if ctrl_value is None:
                msg = '%s.ReadOne(%s[%d]) return error: Expected value(s), ' \
                      'got None instead' % (self.name, element.name, axis)
                raise ValueError(msg)

            if is_chunk(type_, ctrl_value):
                value = [translate_ctrl_value(v) for v in ctrl_value]
            else:
                value = translate_ctrl_value(ctrl_value)
        except:
            value = SardanaValue(exc_info=sys.exc_info())
        return value
github sardana-org / sardana / src / sardana / pool / poolpseudomotor.py View on Github external
curr_physical_positions = self.get_physical_positions()
            if isinstance(new_position, collections.Sequence):
                new_positions = new_position
            else:
                positions = obj.get_siblings_positions()
                positions[obj] = new_position
                new_positions = len(positions) * [None]
                for pseudo, position in positions.items():
                    new_positions[pseudo.axis - 1] = position

            result = obj.controller.calc_all_physical(new_positions,
                                                      curr_physical_positions)
        except SardanaException as se:
            result = SardanaValue(exc_info=se.exc_info)
        except:
            result = SardanaValue(exc_info=sys.exc_info())
        return result
github sardana-org / sardana / src / sardana / pool / poolextension.py View on Github external
def translate_ctrl_value(value):
    if isinstance(value, SardanaValue):
        return value

    for _, translator in list(__CTRL_VALUE_TRANSLATORS.items()):
        try:
            return translator(value)
        except CannotTranslateException:
            continue

    # Fallback translator
    return SardanaValue(value=value)