motion-master-client 0.0.302 → 0.0.303
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/package.json +2 -1
- package/src/lib/motion-master-req-res-client.d.ts +74 -3
- package/src/lib/motion-master-req-res-client.js +148 -4
- package/src/lib/motion-master-req-res-client.js.map +1 -1
- package/src/lib/motion-master.proto.d.ts +110 -2
- package/src/lib/motion-master.proto.js +1101 -4
- package/src/lib/request-status-resolver.js +6 -0
- package/src/lib/request-status-resolver.js.map +1 -1
- package/src/lib/types.d.ts +25 -0
- package/src/lib/types.js.map +1 -1
- package/src/lib/vizualization.d.ts +62 -0
- package/src/lib/vizualization.js +156 -0
- package/src/lib/vizualization.js.map +1 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "motion-master-client",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.303",
|
|
4
4
|
"type": "commonjs",
|
|
5
5
|
"description": "A library and CLI program used for communicating with Motion Master.",
|
|
6
6
|
"dependencies": {
|
|
@@ -8,6 +8,7 @@
|
|
|
8
8
|
"buffer": "^6.0.3",
|
|
9
9
|
"commander": "^11.1.0",
|
|
10
10
|
"cors": "^2.8.5",
|
|
11
|
+
"d3": "^7.8.4",
|
|
11
12
|
"debug": "^4.3.5",
|
|
12
13
|
"ecatmod": "^2.2.6",
|
|
13
14
|
"express": "^4.19.2",
|
|
@@ -6,7 +6,7 @@ import { HardwareDescription, StackInfo } from './hardware-description';
|
|
|
6
6
|
import { MotionMasterReqResSocket } from './motion-master-req-res-socket';
|
|
7
7
|
import { UIFeaturesConfig } from './parameter';
|
|
8
8
|
import { SystemLogLine } from './system-log-line';
|
|
9
|
-
import { MotionMasterMessage, ParameterValueType, ParameterTypeValue, DeviceParameterValuesStatus, ParameterTypeValueKey, DeviceRefObj, DeviceRef, FullAutoTuningStatus, SystemVersionStatus, DeviceInfoStatus, DeviceParameterInfoStatus, GetDeviceParameterInfoRequest, GetDeviceParameterValuesRequest, GetMultiDeviceParameterValuesRequest, MultiDeviceParameterValuesStatus, SetDeviceParameterValuesRequest, SetMultiDeviceParameterValuesRequest, GetDeviceFileListRequest, DeviceFileListStatus, GetDeviceFileRequest, DeviceFileStatus, SetDeviceFileRequest, DeleteDeviceFileRequest, ResetDeviceFaultRequest, DeviceFaultResetStatus, StopDeviceRequest, DeviceStopStatus, StartDeviceFirmwareInstallationRequest, DeviceFirmwareInstallationStatus, GetDeviceLogRequest, DeviceLogStatus, StartCoggingTorqueRecordingRequest, CoggingTorqueRecordingStatus, GetCoggingTorqueDataRequest, CoggingTorqueDataStatus, StartOffsetDetectionRequest, OffsetDetectionStatus, StartPlantModelIdentificationRequest, PlantIdentificationStatus, ComputeAutoTuningGainsRequest, AutoTuningStatus, SetMotionControllerParametersRequest, MotionControllerStatus, EnableMotionControllerRequest, SetSignalGeneratorParametersRequest, SignalGeneratorStatus, StopSignalGeneratorRequest, StartMonitoringDeviceParameterValuesRequest, MonitoringParameterValuesStatus, StopMonitoringDeviceParameterValuesRequest, GetEthercatNetworkStateRequest, EthercatNetworkStateStatus, SetEthercatNetworkStateRequest, StartNarrowAngleCalibrationRequest, NarrowAngleCalibrationStatus, SetSystemClientTimeoutRequest, StartSystemIdentificationRequest, SystemIdentificationStatus, CirculoEncoderMagnetDistanceStatus, StartCirculoEncoderNarrowAngleCalibrationProcedureRequest, CirculoEncoderNarrowAngleCalibrationProcedureStatus, GetDeviceCiA402StateRequest, DeviceCiA402StateStatus, SetDeviceCiA402StateRequest, SystemLogStatus, StartDeviceSiiRestoreRequest, DeviceSiiRestoreStatus, StartOpenLoopFieldControlRequest, OpenLoopFieldControlStatus, ComputeFullAutoTuningGainsRequest, StartFullAutoTuningRequest, StopFullAutoTuningRequest, StartCirculoEncoderConfigurationRequest, CirculoEncoderConfigurationStatus, StopCirculoEncoderNarrowAngleCalibrationProcedureRequest, StartOsCommandRequest, OsCommandStatus, RestoreDefaultParametersType, DeviceParameterAddressValue, DeviceParameterIds, DeviceParameterInfo, RequestStatusMessage, UiPdoMapping, UiConfig, RequestStatus } from './types';
|
|
9
|
+
import { MotionMasterMessage, ParameterValueType, ParameterTypeValue, DeviceParameterValuesStatus, ParameterTypeValueKey, DeviceRefObj, DeviceRef, FullAutoTuningStatus, SystemVersionStatus, DeviceInfoStatus, DeviceParameterInfoStatus, GetDeviceParameterInfoRequest, GetDeviceParameterValuesRequest, GetMultiDeviceParameterValuesRequest, MultiDeviceParameterValuesStatus, SetDeviceParameterValuesRequest, SetMultiDeviceParameterValuesRequest, GetDeviceFileListRequest, DeviceFileListStatus, GetDeviceFileRequest, DeviceFileStatus, SetDeviceFileRequest, DeleteDeviceFileRequest, ResetDeviceFaultRequest, DeviceFaultResetStatus, StopDeviceRequest, DeviceStopStatus, StartDeviceFirmwareInstallationRequest, DeviceFirmwareInstallationStatus, GetDeviceLogRequest, DeviceLogStatus, StartCoggingTorqueRecordingRequest, CoggingTorqueRecordingStatus, GetCoggingTorqueDataRequest, CoggingTorqueDataStatus, StartOffsetDetectionRequest, OffsetDetectionStatus, StartPlantModelIdentificationRequest, PlantIdentificationStatus, ComputeAutoTuningGainsRequest, AutoTuningStatus, SetMotionControllerParametersRequest, MotionControllerStatus, EnableMotionControllerRequest, SetSignalGeneratorParametersRequest, SignalGeneratorStatus, StopSignalGeneratorRequest, StartMonitoringDeviceParameterValuesRequest, MonitoringParameterValuesStatus, StopMonitoringDeviceParameterValuesRequest, GetEthercatNetworkStateRequest, EthercatNetworkStateStatus, SetEthercatNetworkStateRequest, StartNarrowAngleCalibrationRequest, NarrowAngleCalibrationStatus, SetSystemClientTimeoutRequest, StartSystemIdentificationRequest, SystemIdentificationStatus, CirculoEncoderMagnetDistanceStatus, StartCirculoEncoderNarrowAngleCalibrationProcedureRequest, CirculoEncoderNarrowAngleCalibrationProcedureStatus, GetDeviceCiA402StateRequest, DeviceCiA402StateStatus, SetDeviceCiA402StateRequest, SystemLogStatus, StartDeviceSiiRestoreRequest, DeviceSiiRestoreStatus, StartOpenLoopFieldControlRequest, OpenLoopFieldControlStatus, ComputeFullAutoTuningGainsRequest, StartFullAutoTuningRequest, StopFullAutoTuningRequest, StartCirculoEncoderConfigurationRequest, CirculoEncoderConfigurationStatus, StopCirculoEncoderNarrowAngleCalibrationProcedureRequest, StartOsCommandRequest, OsCommandStatus, RestoreDefaultParametersType, DeviceParameterAddressValue, DeviceParameterIds, DeviceParameterInfo, RequestStatusMessage, UiPdoMapping, UiConfig, RequestStatus, ExecuteForwardCallRequest, ForwardCallStatus, PlantModel } from './types';
|
|
10
10
|
import { Cia402State, ModesOfOperation } from './cia402';
|
|
11
11
|
import { EncoderRegisterCommunicationOsCommandResponse, MotorPhaseOrderDetectionOsCommandResponse, OpenPhaseDetectionOsCommandResponse, OsCommandMode, OsCommandResponse, PhaseResistanceMeasurementOsCommandResponse, PhaseInductanceMeasurementOsCommandResponse, PolePairDetectionOsCommandResponse, CommutationOffsetMeasurementOsCommandResponse, IcMuCalibrationModeOsCommandResponse, OpenLoopFieldModeOsCommandResponse, HrdStreamingOsCommandResponse, TorqueConstantMeasurementOsCommandResponse, SkippedCyclesCounterOsCommandResponse, IgnoreBissStatusBitsOsCommandResponse, SystemIdentificationOsCommandResponse, KublerEncoderCommandOsCommandResponse, UseInternalEncoderVelocityOsCommandResponse, KublerEncoderRegisterCommunicationOsCommandResponse, SmmAcyclicHandlerOsCommandResponse, HrdStreamingOsCommandAction, HrdStreamingOsCommandDataIndex, SmmAcyclicHandlerLoadParametersForVerificationOsCommandResponse } from './os-command';
|
|
12
12
|
import { IntegroVariant } from './integro-variant';
|
|
@@ -16,6 +16,7 @@ import { SmmParameter } from './smm';
|
|
|
16
16
|
import { DataType } from 'python-struct';
|
|
17
17
|
import { CirculoIntegratedEncoderI2CDeviceId } from './circulo';
|
|
18
18
|
import { EncoderRegisterError } from './encoder';
|
|
19
|
+
import { BodePlotOptions } from './vizualization';
|
|
19
20
|
/**
|
|
20
21
|
* This class contains methods for making requests to Motion Master using the injected request/response socket.
|
|
21
22
|
*
|
|
@@ -778,6 +779,12 @@ export declare class MotionMasterReqResClient {
|
|
|
778
779
|
* The OS command can timeout if it takes longer than the provided timeout in milliseconds, in which case Motion Master will return an error.
|
|
779
780
|
*/
|
|
780
781
|
startOsCommand(props: StartOsCommandRequest, requestTimeout: number, messageId?: string): Observable<OsCommandStatus>;
|
|
782
|
+
/**
|
|
783
|
+
* Execute the forward call request.
|
|
784
|
+
*
|
|
785
|
+
* This request is used to execute any function provided by the Standalone Auto-tuning Service which is started by the Motion Master.
|
|
786
|
+
*/
|
|
787
|
+
executeForwardCall(props: ExecuteForwardCallRequest, requestTimeout: number, messageId?: string): Observable<ForwardCallStatus>;
|
|
781
788
|
/**
|
|
782
789
|
* Send request.
|
|
783
790
|
*
|
|
@@ -890,6 +897,19 @@ export declare class MotionMasterReqResClient {
|
|
|
890
897
|
* This functions tries to decode the content as a text in utf-8 character encoding.
|
|
891
898
|
*/
|
|
892
899
|
getDecodedFile(deviceRef: DeviceRef, name: string, requestTimeout?: number, messageId?: string): Observable<string>;
|
|
900
|
+
/**
|
|
901
|
+
* Retrieves the plant model data for a given device.
|
|
902
|
+
*
|
|
903
|
+
* Reads and parses the 'plant_model.csv' file associated with the device reference,
|
|
904
|
+
* extracting numerator and denominator coefficients as arrays of numbers,
|
|
905
|
+
* along with friction and inertia parameters.
|
|
906
|
+
*
|
|
907
|
+
* @param deviceRef - Reference to the device to retrieve the model from.
|
|
908
|
+
* @param requestTimeout - Optional timeout in milliseconds for the request. Defaults to 10000 ms.
|
|
909
|
+
* @param messageId - Optional message identifier for tracking or logging purposes.
|
|
910
|
+
* @returns An Observable that emits the parsed PlantModel object or undefined if no content is available.
|
|
911
|
+
*/
|
|
912
|
+
getPlantModel(deviceRef: DeviceRef, requestTimeout?: number, messageId?: string): Observable<PlantModel | undefined>;
|
|
893
913
|
/**
|
|
894
914
|
* Unlock protected files.
|
|
895
915
|
*
|
|
@@ -1382,7 +1402,7 @@ export declare class MotionMasterReqResClient {
|
|
|
1382
1402
|
*
|
|
1383
1403
|
* @returns An observable that emits a tuple of two numbers, representing the byte values of the firmware version.
|
|
1384
1404
|
*/
|
|
1385
|
-
|
|
1405
|
+
readSmmFirmwareVersion(deviceRef: DeviceRef): Observable<[number, number]>;
|
|
1386
1406
|
/**
|
|
1387
1407
|
* Reads the SMM firmware version from a device as a number.
|
|
1388
1408
|
*
|
|
@@ -1392,7 +1412,7 @@ export declare class MotionMasterReqResClient {
|
|
|
1392
1412
|
* @param deviceRef - A reference to the target device.
|
|
1393
1413
|
* @returns An `Observable<number>` emitting the firmware version, represented as an integer.
|
|
1394
1414
|
*/
|
|
1395
|
-
|
|
1415
|
+
readSmmFirmwareVersionAsNumber(deviceRef: DeviceRef): Observable<number>;
|
|
1396
1416
|
/**
|
|
1397
1417
|
* Resolves the SMM parameter structure version for the specified device based on its firmware version.
|
|
1398
1418
|
*
|
|
@@ -1910,4 +1930,55 @@ export declare class MotionMasterReqResClient {
|
|
|
1910
1930
|
message?: string;
|
|
1911
1931
|
};
|
|
1912
1932
|
}>;
|
|
1933
|
+
/**
|
|
1934
|
+
* Executes a forward call by sending the provided data, then parses the JSON response.
|
|
1935
|
+
*
|
|
1936
|
+
* @param data - The data to send. Can be a Uint8Array, an object (which will be JSON-stringified), or a string.
|
|
1937
|
+
* @param requestTimeout - Optional timeout for the request in milliseconds. Defaults to 5000 ms.
|
|
1938
|
+
* @param messageId - Optional message identifier.
|
|
1939
|
+
*
|
|
1940
|
+
* @returns An Observable that emits the parsed JSON response object upon a successful call.
|
|
1941
|
+
*
|
|
1942
|
+
* @throws Will throw an error if:
|
|
1943
|
+
* - `data` is not a Uint8Array, string, or object.
|
|
1944
|
+
* - The forward call fails.
|
|
1945
|
+
* - The response cannot be parsed as valid JSON.
|
|
1946
|
+
*
|
|
1947
|
+
* @example
|
|
1948
|
+
* ```ts
|
|
1949
|
+
* const data = { command: 'status' };
|
|
1950
|
+
* this.executeForwardCallAndParseResponse(data)
|
|
1951
|
+
* .subscribe({
|
|
1952
|
+
* next: (response) => console.log('Parsed response:', response),
|
|
1953
|
+
* error: (err) => console.error('Error:', err),
|
|
1954
|
+
* });
|
|
1955
|
+
* ```
|
|
1956
|
+
*/
|
|
1957
|
+
executeForwardCallAndParseResponse(data: Uint8Array | string | object, requestTimeout?: number, messageId?: string): Observable<any>;
|
|
1958
|
+
/**
|
|
1959
|
+
* Retrieves the plant model for the specified device, generates the Bode plot data CSV,
|
|
1960
|
+
* parses it, and returns an Observable that emits the corresponding SVG string representing the Bode plot.
|
|
1961
|
+
*
|
|
1962
|
+
* The process involves:
|
|
1963
|
+
* 1. Requesting the plant model parameters (numerator and denominator).
|
|
1964
|
+
* 2. Requesting the Bode plot CSV file content based on the plant model.
|
|
1965
|
+
* 3. Parsing the CSV content into numeric data points.
|
|
1966
|
+
* 4. Generating an SVG string of the Bode plot using the parsed data.
|
|
1967
|
+
*
|
|
1968
|
+
* @param deviceRef - Reference to the target device for which the Bode plot is generated.
|
|
1969
|
+
* @param requestTimeout - Optional timeout in milliseconds for all requests. Default is 10000 ms.
|
|
1970
|
+
* @param messageId - Optional message ID for correlating requests and responses.
|
|
1971
|
+
*
|
|
1972
|
+
* @returns An Observable that emits the SVG string of the Bode plot or `void` if data is unavailable.
|
|
1973
|
+
*
|
|
1974
|
+
* @example
|
|
1975
|
+
* getBodePlotSvg(deviceRef).subscribe(svg => {
|
|
1976
|
+
* if (svg) {
|
|
1977
|
+
* document.body.innerHTML = svg;
|
|
1978
|
+
* } else {
|
|
1979
|
+
* console.warn('Bode plot data unavailable');
|
|
1980
|
+
* }
|
|
1981
|
+
* });
|
|
1982
|
+
*/
|
|
1983
|
+
getBodePlotSvg(deviceRef: DeviceRef, options?: BodePlotOptions, requestTimeout?: number, messageId?: string): Observable<string | void>;
|
|
1913
1984
|
}
|
|
@@ -28,6 +28,7 @@ const firmware_1 = require("./firmware");
|
|
|
28
28
|
const fetch_1 = require("./fetch");
|
|
29
29
|
const circulo_1 = require("./circulo");
|
|
30
30
|
const encoder_1 = require("./encoder");
|
|
31
|
+
const vizualization_1 = require("./vizualization");
|
|
31
32
|
const { xmlToEsi } = require('ecatmod');
|
|
32
33
|
/**
|
|
33
34
|
* This class contains methods for making requests to Motion Master using the injected request/response socket.
|
|
@@ -1153,6 +1154,16 @@ class MotionMasterReqResClient {
|
|
|
1153
1154
|
return this.socket.message$.pipe((0, operators_2.transformMotionMasterMessageToStatus)('osCommand', requestTimeout, id));
|
|
1154
1155
|
}));
|
|
1155
1156
|
}
|
|
1157
|
+
/**
|
|
1158
|
+
* Execute the forward call request.
|
|
1159
|
+
*
|
|
1160
|
+
* This request is used to execute any function provided by the Standalone Auto-tuning Service which is started by the Motion Master.
|
|
1161
|
+
*/
|
|
1162
|
+
executeForwardCall(props, requestTimeout, messageId) {
|
|
1163
|
+
const executeForwardCall = types_1.MotionMasterMessage.Request.ExecuteForwardCall.create(props);
|
|
1164
|
+
const id = this.sendRequest({ executeForwardCall }, messageId);
|
|
1165
|
+
return this.socket.message$.pipe((0, operators_2.transformMotionMasterMessageToStatus)('forwardCall', requestTimeout, id));
|
|
1166
|
+
}
|
|
1156
1167
|
/**
|
|
1157
1168
|
* Send request.
|
|
1158
1169
|
*
|
|
@@ -1710,6 +1721,33 @@ class MotionMasterReqResClient {
|
|
|
1710
1721
|
throw new Error(`The content for the device file '${name}' for device ${deviceRef} is undefined. The file is most likely missing.`);
|
|
1711
1722
|
}));
|
|
1712
1723
|
}
|
|
1724
|
+
/**
|
|
1725
|
+
* Retrieves the plant model data for a given device.
|
|
1726
|
+
*
|
|
1727
|
+
* Reads and parses the 'plant_model.csv' file associated with the device reference,
|
|
1728
|
+
* extracting numerator and denominator coefficients as arrays of numbers,
|
|
1729
|
+
* along with friction and inertia parameters.
|
|
1730
|
+
*
|
|
1731
|
+
* @param deviceRef - Reference to the device to retrieve the model from.
|
|
1732
|
+
* @param requestTimeout - Optional timeout in milliseconds for the request. Defaults to 10000 ms.
|
|
1733
|
+
* @param messageId - Optional message identifier for tracking or logging purposes.
|
|
1734
|
+
* @returns An Observable that emits the parsed PlantModel object or undefined if no content is available.
|
|
1735
|
+
*/
|
|
1736
|
+
getPlantModel(deviceRef, requestTimeout = 10000, messageId) {
|
|
1737
|
+
return this.getDecodedFile(deviceRef, 'plant_model.csv', requestTimeout, messageId).pipe((0, operators_1.map)((content) => {
|
|
1738
|
+
if (!content) {
|
|
1739
|
+
return;
|
|
1740
|
+
}
|
|
1741
|
+
const [numerator, denominator] = content.split('\n');
|
|
1742
|
+
const [friction, inertia] = denominator.split(',').reverse();
|
|
1743
|
+
return {
|
|
1744
|
+
numerator: [...numerator.split(',').map((v) => parseFloat(v))],
|
|
1745
|
+
denominator: [...denominator.split(',').map((v) => parseFloat(v))],
|
|
1746
|
+
friction: parseFloat(friction),
|
|
1747
|
+
inertia: parseFloat(inertia),
|
|
1748
|
+
};
|
|
1749
|
+
}));
|
|
1750
|
+
}
|
|
1713
1751
|
/**
|
|
1714
1752
|
* Unlock protected files.
|
|
1715
1753
|
*
|
|
@@ -2778,7 +2816,7 @@ class MotionMasterReqResClient {
|
|
|
2778
2816
|
*
|
|
2779
2817
|
* @returns An observable that emits a tuple of two numbers, representing the byte values of the firmware version.
|
|
2780
2818
|
*/
|
|
2781
|
-
|
|
2819
|
+
readSmmFirmwareVersion(deviceRef) {
|
|
2782
2820
|
return this.readSmmParameterArrayValue(deviceRef, 0x0001, 0).pipe((0, operators_1.map)((bytes) => [bytes[0], bytes[1]]));
|
|
2783
2821
|
}
|
|
2784
2822
|
/**
|
|
@@ -2790,8 +2828,8 @@ class MotionMasterReqResClient {
|
|
|
2790
2828
|
* @param deviceRef - A reference to the target device.
|
|
2791
2829
|
* @returns An `Observable<number>` emitting the firmware version, represented as an integer.
|
|
2792
2830
|
*/
|
|
2793
|
-
|
|
2794
|
-
return this.
|
|
2831
|
+
readSmmFirmwareVersionAsNumber(deviceRef) {
|
|
2832
|
+
return this.readSmmFirmwareVersion(deviceRef).pipe((0, operators_1.map)((bytes) => (bytes[1] << 8) | bytes[0]));
|
|
2795
2833
|
}
|
|
2796
2834
|
/**
|
|
2797
2835
|
* Resolves the SMM parameter structure version for the specified device based on its firmware version.
|
|
@@ -2809,7 +2847,7 @@ class MotionMasterReqResClient {
|
|
|
2809
2847
|
* - If the firmware version is 0x0203 or greater, the parameter structure version is 0x0203.
|
|
2810
2848
|
*/
|
|
2811
2849
|
resolveSmmParameterStructureVersion(deviceRef) {
|
|
2812
|
-
return this.
|
|
2850
|
+
return this.readSmmFirmwareVersionAsNumber(deviceRef).pipe((0, operators_1.map)((version) => {
|
|
2813
2851
|
if (version < 0x0203) {
|
|
2814
2852
|
return 0x0041;
|
|
2815
2853
|
}
|
|
@@ -3723,6 +3761,112 @@ class MotionMasterReqResClient {
|
|
|
3723
3761
|
this.logoutFromSmm(deviceRef).subscribe();
|
|
3724
3762
|
}));
|
|
3725
3763
|
}
|
|
3764
|
+
/**
|
|
3765
|
+
* Executes a forward call by sending the provided data, then parses the JSON response.
|
|
3766
|
+
*
|
|
3767
|
+
* @param data - The data to send. Can be a Uint8Array, an object (which will be JSON-stringified), or a string.
|
|
3768
|
+
* @param requestTimeout - Optional timeout for the request in milliseconds. Defaults to 5000 ms.
|
|
3769
|
+
* @param messageId - Optional message identifier.
|
|
3770
|
+
*
|
|
3771
|
+
* @returns An Observable that emits the parsed JSON response object upon a successful call.
|
|
3772
|
+
*
|
|
3773
|
+
* @throws Will throw an error if:
|
|
3774
|
+
* - `data` is not a Uint8Array, string, or object.
|
|
3775
|
+
* - The forward call fails.
|
|
3776
|
+
* - The response cannot be parsed as valid JSON.
|
|
3777
|
+
*
|
|
3778
|
+
* @example
|
|
3779
|
+
* ```ts
|
|
3780
|
+
* const data = { command: 'status' };
|
|
3781
|
+
* this.executeForwardCallAndParseResponse(data)
|
|
3782
|
+
* .subscribe({
|
|
3783
|
+
* next: (response) => console.log('Parsed response:', response),
|
|
3784
|
+
* error: (err) => console.error('Error:', err),
|
|
3785
|
+
* });
|
|
3786
|
+
* ```
|
|
3787
|
+
*/
|
|
3788
|
+
executeForwardCallAndParseResponse(data, requestTimeout = 5000, messageId) {
|
|
3789
|
+
const props = {};
|
|
3790
|
+
if (data instanceof Uint8Array) {
|
|
3791
|
+
props.message = data;
|
|
3792
|
+
}
|
|
3793
|
+
else {
|
|
3794
|
+
let message;
|
|
3795
|
+
if (typeof data === 'object') {
|
|
3796
|
+
message = JSON.stringify(data);
|
|
3797
|
+
}
|
|
3798
|
+
else if (typeof data === 'string') {
|
|
3799
|
+
message = data;
|
|
3800
|
+
}
|
|
3801
|
+
else {
|
|
3802
|
+
throw new Error('Data must be a string, object, or Uint8Array.');
|
|
3803
|
+
}
|
|
3804
|
+
const encoder = new TextEncoder();
|
|
3805
|
+
props.message = encoder.encode(message);
|
|
3806
|
+
}
|
|
3807
|
+
return this.executeForwardCall(props, requestTimeout, messageId).pipe((0, operators_1.map)((status) => {
|
|
3808
|
+
var _a;
|
|
3809
|
+
if (status.request === 'succeeded') {
|
|
3810
|
+
const bytes = status.response;
|
|
3811
|
+
const uint8array = Array.isArray(bytes) ? new Uint8Array(bytes) : bytes;
|
|
3812
|
+
if (uint8array) {
|
|
3813
|
+
try {
|
|
3814
|
+
const decoder = new TextDecoder('utf-8');
|
|
3815
|
+
const jsonString = decoder.decode(uint8array);
|
|
3816
|
+
return JSON.parse(jsonString);
|
|
3817
|
+
}
|
|
3818
|
+
catch (parseError) {
|
|
3819
|
+
throw new Error(`Failed to parse JSON response: ${parseError instanceof Error ? parseError.message : parseError}`);
|
|
3820
|
+
}
|
|
3821
|
+
}
|
|
3822
|
+
}
|
|
3823
|
+
throw new Error(`Failed to execute forward call: ${((_a = status.error) === null || _a === void 0 ? void 0 : _a.message) || 'Unknown error'}`);
|
|
3824
|
+
}));
|
|
3825
|
+
}
|
|
3826
|
+
/**
|
|
3827
|
+
* Retrieves the plant model for the specified device, generates the Bode plot data CSV,
|
|
3828
|
+
* parses it, and returns an Observable that emits the corresponding SVG string representing the Bode plot.
|
|
3829
|
+
*
|
|
3830
|
+
* The process involves:
|
|
3831
|
+
* 1. Requesting the plant model parameters (numerator and denominator).
|
|
3832
|
+
* 2. Requesting the Bode plot CSV file content based on the plant model.
|
|
3833
|
+
* 3. Parsing the CSV content into numeric data points.
|
|
3834
|
+
* 4. Generating an SVG string of the Bode plot using the parsed data.
|
|
3835
|
+
*
|
|
3836
|
+
* @param deviceRef - Reference to the target device for which the Bode plot is generated.
|
|
3837
|
+
* @param requestTimeout - Optional timeout in milliseconds for all requests. Default is 10000 ms.
|
|
3838
|
+
* @param messageId - Optional message ID for correlating requests and responses.
|
|
3839
|
+
*
|
|
3840
|
+
* @returns An Observable that emits the SVG string of the Bode plot or `void` if data is unavailable.
|
|
3841
|
+
*
|
|
3842
|
+
* @example
|
|
3843
|
+
* getBodePlotSvg(deviceRef).subscribe(svg => {
|
|
3844
|
+
* if (svg) {
|
|
3845
|
+
* document.body.innerHTML = svg;
|
|
3846
|
+
* } else {
|
|
3847
|
+
* console.warn('Bode plot data unavailable');
|
|
3848
|
+
* }
|
|
3849
|
+
* });
|
|
3850
|
+
*/
|
|
3851
|
+
getBodePlotSvg(deviceRef, options = {}, requestTimeout = 10000, messageId) {
|
|
3852
|
+
return this.getPlantModel(deviceRef, requestTimeout, messageId).pipe((0, operators_1.mergeMap)((plantModel) => {
|
|
3853
|
+
if (!plantModel) {
|
|
3854
|
+
return (0, rxjs_1.of)(undefined);
|
|
3855
|
+
}
|
|
3856
|
+
const data = {
|
|
3857
|
+
run: 'generate_plant_bode_file',
|
|
3858
|
+
data: { plant_model: { numerator: plantModel.numerator, denominator: plantModel.denominator } },
|
|
3859
|
+
};
|
|
3860
|
+
return this.executeForwardCallAndParseResponse(data, requestTimeout, messageId).pipe((0, operators_1.mergeMap)((response) => tslib_1.__awaiter(this, void 0, void 0, function* () {
|
|
3861
|
+
const csvText = response === null || response === void 0 ? void 0 : response['bode_file_content'];
|
|
3862
|
+
if (!csvText) {
|
|
3863
|
+
return;
|
|
3864
|
+
}
|
|
3865
|
+
const parsedData = (0, vizualization_1.parseBodePlotCsv)(csvText);
|
|
3866
|
+
return yield (0, vizualization_1.createBodePlotSvg)(parsedData, options);
|
|
3867
|
+
})));
|
|
3868
|
+
}));
|
|
3869
|
+
}
|
|
3726
3870
|
}
|
|
3727
3871
|
exports.MotionMasterReqResClient = MotionMasterReqResClient;
|
|
3728
3872
|
/**
|