@zaber/motion 2.7.0-save-load → 2.8.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/connection.js +3 -3
- package/dist/lib/ascii/connection.js.map +1 -1
- package/dist/lib/ascii/stream.d.ts +0 -6
- package/dist/lib/ascii/stream.js +0 -13
- package/dist/lib/ascii/stream.js.map +1 -1
- package/dist/lib/ascii/stream_axis_definition.d.ts +1 -1
- package/dist/lib/ascii/stream_axis_definition.js.map +1 -1
- package/dist/lib/ascii/stream_buffer.d.ts +0 -1
- package/dist/lib/ascii/stream_buffer.js +0 -1
- package/dist/lib/ascii/stream_buffer.js.map +1 -1
- package/dist/lib/binary/connection.js +3 -3
- package/dist/lib/binary/connection.js.map +1 -1
- package/dist/lib/exceptions/index.d.ts +0 -4
- package/dist/lib/exceptions/index.js +2 -10
- package/dist/lib/exceptions/index.js.map +1 -1
- package/dist/lib/gateway/call.js +7 -7
- package/dist/lib/gateway/call.js.map +1 -1
- package/dist/lib/gateway/convert_exceptions.js +0 -2
- package/dist/lib/gateway/convert_exceptions.js.map +1 -1
- package/dist/lib/gateway/events.js +5 -5
- package/dist/lib/gateway/events.js.map +1 -1
- package/dist/lib/gateway/wasm.js +1 -1
- package/dist/lib/gateway/wasm.js.map +1 -1
- package/dist/lib/index.d.ts +0 -1
- package/dist/lib/index.js +0 -1
- package/dist/lib/index.js.map +1 -1
- package/dist/lib/measurement.d.ts +1 -1
- package/dist/lib/measurement.js.map +1 -1
- package/dist/lib/protobufs/main_pb.d.ts +0 -478
- package/dist/lib/protobufs/main_pb.js +1 -3682
- package/dist/lib/protobufs/main_pb.js.map +1 -1
- package/dist/lib/wasm.js +3 -3
- package/dist/lib/wasm.js.map +1 -1
- package/package.json +3 -3
- package/dist/lib/exceptions/g_code_execution_exception.d.ts +0 -14
- package/dist/lib/exceptions/g_code_execution_exception.js +0 -32
- package/dist/lib/exceptions/g_code_execution_exception.js.map +0 -1
- package/dist/lib/exceptions/g_code_execution_exception_data.d.ts +0 -17
- package/dist/lib/exceptions/g_code_execution_exception_data.js +0 -18
- package/dist/lib/exceptions/g_code_execution_exception_data.js.map +0 -1
- package/dist/lib/exceptions/g_code_syntax_exception.d.ts +0 -14
- package/dist/lib/exceptions/g_code_syntax_exception.js +0 -32
- package/dist/lib/exceptions/g_code_syntax_exception.js.map +0 -1
- package/dist/lib/exceptions/g_code_syntax_exception_data.d.ts +0 -17
- package/dist/lib/exceptions/g_code_syntax_exception_data.js +0 -18
- package/dist/lib/exceptions/g_code_syntax_exception_data.js.map +0 -1
- package/dist/lib/finalizer.d.ts +0 -5
- package/dist/lib/finalizer.js +0 -21
- package/dist/lib/finalizer.js.map +0 -1
- package/dist/lib/gcode/axis_mapping.d.ts +0 -16
- package/dist/lib/gcode/axis_mapping.js +0 -38
- package/dist/lib/gcode/axis_mapping.js.map +0 -1
- package/dist/lib/gcode/index.d.ts +0 -8
- package/dist/lib/gcode/index.js +0 -20
- package/dist/lib/gcode/index.js.map +0 -1
- package/dist/lib/gcode/translate_message.d.ts +0 -21
- package/dist/lib/gcode/translate_message.js +0 -19
- package/dist/lib/gcode/translate_message.js.map +0 -1
- package/dist/lib/gcode/translate_result.d.ts +0 -17
- package/dist/lib/gcode/translate_result.js +0 -19
- package/dist/lib/gcode/translate_result.js.map +0 -1
- package/dist/lib/gcode/translator.d.ts +0 -68
- package/dist/lib/gcode/translator.js +0 -144
- package/dist/lib/gcode/translator.js.map +0 -1
- package/dist/lib/gcode/translator_axis_definition.d.ts +0 -20
- package/dist/lib/gcode/translator_axis_definition.js +0 -48
- package/dist/lib/gcode/translator_axis_definition.js.map +0 -1
- package/dist/lib/gcode/translator_config.d.ts +0 -18
- package/dist/lib/gcode/translator_config.js +0 -41
- package/dist/lib/gcode/translator_config.js.map +0 -1
- package/dist/lib/gcode/translator_definition.d.ts +0 -18
- package/dist/lib/gcode/translator_definition.js +0 -39
- package/dist/lib/gcode/translator_definition.js.map +0 -1
- package/dist/lib/gcode/translator_live.d.ts +0 -70
- package/dist/lib/gcode/translator_live.js +0 -147
- package/dist/lib/gcode/translator_live.js.map +0 -1
- package/dist/lib/gcode_ns.d.ts +0 -19
- package/dist/lib/gcode_ns.js +0 -35
- package/dist/lib/gcode_ns.js.map +0 -1
|
@@ -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;IAyBrB,YAAY,WAAmB;QAyNvB,kBAAa,GAAG,IAAI,oBAAa,EAAsB,CAAC;QAxN9D,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAXD;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAQD;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,cAAc,CAChC,QAAgB,EAChB,WAAmB,UAAU,CAAC,iBAAiB,EAC/C,gBAAyB,KAAK;QAE9B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;QACzD,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAC5D,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,CAAC,WAAW,CAAC,QAAQ,CAAC,CAAC;QAC9B,OAAO,CAAC,gBAAgB,CAAC,aAAa,CAAC,CAAC;QAExC,MAAM,QAAQ,GAAG,MAAM,OAAO,CAAC,SAAS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zE,kBAAM,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,CAAC,WAAW,KAAK,IAAI,CAAC,WAAW,CAAC,EACvD,gBAAI,CAAC,CAAC,CAAC,EACP,eAAG,CAAC,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.CloseInterfaceRequest();\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.toObject().messagesList.map(resp => Message.fromProtobuf(resp));\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.BinaryDeviceRenumberRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = await gateway.callAsync<gateway.BinaryDeviceRenumberResponse>(\n 'binary/device/renumber',\n request,\n gateway.BinaryDeviceRenumberResponse);\n return response.getNumberDevices();\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.ToStringRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = gateway.callSync<gateway.ToStringResponse>(\n 'interface/to_string',\n request,\n gateway.ToStringResponse);\n return response.getToStr();\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;AAC9D,oDAAsC;AACtC,wCAAiD;AACjD,qCAAkC;AAClC,qEAAgE;AAChE,yDAAoD;AAEpD,uCAAoC;AAGpC;;GAEG;AACH,MAAa,UAAU;IAyBrB,YAAY,WAAmB;QAyNvB,kBAAa,GAAG,IAAI,oBAAa,EAAsB,CAAC;QAxN9D,IAAI,CAAC,YAAY,GAAG,WAAW,CAAC;QAChC,IAAI,CAAC,UAAU,EAAE,CAAC;IACpB,CAAC;IAXD;;OAEG;IACH,IAAW,WAAW;QACpB,OAAO,IAAI,CAAC,YAAY,CAAC;IAC3B,CAAC;IAQD;;;;;;;OAOG;IACI,MAAM,CAAC,KAAK,CAAC,cAAc,CAChC,QAAgB,EAChB,WAAmB,UAAU,CAAC,iBAAiB,EAC/C,gBAAyB,KAAK;QAE9B,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,0BAA0B,EAAE,CAAC;QACzD,OAAO,CAAC,gBAAgB,CAAC,OAAO,CAAC,aAAa,CAAC,WAAW,CAAC,CAAC;QAC5D,OAAO,CAAC,WA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C,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.CloseInterfaceRequest();\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.toObject().messagesList.map(resp => Message.fromProtobuf(resp));\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.BinaryDeviceRenumberRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = await gateway.callAsync<gateway.BinaryDeviceRenumberResponse>(\n 'binary/device/renumber',\n request,\n gateway.BinaryDeviceRenumberResponse);\n return response.getNumberDevices();\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.ToStringRequest();\n request.setInterfaceId(this.interfaceId);\n\n const response = gateway.callSync<gateway.ToStringResponse>(\n 'interface/to_string',\n request,\n gateway.ToStringResponse);\n return response.getToStr();\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"]}
|
|
@@ -9,8 +9,6 @@ export { DeviceBusyException } from './device_busy_exception';
|
|
|
9
9
|
export { DeviceDbFailedException } from './device_db_failed_exception';
|
|
10
10
|
export { DeviceFailedException } from './device_failed_exception';
|
|
11
11
|
export { DeviceNotIdentifiedException } from './device_not_identified_exception';
|
|
12
|
-
export { GCodeExecutionException } from './g_code_execution_exception';
|
|
13
|
-
export { GCodeSyntaxException } from './g_code_syntax_exception';
|
|
14
12
|
export { InternalErrorException } from './internal_error_exception';
|
|
15
13
|
export { InvalidArgumentException } from './invalid_argument_exception';
|
|
16
14
|
export { InvalidDataException } from './invalid_data_exception';
|
|
@@ -43,8 +41,6 @@ export { MotionLibException } from './motion_lib_exception';
|
|
|
43
41
|
export { BinaryCommandFailedExceptionData } from './binary_command_failed_exception_data';
|
|
44
42
|
export { CommandFailedExceptionData } from './command_failed_exception_data';
|
|
45
43
|
export { DeviceAddressConflictExceptionData } from './device_address_conflict_exception_data';
|
|
46
|
-
export { GCodeExecutionExceptionData } from './g_code_execution_exception_data';
|
|
47
|
-
export { GCodeSyntaxExceptionData } from './g_code_syntax_exception_data';
|
|
48
44
|
export { InvalidPacketExceptionData } from './invalid_packet_exception_data';
|
|
49
45
|
export { InvalidResponseExceptionData } from './invalid_response_exception_data';
|
|
50
46
|
export { MovementFailedExceptionData } from './movement_failed_exception_data';
|
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //
|
|
3
3
|
// ============= DO NOT EDIT DIRECTLY ============= //
|
|
4
4
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
5
|
-
exports.
|
|
6
|
-
exports.StreamMovementInterruptedExceptionData = exports.StreamMovementFailedExceptionData =
|
|
5
|
+
exports.StreamExecutionExceptionData = exports.SetPeripheralStateExceptionData = exports.SetDeviceStateExceptionData = exports.MovementInterruptedExceptionData = exports.MovementFailedExceptionData = exports.InvalidResponseExceptionData = exports.InvalidPacketExceptionData = exports.DeviceAddressConflictExceptionData = exports.CommandFailedExceptionData = exports.BinaryCommandFailedExceptionData = exports.MotionLibException = exports.UnknownRequestException = exports.TransportAlreadyUsedException = exports.StreamSetupFailedException = exports.StreamMovementInterruptedException = exports.StreamMovementFailedException = exports.StreamModeException = exports.StreamExecutionException = exports.SettingNotFoundException = exports.SetPeripheralStateFailedException = exports.SetDeviceStateFailedException = exports.SerialPortBusyException = exports.RequestTimeoutException = exports.OutOfRequestIdsException = exports.OsFailedException = exports.NotSupportedException = exports.NoDeviceFoundException = exports.MovementInterruptedException = exports.MovementFailedException = exports.LockstepNotEnabledException = exports.LockstepEnabledException = exports.IoFailedException = exports.IoChannelOutOfRangeException = exports.InvalidResponseException = exports.InvalidParkStateException = exports.InvalidPacketException = exports.InvalidDataException = exports.InvalidArgumentException = exports.InternalErrorException = exports.DeviceNotIdentifiedException = exports.DeviceFailedException = exports.DeviceDbFailedException = exports.DeviceBusyException = exports.DeviceAddressConflictException = exports.ConversionFailedException = exports.ConnectionFailedException = exports.ConnectionClosedException = exports.CommandPreemptedException = exports.CommandFailedException = exports.BinaryCommandFailedException = void 0;
|
|
6
|
+
exports.StreamMovementInterruptedExceptionData = exports.StreamMovementFailedExceptionData = void 0;
|
|
7
7
|
var binary_command_failed_exception_1 = require("./binary_command_failed_exception");
|
|
8
8
|
Object.defineProperty(exports, "BinaryCommandFailedException", { enumerable: true, get: function () { return binary_command_failed_exception_1.BinaryCommandFailedException; } });
|
|
9
9
|
var command_failed_exception_1 = require("./command_failed_exception");
|
|
@@ -26,10 +26,6 @@ var device_failed_exception_1 = require("./device_failed_exception");
|
|
|
26
26
|
Object.defineProperty(exports, "DeviceFailedException", { enumerable: true, get: function () { return device_failed_exception_1.DeviceFailedException; } });
|
|
27
27
|
var device_not_identified_exception_1 = require("./device_not_identified_exception");
|
|
28
28
|
Object.defineProperty(exports, "DeviceNotIdentifiedException", { enumerable: true, get: function () { return device_not_identified_exception_1.DeviceNotIdentifiedException; } });
|
|
29
|
-
var g_code_execution_exception_1 = require("./g_code_execution_exception");
|
|
30
|
-
Object.defineProperty(exports, "GCodeExecutionException", { enumerable: true, get: function () { return g_code_execution_exception_1.GCodeExecutionException; } });
|
|
31
|
-
var g_code_syntax_exception_1 = require("./g_code_syntax_exception");
|
|
32
|
-
Object.defineProperty(exports, "GCodeSyntaxException", { enumerable: true, get: function () { return g_code_syntax_exception_1.GCodeSyntaxException; } });
|
|
33
29
|
var internal_error_exception_1 = require("./internal_error_exception");
|
|
34
30
|
Object.defineProperty(exports, "InternalErrorException", { enumerable: true, get: function () { return internal_error_exception_1.InternalErrorException; } });
|
|
35
31
|
var invalid_argument_exception_1 = require("./invalid_argument_exception");
|
|
@@ -94,10 +90,6 @@ var command_failed_exception_data_1 = require("./command_failed_exception_data")
|
|
|
94
90
|
Object.defineProperty(exports, "CommandFailedExceptionData", { enumerable: true, get: function () { return command_failed_exception_data_1.CommandFailedExceptionData; } });
|
|
95
91
|
var device_address_conflict_exception_data_1 = require("./device_address_conflict_exception_data");
|
|
96
92
|
Object.defineProperty(exports, "DeviceAddressConflictExceptionData", { enumerable: true, get: function () { return device_address_conflict_exception_data_1.DeviceAddressConflictExceptionData; } });
|
|
97
|
-
var g_code_execution_exception_data_1 = require("./g_code_execution_exception_data");
|
|
98
|
-
Object.defineProperty(exports, "GCodeExecutionExceptionData", { enumerable: true, get: function () { return g_code_execution_exception_data_1.GCodeExecutionExceptionData; } });
|
|
99
|
-
var g_code_syntax_exception_data_1 = require("./g_code_syntax_exception_data");
|
|
100
|
-
Object.defineProperty(exports, "GCodeSyntaxExceptionData", { enumerable: true, get: function () { return g_code_syntax_exception_data_1.GCodeSyntaxExceptionData; } });
|
|
101
93
|
var invalid_packet_exception_data_1 = require("./invalid_packet_exception_data");
|
|
102
94
|
Object.defineProperty(exports, "InvalidPacketExceptionData", { enumerable: true, get: function () { return invalid_packet_exception_data_1.InvalidPacketExceptionData; } });
|
|
103
95
|
var invalid_response_exception_data_1 = require("./invalid_response_exception_data");
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/exceptions/index.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;AAEtD,qFAAiF;AAAxE,+IAAA,4BAA4B,OAAA;AACrC,uEAAoE;AAA3D,kIAAA,sBAAsB,OAAA;AAC/B,6EAA0E;AAAjE,wIAAA,yBAAyB,OAAA;AAClC,6EAA0E;AAAjE,wIAAA,yBAAyB,OAAA;AAClC,6EAA0E;AAAjE,wIAAA,yBAAyB,OAAA;AAClC,6EAA0E;AAAjE,wIAAA,yBAAyB,OAAA;AAClC,yFAAqF;AAA5E,mJAAA,8BAA8B,OAAA;AACvC,iEAA8D;AAArD,4HAAA,mBAAmB,OAAA;AAC5B,2EAAuE;AAA9D,qIAAA,uBAAuB,OAAA;AAChC,qEAAkE;AAAzD,gIAAA,qBAAqB,OA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TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nexport { BinaryCommandFailedException } from './binary_command_failed_exception';\nexport { CommandFailedException } from './command_failed_exception';\nexport { CommandPreemptedException } from './command_preempted_exception';\nexport { ConnectionClosedException } from './connection_closed_exception';\nexport { ConnectionFailedException } from './connection_failed_exception';\nexport { ConversionFailedException } from './conversion_failed_exception';\nexport { DeviceAddressConflictException } from './device_address_conflict_exception';\nexport { DeviceBusyException } from './device_busy_exception';\nexport { DeviceDbFailedException } from './device_db_failed_exception';\nexport { DeviceFailedException } from './device_failed_exception';\nexport { DeviceNotIdentifiedException } from './device_not_identified_exception';\nexport { InternalErrorException } from './internal_error_exception';\nexport { InvalidArgumentException } from './invalid_argument_exception';\nexport { InvalidDataException } from './invalid_data_exception';\nexport { InvalidPacketException } from './invalid_packet_exception';\nexport { InvalidParkStateException } from './invalid_park_state_exception';\nexport { InvalidResponseException } from './invalid_response_exception';\nexport { IoChannelOutOfRangeException } from './io_channel_out_of_range_exception';\nexport { IoFailedException } from './io_failed_exception';\nexport { LockstepEnabledException } from './lockstep_enabled_exception';\nexport { LockstepNotEnabledException } from './lockstep_not_enabled_exception';\nexport { MovementFailedException } from './movement_failed_exception';\nexport { MovementInterruptedException } from './movement_interrupted_exception';\nexport { NoDeviceFoundException } from './no_device_found_exception';\nexport { NotSupportedException } from './not_supported_exception';\nexport { OsFailedException } from './os_failed_exception';\nexport { OutOfRequestIdsException } from './out_of_request_ids_exception';\nexport { RequestTimeoutException } from './request_timeout_exception';\nexport { SerialPortBusyException } from './serial_port_busy_exception';\nexport { SetDeviceStateFailedException } from './set_device_state_failed_exception';\nexport { SetPeripheralStateFailedException } from './set_peripheral_state_failed_exception';\nexport { SettingNotFoundException } from './setting_not_found_exception';\nexport { StreamExecutionException } from './stream_execution_exception';\nexport { StreamModeException } from './stream_mode_exception';\nexport { StreamMovementFailedException } from './stream_movement_failed_exception';\nexport { StreamMovementInterruptedException } from './stream_movement_interrupted_exception';\nexport { StreamSetupFailedException } from './stream_setup_failed_exception';\nexport { TransportAlreadyUsedException } from './transport_already_used_exception';\nexport { UnknownRequestException } from './unknown_request_exception';\nexport { MotionLibException } from './motion_lib_exception';\n\nexport { BinaryCommandFailedExceptionData } from './binary_command_failed_exception_data';\nexport { CommandFailedExceptionData } from './command_failed_exception_data';\nexport { DeviceAddressConflictExceptionData } from './device_address_conflict_exception_data';\nexport { InvalidPacketExceptionData } from './invalid_packet_exception_data';\nexport { InvalidResponseExceptionData } from './invalid_response_exception_data';\nexport { MovementFailedExceptionData } from './movement_failed_exception_data';\nexport { MovementInterruptedExceptionData } from './movement_interrupted_exception_data';\nexport { SetDeviceStateExceptionData } from './set_device_state_exception_data';\nexport { SetPeripheralStateExceptionData } from './set_peripheral_state_exception_data';\nexport { StreamExecutionExceptionData } from './stream_execution_exception_data';\nexport { StreamMovementFailedExceptionData } from './stream_movement_failed_exception_data';\nexport { StreamMovementInterruptedExceptionData } from './stream_movement_interrupted_exception_data';\n"]}
|
package/dist/lib/gateway/call.js
CHANGED
|
@@ -8,25 +8,25 @@ const convert_exceptions_1 = require("./convert_exceptions");
|
|
|
8
8
|
async function callAsync(request, requestData, responseProto) {
|
|
9
9
|
const requestProto = new main_pb_1.Request();
|
|
10
10
|
requestProto.setRequest(request);
|
|
11
|
-
const data = serialization_1.serialize(requestProto, requestData);
|
|
12
|
-
const resultBuffer = await new Promise(resolve => bindings_1.getBinding().callAsync(data, resolve));
|
|
13
|
-
const structBuffers = serialization_1.deserialize(resultBuffer);
|
|
11
|
+
const data = (0, serialization_1.serialize)(requestProto, requestData);
|
|
12
|
+
const resultBuffer = await new Promise(resolve => (0, bindings_1.getBinding)().callAsync(data, resolve));
|
|
13
|
+
const structBuffers = (0, serialization_1.deserialize)(resultBuffer);
|
|
14
14
|
return processResponse(structBuffers, responseProto);
|
|
15
15
|
}
|
|
16
16
|
exports.callAsync = callAsync;
|
|
17
17
|
function callSync(request, requestData, responseProto) {
|
|
18
18
|
const requestProto = new main_pb_1.Request();
|
|
19
19
|
requestProto.setRequest(request);
|
|
20
|
-
const data = serialization_1.serialize(requestProto, requestData);
|
|
21
|
-
const resultBuffer = bindings_1.getBinding().callSync(data);
|
|
22
|
-
const structBuffers = serialization_1.deserialize(resultBuffer);
|
|
20
|
+
const data = (0, serialization_1.serialize)(requestProto, requestData);
|
|
21
|
+
const resultBuffer = (0, bindings_1.getBinding)().callSync(data);
|
|
22
|
+
const structBuffers = (0, serialization_1.deserialize)(resultBuffer);
|
|
23
23
|
return processResponse(structBuffers, responseProto);
|
|
24
24
|
}
|
|
25
25
|
exports.callSync = callSync;
|
|
26
26
|
function processResponse(structBuffers, responseProto) {
|
|
27
27
|
const response = main_pb_1.Response.deserializeBinary(structBuffers[0]);
|
|
28
28
|
if (response.getResponse() !== main_pb_1.Response.ResponseType.OK) {
|
|
29
|
-
throw convert_exceptions_1.convertToException(response.getErrorType(), response.getErrorMessage(), structBuffers[1]);
|
|
29
|
+
throw (0, convert_exceptions_1.convertToException)(response.getErrorType(), response.getErrorMessage(), structBuffers[1]);
|
|
30
30
|
}
|
|
31
31
|
/* istanbul ignore if */
|
|
32
32
|
if (responseProto && structBuffers.length <= 1) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../src/gateway/call.ts"],"names":[],"mappings":";;;AAEA,kDAAyD;AAEzD,yCAAwC;AACxC,mDAAuE;AACvE,6DAA0D;AAanD,KAAK,UAAU,SAAS,CAC7B,OAAe,EACf,WAAsC,EACtC,aAA2B;IAE3B,MAAM,YAAY,GAAG,IAAI,iBAAO,EAAE,CAAC;IACnC,YAAY,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC;IAEjC,MAAM,IAAI,GAAG,yBAAS,
|
|
1
|
+
{"version":3,"file":"call.js","sourceRoot":"","sources":["../../../src/gateway/call.ts"],"names":[],"mappings":";;;AAEA,kDAAyD;AAEzD,yCAAwC;AACxC,mDAAuE;AACvE,6DAA0D;A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QAAQ,CAAC,YAAY,EAAE,EAAE,QAAQ,CAAC,eAAe,EAAE,EAAE,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;KACjG;IAED,wBAAwB;IACxB,IAAI,aAAa,IAAI,aAAa,CAAC,MAAM,IAAI,CAAC,EAAE;QAC9C,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;KAC7C;IACD,wBAAwB;IACxB,IAAI,CAAC,aAAa,IAAI,aAAa,CAAC,MAAM,GAAG,CAAC,EAAE;QAC9C,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;KAClD;IACD,IAAI,aAAa,EAAE;QACjB,OAAQ,aAAqB,CAAC,iBAAiB,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAAC;KACnE;SAAM;QACL,OAAO,IAAI,CAAC;KACb;AACH,CAAC","sourcesContent":["import { Message } from 'google-protobuf';\n\nimport { Request, Response } from '../protobufs/main_pb';\n\nimport { getBinding } from './bindings';\nimport { Serializable, serialize, deserialize } from './serialization';\nimport { convertToException } from './convert_exceptions';\n\nexport async function callAsync(\n request: string,\n requestData?: Serializable\n): Promise<null>;\n\nexport async function callAsync<T extends Message>(\n request: string,\n requestData: Serializable | undefined,\n responseProto: new () => T\n): Promise<T>;\n\nexport async function callAsync<T extends Message>(\n request: string,\n requestData?: Serializable | undefined,\n responseProto?: new () => T\n): Promise<T | null> {\n const requestProto = new Request();\n requestProto.setRequest(request);\n\n const data = serialize(requestProto, requestData);\n\n const resultBuffer = await new Promise<Buffer>(resolve =>\n getBinding().callAsync(data, resolve)\n );\n\n const structBuffers = deserialize(resultBuffer);\n\n return processResponse(structBuffers, responseProto);\n}\n\nexport function callSync(\n request: string,\n requestData?: Serializable | undefined,\n): null;\n\nexport function callSync<T extends Message>(\n request: string,\n requestData: Serializable | undefined,\n responseProto: new () => T\n): T;\n\nexport function callSync<T extends Message>(\n request: string,\n requestData?: Serializable,\n responseProto?: new () => T\n): T | null {\n const requestProto = new Request();\n requestProto.setRequest(request);\n\n const data = serialize(requestProto, requestData);\n\n const resultBuffer: Buffer = getBinding().callSync(data);\n\n const structBuffers = deserialize(resultBuffer);\n\n return processResponse(structBuffers, responseProto);\n}\n\nfunction processResponse<T extends Message>(structBuffers: Buffer[], responseProto?: new () => T): T | null {\n const response = Response.deserializeBinary(structBuffers[0]);\n\n if (response.getResponse() !== Response.ResponseType.OK) {\n throw convertToException(response.getErrorType(), response.getErrorMessage(), structBuffers[1]);\n }\n\n /* istanbul ignore if */\n if (responseProto && structBuffers.length <= 1) {\n throw new Error('No response from library');\n }\n /* istanbul ignore if */\n if (!responseProto && structBuffers.length > 1) {\n throw new Error('Response from library ignored');\n }\n if (responseProto) {\n return (responseProto as any).deserializeBinary(structBuffers[1]);\n } else {\n return null;\n }\n}\n"]}
|
|
@@ -36,8 +36,6 @@ errorMapping.set(main_pb_1.Errors.DEVICE_BUSY, exceptions.DeviceBusyException);
|
|
|
36
36
|
errorMapping.set(main_pb_1.Errors.DEVICE_DB_FAILED, exceptions.DeviceDbFailedException);
|
|
37
37
|
errorMapping.set(main_pb_1.Errors.DEVICE_FAILED, exceptions.DeviceFailedException);
|
|
38
38
|
errorMapping.set(main_pb_1.Errors.DEVICE_NOT_IDENTIFIED, exceptions.DeviceNotIdentifiedException);
|
|
39
|
-
errorMapping.set(main_pb_1.Errors.G_CODE_EXECUTION, exceptions.GCodeExecutionException);
|
|
40
|
-
errorMapping.set(main_pb_1.Errors.G_CODE_SYNTAX, exceptions.GCodeSyntaxException);
|
|
41
39
|
errorMapping.set(main_pb_1.Errors.INTERNAL_ERROR, exceptions.InternalErrorException);
|
|
42
40
|
errorMapping.set(main_pb_1.Errors.INVALID_ARGUMENT, exceptions.InvalidArgumentException);
|
|
43
41
|
errorMapping.set(main_pb_1.Errors.INVALID_DATA, exceptions.InvalidDataException);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"convert_exceptions.js","sourceRoot":"","sources":["../../../src/gateway/convert_exceptions.ts"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AAC,eAAe,EAAE,UAAU,CAAC,uBAAuB,CAAC,CAAC;AAE/E,SAAgB,kBAAkB,CAAC,KAAe,EAAE,OAAe,EAAE,UAAmB;IACtF,MAAM,iBAAiB,GAAG,YAAY,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC;IAElD,wBAAwB;IACxB,IAAI,CAAC,iBAAiB,EAAE;QACtB,OAAO,IAAI,UAAU,CAAC,kBAAkB,CAAC,OAAO,CAAC,CAAC;KACnD;IAED,OAAO,IAAI,iBAAiB,CAAC,OAAO,EAAE,UAAW,CAAC,CAAC;AACrD,CAAC;AATD,gDASC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport { Errors as PbErrors } from '../protobufs/main_pb';\nimport * as exceptions from '../exceptions';\n\nconst errorMapping = new Map<PbErrors, new (message: string, customData: Buffer) => exceptions.MotionLibException>();\nerrorMapping.set(PbErrors.BINARY_COMMAND_FAILED, exceptions.BinaryCommandFailedException);\nerrorMapping.set(PbErrors.COMMAND_FAILED, exceptions.CommandFailedException);\nerrorMapping.set(PbErrors.COMMAND_PREEMPTED, exceptions.CommandPreemptedException);\nerrorMapping.set(PbErrors.CONNECTION_CLOSED, exceptions.ConnectionClosedException);\nerrorMapping.set(PbErrors.CONNECTION_FAILED, exceptions.ConnectionFailedException);\nerrorMapping.set(PbErrors.CONVERSION_FAILED, exceptions.ConversionFailedException);\nerrorMapping.set(PbErrors.DEVICE_ADDRESS_CONFLICT, exceptions.DeviceAddressConflictException);\nerrorMapping.set(PbErrors.DEVICE_BUSY, exceptions.DeviceBusyException);\nerrorMapping.set(PbErrors.DEVICE_DB_FAILED, exceptions.DeviceDbFailedException);\nerrorMapping.set(PbErrors.DEVICE_FAILED, exceptions.DeviceFailedException);\nerrorMapping.set(PbErrors.DEVICE_NOT_IDENTIFIED, exceptions.DeviceNotIdentifiedException);\nerrorMapping.set(PbErrors.INTERNAL_ERROR, exceptions.InternalErrorException);\nerrorMapping.set(PbErrors.INVALID_ARGUMENT, exceptions.InvalidArgumentException);\nerrorMapping.set(PbErrors.INVALID_DATA, exceptions.InvalidDataException);\nerrorMapping.set(PbErrors.INVALID_PACKET, exceptions.InvalidPacketException);\nerrorMapping.set(PbErrors.INVALID_PARK_STATE, exceptions.InvalidParkStateException);\nerrorMapping.set(PbErrors.INVALID_RESPONSE, exceptions.InvalidResponseException);\nerrorMapping.set(PbErrors.IO_CHANNEL_OUT_OF_RANGE, exceptions.IoChannelOutOfRangeException);\nerrorMapping.set(PbErrors.IO_FAILED, exceptions.IoFailedException);\nerrorMapping.set(PbErrors.LOCKSTEP_ENABLED, exceptions.LockstepEnabledException);\nerrorMapping.set(PbErrors.LOCKSTEP_NOT_ENABLED, exceptions.LockstepNotEnabledException);\nerrorMapping.set(PbErrors.MOVEMENT_FAILED, exceptions.MovementFailedException);\nerrorMapping.set(PbErrors.MOVEMENT_INTERRUPTED, exceptions.MovementInterruptedException);\nerrorMapping.set(PbErrors.NO_DEVICE_FOUND, exceptions.NoDeviceFoundException);\nerrorMapping.set(PbErrors.NOT_SUPPORTED, exceptions.NotSupportedException);\nerrorMapping.set(PbErrors.OS_FAILED, exceptions.OsFailedException);\nerrorMapping.set(PbErrors.OUT_OF_REQUEST_IDS, exceptions.OutOfRequestIdsException);\nerrorMapping.set(PbErrors.REQUEST_TIMEOUT, exceptions.RequestTimeoutException);\nerrorMapping.set(PbErrors.SERIAL_PORT_BUSY, exceptions.SerialPortBusyException);\nerrorMapping.set(PbErrors.SET_DEVICE_STATE_FAILED, exceptions.SetDeviceStateFailedException);\nerrorMapping.set(PbErrors.SET_PERIPHERAL_STATE_FAILED, exceptions.SetPeripheralStateFailedException);\nerrorMapping.set(PbErrors.SETTING_NOT_FOUND, exceptions.SettingNotFoundException);\nerrorMapping.set(PbErrors.STREAM_EXECUTION, exceptions.StreamExecutionException);\nerrorMapping.set(PbErrors.STREAM_MODE, exceptions.StreamModeException);\nerrorMapping.set(PbErrors.STREAM_MOVEMENT_FAILED, exceptions.StreamMovementFailedException);\nerrorMapping.set(PbErrors.STREAM_MOVEMENT_INTERRUPTED, exceptions.StreamMovementInterruptedException);\nerrorMapping.set(PbErrors.STREAM_SETUP_FAILED, exceptions.StreamSetupFailedException);\nerrorMapping.set(PbErrors.TRANSPORT_ALREADY_USED, exceptions.TransportAlreadyUsedException);\nerrorMapping.set(PbErrors.UNKNOWN_REQUEST, exceptions.UnknownRequestException);\n\nexport function convertToException(error: PbErrors, message: string, customData?: Buffer): exceptions.MotionLibException {\n const SpecificException = errorMapping.get(error);\n\n /* istanbul ignore if */\n if (!SpecificException) {\n return new exceptions.MotionLibException(message);\n }\n\n return new SpecificException(message, customData!);\n}\n"]}
|
|
@@ -10,13 +10,13 @@ const serialization_1 = require("./serialization");
|
|
|
10
10
|
const subscriptions = new Set();
|
|
11
11
|
exports.events = rxjs_1.Observable.create((observer) => {
|
|
12
12
|
if (subscriptions.size === 0) {
|
|
13
|
-
bindings_1.getBinding().setEventsEnabled(true);
|
|
13
|
+
(0, bindings_1.getBinding)().setEventsEnabled(true);
|
|
14
14
|
}
|
|
15
15
|
subscriptions.add(observer);
|
|
16
16
|
return () => {
|
|
17
17
|
subscriptions.delete(observer);
|
|
18
18
|
if (subscriptions.size === 0) {
|
|
19
|
-
bindings_1.getBinding().setEventsEnabled(false);
|
|
19
|
+
(0, bindings_1.getBinding)().setEventsEnabled(false);
|
|
20
20
|
}
|
|
21
21
|
};
|
|
22
22
|
});
|
|
@@ -29,7 +29,7 @@ const eventParsers = {
|
|
|
29
29
|
'interface/disconnected': main_pb_1.DisconnectedEvent,
|
|
30
30
|
};
|
|
31
31
|
const eventHandler = (eventBuffer) => {
|
|
32
|
-
const structBuffers = serialization_1.deserialize(eventBuffer);
|
|
32
|
+
const structBuffers = (0, serialization_1.deserialize)(eventBuffer);
|
|
33
33
|
const event = main_pb_1.Event.deserializeBinary(structBuffers[0]);
|
|
34
34
|
const eventData = structBuffers[1] || null;
|
|
35
35
|
const eventName = event.getEvent();
|
|
@@ -51,7 +51,7 @@ const eventHandler = (eventBuffer) => {
|
|
|
51
51
|
observer.next(eventObject);
|
|
52
52
|
}
|
|
53
53
|
};
|
|
54
|
-
bindings_1.addInitCallback(() => bindings_1.getBinding().setEventHandler(eventHandler));
|
|
55
|
-
const filterEvent = (eventTypeToFilter) => (source) => source.pipe(operators_1.filter(({ eventType }) => eventType === eventTypeToFilter), operators_1.map(({ event }) => event));
|
|
54
|
+
(0, bindings_1.addInitCallback)(() => (0, bindings_1.getBinding)().setEventHandler(eventHandler));
|
|
55
|
+
const filterEvent = (eventTypeToFilter) => (source) => source.pipe((0, operators_1.filter)(({ eventType }) => eventType === eventTypeToFilter), (0, operators_1.map)(({ event }) => event));
|
|
56
56
|
exports.filterEvent = filterEvent;
|
|
57
57
|
//# sourceMappingURL=events.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/gateway/events.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAC5C,8CAA6C;AAE7C,kDAA2E;AAC3E,kDAA0H;AAE1H,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,qBAAU,
|
|
1
|
+
{"version":3,"file":"events.js","sourceRoot":"","sources":["../../../src/gateway/events.ts"],"names":[],"mappings":";;;AACA,+BAA4C;AAC5C,8CAA6C;AAE7C,kDAA2E;AAC3E,kDAA0H;AAE1H,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,aAA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AAE,CAAC,CAAC;KACjF;IAED,IAAI,cAAc,GAAmC,IAAI,CAAC;IAC1D,IAAI,SAAS,EAAE;QACb,cAAc,GAAG,WAAW,CAAC,iBAAiB,CAAC,SAAS,CAAC,CAAC,QAAQ,EAAE,CAAC;KACtE;IAED,MAAM,WAAW,GAAa,EAAE,SAAS,EAAE,KAAK,CAAC,QAAQ,EAAE,EAAE,KAAK,EAAE,cAAc,EAAE,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 { Event, TestEvent, DisconnectedEvent } from '../protobufs/main_pb';\nimport { UnknownResponseEvent, UnknownBinaryResponseEvent, AlertEvent, BinaryReplyOnlyEvent } 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"]}
|
package/dist/lib/gateway/wasm.js
CHANGED
|
@@ -4,7 +4,7 @@ exports.runWasm = void 0;
|
|
|
4
4
|
const wasm_exec_1 = require("./wasm-exec");
|
|
5
5
|
const runWasm = async (fetchResponse) => {
|
|
6
6
|
if (window.Go == null) {
|
|
7
|
-
wasm_exec_1.wasmExec();
|
|
7
|
+
(0, wasm_exec_1.wasmExec)();
|
|
8
8
|
}
|
|
9
9
|
const go = new window.Go();
|
|
10
10
|
const result = await window.WebAssembly.instantiateStreaming(fetchResponse, go.importObject);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../../src/gateway/wasm.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAMhC,MAAM,OAAO,GAAG,KAAK,EAAE,aAA2B,EAA0B,EAAE;IACnF,IAAI,MAAM,CAAC,EAAE,IAAI,IAAI,EAAE;QACrB,oBAAQ,
|
|
1
|
+
{"version":3,"file":"wasm.js","sourceRoot":"","sources":["../../../src/gateway/wasm.ts"],"names":[],"mappings":";;;AAAA,2CAAuC;AAMhC,MAAM,OAAO,GAAG,KAAK,EAAE,aAA2B,EAA0B,EAAE;IACnF,IAAI,MAAM,CAAC,EAAE,IAAI,IAAI,EAAE;QACrB,IAAA,oBAAQ,GAAE,CAAC;KACZ;IACD,MAAM,EAAE,GAAG,IAAI,MAAM,CAAC,EAAE,EAAE,CAAC;IAC3B,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,WAAW,CAAC,oBAAoB,CAC1D,aAAa,EACb,EAAE,CAAC,YAAY,CAChB,CAAC;IACF,MAAM,YAAY,GAAG,IAAI,OAAO,CAAO,OAAO,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC,CAAC;IACjF,MAAM,UAAU,GAAG,EAAE,CAAC,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAE3C,MAAM,OAAO,CAAC,IAAI,CAAC,CAAC,YAAY,EAAE,UAAU,CAAC,CAAC,CAAC;IAC/C,OAAO,EAAE,UAAU,EAAE,CAAC;AACxB,CAAC,CAAC;AAdW,QAAA,OAAO,WAclB","sourcesContent":["import { wasmExec } from './wasm-exec';\n\nexport interface RunWasmResult {\n runPromise: Promise<void>;\n}\n\nexport const runWasm = async (fetchResponse: Promise<any>): Promise<RunWasmResult> => {\n if (window.Go == null) {\n wasmExec();\n }\n const go = new window.Go();\n const result = await window.WebAssembly.instantiateStreaming(\n fetchResponse,\n go.importObject\n );\n const startPromise = new Promise<void>(resolve => window.__zmlStarted = resolve);\n const runPromise = go.run(result.instance);\n\n await Promise.race([startPromise, runPromise]);\n return { runPromise };\n};\n"]}
|
package/dist/lib/index.d.ts
CHANGED
package/dist/lib/index.js
CHANGED
|
@@ -13,7 +13,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
13
13
|
exports.Tools = exports.CanSetStateDeviceResponse = exports.CanSetStateAxisResponse = exports.RotationDirection = exports.Measurement = exports.LogOutputMode = exports.Library = exports.FirmwareVersion = exports.DeviceDbSourceType = void 0;
|
|
14
14
|
__exportStar(require("./ascii_ns"), exports);
|
|
15
15
|
__exportStar(require("./binary_ns"), exports);
|
|
16
|
-
__exportStar(require("./gcode_ns"), exports);
|
|
17
16
|
__exportStar(require("./exceptions"), exports);
|
|
18
17
|
var device_db_source_type_1 = require("./device_db_source_type");
|
|
19
18
|
Object.defineProperty(exports, "DeviceDbSourceType", { enumerable: true, get: function () { return device_db_source_type_1.DeviceDbSourceType; } });
|
package/dist/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;AAAA,6CAA2B;AAC3B,8CAA4B;AAC5B,+CAA6B;AAC7B,iEAA6D;AAApD,2HAAA,kBAAkB,OAAA;AAC3B,uDAAqD;AAA5C,mHAAA,eAAe,OAAA;AACxB,qCAAoC;AAA3B,kGAAA,OAAO,OAAA;AAChB,qDAAkD;AAAzC,gHAAA,aAAa,OAAA;AACtB,6CAA4C;AAAnC,0GAAA,WAAW,OAAA;AACpB,2DAAyD;AAAhD,uHAAA,iBAAiB,OAAA;AAC1B,6EAAwE;AAA/D,sIAAA,uBAAuB,OAAA;AAChC,iFAA4E;AAAnE,0IAAA,yBAAyB,OAAA;AAClC,iCAAgC;AAAvB,8FAAA,KAAK,OAAA;AACd,0CAAwB","sourcesContent":["export * from './ascii_ns';\nexport * from './binary_ns';\nexport * from './exceptions';\nexport { DeviceDbSourceType } from './device_db_source_type';\nexport { FirmwareVersion } from './firmware_version';\nexport { Library } from './library';\nexport { LogOutputMode } from './log_output_mode';\nexport { Measurement } from './measurement';\nexport { RotationDirection } from './rotation_direction';\nexport { CanSetStateAxisResponse } from './can_set_state_axis_response';\nexport { CanSetStateDeviceResponse } from './can_set_state_device_response';\nexport { Tools } from './tools';\nexport * from './units';\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measurement.js","sourceRoot":"","sources":["../../src/measurement.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,mDAAqC;AAmBrC,IAAiB,WAAW,CAU3B;AAVD,WAAiB,WAAW;IACb,kBAAM,GAAG,aAAa,CAAC;IAEpC,gBAAgB;IAChB,SAAgB,UAAU,CAAC,MAAmB;QAC5C,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IALe,sBAAU,aAKzB,CAAA;AACH,CAAC,EAVgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAU3B","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from './gateway';\nimport { Units } from './units';\n\n/**\n * Represents a numerical value with optional units specified.\n */\nexport interface Measurement {\n /**\n * Value of the measurement.\n */\n value: number;\n\n /**\n * Optional units of the measurement.\n */\n unit?: Units;\n\n}\n\nexport namespace Measurement {\n export const __type = 'Measurement';\n\n /** @internal */\n export function toProtobuf(source: Measurement): gateway.Measurement {\n const pbData = new gateway.Measurement();\n pbData.setValue(source.value);\n pbData.setUnit(source.unit!);\n return pbData;\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"measurement.js","sourceRoot":"","sources":["../../src/measurement.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,mDAAqC;AAmBrC,IAAiB,WAAW,CAU3B;AAVD,WAAiB,WAAW;IACb,kBAAM,GAAG,aAAa,CAAC;IAEpC,gBAAgB;IAChB,SAAgB,UAAU,CAAC,MAAmB;QAC5C,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACzC,MAAM,CAAC,QAAQ,CAAC,MAAM,CAAC,KAAK,CAAC,CAAC;QAC9B,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,IAAK,CAAC,CAAC;QAC7B,OAAO,MAAM,CAAC;IAChB,CAAC;IALe,sBAAU,aAKzB,CAAA;AACH,CAAC,EAVgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAU3B","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from './gateway';\nimport { Units } from './units';\n\n/**\n * Represents a numerical value with optional units specified.\n */\nexport interface Measurement {\n /**\n * Value of the measurement.\n */\n value: number;\n\n /**\n * Optional units of the measurement.\n */\n unit?: Units | null;\n\n}\n\nexport namespace Measurement {\n export const __type = 'Measurement';\n\n /** @internal */\n export function toProtobuf(source: Measurement): gateway.Measurement {\n const pbData = new gateway.Measurement();\n pbData.setValue(source.value);\n pbData.setUnit(source.unit!);\n return pbData;\n }\n}\n"]}
|