QScanPattern#
- class QPolargraph.patterns.QScanPattern.QScanPattern(*args, width=0.6, height=0.6, dx=0.0, dy=0.1, step=5, polargraph, **kwargs)[source]#
Bases:
QObjectBase class for polargraph scan-trajectory patterns.
Manages the scan geometry and drives the polargraph through a sequence of waypoints. Subclasses override
vertices()andtrajectory()to define different scan patterns.The motion controller is always in one of four states (
ScanState):IDLE — no motion.
MOVING — positioning to the scan start or returning home; data are not collected.
SCANNING — actively scanning;
dataReady()is emitted at each position poll.PAUSED — motion suspended; the remaining trajectory is saved and the polargraph holds its current position.
Properties#
- widthfloat
Horizontal extent of the scan area [m]. Default: 0.6.
- heightfloat
Vertical extent of the scan area [m]. Default: 0.6.
- dxfloat
Horizontal offset of the scan area center from the polargraph centerline [m]. Default: 0.
- dyfloat
Vertical offset of the scan area top edge below the home position [m]. Default: 0.1.
- stepfloat
Spacing between scan lines [mm]. Default: 5.
Signals#
- dataReady(numpy.ndarray)
Emitted with
(x, y, t)— Cartesian position [m] and atime.monotonic()timestamp [s] — at every position poll during motion (MOVING and SCANNING states).tallows post-processing correlation with independently sampled instruments. Connect to belt animation and, gated onscanning(), to instrument data collection. (Callers that only needx, ymay ignoredata[2].)- stateChanged(ScanState)
Emitted on every state-machine transition. Subsumes the former
moveFinishedandscanFinishedsignals.- closeRequested()
Emitted when the state returns to IDLE after
interruptAndClose()was called. Connect to the application window’sclose()slot to shut down cleanly after all motion stops.
- dataReady#
- stateChanged#
- closeRequested#
- vertices()[source]#
Vertices of the scan trajectory.
- Return type:
- Returns:
numpy.ndarray –
(nvertices, 2)array of(x, y)waypoints [m].
- trajectory()[source]#
Coordinates along the scan path for display.
- Return type:
- Returns:
numpy.ndarray –
(2, npts)array of(x, y)coordinates [m].
- scan()[source]#
Execute a full scan, then return home.
State transitions during a normal scan:
IDLE → MOVING(positioning to start)→ SCANNING(collecting data)→ MOVING(returning home)→ IDLEThe scan may be paused at any point via
pause()and resumed viaresume(). Callinghome(),center(), orabandon()while paused discards the saved trajectory.- Return type:
- pause()[source]#
Pause motion at the end of the current move.
The polargraph stops at its current target vertex and holds position. Call
resume()to continue orabandon()to discard the remaining trajectory.- Return type:
- resume()[source]#
Resume a paused trajectory.
Re-issues the last target vertex and continues with the remaining waypoints.
- Return type:
- toggle()[source]#
Start, pause, or resume based on current state.
Calling this slot from any thread is safe: it is the preferred way for the GUI to drive the scan state machine. Connects to the Scan/Pause/Resume button.
- Return type:
- abandon()[source]#
Abandon the current trajectory and return to IDLE.
If the scanner is moving, the motors are stopped immediately. If paused, the saved trajectory is discarded. The polargraph remains at its current position; call
home()to return to the home position.- Return type:
- interruptAndClose()[source]#
Abandon motion and emit
closeRequestedon reaching IDLE.Used by the application window’s
closeEventto ensure the polargraph stops cleanly before the application exits.- Return type: