@zaber/motion 3.2.1 → 3.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/binding/wasm/zaber-motion-lib.wasm +0 -0
- package/dist/lib/ascii/device.d.ts +28 -1
- package/dist/lib/ascii/device.js +45 -2
- package/dist/lib/ascii/device.js.map +1 -1
- package/dist/lib/ascii/index.d.ts +5 -0
- package/dist/lib/ascii/index.js +11 -1
- package/dist/lib/ascii/index.js.map +1 -1
- package/dist/lib/ascii/lockstep.d.ts +22 -0
- package/dist/lib/ascii/lockstep.js +43 -6
- package/dist/lib/ascii/lockstep.js.map +1 -1
- package/dist/lib/ascii/pvt_axis_definition.d.ts +17 -0
- package/dist/lib/ascii/pvt_axis_definition.js +53 -0
- package/dist/lib/ascii/pvt_axis_definition.js.map +1 -0
- package/dist/lib/ascii/pvt_axis_type.d.ts +7 -0
- package/dist/lib/ascii/pvt_axis_type.js +14 -0
- package/dist/lib/ascii/pvt_axis_type.js.map +1 -0
- package/dist/lib/ascii/pvt_buffer.d.ts +28 -0
- package/dist/lib/ascii/pvt_buffer.js +78 -0
- package/dist/lib/ascii/pvt_buffer.js.map +1 -0
- package/dist/lib/ascii/pvt_mode.d.ts +8 -0
- package/dist/lib/ascii/pvt_mode.js +15 -0
- package/dist/lib/ascii/pvt_mode.js.map +1 -0
- package/dist/lib/ascii/pvt_sequence.d.ts +178 -0
- package/dist/lib/ascii/pvt_sequence.js +407 -0
- package/dist/lib/ascii/pvt_sequence.js.map +1 -0
- package/dist/lib/ascii/stream.d.ts +13 -5
- package/dist/lib/ascii/stream.js +25 -5
- package/dist/lib/ascii/stream.js.map +1 -1
- package/dist/lib/ascii/stream_buffer.d.ts +1 -1
- package/dist/lib/ascii/stream_buffer.js +1 -1
- package/dist/lib/ascii/stream_buffer.js.map +1 -1
- package/dist/lib/ascii/warnings.d.ts +9 -0
- package/dist/lib/ascii/warnings.js +17 -0
- package/dist/lib/ascii/warnings.js.map +1 -1
- package/dist/lib/ascii_ns.d.ts +10 -0
- package/dist/lib/ascii_ns.js +5 -0
- package/dist/lib/ascii_ns.js.map +1 -1
- package/dist/lib/exceptions/index.d.ts +12 -0
- package/dist/lib/exceptions/index.js +26 -2
- package/dist/lib/exceptions/index.js.map +1 -1
- package/dist/lib/exceptions/invalid_pvt_point.d.ts +16 -0
- package/dist/lib/exceptions/invalid_pvt_point.js +18 -0
- package/dist/lib/exceptions/invalid_pvt_point.js.map +1 -0
- package/dist/lib/exceptions/pvt_discontinuity_exception.d.ts +7 -0
- package/dist/lib/exceptions/pvt_discontinuity_exception.js +17 -0
- package/dist/lib/exceptions/pvt_discontinuity_exception.js.map +1 -0
- package/dist/lib/exceptions/pvt_execution_exception.d.ts +14 -0
- package/dist/lib/exceptions/pvt_execution_exception.js +32 -0
- package/dist/lib/exceptions/pvt_execution_exception.js.map +1 -0
- package/dist/lib/exceptions/pvt_execution_exception_data.d.ts +21 -0
- package/dist/lib/exceptions/pvt_execution_exception_data.js +20 -0
- package/dist/lib/exceptions/pvt_execution_exception_data.js.map +1 -0
- package/dist/lib/exceptions/pvt_mode_exception.d.ts +7 -0
- package/dist/lib/exceptions/pvt_mode_exception.js +17 -0
- package/dist/lib/exceptions/pvt_mode_exception.js.map +1 -0
- package/dist/lib/exceptions/pvt_movement_failed_exception.d.ts +14 -0
- package/dist/lib/exceptions/pvt_movement_failed_exception.js +32 -0
- package/dist/lib/exceptions/pvt_movement_failed_exception.js.map +1 -0
- package/dist/lib/exceptions/pvt_movement_failed_exception_data.d.ts +16 -0
- package/dist/lib/exceptions/pvt_movement_failed_exception_data.js +18 -0
- package/dist/lib/exceptions/pvt_movement_failed_exception_data.js.map +1 -0
- package/dist/lib/exceptions/pvt_movement_interrupted_exception.d.ts +14 -0
- package/dist/lib/exceptions/pvt_movement_interrupted_exception.js +32 -0
- package/dist/lib/exceptions/pvt_movement_interrupted_exception.js.map +1 -0
- package/dist/lib/exceptions/pvt_movement_interrupted_exception_data.d.ts +16 -0
- package/dist/lib/exceptions/pvt_movement_interrupted_exception_data.js +18 -0
- package/dist/lib/exceptions/pvt_movement_interrupted_exception_data.js.map +1 -0
- package/dist/lib/exceptions/pvt_setup_failed_exception.d.ts +7 -0
- package/dist/lib/exceptions/pvt_setup_failed_exception.js +17 -0
- package/dist/lib/exceptions/pvt_setup_failed_exception.js.map +1 -0
- package/dist/lib/exceptions/stream_discontinuity_exception.d.ts +7 -0
- package/dist/lib/exceptions/stream_discontinuity_exception.js +17 -0
- package/dist/lib/exceptions/stream_discontinuity_exception.js.map +1 -0
- package/dist/lib/exceptions/timeout_exception.d.ts +7 -0
- package/dist/lib/exceptions/timeout_exception.js +17 -0
- package/dist/lib/exceptions/timeout_exception.js.map +1 -0
- package/dist/lib/firmware_version.js +36 -0
- package/dist/lib/firmware_version.js.map +1 -1
- package/dist/lib/gateway/convert_exceptions.js +8 -0
- package/dist/lib/gateway/convert_exceptions.js.map +1 -1
- package/dist/lib/gcode/offline_translator.d.ts +2 -2
- package/dist/lib/gcode/offline_translator.js +2 -2
- package/dist/lib/gcode/offline_translator.js.map +1 -1
- package/dist/lib/gcode/translator.d.ts +1 -1
- package/dist/lib/gcode/translator.js +1 -1
- package/dist/lib/gcode/translator.js.map +1 -1
- package/dist/lib/protobufs/main_pb.d.ts +445 -58
- package/dist/lib/protobufs/main_pb.js +4369 -1463
- package/dist/lib/protobufs/main_pb.js.map +1 -1
- package/package.json +33 -3
|
@@ -62,16 +62,24 @@ errorMapping.set(main_pb_1.Errors.NO_VALUE_FOR_KEY, exceptions.NoValueForKeyExce
|
|
|
62
62
|
errorMapping.set(main_pb_1.Errors.NOT_SUPPORTED, exceptions.NotSupportedException);
|
|
63
63
|
errorMapping.set(main_pb_1.Errors.OS_FAILED, exceptions.OsFailedException);
|
|
64
64
|
errorMapping.set(main_pb_1.Errors.OUT_OF_REQUEST_IDS, exceptions.OutOfRequestIdsException);
|
|
65
|
+
errorMapping.set(main_pb_1.Errors.PVT_DISCONTINUITY, exceptions.PvtDiscontinuityException);
|
|
66
|
+
errorMapping.set(main_pb_1.Errors.PVT_EXECUTION, exceptions.PvtExecutionException);
|
|
67
|
+
errorMapping.set(main_pb_1.Errors.PVT_MODE, exceptions.PvtModeException);
|
|
68
|
+
errorMapping.set(main_pb_1.Errors.PVT_MOVEMENT_FAILED, exceptions.PvtMovementFailedException);
|
|
69
|
+
errorMapping.set(main_pb_1.Errors.PVT_MOVEMENT_INTERRUPTED, exceptions.PvtMovementInterruptedException);
|
|
70
|
+
errorMapping.set(main_pb_1.Errors.PVT_SETUP_FAILED, exceptions.PvtSetupFailedException);
|
|
65
71
|
errorMapping.set(main_pb_1.Errors.REQUEST_TIMEOUT, exceptions.RequestTimeoutException);
|
|
66
72
|
errorMapping.set(main_pb_1.Errors.SERIAL_PORT_BUSY, exceptions.SerialPortBusyException);
|
|
67
73
|
errorMapping.set(main_pb_1.Errors.SET_DEVICE_STATE_FAILED, exceptions.SetDeviceStateFailedException);
|
|
68
74
|
errorMapping.set(main_pb_1.Errors.SET_PERIPHERAL_STATE_FAILED, exceptions.SetPeripheralStateFailedException);
|
|
69
75
|
errorMapping.set(main_pb_1.Errors.SETTING_NOT_FOUND, exceptions.SettingNotFoundException);
|
|
76
|
+
errorMapping.set(main_pb_1.Errors.STREAM_DISCONTINUITY, exceptions.StreamDiscontinuityException);
|
|
70
77
|
errorMapping.set(main_pb_1.Errors.STREAM_EXECUTION, exceptions.StreamExecutionException);
|
|
71
78
|
errorMapping.set(main_pb_1.Errors.STREAM_MODE, exceptions.StreamModeException);
|
|
72
79
|
errorMapping.set(main_pb_1.Errors.STREAM_MOVEMENT_FAILED, exceptions.StreamMovementFailedException);
|
|
73
80
|
errorMapping.set(main_pb_1.Errors.STREAM_MOVEMENT_INTERRUPTED, exceptions.StreamMovementInterruptedException);
|
|
74
81
|
errorMapping.set(main_pb_1.Errors.STREAM_SETUP_FAILED, exceptions.StreamSetupFailedException);
|
|
82
|
+
errorMapping.set(main_pb_1.Errors.TIMEOUT, exceptions.TimeoutException);
|
|
75
83
|
errorMapping.set(main_pb_1.Errors.TRANSPORT_ALREADY_USED, exceptions.TransportAlreadyUsedException);
|
|
76
84
|
errorMapping.set(main_pb_1.Errors.UNKNOWN_REQUEST, exceptions.UnknownRequestException);
|
|
77
85
|
function convertToException(error, message, customData) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert_exceptions.js","sourceRoot":"","sources":["../../../src/gateway/convert_exceptions.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,kDAA0D;AAC1D,0DAA4C;AAE5C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwF,CAAC;AACrH,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC,4BAA4B,CAAC,CAAC;AAC1F,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAC7E,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACnF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,gBAAgB,EAAE,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAChF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACnF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACnF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACnF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,uBAAuB,EAAE,UAAU,CAAC,8BAA8B,CAAC,CAAC;AAC9F,YAAY,CAAC,GAAG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S GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { Errors as PbErrors } from '../protobufs/main_pb';\nimport * as exceptions from '../exceptions';\n\nconst errorMapping = new Map<PbErrors, new (message: string, customData: Buffer) => exceptions.MotionLibException>();\nerrorMapping.set(PbErrors.BINARY_COMMAND_FAILED, exceptions.BinaryCommandFailedException);\nerrorMapping.set(PbErrors.COMMAND_FAILED, exceptions.CommandFailedException);\nerrorMapping.set(PbErrors.COMMAND_PREEMPTED, exceptions.CommandPreemptedException);\nerrorMapping.set(PbErrors.COMMAND_TOO_LONG, exceptions.CommandTooLongException);\nerrorMapping.set(PbErrors.CONNECTION_CLOSED, exceptions.ConnectionClosedException);\nerrorMapping.set(PbErrors.CONNECTION_FAILED, exceptions.ConnectionFailedException);\nerrorMapping.set(PbErrors.CONVERSION_FAILED, exceptions.ConversionFailedException);\nerrorMapping.set(PbErrors.DEVICE_ADDRESS_CONFLICT, exceptions.DeviceAddressConflictException);\nerrorMapping.set(PbErrors.DEVICE_BUSY, exceptions.DeviceBusyException);\nerrorMapping.set(PbErrors.DEVICE_DB_FAILED, exceptions.DeviceDbFailedException);\nerrorMapping.set(PbErrors.DEVICE_DETECTION_FAILED, exceptions.DeviceDetectionFailedException);\nerrorMapping.set(PbErrors.DEVICE_FAILED, exceptions.DeviceFailedException);\nerrorMapping.set(PbErrors.DEVICE_NOT_IDENTIFIED, exceptions.DeviceNotIdentifiedException);\nerrorMapping.set(PbErrors.G_CODE_EXECUTION, exceptions.GCodeExecutionException);\nerrorMapping.set(PbErrors.G_CODE_SYNTAX, exceptions.GCodeSyntaxException);\nerrorMapping.set(PbErrors.INTERNAL_ERROR, exceptions.InternalErrorException);\nerrorMapping.set(PbErrors.INVALID_ARGUMENT, exceptions.InvalidArgumentException);\nerrorMapping.set(PbErrors.INVALID_DATA, exceptions.InvalidDataException);\nerrorMapping.set(PbErrors.INVALID_OPERATION, exceptions.InvalidOperationException);\nerrorMapping.set(PbErrors.INVALID_PACKET, exceptions.InvalidPacketException);\nerrorMapping.set(PbErrors.INVALID_PARK_STATE, exceptions.InvalidParkStateException);\nerrorMapping.set(PbErrors.INVALID_RESPONSE, exceptions.InvalidResponseException);\nerrorMapping.set(PbErrors.IO_CHANNEL_OUT_OF_RANGE, exceptions.IoChannelOutOfRangeException);\nerrorMapping.set(PbErrors.IO_FAILED, exceptions.IoFailedException);\nerrorMapping.set(PbErrors.LOCKSTEP_ENABLED, exceptions.LockstepEnabledException);\nerrorMapping.set(PbErrors.LOCKSTEP_NOT_ENABLED, exceptions.LockstepNotEnabledException);\nerrorMapping.set(PbErrors.MOVEMENT_FAILED, exceptions.MovementFailedException);\nerrorMapping.set(PbErrors.MOVEMENT_INTERRUPTED, exceptions.MovementInterruptedException);\nerrorMapping.set(PbErrors.NO_DEVICE_FOUND, exceptions.NoDeviceFoundException);\nerrorMapping.set(PbErrors.NO_VALUE_FOR_KEY, exceptions.NoValueForKeyException);\nerrorMapping.set(PbErrors.NOT_SUPPORTED, exceptions.NotSupportedException);\nerrorMapping.set(PbErrors.OS_FAILED, exceptions.OsFailedException);\nerrorMapping.set(PbErrors.OUT_OF_REQUEST_IDS, exceptions.OutOfRequestIdsException);\nerrorMapping.set(PbErrors.REQUEST_TIMEOUT, exceptions.RequestTimeoutException);\nerrorMapping.set(PbErrors.SERIAL_PORT_BUSY, exceptions.SerialPortBusyException);\nerrorMapping.set(PbErrors.SET_DEVICE_STATE_FAILED, exceptions.SetDeviceStateFailedException);\nerrorMapping.set(PbErrors.SET_PERIPHERAL_STATE_FAILED, exceptions.SetPeripheralStateFailedException);\nerrorMapping.set(PbErrors.SETTING_NOT_FOUND, exceptions.SettingNotFoundException);\nerrorMapping.set(PbErrors.STREAM_EXECUTION, exceptions.StreamExecutionException);\nerrorMapping.set(PbErrors.STREAM_MODE, exceptions.StreamModeException);\nerrorMapping.set(PbErrors.STREAM_MOVEMENT_FAILED, exceptions.StreamMovementFailedException);\nerrorMapping.set(PbErrors.STREAM_MOVEMENT_INTERRUPTED, exceptions.StreamMovementInterruptedException);\nerrorMapping.set(PbErrors.STREAM_SETUP_FAILED, exceptions.StreamSetupFailedException);\nerrorMapping.set(PbErrors.TRANSPORT_ALREADY_USED, exceptions.TransportAlreadyUsedException);\nerrorMapping.set(PbErrors.UNKNOWN_REQUEST, exceptions.UnknownRequestException);\n\nexport function convertToException(error: PbErrors, message: string, customData?: Buffer): exceptions.MotionLibException {\n const SpecificException = errorMapping.get(error);\n\n /* istanbul ignore if */\n if (!SpecificException) {\n return new exceptions.MotionLibException(message);\n }\n\n return new SpecificException(message, customData!);\n}\n"]}
|
|
1
|
+
{"version":3,"file":"convert_exceptions.js","sourceRoot":"","sources":["../../../src/gateway/convert_exceptions.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,kDAA0D;AAC1D,0DAA4C;AAE5C,MAAM,YAAY,GAAG,IAAI,GAAG,EAAwF,CAAC;AACrH,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,qBAAqB,EAAE,UAAU,CAAC,4BAA4B,CAAC,CAAC;AAC1F,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,cAAc,EAAE,UAAU,CAAC,sBAAsB,CAAC,CAAC;AAC7E,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACnF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,gBAAgB,EAAE,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAChF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACnF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UAAU,CAAC,yBAAyB,CAAC,CAAC;AACnF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,iBAAiB,EAAE,UA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AAC,gBAAQ,CAAC,sBAAsB,EAAE,UAAU,CAAC,6BAA6B,CAAC,CAAC;AAC5F,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,2BAA2B,EAAE,UAAU,CAAC,kCAAkC,CAAC,CAAC;AACtG,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,mBAAmB,EAAE,UAAU,CAAC,0BAA0B,CAAC,CAAC;AACtF,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,OAAO,EAAE,UAAU,CAAC,gBAAgB,CAAC,CAAC;AAChE,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,sBAAsB,EAAE,UAAU,CAAC,6BAA6B,CAAC,CAAC;AAC5F,YAAY,CAAC,GAAG,CAAC,gBAAQ,CAAC,eAAe,EAAE,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAE/E,SAAgB,kBAAkB,CAAC,KAAe,EAAE,OAAe,EAAE,UAAmB;IACtF,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAElD,wBAAwB;IACxB,IAAI,CAAC,iBAAiB,EAAE;QACtB,OAAO,IAAI,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;KACnD;IAED,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,UAAW,CAAC,CAAC;AACrD,CAAC;AATD,gDASC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { Errors as PbErrors } from '../protobufs/main_pb';\nimport * as exceptions from '../exceptions';\n\nconst errorMapping = new Map<PbErrors, new (message: string, customData: Buffer) => exceptions.MotionLibException>();\nerrorMapping.set(PbErrors.BINARY_COMMAND_FAILED, exceptions.BinaryCommandFailedException);\nerrorMapping.set(PbErrors.COMMAND_FAILED, exceptions.CommandFailedException);\nerrorMapping.set(PbErrors.COMMAND_PREEMPTED, exceptions.CommandPreemptedException);\nerrorMapping.set(PbErrors.COMMAND_TOO_LONG, exceptions.CommandTooLongException);\nerrorMapping.set(PbErrors.CONNECTION_CLOSED, exceptions.ConnectionClosedException);\nerrorMapping.set(PbErrors.CONNECTION_FAILED, exceptions.ConnectionFailedException);\nerrorMapping.set(PbErrors.CONVERSION_FAILED, exceptions.ConversionFailedException);\nerrorMapping.set(PbErrors.DEVICE_ADDRESS_CONFLICT, exceptions.DeviceAddressConflictException);\nerrorMapping.set(PbErrors.DEVICE_BUSY, exceptions.DeviceBusyException);\nerrorMapping.set(PbErrors.DEVICE_DB_FAILED, exceptions.DeviceDbFailedException);\nerrorMapping.set(PbErrors.DEVICE_DETECTION_FAILED, exceptions.DeviceDetectionFailedException);\nerrorMapping.set(PbErrors.DEVICE_FAILED, exceptions.DeviceFailedException);\nerrorMapping.set(PbErrors.DEVICE_NOT_IDENTIFIED, exceptions.DeviceNotIdentifiedException);\nerrorMapping.set(PbErrors.G_CODE_EXECUTION, exceptions.GCodeExecutionException);\nerrorMapping.set(PbErrors.G_CODE_SYNTAX, exceptions.GCodeSyntaxException);\nerrorMapping.set(PbErrors.INTERNAL_ERROR, exceptions.InternalErrorException);\nerrorMapping.set(PbErrors.INVALID_ARGUMENT, exceptions.InvalidArgumentException);\nerrorMapping.set(PbErrors.INVALID_DATA, exceptions.InvalidDataException);\nerrorMapping.set(PbErrors.INVALID_OPERATION, exceptions.InvalidOperationException);\nerrorMapping.set(PbErrors.INVALID_PACKET, exceptions.InvalidPacketException);\nerrorMapping.set(PbErrors.INVALID_PARK_STATE, exceptions.InvalidParkStateException);\nerrorMapping.set(PbErrors.INVALID_RESPONSE, exceptions.InvalidResponseException);\nerrorMapping.set(PbErrors.IO_CHANNEL_OUT_OF_RANGE, exceptions.IoChannelOutOfRangeException);\nerrorMapping.set(PbErrors.IO_FAILED, exceptions.IoFailedException);\nerrorMapping.set(PbErrors.LOCKSTEP_ENABLED, exceptions.LockstepEnabledException);\nerrorMapping.set(PbErrors.LOCKSTEP_NOT_ENABLED, exceptions.LockstepNotEnabledException);\nerrorMapping.set(PbErrors.MOVEMENT_FAILED, exceptions.MovementFailedException);\nerrorMapping.set(PbErrors.MOVEMENT_INTERRUPTED, exceptions.MovementInterruptedException);\nerrorMapping.set(PbErrors.NO_DEVICE_FOUND, exceptions.NoDeviceFoundException);\nerrorMapping.set(PbErrors.NO_VALUE_FOR_KEY, exceptions.NoValueForKeyException);\nerrorMapping.set(PbErrors.NOT_SUPPORTED, exceptions.NotSupportedException);\nerrorMapping.set(PbErrors.OS_FAILED, exceptions.OsFailedException);\nerrorMapping.set(PbErrors.OUT_OF_REQUEST_IDS, exceptions.OutOfRequestIdsException);\nerrorMapping.set(PbErrors.PVT_DISCONTINUITY, exceptions.PvtDiscontinuityException);\nerrorMapping.set(PbErrors.PVT_EXECUTION, exceptions.PvtExecutionException);\nerrorMapping.set(PbErrors.PVT_MODE, exceptions.PvtModeException);\nerrorMapping.set(PbErrors.PVT_MOVEMENT_FAILED, exceptions.PvtMovementFailedException);\nerrorMapping.set(PbErrors.PVT_MOVEMENT_INTERRUPTED, exceptions.PvtMovementInterruptedException);\nerrorMapping.set(PbErrors.PVT_SETUP_FAILED, exceptions.PvtSetupFailedException);\nerrorMapping.set(PbErrors.REQUEST_TIMEOUT, exceptions.RequestTimeoutException);\nerrorMapping.set(PbErrors.SERIAL_PORT_BUSY, exceptions.SerialPortBusyException);\nerrorMapping.set(PbErrors.SET_DEVICE_STATE_FAILED, exceptions.SetDeviceStateFailedException);\nerrorMapping.set(PbErrors.SET_PERIPHERAL_STATE_FAILED, exceptions.SetPeripheralStateFailedException);\nerrorMapping.set(PbErrors.SETTING_NOT_FOUND, exceptions.SettingNotFoundException);\nerrorMapping.set(PbErrors.STREAM_DISCONTINUITY, exceptions.StreamDiscontinuityException);\nerrorMapping.set(PbErrors.STREAM_EXECUTION, exceptions.StreamExecutionException);\nerrorMapping.set(PbErrors.STREAM_MODE, exceptions.StreamModeException);\nerrorMapping.set(PbErrors.STREAM_MOVEMENT_FAILED, exceptions.StreamMovementFailedException);\nerrorMapping.set(PbErrors.STREAM_MOVEMENT_INTERRUPTED, exceptions.StreamMovementInterruptedException);\nerrorMapping.set(PbErrors.STREAM_SETUP_FAILED, exceptions.StreamSetupFailedException);\nerrorMapping.set(PbErrors.TIMEOUT, exceptions.TimeoutException);\nerrorMapping.set(PbErrors.TRANSPORT_ALREADY_USED, exceptions.TransportAlreadyUsedException);\nerrorMapping.set(PbErrors.UNKNOWN_REQUEST, exceptions.UnknownRequestException);\n\nexport function convertToException(error: PbErrors, message: string, customData?: Buffer): exceptions.MotionLibException {\n const SpecificException = errorMapping.get(error);\n\n /* istanbul ignore if */\n if (!SpecificException) {\n return new exceptions.MotionLibException(message);\n }\n\n return new SpecificException(message, customData!);\n}\n"]}
|
|
@@ -24,7 +24,7 @@ export declare class OfflineTranslator {
|
|
|
24
24
|
* Sets up translator from provided device definition and configuration.
|
|
25
25
|
* @param definition Definition of device and its peripherals.
|
|
26
26
|
* The definition must match a device that later performs the commands.
|
|
27
|
-
* @param config
|
|
27
|
+
* @param config Configuration of the translator.
|
|
28
28
|
* @returns New instance of translator.
|
|
29
29
|
*/
|
|
30
30
|
static setup(definition: DeviceDefinition, config?: TranslatorConfig): Promise<OfflineTranslator>;
|
|
@@ -33,7 +33,7 @@ export declare class OfflineTranslator {
|
|
|
33
33
|
* @param device Device that later performs the command streaming.
|
|
34
34
|
* @param axes Axis numbers that are later used to setup the stream.
|
|
35
35
|
* For a lockstep group specify only the first axis of the group.
|
|
36
|
-
* @param config
|
|
36
|
+
* @param config Configuration of the translator.
|
|
37
37
|
* @returns New instance of translator.
|
|
38
38
|
*/
|
|
39
39
|
static setupFromDevice(device: Device, axes: number[], config?: TranslatorConfig): Promise<OfflineTranslator>;
|
|
@@ -58,7 +58,7 @@ class OfflineTranslator {
|
|
|
58
58
|
* Sets up translator from provided device definition and configuration.
|
|
59
59
|
* @param definition Definition of device and its peripherals.
|
|
60
60
|
* The definition must match a device that later performs the commands.
|
|
61
|
-
* @param config
|
|
61
|
+
* @param config Configuration of the translator.
|
|
62
62
|
* @returns New instance of translator.
|
|
63
63
|
*/
|
|
64
64
|
static async setup(definition, config) {
|
|
@@ -73,7 +73,7 @@ class OfflineTranslator {
|
|
|
73
73
|
* @param device Device that later performs the command streaming.
|
|
74
74
|
* @param axes Axis numbers that are later used to setup the stream.
|
|
75
75
|
* For a lockstep group specify only the first axis of the group.
|
|
76
|
-
* @param config
|
|
76
|
+
* @param config Configuration of the translator.
|
|
77
77
|
* @returns New instance of translator.
|
|
78
78
|
*/
|
|
79
79
|
static async setupFromDevice(device, axes, config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"offline_translator.js","sourceRoot":"","sources":["../../../src/gcode/offline_translator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,2DAAuD;AACvD,2DAAuD;AACvD,yDAAqD;AAGrD,4CAAuD;AAEvD;;;;;GAKG;AACH,MAAa,iBAAiB;IAC5B;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAGD;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAC5C,CAAC;IAED,YAAY,YAAoB;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAA,mCAAuB,EAAC,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,UAA4B,EAC5B,MAAyB;QAEzB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;QACtD,OAAO,CAAC,aAAa,CAAC,oCAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC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AED;;;OAGG;IACK,2BAA2B;QACjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACrD,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAC/B,qCAAqC,EACrC,OAAO,EACP,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1B,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;CACF;AAtSD,8CAsSC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { DeviceDefinition } from './device_definition';\nimport { TranslatorConfig } from './translator_config';\nimport { TranslateResult } from './translate_result';\nimport { Device } from '../ascii/device';\nimport { Angle, Length, Native, AngularVelocity, Velocity } from '../units';\nimport { registerForFinalization } from '../finalizer';\n\n/**\n * Represents an offline G-Code translator.\n * It allows to translate G-Code blocks to Zaber ASCII protocol stream commands.\n * This translator does not need a connected device to perform translation.\n * Requires at least Firmware 7.11.\n */\nexport class OfflineTranslator {\n /**\n * The ID of the translator that serves to identify native resources.\n */\n public get translatorId(): number {\n return this._translatorId;\n }\n private _translatorId: number;\n\n /**\n * Current coordinate system.\n */\n public get coordinateSystem(): string {\n return this._getCurrentCoordinateSystem();\n }\n\n constructor(translatorId: number) {\n this._translatorId = translatorId;\n registerForFinalization(this, OfflineTranslator._free.bind(null, translatorId));\n }\n\n /**\n * Sets up translator from provided device definition and configuration.\n * @param definition Definition of device and its peripherals.\n * The definition must match a device that later performs the commands.\n * @param config? Configuration of the translator.\n * @returns New instance of translator.\n */\n public static async setup(\n definition: DeviceDefinition,\n config?: TranslatorConfig\n ): Promise<OfflineTranslator> {\n const request = new gateway.TranslatorCreateRequest();\n request.setDefinition(DeviceDefinition.toProtobuf(definition));\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create',\n request,\n gateway.TranslatorCreateResponse);\n return new OfflineTranslator(response.getTranslatorId());\n }\n\n /**\n * Sets up an offline translator from provided device, axes, and configuration.\n * @param device Device that later performs the command streaming.\n * @param axes Axis numbers that are later used to setup the stream.\n * For a lockstep group specify only the first axis of the group.\n * @param config? Configuration of the translator.\n * @returns New instance of translator.\n */\n public static async setupFromDevice(\n device: Device,\n axes: number[],\n config?: TranslatorConfig\n ): Promise<OfflineTranslator> {\n const request = new gateway.TranslatorCreateFromDeviceRequest();\n request.setInterfaceId(device.connection.interfaceId);\n request.setDevice(device.deviceAddress);\n request.setAxesList(axes);\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create_from_device',\n request,\n gateway.TranslatorCreateResponse);\n return new OfflineTranslator(response.getTranslatorId());\n }\n\n /**\n * Translates a single block (line) of G-code.\n * @param block Block (line) of G-code.\n * @returns Result of translation containing the stream commands.\n */\n public translate(\n block: string\n ): TranslateResult {\n const request = new gateway.TranslatorTranslateRequest();\n request.setTranslatorId(this.translatorId);\n request.setBlock(block);\n\n const response = gateway.callSync<gateway.TranslatorTranslateResponse>(\n 'gcode/translate',\n request,\n gateway.TranslatorTranslateResponse);\n return TranslateResult.fromProtobuf(response.toObject());\n }\n\n /**\n * Flushes the remaining stream commands waiting in optimization buffer.\n * The flush is also performed by M2 and M30 codes.\n * @returns The remaining stream commands.\n */\n public flush(): string[] {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.TranslatorFlushResponse>(\n 'gcode/flush',\n request,\n gateway.TranslatorFlushResponse);\n return response.getCommandsList();\n }\n\n /**\n * Sets the speed at which the device moves when traversing (G0).\n * @param traverseRate The traverse rate.\n * @param unit Units of the traverse rate.\n */\n public setTraverseRate(\n traverseRate: number,\n unit: Velocity | AngularVelocity | Native\n ): void {\n const request = new gateway.TranslatorSetTraverseRateRequest();\n request.setTranslatorId(this.translatorId);\n request.setTraverseRate(traverseRate);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_traverse_rate', request);\n }\n\n /**\n * Sets position of translator's axis.\n * Use this method to set position after performing movement outside of the translator.\n * This method does not cause any movement.\n * @param axis Letter of the axis.\n * @param position The position.\n * @param unit Units of position.\n */\n public setAxisPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_position', request);\n }\n\n /**\n * Gets position of translator's axis.\n * This method does not query device but returns value from translator's state.\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Position of translator's axis.\n */\n public getAxisPosition(\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_position',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Sets the home position of translator's axis.\n * This position is used by G28.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_home', request);\n }\n\n /**\n * Sets the secondary home position of translator's axis.\n * This position is used by G30.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisSecondaryHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_secondary_home', request);\n }\n\n /**\n * Gets offset of an axis in a given coordinate system.\n * @param coordinateSystem Coordinate system (e.g. G54).\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Offset in translator units of the axis.\n */\n public getAxisCoordinateSystemOffset(\n coordinateSystem: string,\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisOffsetRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoordinateSystem(coordinateSystem);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_offset',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Resets internal state after device rejected generated command.\n * Axis positions become uninitialized.\n */\n public resetAfterStreamError(): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n gateway.callSync('gcode/reset_after_stream_error', request);\n }\n\n /**\n * Allows to scale feed rate of the translated code by a coefficient.\n * @param coefficient Coefficient of the original feed rate.\n */\n public setFeedRateOverride(\n coefficient: number\n ): void {\n const request = new gateway.TranslatorSetFeedRateOverrideRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoefficient(coefficient);\n\n gateway.callSync('gcode/set_feed_rate_override', request);\n }\n\n /**\n * Releases native resources of a translator.\n * @param translatorId The ID of the translator.\n */\n private static _free(\n translatorId: number\n ): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(translatorId);\n\n gateway.callSync('gcode/free', request);\n }\n\n /**\n * Gets current coordinate system (e.g. G54).\n * @returns Current coordinate system.\n */\n private _getCurrentCoordinateSystem(): string {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.StringResponse>(\n 'gcode/get_current_coordinate_system',\n request,\n gateway.StringResponse);\n return response.getValue();\n }\n\n /**\n * Releases the native resources of the translator.\n * Should only be called if your environment does not support FinalizationRegistry.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\n public free(): void {\n OfflineTranslator._free(this.translatorId);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"offline_translator.js","sourceRoot":"","sources":["../../../src/gcode/offline_translator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,2DAAuD;AACvD,2DAAuD;AACvD,yDAAqD;AAGrD,4CAAuD;AAEvD;;;;;GAKG;AACH,MAAa,iBAAiB;IAC5B;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAGD;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAC5C,CAAC;IAED,YAAY,YAAoB;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAA,mCAAuB,EAAC,IAAI,EAAE,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAClF,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,UAA4B,EAC5B,MAAyB;QAEzB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,uBAAuB,EAAE,CAAC;QACtD,OAAO,CAAC,aAAa,CAAC,oCAAgB,CAAC,UAAU,CAAC,UAAU,CAAC,CAAC,CAAC;QAC/D,OAAO,CAAC,SAAS,CAAC,oCAAgB,CAAC,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC;QAEvD,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS,CACtC,cAAc,EACd,OAAO,EACP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,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAC/B,qCAAqC,EACrC,OAAO,EACP,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1B,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;CACF;AAtSD,8CAsSC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { DeviceDefinition } from './device_definition';\nimport { TranslatorConfig } from './translator_config';\nimport { TranslateResult } from './translate_result';\nimport { Device } from '../ascii/device';\nimport { Angle, Length, Native, AngularVelocity, Velocity } from '../units';\nimport { registerForFinalization } from '../finalizer';\n\n/**\n * Represents an offline G-Code translator.\n * It allows to translate G-Code blocks to Zaber ASCII protocol stream commands.\n * This translator does not need a connected device to perform translation.\n * Requires at least Firmware 7.11.\n */\nexport class OfflineTranslator {\n /**\n * The ID of the translator that serves to identify native resources.\n */\n public get translatorId(): number {\n return this._translatorId;\n }\n private _translatorId: number;\n\n /**\n * Current coordinate system.\n */\n public get coordinateSystem(): string {\n return this._getCurrentCoordinateSystem();\n }\n\n constructor(translatorId: number) {\n this._translatorId = translatorId;\n registerForFinalization(this, OfflineTranslator._free.bind(null, translatorId));\n }\n\n /**\n * Sets up translator from provided device definition and configuration.\n * @param definition Definition of device and its peripherals.\n * The definition must match a device that later performs the commands.\n * @param config Configuration of the translator.\n * @returns New instance of translator.\n */\n public static async setup(\n definition: DeviceDefinition,\n config?: TranslatorConfig\n ): Promise<OfflineTranslator> {\n const request = new gateway.TranslatorCreateRequest();\n request.setDefinition(DeviceDefinition.toProtobuf(definition));\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create',\n request,\n gateway.TranslatorCreateResponse);\n return new OfflineTranslator(response.getTranslatorId());\n }\n\n /**\n * Sets up an offline translator from provided device, axes, and configuration.\n * @param device Device that later performs the command streaming.\n * @param axes Axis numbers that are later used to setup the stream.\n * For a lockstep group specify only the first axis of the group.\n * @param config Configuration of the translator.\n * @returns New instance of translator.\n */\n public static async setupFromDevice(\n device: Device,\n axes: number[],\n config?: TranslatorConfig\n ): Promise<OfflineTranslator> {\n const request = new gateway.TranslatorCreateFromDeviceRequest();\n request.setInterfaceId(device.connection.interfaceId);\n request.setDevice(device.deviceAddress);\n request.setAxesList(axes);\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create_from_device',\n request,\n gateway.TranslatorCreateResponse);\n return new OfflineTranslator(response.getTranslatorId());\n }\n\n /**\n * Translates a single block (line) of G-code.\n * @param block Block (line) of G-code.\n * @returns Result of translation containing the stream commands.\n */\n public translate(\n block: string\n ): TranslateResult {\n const request = new gateway.TranslatorTranslateRequest();\n request.setTranslatorId(this.translatorId);\n request.setBlock(block);\n\n const response = gateway.callSync<gateway.TranslatorTranslateResponse>(\n 'gcode/translate',\n request,\n gateway.TranslatorTranslateResponse);\n return TranslateResult.fromProtobuf(response.toObject());\n }\n\n /**\n * Flushes the remaining stream commands waiting in optimization buffer.\n * The flush is also performed by M2 and M30 codes.\n * @returns The remaining stream commands.\n */\n public flush(): string[] {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.TranslatorFlushResponse>(\n 'gcode/flush',\n request,\n gateway.TranslatorFlushResponse);\n return response.getCommandsList();\n }\n\n /**\n * Sets the speed at which the device moves when traversing (G0).\n * @param traverseRate The traverse rate.\n * @param unit Units of the traverse rate.\n */\n public setTraverseRate(\n traverseRate: number,\n unit: Velocity | AngularVelocity | Native\n ): void {\n const request = new gateway.TranslatorSetTraverseRateRequest();\n request.setTranslatorId(this.translatorId);\n request.setTraverseRate(traverseRate);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_traverse_rate', request);\n }\n\n /**\n * Sets position of translator's axis.\n * Use this method to set position after performing movement outside of the translator.\n * This method does not cause any movement.\n * @param axis Letter of the axis.\n * @param position The position.\n * @param unit Units of position.\n */\n public setAxisPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_position', request);\n }\n\n /**\n * Gets position of translator's axis.\n * This method does not query device but returns value from translator's state.\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Position of translator's axis.\n */\n public getAxisPosition(\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_position',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Sets the home position of translator's axis.\n * This position is used by G28.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_home', request);\n }\n\n /**\n * Sets the secondary home position of translator's axis.\n * This position is used by G30.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisSecondaryHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_secondary_home', request);\n }\n\n /**\n * Gets offset of an axis in a given coordinate system.\n * @param coordinateSystem Coordinate system (e.g. G54).\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Offset in translator units of the axis.\n */\n public getAxisCoordinateSystemOffset(\n coordinateSystem: string,\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisOffsetRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoordinateSystem(coordinateSystem);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_offset',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Resets internal state after device rejected generated command.\n * Axis positions become uninitialized.\n */\n public resetAfterStreamError(): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n gateway.callSync('gcode/reset_after_stream_error', request);\n }\n\n /**\n * Allows to scale feed rate of the translated code by a coefficient.\n * @param coefficient Coefficient of the original feed rate.\n */\n public setFeedRateOverride(\n coefficient: number\n ): void {\n const request = new gateway.TranslatorSetFeedRateOverrideRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoefficient(coefficient);\n\n gateway.callSync('gcode/set_feed_rate_override', request);\n }\n\n /**\n * Releases native resources of a translator.\n * @param translatorId The ID of the translator.\n */\n private static _free(\n translatorId: number\n ): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(translatorId);\n\n gateway.callSync('gcode/free', request);\n }\n\n /**\n * Gets current coordinate system (e.g. G54).\n * @returns Current coordinate system.\n */\n private _getCurrentCoordinateSystem(): string {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.StringResponse>(\n 'gcode/get_current_coordinate_system',\n request,\n gateway.StringResponse);\n return response.getValue();\n }\n\n /**\n * Releases the native resources of the translator.\n * Should only be called if your environment does not support FinalizationRegistry.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\n public free(): void {\n OfflineTranslator._free(this.translatorId);\n }\n}\n"]}
|
|
@@ -23,7 +23,7 @@ export declare class Translator {
|
|
|
23
23
|
* Sets up the translator on top of a provided stream.
|
|
24
24
|
* @param stream The stream to setup the translator on.
|
|
25
25
|
* The stream must be already setup in a live or a store mode.
|
|
26
|
-
* @param config
|
|
26
|
+
* @param config Configuration of the translator.
|
|
27
27
|
* @returns New instance of translator.
|
|
28
28
|
*/
|
|
29
29
|
static setup(stream: Stream, config?: TranslatorConfig): Promise<Translator>;
|
|
@@ -57,7 +57,7 @@ class Translator {
|
|
|
57
57
|
* Sets up the translator on top of a provided stream.
|
|
58
58
|
* @param stream The stream to setup the translator on.
|
|
59
59
|
* The stream must be already setup in a live or a store mode.
|
|
60
|
-
* @param config
|
|
60
|
+
* @param config Configuration of the translator.
|
|
61
61
|
* @returns New instance of translator.
|
|
62
62
|
*/
|
|
63
63
|
static async setup(stream, config) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translator.js","sourceRoot":"","sources":["../../../src/gcode/translator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,yDAAqD;AACrD,2DAAuD;AAGvD,4CAAuD;AAEvD;;;;;GAKG;AACH,MAAa,UAAU;IACrB;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAGD;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAC5C,CAAC;IAED,YAAY,YAAoB;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAA,mCAAuB,EAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;OAMG;IACI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EAAE,CAAC;QACrD,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEtC,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;OAGG;IACK,2BAA2B;QACjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACrD,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAC/B,qCAAqC,EACrC,OAAO,EACP,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1B,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;CACF;AAlSD,gCAkSC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { TranslateResult } from './translate_result';\nimport { TranslatorConfig } from './translator_config';\nimport { Stream } from '../ascii/stream';\nimport { Angle, Length, Native, AngularVelocity, Velocity } from '../units';\nimport { registerForFinalization } from '../finalizer';\n\n/**\n * Represents a live G-Code translator.\n * It allows to stream G-Code blocks to a connected device.\n * It requires a stream to be setup on the device.\n * Requires at least Firmware 7.11.\n */\nexport class Translator {\n /**\n * The ID of the translator that serves to identify native resources.\n */\n public get translatorId(): number {\n return this._translatorId;\n }\n private _translatorId: number;\n\n /**\n * Current coordinate system.\n */\n public get coordinateSystem(): string {\n return this._getCurrentCoordinateSystem();\n }\n\n constructor(translatorId: number) {\n this._translatorId = translatorId;\n registerForFinalization(this, Translator._free.bind(null, translatorId));\n }\n\n /**\n * Sets up the translator on top of a provided stream.\n * @param stream The stream to setup the translator on.\n * The stream must be already setup in a live or a store mode.\n * @param config? Configuration of the translator.\n * @returns New instance of translator.\n */\n public static async setup(\n stream: Stream,\n config?: TranslatorConfig\n ): Promise<Translator> {\n const request = new gateway.TranslatorCreateLiveRequest();\n request.setDevice(stream.device.deviceAddress);\n request.setInterfaceId(stream.device.connection.interfaceId);\n request.setStreamId(stream.streamId);\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create_live',\n request,\n gateway.TranslatorCreateResponse);\n return new Translator(response.getTranslatorId());\n }\n\n /**\n * Translates a single block (line) of G-code.\n * The commands are queued in the underlying stream to ensure smooth continues movement.\n * Returning of this method indicates that the commands are queued (not necessarily executed).\n * @param block Block (line) of G-code.\n * @returns Result of translation containing the commands sent to the device.\n */\n public async translate(\n block: string\n ): Promise<TranslateResult> {\n const request = new gateway.TranslatorTranslateRequest();\n request.setTranslatorId(this.translatorId);\n request.setBlock(block);\n\n const response = await gateway.callAsync<gateway.TranslatorTranslateResponse>(\n 'gcode/translate_live',\n request,\n gateway.TranslatorTranslateResponse);\n return TranslateResult.fromProtobuf(response.toObject());\n }\n\n /**\n * Flushes the remaining stream commands waiting in optimization buffer into the underlying stream.\n * The flush is also performed by M2 and M30 codes.\n * @param [options.waitUntilIdle=true] Determines whether to wait for the stream to finish all the movements.\n * @returns The remaining stream commands.\n */\n public async flush(\n options: Translator.FlushOptions = {}\n ): Promise<string[]> {\n const {\n waitUntilIdle = true,\n } = options;\n const request = new gateway.TranslatorFlushLiveRequest();\n request.setTranslatorId(this.translatorId);\n request.setWaitUntilIdle(waitUntilIdle);\n\n const response = await gateway.callAsync<gateway.TranslatorFlushResponse>(\n 'gcode/flush_live',\n request,\n gateway.TranslatorFlushResponse);\n return response.getCommandsList();\n }\n\n /**\n * Resets position of the translator from the underlying stream.\n * Call this method after performing a movement outside of translator.\n */\n public async resetPosition(): Promise<void> {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n await gateway.callAsync('gcode/reset_position_from_stream', request);\n }\n\n /**\n * Sets the speed at which the device moves when traversing (G0).\n * @param traverseRate The traverse rate.\n * @param unit Units of the traverse rate.\n */\n public setTraverseRate(\n traverseRate: number,\n unit: Velocity | AngularVelocity | Native\n ): void {\n const request = new gateway.TranslatorSetTraverseRateRequest();\n request.setTranslatorId(this.translatorId);\n request.setTraverseRate(traverseRate);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_traverse_rate', request);\n }\n\n /**\n * Sets position of translator's axis.\n * Use this method to set position after performing movement outside of the translator.\n * This method does not cause any movement.\n * @param axis Letter of the axis.\n * @param position The position.\n * @param unit Units of position.\n */\n public setAxisPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_position', request);\n }\n\n /**\n * Gets position of translator's axis.\n * This method does not query device but returns value from translator's state.\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Position of translator's axis.\n */\n public getAxisPosition(\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_position',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Sets the home position of translator's axis.\n * This position is used by G28.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_home', request);\n }\n\n /**\n * Sets the secondary home position of translator's axis.\n * This position is used by G30.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisSecondaryHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_secondary_home', request);\n }\n\n /**\n * Gets offset of an axis in a given coordinate system.\n * @param coordinateSystem Coordinate system (e.g. G54).\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Offset in translator units of the axis.\n */\n public getAxisCoordinateSystemOffset(\n coordinateSystem: string,\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisOffsetRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoordinateSystem(coordinateSystem);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_offset',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Resets internal state after device rejected generated command.\n * Axis positions become uninitialized.\n */\n public resetAfterStreamError(): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n gateway.callSync('gcode/reset_after_stream_error', request);\n }\n\n /**\n * Allows to scale feed rate of the translated code by a coefficient.\n * @param coefficient Coefficient of the original feed rate.\n */\n public setFeedRateOverride(\n coefficient: number\n ): void {\n const request = new gateway.TranslatorSetFeedRateOverrideRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoefficient(coefficient);\n\n gateway.callSync('gcode/set_feed_rate_override', request);\n }\n\n /**\n * Releases native resources of a translator.\n * @param translatorId The ID of the translator.\n */\n private static _free(\n translatorId: number\n ): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(translatorId);\n\n gateway.callSync('gcode/free', request);\n }\n\n /**\n * Gets current coordinate system (e.g. G54).\n * @returns Current coordinate system.\n */\n private _getCurrentCoordinateSystem(): string {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.StringResponse>(\n 'gcode/get_current_coordinate_system',\n request,\n gateway.StringResponse);\n return response.getValue();\n }\n\n /**\n * Releases the native resources of the translator.\n * Should only be called if your environment does not support FinalizationRegistry.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\n public free(): void {\n Translator._free(this.translatorId);\n }\n}\n\nnamespace Translator {\n export interface FlushOptions {\n waitUntilIdle?: boolean;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"translator.js","sourceRoot":"","sources":["../../../src/gcode/translator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,yDAAqD;AACrD,2DAAuD;AAGvD,4CAAuD;AAEvD;;;;;GAKG;AACH,MAAa,UAAU;IACrB;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAGD;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAC5C,CAAC;IAED,YAAY,YAAoB;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAA,mCAAuB,EAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,MAAc,EACd,MAAyB;QAEzB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,2BAA2B,EAAE,CAAC;QAC1D,OAAO,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,aAAa,CAAC,CAAC;QAC/C,OAAO,CAAC,cAAc,CAAC,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,WAAW,CAAC,CAAC;QAC7D,OAAO,CAA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AM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAC/B,qCAAqC,EACrC,OAAO,EACP,OAAO,CAAC,cAAc,CAAC,CAAC;QAC1B,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;CACF;AAlSD,gCAkSC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { TranslateResult } from './translate_result';\nimport { TranslatorConfig } from './translator_config';\nimport { Stream } from '../ascii/stream';\nimport { Angle, Length, Native, AngularVelocity, Velocity } from '../units';\nimport { registerForFinalization } from '../finalizer';\n\n/**\n * Represents a live G-Code translator.\n * It allows to stream G-Code blocks to a connected device.\n * It requires a stream to be setup on the device.\n * Requires at least Firmware 7.11.\n */\nexport class Translator {\n /**\n * The ID of the translator that serves to identify native resources.\n */\n public get translatorId(): number {\n return this._translatorId;\n }\n private _translatorId: number;\n\n /**\n * Current coordinate system.\n */\n public get coordinateSystem(): string {\n return this._getCurrentCoordinateSystem();\n }\n\n constructor(translatorId: number) {\n this._translatorId = translatorId;\n registerForFinalization(this, Translator._free.bind(null, translatorId));\n }\n\n /**\n * Sets up the translator on top of a provided stream.\n * @param stream The stream to setup the translator on.\n * The stream must be already setup in a live or a store mode.\n * @param config Configuration of the translator.\n * @returns New instance of translator.\n */\n public static async setup(\n stream: Stream,\n config?: TranslatorConfig\n ): Promise<Translator> {\n const request = new gateway.TranslatorCreateLiveRequest();\n request.setDevice(stream.device.deviceAddress);\n request.setInterfaceId(stream.device.connection.interfaceId);\n request.setStreamId(stream.streamId);\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create_live',\n request,\n gateway.TranslatorCreateResponse);\n return new Translator(response.getTranslatorId());\n }\n\n /**\n * Translates a single block (line) of G-code.\n * The commands are queued in the underlying stream to ensure smooth continues movement.\n * Returning of this method indicates that the commands are queued (not necessarily executed).\n * @param block Block (line) of G-code.\n * @returns Result of translation containing the commands sent to the device.\n */\n public async translate(\n block: string\n ): Promise<TranslateResult> {\n const request = new gateway.TranslatorTranslateRequest();\n request.setTranslatorId(this.translatorId);\n request.setBlock(block);\n\n const response = await gateway.callAsync<gateway.TranslatorTranslateResponse>(\n 'gcode/translate_live',\n request,\n gateway.TranslatorTranslateResponse);\n return TranslateResult.fromProtobuf(response.toObject());\n }\n\n /**\n * Flushes the remaining stream commands waiting in optimization buffer into the underlying stream.\n * The flush is also performed by M2 and M30 codes.\n * @param [options.waitUntilIdle=true] Determines whether to wait for the stream to finish all the movements.\n * @returns The remaining stream commands.\n */\n public async flush(\n options: Translator.FlushOptions = {}\n ): Promise<string[]> {\n const {\n waitUntilIdle = true,\n } = options;\n const request = new gateway.TranslatorFlushLiveRequest();\n request.setTranslatorId(this.translatorId);\n request.setWaitUntilIdle(waitUntilIdle);\n\n const response = await gateway.callAsync<gateway.TranslatorFlushResponse>(\n 'gcode/flush_live',\n request,\n gateway.TranslatorFlushResponse);\n return response.getCommandsList();\n }\n\n /**\n * Resets position of the translator from the underlying stream.\n * Call this method after performing a movement outside of translator.\n */\n public async resetPosition(): Promise<void> {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n await gateway.callAsync('gcode/reset_position_from_stream', request);\n }\n\n /**\n * Sets the speed at which the device moves when traversing (G0).\n * @param traverseRate The traverse rate.\n * @param unit Units of the traverse rate.\n */\n public setTraverseRate(\n traverseRate: number,\n unit: Velocity | AngularVelocity | Native\n ): void {\n const request = new gateway.TranslatorSetTraverseRateRequest();\n request.setTranslatorId(this.translatorId);\n request.setTraverseRate(traverseRate);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_traverse_rate', request);\n }\n\n /**\n * Sets position of translator's axis.\n * Use this method to set position after performing movement outside of the translator.\n * This method does not cause any movement.\n * @param axis Letter of the axis.\n * @param position The position.\n * @param unit Units of position.\n */\n public setAxisPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_position', request);\n }\n\n /**\n * Gets position of translator's axis.\n * This method does not query device but returns value from translator's state.\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Position of translator's axis.\n */\n public getAxisPosition(\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_position',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Sets the home position of translator's axis.\n * This position is used by G28.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_home', request);\n }\n\n /**\n * Sets the secondary home position of translator's axis.\n * This position is used by G30.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisSecondaryHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_secondary_home', request);\n }\n\n /**\n * Gets offset of an axis in a given coordinate system.\n * @param coordinateSystem Coordinate system (e.g. G54).\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @returns Offset in translator units of the axis.\n */\n public getAxisCoordinateSystemOffset(\n coordinateSystem: string,\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisOffsetRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoordinateSystem(coordinateSystem);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.DoubleResponse>(\n 'gcode/get_axis_offset',\n request,\n gateway.DoubleResponse);\n return response.getValue();\n }\n\n /**\n * Resets internal state after device rejected generated command.\n * Axis positions become uninitialized.\n */\n public resetAfterStreamError(): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n gateway.callSync('gcode/reset_after_stream_error', request);\n }\n\n /**\n * Allows to scale feed rate of the translated code by a coefficient.\n * @param coefficient Coefficient of the original feed rate.\n */\n public setFeedRateOverride(\n coefficient: number\n ): void {\n const request = new gateway.TranslatorSetFeedRateOverrideRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoefficient(coefficient);\n\n gateway.callSync('gcode/set_feed_rate_override', request);\n }\n\n /**\n * Releases native resources of a translator.\n * @param translatorId The ID of the translator.\n */\n private static _free(\n translatorId: number\n ): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(translatorId);\n\n gateway.callSync('gcode/free', request);\n }\n\n /**\n * Gets current coordinate system (e.g. G54).\n * @returns Current coordinate system.\n */\n private _getCurrentCoordinateSystem(): string {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.StringResponse>(\n 'gcode/get_current_coordinate_system',\n request,\n gateway.StringResponse);\n return response.getValue();\n }\n\n /**\n * Releases the native resources of the translator.\n * Should only be called if your environment does not support FinalizationRegistry.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\n public free(): void {\n Translator._free(this.translatorId);\n }\n}\n\nnamespace Translator {\n export interface FlushOptions {\n waitUntilIdle?: boolean;\n }\n}\n"]}
|