@zaber/motion 2.15.4 → 3.0.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/dist/binding/wasm/zaber-motion-lib.wasm +0 -0
- package/dist/lib/ascii/all_axes.d.ts +21 -9
- package/dist/lib/ascii/all_axes.js +12 -9
- package/dist/lib/ascii/all_axes.js.map +1 -1
- package/dist/lib/ascii/axis.d.ts +116 -58
- package/dist/lib/ascii/axis.js +74 -58
- package/dist/lib/ascii/axis.js.map +1 -1
- package/dist/lib/ascii/axis_settings.d.ts +11 -10
- package/dist/lib/ascii/axis_settings.js +11 -10
- package/dist/lib/ascii/axis_settings.js.map +1 -1
- package/dist/lib/ascii/connection.d.ts +91 -68
- package/dist/lib/ascii/connection.js +60 -86
- package/dist/lib/ascii/connection.js.map +1 -1
- package/dist/lib/ascii/device.d.ts +46 -25
- package/dist/lib/ascii/device.js +31 -25
- package/dist/lib/ascii/device.js.map +1 -1
- package/dist/lib/ascii/device_io.d.ts +9 -9
- package/dist/lib/ascii/device_io.js +9 -9
- package/dist/lib/ascii/device_io.js.map +1 -1
- package/dist/lib/ascii/device_settings.d.ts +10 -10
- package/dist/lib/ascii/device_settings.js +10 -10
- package/dist/lib/ascii/device_settings.js.map +1 -1
- package/dist/lib/ascii/lockstep.d.ts +99 -49
- package/dist/lib/ascii/lockstep.js +63 -49
- package/dist/lib/ascii/lockstep.js.map +1 -1
- package/dist/lib/ascii/oscilloscope.d.ts +14 -13
- package/dist/lib/ascii/oscilloscope.js +14 -13
- package/dist/lib/ascii/oscilloscope.js.map +1 -1
- package/dist/lib/ascii/oscilloscope_data.d.ts +9 -9
- package/dist/lib/ascii/oscilloscope_data.js +9 -9
- package/dist/lib/ascii/oscilloscope_data.js.map +1 -1
- package/dist/lib/ascii/servo_tuner.d.ts +20 -10
- package/dist/lib/ascii/servo_tuner.js +13 -10
- package/dist/lib/ascii/servo_tuner.js.map +1 -1
- package/dist/lib/ascii/setting_constants.d.ts +2 -2
- package/dist/lib/ascii/setting_constants.js +2 -2
- package/dist/lib/ascii/setting_constants.js.map +1 -1
- package/dist/lib/ascii/storage.d.ts +49 -24
- package/dist/lib/ascii/storage.js +32 -24
- package/dist/lib/ascii/storage.js.map +1 -1
- package/dist/lib/ascii/stream.d.ts +29 -17
- package/dist/lib/ascii/stream.js +24 -17
- 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/transport.d.ts +2 -2
- package/dist/lib/ascii/transport.js +2 -2
- package/dist/lib/ascii/transport.js.map +1 -1
- package/dist/lib/ascii/warnings.d.ts +2 -2
- package/dist/lib/ascii/warnings.js +2 -2
- package/dist/lib/ascii/warnings.js.map +1 -1
- package/dist/lib/binary/connection.d.ts +46 -25
- package/dist/lib/binary/connection.js +30 -25
- package/dist/lib/binary/connection.js.map +1 -1
- package/dist/lib/binary/device.d.ts +66 -38
- package/dist/lib/binary/device.js +48 -38
- package/dist/lib/binary/device.js.map +1 -1
- package/dist/lib/binary/device_identity.d.ts +1 -0
- package/dist/lib/binary/device_identity.js.map +1 -1
- package/dist/lib/binary/device_settings.d.ts +3 -3
- package/dist/lib/binary/device_settings.js +3 -3
- package/dist/lib/binary/device_settings.js.map +1 -1
- package/dist/lib/exceptions/binary_command_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/command_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/command_preempted_exception.js.map +1 -1
- package/dist/lib/exceptions/command_too_long_exception.js.map +1 -1
- package/dist/lib/exceptions/connection_closed_exception.js.map +1 -1
- package/dist/lib/exceptions/connection_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/conversion_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/device_address_conflict_exception.js.map +1 -1
- package/dist/lib/exceptions/device_busy_exception.js.map +1 -1
- package/dist/lib/exceptions/device_db_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/device_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/device_not_identified_exception.js.map +1 -1
- package/dist/lib/exceptions/g_code_execution_exception.js.map +1 -1
- package/dist/lib/exceptions/g_code_syntax_exception.js.map +1 -1
- package/dist/lib/exceptions/internal_error_exception.js.map +1 -1
- package/dist/lib/exceptions/invalid_argument_exception.js.map +1 -1
- package/dist/lib/exceptions/invalid_data_exception.js.map +1 -1
- package/dist/lib/exceptions/invalid_operation_exception.js.map +1 -1
- package/dist/lib/exceptions/invalid_packet_exception.js.map +1 -1
- package/dist/lib/exceptions/invalid_park_state_exception.js.map +1 -1
- package/dist/lib/exceptions/invalid_response_exception.js.map +1 -1
- package/dist/lib/exceptions/io_channel_out_of_range_exception.js.map +1 -1
- package/dist/lib/exceptions/io_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/lockstep_enabled_exception.js.map +1 -1
- package/dist/lib/exceptions/lockstep_not_enabled_exception.js.map +1 -1
- package/dist/lib/exceptions/motion_lib_exception.js.map +1 -1
- package/dist/lib/exceptions/movement_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/movement_interrupted_exception.js.map +1 -1
- package/dist/lib/exceptions/no_device_found_exception.js.map +1 -1
- package/dist/lib/exceptions/no_value_for_key_exception.js.map +1 -1
- package/dist/lib/exceptions/not_supported_exception.js.map +1 -1
- package/dist/lib/exceptions/os_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/out_of_request_ids_exception.js.map +1 -1
- package/dist/lib/exceptions/request_timeout_exception.js.map +1 -1
- package/dist/lib/exceptions/serial_port_busy_exception.js.map +1 -1
- package/dist/lib/exceptions/set_device_state_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/set_peripheral_state_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/setting_not_found_exception.js.map +1 -1
- package/dist/lib/exceptions/stream_execution_exception.js.map +1 -1
- package/dist/lib/exceptions/stream_mode_exception.js.map +1 -1
- package/dist/lib/exceptions/stream_movement_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/stream_movement_interrupted_exception.js.map +1 -1
- package/dist/lib/exceptions/stream_setup_failed_exception.js.map +1 -1
- package/dist/lib/exceptions/transport_already_used_exception.js.map +1 -1
- package/dist/lib/exceptions/unknown_request_exception.js.map +1 -1
- package/dist/lib/gateway/events.js +4 -5
- package/dist/lib/gateway/events.js.map +1 -1
- package/dist/lib/gateway/serialization.js.map +1 -1
- package/dist/lib/gcode/offline_translator.d.ts +8 -7
- package/dist/lib/gcode/offline_translator.js +8 -7
- package/dist/lib/gcode/offline_translator.js.map +1 -1
- package/dist/lib/gcode/translator.d.ts +15 -8
- package/dist/lib/gcode/translator.js +10 -8
- package/dist/lib/gcode/translator.js.map +1 -1
- package/dist/lib/library.d.ts +3 -3
- package/dist/lib/library.js +3 -3
- package/dist/lib/library.js.map +1 -1
- package/dist/lib/tools.d.ts +3 -3
- package/dist/lib/tools.js +3 -3
- package/dist/lib/tools.js.map +1 -1
- package/dist/lib/wasm.js +1 -3
- package/dist/lib/wasm.js.map +1 -1
- package/package.json +2 -2
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set_device_state_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/set_device_state_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAAyF;AACzF,uFAAgF;AAEhF;;GAEG;AACH,MAAa,6BAA8B,SAAQ,yCAAkB;IACnE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"set_device_state_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/set_device_state_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAAyF;AACzF,uFAAgF;AAEhF;;GAEG;AACH,MAAa,6BAA8B,SAAQ,yCAAkB;IACnE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,YACE,OAAe,EACf,UAAgD;QAEhD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,6BAA6B,CAAC,SAAS,CAAC,CAAC;QAErE,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC/B,MAAM,WAAW,GAAG,qCAAkB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACrE,IAAI,CAAC,QAAQ,GAAG,6DAA2B,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;SAClF;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;SAC5B;IACH,CAAC;CACF;AAtBD,sEAsBC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\nimport { SetDeviceStateExceptionData as CustomDataProtobuf } from '../protobufs/main_pb';\nimport { SetDeviceStateExceptionData } from './set_device_state_exception_data';\n\n/**\n * Thrown when a device cannot be set to the supplied state.\n */\nexport class SetDeviceStateFailedException extends MotionLibException {\n /**\n * Additional data for SetDeviceStateFailedException\n */\n public get details(): SetDeviceStateExceptionData {\n return this._details;\n }\n private _details: SetDeviceStateExceptionData;\n constructor(\n message: string,\n customData: Buffer | SetDeviceStateExceptionData\n ) {\n super(message);\n Object.setPrototypeOf(this, SetDeviceStateFailedException.prototype);\n\n if (Buffer.isBuffer(customData)) {\n const protobufObj = CustomDataProtobuf.deserializeBinary(customData);\n this._details = SetDeviceStateExceptionData.fromProtobuf(protobufObj.toObject());\n } else {\n this._details = customData;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"set_peripheral_state_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/set_peripheral_state_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAA6F;AAC7F,+FAAwF;AAExF;;GAEG;AACH,MAAa,iCAAkC,SAAQ,yCAAkB;IACvE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"set_peripheral_state_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/set_peripheral_state_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAA6F;AAC7F,+FAAwF;AAExF;;GAEG;AACH,MAAa,iCAAkC,SAAQ,yCAAkB;IACvE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,YACE,OAAe,EACf,UAAoD;QAEpD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,iCAAiC,CAAC,SAAS,CAAC,CAAC;QAEzE,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC/B,MAAM,WAAW,GAAG,yCAAkB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACrE,IAAI,CAAC,QAAQ,GAAG,qEAA+B,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;SACtF;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;SAC5B;IACH,CAAC;CACF;AAtBD,8EAsBC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\nimport { SetPeripheralStateExceptionData as CustomDataProtobuf } from '../protobufs/main_pb';\nimport { SetPeripheralStateExceptionData } from './set_peripheral_state_exception_data';\n\n/**\n * Thrown when an axis cannot be set to the supplied state.\n */\nexport class SetPeripheralStateFailedException extends MotionLibException {\n /**\n * Additional data for SetPeripheralStateFailedException\n */\n public get details(): SetPeripheralStateExceptionData {\n return this._details;\n }\n private _details: SetPeripheralStateExceptionData;\n constructor(\n message: string,\n customData: Buffer | SetPeripheralStateExceptionData\n ) {\n super(message);\n Object.setPrototypeOf(this, SetPeripheralStateFailedException.prototype);\n\n if (Buffer.isBuffer(customData)) {\n const protobufObj = CustomDataProtobuf.deserializeBinary(customData);\n this._details = SetPeripheralStateExceptionData.fromProtobuf(protobufObj.toObject());\n } else {\n this._details = customData;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"setting_not_found_exception.js","sourceRoot":"","sources":["../../../src/exceptions/setting_not_found_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,wBAAyB,SAAQ,yCAAkB;
|
|
1
|
+
{"version":3,"file":"setting_not_found_exception.js","sourceRoot":"","sources":["../../../src/exceptions/setting_not_found_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,wBAAyB,SAAQ,yCAAkB;IAC9D,YACE,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;IAClE,CAAC;CACF;AAPD,4DAOC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\n\n/**\n * Thrown when a get or a set command cannot be found for a setting.\n */\nexport class SettingNotFoundException extends MotionLibException {\n constructor(\n message: string\n ) {\n super(message);\n Object.setPrototypeOf(this, SettingNotFoundException.prototype);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream_execution_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_execution_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAA0F;AAC1F,uFAAiF;AAEjF;;GAEG;AACH,MAAa,wBAAyB,SAAQ,yCAAkB;IAC9D;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream_execution_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_execution_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAA0F;AAC1F,uFAAiF;AAEjF;;GAEG;AACH,MAAa,wBAAyB,SAAQ,yCAAkB;IAC9D;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,YACE,OAAe,EACf,UAAiD;QAEjD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,wBAAwB,CAAC,SAAS,CAAC,CAAC;QAEhE,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC/B,MAAM,WAAW,GAAG,sCAAkB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACrE,IAAI,CAAC,QAAQ,GAAG,8DAA4B,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;SACnF;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;SAC5B;IACH,CAAC;CACF;AAtBD,4DAsBC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\nimport { StreamExecutionExceptionData as CustomDataProtobuf } from '../protobufs/main_pb';\nimport { StreamExecutionExceptionData } from './stream_execution_exception_data';\n\n/**\n * Thrown when a streamed motion fails.\n */\nexport class StreamExecutionException extends MotionLibException {\n /**\n * Additional data for StreamExecutionException\n */\n public get details(): StreamExecutionExceptionData {\n return this._details;\n }\n private _details: StreamExecutionExceptionData;\n constructor(\n message: string,\n customData: Buffer | StreamExecutionExceptionData\n ) {\n super(message);\n Object.setPrototypeOf(this, StreamExecutionException.prototype);\n\n if (Buffer.isBuffer(customData)) {\n const protobufObj = CustomDataProtobuf.deserializeBinary(customData);\n this._details = StreamExecutionExceptionData.fromProtobuf(protobufObj.toObject());\n } else {\n this._details = customData;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream_mode_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_mode_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,mBAAoB,SAAQ,yCAAkB;
|
|
1
|
+
{"version":3,"file":"stream_mode_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_mode_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,mBAAoB,SAAQ,yCAAkB;IACzD,YACE,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,mBAAmB,CAAC,SAAS,CAAC,CAAC;IAC7D,CAAC;CACF;AAPD,kDAOC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\n\n/**\n * Thrown when an operation is not supported by a mode the stream is currently set up in.\n */\nexport class StreamModeException extends MotionLibException {\n constructor(\n message: string\n ) {\n super(message);\n Object.setPrototypeOf(this, StreamModeException.prototype);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream_movement_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_movement_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAA+F;AAC/F,mGAA4F;AAE5F;;GAEG;AACH,MAAa,6BAA8B,SAAQ,yCAAkB;IACnE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream_movement_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_movement_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAA+F;AAC/F,mGAA4F;AAE5F;;GAEG;AACH,MAAa,6BAA8B,SAAQ,yCAAkB;IACnE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,YACE,OAAe,EACf,UAAsD;QAEtD,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,6BAA6B,CAAC,SAAS,CAAC,CAAC;QAErE,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC/B,MAAM,WAAW,GAAG,2CAAkB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACrE,IAAI,CAAC,QAAQ,GAAG,yEAAiC,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;SACxF;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;SAC5B;IACH,CAAC;CACF;AAtBD,sEAsBC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\nimport { StreamMovementFailedExceptionData as CustomDataProtobuf } from '../protobufs/main_pb';\nimport { StreamMovementFailedExceptionData } from './stream_movement_failed_exception_data';\n\n/**\n * Thrown when a device registers a fault during streamed movement.\n */\nexport class StreamMovementFailedException extends MotionLibException {\n /**\n * Additional data for StreamMovementFailedException\n */\n public get details(): StreamMovementFailedExceptionData {\n return this._details;\n }\n private _details: StreamMovementFailedExceptionData;\n constructor(\n message: string,\n customData: Buffer | StreamMovementFailedExceptionData\n ) {\n super(message);\n Object.setPrototypeOf(this, StreamMovementFailedException.prototype);\n\n if (Buffer.isBuffer(customData)) {\n const protobufObj = CustomDataProtobuf.deserializeBinary(customData);\n this._details = StreamMovementFailedExceptionData.fromProtobuf(protobufObj.toObject());\n } else {\n this._details = customData;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream_movement_interrupted_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_movement_interrupted_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAAoG;AACpG,6GAAsG;AAEtG;;GAEG;AACH,MAAa,kCAAmC,SAAQ,yCAAkB;IACxE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;
|
|
1
|
+
{"version":3,"file":"stream_movement_interrupted_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_movement_interrupted_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAC5D,kDAAoG;AACpG,6GAAsG;AAEtG;;GAEG;AACH,MAAa,kCAAmC,SAAQ,yCAAkB;IACxE;;OAEG;IACH,IAAW,OAAO;QAChB,OAAO,IAAI,CAAC,QAAQ,CAAC;IACvB,CAAC;IAED,YACE,OAAe,EACf,UAA2D;QAE3D,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,kCAAkC,CAAC,SAAS,CAAC,CAAC;QAE1E,IAAI,MAAM,CAAC,QAAQ,CAAC,UAAU,CAAC,EAAE;YAC/B,MAAM,WAAW,GAAG,gDAAkB,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC;YACrE,IAAI,CAAC,QAAQ,GAAG,mFAAsC,CAAC,YAAY,CAAC,WAAW,CAAC,QAAQ,EAAE,CAAC,CAAC;SAC7F;aAAM;YACL,IAAI,CAAC,QAAQ,GAAG,UAAU,CAAC;SAC5B;IACH,CAAC;CACF;AAtBD,gFAsBC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\nimport { StreamMovementInterruptedExceptionData as CustomDataProtobuf } from '../protobufs/main_pb';\nimport { StreamMovementInterruptedExceptionData } from './stream_movement_interrupted_exception_data';\n\n/**\n * Thrown when ongoing stream movement is interrupted by another command or user input.\n */\nexport class StreamMovementInterruptedException extends MotionLibException {\n /**\n * Additional data for StreamMovementInterruptedException\n */\n public get details(): StreamMovementInterruptedExceptionData {\n return this._details;\n }\n private _details: StreamMovementInterruptedExceptionData;\n constructor(\n message: string,\n customData: Buffer | StreamMovementInterruptedExceptionData\n ) {\n super(message);\n Object.setPrototypeOf(this, StreamMovementInterruptedException.prototype);\n\n if (Buffer.isBuffer(customData)) {\n const protobufObj = CustomDataProtobuf.deserializeBinary(customData);\n this._details = StreamMovementInterruptedExceptionData.fromProtobuf(protobufObj.toObject());\n } else {\n this._details = customData;\n }\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"stream_setup_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_setup_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,0BAA2B,SAAQ,yCAAkB;
|
|
1
|
+
{"version":3,"file":"stream_setup_failed_exception.js","sourceRoot":"","sources":["../../../src/exceptions/stream_setup_failed_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,0BAA2B,SAAQ,yCAAkB;IAChE,YACE,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,0BAA0B,CAAC,SAAS,CAAC,CAAC;IACpE,CAAC;CACF;AAPD,gEAOC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\n\n/**\n * Thrown when setting up a stream fails.\n */\nexport class StreamSetupFailedException extends MotionLibException {\n constructor(\n message: string\n ) {\n super(message);\n Object.setPrototypeOf(this, StreamSetupFailedException.prototype);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"transport_already_used_exception.js","sourceRoot":"","sources":["../../../src/exceptions/transport_already_used_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,6BAA8B,SAAQ,yCAAkB;
|
|
1
|
+
{"version":3,"file":"transport_already_used_exception.js","sourceRoot":"","sources":["../../../src/exceptions/transport_already_used_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,6BAA8B,SAAQ,yCAAkB;IACnE,YACE,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,6BAA6B,CAAC,SAAS,CAAC,CAAC;IACvE,CAAC;CACF;AAPD,sEAOC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\n\n/**\n * Thrown when a transport has already been used to open another connection.\n */\nexport class TransportAlreadyUsedException extends MotionLibException {\n constructor(\n message: string\n ) {\n super(message);\n Object.setPrototypeOf(this, TransportAlreadyUsedException.prototype);\n }\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"unknown_request_exception.js","sourceRoot":"","sources":["../../../src/exceptions/unknown_request_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,uBAAwB,SAAQ,yCAAkB;
|
|
1
|
+
{"version":3,"file":"unknown_request_exception.js","sourceRoot":"","sources":["../../../src/exceptions/unknown_request_exception.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;AAEtD,iEAA4D;AAE5D;;GAEG;AACH,MAAa,uBAAwB,SAAQ,yCAAkB;IAC7D,YACE,OAAe;QAEf,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,uBAAuB,CAAC,SAAS,CAAC,CAAC;IACjE,CAAC;CACF;AAPD,0DAOC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { MotionLibException } from './motion_lib_exception';\n\n/**\n * Used for internal error handling. Indicates mixed library binary files. Reinstall the library.\n */\nexport class UnknownRequestException extends MotionLibException {\n constructor(\n message: string\n ) {\n super(message);\n Object.setPrototypeOf(this, UnknownRequestException.prototype);\n }\n}\n"]}
|
|
@@ -4,7 +4,6 @@ exports.filterEvent = exports.events = void 0;
|
|
|
4
4
|
const rxjs_1 = require("rxjs");
|
|
5
5
|
const operators_1 = require("rxjs/operators");
|
|
6
6
|
const main_pb_1 = require("../protobufs/main_pb");
|
|
7
|
-
const main_pb_2 = require("../protobufs/main_pb");
|
|
8
7
|
const bindings_1 = require("./bindings");
|
|
9
8
|
const serialization_1 = require("./serialization");
|
|
10
9
|
const subscriptions = new Set();
|
|
@@ -22,10 +21,10 @@ exports.events = rxjs_1.Observable.create((observer) => {
|
|
|
22
21
|
});
|
|
23
22
|
const eventParsers = {
|
|
24
23
|
'test/event': main_pb_1.TestEvent,
|
|
25
|
-
'interface/unknown_response':
|
|
26
|
-
'binary/interface/unknown_response':
|
|
27
|
-
'interface/alert':
|
|
28
|
-
'binary/interface/reply_only':
|
|
24
|
+
'interface/unknown_response': main_pb_1.UnknownResponseEvent,
|
|
25
|
+
'binary/interface/unknown_response': main_pb_1.UnknownBinaryResponseEvent,
|
|
26
|
+
'interface/alert': main_pb_1.AlertEvent,
|
|
27
|
+
'binary/interface/reply_only': main_pb_1.BinaryReplyOnlyEvent,
|
|
29
28
|
'interface/disconnected': main_pb_1.DisconnectedEvent,
|
|
30
29
|
};
|
|
31
30
|
const eventHandler = (eventBuffer) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/gateway/events.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAC5C,8CAA6C;AAE7C,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/gateway/events.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAC5C,8CAA6C;AAE7C,kDAE8B;AAE9B,yCAAyD;AACzD,mDAA8C;AAO9C,MAAM,aAAa,GAAG,IAAI,GAAG,EAAsB,CAAC;AAEvC,QAAA,MAAM,GAAyB,iBAAU,CAAC,MAAM,CAAC,CAAC,QAA4B,EAAE,EAAE;IAC7F,IAAI,aAAa,CAAC,IAAI,KAAK,CAAC,EAAE;QAC5B,IAAA,qBAAU,GAAE,CAAC,gBAAgB,CAAC,IAAI,CAAC,CAAC;KACrC;IAED,aAAa,CAAC,GAAG,CAAC,QAAQ,CAAC,CAAC;IAE5B,OAAO,GAAG,EAAE;QACV,aAAa,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QAE/B,IAAI,aAAa,CAAC,IAAI,KAAK,C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AAE,CAAC;IAErF,KAAK,MAAM,QAAQ,IAAI,aAAa,EAAE;QACpC,QAAQ,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;KAC5B;AACH,CAAC,CAAC;AAEF,IAAA,0BAAe,EAAC,GAAG,EAAE,CAAC,IAAA,qBAAU,GAAE,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC,CAAC;AAE3D,MAAM,WAAW,GAAG,CAAI,iBAAyB,EAAE,EAAE,CAAC,CAAC,MAA4B,EAAE,EAAE,CAC5F,MAAM,CAAC,IAAI,CACT,IAAA,kBAAM,EAAC,CAAC,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,SAAS,KAAK,iBAAiB,CAAC,EAC1D,IAAA,eAAG,EAAc,CAAC,EAAE,KAAK,EAAE,EAAE,EAAE,CAAC,KAAU,CAAC,CAC5C,CAAC;AAJS,QAAA,WAAW,eAIpB","sourcesContent":["import { Message } from 'google-protobuf';\nimport { Observable, Observer } from 'rxjs';\nimport { filter, map } from 'rxjs/operators';\n\nimport {\n Event, TestEvent, DisconnectedEvent, UnknownResponseEvent, UnknownBinaryResponseEvent, AlertEvent, BinaryReplyOnlyEvent\n} from '../protobufs/main_pb';\n\nimport { addInitCallback, getBinding } from './bindings';\nimport { deserialize } from './serialization';\n\ninterface SdkEvent {\n eventType: string;\n event: unknown;\n}\n\nconst subscriptions = new Set<Observer<SdkEvent>>();\n\nexport const events: Observable<SdkEvent> = Observable.create((observer: Observer<SdkEvent>) => {\n if (subscriptions.size === 0) {\n getBinding().setEventsEnabled(true);\n }\n\n subscriptions.add(observer);\n\n return () => {\n subscriptions.delete(observer);\n\n if (subscriptions.size === 0) {\n getBinding().setEventsEnabled(false);\n }\n };\n});\n\nconst eventParsers: { [event: string]: { deserializeBinary(buffer: Uint8Array): Message } } = {\n 'test/event': TestEvent,\n 'interface/unknown_response': UnknownResponseEvent,\n 'binary/interface/unknown_response': UnknownBinaryResponseEvent,\n 'interface/alert': AlertEvent,\n 'binary/interface/reply_only': BinaryReplyOnlyEvent,\n 'interface/disconnected': DisconnectedEvent,\n};\n\nconst eventHandler = (eventBuffer: Buffer) => {\n const structBuffers = deserialize(eventBuffer);\n const event = Event.deserializeBinary(structBuffers[0]);\n const eventData = structBuffers[1] || null;\n\n const eventName = event.getEvent();\n /* istanbul ignore if */\n if (!(eventName in eventParsers)) {\n throw new Error(`Unknown event: ${eventName}`);\n }\n const eventParser = eventParsers[eventName] || null;\n\n /* istanbul ignore if */\n if (!eventParser !== !eventData) {\n throw new Error(`Event data ignored or parser not provided for ${eventName}`);\n }\n\n let eventDataProto: Record<string, unknown> | null = null;\n if (eventData) {\n eventDataProto = eventParser.deserializeBinary(eventData).toObject();\n }\n\n const eventObject: SdkEvent = { eventType: event.getEvent(), event: eventDataProto };\n\n for (const observer of subscriptions) {\n observer.next(eventObject);\n }\n};\n\naddInitCallback(() => getBinding().setEventHandler(eventHandler));\n\nexport const filterEvent = <T>(eventTypeToFilter: string) => (source: Observable<SdkEvent>) =>\n source.pipe(\n filter(({ eventType }) => eventType === eventTypeToFilter),\n map<SdkEvent, T>(({ event }) => event as T)\n );\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../../src/gateway/serialization.ts"],"names":[],"mappings":";;;AAEA,MAAM,cAAc,GAAG,CAAC,CAAC,CAAC,SAAS;AAE5B,MAAM,SAAS,GAAG,CAAC,GAAG,QAAyC,EAAE,EAAE;IACxE,MAAM,OAAO,GAAa,EAAE,CAAC;IAE7B,IAAI,IAAI,GAAG,cAAc,CAAC,CAAC,eAAe;IAC1C,KAAK,MAAM,OAAO,IAAI,QAAQ,CAAC,MAAM,CAAC,kBAAkB,CAAC,EAAE,CAAC,kBAAkB,CAAC,EAAE;QAC/E,MAAM,KAAK,GAAG,OAAQ,CAAC,eAAe,EAAE,CAAC;QACzC,OAAO,CAAC,IAAI,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;QACjC,IAAI,IAAI,cAAc,GAAG,KAAK,CAAC,MAAM,CAAC,CAAC,qBAAqB;KAC7D;IAED,MAAM,MAAM,GAAG,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;IAClC,IAAI,MAAM,GAAG,CAAC,CAAC;IAEf,MAAM,CAAC,aAAa,CAAC,IAAI,EAAE,MAAM,CAAC,CAAC;IACnC,MAAM,IAAI,cAAc,CAAC;IAEzB,KAAK,MAAM,OAAO,IAAI,OAAO,EAAE;QAC7B,MAAM,CAAC,aAAa,CAAC,OAAO,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7C,MAAM,IAAI,cAAc,CAAC;QAEzB,OAAO,CAAC,IAAI,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QAC7B,MAAM,IAAI,OAAO,CAAC,MAAM,CAAC;KAC1B;IAED,OAAO,MAAM,CAAC;AAChB,CAAC,CAAC;AAzBW,QAAA,SAAS,aAyBpB;AAEK,MAAM,WAAW,GAAG,CAAC,MAAc,EAAE,EAAE;IAC5C,IAAI,MAAM,GAAG,cAAc,CAAC;IAC5B,MAAM,OAAO,GAAa,EAAE,CAAC;IAC7B,OAAO,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE;QAC7B,MAAM,IAAI,GAAG,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,IAAI,cAAc,CAAC;QAEzB,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3B,MAAM,IAAI,IAAI,CAAC;KAChB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAbW,QAAA,WAAW,eAatB","sourcesContent":["export interface Serializable { serializeBinary(): Uint8Array
|
|
1
|
+
{"version":3,"file":"serialization.js","sourceRoot":"","sources":["../../../src/gateway/serialization.ts"],"names":[],"mappings":";;;AAEA,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,CAAC,MAAM,CAAC,CAAC;QACzC,MAAM,IAAI,cAAc,CAAC;QAEzB,MAAM,YAAY,GAAG,MAAM,CAAC,KAAK,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC,CAAC;QACzD,OAAO,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3B,MAAM,IAAI,IAAI,CAAC;KAChB;IACD,OAAO,OAAO,CAAC;AACjB,CAAC,CAAC;AAbW,QAAA,WAAW,eAatB","sourcesContent":["export interface Serializable { serializeBinary(): Uint8Array }\n\nconst SIZE_TYPE_SIZE = 4; // uint32\n\nexport const serialize = (...messages: Array<Serializable | undefined>) => {\n const buffers: Buffer[] = [];\n\n let size = SIZE_TYPE_SIZE; // total length\n for (const message of messages.filter(mesasgeOrUndefined => mesasgeOrUndefined)) {\n const bytes = message!.serializeBinary();\n buffers.push(Buffer.from(bytes));\n size += SIZE_TYPE_SIZE + bytes.length; // length + structure\n }\n\n const buffer = Buffer.alloc(size);\n let offset = 0;\n\n buffer.writeUInt32LE(size, offset);\n offset += SIZE_TYPE_SIZE;\n\n for (const message of buffers) {\n buffer.writeUInt32LE(message.length, offset);\n offset += SIZE_TYPE_SIZE;\n\n message.copy(buffer, offset);\n offset += message.length;\n }\n\n return buffer;\n};\n\nexport const deserialize = (buffer: Buffer) => {\n let offset = SIZE_TYPE_SIZE;\n const buffers: Buffer[] = [];\n while (offset < buffer.length) {\n const size = buffer.readUInt32LE(offset);\n offset += SIZE_TYPE_SIZE;\n\n const structBuffer = buffer.slice(offset, offset + size);\n buffers.push(structBuffer);\n\n offset += size;\n }\n return buffers;\n};\n"]}
|
|
@@ -7,6 +7,7 @@ import { Angle, Length, Native, AngularVelocity, Velocity } from '../units';
|
|
|
7
7
|
* Represents an offline G-Code translator.
|
|
8
8
|
* It allows to translate G-Code blocks to Zaber ASCII protocol stream commands.
|
|
9
9
|
* This translator does not need a connected device to perform translation.
|
|
10
|
+
* Requires at least Firmware 7.11.
|
|
10
11
|
*/
|
|
11
12
|
export declare class OfflineTranslator {
|
|
12
13
|
/**
|
|
@@ -24,7 +25,7 @@ export declare class OfflineTranslator {
|
|
|
24
25
|
* @param definition Definition of device and its peripherals.
|
|
25
26
|
* The definition must match a device that later performs the commands.
|
|
26
27
|
* @param config? Configuration of the translator.
|
|
27
|
-
* @
|
|
28
|
+
* @returns New instance of translator.
|
|
28
29
|
*/
|
|
29
30
|
static setup(definition: DeviceDefinition, config?: TranslatorConfig): Promise<OfflineTranslator>;
|
|
30
31
|
/**
|
|
@@ -33,19 +34,19 @@ export declare class OfflineTranslator {
|
|
|
33
34
|
* @param axes Axis numbers that are later used to setup the stream.
|
|
34
35
|
* For a lockstep group specify only the first axis of the group.
|
|
35
36
|
* @param config? Configuration of the translator.
|
|
36
|
-
* @
|
|
37
|
+
* @returns New instance of translator.
|
|
37
38
|
*/
|
|
38
39
|
static setupFromDevice(device: Device, axes: number[], config?: TranslatorConfig): Promise<OfflineTranslator>;
|
|
39
40
|
/**
|
|
40
41
|
* Translates a single block (line) of G-code.
|
|
41
42
|
* @param block Block (line) of G-code.
|
|
42
|
-
* @
|
|
43
|
+
* @returns Result of translation containing the stream commands.
|
|
43
44
|
*/
|
|
44
45
|
translate(block: string): TranslateResult;
|
|
45
46
|
/**
|
|
46
47
|
* Flushes the remaining stream commands waiting in optimization buffer.
|
|
47
48
|
* The flush is also performed by M2 and M30 codes.
|
|
48
|
-
* @
|
|
49
|
+
* @returns The remaining stream commands.
|
|
49
50
|
*/
|
|
50
51
|
flush(): string[];
|
|
51
52
|
/**
|
|
@@ -68,7 +69,7 @@ export declare class OfflineTranslator {
|
|
|
68
69
|
* This method does not query device but returns value from translator's state.
|
|
69
70
|
* @param axis Letter of the axis.
|
|
70
71
|
* @param unit Units of position.
|
|
71
|
-
* @
|
|
72
|
+
* @returns Position of translator's axis.
|
|
72
73
|
*/
|
|
73
74
|
getAxisPosition(axis: string, unit: Length | Angle | Native): number;
|
|
74
75
|
/**
|
|
@@ -92,7 +93,7 @@ export declare class OfflineTranslator {
|
|
|
92
93
|
* @param coordinateSystem Coordinate system (e.g. G54).
|
|
93
94
|
* @param axis Letter of the axis.
|
|
94
95
|
* @param unit Units of position.
|
|
95
|
-
* @
|
|
96
|
+
* @returns Offset in translator units of the axis.
|
|
96
97
|
*/
|
|
97
98
|
getAxisCoordinateSystemOffset(coordinateSystem: string, axis: string, unit: Length | Angle | Native): number;
|
|
98
99
|
/**
|
|
@@ -112,7 +113,7 @@ export declare class OfflineTranslator {
|
|
|
112
113
|
private static _free;
|
|
113
114
|
/**
|
|
114
115
|
* Gets current coordinate system (e.g. G54).
|
|
115
|
-
* @
|
|
116
|
+
* @returns Current coordinate system.
|
|
116
117
|
*/
|
|
117
118
|
private _getCurrentCoordinateSystem;
|
|
118
119
|
/**
|
|
@@ -35,6 +35,7 @@ const finalizer_1 = require("../finalizer");
|
|
|
35
35
|
* Represents an offline G-Code translator.
|
|
36
36
|
* It allows to translate G-Code blocks to Zaber ASCII protocol stream commands.
|
|
37
37
|
* This translator does not need a connected device to perform translation.
|
|
38
|
+
* Requires at least Firmware 7.11.
|
|
38
39
|
*/
|
|
39
40
|
class OfflineTranslator {
|
|
40
41
|
/**
|
|
@@ -58,7 +59,7 @@ class OfflineTranslator {
|
|
|
58
59
|
* @param definition Definition of device and its peripherals.
|
|
59
60
|
* The definition must match a device that later performs the commands.
|
|
60
61
|
* @param config? Configuration of the translator.
|
|
61
|
-
* @
|
|
62
|
+
* @returns New instance of translator.
|
|
62
63
|
*/
|
|
63
64
|
static async setup(definition, config) {
|
|
64
65
|
const request = new gateway.TranslatorCreateRequest();
|
|
@@ -73,7 +74,7 @@ class OfflineTranslator {
|
|
|
73
74
|
* @param axes Axis numbers that are later used to setup the stream.
|
|
74
75
|
* For a lockstep group specify only the first axis of the group.
|
|
75
76
|
* @param config? Configuration of the translator.
|
|
76
|
-
* @
|
|
77
|
+
* @returns New instance of translator.
|
|
77
78
|
*/
|
|
78
79
|
static async setupFromDevice(device, axes, config) {
|
|
79
80
|
const request = new gateway.TranslatorCreateFromDeviceRequest();
|
|
@@ -87,7 +88,7 @@ class OfflineTranslator {
|
|
|
87
88
|
/**
|
|
88
89
|
* Translates a single block (line) of G-code.
|
|
89
90
|
* @param block Block (line) of G-code.
|
|
90
|
-
* @
|
|
91
|
+
* @returns Result of translation containing the stream commands.
|
|
91
92
|
*/
|
|
92
93
|
translate(block) {
|
|
93
94
|
const request = new gateway.TranslatorTranslateRequest();
|
|
@@ -99,7 +100,7 @@ class OfflineTranslator {
|
|
|
99
100
|
/**
|
|
100
101
|
* Flushes the remaining stream commands waiting in optimization buffer.
|
|
101
102
|
* The flush is also performed by M2 and M30 codes.
|
|
102
|
-
* @
|
|
103
|
+
* @returns The remaining stream commands.
|
|
103
104
|
*/
|
|
104
105
|
flush() {
|
|
105
106
|
const request = new gateway.TranslatorEmptyRequest();
|
|
@@ -140,7 +141,7 @@ class OfflineTranslator {
|
|
|
140
141
|
* This method does not query device but returns value from translator's state.
|
|
141
142
|
* @param axis Letter of the axis.
|
|
142
143
|
* @param unit Units of position.
|
|
143
|
-
* @
|
|
144
|
+
* @returns Position of translator's axis.
|
|
144
145
|
*/
|
|
145
146
|
getAxisPosition(axis, unit) {
|
|
146
147
|
const request = new gateway.TranslatorGetAxisPositionRequest();
|
|
@@ -185,7 +186,7 @@ class OfflineTranslator {
|
|
|
185
186
|
* @param coordinateSystem Coordinate system (e.g. G54).
|
|
186
187
|
* @param axis Letter of the axis.
|
|
187
188
|
* @param unit Units of position.
|
|
188
|
-
* @
|
|
189
|
+
* @returns Offset in translator units of the axis.
|
|
189
190
|
*/
|
|
190
191
|
getAxisCoordinateSystemOffset(coordinateSystem, axis, unit) {
|
|
191
192
|
const request = new gateway.TranslatorGetAxisOffsetRequest();
|
|
@@ -226,7 +227,7 @@ class OfflineTranslator {
|
|
|
226
227
|
}
|
|
227
228
|
/**
|
|
228
229
|
* Gets current coordinate system (e.g. G54).
|
|
229
|
-
* @
|
|
230
|
+
* @returns Current coordinate system.
|
|
230
231
|
*/
|
|
231
232
|
_getCurrentCoordinateSystem() {
|
|
232
233
|
const request = new gateway.TranslatorEmptyRequest();
|
|
@@ -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;;;;GAIG;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,OAAO,CAAC,wBAAwB,CAAC,CAAC;QACpC,OAAO,IAAI,iBAAiB,CAAC,QAAQ,CAAC,eAAe,EAAE,CAAC,CAAC;IAC3D,CAAC;I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AAC,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 */\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 * @return 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 * @return 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 * @return 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 * @return 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 * @return 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 * @return 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 * @return 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"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ROM 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"]}
|
|
@@ -6,6 +6,7 @@ import { Angle, Length, Native, AngularVelocity, Velocity } from '../units';
|
|
|
6
6
|
* Represents a live G-Code translator.
|
|
7
7
|
* It allows to stream G-Code blocks to a connected device.
|
|
8
8
|
* It requires a stream to be setup on the device.
|
|
9
|
+
* Requires at least Firmware 7.11.
|
|
9
10
|
*/
|
|
10
11
|
export declare class Translator {
|
|
11
12
|
/**
|
|
@@ -23,7 +24,7 @@ export declare class Translator {
|
|
|
23
24
|
* @param stream The stream to setup the translator on.
|
|
24
25
|
* The stream must be already setup in a live or a store mode.
|
|
25
26
|
* @param config? Configuration of the translator.
|
|
26
|
-
* @
|
|
27
|
+
* @returns New instance of translator.
|
|
27
28
|
*/
|
|
28
29
|
static setup(stream: Stream, config?: TranslatorConfig): Promise<Translator>;
|
|
29
30
|
/**
|
|
@@ -31,16 +32,16 @@ export declare class Translator {
|
|
|
31
32
|
* The commands are queued in the underlying stream to ensure smooth continues movement.
|
|
32
33
|
* Returning of this method indicates that the commands are queued (not necessarily executed).
|
|
33
34
|
* @param block Block (line) of G-code.
|
|
34
|
-
* @
|
|
35
|
+
* @returns Result of translation containing the commands sent to the device.
|
|
35
36
|
*/
|
|
36
37
|
translate(block: string): Promise<TranslateResult>;
|
|
37
38
|
/**
|
|
38
39
|
* Flushes the remaining stream commands waiting in optimization buffer into the underlying stream.
|
|
39
40
|
* The flush is also performed by M2 and M30 codes.
|
|
40
|
-
* @param waitUntilIdle Determines whether to wait for the stream to finish all the movements.
|
|
41
|
-
* @
|
|
41
|
+
* @param [options.waitUntilIdle=true] Determines whether to wait for the stream to finish all the movements.
|
|
42
|
+
* @returns The remaining stream commands.
|
|
42
43
|
*/
|
|
43
|
-
flush(
|
|
44
|
+
flush(options?: Translator.FlushOptions): Promise<string[]>;
|
|
44
45
|
/**
|
|
45
46
|
* Resets position of the translator from the underlying stream.
|
|
46
47
|
* Call this method after performing a movement outside of translator.
|
|
@@ -66,7 +67,7 @@ export declare class Translator {
|
|
|
66
67
|
* This method does not query device but returns value from translator's state.
|
|
67
68
|
* @param axis Letter of the axis.
|
|
68
69
|
* @param unit Units of position.
|
|
69
|
-
* @
|
|
70
|
+
* @returns Position of translator's axis.
|
|
70
71
|
*/
|
|
71
72
|
getAxisPosition(axis: string, unit: Length | Angle | Native): number;
|
|
72
73
|
/**
|
|
@@ -90,7 +91,7 @@ export declare class Translator {
|
|
|
90
91
|
* @param coordinateSystem Coordinate system (e.g. G54).
|
|
91
92
|
* @param axis Letter of the axis.
|
|
92
93
|
* @param unit Units of position.
|
|
93
|
-
* @
|
|
94
|
+
* @returns Offset in translator units of the axis.
|
|
94
95
|
*/
|
|
95
96
|
getAxisCoordinateSystemOffset(coordinateSystem: string, axis: string, unit: Length | Angle | Native): number;
|
|
96
97
|
/**
|
|
@@ -110,7 +111,7 @@ export declare class Translator {
|
|
|
110
111
|
private static _free;
|
|
111
112
|
/**
|
|
112
113
|
* Gets current coordinate system (e.g. G54).
|
|
113
|
-
* @
|
|
114
|
+
* @returns Current coordinate system.
|
|
114
115
|
*/
|
|
115
116
|
private _getCurrentCoordinateSystem;
|
|
116
117
|
/**
|
|
@@ -120,3 +121,9 @@ export declare class Translator {
|
|
|
120
121
|
*/
|
|
121
122
|
free(): void;
|
|
122
123
|
}
|
|
124
|
+
declare namespace Translator {
|
|
125
|
+
interface FlushOptions {
|
|
126
|
+
waitUntilIdle?: boolean;
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
export {};
|
|
@@ -34,6 +34,7 @@ const finalizer_1 = require("../finalizer");
|
|
|
34
34
|
* Represents a live G-Code translator.
|
|
35
35
|
* It allows to stream G-Code blocks to a connected device.
|
|
36
36
|
* It requires a stream to be setup on the device.
|
|
37
|
+
* Requires at least Firmware 7.11.
|
|
37
38
|
*/
|
|
38
39
|
class Translator {
|
|
39
40
|
/**
|
|
@@ -57,7 +58,7 @@ class Translator {
|
|
|
57
58
|
* @param stream The stream to setup the translator on.
|
|
58
59
|
* The stream must be already setup in a live or a store mode.
|
|
59
60
|
* @param config? Configuration of the translator.
|
|
60
|
-
* @
|
|
61
|
+
* @returns New instance of translator.
|
|
61
62
|
*/
|
|
62
63
|
static async setup(stream, config) {
|
|
63
64
|
const request = new gateway.TranslatorCreateLiveRequest();
|
|
@@ -73,7 +74,7 @@ class Translator {
|
|
|
73
74
|
* The commands are queued in the underlying stream to ensure smooth continues movement.
|
|
74
75
|
* Returning of this method indicates that the commands are queued (not necessarily executed).
|
|
75
76
|
* @param block Block (line) of G-code.
|
|
76
|
-
* @
|
|
77
|
+
* @returns Result of translation containing the commands sent to the device.
|
|
77
78
|
*/
|
|
78
79
|
async translate(block) {
|
|
79
80
|
const request = new gateway.TranslatorTranslateRequest();
|
|
@@ -85,10 +86,11 @@ class Translator {
|
|
|
85
86
|
/**
|
|
86
87
|
* Flushes the remaining stream commands waiting in optimization buffer into the underlying stream.
|
|
87
88
|
* The flush is also performed by M2 and M30 codes.
|
|
88
|
-
* @param waitUntilIdle Determines whether to wait for the stream to finish all the movements.
|
|
89
|
-
* @
|
|
89
|
+
* @param [options.waitUntilIdle=true] Determines whether to wait for the stream to finish all the movements.
|
|
90
|
+
* @returns The remaining stream commands.
|
|
90
91
|
*/
|
|
91
|
-
async flush(
|
|
92
|
+
async flush(options = {}) {
|
|
93
|
+
const { waitUntilIdle = true, } = options;
|
|
92
94
|
const request = new gateway.TranslatorFlushLiveRequest();
|
|
93
95
|
request.setTranslatorId(this.translatorId);
|
|
94
96
|
request.setWaitUntilIdle(waitUntilIdle);
|
|
@@ -137,7 +139,7 @@ class Translator {
|
|
|
137
139
|
* This method does not query device but returns value from translator's state.
|
|
138
140
|
* @param axis Letter of the axis.
|
|
139
141
|
* @param unit Units of position.
|
|
140
|
-
* @
|
|
142
|
+
* @returns Position of translator's axis.
|
|
141
143
|
*/
|
|
142
144
|
getAxisPosition(axis, unit) {
|
|
143
145
|
const request = new gateway.TranslatorGetAxisPositionRequest();
|
|
@@ -182,7 +184,7 @@ class Translator {
|
|
|
182
184
|
* @param coordinateSystem Coordinate system (e.g. G54).
|
|
183
185
|
* @param axis Letter of the axis.
|
|
184
186
|
* @param unit Units of position.
|
|
185
|
-
* @
|
|
187
|
+
* @returns Offset in translator units of the axis.
|
|
186
188
|
*/
|
|
187
189
|
getAxisCoordinateSystemOffset(coordinateSystem, axis, unit) {
|
|
188
190
|
const request = new gateway.TranslatorGetAxisOffsetRequest();
|
|
@@ -223,7 +225,7 @@ class Translator {
|
|
|
223
225
|
}
|
|
224
226
|
/**
|
|
225
227
|
* Gets current coordinate system (e.g. G54).
|
|
226
|
-
* @
|
|
228
|
+
* @returns Current coordinate system.
|
|
227
229
|
*/
|
|
228
230
|
_getCurrentCoordinateSystem() {
|
|
229
231
|
const request = new gateway.TranslatorEmptyRequest();
|
|
@@ -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;;;;GAIG;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,CAAC,WAAW,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;QACrC,OAAO,CAAC,S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C,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;CACF;AA/RD,gCA+RC","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 */\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 * @return 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 * @return 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 waitUntilIdle Determines whether to wait for the stream to finish all the movements.\n * @return The remaining stream commands.\n */\n public async flush(\n waitUntilIdle: boolean = true\n ): Promise<string[]> {\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 * @return 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 * @return 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 * @return 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"]}
|
|
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;;;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D,CAAC;IAED;;;OAGG;IACI,mBAAmB,CACxB,WAAmB;QAEnB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,oCAAoC,EAAE,CAAC;QACnE,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAC3C,OAAO,CAAC,cAAc,CAAC,WAAW,CAAC,CAAC;QAEpC,OAAO,CAAC,QAAQ,CAAC,8BAA8B,EAAE,OAAO,CAAC,CAAC;IAC5D,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,KAAK,CAClB,YAAoB;QAEpB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,sBAAsB,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"]}
|