# Bosch Rexroth ctrlX Data Layer Node.js API 

This is the ctrlX Data Layer API for Node.js.

Based on Node.js _N-API_ accessed by module _node-addon-api_

    https://github.com/nodejs/node-addon-api

- [`nan`](https://github.com/nodejs/nan): C++-based abstraction between Node and direct V8 APIs.
- [`Node-API`](https://nodejs.org/api/n-api.html): C-based API guaranteeing [ABI stability](https://nodejs.org/en/docs/guides/abi-stability/) across different node versions as well as JavaScript engines. (Node-API was previously known as N-API.)
- [`node-addon-api`](https://github.com/nodejs/node-addon-api): header-only C++ wrapper classes which simplify the use of the C-based Node-API.

This also uses Node.js native addon build tool _node-gyp_ as native compiler toolchain

    https://github.com/nodejs/node-gyp

The API project has been initially generated by _generator-napi-module_

    https://www.npmjs.com/package/generator-napi-module

    https://github.com/digitalinfinity/generator-napi-module/blob/master/README.md

## Usage

### Quick Overview

This library enables read and write access to the ctrlX Data Layer of [ctrlX AUTOMATION](https://www.ctrlx-automation.com/) devices from [Bosch Rexroth](https://www.boschrexroth.com).
It provides interfaces and classes written in Typescript to create ctrlX Data Layer clients and providers.

### Install

```sh
npm install ctrlx-datalayer --save
```

### Usage

The following code snippet demonstrates how to create a client and read a value from a ctrlX Data Layer node:

```ts
async function main() {

    // Create DatalayerSystem and start
    const system = new DatalayerSystem('');
    await system.start(false);

    // Build remote
    const cred = {
        user: 'boschrexroth',
        password: 'boschrexroth',
        ip: '192.168.1.1'
    };
    let remote = Remote.build(cred);

    // Create a client
    const client = await system.createClient(remote);

    // Read value
    const variant = await client.read('framework/metrics/system/cpu-utilisation-percent');
    console.log(variant);
}

main();
```
### Samples

It might be helpful to have a look at the [README Node.js Apps @ ctrlX](https://github.com/boschrexroth/ctrlx-automation-sdk/blob/main/samples-node/README.md) document to find implementations of the different use-cases. 

## Support

This repository is provided and maintained by [Bosch Rexroth](https://www.boschrexroth.com). 

### Developer Community

Feel free to check out and be part of the [ctrlX AUTOMATION Community](https://ctrlx-automation.com/community). Get additional support, e.g. related to Bosch Rexroth Devices, Apps, SDKs and Services, or leave some ideas and feedback.

### SDK Forum

Please join the discussions in the [SDK Forum ctrlX AUTOMATION](https://developer.community.boschrexroth.com/t5/SDK/bd-p/dcdev_community-dcae-sdk):

### Issues

To report bugs, request changes and discuss new ideas you may also have a look at the issue tracker of this repository:
<https://github.com/boschrexroth/ctrlx-automation-sdk/issues>

## License

The binary files "datalayer.dll" and "comm.datalayer.so*" are licensed under the "Terms and Conditions for the Provision of
Products of Bosch Rexroth AG Free of Charge" supplemented by the right to redistribution, any other software code in this repository is licensed under the:

    SPDX-FileCopyrightText: Bosch Rexroth AG
    SPDX-License-Identifier: MIT

### Terms and Conditions for the Provision of Products of Bosch Rexroth AG Free of Charge

See _LICENSES/tc_for_provision_of_products_free_of_charge.pdf_ inside this package. 
Download the latest version from <https://www.boschrexroth.com>. 
Navigate to Legal Notice (footer) -> Terms and Conditions for the Provision of Products Free of Charge.

### Open Source Software Licenses
See _LICENSES/FossInfo.json_ or _LICENSES/FossInfo.csv_ for used open source software licenses.

## About

Please note that any trademarks, logos and pictures contained or linked to in this Software are owned by or copyright © Bosch Rexroth AG and not licensed under the Software's license terms.

<https://www.boschrexroth.com>

Bosch Rexroth AG  
Bgm.-Dr.-Nebel-Str. 2  
97816 Lohr am Main  
GERMANY



