API Reference v9.2.0

OfflineTranslatorclass

Module: ZaberMotionGcode

Represents an offline G-Code translator. It allows to translate G-Code blocks to Zaber ASCII protocol stream commands. This translator does not need a connected device to perform translation. Requires at least Firmware 7.11.

The following examples illustrate how you can obtain an instance of this type:

Example 1
Example 2
import ZaberMotionAscii
import ZaberMotionGcode

let connection = try await Connection.openSerialPort(portName: "COM3")
let device = try connection.getDevice(deviceAddress: 1)
let offlineTranslator = try await OfflineTranslator.setupFromDevice(device: device, axes: [1, 2])
import ZaberMotionGcode

let offlineTranslator = try await OfflineTranslator.setup(definition: ...)
Related Guides:

Properties

p

coordinateSystem

readonlythrows
try offlineTranslator.coordinateSystem
String Current coordinate system.
p

translatorId

readonly
offlineTranslator.translatorId
Int The ID of the translator that serves to identify native resources.

Methods

m

flush()

throws
try offlineTranslator.flush()
Flushes the remaining stream commands waiting in optimization buffer. The flush is also performed by M2 and M30 codes.
Return Value
[String] The remaining stream commands.
m

getAxisCoordinateSystemOffset()

throws
try offlineTranslator.getAxisCoordinateSystemOffset(coordinateSystem, axis, unit)
Gets offset of an axis in a given coordinate system.
Arguments
NameTypeDescription
coordinateSystemStringCoordinate system (e.g. G54).
axisStringLetter of the axis.
unitUnitsUnits of position.
Return Value
Double Offset in translator units of the axis.
m

getAxisPosition()

throws
try offlineTranslator.getAxisPosition(axis, unit)
Gets position of translator's axis. This method does not query device but returns value from translator's state.
Arguments
NameTypeDescription
axisStringLetter of the axis.
unitUnitsUnits of position.
Return Value
Double Position of translator's axis.
m

resetAfterStreamError()

throws
try offlineTranslator.resetAfterStreamError()
Resets internal state after device rejected generated command. Axis positions become uninitialized.
m

setAxisHomePosition()

throws
try offlineTranslator.setAxisHomePosition(axis, position, unit)
Sets the home position of translator's axis. This position is used by G28.
Arguments
NameTypeDescription
axisStringLetter of the axis.
positionDoubleThe home position.
unitUnitsUnits of position.
m

setAxisPosition()

throws
try offlineTranslator.setAxisPosition(axis, position, unit)
Sets position of translator's axis. Use this method to set position after performing movement outside of the translator. This method does not cause any movement.
Arguments
NameTypeDescription
axisStringLetter of the axis.
positionDoubleThe position.
unitUnitsUnits of position.
m

setAxisSecondaryHomePosition()

throws
try offlineTranslator.setAxisSecondaryHomePosition(axis, position, unit)
Sets the secondary home position of translator's axis. This position is used by G30.
Arguments
NameTypeDescription
axisStringLetter of the axis.
positionDoubleThe home position.
unitUnitsUnits of position.
m

setFeedRateOverride()

throws
try offlineTranslator.setFeedRateOverride(coefficient)
Allows to scale feed rate of the translated code by a coefficient.
Arguments
NameTypeDescription
coefficientDoubleCoefficient of the original feed rate.
m

setTraverseRate()

throws
try offlineTranslator.setTraverseRate(traverseRate, unit)
Sets the speed at which the device moves when traversing (G0).
Arguments
NameTypeDescription
traverseRateDoubleThe traverse rate.
unitUnitsUnits of the traverse rate.
s

setup()

asyncthrows
try await OfflineTranslator.setup(definition, config = nil)
Sets up translator from provided device definition and configuration.
Arguments
NameTypeDescription
definitionDeviceDefinitionDefinition of device and its peripherals. The definition must match a device that later performs the commands.
configTranslatorConfig?Configuration of the translator.
Return Value
OfflineTranslator New instance of translator.
s

setupFromDevice()

asyncthrows
try await OfflineTranslator.setupFromDevice(device, axes, config = nil)
Sets up an offline translator from provided device, axes, and configuration.
Arguments
NameTypeDescription
deviceDeviceDevice that later performs the command streaming.
axes[Int]Axis numbers that are later used to setup the stream. For a lockstep group specify only the first axis of the group.
configTranslatorConfig?Configuration of the translator.
Return Value
OfflineTranslator New instance of translator.
m

translate()

throws
try offlineTranslator.translate(block)
Translates a single block (line) of G-code.
Arguments
NameTypeDescription
blockStringBlock (line) of G-code.
Return Value
TranslateResult Result of translation containing the stream commands.