CommandEntryο
- class bapsf_motion.actors.motor_.CommandEntry(command: str, *, send: str, send_processor: ~typing.Callable[[~typing.Any], str] | None = None, recv: ~re.Pattern | None = None, recv_processor: ~typing.Callable[[str], ~typing.Any] | None = <function do_nothing>, two_way: bool = False, units: str | ~astropy.units.core.Unit | None = None, method_command: bool = False, buffered: bool = True)ο
Bases:
UserDictA
dictcontaining all the necessary information to define a command that is sent to an ethernet based stepper motor.- Parameters:
command (str) β Name of the command. If the command entry is also a method command, then this must be the name of the class method to be called.
send (str) β The base
strcommand that is sent to the motor.send_processor (callable, optional) β A callable object that processes the command argument before the full command is sent to the motor. The callable must return a string that is concatenated with the
sendcommand to form the full command. IfNone, then the command is assumed to have no argument. (DEFAULT:None)recv (re.Pattern, optional) β A
recompiled pattern to expression match any received string from the sent command. IfNone, then no expression matching is performed on the returned string. If a pattern is defined, then the pattern must define a return group (i.e.'(?P<return>...)'). This return group is assumed to be the returned argument and will be further processed by therecv_processor. (DEFAULT:None)recv_processor (callable, optional) β A callable object that will process the returned argument from the sent command. The returned command is always in the form of a string, so the processor must take a string and process that it into any desirable type. If
None, then no processing is performed. (DEFAULT:do_nothing)two_way (bool, optional) β The command both sends and receives arguments from the motor. (DEFAULT:
False)units (unit-like, optional) β An object that represents the units of the sent and/or returned arguments. These units will converted into
astropy.unitsand will become the default units for any argument sent or received by this defined command. (DEFAULT:None)method_command (bool) β If
True, then the defined command is a method command. A method command is an advanced motor command (e.g.move_to) that requires multiple base commands to be performed in a particular sequence. Thus, thecommandargument defines the name of a class method that will be executed for this command. (DEFAULT:False)
Examples
An example of a typical motor command entryβ¦
ce = CommandEntry( "speed", send="VE", send_processor=lambda value: f"{float(value):.4f}", recv=re.compile(r"VE=(?P<return>[0-9]+\.?[0-9]*)"), recv_processor=float, two_way=True, units=u.rev / u.s, )
An example of a method based motor command entry. A method based command is reserved for more advanced commands that typically require multiple base commands to be sent in a particular sequence.
ce = CommandEntry( "move_to", send="", units=u.steps, method_command=True, )
Attributes Summary
Name of the command.
Methods Summary
clear()copy()fromkeys(iterable[,Β value])get(k[,d])items()keys()pop(k[,d])value.
popitem()as a 2-tuple; but raise KeyError if D is empty.
setdefault(k[,d])update([E,Β ]**F)If E present and has a .keys() method, does:
values()Attributes Documentation
- commandο
Name of the command. If the command entry is also a method command, then this is the name of the class method to be called.
Methods Documentation
- clear() None. Remove all items from D.ο
- copy()ο
- classmethod fromkeys(iterable, value=None)ο
- get(k[, d]) D[k] if k in D, else d. d defaults to None.ο
- items() a set-like object providing a view on D's itemsο
- keys() a set-like object providing a view on D's keysο
- pop(k[, d]) v, remove specified key and return the correspondingο
value. If key is not found, d is returned if given, otherwise KeyError is raised.
- popitem() (k, v), remove and return some (key, value) pairο
as a 2-tuple; but raise KeyError if D is empty.
- setdefault(k[, d]) D.get(k,d), also set D[k]=d if k not in Dο
- update([E, ]**F) None. Update D from mapping/iterable E and F.ο
- If E present and has a .keys() method, does:
for k in E.keys(): D[k] = E[k]
- If E present and lacks .keys() method, does:
for (k, v) in E: D[k] = v
- In either case, this is followed by:
for k, v in F.items(): D[k] = v
- values() an object providing a view on D's valuesο