@zaber/motion 2.9.1 → 2.11.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.d.ts +11 -0
- package/dist/lib/ascii/connection.js +11 -0
- package/dist/lib/ascii/connection.js.map +1 -1
- package/dist/lib/ascii/device.d.ts +6 -0
- package/dist/lib/ascii/device.js +8 -0
- package/dist/lib/ascii/device.js.map +1 -1
- package/dist/lib/ascii/index.d.ts +9 -0
- package/dist/lib/ascii/index.js +19 -1
- package/dist/lib/ascii/index.js.map +1 -1
- package/dist/lib/ascii/oscilloscope.d.ts +62 -0
- package/dist/lib/ascii/oscilloscope.js +153 -0
- package/dist/lib/ascii/oscilloscope.js.map +1 -0
- package/dist/lib/ascii/oscilloscope_capture_properties.d.ts +16 -0
- package/dist/lib/ascii/oscilloscope_capture_properties.js +18 -0
- package/dist/lib/ascii/oscilloscope_capture_properties.js.map +1 -0
- package/dist/lib/ascii/oscilloscope_data.d.ts +67 -0
- package/dist/lib/ascii/oscilloscope_data.js +151 -0
- package/dist/lib/ascii/oscilloscope_data.js.map +1 -0
- package/dist/lib/ascii/paramset_info.d.ts +17 -0
- package/dist/lib/ascii/paramset_info.js +19 -0
- package/dist/lib/ascii/paramset_info.js.map +1 -0
- package/dist/lib/ascii/pid_tuning.d.ts +32 -0
- package/dist/lib/ascii/pid_tuning.js +22 -0
- package/dist/lib/ascii/pid_tuning.js.map +1 -0
- package/dist/lib/ascii/servo_tuner.d.ts +77 -0
- package/dist/lib/ascii/servo_tuner.js +180 -0
- package/dist/lib/ascii/servo_tuner.js.map +1 -0
- package/dist/lib/ascii/servo_tuning_param.d.ts +16 -0
- package/dist/lib/ascii/servo_tuning_param.js +49 -0
- package/dist/lib/ascii/servo_tuning_param.js.map +1 -0
- package/dist/lib/ascii/servo_tuning_paramset.d.ts +17 -0
- package/dist/lib/ascii/servo_tuning_paramset.js +24 -0
- package/dist/lib/ascii/servo_tuning_paramset.js.map +1 -0
- package/dist/lib/ascii/simple_tuning_param.d.ts +24 -0
- package/dist/lib/ascii/simple_tuning_param.js +20 -0
- package/dist/lib/ascii/simple_tuning_param.js.map +1 -0
- package/dist/lib/ascii/stream.d.ts +7 -0
- package/dist/lib/ascii/stream.js +14 -0
- package/dist/lib/ascii/stream.js.map +1 -1
- package/dist/lib/ascii/stream_axis_definition.js +3 -0
- package/dist/lib/ascii/stream_axis_definition.js.map +1 -1
- package/dist/lib/ascii/transport.d.ts +4 -0
- package/dist/lib/ascii/transport.js +4 -0
- package/dist/lib/ascii/transport.js.map +1 -1
- package/dist/lib/ascii_ns.d.ts +18 -0
- package/dist/lib/ascii_ns.js +9 -0
- package/dist/lib/ascii_ns.js.map +1 -1
- package/dist/lib/exceptions/index.d.ts +1 -0
- package/dist/lib/exceptions/index.js +4 -2
- package/dist/lib/exceptions/index.js.map +1 -1
- package/dist/lib/exceptions/invalid_operation_exception.d.ts +7 -0
- package/dist/lib/exceptions/invalid_operation_exception.js +17 -0
- package/dist/lib/exceptions/invalid_operation_exception.js.map +1 -0
- package/dist/lib/gateway/convert_exceptions.js +1 -0
- package/dist/lib/gateway/convert_exceptions.js.map +1 -1
- package/dist/lib/gcode/axis_definition.d.ts +18 -0
- package/dist/lib/gcode/{translator_axis_definition.js → axis_definition.js} +11 -10
- package/dist/lib/gcode/axis_definition.js.map +1 -0
- package/dist/lib/gcode/axis_mapping.js +3 -0
- package/dist/lib/gcode/axis_mapping.js.map +1 -1
- package/dist/lib/gcode/axis_transformation.d.ts +21 -0
- package/dist/lib/gcode/axis_transformation.js +43 -0
- package/dist/lib/gcode/axis_transformation.js.map +1 -0
- package/dist/lib/gcode/device_definition.d.ts +24 -0
- package/dist/lib/gcode/{translator_definition.js → device_definition.js} +14 -9
- package/dist/lib/gcode/device_definition.js.map +1 -0
- package/dist/lib/gcode/index.d.ts +4 -3
- package/dist/lib/gcode/index.js +9 -7
- package/dist/lib/gcode/index.js.map +1 -1
- package/dist/lib/gcode/offline_translator.d.ts +114 -0
- package/dist/lib/gcode/offline_translator.js +226 -0
- package/dist/lib/gcode/offline_translator.js.map +1 -0
- package/dist/lib/gcode/translator.d.ts +66 -12
- package/dist/lib/gcode/translator.js +113 -17
- package/dist/lib/gcode/translator.js.map +1 -1
- package/dist/lib/gcode/translator_config.d.ts +6 -6
- package/dist/lib/gcode/translator_config.js +7 -4
- package/dist/lib/gcode/translator_config.js.map +1 -1
- package/dist/lib/gcode_ns.d.ts +8 -6
- package/dist/lib/gcode_ns.js +4 -3
- package/dist/lib/gcode_ns.js.map +1 -1
- package/dist/lib/measurement.js +3 -0
- package/dist/lib/measurement.js.map +1 -1
- package/dist/lib/protobufs/main_pb.d.ts +1011 -30
- package/dist/lib/protobufs/main_pb.js +12857 -5306
- package/dist/lib/protobufs/main_pb.js.map +1 -1
- package/dist/lib/tools.d.ts +6 -0
- package/dist/lib/tools.js +10 -0
- package/dist/lib/tools.js.map +1 -1
- package/package.json +1 -1
- package/dist/lib/gcode/translator_axis_definition.d.ts +0 -20
- package/dist/lib/gcode/translator_axis_definition.js.map +0 -1
- package/dist/lib/gcode/translator_definition.d.ts +0 -18
- 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
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"offline_translator.js","sourceRoot":"","sources":["../../../src/gcode/offline_translator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,2DAAuD;AACvD,2DAAuD;AACvD,yDAAqD;AAErD,4CAAuD;AAEvD;;;;GAIG;AACH,MAAa,iBAAiB;IAgB5B,YAAY,YAAoB;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAA,m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AAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAC/B,qCAAqC,EACrC,OAAO,EACP,OAAO,CAAC,4CAA4C,CAAC,CAAC;QACxD,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,iBAAiB,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IAC7C,CAAC;CACF;AA5QD,8CA4QC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { DeviceDefinition } from './device_definition';\nimport { TranslatorConfig } from './translator_config';\nimport { TranslateResult } from './translate_result';\nimport { Angle, Length, Native, AngularVelocity, Velocity } from '../units';\nimport { registerForFinalization } from '../finalizer';\n\n/**\n * Represents an offline G-Code translator.\n * It allows to translate G-Code blocks to Zaber ASCII protocol stream commands.\n * This translator does not need a connected device to perform translation.\n */\nexport class OfflineTranslator {\n /**\n * The ID of the translator that serves to identify native resources.\n */\n public get translatorId(): number {\n return this._translatorId;\n }\n private _translatorId: number;\n\n /**\n * Current coordinate system.\n */\n public get coordinateSystem(): string {\n return this._getCurrentCoordinateSystem();\n }\n\n constructor(translatorId: number) {\n this._translatorId = translatorId;\n registerForFinalization(this, OfflineTranslator._free.bind(null, translatorId));\n }\n\n /**\n * Sets up translator from provided device definition and configuration.\n * @param definition Definition of device and its peripherals.\n * The definition must match a device that later performs the commands.\n * @param config? Configuration of the translator.\n * @return New instance of translator.\n */\n public static async setup(\n definition: DeviceDefinition,\n config?: TranslatorConfig\n ): Promise<OfflineTranslator> {\n const request = new gateway.TranslatorCreateRequest();\n request.setDefinition(DeviceDefinition.toProtobuf(definition));\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create',\n request,\n gateway.TranslatorCreateResponse);\n return new OfflineTranslator(response.getTranslatorId());\n }\n\n /**\n * Translates a single block (line) of G-code.\n * @param block Block (line) of G-code.\n * @return Result of translation containing the stream commands.\n */\n public translate(\n block: string\n ): TranslateResult {\n const request = new gateway.TranslatorTranslateRequest();\n request.setTranslatorId(this.translatorId);\n request.setBlock(block);\n\n const response = gateway.callSync<gateway.TranslatorTranslateResponse>(\n 'gcode/translate',\n request,\n gateway.TranslatorTranslateResponse);\n return TranslateResult.fromProtobuf(response.toObject());\n }\n\n /**\n * Flushes the remaining stream commands waiting in optimization buffer.\n * The flush is also performed by M2 and M30 codes.\n * @return The remaining stream commands.\n */\n public flush(): string[] {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.TranslatorFlushResponse>(\n 'gcode/flush',\n request,\n gateway.TranslatorFlushResponse);\n return response.getCommandsList();\n }\n\n /**\n * Sets the speed at which the device moves when traversing (G0).\n * @param traverseRate The traverse rate.\n * @param unit Units of the traverse rate.\n */\n public setTraverseRate(\n traverseRate: number,\n unit: Velocity | AngularVelocity | Native\n ): void {\n const request = new gateway.TranslatorSetTraverseRateRequest();\n request.setTranslatorId(this.translatorId);\n request.setTraverseRate(traverseRate);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_traverse_rate', request);\n }\n\n /**\n * Sets position of translator's axis.\n * Use this method to set position after performing movement outside of the translator.\n * This method does not cause any movement.\n * @param axis Letter of the axis.\n * @param position The position.\n * @param unit Units of position.\n */\n public setAxisPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_position', request);\n }\n\n /**\n * Gets position of translator's axis.\n * This method does not query device but returns value from translator's state.\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @return Position of translator's axis.\n */\n public getAxisPosition(\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.TranslatorGetAxisPositionResponse>(\n 'gcode/get_axis_position',\n request,\n gateway.TranslatorGetAxisPositionResponse);\n return response.getValue();\n }\n\n /**\n * Sets the home position of translator's axis.\n * This position is used by G28.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_home', request);\n }\n\n /**\n * Sets the secondary home position of translator's axis.\n * This position is used by G30.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisSecondaryHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_secondary_home', request);\n }\n\n /**\n * Gets offset of an axis in a given coordinate system.\n * @param coordinateSystem Coordinate system (e.g. G54).\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @return Offset in translator units of the axis.\n */\n public getAxisCoordinateSystemOffset(\n coordinateSystem: string,\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisOffsetRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoordinateSystem(coordinateSystem);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.TranslatorGetAxisPositionResponse>(\n 'gcode/get_axis_offset',\n request,\n gateway.TranslatorGetAxisPositionResponse);\n return response.getValue();\n }\n\n /**\n * Resets internal state after device rejected generated command.\n * Axis positions become uninitialized.\n */\n public resetAfterStreamError(): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n gateway.callSync('gcode/reset_after_stream_error', request);\n }\n\n /**\n * Allows to scale feed rate of the translated code by a coefficient.\n * @param coefficient Coefficient of the original feed rate.\n */\n public setFeedRateOverride(\n coefficient: number\n ): void {\n const request = new gateway.TranslatorSetFeedRateOverrideRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoefficient(coefficient);\n\n gateway.callSync('gcode/set_feed_rate_override', request);\n }\n\n /**\n * Releases native resources of a translator.\n * @param translatorId The ID of the translator.\n */\n private static _free(\n translatorId: number\n ): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(translatorId);\n\n gateway.callSync('gcode/free', request);\n }\n\n /**\n * Gets current coordinate system (e.g. G54).\n * @return Current coordinate system.\n */\n private _getCurrentCoordinateSystem(): string {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.TranslatorGetCurrentCoordinateSystemResponse>(\n 'gcode/get_current_coordinate_system',\n request,\n gateway.TranslatorGetCurrentCoordinateSystemResponse);\n return response.getValue();\n }\n\n /**\n * Releases the native resources of the translator.\n * Should only be called if your environment does not support FinalizationRegistry.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\n public free(): void {\n OfflineTranslator._free(this.translatorId);\n }\n}\n"]}
|
|
@@ -1,28 +1,51 @@
|
|
|
1
|
-
import { TranslatorDefinition } from './translator_definition';
|
|
2
|
-
import { TranslatorConfig } from './translator_config';
|
|
3
1
|
import { TranslateResult } from './translate_result';
|
|
2
|
+
import { TranslatorConfig } from './translator_config';
|
|
3
|
+
import { Stream } from '../ascii/stream';
|
|
4
4
|
import { Angle, Length, Native, AngularVelocity, Velocity } from '../units';
|
|
5
|
+
/**
|
|
6
|
+
* Represents a live G-Code translator.
|
|
7
|
+
* It allows to stream G-Code blocks to a connected device.
|
|
8
|
+
* It requires a stream to be setup on the device.
|
|
9
|
+
*/
|
|
5
10
|
export declare class Translator {
|
|
6
11
|
/**
|
|
7
12
|
* The ID of the translator that serves to identify native resources.
|
|
8
13
|
*/
|
|
9
14
|
get translatorId(): number;
|
|
10
15
|
private _translatorId;
|
|
16
|
+
/**
|
|
17
|
+
* Current coordinate system.
|
|
18
|
+
*/
|
|
19
|
+
get coordinateSystem(): string;
|
|
11
20
|
constructor(translatorId: number);
|
|
12
21
|
/**
|
|
13
|
-
* Sets up translator
|
|
14
|
-
* @param
|
|
15
|
-
* The
|
|
16
|
-
* @param config Configuration of the translator.
|
|
22
|
+
* Sets up the translator on top of a provided stream.
|
|
23
|
+
* @param stream The stream to setup the translator on.
|
|
24
|
+
* The stream must be already setup in a live or a store mode.
|
|
25
|
+
* @param config? Configuration of the translator.
|
|
17
26
|
* @return New instance of translator.
|
|
18
27
|
*/
|
|
19
|
-
static setup(
|
|
28
|
+
static setup(stream: Stream, config?: TranslatorConfig): Promise<Translator>;
|
|
20
29
|
/**
|
|
21
30
|
* Translates a single block (line) of G-code.
|
|
31
|
+
* The commands are queued in the underlying stream to ensure smooth continues movement.
|
|
32
|
+
* Returning of this method indicates that the commands are queued (not necessarily executed).
|
|
22
33
|
* @param block Block (line) of G-code.
|
|
23
|
-
* @return Result of translation containing the
|
|
34
|
+
* @return Result of translation containing the commands sent to the device.
|
|
35
|
+
*/
|
|
36
|
+
translate(block: string): Promise<TranslateResult>;
|
|
37
|
+
/**
|
|
38
|
+
* Flushes the remaining stream commands waiting in optimization buffer into the underlying stream.
|
|
39
|
+
* The flush is also performed by M2 and M30 codes.
|
|
40
|
+
* @param waitUntilIdle Determines whether to wait for the stream to finish all the movements.
|
|
41
|
+
* @return The remaining stream commands.
|
|
24
42
|
*/
|
|
25
|
-
|
|
43
|
+
flush(waitUntilIdle?: boolean): Promise<string[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Resets position of the translator from the underlying stream.
|
|
46
|
+
* Call this method after performing a movement outside of translator.
|
|
47
|
+
*/
|
|
48
|
+
resetPosition(): Promise<void>;
|
|
26
49
|
/**
|
|
27
50
|
* Sets the speed at which the device moves when traversing (G0).
|
|
28
51
|
* @param traverseRate The traverse rate.
|
|
@@ -47,18 +70,49 @@ export declare class Translator {
|
|
|
47
70
|
*/
|
|
48
71
|
getAxisPosition(axis: string, unit: Length | Angle | Native): number;
|
|
49
72
|
/**
|
|
50
|
-
* Sets
|
|
73
|
+
* Sets the home position of translator's axis.
|
|
51
74
|
* This position is used by G28.
|
|
52
75
|
* @param axis Letter of the axis.
|
|
53
|
-
* @param position The
|
|
76
|
+
* @param position The home position.
|
|
77
|
+
* @param unit Units of position.
|
|
78
|
+
*/
|
|
79
|
+
setAxisHomePosition(axis: string, position: number, unit: Length | Angle | Native): void;
|
|
80
|
+
/**
|
|
81
|
+
* Sets the secondary home position of translator's axis.
|
|
82
|
+
* This position is used by G30.
|
|
83
|
+
* @param axis Letter of the axis.
|
|
84
|
+
* @param position The home position.
|
|
85
|
+
* @param unit Units of position.
|
|
86
|
+
*/
|
|
87
|
+
setAxisSecondaryHomePosition(axis: string, position: number, unit: Length | Angle | Native): void;
|
|
88
|
+
/**
|
|
89
|
+
* Gets offset of an axis in a given coordinate system.
|
|
90
|
+
* @param coordinateSystem Coordinate system (e.g. G54).
|
|
91
|
+
* @param axis Letter of the axis.
|
|
54
92
|
* @param unit Units of position.
|
|
93
|
+
* @return Offset in translator units of the axis.
|
|
55
94
|
*/
|
|
56
|
-
|
|
95
|
+
getAxisCoordinateSystemOffset(coordinateSystem: string, axis: string, unit: Length | Angle | Native): number;
|
|
96
|
+
/**
|
|
97
|
+
* Resets internal state after device rejected generated command.
|
|
98
|
+
* Axis positions become uninitialized.
|
|
99
|
+
*/
|
|
100
|
+
resetAfterStreamError(): void;
|
|
101
|
+
/**
|
|
102
|
+
* Allows to scale feed rate of the translated code by a coefficient.
|
|
103
|
+
* @param coefficient Coefficient of the original feed rate.
|
|
104
|
+
*/
|
|
105
|
+
setFeedRateOverride(coefficient: number): void;
|
|
57
106
|
/**
|
|
58
107
|
* Releases native resources of a translator.
|
|
59
108
|
* @param translatorId The ID of the translator.
|
|
60
109
|
*/
|
|
61
110
|
private static _free;
|
|
111
|
+
/**
|
|
112
|
+
* Gets current coordinate system (e.g. G54).
|
|
113
|
+
* @return Current coordinate system.
|
|
114
|
+
*/
|
|
115
|
+
private _getCurrentCoordinateSystem;
|
|
62
116
|
/**
|
|
63
117
|
* Releases the native resources of the translator.
|
|
64
118
|
* Should only be called if your environment does not support FinalizationRegistry.
|
|
@@ -23,10 +23,14 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.Translator = void 0;
|
|
25
25
|
const gateway = __importStar(require("../gateway"));
|
|
26
|
-
const translator_definition_1 = require("./translator_definition");
|
|
27
|
-
const translator_config_1 = require("./translator_config");
|
|
28
26
|
const translate_result_1 = require("./translate_result");
|
|
27
|
+
const translator_config_1 = require("./translator_config");
|
|
29
28
|
const finalizer_1 = require("../finalizer");
|
|
29
|
+
/**
|
|
30
|
+
* Represents a live G-Code translator.
|
|
31
|
+
* It allows to stream G-Code blocks to a connected device.
|
|
32
|
+
* It requires a stream to be setup on the device.
|
|
33
|
+
*/
|
|
30
34
|
class Translator {
|
|
31
35
|
constructor(translatorId) {
|
|
32
36
|
this._translatorId = translatorId;
|
|
@@ -39,31 +43,63 @@ class Translator {
|
|
|
39
43
|
return this._translatorId;
|
|
40
44
|
}
|
|
41
45
|
/**
|
|
42
|
-
*
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
+
* Current coordinate system.
|
|
47
|
+
*/
|
|
48
|
+
get coordinateSystem() {
|
|
49
|
+
return this._getCurrentCoordinateSystem();
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* Sets up the translator on top of a provided stream.
|
|
53
|
+
* @param stream The stream to setup the translator on.
|
|
54
|
+
* The stream must be already setup in a live or a store mode.
|
|
55
|
+
* @param config? Configuration of the translator.
|
|
46
56
|
* @return New instance of translator.
|
|
47
57
|
*/
|
|
48
|
-
static async setup(
|
|
49
|
-
const request = new gateway.
|
|
50
|
-
request.
|
|
58
|
+
static async setup(stream, config) {
|
|
59
|
+
const request = new gateway.TranslatorCreateLiveRequest();
|
|
60
|
+
request.setDevice(stream.device.deviceAddress);
|
|
61
|
+
request.setInterfaceId(stream.device.connection.interfaceId);
|
|
62
|
+
request.setStreamId(stream.streamId);
|
|
51
63
|
request.setConfig(translator_config_1.TranslatorConfig.toProtobuf(config));
|
|
52
|
-
const response = await gateway.callAsync('gcode/
|
|
64
|
+
const response = await gateway.callAsync('gcode/create_live', request, gateway.TranslatorCreateResponse);
|
|
53
65
|
return new Translator(response.getTranslatorId());
|
|
54
66
|
}
|
|
55
67
|
/**
|
|
56
68
|
* Translates a single block (line) of G-code.
|
|
69
|
+
* The commands are queued in the underlying stream to ensure smooth continues movement.
|
|
70
|
+
* Returning of this method indicates that the commands are queued (not necessarily executed).
|
|
57
71
|
* @param block Block (line) of G-code.
|
|
58
|
-
* @return Result of translation containing the
|
|
72
|
+
* @return Result of translation containing the commands sent to the device.
|
|
59
73
|
*/
|
|
60
|
-
translate(block) {
|
|
74
|
+
async translate(block) {
|
|
61
75
|
const request = new gateway.TranslatorTranslateRequest();
|
|
62
76
|
request.setTranslatorId(this.translatorId);
|
|
63
77
|
request.setBlock(block);
|
|
64
|
-
const response = gateway.
|
|
78
|
+
const response = await gateway.callAsync('gcode/translate_live', request, gateway.TranslatorTranslateResponse);
|
|
65
79
|
return translate_result_1.TranslateResult.fromProtobuf(response.toObject());
|
|
66
80
|
}
|
|
81
|
+
/**
|
|
82
|
+
* Flushes the remaining stream commands waiting in optimization buffer into the underlying stream.
|
|
83
|
+
* The flush is also performed by M2 and M30 codes.
|
|
84
|
+
* @param waitUntilIdle Determines whether to wait for the stream to finish all the movements.
|
|
85
|
+
* @return The remaining stream commands.
|
|
86
|
+
*/
|
|
87
|
+
async flush(waitUntilIdle = true) {
|
|
88
|
+
const request = new gateway.TranslatorFlushLiveRequest();
|
|
89
|
+
request.setTranslatorId(this.translatorId);
|
|
90
|
+
request.setWaitUntilIdle(waitUntilIdle);
|
|
91
|
+
const response = await gateway.callAsync('gcode/flush_live', request, gateway.TranslatorFlushResponse);
|
|
92
|
+
return response.getCommandsList();
|
|
93
|
+
}
|
|
94
|
+
/**
|
|
95
|
+
* Resets position of the translator from the underlying stream.
|
|
96
|
+
* Call this method after performing a movement outside of translator.
|
|
97
|
+
*/
|
|
98
|
+
async resetPosition() {
|
|
99
|
+
const request = new gateway.TranslatorEmptyRequest();
|
|
100
|
+
request.setTranslatorId(this.translatorId);
|
|
101
|
+
await gateway.callAsync('gcode/reset_position_from_stream', request);
|
|
102
|
+
}
|
|
67
103
|
/**
|
|
68
104
|
* Sets the speed at which the device moves when traversing (G0).
|
|
69
105
|
* @param traverseRate The traverse rate.
|
|
@@ -108,19 +144,69 @@ class Translator {
|
|
|
108
144
|
return response.getValue();
|
|
109
145
|
}
|
|
110
146
|
/**
|
|
111
|
-
* Sets
|
|
147
|
+
* Sets the home position of translator's axis.
|
|
112
148
|
* This position is used by G28.
|
|
113
149
|
* @param axis Letter of the axis.
|
|
114
|
-
* @param position The
|
|
150
|
+
* @param position The home position.
|
|
151
|
+
* @param unit Units of position.
|
|
152
|
+
*/
|
|
153
|
+
setAxisHomePosition(axis, position, unit) {
|
|
154
|
+
const request = new gateway.TranslatorSetAxisPositionRequest();
|
|
155
|
+
request.setTranslatorId(this.translatorId);
|
|
156
|
+
request.setAxis(axis);
|
|
157
|
+
request.setPosition(position);
|
|
158
|
+
request.setUnit(unit);
|
|
159
|
+
gateway.callSync('gcode/set_axis_home', request);
|
|
160
|
+
}
|
|
161
|
+
/**
|
|
162
|
+
* Sets the secondary home position of translator's axis.
|
|
163
|
+
* This position is used by G30.
|
|
164
|
+
* @param axis Letter of the axis.
|
|
165
|
+
* @param position The home position.
|
|
115
166
|
* @param unit Units of position.
|
|
116
167
|
*/
|
|
117
|
-
|
|
168
|
+
setAxisSecondaryHomePosition(axis, position, unit) {
|
|
118
169
|
const request = new gateway.TranslatorSetAxisPositionRequest();
|
|
119
170
|
request.setTranslatorId(this.translatorId);
|
|
120
171
|
request.setAxis(axis);
|
|
121
172
|
request.setPosition(position);
|
|
122
173
|
request.setUnit(unit);
|
|
123
|
-
gateway.callSync('gcode/
|
|
174
|
+
gateway.callSync('gcode/set_axis_secondary_home', request);
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Gets offset of an axis in a given coordinate system.
|
|
178
|
+
* @param coordinateSystem Coordinate system (e.g. G54).
|
|
179
|
+
* @param axis Letter of the axis.
|
|
180
|
+
* @param unit Units of position.
|
|
181
|
+
* @return Offset in translator units of the axis.
|
|
182
|
+
*/
|
|
183
|
+
getAxisCoordinateSystemOffset(coordinateSystem, axis, unit) {
|
|
184
|
+
const request = new gateway.TranslatorGetAxisOffsetRequest();
|
|
185
|
+
request.setTranslatorId(this.translatorId);
|
|
186
|
+
request.setCoordinateSystem(coordinateSystem);
|
|
187
|
+
request.setAxis(axis);
|
|
188
|
+
request.setUnit(unit);
|
|
189
|
+
const response = gateway.callSync('gcode/get_axis_offset', request, gateway.TranslatorGetAxisPositionResponse);
|
|
190
|
+
return response.getValue();
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Resets internal state after device rejected generated command.
|
|
194
|
+
* Axis positions become uninitialized.
|
|
195
|
+
*/
|
|
196
|
+
resetAfterStreamError() {
|
|
197
|
+
const request = new gateway.TranslatorEmptyRequest();
|
|
198
|
+
request.setTranslatorId(this.translatorId);
|
|
199
|
+
gateway.callSync('gcode/reset_after_stream_error', request);
|
|
200
|
+
}
|
|
201
|
+
/**
|
|
202
|
+
* Allows to scale feed rate of the translated code by a coefficient.
|
|
203
|
+
* @param coefficient Coefficient of the original feed rate.
|
|
204
|
+
*/
|
|
205
|
+
setFeedRateOverride(coefficient) {
|
|
206
|
+
const request = new gateway.TranslatorSetFeedRateOverrideRequest();
|
|
207
|
+
request.setTranslatorId(this.translatorId);
|
|
208
|
+
request.setCoefficient(coefficient);
|
|
209
|
+
gateway.callSync('gcode/set_feed_rate_override', request);
|
|
124
210
|
}
|
|
125
211
|
/**
|
|
126
212
|
* Releases native resources of a translator.
|
|
@@ -131,6 +217,16 @@ class Translator {
|
|
|
131
217
|
request.setTranslatorId(translatorId);
|
|
132
218
|
gateway.callSync('gcode/free', request);
|
|
133
219
|
}
|
|
220
|
+
/**
|
|
221
|
+
* Gets current coordinate system (e.g. G54).
|
|
222
|
+
* @return Current coordinate system.
|
|
223
|
+
*/
|
|
224
|
+
_getCurrentCoordinateSystem() {
|
|
225
|
+
const request = new gateway.TranslatorEmptyRequest();
|
|
226
|
+
request.setTranslatorId(this.translatorId);
|
|
227
|
+
const response = gateway.callSync('gcode/get_current_coordinate_system', request, gateway.TranslatorGetCurrentCoordinateSystemResponse);
|
|
228
|
+
return response.getValue();
|
|
229
|
+
}
|
|
134
230
|
/**
|
|
135
231
|
* Releases the native resources of the translator.
|
|
136
232
|
* Should only be called if your environment does not support FinalizationRegistry.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translator.js","sourceRoot":"","sources":["../../../src/gcode/translator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,mEAA+D;AAC/D,2DAAuD;AACvD,yDAAqD;AAErD,4CAAuD;AAEvD,MAAa,UAAU;IASrB,YAAY,YAAoB;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAA,mCAAuB,EAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAC3E,CAAC;IAXD;;OAEG;IACH,IAAW,YAAY;QACrB,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,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC;QAEtB,OAAO,CAAC,QAAQ,CAAC,wBAAwB,EAAE,OAAO,CAAC,CAAC;IACtD,CAAC;IAED;;;OAGG;IACK,MAAM,CAAC,KAAK,CAClB,YAAoB;QAEpB,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACrD,OAAO,CAAC,eAAe,CAAC,YAAY,CAAC,CAAC;QAEtC,OAAO,CAAC,QAAQ,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAC1C,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;CACF;AA/JD,gCA+JC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { TranslatorDefinition } from './translator_definition';\nimport { TranslatorConfig } from './translator_config';\nimport { TranslateResult } from './translate_result';\nimport { Angle, Length, Native, AngularVelocity, Velocity } from '../units';\nimport { registerForFinalization } from '../finalizer';\n\nexport class Translator {\n /**\n * The ID of the translator that serves to identify native resources.\n */\n public get translatorId(): number {\n return this._translatorId;\n }\n private _translatorId: number;\n\n constructor(translatorId: number) {\n this._translatorId = translatorId;\n registerForFinalization(this, Translator._free.bind(null, translatorId));\n }\n\n /**\n * Sets up translator from provided device definition and configuration.\n * @param definition Definition of device and its peripherals.\n * The definition must match a device that later performs the commands.\n * @param config Configuration of the translator.\n * @return New instance of translator.\n */\n public static async setup(\n definition: TranslatorDefinition,\n config: TranslatorConfig\n ): Promise<Translator> {\n const request = new gateway.TranslatorCreateRequest();\n request.setDefinition(TranslatorDefinition.toProtobuf(definition));\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create',\n request,\n gateway.TranslatorCreateResponse);\n return new Translator(response.getTranslatorId());\n }\n\n /**\n * Translates a single block (line) of G-code.\n * @param block Block (line) of G-code.\n * @return Result of translation containing the stream commands.\n */\n public translate(\n block: string\n ): TranslateResult {\n const request = new gateway.TranslatorTranslateRequest();\n request.setTranslatorId(this.translatorId);\n request.setBlock(block);\n\n const response = gateway.callSync<gateway.TranslatorTranslateResponse>(\n 'gcode/translate',\n request,\n gateway.TranslatorTranslateResponse);\n return TranslateResult.fromProtobuf(response.toObject());\n }\n\n /**\n * Sets the speed at which the device moves when traversing (G0).\n * @param traverseRate The traverse rate.\n * @param unit Units of the traverse rate.\n */\n public setTraverseRate(\n traverseRate: number,\n unit: Velocity | AngularVelocity | Native\n ): void {\n const request = new gateway.TranslatorSetTraverseRateRequest();\n request.setTranslatorId(this.translatorId);\n request.setTraverseRate(traverseRate);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_traverse_rate', request);\n }\n\n /**\n * Sets position of translator's axis.\n * Use this method to set position after performing movement outside of the translator.\n * This method does not cause any movement.\n * @param axis Letter of the axis.\n * @param position The position.\n * @param unit Units of position.\n */\n public setAxisPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_position', request);\n }\n\n /**\n * Gets position of translator's axis.\n * This method does not query device but returns value from translator's state.\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @return Position of translator's axis.\n */\n public getAxisPosition(\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.TranslatorGetAxisPositionResponse>(\n 'gcode/get_axis_position',\n request,\n gateway.TranslatorGetAxisPositionResponse);\n return response.getValue();\n }\n\n /**\n * Sets default position of translator's axis.\n * This position is used by G28.\n * @param axis Letter of the axis.\n * @param position The default position.\n * @param unit Units of position.\n */\n public setAxisDefaultPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_default', request);\n }\n\n /**\n * Releases native resources of a translator.\n * @param translatorId The ID of the translator.\n */\n private static _free(\n translatorId: number\n ): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(translatorId);\n\n gateway.callSync('gcode/free', request);\n }\n\n /**\n * Releases the native resources of the translator.\n * Should only be called if your environment does not support FinalizationRegistry.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\n public free(): void {\n Translator._free(this.translatorId);\n }\n}\n"]}
|
|
1
|
+
{"version":3,"file":"translator.js","sourceRoot":"","sources":["../../../src/gcode/translator.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,yDAAqD;AACrD,2DAAuD;AAGvD,4CAAuD;AAEvD;;;;GAIG;AACH,MAAa,UAAU;IAgBrB,YAAY,YAAoB;QAC9B,IAAI,CAAC,aAAa,GAAG,YAAY,CAAC;QAClC,IAAA,mCAAuB,EAAC,IAAI,EAAE,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,EAAE,YAAY,CAAC,CAAC,CAAC;IAC3E,CAAC;IAlBD;;OAEG;IACH,IAAW,YAAY;QACrB,OAAO,IAAI,CAAC,aAAa,CAAC;IAC5B,CAAC;IAGD;;OAEG;IACH,IAAW,gBAAgB;QACzB,OAAO,IAAI,CAAC,2BAA2B,EAAE,CAAC;IAC5C,CAAC;IAOD;;;;;;OAMG;IACI,MAAM,CAAC,KAAK,CAAC,KAAK,CACvB,MAAc,EACd,MAAyB;QAEzB,MAAM,OAAO,GAAG,IAA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AED;;;OAGG;IACK,2BAA2B;QACjC,MAAM,OAAO,GAAG,IAAI,OAAO,CAAC,sBAAsB,EAAE,CAAC;QACrD,OAAO,CAAC,eAAe,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;QAE3C,MAAM,QAAQ,GAAG,OAAO,CAAC,QAAQ,CAC/B,qCAAqC,EACrC,OAAO,EACP,OAAO,CAAC,4CAA4C,CAAC,CAAC;QACxD,OAAO,QAAQ,CAAC,QAAQ,EAAE,CAAC;IAC7B,CAAC;IAED;;;;OAIG;IACI,IAAI;QACT,UAAU,CAAC,KAAK,CAAC,IAAI,CAAC,YAAY,CAAC,CAAC;IACtC,CAAC;CACF;AA/RD,gCA+RC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { TranslateResult } from './translate_result';\nimport { TranslatorConfig } from './translator_config';\nimport { Stream } from '../ascii/stream';\nimport { Angle, Length, Native, AngularVelocity, Velocity } from '../units';\nimport { registerForFinalization } from '../finalizer';\n\n/**\n * Represents a live G-Code translator.\n * It allows to stream G-Code blocks to a connected device.\n * It requires a stream to be setup on the device.\n */\nexport class Translator {\n /**\n * The ID of the translator that serves to identify native resources.\n */\n public get translatorId(): number {\n return this._translatorId;\n }\n private _translatorId: number;\n\n /**\n * Current coordinate system.\n */\n public get coordinateSystem(): string {\n return this._getCurrentCoordinateSystem();\n }\n\n constructor(translatorId: number) {\n this._translatorId = translatorId;\n registerForFinalization(this, Translator._free.bind(null, translatorId));\n }\n\n /**\n * Sets up the translator on top of a provided stream.\n * @param stream The stream to setup the translator on.\n * The stream must be already setup in a live or a store mode.\n * @param config? Configuration of the translator.\n * @return New instance of translator.\n */\n public static async setup(\n stream: Stream,\n config?: TranslatorConfig\n ): Promise<Translator> {\n const request = new gateway.TranslatorCreateLiveRequest();\n request.setDevice(stream.device.deviceAddress);\n request.setInterfaceId(stream.device.connection.interfaceId);\n request.setStreamId(stream.streamId);\n request.setConfig(TranslatorConfig.toProtobuf(config));\n\n const response = await gateway.callAsync<gateway.TranslatorCreateResponse>(\n 'gcode/create_live',\n request,\n gateway.TranslatorCreateResponse);\n return new Translator(response.getTranslatorId());\n }\n\n /**\n * Translates a single block (line) of G-code.\n * The commands are queued in the underlying stream to ensure smooth continues movement.\n * Returning of this method indicates that the commands are queued (not necessarily executed).\n * @param block Block (line) of G-code.\n * @return Result of translation containing the commands sent to the device.\n */\n public async translate(\n block: string\n ): Promise<TranslateResult> {\n const request = new gateway.TranslatorTranslateRequest();\n request.setTranslatorId(this.translatorId);\n request.setBlock(block);\n\n const response = await gateway.callAsync<gateway.TranslatorTranslateResponse>(\n 'gcode/translate_live',\n request,\n gateway.TranslatorTranslateResponse);\n return TranslateResult.fromProtobuf(response.toObject());\n }\n\n /**\n * Flushes the remaining stream commands waiting in optimization buffer into the underlying stream.\n * The flush is also performed by M2 and M30 codes.\n * @param waitUntilIdle Determines whether to wait for the stream to finish all the movements.\n * @return The remaining stream commands.\n */\n public async flush(\n waitUntilIdle: boolean = true\n ): Promise<string[]> {\n const request = new gateway.TranslatorFlushLiveRequest();\n request.setTranslatorId(this.translatorId);\n request.setWaitUntilIdle(waitUntilIdle);\n\n const response = await gateway.callAsync<gateway.TranslatorFlushResponse>(\n 'gcode/flush_live',\n request,\n gateway.TranslatorFlushResponse);\n return response.getCommandsList();\n }\n\n /**\n * Resets position of the translator from the underlying stream.\n * Call this method after performing a movement outside of translator.\n */\n public async resetPosition(): Promise<void> {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n await gateway.callAsync('gcode/reset_position_from_stream', request);\n }\n\n /**\n * Sets the speed at which the device moves when traversing (G0).\n * @param traverseRate The traverse rate.\n * @param unit Units of the traverse rate.\n */\n public setTraverseRate(\n traverseRate: number,\n unit: Velocity | AngularVelocity | Native\n ): void {\n const request = new gateway.TranslatorSetTraverseRateRequest();\n request.setTranslatorId(this.translatorId);\n request.setTraverseRate(traverseRate);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_traverse_rate', request);\n }\n\n /**\n * Sets position of translator's axis.\n * Use this method to set position after performing movement outside of the translator.\n * This method does not cause any movement.\n * @param axis Letter of the axis.\n * @param position The position.\n * @param unit Units of position.\n */\n public setAxisPosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_position', request);\n }\n\n /**\n * Gets position of translator's axis.\n * This method does not query device but returns value from translator's state.\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @return Position of translator's axis.\n */\n public getAxisPosition(\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.TranslatorGetAxisPositionResponse>(\n 'gcode/get_axis_position',\n request,\n gateway.TranslatorGetAxisPositionResponse);\n return response.getValue();\n }\n\n /**\n * Sets the home position of translator's axis.\n * This position is used by G28.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_home', request);\n }\n\n /**\n * Sets the secondary home position of translator's axis.\n * This position is used by G30.\n * @param axis Letter of the axis.\n * @param position The home position.\n * @param unit Units of position.\n */\n public setAxisSecondaryHomePosition(\n axis: string,\n position: number,\n unit: Length | Angle | Native\n ): void {\n const request = new gateway.TranslatorSetAxisPositionRequest();\n request.setTranslatorId(this.translatorId);\n request.setAxis(axis);\n request.setPosition(position);\n request.setUnit(unit);\n\n gateway.callSync('gcode/set_axis_secondary_home', request);\n }\n\n /**\n * Gets offset of an axis in a given coordinate system.\n * @param coordinateSystem Coordinate system (e.g. G54).\n * @param axis Letter of the axis.\n * @param unit Units of position.\n * @return Offset in translator units of the axis.\n */\n public getAxisCoordinateSystemOffset(\n coordinateSystem: string,\n axis: string,\n unit: Length | Angle | Native\n ): number {\n const request = new gateway.TranslatorGetAxisOffsetRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoordinateSystem(coordinateSystem);\n request.setAxis(axis);\n request.setUnit(unit);\n\n const response = gateway.callSync<gateway.TranslatorGetAxisPositionResponse>(\n 'gcode/get_axis_offset',\n request,\n gateway.TranslatorGetAxisPositionResponse);\n return response.getValue();\n }\n\n /**\n * Resets internal state after device rejected generated command.\n * Axis positions become uninitialized.\n */\n public resetAfterStreamError(): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n gateway.callSync('gcode/reset_after_stream_error', request);\n }\n\n /**\n * Allows to scale feed rate of the translated code by a coefficient.\n * @param coefficient Coefficient of the original feed rate.\n */\n public setFeedRateOverride(\n coefficient: number\n ): void {\n const request = new gateway.TranslatorSetFeedRateOverrideRequest();\n request.setTranslatorId(this.translatorId);\n request.setCoefficient(coefficient);\n\n gateway.callSync('gcode/set_feed_rate_override', request);\n }\n\n /**\n * Releases native resources of a translator.\n * @param translatorId The ID of the translator.\n */\n private static _free(\n translatorId: number\n ): void {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(translatorId);\n\n gateway.callSync('gcode/free', request);\n }\n\n /**\n * Gets current coordinate system (e.g. G54).\n * @return Current coordinate system.\n */\n private _getCurrentCoordinateSystem(): string {\n const request = new gateway.TranslatorEmptyRequest();\n request.setTranslatorId(this.translatorId);\n\n const response = gateway.callSync<gateway.TranslatorGetCurrentCoordinateSystemResponse>(\n 'gcode/get_current_coordinate_system',\n request,\n gateway.TranslatorGetCurrentCoordinateSystemResponse);\n return response.getValue();\n }\n\n /**\n * Releases the native resources of the translator.\n * Should only be called if your environment does not support FinalizationRegistry.\n * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/FinalizationRegistry\n */\n public free(): void {\n Translator._free(this.translatorId);\n }\n}\n"]}
|
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import { Measurement } from '../measurement';
|
|
2
1
|
import { AxisMapping } from './axis_mapping';
|
|
2
|
+
import { AxisTransformation } from './axis_transformation';
|
|
3
3
|
/**
|
|
4
|
-
* Configuration of translator.
|
|
4
|
+
* Configuration of a translator.
|
|
5
5
|
*/
|
|
6
6
|
export interface TranslatorConfig {
|
|
7
7
|
/**
|
|
8
|
-
*
|
|
8
|
+
* Optional custom mapping of translator axes to stream axes.
|
|
9
9
|
*/
|
|
10
|
-
|
|
10
|
+
axisMappings?: AxisMapping[];
|
|
11
11
|
/**
|
|
12
|
-
* Optional
|
|
12
|
+
* Optional transformation of axes.
|
|
13
13
|
*/
|
|
14
|
-
|
|
14
|
+
axisTransformations?: AxisTransformation[];
|
|
15
15
|
}
|
|
16
16
|
export declare namespace TranslatorConfig {
|
|
17
17
|
const __type = "TranslatorConfig";
|
|
@@ -23,17 +23,20 @@ var __importStar = (this && this.__importStar) || function (mod) {
|
|
|
23
23
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
24
24
|
exports.TranslatorConfig = void 0;
|
|
25
25
|
const gateway = __importStar(require("../gateway"));
|
|
26
|
-
const measurement_1 = require("../measurement");
|
|
27
26
|
const axis_mapping_1 = require("./axis_mapping");
|
|
27
|
+
const axis_transformation_1 = require("./axis_transformation");
|
|
28
28
|
var TranslatorConfig;
|
|
29
29
|
(function (TranslatorConfig) {
|
|
30
30
|
TranslatorConfig.__type = 'TranslatorConfig';
|
|
31
31
|
/** @internal */
|
|
32
32
|
function toProtobuf(source) {
|
|
33
|
-
var _a, _b;
|
|
33
|
+
var _a, _b, _c, _d;
|
|
34
34
|
const pbData = new gateway.TranslatorConfig();
|
|
35
|
-
|
|
36
|
-
|
|
35
|
+
if (source == null) {
|
|
36
|
+
return pbData;
|
|
37
|
+
}
|
|
38
|
+
pbData.setAxisMappingsList((_b = (_a = source.axisMappings) === null || _a === void 0 ? void 0 : _a.map(item => axis_mapping_1.AxisMapping.toProtobuf(item))) !== null && _b !== void 0 ? _b : []);
|
|
39
|
+
pbData.setAxisTransformationsList((_d = (_c = source.axisTransformations) === null || _c === void 0 ? void 0 : _c.map(item => axis_transformation_1.AxisTransformation.toProtobuf(item))) !== null && _d !== void 0 ? _d : []);
|
|
37
40
|
return pbData;
|
|
38
41
|
}
|
|
39
42
|
TranslatorConfig.toProtobuf = toProtobuf;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"translator_config.js","sourceRoot":"","sources":["../../../src/gcode/translator_config.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,
|
|
1
|
+
{"version":3,"file":"translator_config.js","sourceRoot":"","sources":["../../../src/gcode/translator_config.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,oDAAsC;AACtC,iDAA6C;AAC7C,+DAA2D;AAkB3D,IAAiB,gBAAgB,CAchC;AAdD,WAAiB,gBAAgB;IAClB,uBAAM,GAAG,kBAAkB,CAAC;IAEzC,gBAAgB;IAChB,SAAgB,UAAU,CAAC,MAA2C;;QACpE,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,gBAAgB,EAAE,CAAC;QAC9C,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,OAAO,MAAM,CAAC;SACf;QAED,MAAM,CAAC,mBAAmB,CAAC,MAAA,MAAA,MAAM,CAAC,YAAY,0CAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,0BAAW,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,mCAAI,EAAE,CAAC,CAAC;QACjG,MAAM,CAAC,0BAA0B,CAAC,MAAA,MAAA,MAAM,CAAC,mBAAmB,0CAAE,GAAG,CAAC,IAAI,CAAC,EAAE,CAAC,wCAAkB,CAAC,UAAU,CAAC,IAAI,CAAC,CAAC,mCAAI,EAAE,CAAC,CAAC;QACtH,OAAO,MAAM,CAAC;IAChB,CAAC;IATe,2BAAU,aASzB,CAAA;AACH,CAAC,EAdgB,gBAAgB,GAAhB,wBAAgB,KAAhB,wBAAgB,QAchC","sourcesContent":["// ==== THIS FILE IS GENERATED FROM A TEMPLATE ==== //\n// ============= DO NOT EDIT DIRECTLY ============= //\n\nimport * as gateway from '../gateway';\nimport { AxisMapping } from './axis_mapping';\nimport { AxisTransformation } from './axis_transformation';\n\n/**\n * Configuration of a translator.\n */\nexport interface TranslatorConfig {\n /**\n * Optional custom mapping of translator axes to stream axes.\n */\n axisMappings?: AxisMapping[];\n\n /**\n * Optional transformation of axes.\n */\n axisTransformations?: AxisTransformation[];\n\n}\n\nexport namespace TranslatorConfig {\n export const __type = 'TranslatorConfig';\n\n /** @internal */\n export function toProtobuf(source: TranslatorConfig | null | undefined): gateway.TranslatorConfig {\n const pbData = new gateway.TranslatorConfig();\n if (source == null) {\n return pbData;\n }\n\n pbData.setAxisMappingsList(source.axisMappings?.map(item => AxisMapping.toProtobuf(item)) ?? []);\n pbData.setAxisTransformationsList(source.axisTransformations?.map(item => AxisTransformation.toProtobuf(item)) ?? []);\n return pbData;\n }\n}\n"]}
|
package/dist/lib/gcode_ns.d.ts
CHANGED
|
@@ -4,16 +4,18 @@ export declare namespace gcode {
|
|
|
4
4
|
type TranslateMessage = gcodeImport.TranslateMessage;
|
|
5
5
|
const TranslateResult: typeof gcodeImport.TranslateResult;
|
|
6
6
|
type TranslateResult = gcodeImport.TranslateResult;
|
|
7
|
-
const
|
|
8
|
-
type
|
|
9
|
-
const
|
|
10
|
-
type
|
|
7
|
+
const AxisDefinition: typeof gcodeImport.AxisDefinition;
|
|
8
|
+
type AxisDefinition = gcodeImport.AxisDefinition;
|
|
9
|
+
const DeviceDefinition: typeof gcodeImport.DeviceDefinition;
|
|
10
|
+
type DeviceDefinition = gcodeImport.DeviceDefinition;
|
|
11
11
|
const TranslatorConfig: typeof gcodeImport.TranslatorConfig;
|
|
12
12
|
type TranslatorConfig = gcodeImport.TranslatorConfig;
|
|
13
13
|
const AxisMapping: typeof gcodeImport.AxisMapping;
|
|
14
14
|
type AxisMapping = gcodeImport.AxisMapping;
|
|
15
|
+
const AxisTransformation: typeof gcodeImport.AxisTransformation;
|
|
16
|
+
type AxisTransformation = gcodeImport.AxisTransformation;
|
|
15
17
|
const Translator: typeof gcodeImport.Translator;
|
|
16
18
|
type Translator = gcodeImport.Translator;
|
|
17
|
-
const
|
|
18
|
-
type
|
|
19
|
+
const OfflineTranslator: typeof gcodeImport.OfflineTranslator;
|
|
20
|
+
type OfflineTranslator = gcodeImport.OfflineTranslator;
|
|
19
21
|
}
|
package/dist/lib/gcode_ns.js
CHANGED
|
@@ -25,11 +25,12 @@ var gcode;
|
|
|
25
25
|
(function (gcode) {
|
|
26
26
|
gcode.TranslateMessage = gcodeImport.TranslateMessage;
|
|
27
27
|
gcode.TranslateResult = gcodeImport.TranslateResult;
|
|
28
|
-
gcode.
|
|
29
|
-
gcode.
|
|
28
|
+
gcode.AxisDefinition = gcodeImport.AxisDefinition;
|
|
29
|
+
gcode.DeviceDefinition = gcodeImport.DeviceDefinition;
|
|
30
30
|
gcode.TranslatorConfig = gcodeImport.TranslatorConfig;
|
|
31
31
|
gcode.AxisMapping = gcodeImport.AxisMapping;
|
|
32
|
+
gcode.AxisTransformation = gcodeImport.AxisTransformation;
|
|
32
33
|
gcode.Translator = gcodeImport.Translator;
|
|
33
|
-
gcode.
|
|
34
|
+
gcode.OfflineTranslator = gcodeImport.OfflineTranslator;
|
|
34
35
|
})(gcode = exports.gcode || (exports.gcode = {}));
|
|
35
36
|
//# sourceMappingURL=gcode_ns.js.map
|
package/dist/lib/gcode_ns.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"gcode_ns.js","sourceRoot":"","sources":["../../src/gcode_ns.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAEvC,IAAiB,KAAK,
|
|
1
|
+
{"version":3,"file":"gcode_ns.js","sourceRoot":"","sources":["../../src/gcode_ns.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;AAAA,qDAAuC;AAEvC,IAAiB,KAAK,CAmBrB;AAnBD,WAAiB,KAAK;IACP,sBAAgB,GAAG,WAAW,CAAC,gBAAgB,CAAC;IAEhD,qBAAe,GAAG,WAAW,CAAC,eAAe,CAAC;IAE9C,oBAAc,GAAG,WAAW,CAAC,cAAc,CAAC;IAE5C,sBAAgB,GAAG,WAAW,CAAC,gBAAgB,CAAC;IAEhD,sBAAgB,GAAG,WAAW,CAAC,gBAAgB,CAAC;IAEhD,iBAAW,GAAG,WAAW,CAAC,WAAW,CAAC;IAEtC,wBAAkB,GAAG,WAAW,CAAC,kBAAkB,CAAC;IAEpD,gBAAU,GAAG,WAAW,CAAC,UAAU,CAAC;IAEpC,uBAAiB,GAAG,WAAW,CAAC,iBAAiB,CAAC;AAEjE,CAAC,EAnBgB,KAAK,GAAL,aAAK,KAAL,aAAK,QAmBrB","sourcesContent":["import * as gcodeImport from './gcode';\n\nexport namespace gcode {\n export const TranslateMessage = gcodeImport.TranslateMessage;\n export type TranslateMessage = gcodeImport.TranslateMessage;\n export const TranslateResult = gcodeImport.TranslateResult;\n export type TranslateResult = gcodeImport.TranslateResult;\n export const AxisDefinition = gcodeImport.AxisDefinition;\n export type AxisDefinition = gcodeImport.AxisDefinition;\n export const DeviceDefinition = gcodeImport.DeviceDefinition;\n export type DeviceDefinition = gcodeImport.DeviceDefinition;\n export const TranslatorConfig = gcodeImport.TranslatorConfig;\n export type TranslatorConfig = gcodeImport.TranslatorConfig;\n export const AxisMapping = gcodeImport.AxisMapping;\n export type AxisMapping = gcodeImport.AxisMapping;\n export const AxisTransformation = gcodeImport.AxisTransformation;\n export type AxisTransformation = gcodeImport.AxisTransformation;\n export const Translator = gcodeImport.Translator;\n export type Translator = gcodeImport.Translator;\n export const OfflineTranslator = gcodeImport.OfflineTranslator;\n export type OfflineTranslator = gcodeImport.OfflineTranslator;\n}\n"]}
|
package/dist/lib/measurement.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"measurement.js","sourceRoot":"","sources":["../../src/measurement.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,mDAAqC;AAmBrC,IAAiB,WAAW,
|
|
1
|
+
{"version":3,"file":"measurement.js","sourceRoot":"","sources":["../../src/measurement.ts"],"names":[],"mappings":";AAAA,sDAAsD;AACtD,sDAAsD;;;;;;;;;;;;;;;;;;;;;;AAEtD,mDAAqC;AAmBrC,IAAiB,WAAW,CAc3B;AAdD,WAAiB,WAAW;IACb,kBAAM,GAAG,aAAa,CAAC;IAEpC,gBAAgB;IAChB,SAAgB,UAAU,CAAC,MAAsC;QAC/D,MAAM,MAAM,GAAG,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;QACzC,IAAI,MAAM,IAAI,IAAI,EAAE;YAClB,OAAO,MAAM,CAAC;SACf;QAED,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;IATe,sBAAU,aASzB,CAAA;AACH,CAAC,EAdgB,WAAW,GAAX,mBAAW,KAAX,mBAAW,QAc3B","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 | null | undefined): gateway.Measurement {\n const pbData = new gateway.Measurement();\n if (source == null) {\n return pbData;\n }\n\n pbData.setValue(source.value);\n pbData.setUnit(source.unit!);\n return pbData;\n }\n}\n"]}
|