API Reference v9.2.0

Deviceclass

Module: ZaberMotionAscii

Represents the controller part of one device - may be either a standalone controller or an integrated controller.

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

import ZaberMotionAscii

let connection = try await Connection.openSerialPort(portName: "COM3")
let device = try connection.getDevice(deviceAddress: 1)

Properties

p

allAxes

readonly
device.allAxes
AllAxes Virtual axis which allows you to target all axes of this device.
p

axisCount

readonlythrows
try device.axisCount
Int Number of axes this device has.
p

connection

readonly
device.connection
Connection Connection of this device.
p

deviceAddress

readonly
device.deviceAddress
Int The device address uniquely identifies the device on the connection. It can be configured or automatically assigned by the renumber command.
p

deviceId

readonlythrows
try device.deviceId
Int Unique ID of the device hardware.
p

firmwareVersion

readonlythrows
try device.firmwareVersion
FirmwareVersion Version of the firmware.
p

identity

readonlythrows
try device.identity
DeviceIdentity Identity of the device.
p

io

readonly
device.io
DeviceIO I/O channels of this device.
p

isIdentified

readonlythrows
try device.isIdentified
Bool Indicates whether or not the device has been identified.
p

isIntegrated

readonlythrows
try device.isIntegrated
Bool The device is an integrated product.
p

label

readonlythrows
try device.label
String User-assigned label of the device.
p

name

readonlythrows
try device.name
String Name of the product.
p

oscilloscope

readonly
device.oscilloscope
Oscilloscope Oscilloscope recording helper for this device. Requires at least Firmware 7.00.
p

pvt

readonly
device.pvt
Pvt Gets an object that provides access to PVT functions of this device. Note that as of ZML v5.0.0, this returns a Pvt object and NOT a PvtSequence object. The PvtSequence can now be obtained from the Pvt object. Requires at least Firmware 7.33.
p

serialNumber

readonlythrows
try device.serialNumber
UInt Serial number of the device.
p

settings

readonly
device.settings
DeviceSettings Settings and properties of this device.
p

storage

readonly
device.storage
DeviceStorage Key-value storage of this device.
p

streams

readonly
device.streams
Streams Gets an object that provides access to Streams on this device. Requires at least Firmware 7.05.
p

triggers

readonly
device.triggers
Triggers Triggers for this device. Requires at least Firmware 7.06.
p

warnings

readonly
device.warnings
Warnings Warnings and faults of this device and all its axes.

Methods

m

genericCommand()

asyncthrows
try await device.genericCommand(command, axis = 0, checkErrors = true, timeout = 0)
Sends a generic ASCII command to this device. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandStringCommand and its parameters.
axisIntOptional axis number to send the command to.
checkErrorsBoolControls whether to throw an exception when the device rejects the command.
timeoutIntThe timeout, in milliseconds, for a device to respond to the command. Overrides the connection default request timeout.
Return Value
Response A response to the command.
m

genericCommandMultiResponse()

asyncthrows
try await device.genericCommandMultiResponse(command, axis = 0, checkErrors = true, timeout = 0)
Sends a generic ASCII command to this device and expect multiple responses. Responses are returned in order of arrival. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandStringCommand and its parameters.
axisIntOptional axis number to send the command to.
checkErrorsBoolControls whether to throw an exception when a device rejects the command.
timeoutIntThe timeout, in milliseconds, for a device to respond to the command. Overrides the connection default request timeout.
Return Value
[Response] All responses to the command.
m

genericCommandNoResponse()

asyncthrows
try await device.genericCommandNoResponse(command, axis = 0)
Sends a generic ASCII command to this device without expecting a response and without adding a message ID For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandStringCommand and its parameters.
axisIntOptional axis number to send the command to. Specifying -1 omits the number completely.
m

getAxis()

throws
try device.getAxis(axisNumber)
Gets an Axis class instance which allows you to control a particular axis on this device. Axes are numbered from 1.
Arguments
NameTypeDescription
axisNumberIntNumber of axis intended to control.
Return Value
Axis Axis instance.
m

getCommandUnitConversionDescriptors()

throws
try device.getCommandUnitConversionDescriptors(commandTemplate)
Retrieves unit conversion descriptors for a command, allowing unit conversion without a device. The descriptors can be used with the ConvertTo/FromNativeUnits methods of the UnitTable class. Parameters in the command template are denoted by a question mark. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandTemplateStringTemplate of the command. Parameters are denoted by question marks.
Return Value
[UnitConversionDescriptor?] Unit conversion descriptor for each parameter in the command. Nil if a parameter does not have conversion.
m

getLockstep()

throws
try device.getLockstep(lockstepGroupId)
Gets a Lockstep class instance which allows you to control a particular lockstep group on the device. Requires at least Firmware 6.15 or 7.11.
Arguments
NameTypeDescription
lockstepGroupIdIntThe ID of the lockstep group to control. Lockstep group IDs start at one.
Return Value
Lockstep Lockstep instance.
m

getState()

asyncthrows
try await device.getState()
Returns a serialization of the current device state that can be saved and reapplied.
Return Value
String A serialization of the current state of the device.
m

identify()

asyncthrows
try await device.identify(assumeVersion = nil)
Queries the device and the database, gathering information about the product. Without this information features such as unit conversions will not work. Usually, called automatically by detect devices method.
Arguments
NameTypeDescription
assumeVersionFirmwareVersion?The identification assumes the specified firmware version instead of the version queried from the device. Providing this argument can lead to unexpected compatibility issues.
Return Value
DeviceIdentity Device identification data.
m

prepareCommand()

throws
try device.prepareCommand(commandTemplate, ...parameters)
Formats parameters into a command and performs unit conversions. Parameters in the command template are denoted by a question mark. Command returned is only valid for this device. Unit conversion is not supported for commands where axes can be remapped, such as stream and PVT commands. For more information refer to: ASCII Protocol Manual.
Arguments
NameTypeDescription
commandTemplateStringTemplate of a command to prepare. Parameters are denoted by question marks.
...parameters[Measurement]Variable number of command parameters.
Return Value
String Command with converted parameters.
m

renumber()

asyncthrows
try await device.renumber(address)
Changes the address of this device. After the address is successfully changed, the existing device class instance no longer represents the device. Instead, use the new device instance returned by this method.
Arguments
NameTypeDescription
addressIntThe new address to assign to the device.
Return Value
Device New device instance with the new address.
m

restore()

asyncthrows
try await device.restore(hard = false)
Restores most of the settings to their default values. Deletes all triggers, stream and PVT buffers, servo tunings. Deletes all zaber storage keys. Disables locksteps, unparks axes. Preserves storage, communication settings, peripherals (unless hard is specified). The device needs to be identified again after the restore.
Arguments
NameTypeDescription
hardBoolIf true, completely erases device's memory. The device also resets.
m

setLabel()

asyncthrows
try await device.setLabel(label)
Sets the user-assigned device label. The label is stored on the controller and recognized by other software.
Arguments
NameTypeDescription
labelStringLabel to set.
m

setState()

asyncthrows
try await device.setState(state, deviceOnly = false)
Applies a saved state to this device.
Arguments
NameTypeDescription
stateStringThe state object to apply to this device.
deviceOnlyBoolIf true, only device scope settings and features will be set.
Return Value
SetStateDeviceResponse Reports of any issues that were handled, but caused the state to not be exactly restored.
m

toString()

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