ads-client 2.0.0-beta.5 → 2.0.0-beta.6

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.
@@ -1,7 +1,7 @@
1
1
  import EventEmitter from "events";
2
2
  import * as ADS from './ads-commons';
3
3
  import type { ActiveSubscription, AdsClientConnection, AdsClientSettings, AdsCommandToSend, AdsDataTypeContainer, AdsSymbolContainer, ConnectionMetaData, SubscriptionSettings, ReadValueResult, WriteValueResult, VariableHandle, RpcMethodCallResult, CreateVariableHandleMultiResult, ReadRawMultiResult, ReadRawMultiCommand, WriteRawMultiResult, DeleteVariableHandleMultiResult, ReadWriteRawMultiResult, ReadWriteRawMultiCommand, WriteRawMultiCommand, SubscriptionCallback, DebugLevel, AdsClientEvents, SendAdsCommandWithFallbackResult } from "./types/ads-client-types";
4
- import { AdsDataType, AdsDeviceInfo, AdsResponse, AdsState, AdsSymbol, AmsAddress, AmsTcpPacket, AdsUploadInfo } from "./types/ads-protocol-types";
4
+ import { AdsAttributeEntry, AdsDataType, AdsDeviceInfo, AdsResponse, AdsState, AdsSymbol, AmsAddress, AmsTcpPacket, AdsUploadInfo } from "./types/ads-protocol-types";
5
5
  export type * from "./types/ads-client-types";
6
6
  export type * from './types/ads-protocol-types';
7
7
  export type * from './client-error';
@@ -471,8 +471,16 @@ export declare class Client extends EventEmitter<AdsClientEvents> {
471
471
  *
472
472
  * @param buffer The raw data to convert
473
473
  * @param dataType Target data type
474
+ * @param attributes Additional attributes of the symbol or data type to use for conversion
474
475
  */
475
476
  private convertBufferToPrimitiveType;
477
+ /**
478
+ * Extracts TcEncoding attribute from the data datatype attributes or additional attributes
479
+ *
480
+ * @param dataType The data type
481
+ * @param attributes Additional attributes of the symbol or data type
482
+ */
483
+ private getStringDataTypeEncoding;
476
484
  /**
477
485
  * Converts raw data to Javascript object.
478
486
  *
@@ -480,6 +488,7 @@ export declare class Client extends EventEmitter<AdsClientEvents> {
480
488
  *
481
489
  * @param data The raw data to convert
482
490
  * @param dataType Target data type
491
+ * @param attributes Additional attributes of the symbol or data type used for conversion
483
492
  * @param isArrayItem If `true`, this is an array item (default: `false`)
484
493
  */
485
494
  private convertBufferToObject;
@@ -488,6 +497,7 @@ export declare class Client extends EventEmitter<AdsClientEvents> {
488
497
  *
489
498
  * @param value Javascript object to convert
490
499
  * @param dataType Target data type
500
+ * @param attributes Additional attributes of the symbol or data type used for conversion
491
501
  * @param objectPath Object path that is passed forward when calling recursively. This is used for error reporting if a property is missing
492
502
  * @param isArrayItem If `true`, this is an array item (default: `false`)
493
503
  */
@@ -498,6 +508,7 @@ export declare class Client extends EventEmitter<AdsClientEvents> {
498
508
  * @param value Javascript object to convert
499
509
  * @param dataType Data type
500
510
  * @param buffer Reference to Buffer object where to write the raw value
511
+ * @param attributes Additional attributes of the symbol or data type used for conversion
501
512
  */
502
513
  private convertPrimitiveTypeToBuffer;
503
514
  /**
@@ -1809,12 +1820,13 @@ export declare class Client extends EventEmitter<AdsClientEvents> {
1809
1820
  * ```
1810
1821
  *
1811
1822
  * @param dataType Data type name in the PLC as string (such as `ST_Struct`) or data type object (acquired using {@link getDataType}())
1823
+ * @param attributes Additional attributes of the symbol or data type used for conversion
1812
1824
  * @param targetOpts Optional target settings that override values in `settings`
1813
1825
  *
1814
1826
  * @template T Typescript data type of the PLC data, for example `getDefaultPlcObject<number>(...)` or `getDefaultPlcObject<ST_TypedStruct>(...)`
1815
1827
  * @throws Throws an error if sending the command fails or if the target responds with an error.
1816
1828
  */
1817
- getDefaultPlcObject<T = any>(dataType: string | AdsDataType, targetOpts?: Partial<AmsAddress>): Promise<T>;
1829
+ getDefaultPlcObject<T = any>(dataType: string | AdsDataType, attributes?: AdsAttributeEntry[], targetOpts?: Partial<AmsAddress>): Promise<T>;
1818
1830
  /**
1819
1831
  * Converts raw data to a Javascript object by using the provided data type.
1820
1832
  *
@@ -1834,12 +1846,13 @@ export declare class Client extends EventEmitter<AdsClientEvents> {
1834
1846
  *
1835
1847
  * @param data Raw data (acquired for example using {@link readRaw}())
1836
1848
  * @param dataType Data type name in the PLC as string (such as `ST_Struct`) or data type object (acquired using {@link getDataType}())
1849
+ * @param attributes Additional attributes of the symbol or data type used for conversion
1837
1850
  * @param targetOpts Optional target settings that override values in `settings`
1838
1851
  *
1839
1852
  * @template T Typescript data type of the PLC data, for example `convertFromRaw<number>(...)` or `convertFromRaw<ST_TypedStruct>(...)`
1840
1853
  * @throws Throws an error if sending the command fails or if the target responds with an error.
1841
1854
  */
1842
- convertFromRaw<T = any>(data: Buffer, dataType: string | AdsDataType, targetOpts?: Partial<AmsAddress>): Promise<T>;
1855
+ convertFromRaw<T = any>(data: Buffer, dataType: string | AdsDataType, attributes?: AdsAttributeEntry[], targetOpts?: Partial<AmsAddress>): Promise<T>;
1843
1856
  /**
1844
1857
  * Converts a Javascript object to raw data by using the provided data type.
1845
1858
  *
@@ -1859,11 +1872,12 @@ export declare class Client extends EventEmitter<AdsClientEvents> {
1859
1872
  * @param value Value to convert
1860
1873
  * @param dataType Data type name in the PLC as string (such as `ST_Struct`) or data type object (acquired using {@link getDataType}())
1861
1874
  * @param autoFill autoFill If set and the data type is a container (`STRUCT`, `FUNCTION_BLOCK` etc.), missing properties are automatically set to default values (`0` or empty string).
1875
+ * @param attributes Additional attributes of the symbol or data type used for conversion
1862
1876
  * @param targetOpts Optional target settings that override values in `settings`
1863
1877
  *
1864
1878
  * @throws Throws an error if sending the command fails or if the target responds with an error.
1865
1879
  */
1866
- convertToRaw(value: any, dataType: string | AdsDataType, autoFill?: boolean, targetOpts?: Partial<AmsAddress>): Promise<Buffer>;
1880
+ convertToRaw(value: any, dataType: string | AdsDataType, autoFill?: boolean, attributes?: AdsAttributeEntry[], targetOpts?: Partial<AmsAddress>): Promise<Buffer>;
1867
1881
  /**
1868
1882
  * Creates a handle to a variable at the target system by variable path (such as `GVL_Test.ExampleStruct`).
1869
1883
  *
@@ -39,13 +39,23 @@ var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (
39
39
  }) : function(o, v) {
40
40
  o["default"] = v;
41
41
  });
42
- var __importStar = (this && this.__importStar) || function (mod) {
43
- if (mod && mod.__esModule) return mod;
44
- var result = {};
45
- if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
46
- __setModuleDefault(result, mod);
47
- return result;
48
- };
42
+ var __importStar = (this && this.__importStar) || (function () {
43
+ var ownKeys = function(o) {
44
+ ownKeys = Object.getOwnPropertyNames || function (o) {
45
+ var ar = [];
46
+ for (var k in o) if (Object.prototype.hasOwnProperty.call(o, k)) ar[ar.length] = k;
47
+ return ar;
48
+ };
49
+ return ownKeys(o);
50
+ };
51
+ return function (mod) {
52
+ if (mod && mod.__esModule) return mod;
53
+ var result = {};
54
+ if (mod != null) for (var k = ownKeys(mod), i = 0; i < k.length; i++) if (k[i] !== "default") __createBinding(result, mod, k[i]);
55
+ __setModuleDefault(result, mod);
56
+ return result;
57
+ };
58
+ })();
49
59
  var __importDefault = (this && this.__importDefault) || function (mod) {
50
60
  return (mod && mod.__esModule) ? mod : { "default": mod };
51
61
  };
@@ -1708,7 +1718,7 @@ class Client extends events_1.default {
1708
1718
  };
1709
1719
  if (this.symbol) {
1710
1720
  const dataType = await clientRef.getDataType(this.symbol.type, this.targetOpts);
1711
- result.value = clientRef.convertBufferToObject(data, dataType);
1721
+ result.value = clientRef.convertBufferToObject(data, dataType, this.symbol.attributes);
1712
1722
  }
1713
1723
  this.latestData = result;
1714
1724
  return result;
@@ -2279,7 +2289,6 @@ class Client extends events_1.default {
2279
2289
  pos += commentLength + 1;
2280
2290
  //Enumeration attributes
2281
2291
  dataType.enumInfos[i].attributes = [];
2282
- //console.log(enumInfoCount, num1, commentLength, attributeCount, test, attributes);
2283
2292
  //Attributes
2284
2293
  for (let i = 0; i < attributeCount; i++) {
2285
2294
  const attr = {};
@@ -2483,6 +2492,8 @@ class Client extends events_1.default {
2483
2492
  subItemType.hashValue = dataType.subItems[i].hashValue;
2484
2493
  subItemType.offset = dataType.subItems[i].offset;
2485
2494
  subItemType.comment = dataType.subItems[i].comment;
2495
+ //Let's keep attributes from parent as well as subitem's own attributes
2496
+ subItemType.attributes = [...subItemType.attributes, ...dataType.subItems[i].attributes];
2486
2497
  }
2487
2498
  builtType.subItems.push(subItemType);
2488
2499
  }
@@ -2553,10 +2564,11 @@ class Client extends events_1.default {
2553
2564
  *
2554
2565
  * @param buffer The raw data to convert
2555
2566
  * @param dataType Target data type
2567
+ * @param attributes Additional attributes of the symbol or data type to use for conversion
2556
2568
  */
2557
- convertBufferToPrimitiveType(buffer, dataType) {
2569
+ convertBufferToPrimitiveType(buffer, dataType, attributes) {
2558
2570
  if (dataType.adsDataType === ADS.ADS_DATA_TYPES.ADST_STRING) {
2559
- return ADS.decodePlcStringBuffer(buffer); //TODO: If symbol has {attribute 'TcEncoding':='UTF-8'}
2571
+ return ADS.decodePlcStringBuffer(buffer, this.getStringDataTypeEncoding(dataType, attributes) === 'UTF-8');
2560
2572
  }
2561
2573
  else if (dataType.adsDataType === ADS.ADS_DATA_TYPES.ADST_WSTRING) {
2562
2574
  return ADS.decodePlcWstringBuffer(buffer);
@@ -2565,6 +2577,16 @@ class Client extends events_1.default {
2565
2577
  return ADS.BASE_DATA_TYPES.fromBuffer(dataType.type, buffer, this.settings.convertDatesToJavascript);
2566
2578
  }
2567
2579
  }
2580
+ /**
2581
+ * Extracts TcEncoding attribute from the data datatype attributes or additional attributes
2582
+ *
2583
+ * @param dataType The data type
2584
+ * @param attributes Additional attributes of the symbol or data type
2585
+ */
2586
+ getStringDataTypeEncoding(dataType, attributes) {
2587
+ return dataType.attributes.find((attr) => attr.name === 'TcEncoding')?.value
2588
+ || attributes?.find((attr) => attr.name === 'TcEncoding')?.value;
2589
+ }
2568
2590
  /**
2569
2591
  * Converts raw data to Javascript object.
2570
2592
  *
@@ -2572,9 +2594,10 @@ class Client extends events_1.default {
2572
2594
  *
2573
2595
  * @param data The raw data to convert
2574
2596
  * @param dataType Target data type
2597
+ * @param attributes Additional attributes of the symbol or data type used for conversion
2575
2598
  * @param isArrayItem If `true`, this is an array item (default: `false`)
2576
2599
  */
2577
- convertBufferToObject(data, dataType, isArrayItem = false) {
2600
+ convertBufferToObject(data, dataType, attributes, isArrayItem = false) {
2578
2601
  let result;
2579
2602
  if ((dataType.arrayInfos.length === 0 || isArrayItem) && dataType.subItems.length > 0) {
2580
2603
  //Struct or array item
@@ -2596,7 +2619,7 @@ class Client extends events_1.default {
2596
2619
  }
2597
2620
  else {
2598
2621
  //Final dimension
2599
- temp.push(this.convertBufferToObject(data, dataType, true));
2622
+ temp.push(this.convertBufferToObject(data, dataType, undefined, true));
2600
2623
  data = data.subarray(dataType.size);
2601
2624
  }
2602
2625
  }
@@ -2642,7 +2665,7 @@ class Client extends events_1.default {
2642
2665
  }
2643
2666
  else {
2644
2667
  //Primitive type
2645
- result = this.convertBufferToPrimitiveType(data.subarray(dataType.offset, dataType.offset + dataType.size), dataType);
2668
+ result = this.convertBufferToPrimitiveType(data.subarray(dataType.offset, dataType.offset + dataType.size), dataType, attributes);
2646
2669
  }
2647
2670
  return result;
2648
2671
  }
@@ -2651,10 +2674,11 @@ class Client extends events_1.default {
2651
2674
  *
2652
2675
  * @param value Javascript object to convert
2653
2676
  * @param dataType Target data type
2677
+ * @param attributes Additional attributes of the symbol or data type used for conversion
2654
2678
  * @param objectPath Object path that is passed forward when calling recursively. This is used for error reporting if a property is missing
2655
2679
  * @param isArrayItem If `true`, this is an array item (default: `false`)
2656
2680
  */
2657
- convertObjectToBuffer(value, dataType, objectPath = '', isArrayItem = false) {
2681
+ convertObjectToBuffer(value, dataType, attributes, objectPath = '', isArrayItem = false) {
2658
2682
  let rawValue = Buffer.alloc(0);
2659
2683
  const pathInfo = objectPath === '' && dataType.name === ''
2660
2684
  ? ''
@@ -2688,7 +2712,7 @@ class Client extends events_1.default {
2688
2712
  };
2689
2713
  }
2690
2714
  //Converting subItem
2691
- let res = this.convertObjectToBuffer(value[key], subItem, `${pathInfo}.${subItem.name}`);
2715
+ let res = this.convertObjectToBuffer(value[key], subItem, undefined, `${pathInfo}.${subItem.name}`);
2692
2716
  if (res.missingProperty) {
2693
2717
  //We have a missing property somewhere -> quit
2694
2718
  return res;
@@ -2743,7 +2767,7 @@ class Client extends events_1.default {
2743
2767
  return `${pathInfo}${path}[${child}]`;
2744
2768
  }
2745
2769
  //Converting array item
2746
- let res = this.convertObjectToBuffer(value[child], dataType, `${pathInfo}.${path}[${child}]`, true);
2770
+ let res = this.convertObjectToBuffer(value[child], dataType, undefined, `${pathInfo}.${path}[${child}]`, true);
2747
2771
  if (res.missingProperty) {
2748
2772
  //We have a missing property somewhere -> quit
2749
2773
  return res.missingProperty;
@@ -2794,11 +2818,11 @@ class Client extends events_1.default {
2794
2818
  else {
2795
2819
  throw new client_error_1.default(`Provided value ${JSON.stringify(value)}${pathInfo} is not valid value for this ENUM. Allowed values are a number and any of the following: ${allowedEnumValuesStr}`);
2796
2820
  }
2797
- this.convertPrimitiveTypeToBuffer(enumEntry.value, dataType, rawValue);
2821
+ this.convertPrimitiveTypeToBuffer(enumEntry.value, dataType, rawValue, attributes);
2798
2822
  }
2799
2823
  else if (ADS.BASE_DATA_TYPES.isKnownType(dataType.type)) {
2800
2824
  rawValue = Buffer.alloc(dataType.size);
2801
- this.convertPrimitiveTypeToBuffer(value, dataType, rawValue);
2825
+ this.convertPrimitiveTypeToBuffer(value, dataType, rawValue, attributes);
2802
2826
  }
2803
2827
  else if (dataType.adsDataType === ADS.ADS_DATA_TYPES.ADST_BIGTYPE && dataType.subItems.length === 0) {
2804
2828
  //If size is 0, then it's empty struct -> rawValue is already OK
@@ -2833,15 +2857,17 @@ class Client extends events_1.default {
2833
2857
  * @param value Javascript object to convert
2834
2858
  * @param dataType Data type
2835
2859
  * @param buffer Reference to Buffer object where to write the raw value
2860
+ * @param attributes Additional attributes of the symbol or data type used for conversion
2836
2861
  */
2837
- convertPrimitiveTypeToBuffer(value, dataType, buffer) {
2862
+ convertPrimitiveTypeToBuffer(value, dataType, buffer, attributes) {
2838
2863
  if (dataType.size === 0) {
2839
2864
  return;
2840
2865
  }
2841
2866
  if (dataType.adsDataType === ADS.ADS_DATA_TYPES.ADST_STRING) {
2867
+ const encoded = ADS.encodeStringToPlcStringBuffer(value, this.getStringDataTypeEncoding(dataType, attributes) === 'UTF-8');
2842
2868
  //If string is too long for target data type, truncate it
2843
- const length = Math.min(dataType.size - 1, value.length);
2844
- ADS.encodeStringToPlcStringBuffer(value).copy(buffer, 0, 0, length);
2869
+ const length = Math.min(dataType.size - 1, encoded.length);
2870
+ encoded.copy(buffer, 0, 0, length);
2845
2871
  }
2846
2872
  else if (dataType.adsDataType === ADS.ADS_DATA_TYPES.ADST_WSTRING) {
2847
2873
  ADS.encodeStringToPlcWstringBuffer(value).copy(buffer);
@@ -5317,11 +5343,11 @@ class Client extends events_1.default {
5317
5343
  this.debug(`readValue(): Reading raw value from ${path} failed: %o`, err);
5318
5344
  throw new client_error_1.default(`readValue(): Reading raw value from ${path} failed`, err);
5319
5345
  }
5320
- //Converting byte data to javascript object
5346
+ //Converting byte data to javascript object
5321
5347
  let value;
5322
5348
  try {
5323
5349
  this.debugD(`readValue(): Converting raw value to object for ${path}`);
5324
- value = await this.convertBufferToObject(rawValue, dataType);
5350
+ value = await this.convertBufferToObject(rawValue, dataType, symbol.attributes);
5325
5351
  }
5326
5352
  catch (err) {
5327
5353
  this.debug(`readValue(): Converting raw value to object for ${path} failed: %o`, err);
@@ -5433,7 +5459,7 @@ class Client extends events_1.default {
5433
5459
  //Creating raw data from object
5434
5460
  let rawValue;
5435
5461
  try {
5436
- let res = this.convertObjectToBuffer(value, dataType);
5462
+ let res = this.convertObjectToBuffer(value, dataType, symbol.attributes);
5437
5463
  if (res.missingProperty && autoFill) {
5438
5464
  //Some fields are missing and autoFill is used -> try to auto fill missing values
5439
5465
  this.debug(`writeValue(): Autofilling missing fields with active values`);
@@ -5442,7 +5468,7 @@ class Client extends events_1.default {
5442
5468
  this.debugD(`writeValue(): Merging objects (adding missing fields)`);
5443
5469
  value = this.deepMergeObjects(false, valueNow.value, value);
5444
5470
  //Try conversion again - should work now
5445
- res = this.convertObjectToBuffer(value, dataType);
5471
+ res = this.convertObjectToBuffer(value, dataType, symbol.attributes);
5446
5472
  if (res.missingProperty) {
5447
5473
  //This shouldn't really happen
5448
5474
  //However, if it happened, the merge isn't working as it should
@@ -5538,12 +5564,13 @@ class Client extends events_1.default {
5538
5564
  * ```
5539
5565
  *
5540
5566
  * @param dataType Data type name in the PLC as string (such as `ST_Struct`) or data type object (acquired using {@link getDataType}())
5567
+ * @param attributes Additional attributes of the symbol or data type used for conversion
5541
5568
  * @param targetOpts Optional target settings that override values in `settings`
5542
5569
  *
5543
5570
  * @template T Typescript data type of the PLC data, for example `getDefaultPlcObject<number>(...)` or `getDefaultPlcObject<ST_TypedStruct>(...)`
5544
5571
  * @throws Throws an error if sending the command fails or if the target responds with an error.
5545
5572
  */
5546
- async getDefaultPlcObject(dataType, targetOpts = {}) {
5573
+ async getDefaultPlcObject(dataType, attributes, targetOpts = {}) {
5547
5574
  if (!this.connection.connected) {
5548
5575
  throw new client_error_1.default(`getDefaultPlcObject(): Client is not connected. Use connect() to connect to the target first.`);
5549
5576
  }
@@ -5560,7 +5587,7 @@ class Client extends events_1.default {
5560
5587
  }
5561
5588
  }
5562
5589
  //Converting raw byte data to Javascript object
5563
- let value = await this.convertFromRaw(Buffer.alloc(dataType.size), dataType, targetOpts);
5590
+ let value = await this.convertFromRaw(Buffer.alloc(dataType.size), dataType, attributes, targetOpts);
5564
5591
  this.debug(`getDefaultPlcObject(): Empty default object created for ${dataType.type}`);
5565
5592
  return value;
5566
5593
  }
@@ -5583,12 +5610,13 @@ class Client extends events_1.default {
5583
5610
  *
5584
5611
  * @param data Raw data (acquired for example using {@link readRaw}())
5585
5612
  * @param dataType Data type name in the PLC as string (such as `ST_Struct`) or data type object (acquired using {@link getDataType}())
5613
+ * @param attributes Additional attributes of the symbol or data type used for conversion
5586
5614
  * @param targetOpts Optional target settings that override values in `settings`
5587
5615
  *
5588
5616
  * @template T Typescript data type of the PLC data, for example `convertFromRaw<number>(...)` or `convertFromRaw<ST_TypedStruct>(...)`
5589
5617
  * @throws Throws an error if sending the command fails or if the target responds with an error.
5590
5618
  */
5591
- async convertFromRaw(data, dataType, targetOpts = {}) {
5619
+ async convertFromRaw(data, dataType, attributes, targetOpts = {}) {
5592
5620
  if (!this.connection.connected) {
5593
5621
  throw new client_error_1.default(`convertFromRaw(): Client is not connected. Use connect() to connect to the target first.`);
5594
5622
  }
@@ -5608,7 +5636,7 @@ class Client extends events_1.default {
5608
5636
  let value;
5609
5637
  try {
5610
5638
  this.debugD(`convertFromRaw(): Converting raw value to object for ${dataType.type}`);
5611
- value = await this.convertBufferToObject(data, dataType);
5639
+ value = await this.convertBufferToObject(data, dataType, attributes);
5612
5640
  }
5613
5641
  catch (err) {
5614
5642
  this.debug(`convertFromRaw(): Converting raw value to object for ${dataType.type} failed: %o`, err);
@@ -5636,11 +5664,12 @@ class Client extends events_1.default {
5636
5664
  * @param value Value to convert
5637
5665
  * @param dataType Data type name in the PLC as string (such as `ST_Struct`) or data type object (acquired using {@link getDataType}())
5638
5666
  * @param autoFill autoFill If set and the data type is a container (`STRUCT`, `FUNCTION_BLOCK` etc.), missing properties are automatically set to default values (`0` or empty string).
5667
+ * @param attributes Additional attributes of the symbol or data type used for conversion
5639
5668
  * @param targetOpts Optional target settings that override values in `settings`
5640
5669
  *
5641
5670
  * @throws Throws an error if sending the command fails or if the target responds with an error.
5642
5671
  */
5643
- async convertToRaw(value, dataType, autoFill = false, targetOpts = {}) {
5672
+ async convertToRaw(value, dataType, autoFill = false, attributes, targetOpts = {}) {
5644
5673
  if (!this.connection.connected) {
5645
5674
  throw new client_error_1.default(`convertToRaw(): Client is not connected. Use connect() to connect to the target first.`);
5646
5675
  }
@@ -5659,16 +5688,16 @@ class Client extends events_1.default {
5659
5688
  //Converting Javascript object to raw byte data
5660
5689
  let rawValue;
5661
5690
  try {
5662
- let res = this.convertObjectToBuffer(value, dataType);
5691
+ let res = this.convertObjectToBuffer(value, dataType, attributes);
5663
5692
  if (res.missingProperty && autoFill) {
5664
5693
  //Some fields are missing and autoFill is used -> try to auto fill missing values
5665
5694
  this.debug(`convertToRaw(): Autofilling missing fields with default/zero values`);
5666
5695
  this.debugD(`convertToRaw(): Creating default object`);
5667
- const defaultValue = await this.getDefaultPlcObject(dataType, targetOpts);
5696
+ const defaultValue = await this.getDefaultPlcObject(dataType, attributes, targetOpts);
5668
5697
  this.debugD(`convertToRaw(): Merging objects (adding missing fields)`);
5669
5698
  value = this.deepMergeObjects(false, defaultValue, value);
5670
5699
  //Try conversion again - should work now
5671
- res = this.convertObjectToBuffer(value, dataType);
5700
+ res = this.convertObjectToBuffer(value, dataType, attributes);
5672
5701
  if (res.missingProperty) {
5673
5702
  //This shouldn't really happen
5674
5703
  //However, if it happened, the merge isn't working as it should