rticonnextdds-connector 1.3.0 → 1.4.0
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/README.md +1 -10
- package/README.rst +1 -16
- package/package.json +4 -5
- package/rticonnextdds-connector/lib/linux-arm64/libnddsc.so +0 -0
- package/rticonnextdds-connector/lib/linux-arm64/libnddscore.so +0 -0
- package/rticonnextdds-connector/lib/linux-arm64/librtiddsconnector.so +0 -0
- package/rticonnextdds-connector/lib/linux-x64/libnddsc.so +0 -0
- package/rticonnextdds-connector/lib/linux-x64/libnddscore.so +0 -0
- package/rticonnextdds-connector/lib/linux-x64/librtiddsconnector.so +0 -0
- package/rticonnextdds-connector/lib/osx-arm64/libnddsc.dylib +0 -0
- package/rticonnextdds-connector/lib/osx-arm64/libnddscore.dylib +0 -0
- package/rticonnextdds-connector/lib/osx-arm64/librtiddsconnector.dylib +0 -0
- package/rticonnextdds-connector/lib/win-x64/nddsc.dll +0 -0
- package/rticonnextdds-connector/lib/win-x64/nddscore.dll +0 -0
- package/rticonnextdds-connector/lib/win-x64/rtiddsconnector.dll +0 -0
- package/rticonnextdds-connector/lib/win-x64/vcruntime140.dll +0 -0
- package/rticonnextdds-connector.js +193 -202
- package/rticonnextdds-connector/lib/linux-arm/libnddsc.so +0 -0
- package/rticonnextdds-connector/lib/linux-arm/libnddscore.so +0 -0
- package/rticonnextdds-connector/lib/linux-arm/librtiddsconnector.so +0 -0
- package/rticonnextdds-connector/lib/osx-x64/libnddsc.dylib +0 -0
- package/rticonnextdds-connector/lib/osx-x64/libnddscore.dylib +0 -0
- package/rticonnextdds-connector/lib/osx-x64/librtiddsconnector.dylib +0 -0
package/README.md
CHANGED
|
@@ -26,22 +26,13 @@ The `examples/nodejs` directory provides several examples:
|
|
|
26
26
|
## Dependencies
|
|
27
27
|
|
|
28
28
|
RTI Connector for JavaScript has the following dependencies, which are also listed in `package.json`:
|
|
29
|
-
* [
|
|
30
|
-
* [ref-struct-napi](https://www.npmjs.com/package/ref-struct-napi): create ABI-compilant "Struct" instances on top of Buffers
|
|
31
|
-
* [ffi-napi](https://www.npmjs.com/package/ffi-napi): used for loading and calling dynamic libraries using pure JavaScript
|
|
29
|
+
* [koffi](https://koffi.dev/): used for loading and calling dynamic libraries using pure JavaScript
|
|
32
30
|
* [events](https://www.npmjs.com/package/events): used for the 'EventEmitter' (legacy implementation of RTI Connector)
|
|
33
31
|
|
|
34
32
|
Additionally to run the `web_socket` example, [socket.io](https://github.com/Automattic/socket.io) and [OpenLayers](https://openlayers.org) are required.
|
|
35
33
|
|
|
36
34
|
Additional dependencies are required to run the unit tests and some of the examples. Please see the README files in the appropriate directory.
|
|
37
35
|
|
|
38
|
-
### Python dependency
|
|
39
|
-
|
|
40
|
-
Some of the dependencies are shipped as source code and use [node-gyp](https://github.com/nodejs/node-gyp) to be compiled locally. `node-gyp` requires Python 2.7 and does not work with Python 3. The requirements for `node-gyp` can be found at:
|
|
41
|
-
* [unix](https://github.com/nodejs/node-gyp#on-unix)
|
|
42
|
-
* [darwin](https://github.com/nodejs/node-gyp#on-macos)
|
|
43
|
-
* [windows](https://github.com/nodejs/node-gyp#on-windows)
|
|
44
|
-
|
|
45
36
|
### C/C++ compiler dependency
|
|
46
37
|
|
|
47
38
|
The dependency [ref](https://www.npmjs.com/package/ref) is shipped as source code and requires a C++11 compiler.
|
package/README.rst
CHANGED
|
@@ -34,11 +34,7 @@ Dependencies
|
|
|
34
34
|
|
|
35
35
|
RTI Connector for JavaScript has the following dependencies, which are
|
|
36
36
|
also listed in ``package.json``: \*
|
|
37
|
-
`
|
|
38
|
-
instances into "pointers" \*
|
|
39
|
-
`ref-struct-napi <https://www.npmjs.com/package/ref-struct-napi>`__:
|
|
40
|
-
create ABI-compilant "Struct" instances on top of Buffers \*
|
|
41
|
-
`ffi-napi <https://www.npmjs.com/package/ffi-napi>`__: used for loading
|
|
37
|
+
`koffi <https://koffi.dev/>`__: used for loading
|
|
42
38
|
and calling dynamic libraries using pure JavaScript \*
|
|
43
39
|
`events <https://www.npmjs.com/package/events>`__: used for the
|
|
44
40
|
'EventEmitter' (legacy implementation of RTI Connector)
|
|
@@ -50,17 +46,6 @@ Additionally to run the ``web_socket`` example,
|
|
|
50
46
|
Additional dependencies are required to run the unit tests and some of
|
|
51
47
|
the examples. Please see the README files in the appropriate directory.
|
|
52
48
|
|
|
53
|
-
Python dependency
|
|
54
|
-
~~~~~~~~~~~~~~~~~
|
|
55
|
-
|
|
56
|
-
Some of the dependencies are shipped as source code and use
|
|
57
|
-
`node-gyp <https://github.com/nodejs/node-gyp>`__ to be compiled
|
|
58
|
-
locally. ``node-gyp`` requires Python 2.7 and does not work with Python
|
|
59
|
-
3. The requirements for ``node-gyp`` can be found at: \*
|
|
60
|
-
`unix <https://github.com/nodejs/node-gyp#on-unix>`__ \*
|
|
61
|
-
`darwin <https://github.com/nodejs/node-gyp#on-macos>`__ \*
|
|
62
|
-
`windows <https://github.com/nodejs/node-gyp#on-windows>`__
|
|
63
|
-
|
|
64
49
|
C/C++ compiler dependency
|
|
65
50
|
~~~~~~~~~~~~~~~~~~~~~~~~~
|
|
66
51
|
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rticonnextdds-connector",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.4.0",
|
|
4
4
|
"description": "RTI Connector for JavaScript",
|
|
5
5
|
"main": "rticonnextdds-connector.js",
|
|
6
6
|
"files": [
|
|
@@ -14,9 +14,7 @@
|
|
|
14
14
|
},
|
|
15
15
|
"dependencies": {
|
|
16
16
|
"events": "^3.2.0",
|
|
17
|
-
"
|
|
18
|
-
"ref-napi": "^3.0.1",
|
|
19
|
-
"ref-struct-di": "^1.1.1"
|
|
17
|
+
"koffi": "^2.8.9"
|
|
20
18
|
},
|
|
21
19
|
"scripts": {
|
|
22
20
|
"test": "mocha ./test/nodejs/",
|
|
@@ -44,5 +42,6 @@
|
|
|
44
42
|
"mocha": "^10.2.0",
|
|
45
43
|
"mocha-junit-reporter": "^2.2.0",
|
|
46
44
|
"sinon": "^10.0.0"
|
|
47
|
-
}
|
|
45
|
+
},
|
|
46
|
+
"rti.build-id": "BUILD_7.6.0.0_20250918T000000Z_RTI_REL"
|
|
48
47
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
@@ -7,25 +7,16 @@
|
|
|
7
7
|
******************************************************************************/
|
|
8
8
|
|
|
9
9
|
const os = require('os')
|
|
10
|
-
const ref = require('ref-napi')
|
|
11
|
-
const ffi = require('ffi-napi')
|
|
12
10
|
const path = require('path')
|
|
13
|
-
const
|
|
11
|
+
const koffi = require('koffi');
|
|
14
12
|
const EventEmitter = require('events').EventEmitter
|
|
15
13
|
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
*
|
|
23
|
-
* @private
|
|
24
|
-
*/
|
|
25
|
-
const _ConnectorOptions = StructType({
|
|
26
|
-
enable_on_data_event: ref.types.int,
|
|
27
|
-
one_based_sequence_indexing: ref.types.int
|
|
28
|
-
})
|
|
14
|
+
const _ConnectorOptions = koffi.struct('RTI_Connector_Options', {
|
|
15
|
+
enable_on_data_event: 'int',
|
|
16
|
+
one_based_sequence_indexing: 'int'
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
const RTI_HANDLE = koffi.pointer('RTI_HANDLE', koffi.opaque());
|
|
29
20
|
|
|
30
21
|
// We ignore the loading of the libraries in code coverage since it is
|
|
31
22
|
// not easily testable
|
|
@@ -42,26 +33,20 @@ class _ConnectorBinding {
|
|
|
42
33
|
if (os.platform() === 'linux') {
|
|
43
34
|
libDir = 'linux-arm64'
|
|
44
35
|
libName = 'librtiddsconnector.so'
|
|
36
|
+
} else if (os.platform() === 'darwin') {
|
|
37
|
+
libDir = 'osx-arm64'
|
|
38
|
+
libName = 'librtiddsconnector.dylib'
|
|
45
39
|
} else {
|
|
46
40
|
throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
|
|
47
41
|
}
|
|
48
42
|
} else if (os.arch() === 'arm') {
|
|
49
|
-
|
|
50
|
-
libDir = 'linux-arm'
|
|
51
|
-
libName = 'librtiddsconnector.so'
|
|
52
|
-
} else {
|
|
53
|
-
throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
|
|
54
|
-
}
|
|
43
|
+
throw new Error('This platform (' + os.platform() + ' ' + os.arch() + ') is not supported')
|
|
55
44
|
} else {
|
|
56
45
|
// Note that we are intentionally not checking if os.arch() is x64.
|
|
57
46
|
// This allows somebody with access to 32-bit libraries to replace them
|
|
58
47
|
// in the corresponding x64 directory and we will try to load them.
|
|
59
48
|
// This behaviour is not officially supported.
|
|
60
49
|
switch (os.platform()) {
|
|
61
|
-
case 'darwin':
|
|
62
|
-
libDir = 'osx-x64'
|
|
63
|
-
libName = 'librtiddsconnector.dylib'
|
|
64
|
-
break
|
|
65
50
|
case 'linux':
|
|
66
51
|
libDir = 'linux-x64'
|
|
67
52
|
libName = 'librtiddsconnector.so'
|
|
@@ -70,7 +55,6 @@ class _ConnectorBinding {
|
|
|
70
55
|
case 'win32':
|
|
71
56
|
libDir = 'win-x64'
|
|
72
57
|
libName = 'rtiddsconnector.dll'
|
|
73
|
-
additionalLib = 'vcruntime140.dll'
|
|
74
58
|
isWindows = true
|
|
75
59
|
break
|
|
76
60
|
default:
|
|
@@ -85,95 +69,67 @@ class _ConnectorBinding {
|
|
|
85
69
|
console.log('Warning: 32-bit ' + os.platform() + ' is not supported')
|
|
86
70
|
}
|
|
87
71
|
|
|
88
|
-
|
|
89
|
-
try {
|
|
90
|
-
ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', additionalLib))
|
|
91
|
-
} catch (_) {
|
|
92
|
-
// ignore this error and try to run without explicitly loading the VC++ runtime
|
|
93
|
-
}
|
|
94
|
-
}
|
|
72
|
+
this.library = path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', libName)
|
|
95
73
|
|
|
96
|
-
|
|
97
|
-
if (isWindows) {
|
|
98
|
-
ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddscore.dll'))
|
|
99
|
-
ffi.Library(path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', 'nddsc.dll'))
|
|
100
|
-
}
|
|
74
|
+
this.api = koffi.load(this.library);
|
|
101
75
|
|
|
102
|
-
this.library = path.join(__dirname, '/rticonnextdds-connector/lib/', libDir, '/', libName)
|
|
103
76
|
// Obtain FFI'd methods for all of the APIs which we require from the binding,
|
|
104
77
|
// specifying the argument types and return types. If any of the types are
|
|
105
78
|
// not builtin Node types then we have to use the ref module to represent them.
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
79
|
+
|
|
80
|
+
const RTI_Connector_free_string = this.api.func('RTI_Connector_free_string', 'void', ['char *']);
|
|
81
|
+
const AllocatedString = koffi.disposable('AllocatedString', 'string', RTI_Connector_free_string);
|
|
82
|
+
|
|
83
|
+
this.RTI_Connector_new = this.api.func('RTI_Connector_new', RTI_HANDLE, ['string', 'string', koffi.pointer(_ConnectorOptions)]);
|
|
84
|
+
this.RTI_Connector_delete = this.api.func('RTI_Connector_delete', 'void', ['RTI_HANDLE']);
|
|
85
|
+
this.RTI_Connector_get_datawriter = this.api.func('RTI_Connector_get_datawriter', 'RTI_HANDLE', ['RTI_HANDLE', 'string']);
|
|
86
|
+
this.RTI_Connector_get_datareader = this.api.func('RTI_Connector_get_datareader', 'RTI_HANDLE', ['RTI_HANDLE', 'string']);
|
|
87
|
+
this.RTI_Connector_get_native_sample = this.api.func('RTI_Connector_get_native_sample', 'RTI_HANDLE', ['RTI_HANDLE', 'string', 'int']);
|
|
88
|
+
this.RTI_Connector_set_number_into_samples = this.api.func('RTI_Connector_set_number_into_samples', 'int', ['RTI_HANDLE', 'string', 'string', 'double']);
|
|
89
|
+
this.RTI_Connector_set_boolean_into_samples = this.api.func('RTI_Connector_set_boolean_into_samples', 'int', ['RTI_HANDLE', 'string', 'string', 'bool']);
|
|
90
|
+
this.RTI_Connector_set_string_into_samples = this.api.func('RTI_Connector_set_string_into_samples', 'int', ['RTI_HANDLE', 'string', 'string', 'string']);
|
|
91
|
+
this.RTI_Connector_clear_member = this.api.func('RTI_Connector_clear_member', 'int', ['RTI_HANDLE', 'string', 'string']);
|
|
92
|
+
this.RTI_Connector_write = this.api.func('RTI_Connector_write', 'int', ['RTI_HANDLE', 'string', 'string']);
|
|
93
|
+
this.RTI_Connector_wait_for_acknowledgments = this.api.func('RTI_Connector_wait_for_acknowledgments', 'int', ['RTI_HANDLE', 'int']);
|
|
94
|
+
this.RTI_Connector_read = this.api.func('RTI_Connector_read', 'int', ['RTI_HANDLE', 'string']);
|
|
95
|
+
this.RTI_Connector_take = this.api.func('RTI_Connector_take', 'int', ['RTI_HANDLE', 'string']);
|
|
96
|
+
this.RTI_Connector_return_loan = this.api.func('RTI_Connector_return_loan', 'int', ['RTI_HANDLE', 'string']);
|
|
97
|
+
this.RTI_Connector_wait_for_data = this.api.func('RTI_Connector_wait_for_data', 'int', ['RTI_HANDLE', 'int']);
|
|
98
|
+
this.RTI_Connector_wait_for_data_on_reader = this.api.func('RTI_Connector_wait_for_data_on_reader', 'int', ['RTI_HANDLE', 'int']);
|
|
99
|
+
this.RTI_Connector_wait_for_matched_publication = this.api.func('RTI_Connector_wait_for_matched_publication', 'int', ['RTI_HANDLE', 'int', koffi.out(koffi.pointer('int'))]);
|
|
100
|
+
this.RTI_Connector_wait_for_matched_subscription = this.api.func('RTI_Connector_wait_for_matched_subscription', 'int', ['RTI_HANDLE', 'int', koffi.out(koffi.pointer('int'))]);
|
|
101
|
+
this.RTI_Connector_get_matched_subscriptions = this.api.func('RTI_Connector_get_matched_subscriptions', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer(AllocatedString))]);
|
|
102
|
+
this.RTI_Connector_get_matched_publications = this.api.func('RTI_Connector_get_matched_publications', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer(AllocatedString))]);
|
|
103
|
+
this.RTI_Connector_clear = this.api.func('RTI_Connector_clear', 'int', ['RTI_HANDLE', 'string']);
|
|
104
|
+
this.RTI_Connector_get_boolean_from_infos = this.api.func('RTI_Connector_get_boolean_from_infos', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('bool')), 'string', 'int', 'string']);
|
|
105
|
+
this.RTI_Connector_get_json_from_infos = this.api.func('RTI_Connector_get_json_from_infos', 'int', ['RTI_HANDLE', 'string', 'int', 'string', koffi.out(koffi.pointer(AllocatedString))]);
|
|
106
|
+
this.RTI_Connector_get_sample_count = this.api.func('RTI_Connector_get_sample_count', 'int', ['RTI_HANDLE', 'string', koffi.out(koffi.pointer('double'))]);
|
|
107
|
+
this.RTI_Connector_get_number_from_sample = this.api.func('RTI_Connector_get_number_from_sample', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('double')), 'string', 'int', 'string']);
|
|
108
|
+
this.RTI_Connector_get_boolean_from_sample = this.api.func('RTI_Connector_get_boolean_from_sample', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('int')), 'string', 'int', 'string']);
|
|
109
|
+
this.RTI_Connector_get_string_from_sample = this.api.func('RTI_Connector_get_string_from_sample', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer(AllocatedString)), 'string', 'int', 'string']);
|
|
110
|
+
this.RTI_Connector_get_any_from_sample = this.api.func('RTI_Connector_get_any_from_sample', 'int', ['RTI_HANDLE',koffi.out(koffi.pointer('double')), koffi.out(koffi.pointer('int')), koffi.out(koffi.pointer(AllocatedString)), koffi.out(koffi.pointer('int')), 'string', 'int', 'string']);
|
|
111
|
+
this.RTI_Connector_get_any_from_info = this.api.func('RTI_Connector_get_any_from_info', 'int', ['RTI_HANDLE', koffi.out(koffi.pointer('double')), koffi.out(koffi.pointer('int')), koffi.out(koffi.pointer(AllocatedString)), koffi.out(koffi.pointer('int')), 'string', 'int', 'string']);
|
|
112
|
+
this.RTI_Connector_get_json_sample = this.api.func('RTI_Connector_get_json_sample', 'int', ['RTI_HANDLE', 'string', 'int', koffi.out(koffi.pointer(AllocatedString))]);
|
|
113
|
+
this.RTI_Connector_get_json_member = this.api.func('RTI_Connector_get_json_member', 'int', ['RTI_HANDLE', 'string', 'int', 'string', koffi.out(koffi.pointer(AllocatedString))]);
|
|
114
|
+
this.RTI_Connector_set_json_instance = this.api.func('RTI_Connector_set_json_instance', 'int', ['RTI_HANDLE', 'string', 'string']);
|
|
115
|
+
this.RTI_Connector_get_last_error_message = this.api.func('RTI_Connector_get_last_error_message', AllocatedString, []);
|
|
116
|
+
this.RTI_Connector_get_native_instance = this.api.func('RTI_Connector_get_native_instance', 'int', ['RTI_HANDLE', 'string', koffi.out(koffi.pointer(RTI_HANDLE))]);
|
|
117
|
+
this.RTIDDSConnector_getJSONInstance = this.api.func('RTIDDSConnector_getJSONInstance', AllocatedString, ['RTI_HANDLE', 'string']);
|
|
142
118
|
// This API is only used in the unit tests
|
|
143
|
-
RTI_Connector_create_test_scenario
|
|
144
|
-
RTI_Connector_get_build_versions
|
|
145
|
-
})
|
|
119
|
+
this.RTI_Connector_create_test_scenario = this.api.func('RTI_Connector_create_test_scenario', 'int', ['RTI_HANDLE', 'int', 'RTI_HANDLE']);
|
|
120
|
+
this.RTI_Connector_get_build_versions = this.api.func('RTI_Connector_get_build_versions', 'int', [koffi.out(koffi.pointer('string')), koffi.out(koffi.pointer('string'))]);
|
|
146
121
|
}
|
|
147
122
|
}
|
|
148
123
|
|
|
149
124
|
// Create an instance of the connectorBinding class, allowing us to call the FFI'd methods
|
|
150
125
|
const connectorBinding = new _ConnectorBinding()
|
|
151
126
|
|
|
152
|
-
/**
|
|
153
|
-
* Copies a natively allocated string into a Node.js string and frees the
|
|
154
|
-
* native memory.
|
|
155
|
-
*
|
|
156
|
-
* @param {Buffer} cstring - The string returned by the core
|
|
157
|
-
*
|
|
158
|
-
* @private
|
|
159
|
-
*/
|
|
160
|
-
function _moveCString (cstring) {
|
|
161
|
-
const ret = ref.readCString(cstring)
|
|
162
|
-
connectorBinding.api.RTI_Connector_free_string(cstring)
|
|
163
|
-
return ret
|
|
164
|
-
}
|
|
165
|
-
|
|
166
127
|
/**
|
|
167
128
|
* Obtains the last error message from the *RTI Connext DDS* Core
|
|
168
129
|
* @private
|
|
169
130
|
*/
|
|
170
131
|
function _getLastDdsErrorMessage () {
|
|
171
|
-
|
|
172
|
-
if (cStr !== null) {
|
|
173
|
-
return _moveCString(cStr)
|
|
174
|
-
} else {
|
|
175
|
-
return ''
|
|
176
|
-
}
|
|
132
|
+
return connectorBinding.RTI_Connector_get_last_error_message()
|
|
177
133
|
}
|
|
178
134
|
|
|
179
135
|
/**
|
|
@@ -284,6 +240,14 @@ function _isNumber (value) {
|
|
|
284
240
|
return typeof value === 'number' && isFinite(value)
|
|
285
241
|
}
|
|
286
242
|
|
|
243
|
+
/**
|
|
244
|
+
* Checks if a value is an object
|
|
245
|
+
* @param {any} value - The value to check the type of
|
|
246
|
+
*/
|
|
247
|
+
function _isObject (value) {
|
|
248
|
+
return typeof value === 'object' && value !== null
|
|
249
|
+
}
|
|
250
|
+
|
|
287
251
|
/**
|
|
288
252
|
* Function used to get any value from either the samples or infos (depending
|
|
289
253
|
* on the supplied getter). The type of the fieldName need not be specified.
|
|
@@ -297,10 +261,10 @@ function _isNumber (value) {
|
|
|
297
261
|
* @private
|
|
298
262
|
*/
|
|
299
263
|
function _getAnyValue (getter, connector, inputName, index, fieldName) {
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
let selection =
|
|
264
|
+
let numberVal = [null]
|
|
265
|
+
let boolVal = [null]
|
|
266
|
+
let stringVal = [null]
|
|
267
|
+
let selection = [null]
|
|
304
268
|
const retcode = getter(
|
|
305
269
|
connector,
|
|
306
270
|
numberVal,
|
|
@@ -314,13 +278,13 @@ function _getAnyValue (getter, connector, inputName, index, fieldName) {
|
|
|
314
278
|
if (retcode === _ReturnCodes.noData) {
|
|
315
279
|
return null
|
|
316
280
|
}
|
|
317
|
-
selection = selection
|
|
281
|
+
selection = selection[0]
|
|
318
282
|
if (selection === _AnyValueKind.connector_number) {
|
|
319
|
-
return numberVal
|
|
283
|
+
return numberVal[0]
|
|
320
284
|
} else if (selection === _AnyValueKind.connector_boolean) {
|
|
321
|
-
return !!boolVal
|
|
285
|
+
return !!boolVal[0]
|
|
322
286
|
} else if (selection === _AnyValueKind.connector_string) {
|
|
323
|
-
const nodeStr =
|
|
287
|
+
const nodeStr = stringVal[0]
|
|
324
288
|
// If this is NOT a numeric string, try to convert the returned string to a
|
|
325
289
|
// JSON object. We can now return one of two things:
|
|
326
290
|
// - An actual string (if the JSON.parse call fails)
|
|
@@ -358,13 +322,13 @@ class Infos {
|
|
|
358
322
|
* @private
|
|
359
323
|
*/
|
|
360
324
|
getLength () {
|
|
361
|
-
|
|
362
|
-
const retcode = connectorBinding.
|
|
325
|
+
let length = [null];
|
|
326
|
+
const retcode = connectorBinding.RTI_Connector_get_sample_count(
|
|
363
327
|
this.input.connector.native,
|
|
364
328
|
this.input.name,
|
|
365
329
|
length)
|
|
366
330
|
_checkRetcode(retcode)
|
|
367
|
-
return length
|
|
331
|
+
return length[0]
|
|
368
332
|
}
|
|
369
333
|
|
|
370
334
|
/**
|
|
@@ -381,8 +345,8 @@ class Infos {
|
|
|
381
345
|
} else {
|
|
382
346
|
// Increment index since Lua arrays are 1-indexed
|
|
383
347
|
index += 1
|
|
384
|
-
|
|
385
|
-
const retcode = connectorBinding.
|
|
348
|
+
let value = [null]
|
|
349
|
+
const retcode = connectorBinding.RTI_Connector_get_boolean_from_infos(
|
|
386
350
|
this.input.connector.native,
|
|
387
351
|
value,
|
|
388
352
|
this.input.name,
|
|
@@ -392,7 +356,7 @@ class Infos {
|
|
|
392
356
|
if (retcode === _ReturnCodes.noData) {
|
|
393
357
|
return null
|
|
394
358
|
}
|
|
395
|
-
return value
|
|
359
|
+
return value[0]
|
|
396
360
|
}
|
|
397
361
|
}
|
|
398
362
|
}
|
|
@@ -427,7 +391,7 @@ class SampleIterator {
|
|
|
427
391
|
* contains valid data.
|
|
428
392
|
* @property {SampleInfo} infos - The meta-data associated with the
|
|
429
393
|
* current sample.
|
|
430
|
-
* @property {
|
|
394
|
+
* @property {RTI_HANDLE} native - A native handle that allows accessing
|
|
431
395
|
* additional *Connext DDS* APIs in C.
|
|
432
396
|
*/
|
|
433
397
|
constructor (input, index) {
|
|
@@ -553,9 +517,9 @@ class SampleIterator {
|
|
|
553
517
|
}
|
|
554
518
|
|
|
555
519
|
/**
|
|
556
|
-
* The native
|
|
520
|
+
* The native RTI_HANDLE to the DynamicData sample.
|
|
557
521
|
*
|
|
558
|
-
* @type {
|
|
522
|
+
* @type {RTI_HANDLE}
|
|
559
523
|
* @private
|
|
560
524
|
*/
|
|
561
525
|
get native () {
|
|
@@ -774,8 +738,8 @@ class Samples {
|
|
|
774
738
|
* @private
|
|
775
739
|
*/
|
|
776
740
|
getLength () {
|
|
777
|
-
|
|
778
|
-
const retcode = connectorBinding.
|
|
741
|
+
let length = [null]
|
|
742
|
+
const retcode = connectorBinding.RTI_Connector_get_sample_count(
|
|
779
743
|
this.input.connector.native,
|
|
780
744
|
this.input.name,
|
|
781
745
|
length)
|
|
@@ -783,7 +747,7 @@ class Samples {
|
|
|
783
747
|
// We use ~~ to convert from double -> int. This is required to allow:
|
|
784
748
|
// for (var i =0; i < input.samples.getLength(); ++i)
|
|
785
749
|
// It works since we are doing a bitwise complement (double not).
|
|
786
|
-
return ~~length
|
|
750
|
+
return ~~length[0]
|
|
787
751
|
}
|
|
788
752
|
|
|
789
753
|
/**
|
|
@@ -803,8 +767,8 @@ class Samples {
|
|
|
803
767
|
} else {
|
|
804
768
|
// Increment index since C API is based on Lua with 1-based indexes
|
|
805
769
|
index += 1
|
|
806
|
-
|
|
807
|
-
const retcode = connectorBinding.
|
|
770
|
+
let value = [null]
|
|
771
|
+
const retcode = connectorBinding.RTI_Connector_get_number_from_sample(
|
|
808
772
|
this.input.connector.native,
|
|
809
773
|
value,
|
|
810
774
|
this.input.name,
|
|
@@ -815,7 +779,7 @@ class Samples {
|
|
|
815
779
|
if (retcode === _ReturnCodes.noData) {
|
|
816
780
|
return null
|
|
817
781
|
} else {
|
|
818
|
-
return value
|
|
782
|
+
return value[0]
|
|
819
783
|
}
|
|
820
784
|
}
|
|
821
785
|
}
|
|
@@ -837,8 +801,8 @@ class Samples {
|
|
|
837
801
|
} else {
|
|
838
802
|
// Increment index since C API is based on Lua with 1-based indexes
|
|
839
803
|
index += 1
|
|
840
|
-
|
|
841
|
-
const retcode = connectorBinding.
|
|
804
|
+
let value = [null]
|
|
805
|
+
const retcode = connectorBinding.RTI_Connector_get_boolean_from_sample(
|
|
842
806
|
this.input.connector.native,
|
|
843
807
|
value,
|
|
844
808
|
this.input.name,
|
|
@@ -849,7 +813,7 @@ class Samples {
|
|
|
849
813
|
if (retcode === _ReturnCodes.noData) {
|
|
850
814
|
return null
|
|
851
815
|
} else {
|
|
852
|
-
return value
|
|
816
|
+
return value[0]
|
|
853
817
|
}
|
|
854
818
|
}
|
|
855
819
|
}
|
|
@@ -871,8 +835,8 @@ class Samples {
|
|
|
871
835
|
} else {
|
|
872
836
|
// Increment index since C API is based on Lua with 1-based indexes
|
|
873
837
|
index += 1
|
|
874
|
-
|
|
875
|
-
const retcode = connectorBinding.
|
|
838
|
+
let value = [null]
|
|
839
|
+
const retcode = connectorBinding.RTI_Connector_get_string_from_sample(
|
|
876
840
|
this.input.connector.native,
|
|
877
841
|
value,
|
|
878
842
|
this.input.name,
|
|
@@ -882,7 +846,7 @@ class Samples {
|
|
|
882
846
|
if (retcode === _ReturnCodes.noData) {
|
|
883
847
|
return null
|
|
884
848
|
} else {
|
|
885
|
-
return
|
|
849
|
+
return value[0]
|
|
886
850
|
}
|
|
887
851
|
}
|
|
888
852
|
}
|
|
@@ -905,7 +869,7 @@ class Samples {
|
|
|
905
869
|
throw new TypeError('fieldName must be a string')
|
|
906
870
|
} else {
|
|
907
871
|
return _getAnyValue(
|
|
908
|
-
connectorBinding.
|
|
872
|
+
connectorBinding.RTI_Connector_get_any_from_sample,
|
|
909
873
|
this.input.connector.native,
|
|
910
874
|
this.input.name,
|
|
911
875
|
index,
|
|
@@ -930,7 +894,7 @@ class Samples {
|
|
|
930
894
|
} else {
|
|
931
895
|
// Increment index since Lua arrays are 1-indexed
|
|
932
896
|
index += 1
|
|
933
|
-
|
|
897
|
+
let str = [null]
|
|
934
898
|
let retcode = _ReturnCodes.noData
|
|
935
899
|
// memberName is "optional" - if supplied we will get the JSON object for
|
|
936
900
|
// a specific complex member in the sample
|
|
@@ -938,25 +902,25 @@ class Samples {
|
|
|
938
902
|
if (!_isString(memberName)) {
|
|
939
903
|
throw new TypeError('memberName must be a string')
|
|
940
904
|
} else {
|
|
941
|
-
retcode = connectorBinding.
|
|
905
|
+
retcode = connectorBinding.RTI_Connector_get_json_member(
|
|
942
906
|
this.input.connector.native,
|
|
943
907
|
this.input.name,
|
|
944
908
|
index,
|
|
945
909
|
memberName,
|
|
946
|
-
|
|
910
|
+
str)
|
|
947
911
|
}
|
|
948
912
|
} else {
|
|
949
|
-
retcode = connectorBinding.
|
|
913
|
+
retcode = connectorBinding.RTI_Connector_get_json_sample(
|
|
950
914
|
this.input.connector.native,
|
|
951
915
|
this.input.name,
|
|
952
916
|
index,
|
|
953
|
-
|
|
917
|
+
str)
|
|
954
918
|
}
|
|
955
919
|
_checkRetcode(retcode)
|
|
956
920
|
if (retcode === _ReturnCodes.noData) {
|
|
957
921
|
return null
|
|
958
922
|
}
|
|
959
|
-
return JSON.parse(
|
|
923
|
+
return JSON.parse(str[0])
|
|
960
924
|
}
|
|
961
925
|
}
|
|
962
926
|
|
|
@@ -965,8 +929,8 @@ class Samples {
|
|
|
965
929
|
* additional *Connext DDS* APIs in C.
|
|
966
930
|
*
|
|
967
931
|
* @param {number} index The index of the sample for which to obtain
|
|
968
|
-
* the native
|
|
969
|
-
* @returns {
|
|
932
|
+
* the native RTI_HANDLE.
|
|
933
|
+
* @returns {RTI_HANDLE} A native RTI_HANDLE to the sample.
|
|
970
934
|
*/
|
|
971
935
|
getNative (index) {
|
|
972
936
|
if (!_isValidIndex(index)) {
|
|
@@ -974,7 +938,7 @@ class Samples {
|
|
|
974
938
|
} else {
|
|
975
939
|
// Increment index since Lua arrays are 1-indexed
|
|
976
940
|
index += 1
|
|
977
|
-
return connectorBinding.
|
|
941
|
+
return connectorBinding.RTI_Connector_get_native_sample(
|
|
978
942
|
this.input.connector.native,
|
|
979
943
|
this.input.name,
|
|
980
944
|
index)
|
|
@@ -1035,7 +999,7 @@ class SampleInfo {
|
|
|
1035
999
|
throw new TypeError('fieldName must be a string')
|
|
1036
1000
|
} else {
|
|
1037
1001
|
return _getAnyValue(
|
|
1038
|
-
connectorBinding.
|
|
1002
|
+
connectorBinding.RTI_Connector_get_any_from_info,
|
|
1039
1003
|
this.input.connector.native,
|
|
1040
1004
|
this.input.name,
|
|
1041
1005
|
this.index,
|
|
@@ -1057,7 +1021,7 @@ class Input {
|
|
|
1057
1021
|
* * connector (:class:`Connector`) - The Connector creates this Input.
|
|
1058
1022
|
* * name (string) - The name of the Input (the name used in
|
|
1059
1023
|
* :meth:`Connector.getInput`).
|
|
1060
|
-
* * native (
|
|
1024
|
+
* * native (RTI_HANDLE) - A native handle that allows accessing additional
|
|
1061
1025
|
* *Connext DDS* APIs in C.
|
|
1062
1026
|
* * matchedPublications (JSON) - A JSON object containing information
|
|
1063
1027
|
* about all the publications currently matched with this Input.
|
|
@@ -1065,10 +1029,10 @@ class Input {
|
|
|
1065
1029
|
constructor (connector, name) {
|
|
1066
1030
|
this.connector = connector
|
|
1067
1031
|
this.name = name
|
|
1068
|
-
this.native = connectorBinding.
|
|
1032
|
+
this.native = connectorBinding.RTI_Connector_get_datareader(
|
|
1069
1033
|
this.connector.native,
|
|
1070
1034
|
this.name)
|
|
1071
|
-
if (this.native
|
|
1035
|
+
if (this.native == null) {
|
|
1072
1036
|
throw new Error('Invalid Subscription::DataReader name')
|
|
1073
1037
|
}
|
|
1074
1038
|
// We use the '_' since samples is the name of the property and we want
|
|
@@ -1092,7 +1056,7 @@ class Input {
|
|
|
1092
1056
|
* operation has been called.
|
|
1093
1057
|
*/
|
|
1094
1058
|
read () {
|
|
1095
|
-
_checkRetcode(connectorBinding.
|
|
1059
|
+
_checkRetcode(connectorBinding.RTI_Connector_read(
|
|
1096
1060
|
this.connector.native,
|
|
1097
1061
|
this.name))
|
|
1098
1062
|
}
|
|
@@ -1104,7 +1068,7 @@ class Input {
|
|
|
1104
1068
|
* :meth:`Input.samples`.
|
|
1105
1069
|
*/
|
|
1106
1070
|
take () {
|
|
1107
|
-
_checkRetcode(connectorBinding.
|
|
1071
|
+
_checkRetcode(connectorBinding.RTI_Connector_take(
|
|
1108
1072
|
this.connector.native,
|
|
1109
1073
|
this.name))
|
|
1110
1074
|
}
|
|
@@ -1152,8 +1116,8 @@ class Input {
|
|
|
1152
1116
|
throw new Error('Can not concurrently wait on the same Input')
|
|
1153
1117
|
} else {
|
|
1154
1118
|
this.waitSetBusy = true
|
|
1155
|
-
|
|
1156
|
-
connectorBinding.
|
|
1119
|
+
let currentChangeCount = [null]
|
|
1120
|
+
connectorBinding.RTI_Connector_wait_for_matched_publication.async(
|
|
1157
1121
|
this.native,
|
|
1158
1122
|
timeout,
|
|
1159
1123
|
currentChangeCount,
|
|
@@ -1162,7 +1126,7 @@ class Input {
|
|
|
1162
1126
|
if (err) {
|
|
1163
1127
|
return reject(err)
|
|
1164
1128
|
} else if (res === _ReturnCodes.ok) {
|
|
1165
|
-
return resolve(currentChangeCount
|
|
1129
|
+
return resolve(currentChangeCount[0])
|
|
1166
1130
|
} else if (res === _ReturnCodes.timeout) {
|
|
1167
1131
|
return reject(new TimeoutError('Timeout error'))
|
|
1168
1132
|
} else {
|
|
@@ -1191,12 +1155,23 @@ class Input {
|
|
|
1191
1155
|
* @type {JSON}
|
|
1192
1156
|
*/
|
|
1193
1157
|
get matchedPublications () {
|
|
1194
|
-
|
|
1195
|
-
const retcode = connectorBinding.
|
|
1158
|
+
let str = [null]
|
|
1159
|
+
const retcode = connectorBinding.RTI_Connector_get_matched_publications(
|
|
1196
1160
|
this.native,
|
|
1197
|
-
|
|
1161
|
+
str)
|
|
1198
1162
|
_checkRetcode(retcode)
|
|
1199
|
-
return JSON.parse(
|
|
1163
|
+
return JSON.parse(str[0])
|
|
1164
|
+
}
|
|
1165
|
+
|
|
1166
|
+
/**
|
|
1167
|
+
* Returns any samples held by this Input
|
|
1168
|
+
*
|
|
1169
|
+
* After calling this method, the samples are no longer accessible from :meth:`Input.samples`.
|
|
1170
|
+
*/
|
|
1171
|
+
returnSamples () {
|
|
1172
|
+
_checkRetcode(connectorBinding.RTI_Connector_return_loan(
|
|
1173
|
+
this.connector.native,
|
|
1174
|
+
this.name))
|
|
1200
1175
|
}
|
|
1201
1176
|
|
|
1202
1177
|
/**
|
|
@@ -1205,26 +1180,42 @@ class Input {
|
|
|
1205
1180
|
* .. note::
|
|
1206
1181
|
* This operation is asynchronous.
|
|
1207
1182
|
*
|
|
1208
|
-
*
|
|
1183
|
+
* .. note::
|
|
1184
|
+
* If no object is provided as the first parameter and for backwards compatibility,
|
|
1185
|
+
* the arguments are interpreted sequentially as defined in the documentation.
|
|
1186
|
+
*
|
|
1187
|
+
* @param {Object} [options] Options for the wait operation.
|
|
1188
|
+
* @param {number} [options.timeout] The maximum time to wait, in milliseconds.
|
|
1209
1189
|
* By default, infinite.
|
|
1190
|
+
* @param {boolean} [options.returnSamples] Whether to return samples before waiting.
|
|
1191
|
+
* By default ``True``. Set it to ``False`` for backwards compatibility.
|
|
1210
1192
|
* @throws {TimeoutError} :class:`TimeoutError` will be thrown if the
|
|
1211
1193
|
* timeout expires before data is received.
|
|
1212
1194
|
* @returns {Promise} A ``Promise`` which will be resolved once data is
|
|
1213
1195
|
* available, or rejected if the timeout expires.
|
|
1214
1196
|
*/
|
|
1215
|
-
wait
|
|
1197
|
+
wait({ timeout, returnSamples } = {}) {
|
|
1216
1198
|
return new Promise((resolve, reject) => {
|
|
1217
|
-
|
|
1218
|
-
if (
|
|
1219
|
-
timeout =
|
|
1220
|
-
}
|
|
1199
|
+
/* if the first parameter was not an object, parse it */
|
|
1200
|
+
if (!_isObject(arguments[0])) {
|
|
1201
|
+
[ timeout, returnSamples ] = arguments
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
/* Assign defaults */
|
|
1205
|
+
timeout ??= -1
|
|
1206
|
+
returnSamples ??= true
|
|
1207
|
+
|
|
1208
|
+
if (!_isNumber(timeout)) {
|
|
1221
1209
|
throw new TypeError('timeout must be a number')
|
|
1222
1210
|
}
|
|
1223
1211
|
if (this.waitSetBusy) {
|
|
1224
1212
|
throw new Error('Can not concurrently wait on the same Input')
|
|
1225
1213
|
} else {
|
|
1226
1214
|
this.waitSetBusy = true
|
|
1227
|
-
|
|
1215
|
+
if (returnSamples) {
|
|
1216
|
+
this.returnSamples()
|
|
1217
|
+
}
|
|
1218
|
+
connectorBinding.RTI_Connector_wait_for_data_on_reader.async(
|
|
1228
1219
|
this.native,
|
|
1229
1220
|
timeout,
|
|
1230
1221
|
(err, res) => {
|
|
@@ -1258,7 +1249,7 @@ class Instance {
|
|
|
1258
1249
|
* Attributes:
|
|
1259
1250
|
* * ``output`` (:class:`Output`) - The :class:`Output` that owns
|
|
1260
1251
|
* this Instance.
|
|
1261
|
-
* * ``native`` (
|
|
1252
|
+
* * ``native`` (RTI_HANDLE) - Native handle to this Instance that allows
|
|
1262
1253
|
* for additional *Connext DDS Pro* C APIs to be called.
|
|
1263
1254
|
*/
|
|
1264
1255
|
constructor (output) {
|
|
@@ -1277,7 +1268,7 @@ class Instance {
|
|
|
1277
1268
|
if (!_isString(fieldName)) {
|
|
1278
1269
|
throw new TypeError('fieldName must be a string')
|
|
1279
1270
|
} else {
|
|
1280
|
-
const retcode = connectorBinding.
|
|
1271
|
+
const retcode = connectorBinding.RTI_Connector_clear_member(
|
|
1281
1272
|
this.output.connector.native,
|
|
1282
1273
|
this.output.name,
|
|
1283
1274
|
fieldName)
|
|
@@ -1307,7 +1298,7 @@ class Instance {
|
|
|
1307
1298
|
throw new TypeError('value must be a number')
|
|
1308
1299
|
}
|
|
1309
1300
|
} else {
|
|
1310
|
-
_checkRetcode(connectorBinding.
|
|
1301
|
+
_checkRetcode(connectorBinding.RTI_Connector_set_number_into_samples(
|
|
1311
1302
|
this.output.connector.native,
|
|
1312
1303
|
this.output.name,
|
|
1313
1304
|
fieldName,
|
|
@@ -1332,7 +1323,7 @@ class Instance {
|
|
|
1332
1323
|
throw new TypeError('value must be a boolean')
|
|
1333
1324
|
}
|
|
1334
1325
|
} else {
|
|
1335
|
-
const retcode = connectorBinding.
|
|
1326
|
+
const retcode = connectorBinding.RTI_Connector_set_boolean_into_samples(
|
|
1336
1327
|
this.output.connector.native,
|
|
1337
1328
|
this.output.name,
|
|
1338
1329
|
fieldName,
|
|
@@ -1358,7 +1349,7 @@ class Instance {
|
|
|
1358
1349
|
throw new TypeError('value must be a boolean')
|
|
1359
1350
|
}
|
|
1360
1351
|
} else {
|
|
1361
|
-
const retcode = connectorBinding.
|
|
1352
|
+
const retcode = connectorBinding.RTI_Connector_set_string_into_samples(
|
|
1362
1353
|
this.output.connector.native,
|
|
1363
1354
|
this.output.name,
|
|
1364
1355
|
fieldName,
|
|
@@ -1387,7 +1378,7 @@ class Instance {
|
|
|
1387
1378
|
* (field names) and values (values for the fields).
|
|
1388
1379
|
*/
|
|
1389
1380
|
setFromJson (jsonObj) {
|
|
1390
|
-
_checkRetcode(connectorBinding.
|
|
1381
|
+
_checkRetcode(connectorBinding.RTI_Connector_set_json_instance(
|
|
1391
1382
|
this.output.connector.native,
|
|
1392
1383
|
this.output.name,
|
|
1393
1384
|
JSON.stringify(jsonObj)))
|
|
@@ -1442,14 +1433,13 @@ class Instance {
|
|
|
1442
1433
|
* @returns {JSON} The value of this instance as a JSON object.
|
|
1443
1434
|
*/
|
|
1444
1435
|
getJson () {
|
|
1445
|
-
const
|
|
1436
|
+
const result = connectorBinding.RTIDDSConnector_getJSONInstance(
|
|
1446
1437
|
this.output.connector.native,
|
|
1447
1438
|
this.output.name)
|
|
1448
|
-
|
|
1449
|
-
if (nativeStr === null) {
|
|
1439
|
+
if (result === null) {
|
|
1450
1440
|
throw new Error('Failed to create JSON object of instance')
|
|
1451
1441
|
} else {
|
|
1452
|
-
return JSON.parse(
|
|
1442
|
+
return JSON.parse(result)
|
|
1453
1443
|
}
|
|
1454
1444
|
}
|
|
1455
1445
|
|
|
@@ -1467,16 +1457,16 @@ class Instance {
|
|
|
1467
1457
|
* The native C object.
|
|
1468
1458
|
*
|
|
1469
1459
|
* This property allows accessing additional *Connext DDS* APIs in C.
|
|
1470
|
-
* @type {
|
|
1460
|
+
* @type {RTI_HANDLE}
|
|
1471
1461
|
*/
|
|
1472
1462
|
get native () {
|
|
1473
|
-
|
|
1474
|
-
const retcode = connectorBinding.
|
|
1463
|
+
let nativePointer = [null]
|
|
1464
|
+
const retcode = connectorBinding.RTI_Connector_get_native_instance(
|
|
1475
1465
|
this.output.connector.native,
|
|
1476
1466
|
this.output.name,
|
|
1477
1467
|
nativePointer)
|
|
1478
1468
|
_checkRetcode(retcode)
|
|
1479
|
-
return nativePointer
|
|
1469
|
+
return nativePointer[0]
|
|
1480
1470
|
}
|
|
1481
1471
|
}
|
|
1482
1472
|
|
|
@@ -1496,7 +1486,7 @@ class Output {
|
|
|
1496
1486
|
* that created this object.
|
|
1497
1487
|
* * ``name`` (str) - The name of this Output (the name used in
|
|
1498
1488
|
* :meth:`Connector.getOutput`).
|
|
1499
|
-
* * ``native`` (
|
|
1489
|
+
* * ``native`` (RTI_HANDLE) - The native handle that allows accessing
|
|
1500
1490
|
* additional *Connext DDS* APIs in C.
|
|
1501
1491
|
* * ``matchedSubscriptions`` (JSON) - Information about matched
|
|
1502
1492
|
* subscriptions (see below).
|
|
@@ -1505,10 +1495,10 @@ class Output {
|
|
|
1505
1495
|
constructor (connector, name) {
|
|
1506
1496
|
this.connector = connector
|
|
1507
1497
|
this.name = name
|
|
1508
|
-
this.native = connectorBinding.
|
|
1498
|
+
this.native = connectorBinding.RTI_Connector_get_datawriter(
|
|
1509
1499
|
this.connector.native,
|
|
1510
1500
|
this.name)
|
|
1511
|
-
if (this.native
|
|
1501
|
+
if (this.native == null) {
|
|
1512
1502
|
throw new Error('Invalid Publisher::DataWriter name')
|
|
1513
1503
|
}
|
|
1514
1504
|
this.instance = new Instance(this)
|
|
@@ -1551,16 +1541,16 @@ class Output {
|
|
|
1551
1541
|
* throws :class:`TimeoutError`.
|
|
1552
1542
|
*/
|
|
1553
1543
|
write (params) {
|
|
1554
|
-
let
|
|
1544
|
+
let str
|
|
1555
1545
|
if (params === undefined) {
|
|
1556
|
-
|
|
1546
|
+
str = null
|
|
1557
1547
|
} else {
|
|
1558
|
-
|
|
1548
|
+
str = JSON.stringify(params)
|
|
1559
1549
|
}
|
|
1560
|
-
_checkRetcode(connectorBinding.
|
|
1550
|
+
_checkRetcode(connectorBinding.RTI_Connector_write(
|
|
1561
1551
|
this.connector.native,
|
|
1562
1552
|
this.name,
|
|
1563
|
-
|
|
1553
|
+
str))
|
|
1564
1554
|
}
|
|
1565
1555
|
|
|
1566
1556
|
/**
|
|
@@ -1577,7 +1567,7 @@ class Output {
|
|
|
1577
1567
|
* y = 0
|
|
1578
1568
|
*/
|
|
1579
1569
|
clearMembers () {
|
|
1580
|
-
_checkRetcode(connectorBinding.
|
|
1570
|
+
_checkRetcode(connectorBinding.RTI_Connector_clear(
|
|
1581
1571
|
this.connector.native,
|
|
1582
1572
|
this.name))
|
|
1583
1573
|
}
|
|
@@ -1607,7 +1597,7 @@ class Output {
|
|
|
1607
1597
|
} else if (!_isNumber(timeout)) {
|
|
1608
1598
|
throw new TypeError('timeout must be a number')
|
|
1609
1599
|
}
|
|
1610
|
-
connectorBinding.
|
|
1600
|
+
connectorBinding.RTI_Connector_wait_for_acknowledgments.async(
|
|
1611
1601
|
this.native,
|
|
1612
1602
|
timeout,
|
|
1613
1603
|
(err, res) => {
|
|
@@ -1655,9 +1645,9 @@ class Output {
|
|
|
1655
1645
|
if (this.waitsetBusy) {
|
|
1656
1646
|
throw new Error('Can not concurrently wait on the same Output')
|
|
1657
1647
|
} else {
|
|
1658
|
-
|
|
1648
|
+
let currentChangeCount = [null]
|
|
1659
1649
|
this.waitsetBusy = true
|
|
1660
|
-
connectorBinding.
|
|
1650
|
+
connectorBinding.RTI_Connector_wait_for_matched_subscription.async(
|
|
1661
1651
|
this.native,
|
|
1662
1652
|
timeout,
|
|
1663
1653
|
currentChangeCount,
|
|
@@ -1666,7 +1656,7 @@ class Output {
|
|
|
1666
1656
|
if (err) {
|
|
1667
1657
|
return reject(err)
|
|
1668
1658
|
} else if (res === _ReturnCodes.ok) {
|
|
1669
|
-
return resolve(currentChangeCount
|
|
1659
|
+
return resolve(currentChangeCount[0])
|
|
1670
1660
|
} else if (res === _ReturnCodes.timeout) {
|
|
1671
1661
|
return reject(new TimeoutError('Timeout error'))
|
|
1672
1662
|
} else {
|
|
@@ -1694,12 +1684,12 @@ class Output {
|
|
|
1694
1684
|
* @type {JSON}
|
|
1695
1685
|
*/
|
|
1696
1686
|
get matchedSubscriptions () {
|
|
1697
|
-
|
|
1698
|
-
const retcode = connectorBinding.
|
|
1687
|
+
let str = [null]
|
|
1688
|
+
const retcode = connectorBinding.RTI_Connector_get_matched_subscriptions(
|
|
1699
1689
|
this.native,
|
|
1700
|
-
|
|
1690
|
+
str)
|
|
1701
1691
|
_checkRetcode(retcode)
|
|
1702
|
-
return JSON.parse(
|
|
1692
|
+
return JSON.parse(str[0])
|
|
1703
1693
|
}
|
|
1704
1694
|
|
|
1705
1695
|
/* istanbul ignore next */
|
|
@@ -1753,14 +1743,15 @@ class Connector extends EventEmitter {
|
|
|
1753
1743
|
*/
|
|
1754
1744
|
constructor (configName, url) {
|
|
1755
1745
|
super()
|
|
1756
|
-
const options =
|
|
1757
|
-
|
|
1758
|
-
|
|
1759
|
-
|
|
1746
|
+
const options = {
|
|
1747
|
+
one_based_sequence_indexing: 0,
|
|
1748
|
+
enable_on_data_event: 1
|
|
1749
|
+
};
|
|
1750
|
+
this.native = connectorBinding.RTI_Connector_new(
|
|
1760
1751
|
configName,
|
|
1761
1752
|
url,
|
|
1762
|
-
options
|
|
1763
|
-
if (this.native
|
|
1753
|
+
options)
|
|
1754
|
+
if (this.native == null) {
|
|
1764
1755
|
throw new Error('Invalid participant profile, xml path or xml profile')
|
|
1765
1756
|
}
|
|
1766
1757
|
this.on('newListener', this.newListenerCallBack)
|
|
@@ -1798,7 +1789,7 @@ class Connector extends EventEmitter {
|
|
|
1798
1789
|
// is also used by the waitForCallbackFinalization API, and in that case we
|
|
1799
1790
|
// should not delete anything
|
|
1800
1791
|
if (cleanup) {
|
|
1801
|
-
connectorBinding.
|
|
1792
|
+
connectorBinding.RTI_Connector_delete(this.native)
|
|
1802
1793
|
this.native = null
|
|
1803
1794
|
}
|
|
1804
1795
|
// Call the resolve() callback of the passed promise
|
|
@@ -1965,7 +1956,7 @@ class Connector extends EventEmitter {
|
|
|
1965
1956
|
throw new Error('Can not concurrently wait on the same Connector object')
|
|
1966
1957
|
} else {
|
|
1967
1958
|
this.waitSetBusy = true
|
|
1968
|
-
connectorBinding.
|
|
1959
|
+
connectorBinding.RTI_Connector_wait_for_data.async(
|
|
1969
1960
|
this.native,
|
|
1970
1961
|
timeout,
|
|
1971
1962
|
(err, res) => {
|
|
@@ -2103,17 +2094,17 @@ class Connector extends EventEmitter {
|
|
|
2103
2094
|
// Parse numbers out of string
|
|
2104
2095
|
const versionNumbers = versionString.split('.')
|
|
2105
2096
|
// Now get the build IDs of the native libraries
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
_checkRetcode(connectorBinding.
|
|
2097
|
+
let nativeConnectorVersion = [null]
|
|
2098
|
+
let nativeCoreCVersion = [null]
|
|
2099
|
+
_checkRetcode(connectorBinding.RTI_Connector_get_build_versions(
|
|
2109
2100
|
nativeCoreCVersion,
|
|
2110
2101
|
nativeConnectorVersion))
|
|
2111
2102
|
|
|
2112
2103
|
// Now create the string containing all of the above information
|
|
2113
2104
|
let versionStr = 'RTI Connector for JavaScript, version ' +
|
|
2114
2105
|
versionNumbers[0] + '.' + versionNumbers[1] + '.' + versionNumbers[2] + '\n'
|
|
2115
|
-
versionStr +=
|
|
2116
|
-
versionStr +=
|
|
2106
|
+
versionStr += nativeCoreCVersion[0] + '\n'
|
|
2107
|
+
versionStr += nativeConnectorVersion[0]
|
|
2117
2108
|
return versionStr
|
|
2118
2109
|
}
|
|
2119
2110
|
}
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|
|
Binary file
|