Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Axis(object):
- """IcePAP emulated axis"""
- def __init__(self, icepap, address=None, **opts):
- """ COSICAS DE LA CLASSE """
- # --- Axis level commands
- def move(self, args=(), cmd_result=None, **kwargs):
- self._destination = float(args)
- velocity = float(getattr(self, "velocity", None)())
- acctime = float(getattr(self, "acctime", None)())
- position = float(getattr(self, "posaxis", None)())
- acceleration = velocity / acctime
- self._sign = 1
- if position > self._destination:
- self._sign = -1
- self._t1 = velocity / acceleration
- self._x0 = position
- self._x1 = self._x0 + self._sign * acceleration * (self._t1 ** 2) / 2
- if self._t1 == self._t2:
- self._x2 = self._x1
- else:
- self._x2 = self._x1 + self._sign * (abs(self._x0 - self._destination) - 2 *
- abs(self._x0 - self._x1))
- self._t2 = self._t1 + abs(self._x2 - self._x1) / velocity
- self._t3 = self._t1 + self._t2
- if 2 * self._t1 > self._t3:
- raise RuntimeError("Acceleration time too slow")
- """ NECESITO QUE TODOS LOS MOTORES HAGAN ESTA LINEA CASI AL MISMO TIEMPO """
- self._start_time = time.time()
- self._log.debug("move %r to %r", self.address, self._destination)
- # setattr(self, "_posaxis", destination)
- return " OK"
- posaxis = fpos = axis_command(position)
- pos = axis_command("pos", default=0)
- velocity = axis_command("velocity", default=1000)
- acctime = axis_command("acctime", default=0.25)
- move = axis_command(move)
- """ ... MUCHO CODIGO ... """
- def command(f_or_name=None, mode="rw", axes_arg_parser=None, default=None):
- """ ... MUCHO CODIGO ... """
- @functools.wraps(f)
- def wraps(self, **kwargs):
- """ ... MUCHO CODIGO ... """
- else:
- for axis, arg in zip(axes, args):
- axis = self._get_axis(axis, system=True)
- """ MI INTENTO DE THREAD """
- thread = lambda a, n, ar: result.append(str(getattr(a, n)(ar)))
- x = threading.Thread(target=thread, args=(axis, name, arg))
- x.start()
- """ EL VERDADERO CODIGO A THREDEAR QUE LLAMA EL WRAPPER EN LA CLASSE ANTERIOR CON LA FUNCION """
- # result.append(str(getattr(axis, name)(arg)))
- """ ... MUCHO CODIGO ... """
- return wraps
- read_command = functools.partial(command, mode="r")
- axes_command = functools.partial(command, axes_arg_parser=axis_value_parse_args)
- axes_read_command = functools.partial(axes_command, mode="r")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement