Lines 3-90javascript
3 * SPDX-FileCopyrightText: Bosch Rexroth AG
5 * SPDX-License-Identifier: MIT
7var __importDefault = (this && this.__importDefault) || function (mod) {
8 return (mod && mod.__esModule) ? mod : { "default": mod };
10Object.defineProperty(exports, "__esModule", { value: true });
11exports.Remote = void 0;
13* This class provides auxiliary methods to create ctrlX Data Layer client and provider connection strings to ctrlX CORE devices.
14* It can be used for both running in an app build environment(QEMU VM) and within the snap environment on the ctrlX CORE.
16* Feel free to use it in your projects and to change it if necessary.
18* For ease of use, the default values for IP address, user, password and SSL port are chosen to match the settings of a
19* newly created ctrlX CORE device:
23* password='boschrexroth'
26* with these variables, the tcp connection string can be formatted as follows:
28* tcp://{user}:{password}@{ip}?sslport={sslPort}
30* If these values do not suit your use case, explicitly pass the parameters that require different values.
34* 1. ctrlX CORE or ctrlX CORE virtual with another IP address, user and password:
36* const remote = Remote.build({ ip: '192.168.1.100', user: 'admin', password: '-$_U/{X$aG}Z3/e<' })
38* 2. ctrlX CORE virtual with port forwarding running on the same host as the app build environment (QEMU VM):
40* const remote = Remote.build({ ip: '10.0.2.2', sslPort: 8443 })
43* 10.0.2.2 is the IP address of the host from the point of view of the app build environment(QEMU VM).
44* 8443 is the host port which is forwarded to the SSL port(=433) of the ctrlX CORE virtual
46* 3. ctrlX CORE virtual with port forwarding running on windows build environment (MS Visual Studio):
48* const remote = Remote.build({ ip: '127.0.0.1', sslPort: 8443 })
51* 127.0.0.1 is the IP address of the ctrlX virtual on the windows host system.
52* 8443 is the host port which is forwarded to the SSL port(=433) of the ctrlX CORE virtual
55* You don't need to change the parameter settings, before building a snap and installing the snap on a ctrlX CORE.
56* The Remote util detects the snap environment and uses automatically inter process communication 'ipc://'.
57* If you don't wan't to communicate to localhost (e.g. C2C), please build up the remote string manually in the following form (sslport is optional):
59* const remote = `${DatalayerSystem.protocolSchemeTcp}${user}:${password}@${ip}?sslport=${sslPort}`
61* If you have a special port, different from the default one (e.g. for port forwarding),
62* set the port and build up the remote string manually in the following form (SSL port defaults to 443 and is optional):
64* const remote = `${DatalayerSystem.protocolSchemeTcp}${user}:${password}@${ip}:${port}?sslport=${sslPort}`
66const datalayersystem_1 = __importDefault(require("./datalayersystem"));
69 * Creates a ctrlX Data Layer connection string.
70 * @param ip: The IP address of the ctrlX CORE. Use '10.0.2.2' to connect to a ctrlX CORE virtual with port forwarding.
71 * @param user: The Name of the user.
72 * @param password: The Password of the user.
73 * @param sslPort: The Port number for a SSL connection. ctrlX CORE virtual with port forwarding: Use the host port (default 8443) forwarded to port 22 of the ctrlX virtual.
74 * @param port: The port number of connection.
75 * @returns The connection string: ipc connection string if running inside snap, otherwise tcp connection string.
77 static build({ ip = '192.168.1.1', user = 'boschrexroth', password = 'boschrexroth', sslPort = 443, port = NaN }) {
78 const isSnap = typeof process.env.SNAP !== 'undefined' && process.env.SNAP_NAME !== 'node';
80 return datalayersystem_1.default.protocolSchemeIpc;
82 if (!Number.isNaN(port) && port < 0) {
83 throw new TypeError("invalid port");
85 const address = Number.isNaN(port) ? ip : `${ip}:${port}`;
86 return `${datalayersystem_1.default.protocolSchemeTcp}${user}:${password}@${address}?sslport=${sslPort}`;
89exports.Remote = Remote;