API Reference v9.2.0

Autofocusclass

Module: ZaberMotionMicroscopy

A generic autofocus device.

The following example illustrates how you can obtain an instance of this type:

import ZaberMotionAscii
import ZaberMotionMicroscopy

let connection = try await Connection.openSerialPort(portName: "COM3")
let microscope = try await Microscope.find(connection: connection)
let autofocus = microscope.autofocus
Related Guides:

Constructor

Autofocus(providerId, focusAxis, objectiveTurret)
Creates instance of `Autofocus` based on the given provider id.
Arguments
NameTypeDescription
providerIdIntThe identification of external device providing the capability.
focusAxisAxisThe focus axis.
objectiveTurretDevice?The objective turret device if the microscope has one.

Properties

p

focusAxis

readonly
autofocus.focusAxis
Axis The focus axis.
p

objectiveTurret

readonlyoptional
autofocus.objectiveTurret
Device? The objective turret device if the microscope has one.
p

providerId

readonly
autofocus.providerId
Int The identification of external device providing the capability.

Methods

m

focusOnce()

asyncthrows
try await autofocus.focusOnce(scan = false, timeout = -1)
Moves the device until it's in focus.
Arguments
NameTypeDescription
scanBoolIf true, the autofocus will approach from the limit moving until it's in range.
timeoutIntSets autofocus timeout duration in milliseconds.
m

getLimitMax()

asyncthrows
try await autofocus.getLimitMax(unit = Units.native)
Gets the upper motion limit for the autofocus control loop. Gets motion.tracking.limit.max setting of the focus axis.
Arguments
NameTypeDescription
unitUnitsThe units of the limit.
Return Value
Double Limit value.
m

getLimitMin()

asyncthrows
try await autofocus.getLimitMin(unit = Units.native)
Gets the lower motion limit for the autofocus control loop. Gets motion.tracking.limit.min setting of the focus axis.
Arguments
NameTypeDescription
unitUnitsThe units of the limit.
Return Value
Double Limit value.
m

getObjectiveParameters()

asyncthrows
try await autofocus.getObjectiveParameters(objective)
Returns the parameters for the autofocus objective.
Arguments
NameTypeDescription
objectiveIntThe objective (numbered from 1) to get the parameters for. If your microscope has only one objective, use value of 1. Note that the method temporarily switches current objective to get the parameters.
Return Value
[NamedParameter] The parameters for the autofocus objective.
m

getStatus()

asyncthrows
try await autofocus.getStatus()
Returns the status of the autofocus.
Return Value
AutofocusStatus The status of the autofocus.
m

isBusy()

asyncthrows
try await autofocus.isBusy()
Returns bool indicating whether the focus axis is busy. Can be used to determine if the focus loop is running.
Return Value
Bool True if the axis is currently executing a motion command.
m

setFocusZero()

asyncthrows
try await autofocus.setFocusZero()
Sets the current focus to be target for the autofocus control loop.
m

setLimitMax()

asyncthrows
try await autofocus.setLimitMax(limit, unit = Units.native)
Sets the upper motion limit for the autofocus control loop. Use the limits to prevent the focus axis from crashing into the sample. Changes motion.tracking.limit.max setting of the focus axis.
Arguments
NameTypeDescription
limitDoubleThe upper limit of the focus axis.
unitUnitsThe units of the limit.
m

setLimitMin()

asyncthrows
try await autofocus.setLimitMin(limit, unit = Units.native)
Sets the lower motion limit for the autofocus control loop. Use the limits to prevent the focus axis from crashing into the sample. Changes motion.tracking.limit.min setting of the focus axis.
Arguments
NameTypeDescription
limitDoubleThe lower limit of the focus axis.
unitUnitsThe units of the limit.
m

setObjectiveParameters()

asyncthrows
try await autofocus.setObjectiveParameters(objective, parameters)
Sets the parameters for the autofocus objective. Note that the method temporarily switches current objective to set the parameters.
Arguments
NameTypeDescription
objectiveIntThe objective (numbered from 1) to set the parameters for. If your microscope has only one objective, use value of 1.
parameters[NamedParameter]The parameters for the autofocus objective.
m

startFocusLoop()

asyncthrows
try await autofocus.startFocusLoop()
Moves the focus axis continuously maintaining focus. Starts the autofocus control loop. Note that the control loop may stop if the autofocus comes out of range or a movement error occurs. Use WaitUntilIdle of the focus axis to wait for the loop to stop and handle potential errors.
m

stopFocusLoop()

asyncthrows
try await autofocus.stopFocusLoop()
Stops autofocus control loop. If the focus axis already stopped moving because of an error, an exception will be thrown.
m

synchronizeParameters()

asyncthrows
try await autofocus.synchronizeParameters()
Typically, the control loop parameters and objective are kept synchronized by the library. If the parameters or current objective changes outside of the library, call this method to synchronize them.
m

toString()

throws
try autofocus.toString()
Returns a string that represents the autofocus.
Return Value
String A string that represents the autofocus.