@zaber/motion 2.15.4 → 3.0.1

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.
Files changed (126) hide show
  1. package/dist/binding/wasm/zaber-motion-lib.wasm +0 -0
  2. package/dist/lib/ascii/all_axes.d.ts +21 -9
  3. package/dist/lib/ascii/all_axes.js +12 -9
  4. package/dist/lib/ascii/all_axes.js.map +1 -1
  5. package/dist/lib/ascii/axis.d.ts +116 -58
  6. package/dist/lib/ascii/axis.js +74 -58
  7. package/dist/lib/ascii/axis.js.map +1 -1
  8. package/dist/lib/ascii/axis_settings.d.ts +11 -10
  9. package/dist/lib/ascii/axis_settings.js +11 -10
  10. package/dist/lib/ascii/axis_settings.js.map +1 -1
  11. package/dist/lib/ascii/connection.d.ts +91 -68
  12. package/dist/lib/ascii/connection.js +60 -86
  13. package/dist/lib/ascii/connection.js.map +1 -1
  14. package/dist/lib/ascii/device.d.ts +46 -25
  15. package/dist/lib/ascii/device.js +31 -25
  16. package/dist/lib/ascii/device.js.map +1 -1
  17. package/dist/lib/ascii/device_io.d.ts +9 -9
  18. package/dist/lib/ascii/device_io.js +9 -9
  19. package/dist/lib/ascii/device_io.js.map +1 -1
  20. package/dist/lib/ascii/device_settings.d.ts +10 -10
  21. package/dist/lib/ascii/device_settings.js +10 -10
  22. package/dist/lib/ascii/device_settings.js.map +1 -1
  23. package/dist/lib/ascii/lockstep.d.ts +99 -49
  24. package/dist/lib/ascii/lockstep.js +63 -49
  25. package/dist/lib/ascii/lockstep.js.map +1 -1
  26. package/dist/lib/ascii/oscilloscope.d.ts +14 -13
  27. package/dist/lib/ascii/oscilloscope.js +14 -13
  28. package/dist/lib/ascii/oscilloscope.js.map +1 -1
  29. package/dist/lib/ascii/oscilloscope_data.d.ts +9 -9
  30. package/dist/lib/ascii/oscilloscope_data.js +9 -9
  31. package/dist/lib/ascii/oscilloscope_data.js.map +1 -1
  32. package/dist/lib/ascii/servo_tuner.d.ts +20 -10
  33. package/dist/lib/ascii/servo_tuner.js +13 -10
  34. package/dist/lib/ascii/servo_tuner.js.map +1 -1
  35. package/dist/lib/ascii/setting_constants.d.ts +2 -2
  36. package/dist/lib/ascii/setting_constants.js +2 -2
  37. package/dist/lib/ascii/setting_constants.js.map +1 -1
  38. package/dist/lib/ascii/storage.d.ts +49 -24
  39. package/dist/lib/ascii/storage.js +32 -24
  40. package/dist/lib/ascii/storage.js.map +1 -1
  41. package/dist/lib/ascii/stream.d.ts +29 -17
  42. package/dist/lib/ascii/stream.js +24 -17
  43. package/dist/lib/ascii/stream.js.map +1 -1
  44. package/dist/lib/ascii/stream_buffer.d.ts +1 -1
  45. package/dist/lib/ascii/stream_buffer.js +1 -1
  46. package/dist/lib/ascii/stream_buffer.js.map +1 -1
  47. package/dist/lib/ascii/transport.d.ts +2 -2
  48. package/dist/lib/ascii/transport.js +2 -2
  49. package/dist/lib/ascii/transport.js.map +1 -1
  50. package/dist/lib/ascii/warnings.d.ts +2 -2
  51. package/dist/lib/ascii/warnings.js +2 -2
  52. package/dist/lib/ascii/warnings.js.map +1 -1
  53. package/dist/lib/binary/connection.d.ts +46 -25
  54. package/dist/lib/binary/connection.js +30 -25
  55. package/dist/lib/binary/connection.js.map +1 -1
  56. package/dist/lib/binary/device.d.ts +66 -38
  57. package/dist/lib/binary/device.js +48 -38
  58. package/dist/lib/binary/device.js.map +1 -1
  59. package/dist/lib/binary/device_identity.d.ts +1 -0
  60. package/dist/lib/binary/device_identity.js.map +1 -1
  61. package/dist/lib/binary/device_settings.d.ts +3 -3
  62. package/dist/lib/binary/device_settings.js +3 -3
  63. package/dist/lib/binary/device_settings.js.map +1 -1
  64. package/dist/lib/exceptions/binary_command_failed_exception.js.map +1 -1
  65. package/dist/lib/exceptions/command_failed_exception.js.map +1 -1
  66. package/dist/lib/exceptions/command_preempted_exception.js.map +1 -1
  67. package/dist/lib/exceptions/command_too_long_exception.js.map +1 -1
  68. package/dist/lib/exceptions/connection_closed_exception.js.map +1 -1
  69. package/dist/lib/exceptions/connection_failed_exception.js.map +1 -1
  70. package/dist/lib/exceptions/conversion_failed_exception.js.map +1 -1
  71. package/dist/lib/exceptions/device_address_conflict_exception.js.map +1 -1
  72. package/dist/lib/exceptions/device_busy_exception.js.map +1 -1
  73. package/dist/lib/exceptions/device_db_failed_exception.js.map +1 -1
  74. package/dist/lib/exceptions/device_failed_exception.js.map +1 -1
  75. package/dist/lib/exceptions/device_not_identified_exception.js.map +1 -1
  76. package/dist/lib/exceptions/g_code_execution_exception.js.map +1 -1
  77. package/dist/lib/exceptions/g_code_syntax_exception.js.map +1 -1
  78. package/dist/lib/exceptions/internal_error_exception.js.map +1 -1
  79. package/dist/lib/exceptions/invalid_argument_exception.js.map +1 -1
  80. package/dist/lib/exceptions/invalid_data_exception.js.map +1 -1
  81. package/dist/lib/exceptions/invalid_operation_exception.js.map +1 -1
  82. package/dist/lib/exceptions/invalid_packet_exception.js.map +1 -1
  83. package/dist/lib/exceptions/invalid_park_state_exception.js.map +1 -1
  84. package/dist/lib/exceptions/invalid_response_exception.js.map +1 -1
  85. package/dist/lib/exceptions/io_channel_out_of_range_exception.js.map +1 -1
  86. package/dist/lib/exceptions/io_failed_exception.js.map +1 -1
  87. package/dist/lib/exceptions/lockstep_enabled_exception.js.map +1 -1
  88. package/dist/lib/exceptions/lockstep_not_enabled_exception.js.map +1 -1
  89. package/dist/lib/exceptions/motion_lib_exception.js.map +1 -1
  90. package/dist/lib/exceptions/movement_failed_exception.js.map +1 -1
  91. package/dist/lib/exceptions/movement_interrupted_exception.js.map +1 -1
  92. package/dist/lib/exceptions/no_device_found_exception.js.map +1 -1
  93. package/dist/lib/exceptions/no_value_for_key_exception.js.map +1 -1
  94. package/dist/lib/exceptions/not_supported_exception.js.map +1 -1
  95. package/dist/lib/exceptions/os_failed_exception.js.map +1 -1
  96. package/dist/lib/exceptions/out_of_request_ids_exception.js.map +1 -1
  97. package/dist/lib/exceptions/request_timeout_exception.js.map +1 -1
  98. package/dist/lib/exceptions/serial_port_busy_exception.js.map +1 -1
  99. package/dist/lib/exceptions/set_device_state_failed_exception.js.map +1 -1
  100. package/dist/lib/exceptions/set_peripheral_state_failed_exception.js.map +1 -1
  101. package/dist/lib/exceptions/setting_not_found_exception.js.map +1 -1
  102. package/dist/lib/exceptions/stream_execution_exception.js.map +1 -1
  103. package/dist/lib/exceptions/stream_mode_exception.js.map +1 -1
  104. package/dist/lib/exceptions/stream_movement_failed_exception.js.map +1 -1
  105. package/dist/lib/exceptions/stream_movement_interrupted_exception.js.map +1 -1
  106. package/dist/lib/exceptions/stream_setup_failed_exception.js.map +1 -1
  107. package/dist/lib/exceptions/transport_already_used_exception.js.map +1 -1
  108. package/dist/lib/exceptions/unknown_request_exception.js.map +1 -1
  109. package/dist/lib/gateway/events.js +4 -5
  110. package/dist/lib/gateway/events.js.map +1 -1
  111. package/dist/lib/gateway/serialization.js.map +1 -1
  112. package/dist/lib/gcode/offline_translator.d.ts +8 -7
  113. package/dist/lib/gcode/offline_translator.js +8 -7
  114. package/dist/lib/gcode/offline_translator.js.map +1 -1
  115. package/dist/lib/gcode/translator.d.ts +15 -8
  116. package/dist/lib/gcode/translator.js +10 -8
  117. package/dist/lib/gcode/translator.js.map +1 -1
  118. package/dist/lib/library.d.ts +3 -3
  119. package/dist/lib/library.js +3 -3
  120. package/dist/lib/library.js.map +1 -1
  121. package/dist/lib/tools.d.ts +3 -3
  122. package/dist/lib/tools.js +3 -3
  123. package/dist/lib/tools.js.map +1 -1
  124. package/dist/lib/wasm.js +1 -3
  125. package/dist/lib/wasm.js.map +1 -1
  126. package/package.json +3 -3
@@ -52,12 +52,13 @@ class Connection {
52
52
  /**
53
53
  * Opens a serial port.
54
54
  * @param portName Name of the port to open.
55
- * @param baudRate Optional baud rate (defaults to 9600).
56
- * @param useMessageIds Enable use of message IDs (defaults to disabled).
55
+ * @param [options.baudRate=Connection.DEFAULT_BAUD_RATE] Optional baud rate (defaults to 9600).
56
+ * @param [options.useMessageIds=false] Enable use of message IDs (defaults to disabled).
57
57
  * All your devices must be pre-configured to match.
58
- * @return An object representing the port.
58
+ * @returns An object representing the port.
59
59
  */
60
- static async openSerialPort(portName, baudRate = Connection.DEFAULT_BAUD_RATE, useMessageIds = false) {
60
+ static async openSerialPort(portName, options = {}) {
61
+ const { baudRate = Connection.DEFAULT_BAUD_RATE, useMessageIds = false, } = options;
61
62
  const request = new gateway.OpenBinaryInterfaceRequest();
62
63
  request.setInterfaceType(gateway.InterfaceType.SERIAL_PORT);
63
64
  request.setPortName(portName);
@@ -69,12 +70,13 @@ class Connection {
69
70
  /**
70
71
  * Opens a TCP connection.
71
72
  * @param hostName Hostname or IP address.
72
- * @param port Optional port number (defaults to 8657).
73
- * @param useMessageIds Enable use of message IDs (defaults to disabled).
73
+ * @param port Port number.
74
+ * @param [options.useMessageIds=false] Enable use of message IDs (defaults to disabled).
74
75
  * All your devices must be pre-configured to match.
75
- * @return An object representing the connection.
76
+ * @returns An object representing the connection.
76
77
  */
77
- static async openTcp(hostName, port = 0, useMessageIds = false) {
78
+ static async openTcp(hostName, port, options = {}) {
79
+ const { useMessageIds = false, } = options;
78
80
  const request = new gateway.OpenBinaryInterfaceRequest();
79
81
  request.setInterfaceType(gateway.InterfaceType.TCP);
80
82
  request.setHostName(hostName);
@@ -97,12 +99,13 @@ class Connection {
97
99
  * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
98
100
  * @param device Device address to send the command to. Use zero for broadcast.
99
101
  * @param command Command to send.
100
- * @param data Optional data argument to the command. Defaults to zero.
101
- * @param timeout Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
102
- * @param checkErrors Controls whether to throw an exception when the device rejects the command.
103
- * @return A response to the command.
102
+ * @param [data=0] Optional data argument to the command. Defaults to zero.
103
+ * @param [options.timeout=0.0] Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
104
+ * @param [options.checkErrors=true] Controls whether to throw an exception when the device rejects the command.
105
+ * @returns A response to the command.
104
106
  */
105
- async genericCommand(device, command, data = 0, timeout = 0.0, checkErrors = true) {
107
+ async genericCommand(device, command, data = 0, options = {}) {
108
+ const { timeout = 0.0, checkErrors = true, } = options;
106
109
  const request = new gateway.GenericBinaryRequest();
107
110
  request.setInterfaceId(this.interfaceId);
108
111
  request.setDevice(device);
@@ -119,7 +122,7 @@ class Connection {
119
122
  * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
120
123
  * @param device Device address to send the command to. Use zero for broadcast.
121
124
  * @param command Command to send.
122
- * @param data Optional data argument to the command. Defaults to zero.
125
+ * @param [data=0] Optional data argument to the command. Defaults to zero.
123
126
  */
124
127
  async genericCommandNoResponse(device, command, data = 0) {
125
128
  const request = new gateway.GenericBinaryRequest();
@@ -135,12 +138,13 @@ class Connection {
135
138
  * For more information please refer to the
136
139
  * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
137
140
  * @param command Command to send.
138
- * @param data Optional data argument to the command. Defaults to zero.
139
- * @param timeout Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.
140
- * @param checkErrors Controls whether to throw an exception when any device rejects the command.
141
- * @return All responses to the command.
141
+ * @param [data=0] Optional data argument to the command. Defaults to zero.
142
+ * @param [options.timeout=0.0] Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.
143
+ * @param [options.checkErrors=true] Controls whether to throw an exception when any device rejects the command.
144
+ * @returns All responses to the command.
142
145
  */
143
- async genericCommandMultiResponse(command, data = 0, timeout = 0.0, checkErrors = true) {
146
+ async genericCommandMultiResponse(command, data = 0, options = {}) {
147
+ const { timeout = 0.0, checkErrors = true, } = options;
144
148
  const request = new gateway.GenericBinaryRequest();
145
149
  request.setInterfaceId(this.interfaceId);
146
150
  request.setCommand(command);
@@ -152,7 +156,7 @@ class Connection {
152
156
  }
153
157
  /**
154
158
  * Renumbers devices present on this connection. After renumbering, you must identify devices again.
155
- * @return Total number of devices that responded to the renumber.
159
+ * @returns Total number of devices that responded to the renumber.
156
160
  */
157
161
  async renumberDevices() {
158
162
  const request = new gateway.InterfaceEmptyRequest();
@@ -162,10 +166,11 @@ class Connection {
162
166
  }
163
167
  /**
164
168
  * Attempts to detect any devices present on this connection.
165
- * @param identifyDevices Determines whether device identification should be performed as well.
166
- * @return Array of detected devices.
169
+ * @param [options.identifyDevices=true] Determines whether device identification should be performed as well.
170
+ * @returns Array of detected devices.
167
171
  */
168
- async detectDevices(identifyDevices = true) {
172
+ async detectDevices(options = {}) {
173
+ const { identifyDevices = true, } = options;
169
174
  const request = new gateway.BinaryDeviceDetectRequest();
170
175
  request.setInterfaceId(this.interfaceId);
171
176
  request.setIdentifyDevices(identifyDevices);
@@ -176,7 +181,7 @@ class Connection {
176
181
  * Gets a Device class instance which allows you to control a particular device on this connection.
177
182
  * Devices are numbered from 1.
178
183
  * @param deviceAddress Address of device intended to control. Address is configured for each device.
179
- * @return Device instance.
184
+ * @returns Device instance.
180
185
  */
181
186
  getDevice(deviceAddress) {
182
187
  if (deviceAddress <= 0) {
@@ -186,7 +191,7 @@ class Connection {
186
191
  }
187
192
  /**
188
193
  * Returns a string that represents the connection.
189
- * @return A string that represents the connection.
194
+ * @returns A string that represents the connection.
190
195
  */
191
196
  toString() {
192
197
  const request = new gateway.InterfaceEmptyRequest();
@@ -1 +1 @@
1
- {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/binary/connection.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,+BAAiD;AACjD,8CAA8D;AAC9D,oDAAsC;AACtC,wCAAiD;AACjD,qCAAkC;AAClC,qEAAgE;AAChE,yDAAoD;AAEpD,uCAAoC;AAGpC;;GAEG;AACH,MAAa,UAAU;IAiBrB;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAGD,YAAY,WAAmB;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,EAC7B,IAAA,qBAAW,EAA8C,mCAAmC,CAAC,EAC7F,IAAA,kBAAM,EAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC,EACvD,IAAA,eAAG,EAAC,KAAK,CAAC,EAAE,CAAC,6CAAoB,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CACvD,CAAC;QAEF,IAAI,CAAC,SAAS,GAAG,gBAAM,CAAC,IAAI,CAC1B,IAAA,qBAAS,EAAC,IAAI,CAAC,aAAa,CAAC,EAC7B,IAAA,qBAAW,EAAwC,6BAA6B,CAAC,EACjF,IAAA,kBAAM,EAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC,EACvD,IAAA,eAAG,EAAC,KAAK,CAAC,EAAE,CAAC,iCAAc,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CACjD,CAAC;QAEF,gBAAM,CAAC,IAAI,CACT,IAAA,qBAAW,EAAqC,wBAAwB,CAAC,EACzE,IAAA,kBAAM,EAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC,EACvD,IAAA,gBAAI,EAAC,CAAC,CAAC,EACP,IAAA,eAAG,EAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAC1F,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;;AAhRH,gCAiRC;AArQC;;GAEG;AACoB,4BAAiB,GAAW,IAAI,CAAC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { Observable, ReplaySubject } from 'rxjs';\nimport { map, filter, takeUntil, take } from 'rxjs/operators';\nimport * as gateway from '../gateway';\nimport { events, filterEvent } from '../gateway';\nimport { Device } from './device';\nimport { UnknownResponseEvent } from './unknown_response_event';\nimport { ReplyOnlyEvent } from './reply_only_event';\nimport { CommandCode } from './command_code';\nimport { Message } from './message';\nimport { MotionLibException } from '../exceptions';\n\n/**\n * Class representing access to particular connection (serial port, TCP connection) using the legacy Binary protocol.\n */\nexport class Connection {\n\n /**\n * Event invoked when a response from a device cannot be matched to any known request.\n */\n public unknownResponse!: Observable<UnknownResponseEvent>;\n\n /**\n * Event invoked when a reply-only command such as a move tracking message is received from a device.\n */\n public replyOnly!: Observable<ReplyOnlyEvent>;\n\n /**\n * Default baud rate for serial connections.\n */\n public static readonly DEFAULT_BAUD_RATE: number = 9600;\n\n /**\n * The interface ID identifies thisConnection instance with the underlying library.\n */\n public get interfaceId(): number {\n return this._interfaceId;\n }\n private _interfaceId: number;\n\n constructor(interfaceId: number) {\n this._interfaceId = interfaceId;\n this._subscribe();\n }\n\n /**\n * Opens a serial port.\n * @param portName Name of the port to open.\n * @param baudRate Optional baud rate (defaults to 9600).\n * @param useMessageIds Enable use of message IDs (defaults to disabled).\n * All your devices must be pre-configured to match.\n * @return An object representing the port.\n */\n public static async openSerialPort(\n portName: string,\n baudRate: number = Connection.DEFAULT_BAUD_RATE,\n useMessageIds: boolean = false\n ): Promise<Connection> {\n const request = new gateway.OpenBinaryInterfaceRequest();\n request.setInterfaceType(gateway.InterfaceType.SERIAL_PORT);\n request.setPortName(portName);\n request.setBaudRate(baudRate);\n request.setUseMessageIds(useMessageIds);\n\n const response = await gateway.callAsync<gateway.OpenInterfaceResponse>(\n 'binary/interface/open',\n request,\n gateway.OpenInterfaceResponse);\n return new Connection(response.getInterfaceId());\n }\n\n /**\n * Opens a TCP connection.\n * @param hostName Hostname or IP address.\n * @param port Optional port number (defaults to 8657).\n * @param useMessageIds Enable use of message IDs (defaults to disabled).\n * All your devices must be pre-configured to match.\n * @return An object representing the connection.\n */\n public static async openTcp(\n hostName: string,\n port: number = 0,\n useMessageIds: boolean = false\n ): Promise<Connection> {\n const request = new gateway.OpenBinaryInterfaceRequest();\n request.setInterfaceType(gateway.InterfaceType.TCP);\n request.setHostName(hostName);\n request.setPort(port);\n request.setUseMessageIds(useMessageIds);\n\n const response = await gateway.callAsync<gateway.OpenInterfaceResponse>(\n 'binary/interface/open',\n request,\n gateway.OpenInterfaceResponse);\n return new Connection(response.getInterfaceId());\n }\n\n /**\n * Close the connection.\n */\n public async close(): Promise<void> {\n const request = new gateway.InterfaceEmptyRequest();\n request.setInterfaceId(this.interfaceId);\n\n await gateway.callAsync('interface/close', request);\n }\n\n /**\n * Sends a generic Binary command to this connection.\n * For more information please refer to the\n * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).\n * @param device Device address to send the command to. Use zero for broadcast.\n * @param command Command to send.\n * @param data Optional data argument to the command. Defaults to zero.\n * @param timeout Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.\n * @param checkErrors Controls whether to throw an exception when the device rejects the command.\n * @return A response to the command.\n */\n public async genericCommand(\n device: number,\n command: CommandCode,\n data: number = 0,\n timeout: number = 0.0,\n checkErrors: boolean = true\n ): Promise<Message> {\n const request = new gateway.GenericBinaryRequest();\n request.setInterfaceId(this.interfaceId);\n request.setDevice(device);\n request.setCommand(command as any);\n request.setData(data);\n request.setTimeout(timeout);\n request.setCheckErrors(checkErrors);\n\n const response = await gateway.callAsync<gateway.BinaryMessage>(\n 'binary/interface/generic_command',\n request,\n gateway.BinaryMessage);\n return Message.fromProtobuf(response.toObject());\n }\n\n /**\n * Sends a generic Binary command to this connection without expecting a response.\n * For more information please refer to the\n * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).\n * @param device Device address to send the command to. Use zero for broadcast.\n * @param command Command to send.\n * @param data Optional data argument to the command. Defaults to zero.\n */\n public async genericCommandNoResponse(\n device: number,\n command: CommandCode,\n data: number = 0\n ): Promise<void> {\n const request = new gateway.GenericBinaryRequest();\n request.setInterfaceId(this.interfaceId);\n request.setDevice(device);\n request.setCommand(command as any);\n request.setData(data);\n\n await gateway.callAsync('binary/interface/generic_command_no_response', request);\n }\n\n /**\n * Sends a generic Binary command to this connection and expects responses from one or more devices.\n * Responses are returned in order of arrival.\n * For more information please refer to the\n * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).\n * @param command Command to send.\n * @param data Optional data argument to the command. Defaults to zero.\n * @param timeout Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.\n * @param checkErrors Controls whether to throw an exception when any device rejects the command.\n * @return All responses to the command.\n */\n public async genericCommandMultiResponse(\n command: CommandCode,\n data: number = 0,\n timeout: number = 0.0,\n checkErrors: boolean = true\n ): Promise<Message[]> {\n const request = new gateway.GenericBinaryRequest();\n request.setInterfaceId(this.interfaceId);\n request.setCommand(command as any);\n request.setData(data);\n request.setTimeout(timeout);\n request.setCheckErrors(checkErrors);\n\n const response = await gateway.callAsync<gateway.BinaryMessageCollection>(\n 'binary/interface/generic_command_multi_response',\n request,\n gateway.BinaryMessageCollection);\n return response.getMessagesList().map(a => Message.fromProtobuf(a.toObject()));\n }\n\n /**\n * Renumbers devices present on this connection. After renumbering, you must identify devices again.\n * @return Total number of devices that responded to the renumber.\n */\n public async renumberDevices(): Promise<number> {\n const request = new gateway.InterfaceEmptyRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = await gateway.callAsync<gateway.IntResponse>(\n 'binary/device/renumber',\n request,\n gateway.IntResponse);\n return response.getValue();\n }\n\n /**\n * Attempts to detect any devices present on this connection.\n * @param identifyDevices Determines whether device identification should be performed as well.\n * @return Array of detected devices.\n */\n public async detectDevices(\n identifyDevices: boolean = true\n ): Promise<Device[]> {\n const request = new gateway.BinaryDeviceDetectRequest();\n request.setInterfaceId(this.interfaceId);\n request.setIdentifyDevices(identifyDevices);\n\n const response = await gateway.callAsync<gateway.BinaryDeviceDetectResponse>(\n 'binary/device/detect',\n request,\n gateway.BinaryDeviceDetectResponse);\n return response.getDevicesList().map(deviceAddress => this.getDevice(deviceAddress));\n }\n\n /**\n * Gets a Device class instance which allows you to control a particular device on this connection.\n * Devices are numbered from 1.\n * @param deviceAddress Address of device intended to control. Address is configured for each device.\n * @return Device instance.\n */\n public getDevice(\n deviceAddress: number\n ): Device {\n if (deviceAddress <= 0) {\n throw new TypeError('Invalid value; physical devices are numbered from 1.');\n }\n return new Device(this, deviceAddress);\n }\n\n /**\n * Returns a string that represents the connection.\n * @return A string that represents the connection.\n */\n public toString(): string {\n const request = new gateway.InterfaceEmptyRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = gateway.callSync<gateway.StringResponse>(\n 'interface/to_string',\n request,\n gateway.StringResponse);\n return response.getValue();\n }\n\n private _disconnected = new ReplaySubject<MotionLibException>();\n\n /**\n * Event invoked when connection is interrupted or closed.\n */\n public get disconnected(): Observable<MotionLibException> {\n return this._disconnected;\n }\n\n private _subscribe(): void {\n this.unknownResponse = events.pipe(\n takeUntil(this._disconnected),\n filterEvent<gateway.UnknownBinaryResponseEvent.AsObject>('binary/interface/unknown_response'),\n filter(event => event.interfaceId === this.interfaceId),\n map(event => UnknownResponseEvent.fromProtobuf(event))\n );\n\n this.replyOnly = events.pipe(\n takeUntil(this._disconnected),\n filterEvent<gateway.BinaryReplyOnlyEvent.AsObject>('binary/interface/reply_only'),\n filter(event => event.interfaceId === this.interfaceId),\n map(event => ReplyOnlyEvent.fromProtobuf(event))\n );\n\n events.pipe(\n filterEvent<gateway.DisconnectedEvent.AsObject>('interface/disconnected'),\n filter(event => event.interfaceId === this.interfaceId),\n take(1),\n map(({ errorMessage, errorType }) => gateway.convertToException(errorType, errorMessage))\n ).subscribe(this._disconnected);\n }\n}\n"]}
1
+ {"version":3,"file":"connection.js","sourceRoot":"","sources":["../../../src/binary/connection.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;;;;;AAEtD,+BAAiD;AACjD,8CAA8D;AA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CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC,EACvD,IAAA,gBAAI,EAAC,CAAC,CAAC,EACP,IAAA,eAAG,EAAC,CAAC,EAAE,YAAY,EAAE,SAAS,EAAE,EAAE,EAAE,CAAC,OAAO,CAAC,kBAAkB,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAC1F,CAAC,SAAS,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IAClC,CAAC;;AA9RH,gCA+RC;AApRC;;GAEG;AACoB,4BAAiB,GAAW,IAAI,CAAC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { Observable, ReplaySubject } from 'rxjs';\nimport { map, filter, takeUntil, take } from 'rxjs/operators';\nimport * as gateway from '../gateway';\nimport { events, filterEvent } from '../gateway';\nimport { Device } from './device';\nimport { UnknownResponseEvent } from './unknown_response_event';\nimport { ReplyOnlyEvent } from './reply_only_event';\nimport { CommandCode } from './command_code';\nimport { Message } from './message';\nimport { MotionLibException } from '../exceptions';\n\n/**\n * Class representing access to particular connection (serial port, TCP connection) using the legacy Binary protocol.\n */\nexport class Connection {\n /**\n * Event invoked when a response from a device cannot be matched to any known request.\n */\n public unknownResponse!: Observable<UnknownResponseEvent>;\n\n /**\n * Event invoked when a reply-only command such as a move tracking message is received from a device.\n */\n public replyOnly!: Observable<ReplyOnlyEvent>;\n\n /**\n * Default baud rate for serial connections.\n */\n public static readonly DEFAULT_BAUD_RATE: number = 9600;\n\n /**\n * The interface ID identifies thisConnection instance with the underlying library.\n */\n public get interfaceId(): number {\n return this._interfaceId;\n }\n private _interfaceId: number;\n\n constructor(interfaceId: number) {\n this._interfaceId = interfaceId;\n this._subscribe();\n }\n\n /**\n * Opens a serial port.\n * @param portName Name of the port to open.\n * @param [options.baudRate=Connection.DEFAULT_BAUD_RATE] Optional baud rate (defaults to 9600).\n * @param [options.useMessageIds=false] Enable use of message IDs (defaults to disabled).\n * All your devices must be pre-configured to match.\n * @returns An object representing the port.\n */\n public static async openSerialPort(\n portName: string,\n options: Connection.OpenSerialPortOptions = {}\n ): Promise<Connection> {\n const {\n baudRate = Connection.DEFAULT_BAUD_RATE,\n useMessageIds = false,\n } = options;\n const request = new gateway.OpenBinaryInterfaceRequest();\n request.setInterfaceType(gateway.InterfaceType.SERIAL_PORT);\n request.setPortName(portName);\n request.setBaudRate(baudRate);\n request.setUseMessageIds(useMessageIds);\n\n const response = await gateway.callAsync<gateway.OpenInterfaceResponse>(\n 'binary/interface/open',\n request,\n gateway.OpenInterfaceResponse);\n return new Connection(response.getInterfaceId());\n }\n\n /**\n * Opens a TCP connection.\n * @param hostName Hostname or IP address.\n * @param port Port number.\n * @param [options.useMessageIds=false] Enable use of message IDs (defaults to disabled).\n * All your devices must be pre-configured to match.\n * @returns An object representing the connection.\n */\n public static async openTcp(\n hostName: string,\n port: number,\n options: Connection.OpenTcpOptions = {}\n ): Promise<Connection> {\n const {\n useMessageIds = false,\n } = options;\n const request = new gateway.OpenBinaryInterfaceRequest();\n request.setInterfaceType(gateway.InterfaceType.TCP);\n request.setHostName(hostName);\n request.setPort(port);\n request.setUseMessageIds(useMessageIds);\n\n const response = await gateway.callAsync<gateway.OpenInterfaceResponse>(\n 'binary/interface/open',\n request,\n gateway.OpenInterfaceResponse);\n return new Connection(response.getInterfaceId());\n }\n\n /**\n * Close the connection.\n */\n public async close(): Promise<void> {\n const request = new gateway.InterfaceEmptyRequest();\n request.setInterfaceId(this.interfaceId);\n\n await gateway.callAsync('interface/close', request);\n }\n\n /**\n * Sends a generic Binary command to this connection.\n * For more information please refer to the\n * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).\n * @param device Device address to send the command to. Use zero for broadcast.\n * @param command Command to send.\n * @param [data=0] Optional data argument to the command. Defaults to zero.\n * @param [options.timeout=0.0] Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.\n * @param [options.checkErrors=true] Controls whether to throw an exception when the device rejects the command.\n * @returns A response to the command.\n */\n public async genericCommand(\n device: number,\n command: CommandCode,\n data: number = 0,\n options: Connection.GenericCommandOptions = {}\n ): Promise<Message> {\n const {\n timeout = 0.0,\n checkErrors = true,\n } = options;\n const request = new gateway.GenericBinaryRequest();\n request.setInterfaceId(this.interfaceId);\n request.setDevice(device);\n request.setCommand(command as any);\n request.setData(data);\n request.setTimeout(timeout);\n request.setCheckErrors(checkErrors);\n\n const response = await gateway.callAsync<gateway.BinaryMessage>(\n 'binary/interface/generic_command',\n request,\n gateway.BinaryMessage);\n return Message.fromProtobuf(response.toObject());\n }\n\n /**\n * Sends a generic Binary command to this connection without expecting a response.\n * For more information please refer to the\n * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).\n * @param device Device address to send the command to. Use zero for broadcast.\n * @param command Command to send.\n * @param [data=0] Optional data argument to the command. Defaults to zero.\n */\n public async genericCommandNoResponse(\n device: number,\n command: CommandCode,\n data: number = 0\n ): Promise<void> {\n const request = new gateway.GenericBinaryRequest();\n request.setInterfaceId(this.interfaceId);\n request.setDevice(device);\n request.setCommand(command as any);\n request.setData(data);\n\n await gateway.callAsync('binary/interface/generic_command_no_response', request);\n }\n\n /**\n * Sends a generic Binary command to this connection and expects responses from one or more devices.\n * Responses are returned in order of arrival.\n * For more information please refer to the\n * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).\n * @param command Command to send.\n * @param [data=0] Optional data argument to the command. Defaults to zero.\n * @param [options.timeout=0.0] Number of seconds to wait for all responses from the device chain. 0 or negative defaults to 0.5s.\n * @param [options.checkErrors=true] Controls whether to throw an exception when any device rejects the command.\n * @returns All responses to the command.\n */\n public async genericCommandMultiResponse(\n command: CommandCode,\n data: number = 0,\n options: Connection.GenericCommandMultiResponseOptions = {}\n ): Promise<Message[]> {\n const {\n timeout = 0.0,\n checkErrors = true,\n } = options;\n const request = new gateway.GenericBinaryRequest();\n request.setInterfaceId(this.interfaceId);\n request.setCommand(command as any);\n request.setData(data);\n request.setTimeout(timeout);\n request.setCheckErrors(checkErrors);\n\n const response = await gateway.callAsync<gateway.BinaryMessageCollection>(\n 'binary/interface/generic_command_multi_response',\n request,\n gateway.BinaryMessageCollection);\n return response.getMessagesList().map(a => Message.fromProtobuf(a.toObject()));\n }\n\n /**\n * Renumbers devices present on this connection. After renumbering, you must identify devices again.\n * @returns Total number of devices that responded to the renumber.\n */\n public async renumberDevices(): Promise<number> {\n const request = new gateway.InterfaceEmptyRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = await gateway.callAsync<gateway.IntResponse>(\n 'binary/device/renumber',\n request,\n gateway.IntResponse);\n return response.getValue();\n }\n\n /**\n * Attempts to detect any devices present on this connection.\n * @param [options.identifyDevices=true] Determines whether device identification should be performed as well.\n * @returns Array of detected devices.\n */\n public async detectDevices(\n options: Connection.DetectDevicesOptions = {}\n ): Promise<Device[]> {\n const {\n identifyDevices = true,\n } = options;\n const request = new gateway.BinaryDeviceDetectRequest();\n request.setInterfaceId(this.interfaceId);\n request.setIdentifyDevices(identifyDevices);\n\n const response = await gateway.callAsync<gateway.BinaryDeviceDetectResponse>(\n 'binary/device/detect',\n request,\n gateway.BinaryDeviceDetectResponse);\n return response.getDevicesList().map(deviceAddress => this.getDevice(deviceAddress));\n }\n\n /**\n * Gets a Device class instance which allows you to control a particular device on this connection.\n * Devices are numbered from 1.\n * @param deviceAddress Address of device intended to control. Address is configured for each device.\n * @returns Device instance.\n */\n public getDevice(\n deviceAddress: number\n ): Device {\n if (deviceAddress <= 0) {\n throw new TypeError('Invalid value; physical devices are numbered from 1.');\n }\n return new Device(this, deviceAddress);\n }\n\n /**\n * Returns a string that represents the connection.\n * @returns A string that represents the connection.\n */\n public toString(): string {\n const request = new gateway.InterfaceEmptyRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = gateway.callSync<gateway.StringResponse>(\n 'interface/to_string',\n request,\n gateway.StringResponse);\n return response.getValue();\n }\n\n private _disconnected = new ReplaySubject<MotionLibException>();\n\n /**\n * Event invoked when connection is interrupted or closed.\n */\n public get disconnected(): Observable<MotionLibException> {\n return this._disconnected;\n }\n\n private _subscribe(): void {\n this.unknownResponse = events.pipe(\n takeUntil(this._disconnected),\n filterEvent<gateway.UnknownBinaryResponseEvent.AsObject>('binary/interface/unknown_response'),\n filter(event => event.interfaceId === this.interfaceId),\n map(event => UnknownResponseEvent.fromProtobuf(event))\n );\n\n this.replyOnly = events.pipe(\n takeUntil(this._disconnected),\n filterEvent<gateway.BinaryReplyOnlyEvent.AsObject>('binary/interface/reply_only'),\n filter(event => event.interfaceId === this.interfaceId),\n map(event => ReplyOnlyEvent.fromProtobuf(event))\n );\n\n events.pipe(\n filterEvent<gateway.DisconnectedEvent.AsObject>('interface/disconnected'),\n filter(event => event.interfaceId === this.interfaceId),\n take(1),\n map(({ errorMessage, errorType }) => gateway.convertToException(errorType, errorMessage))\n ).subscribe(this._disconnected);\n }\n}\n\nnamespace Connection {\n export interface OpenSerialPortOptions {\n baudRate?: number;\n useMessageIds?: boolean;\n }\n export interface OpenTcpOptions {\n useMessageIds?: boolean;\n }\n export interface GenericCommandOptions {\n timeout?: number;\n checkErrors?: boolean;\n }\n export interface GenericCommandMultiResponseOptions {\n timeout?: number;\n checkErrors?: boolean;\n }\n export interface DetectDevicesOptions {\n identifyDevices?: boolean;\n }\n}\n"]}
@@ -44,6 +44,7 @@ export declare class Device {
44
44
  get deviceId(): number;
45
45
  /**
46
46
  * Serial number of the device.
47
+ * Requires at least Firmware 6.15 for devices or 6.24 for peripherals.
47
48
  */
48
49
  get serialNumber(): number;
49
50
  /**
@@ -76,65 +77,65 @@ export declare class Device {
76
77
  * For more information please refer to the
77
78
  * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
78
79
  * @param command Command to send.
79
- * @param data Optional data argument to the command. Defaults to zero.
80
- * @param timeout Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
81
- * @param checkErrors Controls whether to throw an exception when the device rejects the command.
82
- * @return A response to the command.
80
+ * @param [data=0] Optional data argument to the command. Defaults to zero.
81
+ * @param [options.timeout=0.0] Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
82
+ * @param [options.checkErrors=true] Controls whether to throw an exception when the device rejects the command.
83
+ * @returns A response to the command.
83
84
  */
84
- genericCommand(command: CommandCode, data?: number, timeout?: number, checkErrors?: boolean): Promise<Message>;
85
+ genericCommand(command: CommandCode, data?: number, options?: Device.GenericCommandOptions): Promise<Message>;
85
86
  /**
86
87
  * Sends a generic Binary command to this device without expecting a response.
87
88
  * For more information please refer to the
88
89
  * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
89
90
  * @param command Command to send.
90
- * @param data Optional data argument to the command. Defaults to zero.
91
+ * @param [data=0] Optional data argument to the command. Defaults to zero.
91
92
  */
92
93
  genericCommandNoResponse(command: CommandCode, data?: number): Promise<void>;
93
94
  /**
94
95
  * Sends a generic Binary command to this device with unit conversions for both sent data and retrieved data.
95
96
  * @param command Command to send.
96
- * @param data Data argument to the command. Set to zero if command does not require argument.
97
- * @param fromUnit Unit to convert sent data from.
98
- * @param toUnit Unit to convert retrieved data to.
99
- * @param timeout Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
100
- * @return Data that has been converted to the provided unit.
97
+ * @param [data=0] Data argument to the command. Defaults to zero.
98
+ * @param [fromUnit=Units.NATIVE] Unit to convert sent data from.
99
+ * @param [toUnit=Units.NATIVE] Unit to convert retrieved data to.
100
+ * @param [options.timeout=0.0] Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
101
+ * @returns Data that has been converted to the provided unit.
101
102
  */
102
- genericCommandWithUnits(command: CommandCode, data: number, fromUnit?: Units, toUnit?: Units, timeout?: number): Promise<number>;
103
+ genericCommandWithUnits(command: CommandCode, data?: number, fromUnit?: Units, toUnit?: Units, options?: Device.GenericCommandWithUnitsOptions): Promise<number>;
103
104
  /**
104
105
  * Homes device. Device returns to its homing position.
105
- * @param unit Unit to convert returned position to.
106
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
107
- * @return Current position that has been converted to the provided unit.
106
+ * @param [options.unit=Units.NATIVE] Unit to convert returned position to.
107
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
108
+ * @returns Current position that has been converted to the provided unit.
108
109
  */
109
- home(unit?: Length | Angle | Native, timeout?: number): Promise<number>;
110
+ home(options?: Device.HomeOptions): Promise<number>;
110
111
  /**
111
112
  * Stops ongoing device movement. Decelerates until zero speed.
112
- * @param unit Unit to convert returned position to.
113
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
114
- * @return Current position that has been converted to the provided unit.
113
+ * @param [options.unit=Units.NATIVE] Unit to convert returned position to.
114
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
115
+ * @returns Current position that has been converted to the provided unit.
115
116
  */
116
- stop(unit?: Length | Angle | Native, timeout?: number): Promise<number>;
117
+ stop(options?: Device.StopOptions): Promise<number>;
117
118
  /**
118
119
  * Move device to absolute position.
119
120
  * @param position Absolute position.
120
- * @param unit Unit for the provided position as well as position returned by the device.
121
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
122
- * @return Current position that has been converted to the provided unit.
121
+ * @param [unit=Units.NATIVE] Unit for the provided position as well as position returned by the device.
122
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
123
+ * @returns Current position that has been converted to the provided unit.
123
124
  */
124
- moveAbsolute(position: number, unit?: Length | Angle | Native, timeout?: number): Promise<number>;
125
+ moveAbsolute(position: number, unit?: Length | Angle | Native, options?: Device.MoveAbsoluteOptions): Promise<number>;
125
126
  /**
126
127
  * Move device to position relative to current position.
127
128
  * @param position Relative position.
128
- * @param unit Unit for the provided position as well as position returned by the device.
129
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
130
- * @return Current position that has been converted to the provided unit.
129
+ * @param [unit=Units.NATIVE] Unit for the provided position as well as position returned by the device.
130
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
131
+ * @returns Current position that has been converted to the provided unit.
131
132
  */
132
- moveRelative(position: number, unit?: Length | Angle | Native, timeout?: number): Promise<number>;
133
+ moveRelative(position: number, unit?: Length | Angle | Native, options?: Device.MoveRelativeOptions): Promise<number>;
133
134
  /**
134
135
  * Begins to move device at specified speed.
135
136
  * @param velocity Movement velocity.
136
- * @param unit Unit to convert returned velocity to.
137
- * @return Device velocity that has been converted to the provided unit.
137
+ * @param [unit=Units.NATIVE] Unit to convert returned velocity to.
138
+ * @returns Device velocity that has been converted to the provided unit.
138
139
  */
139
140
  moveVelocity(velocity: number, unit?: Velocity | AngularVelocity | Native): Promise<number>;
140
141
  /**
@@ -143,50 +144,77 @@ export declare class Device {
143
144
  waitUntilIdle(): Promise<void>;
144
145
  /**
145
146
  * Check whether the device is moving.
146
- * @return True if the device is currently executing a motion command.
147
+ * @returns True if the device is currently executing a motion command.
147
148
  */
148
149
  isBusy(): Promise<boolean>;
149
150
  /**
150
151
  * Queries the device and the database, gathering information about the product.
151
152
  * Without this information features such as unit conversions will not work.
152
153
  * Usually, called automatically by detect devices method.
153
- * @return Device identification data.
154
+ * @returns Device identification data.
154
155
  */
155
156
  identify(): Promise<DeviceIdentity>;
156
157
  /**
157
158
  * Parks the axis.
158
159
  * Motor drivers remain enabled and hold current continues to be applied until the device is powered off.
159
160
  * It can later be unparked and moved without first having to home it.
161
+ * Requires at least Firmware 6.06.
160
162
  */
161
163
  park(): Promise<void>;
162
164
  /**
163
165
  * Unparks axis. Axis will now be able to move.
166
+ * Requires at least Firmware 6.06.
164
167
  */
165
168
  unpark(): Promise<void>;
166
169
  /**
167
170
  * Returns bool indicating whether the axis is parked or not.
168
- * @return True if the axis is currently parked. False otherwise.
171
+ * Requires at least Firmware 6.06.
172
+ * @returns True if the axis is currently parked. False otherwise.
169
173
  */
170
174
  isParked(): Promise<boolean>;
171
175
  /**
172
176
  * Returns current device position.
173
- * @param unit Units of position.
174
- * @return Axis position.
177
+ * @param [unit=Units.NATIVE] Units of position.
178
+ * @returns Axis position.
175
179
  */
176
180
  getPosition(unit?: Length | Angle | Native): Promise<number>;
177
181
  /**
178
182
  * Returns a string that represents the device.
179
- * @return A string that represents the device.
183
+ * @returns A string that represents the device.
180
184
  */
181
185
  toString(): string;
182
186
  /**
183
187
  * Returns identity.
184
- * @return Device identity.
188
+ * @returns Device identity.
185
189
  */
186
190
  private _retrieveIdentity;
187
191
  /**
188
192
  * Returns whether or not the device have been identified.
189
- * @return True if the device has already been identified. False otherwise.
193
+ * @returns True if the device has already been identified. False otherwise.
190
194
  */
191
195
  private _retrieveIsIdentified;
192
196
  }
197
+ declare namespace Device {
198
+ interface GenericCommandOptions {
199
+ timeout?: number;
200
+ checkErrors?: boolean;
201
+ }
202
+ interface GenericCommandWithUnitsOptions {
203
+ timeout?: number;
204
+ }
205
+ interface HomeOptions {
206
+ unit?: Length | Angle | Native;
207
+ timeout?: number;
208
+ }
209
+ interface StopOptions {
210
+ unit?: Length | Angle | Native;
211
+ timeout?: number;
212
+ }
213
+ interface MoveAbsoluteOptions {
214
+ timeout?: number;
215
+ }
216
+ interface MoveRelativeOptions {
217
+ timeout?: number;
218
+ }
219
+ }
220
+ export {};
@@ -75,6 +75,7 @@ class Device {
75
75
  }
76
76
  /**
77
77
  * Serial number of the device.
78
+ * Requires at least Firmware 6.15 for devices or 6.24 for peripherals.
78
79
  */
79
80
  get serialNumber() {
80
81
  return this.identity.serialNumber;
@@ -125,12 +126,13 @@ class Device {
125
126
  * For more information please refer to the
126
127
  * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
127
128
  * @param command Command to send.
128
- * @param data Optional data argument to the command. Defaults to zero.
129
- * @param timeout Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
130
- * @param checkErrors Controls whether to throw an exception when the device rejects the command.
131
- * @return A response to the command.
129
+ * @param [data=0] Optional data argument to the command. Defaults to zero.
130
+ * @param [options.timeout=0.0] Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
131
+ * @param [options.checkErrors=true] Controls whether to throw an exception when the device rejects the command.
132
+ * @returns A response to the command.
132
133
  */
133
- async genericCommand(command, data = 0, timeout = 0.0, checkErrors = true) {
134
+ async genericCommand(command, data = 0, options = {}) {
135
+ const { timeout = 0.0, checkErrors = true, } = options;
134
136
  const request = new gateway.GenericBinaryRequest();
135
137
  request.setInterfaceId(this.connection.interfaceId);
136
138
  request.setDevice(this.deviceAddress);
@@ -146,7 +148,7 @@ class Device {
146
148
  * For more information please refer to the
147
149
  * [Binary Protocol Manual](https://www.zaber.com/protocol-manual?protocol=Binary#topic_quick_command_reference).
148
150
  * @param command Command to send.
149
- * @param data Optional data argument to the command. Defaults to zero.
151
+ * @param [data=0] Optional data argument to the command. Defaults to zero.
150
152
  */
151
153
  async genericCommandNoResponse(command, data = 0) {
152
154
  const request = new gateway.GenericBinaryRequest();
@@ -159,13 +161,14 @@ class Device {
159
161
  /**
160
162
  * Sends a generic Binary command to this device with unit conversions for both sent data and retrieved data.
161
163
  * @param command Command to send.
162
- * @param data Data argument to the command. Set to zero if command does not require argument.
163
- * @param fromUnit Unit to convert sent data from.
164
- * @param toUnit Unit to convert retrieved data to.
165
- * @param timeout Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
166
- * @return Data that has been converted to the provided unit.
164
+ * @param [data=0] Data argument to the command. Defaults to zero.
165
+ * @param [fromUnit=Units.NATIVE] Unit to convert sent data from.
166
+ * @param [toUnit=Units.NATIVE] Unit to convert retrieved data to.
167
+ * @param [options.timeout=0.0] Number of seconds to wait for a response from the device. 0 or negative defaults to 0.5s.
168
+ * @returns Data that has been converted to the provided unit.
167
169
  */
168
- async genericCommandWithUnits(command, data, fromUnit = units_1.Units.NATIVE, toUnit = units_1.Units.NATIVE, timeout = 0.0) {
170
+ async genericCommandWithUnits(command, data = 0, fromUnit = units_1.Units.NATIVE, toUnit = units_1.Units.NATIVE, options = {}) {
171
+ const { timeout = 0.0, } = options;
169
172
  const request = new gateway.BinaryGenericWithUnitsRequest();
170
173
  request.setInterfaceId(this.connection.interfaceId);
171
174
  request.setDevice(this.deviceAddress);
@@ -179,11 +182,12 @@ class Device {
179
182
  }
180
183
  /**
181
184
  * Homes device. Device returns to its homing position.
182
- * @param unit Unit to convert returned position to.
183
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
184
- * @return Current position that has been converted to the provided unit.
185
+ * @param [options.unit=Units.NATIVE] Unit to convert returned position to.
186
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
187
+ * @returns Current position that has been converted to the provided unit.
185
188
  */
186
- async home(unit = units_1.Units.NATIVE, timeout = Device.DEFAULT_MOVEMENT_TIMEOUT) {
189
+ async home(options = {}) {
190
+ const { unit = units_1.Units.NATIVE, timeout = Device.DEFAULT_MOVEMENT_TIMEOUT, } = options;
187
191
  const request = new gateway.BinaryDeviceHomeRequest();
188
192
  request.setInterfaceId(this.connection.interfaceId);
189
193
  request.setDevice(this.deviceAddress);
@@ -194,11 +198,12 @@ class Device {
194
198
  }
195
199
  /**
196
200
  * Stops ongoing device movement. Decelerates until zero speed.
197
- * @param unit Unit to convert returned position to.
198
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
199
- * @return Current position that has been converted to the provided unit.
201
+ * @param [options.unit=Units.NATIVE] Unit to convert returned position to.
202
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
203
+ * @returns Current position that has been converted to the provided unit.
200
204
  */
201
- async stop(unit = units_1.Units.NATIVE, timeout = Device.DEFAULT_MOVEMENT_TIMEOUT) {
205
+ async stop(options = {}) {
206
+ const { unit = units_1.Units.NATIVE, timeout = Device.DEFAULT_MOVEMENT_TIMEOUT, } = options;
202
207
  const request = new gateway.BinaryDeviceStopRequest();
203
208
  request.setInterfaceId(this.connection.interfaceId);
204
209
  request.setDevice(this.deviceAddress);
@@ -210,11 +215,12 @@ class Device {
210
215
  /**
211
216
  * Move device to absolute position.
212
217
  * @param position Absolute position.
213
- * @param unit Unit for the provided position as well as position returned by the device.
214
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
215
- * @return Current position that has been converted to the provided unit.
218
+ * @param [unit=Units.NATIVE] Unit for the provided position as well as position returned by the device.
219
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
220
+ * @returns Current position that has been converted to the provided unit.
216
221
  */
217
- async moveAbsolute(position, unit = units_1.Units.NATIVE, timeout = Device.DEFAULT_MOVEMENT_TIMEOUT) {
222
+ async moveAbsolute(position, unit = units_1.Units.NATIVE, options = {}) {
223
+ const { timeout = Device.DEFAULT_MOVEMENT_TIMEOUT, } = options;
218
224
  const request = new gateway.BinaryDeviceMoveRequest();
219
225
  request.setInterfaceId(this.connection.interfaceId);
220
226
  request.setDevice(this.deviceAddress);
@@ -228,11 +234,12 @@ class Device {
228
234
  /**
229
235
  * Move device to position relative to current position.
230
236
  * @param position Relative position.
231
- * @param unit Unit for the provided position as well as position returned by the device.
232
- * @param timeout Number of seconds to wait for response from the device chain (defaults to 60s).
233
- * @return Current position that has been converted to the provided unit.
237
+ * @param [unit=Units.NATIVE] Unit for the provided position as well as position returned by the device.
238
+ * @param [options.timeout=Device.DEFAULT_MOVEMENT_TIMEOUT] Number of seconds to wait for response from the device chain (defaults to 60s).
239
+ * @returns Current position that has been converted to the provided unit.
234
240
  */
235
- async moveRelative(position, unit = units_1.Units.NATIVE, timeout = Device.DEFAULT_MOVEMENT_TIMEOUT) {
241
+ async moveRelative(position, unit = units_1.Units.NATIVE, options = {}) {
242
+ const { timeout = Device.DEFAULT_MOVEMENT_TIMEOUT, } = options;
236
243
  const request = new gateway.BinaryDeviceMoveRequest();
237
244
  request.setInterfaceId(this.connection.interfaceId);
238
245
  request.setDevice(this.deviceAddress);
@@ -246,8 +253,8 @@ class Device {
246
253
  /**
247
254
  * Begins to move device at specified speed.
248
255
  * @param velocity Movement velocity.
249
- * @param unit Unit to convert returned velocity to.
250
- * @return Device velocity that has been converted to the provided unit.
256
+ * @param [unit=Units.NATIVE] Unit to convert returned velocity to.
257
+ * @returns Device velocity that has been converted to the provided unit.
251
258
  */
252
259
  async moveVelocity(velocity, unit = units_1.Units.NATIVE) {
253
260
  const request = new gateway.BinaryDeviceMoveRequest();
@@ -270,7 +277,7 @@ class Device {
270
277
  }
271
278
  /**
272
279
  * Check whether the device is moving.
273
- * @return True if the device is currently executing a motion command.
280
+ * @returns True if the device is currently executing a motion command.
274
281
  */
275
282
  async isBusy() {
276
283
  const request = new gateway.DeviceEmptyRequest();
@@ -283,7 +290,7 @@ class Device {
283
290
  * Queries the device and the database, gathering information about the product.
284
291
  * Without this information features such as unit conversions will not work.
285
292
  * Usually, called automatically by detect devices method.
286
- * @return Device identification data.
293
+ * @returns Device identification data.
287
294
  */
288
295
  async identify() {
289
296
  const request = new gateway.DeviceEmptyRequest();
@@ -296,6 +303,7 @@ class Device {
296
303
  * Parks the axis.
297
304
  * Motor drivers remain enabled and hold current continues to be applied until the device is powered off.
298
305
  * It can later be unparked and moved without first having to home it.
306
+ * Requires at least Firmware 6.06.
299
307
  */
300
308
  async park() {
301
309
  const request = new gateway.DeviceEmptyRequest();
@@ -305,6 +313,7 @@ class Device {
305
313
  }
306
314
  /**
307
315
  * Unparks axis. Axis will now be able to move.
316
+ * Requires at least Firmware 6.06.
308
317
  */
309
318
  async unpark() {
310
319
  const request = new gateway.DeviceEmptyRequest();
@@ -314,7 +323,8 @@ class Device {
314
323
  }
315
324
  /**
316
325
  * Returns bool indicating whether the axis is parked or not.
317
- * @return True if the axis is currently parked. False otherwise.
326
+ * Requires at least Firmware 6.06.
327
+ * @returns True if the axis is currently parked. False otherwise.
318
328
  */
319
329
  async isParked() {
320
330
  const request = new gateway.DeviceEmptyRequest();
@@ -325,8 +335,8 @@ class Device {
325
335
  }
326
336
  /**
327
337
  * Returns current device position.
328
- * @param unit Units of position.
329
- * @return Axis position.
338
+ * @param [unit=Units.NATIVE] Units of position.
339
+ * @returns Axis position.
330
340
  */
331
341
  async getPosition(unit = units_1.Units.NATIVE) {
332
342
  const request = new gateway.BinaryDeviceGetSettingRequest();
@@ -339,7 +349,7 @@ class Device {
339
349
  }
340
350
  /**
341
351
  * Returns a string that represents the device.
342
- * @return A string that represents the device.
352
+ * @returns A string that represents the device.
343
353
  */
344
354
  toString() {
345
355
  const request = new gateway.DeviceEmptyRequest();
@@ -350,7 +360,7 @@ class Device {
350
360
  }
351
361
  /**
352
362
  * Returns identity.
353
- * @return Device identity.
363
+ * @returns Device identity.
354
364
  */
355
365
  _retrieveIdentity() {
356
366
  const request = new gateway.DeviceEmptyRequest();
@@ -361,7 +371,7 @@ class Device {
361
371
  }
362
372
  /**
363
373
  * Returns whether or not the device have been identified.
364
- * @return True if the device has already been identified. False otherwise.
374
+ * @returns True if the device has already been identified. False otherwise.
365
375
  */
366
376
  _retrieveIsIdentified() {
367
377
  const request = new gateway.DeviceEmptyRequest();