# Bosch Rexroth ctrlX Data Layer Node.js API 
## CHANGELOG

### 3.2.0
+ New: Updated to Data Layer API 3.6.2.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 5.2.0.

### 3.1.1
+ New: Upgraded to Node.js v24 LTS (Krypton).
+ New: Updated to Data Layer API 3.5.2.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 4.6.0.
+ New: ISubscription: Introduced method modify() to replace all subscribed nodes by a new list of addresses. Because calling unsubscribeAll() disables the subscription for reuse, use this new method to replace all subscribed nodes programmaticaly, without the need to create a new subscription. 

### 3.0.0
+ New: Updated to Data Layer API 3.4.1.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 4.4.0.
+ New: Common SBOM Initiative (CSI): Added Software Bill of Materials (SBOM) in CycloneDX format.

+ Changed: Upgraded to Ubuntu Core24 (noble).

### 2.5.0
+ New: Updated to Data Layer API 2.9.5.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 3.6.0.
+ New: Improved object lifetime management and performance.


+ Fix: Prevented unexpected crashes caused by GC cleanup and possible seqmentation faults on exiting the application.


+ Changed: Removed support for x86, because not applicable for ctrlX OS.

### 2.4.1
+ New: Updated to Data Layer API 2.8.6.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 3.4.0.
+ New: IClient: Introduced method _getDataFromFlatbuffers_ to query data of flatbuffers without using the ctrlX-dataLayer-flatbuffers package.

+ Changed: Removed support for x86, because not applicable for ctrlX OS.

### 2.3.0
+ New: Updated to Data Layer API 2.7.5.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 3.2.0.
+ New: IClient: Introduced method _getDataFromFlatbuffers_ to query data of flatbuffers without using the ctrlX-dataLayer-flatbuffers package.

### 2.2.2
+ New: Updated to Data Layer API 2.6.1.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 2.6.0.
+ New: IProvider: Introduced method _publishEvent_ to publish an event.

### 2.1.1
+ New: Updated to Data Layer API 2.5.1.

+ Fix: Bug 764861: libcomm_datalayer.so.2.4: cannot open shared object file: No such file or directory

### 2.1.0

+ New: Updated to Data Layer API 2.4.4.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 2.4.0.
+ New: IProvider: Introduced method _getRejectedNodePaths_ to get all rejected node paths, failed to register.


+ Changed: Removed OpenSSL V3 libraries for Windows, because of export control relevance. You have to install the latest [Win64 OpenSSL v3 Light](https://slproweb.com/products/Win32OpenSSL.html) setup, if the API is used on Windows operating systems.

### 2.0.1
+ New: Updated to Data Layer API 2.2.7.

+ Fix: API crash on arm64 and amd64 (undefined symbol: _ZN6common3log5trace11LogBufferedC1EPKcb)

### 2.0.0
+ New: Upgraded to Ubuntu 22.04 LTS (Jammy Jellyfish).
+ New: Upgraded to Data Layer API 2.2.5.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 2.2.0.

+ Fix: subscription-utils: Setting properties like SamplingInterval, QueueSize, DataChangeFilter, ChangeEvents, Counter were not applied to the subscription.

### 1.6.0
+ New: Updated to Data Layer API 1.10.7
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 1.20.0.
+ New: IClient: Introduced method _getConnectionStatus_ to get the current connection status.
+ New: Introduced remote builder to create a TCP remote address, replaced automatically by IPC if running locally on a ctrlX Core.

        const remote = Remote.build({ ip: "192.168.1.100", user: "admin", password: "-$_U/{X$aG}Z3/e<" })

### 1.5.0
+ New: Updated to Data Layer API 1.9.1.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 1.18.0.
+ New: IProvider: Introduced method _getRegisteredNodePaths_ to get all node paths, registered and handled by the provider.
+ New: IClient: Introduced efficient and fast _Bulk*_ methods to apply the same operation on a list of nodes (read, read metadata, write, create, remove, browse) just on a single method call. 

+ Fix: Result: Not all available result codes properly exported.

+ Changed: IClient: Method _writeJson_ now returns Promise\<IResult\> instead of Promise\<IVariant\>.

        writeJson(address: string, json: string): Promise<IResult>;

+ Changed: IClient: Changed signature of method _readJson_ to specify an optional argument (JSON).

        readJson(address: string, indentStep?: number, arg?: string): Promise<IVariant>;

+ Changed: IClient: Changed signature of method _read_ to specify an optional argument and optional datatype of this argument for conversion.
   
       read(address: string, arg?: any, argVariantType?: string): Promise<IVariant>;

### 1.4.1
### 1.4.0
+ New: Updated to Data Layer API 1.8.6.
+ New: Introduced data type _DLR_VARIANT_TYPE_TIMESTAMP_ ((FILETIME) 64 bit 100ns since 1.1.1601 UTC). Represented and converted to Date (milliseconds since 1 January 1970 UTC).
+ New: Introduced data type _DLR_VARIANT_TYPE_ARRAY_OF_TIMESTAMP_ ((FILETIME) 64 bit 100ns since 1.1.1601 UTC). Represented and converted to an array of Date (milliseconds since 1 January 1970 UTC).
+ New: Added converter methods for converting ctrlX Timestamp's into Date's and vice versa:

Converts a FILETIME (64 bit (BigInt) - 100ns since 1.1.1601 UTC) to a Date (milliseconds since 1 January 1970 UTC)

        public static toDate(fileTime: bigint): Date

Converts a Date (milliseconds since 1 January 1970 UTC) to a FILETIME (64 bit (BigInt) - 100ns since 1.1.1601 UTC)

        public static toFiletime(date: Date): bigint


+ Fix: IClient - createSubscription(): Application crashed (Native API), if already used subscription id used twice.
+ Fix: IClient - create(): Method returned Promise<IResult> instead of Promise<IVariant>, which is the value result of the create operation.

+ Changed: _TypeError_ to _Error_ for some exceptions.

### 1.3.1
+ New: Updated to Data Layer API 1.7.13.


### 1.3.0
+ New: Updated to Data Layer API 1.7.12.

+ Changed: IClient - Signature of subscription callback: Added result (status) of the subscription as first argument. 

        const dataChanged = (result: IResult, item: INotifyItem) => {
            if (result.isBad) {
                return;
            }

            // ...
        };

    __IMPORTANT__:

    If the client connection is interrupted (isConnected=false), the notification value changes to a flatbuffers of type _Diagnosis_. So always check the result, before accessing the value in a subscription callback.

### 1.2.1
+ New: Update to _ctrlx-datalayer-flatbuffers 1.14.2_.

### 1.2.0

+ New: Updated to Data Layer API 1.7.12.
+ New: Update to _ctrlx-datalayer-flatbuffers 1.14.1_ (using _flatbuffers 2.0.6_, which breaks with _flatbuffers 2.0.4_).

+ Changed: Signature of filetime timestamp conhelper method according _flatbuffers 2.0.6_:
 
        DatalayerSystem.toDate(fileTime: bigint): Date

### 1.1.0
+ New: Updated to Data Layer API 1.7.10.
+ New: Updated Flatbuffers types package 'ctrlx-datalayer-flatbuffers' 1.14.0.
+ New: MetadataUtils: Create Metadata with _MetadataBuilder_ without referencing flatbuffers classes directly:

        const metadata = new MetadataUtils.MetadataBuilder(
                        MetadataUtils.AllowedOperationFlags.Read |
                        MetadataUtils.AllowedOperationFlags.Write,
                        'my description',
                        'my descriptionUrl')
                        .setNodeClass(MetadataUtils.NodeClass.Variable)
                        ...
                        .build();

+ New: SubscriptionUtils: Create SubscriptionProperties with _SubscriptionPropertiesBuilder_ without referencing flatbuffers classes directly.
+ 
        const subscriptionProperties = new SubscriptionUtils.SubscriptionPropertiesBuilder('mySubscription')      
                .setPublishIntervalMillis(1000)
                .setSamplingIntervalMillis(100)
                ...
                .build();

+ New: SubscriptionUtils: Get _NotifyInfo_ within a subscription callback without referencing flatbuffers classes directly:

        const notifyInfo = SubscriptionUtils.NotifyInfo.from(item);

+ New: Provider: Introduced method _registerTypeVariant()_ to register a Variant containing a flatbuffers type.


+ Fix: Possible crash caused by Garbage Collector (GC).
+ Fix: Minor fixes and improvements.


+ Changed: Renamed package to _ctrlx-flatbuffers_.
+ Changed: Provider - Simplified signature of method _registerNode()_ using interface _IProviderNodeCallbacks_ as a single argument.
  
        registerNode(
            address: string,
            providerNodeCallbacks: IProviderNodeCallbacks): Promise<IResult>,

+ Changed: Outsourced all flatbuffers classes to new package 'ctrlx-datalayer-flatbuffers'. Please add the new package to dependencies section in package.json:

        "dependencies": {
                "ctrlx-datalayer-flatbuffers" : "^1.14.0"
        }

### 1.0.4
+ Fix: Client: readJson: Fixed possible application crash on reading some nodes.

### 1.0.3
+ Fix: Wrong array con(JavaScript -> ctrlX Data Layer) for numeric arrays to other numeric array types, specified by optional VariantTypes argument (e.g. VariantTypes.arint8). The converted array was truncated/resized to fix size of 8 elements.

### 1.0.2

+ New: Provider: registerNode() : Made handler functions optional. Use 'null' if not supported.

        provider.registerNode('samples/nodejs/test', null, null, null, onMetadata, onRead, null))

### 1.0.1
+ Fix: Subscription and Provider callback handling: Not possible to use different callbacks.
+ Fix: Fixed flatbuffer generated types for typescript (*.ts)

        admin_generated.ts
        controls_generated.ts
        sub_properties_generated.ts
        UserIdentityToken_generated.ts
        watchdog_generated.ts

    __Example:__

        import * as sub_settings from '../fbs/ts/sub_settings_generated';
### 1.0.0
+ First official release.
 
### 0.2.0
+ New: Updated to Data Layer API 1.7.4.
+ New: Introduced _VariantTypes_, which can be used for methods call using an (optional) type argument (write, create, ...)

        const VariantTypes = require('../dist/varianttypes');

        ...

        //Write the value
        const writeValue = 42;
        const variant = await client.write('samples/all-data/static/int8', writeValue, VariantTypes.int8);

+ Changed: Variant: Removed property (client) 'timestamp', because this is not created either by source nor by server. 
+ Changed: Client: Changed signature of method 'createSubscription'.

        /**
        * Creates a subscription.
        *
        * @param {string} subscriptionPropertiesFlatbuffers - The properties of the subscription (flatbuffers).
        * @param {function} callback - The callback called on data changes for all subscribed nodes.
        * @return {Promise<ISubscription>} The result.
        */
        createSubscription(subscriptionPropertiesFlatbuffers: Uint8Array, callback: DataChangedCallback): Promise<ISubscription>;
+ Changed - Provider: Changed signature of method 'registerNode'.

        /**
        * Registers the node to the datalayer.
        *
        * @param {string} address - The address of the node.
        * @param {function} onCreateCallback - The node handler function. Use 'null' if not supported.
        * @param {function} onRemoveCallback - The node handler function. Use 'null' if not supported.
        * @param {function} onBrowseCallback - The node handler function. Use 'null' if not supported.
        * @param {function} onMetadataCallback - The node handler function. Use 'null' if not supported.
        * @param {function} onReadCallback - The node handler function. Use 'null' if not supported.
        * @param {function} onWriteCallback - The node handler function. Use 'null' if not supported.
        * @return {Promise<IResult>} The result.
        */
        registerNode(
            address: string,
            onCreateCallback: ProviderNodeArgsCallback,
            onRemoveCallback: ProviderNodeCallback,
            onBrowseCallback: ProviderNodeCallback,
            onMetadataCallback: ProviderNodeCallback,
            onReadCallback: ProviderNodeArgsCallback,
            onWriteCallback: ProviderNodeArgsCallback): Promise<IResult>

### 0.1.0
+ New: First API draft.
+ New: Full support: Datalayersystem, Client, Provider.