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:
Index
pProperties
Properties
p
p
Methods
m
m
try offlineTranslator.getAxisCoordinateSystemOffset(coordinateSystem, axis, unit)Gets offset of an axis in a given coordinate system.
Arguments
| Name | Type | Description |
|---|---|---|
| coordinateSystem | String | Coordinate system (e.g. G54). |
| axis | String | Letter of the axis. |
| unit | Units | Units of position. |
Return Value
Double Offset in translator units of the axis.m
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
| Name | Type | Description |
|---|---|---|
| axis | String | Letter of the axis. |
| unit | Units | Units of position. |
Return Value
Double Position of translator's axis.m
m
try offlineTranslator.setAxisHomePosition(axis, position, unit)Sets the home position of translator's axis. This position is used by G28.
Arguments
| Name | Type | Description |
|---|---|---|
| axis | String | Letter of the axis. |
| position | Double | The home position. |
| unit | Units | Units of position. |
m
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
| Name | Type | Description |
|---|---|---|
| axis | String | Letter of the axis. |
| position | Double | The position. |
| unit | Units | Units of position. |
m
try offlineTranslator.setAxisSecondaryHomePosition(axis, position, unit)Sets the secondary home position of translator's axis. This position is used by G30.
Arguments
| Name | Type | Description |
|---|---|---|
| axis | String | Letter of the axis. |
| position | Double | The home position. |
| unit | Units | Units of position. |
m
m
try offlineTranslator.setTraverseRate(traverseRate, unit)Sets the speed at which the device moves when traversing (G0).
Arguments
| Name | Type | Description |
|---|---|---|
| traverseRate | Double | The traverse rate. |
| unit | Units | Units of the traverse rate. |
s
try await OfflineTranslator.setup(definition, config = nil)Sets up translator from provided device definition and configuration.
Arguments
| Name | Type | Description |
|---|---|---|
| definition | DeviceDefinition | Definition of device and its peripherals. The definition must match a device that later performs the commands. |
| config | TranslatorConfig? | Configuration of the translator. |
Return Value
OfflineTranslator New instance of translator.s
try await OfflineTranslator.setupFromDevice(device, axes, config = nil)Sets up an offline translator from provided device, axes, and configuration.
Arguments
| Name | Type | Description |
|---|---|---|
| device | Device | Device 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. |
| config | TranslatorConfig? | Configuration of the translator. |
Return Value
OfflineTranslator New instance of translator.m
try offlineTranslator.translate(block)Translates a single block (line) of G-code.
Arguments
| Name | Type | Description |
|---|---|---|
| block | String | Block (line) of G-code. |
Return Value
TranslateResult Result of translation containing the stream commands.