API Reference v9.2.0
Translatorclass
Module: ZaberMotionGcode
Represents a live G-Code translator. It allows to stream G-Code blocks to a connected device. It requires a stream to be setup on the device.
Requires at least Firmware 7.11.
The following example illustrates how you can obtain an instance of this type:
import ZaberMotionAscii
import ZaberMotionGcode
let connection = try await Connection.openSerialPort(portName: "COM3")
let device = try connection.getDevice(deviceAddress: 1)
let streams = device.streams
let stream = try streams.getStream(streamId: 1)
let translator = try await Translator.setup(stream: stream)Related Guides:
Index
pProperties
Properties
p
Methods
m
try await translator.flush(waitUntilIdle = true)Flushes the remaining stream commands waiting in optimization buffer into the underlying stream. The flush is also performed by M2 and M30 codes.
Arguments
| Name | Type | Description |
|---|---|---|
| waitUntilIdle | Bool | Determines whether to wait for the stream to finish all the movements. |
Return Value
[String] The remaining stream commands.m
try translator.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 translator.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
m
try translator.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 translator.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 translator.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 translator.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 Translator.setup(stream, config = nil)Sets up the translator on top of a provided stream.
Arguments
| Name | Type | Description |
|---|---|---|
| stream | Stream | The stream to setup the translator on. The stream must be already setup in a live or a store mode. |
| config | TranslatorConfig? | Configuration of the translator. |
Return Value
Translator New instance of translator.m
try await translator.translate(block)Translates a single block (line) of G-code. The commands are queued in the underlying stream to ensure smooth continues movement. Returning of this method indicates that the commands are queued (not necessarily executed).
Arguments
| Name | Type | Description |
|---|---|---|
| block | String | Block (line) of G-code. |
Return Value
TranslateResult Result of translation containing the commands sent to the device.