MotionGroupο
- class bapsf_motion.actors.motion_group_.MotionGroup(config: str | Dict[str, Any] = None, *, logger: Logger = None, loop: AbstractEventLoop = None, auto_run: bool = False, build_mode: bool = False, parent: EventActor | None = None)ο
Bases:
EventActorThe
MotionGroupactor brings together all the components that are needed to move a probe drive around the motion space. These components include: (1) the full motion group configuration (i.e. instance ofMotionGroupConfig), (2) communication with the probe drive (i.e. instance ofDrive), (3) an understanding of the motion space (i.e. instance ofMotionBuilder, and (4) how to convert back and forth from the motion space coordinate system and the probe drive coordinate system (i.e. instance of a subclass ofBaseTransform).- Parameters:
config (
strordict) β A TOML like string or dictionary defining the motion group configuration. SeeMotionGroupConfigfor further details.logger (
Logger, optional) β An instance ofLoggerthat the Actor will record events and status updates to. IfNone, then a logger will automatically be generated. (DEFAULT:None)loop (
asyncio.AbstractEventLoop, optional) β Instance of anasyncioevent loop. Communication with all the axes will happen primarily through the event loop. IfNone, then an event loop will be auto-generated. (DEFAULT:None)auto_run (bool, optional) β If
True, then the event loop will be placed in a separate thread and started. This is all done via therun()method. (DEFAULT:False)
Attributes Summary
Configuration dictionary of the actor.
Trueif the TCP connection is established for ALL drive axes (i.e. the entire motion group).Instance of
Driveassociated with the motion group.Current encoder position of the probe drive, in motion space coordinates and units.
The
Loggerinstance being used for the actor.The
asyncioevent loop for the actor.Instance of
MotionBuilderassociated with the motion group.Last motion list index the probe drive moved to.
(
str) A unique name given for the instance of the actor.Current position of the probe drive, in motion space coordinates and units.
List of
asyncio.Tasks this actor has in its event loop.Indicates if the actor has been terminated.
The
Threadthe event loop is running in.Instance of the transformer associated with the motion group.
Methods Summary
move_ml(index)Move the probe drive to a specific index of the motion list.
move_to(pos[,Β axis])Move the probe drive to a specified location,
pos.replace_drive(drive)Replace the
Driveinstance associated with the motion group.run([auto_run])Activate the
asyncioevent loop.set_zero([axis])Make current motion space position zero.
setup_event_loop([loop])Set up the
asyncioevent loop.stop([soft])Immediately stop the probe drive motion.
terminate([delay_loop_stop])Stop the actor's event loop.
Attributes Documentation
- configο
Configuration dictionary of the actor.
Warning
This dictionary should never be written to from outside the owning actor.
- connectedο
Trueif the TCP connection is established for ALL drive axes (i.e. the entire motion group).
- encoderο
Current encoder position of the probe drive, in motion space coordinates and units.
- is_movingο
- loggerο
The
Loggerinstance being used for the actor.
- loopο
The
asyncioevent loop for the actor.
- mbο
Instance of
MotionBuilderassociated with the motion group.
- ml_indexο
Last motion list index the probe drive moved to.
- nameο
(
str) A unique name given for the instance of the actor. This name is used as an identifier in the actor logger (seelogger).If the user does not specify a name, then the Actor should auto-generate a name.
- parentο
- positionο
Current position of the probe drive, in motion space coordinates and units.
- tasksο
List of
asyncio.Tasks this actor has in its event loop.
- terminatedο
Indicates if the actor has been terminated.
- threadο
The
Threadthe event loop is running in.If
loopwas given during instantiation, then there is no way of obtaining the thread object the event loop is running in. In this casethreadwill beNone.The thread id can always be retrieved using
_thread_id.
- transformο
Instance of the transformer associated with the motion group.
Methods Documentation
- move_to(pos, axis: int | None = None)ο
Move the probe drive to a specified location,
pos.- Parameters:
pos (array_like) β A position in the motion space for the probe to be moved to.
posshould have the same dimensionality as the motion space unless keywordaxisis used.axis (
int, optional) β An integer specifying which axis is to be moved.axisis integer of 0 to \(N-1\), where \(N\) is the dimensionality of the motion space.
- replace_drive(drive: Drive | Dict[str, Any])ο
Replace the
Driveinstance associated with the motion group. If the new drive is not valid, then no replacement will be performed.- Parameters:
drive (Union[Drive, Dict[str, Any]]) β The new drive to replace this existing drive. This can either be an instance of
Driveor a valid dictionary configuration for a drive.
Notes
If the given
driveis running, then it will be terminated and respawned using the event looploop()associated with the motion group.
- replace_motion_builder(mb: MotionBuilder | Dict[str, Any])ο
- replace_transform(tr: BaseTransform | Dict[str, Any])ο
- run(auto_run=True)ο
Activate the
asyncioevent loop. If the event loop is running, then nothing happens. Otherwise, the event loop is placed in a separate thread and set torun_forever.
- setup_event_loop(loop: AbstractEventLoop | None = None)ο
Set up the
asyncioevent loop. If the given loop is not an instance ofAbstractEventLoop, then a new loop will be created.- Parameters:
loop (
asyncio.AbstractEventLoop) βasyncioevent loop for the actorβs tasks
- stop(soft=False)ο
Immediately stop the probe drive motion.
- terminate(delay_loop_stop=False)ο
Stop the actorβs event loop. All actor tasks will be cancelled, the connection to the motor will be shutdown, and the event loop will be stopped.
- Parameters:
delay_loop_stop (bool) β If
True, then do NOT stop the event loop. In this case it is assumed the calling functionality is managing additional tasks in the event loop, and it is up to that functionality to stop the loop. (DEFAULT:False)