node-opcua-file-transfer 2.113.0 → 2.115.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/dist/client/client_file.js +191 -220
- package/dist/client/client_file.js.map +1 -1
- package/dist/client/read_file.js +31 -44
- package/dist/client/read_file.js.map +1 -1
- package/dist/client/read_max_byte_string_length.js +8 -19
- package/dist/client/read_max_byte_string_length.js.map +1 -1
- package/dist/client/write_file.js +34 -45
- package/dist/client/write_file.js.map +1 -1
- package/dist/server/file_type_helpers.js +262 -292
- package/dist/server/file_type_helpers.js.map +1 -1
- package/package.json +20 -20
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.ClientFile = exports.OpenFileMode = void 0;
|
|
13
4
|
/**
|
|
@@ -36,241 +27,221 @@ class ClientFile {
|
|
|
36
27
|
this.session = session;
|
|
37
28
|
this.fileNodeId = nodeId;
|
|
38
29
|
}
|
|
39
|
-
open(mode) {
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
objectId: this.fileNodeId
|
|
52
|
-
});
|
|
53
|
-
if (result.statusCode.isNotGood()) {
|
|
54
|
-
debugLog("Cannot open file : ");
|
|
55
|
-
throw new Error("cannot open file statusCode = " + result.statusCode.toString() + " mode = " + open_mode_1.OpenFileMode[mode]);
|
|
56
|
-
}
|
|
57
|
-
this.fileHandle = result.outputArguments[0].value;
|
|
58
|
-
return this.fileHandle;
|
|
30
|
+
async open(mode) {
|
|
31
|
+
if (mode === null || mode === undefined) {
|
|
32
|
+
throw new Error("expecting a validMode " + open_mode_1.OpenFileMode[mode]);
|
|
33
|
+
}
|
|
34
|
+
if (this.fileHandle) {
|
|
35
|
+
throw new Error("File has already be opened");
|
|
36
|
+
}
|
|
37
|
+
await this.ensureInitialized();
|
|
38
|
+
const result = await this.session.call({
|
|
39
|
+
inputArguments: [{ dataType: node_opcua_variant_1.DataType.Byte, value: mode }],
|
|
40
|
+
methodId: this.openMethodNodeId,
|
|
41
|
+
objectId: this.fileNodeId
|
|
59
42
|
});
|
|
43
|
+
if (result.statusCode.isNotGood()) {
|
|
44
|
+
debugLog("Cannot open file : ");
|
|
45
|
+
throw new Error("cannot open file statusCode = " + result.statusCode.toString() + " mode = " + open_mode_1.OpenFileMode[mode]);
|
|
46
|
+
}
|
|
47
|
+
this.fileHandle = result.outputArguments[0].value;
|
|
48
|
+
return this.fileHandle;
|
|
60
49
|
}
|
|
61
|
-
close() {
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
objectId: this.fileNodeId
|
|
71
|
-
});
|
|
72
|
-
if (result.statusCode.isNotGood()) {
|
|
73
|
-
debugLog("Cannot close file : ");
|
|
74
|
-
throw new Error("cannot close file statusCode = " + result.statusCode.toString());
|
|
75
|
-
}
|
|
76
|
-
this.fileHandle = 0;
|
|
50
|
+
async close() {
|
|
51
|
+
if (!this.fileHandle) {
|
|
52
|
+
throw new Error("File has not been opened yet");
|
|
53
|
+
}
|
|
54
|
+
await this.ensureInitialized();
|
|
55
|
+
const result = await this.session.call({
|
|
56
|
+
inputArguments: [{ dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle }],
|
|
57
|
+
methodId: this.closeMethodNodeId,
|
|
58
|
+
objectId: this.fileNodeId
|
|
77
59
|
});
|
|
60
|
+
if (result.statusCode.isNotGood()) {
|
|
61
|
+
debugLog("Cannot close file : ");
|
|
62
|
+
throw new Error("cannot close file statusCode = " + result.statusCode.toString());
|
|
63
|
+
}
|
|
64
|
+
this.fileHandle = 0;
|
|
78
65
|
}
|
|
79
|
-
getPosition() {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
objectId: this.fileNodeId
|
|
89
|
-
});
|
|
90
|
-
if (result.statusCode.isNotGood()) {
|
|
91
|
-
throw new Error("Error " + result.statusCode.toString());
|
|
92
|
-
}
|
|
93
|
-
return result.outputArguments[0].value;
|
|
66
|
+
async getPosition() {
|
|
67
|
+
await this.ensureInitialized();
|
|
68
|
+
if (!this.fileHandle) {
|
|
69
|
+
throw new Error("File has not been opened yet");
|
|
70
|
+
}
|
|
71
|
+
const result = await this.session.call({
|
|
72
|
+
inputArguments: [{ dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle }],
|
|
73
|
+
methodId: this.getPositionNodeId,
|
|
74
|
+
objectId: this.fileNodeId
|
|
94
75
|
});
|
|
76
|
+
if (result.statusCode.isNotGood()) {
|
|
77
|
+
throw new Error("Error " + result.statusCode.toString());
|
|
78
|
+
}
|
|
79
|
+
return result.outputArguments[0].value;
|
|
95
80
|
}
|
|
96
|
-
setPosition(position) {
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
objectId: this.fileNodeId
|
|
116
|
-
});
|
|
117
|
-
if (result.statusCode.isNotGood()) {
|
|
118
|
-
throw new Error("Error " + result.statusCode.toString());
|
|
119
|
-
}
|
|
120
|
-
return;
|
|
81
|
+
async setPosition(position) {
|
|
82
|
+
await this.ensureInitialized();
|
|
83
|
+
if (!this.fileHandle) {
|
|
84
|
+
throw new Error("File has not been opened yet");
|
|
85
|
+
}
|
|
86
|
+
if (typeof position === "number") {
|
|
87
|
+
position = [0, position];
|
|
88
|
+
}
|
|
89
|
+
const result = await this.session.call({
|
|
90
|
+
inputArguments: [
|
|
91
|
+
{ dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
|
|
92
|
+
{
|
|
93
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
94
|
+
dataType: node_opcua_variant_1.DataType.UInt64,
|
|
95
|
+
value: position
|
|
96
|
+
}
|
|
97
|
+
],
|
|
98
|
+
methodId: this.setPositionNodeId,
|
|
99
|
+
objectId: this.fileNodeId
|
|
121
100
|
});
|
|
101
|
+
if (result.statusCode.isNotGood()) {
|
|
102
|
+
throw new Error("Error " + result.statusCode.toString());
|
|
103
|
+
}
|
|
104
|
+
return;
|
|
122
105
|
}
|
|
123
|
-
read(bytesToRead) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
objectId: this.fileNodeId
|
|
140
|
-
});
|
|
141
|
-
if (result.statusCode.isNotGood()) {
|
|
142
|
-
throw new Error("Error " + result.statusCode.toString());
|
|
143
|
-
}
|
|
144
|
-
if (!result.outputArguments || result.outputArguments[0].dataType !== node_opcua_variant_1.DataType.ByteString) {
|
|
145
|
-
throw new Error("Error invalid output");
|
|
146
|
-
}
|
|
147
|
-
return result.outputArguments[0].value;
|
|
106
|
+
async read(bytesToRead) {
|
|
107
|
+
await this.ensureInitialized();
|
|
108
|
+
if (!this.fileHandle) {
|
|
109
|
+
throw new Error("File has not been opened yet");
|
|
110
|
+
}
|
|
111
|
+
const result = await this.session.call({
|
|
112
|
+
inputArguments: [
|
|
113
|
+
{ dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
|
|
114
|
+
{
|
|
115
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
116
|
+
dataType: node_opcua_variant_1.DataType.Int32,
|
|
117
|
+
value: (0, node_opcua_basic_types_1.coerceInt32)(bytesToRead)
|
|
118
|
+
}
|
|
119
|
+
],
|
|
120
|
+
methodId: this.readNodeId,
|
|
121
|
+
objectId: this.fileNodeId
|
|
148
122
|
});
|
|
123
|
+
if (result.statusCode.isNotGood()) {
|
|
124
|
+
throw new Error("Error " + result.statusCode.toString());
|
|
125
|
+
}
|
|
126
|
+
if (!result.outputArguments || result.outputArguments[0].dataType !== node_opcua_variant_1.DataType.ByteString) {
|
|
127
|
+
throw new Error("Error invalid output");
|
|
128
|
+
}
|
|
129
|
+
return result.outputArguments[0].value;
|
|
149
130
|
}
|
|
150
|
-
write(data) {
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
objectId: this.fileNodeId
|
|
167
|
-
});
|
|
168
|
-
if (result.statusCode.isNotGood()) {
|
|
169
|
-
throw new Error("Error " + result.statusCode.toString());
|
|
170
|
-
}
|
|
171
|
-
return;
|
|
131
|
+
async write(data) {
|
|
132
|
+
await this.ensureInitialized();
|
|
133
|
+
if (!this.fileHandle) {
|
|
134
|
+
throw new Error("File has not been opened yet");
|
|
135
|
+
}
|
|
136
|
+
const result = await this.session.call({
|
|
137
|
+
inputArguments: [
|
|
138
|
+
{ dataType: node_opcua_variant_1.DataType.UInt32, value: this.fileHandle },
|
|
139
|
+
{
|
|
140
|
+
arrayType: node_opcua_variant_1.VariantArrayType.Scalar,
|
|
141
|
+
dataType: node_opcua_variant_1.DataType.ByteString,
|
|
142
|
+
value: data
|
|
143
|
+
}
|
|
144
|
+
],
|
|
145
|
+
methodId: this.writeNodeId,
|
|
146
|
+
objectId: this.fileNodeId
|
|
172
147
|
});
|
|
148
|
+
if (result.statusCode.isNotGood()) {
|
|
149
|
+
throw new Error("Error " + result.statusCode.toString());
|
|
150
|
+
}
|
|
151
|
+
return;
|
|
173
152
|
}
|
|
174
|
-
openCount() {
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
return dataValue.value.value;
|
|
184
|
-
});
|
|
153
|
+
async openCount() {
|
|
154
|
+
await this.ensureInitialized();
|
|
155
|
+
const nodeToRead = { nodeId: this.openCountNodeId, attributeId: node_opcua_data_model_1.AttributeIds.Value };
|
|
156
|
+
const dataValue = await this.session.read(nodeToRead);
|
|
157
|
+
// istanbul ignore next
|
|
158
|
+
if (doDebug) {
|
|
159
|
+
debugLog(" OpenCount ", nodeToRead.nodeId.toString(), dataValue.toString());
|
|
160
|
+
}
|
|
161
|
+
return dataValue.value.value;
|
|
185
162
|
}
|
|
186
|
-
size() {
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
return dataValue.value.value;
|
|
192
|
-
});
|
|
163
|
+
async size() {
|
|
164
|
+
await this.ensureInitialized();
|
|
165
|
+
const nodeToRead = { nodeId: this.sizeNodeId, attributeId: node_opcua_data_model_1.AttributeIds.Value };
|
|
166
|
+
const dataValue = await this.session.read(nodeToRead);
|
|
167
|
+
return dataValue.value.value;
|
|
193
168
|
}
|
|
194
169
|
// eslint-disable-next-line max-statements
|
|
195
|
-
extractMethodsIds() {
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
this.readNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Read);
|
|
205
|
-
const browsePaths = [
|
|
206
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/OpenCount"),
|
|
207
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Size")
|
|
208
|
-
];
|
|
209
|
-
const results = yield this.session.translateBrowsePath(browsePaths);
|
|
210
|
-
if (results[0].statusCode.isNotGood()) {
|
|
211
|
-
throw new Error("fileType object does not expose mandatory OpenCount Property");
|
|
212
|
-
}
|
|
213
|
-
if (results[1].statusCode.isNotGood()) {
|
|
214
|
-
throw new Error("fileType object does not expose mandatory Size Property");
|
|
215
|
-
}
|
|
216
|
-
this.openCountNodeId = results[0].targets[0].targetId;
|
|
217
|
-
this.sizeNodeId = results[1].targets[0].targetId;
|
|
218
|
-
return;
|
|
219
|
-
}
|
|
170
|
+
async extractMethodsIds() {
|
|
171
|
+
if (ClientFile.useGlobalMethod) {
|
|
172
|
+
debugLog("Using GlobalMethodId");
|
|
173
|
+
this.openMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Open);
|
|
174
|
+
this.closeMethodNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Close);
|
|
175
|
+
this.setPositionNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_SetPosition);
|
|
176
|
+
this.getPositionNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_GetPosition);
|
|
177
|
+
this.writeNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Write);
|
|
178
|
+
this.readNodeId = (0, node_opcua_nodeid_1.resolveNodeId)(node_opcua_constants_1.MethodIds.FileType_Read);
|
|
220
179
|
const browsePaths = [
|
|
221
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Open"),
|
|
222
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Close"),
|
|
223
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/SetPosition"),
|
|
224
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/GetPosition"),
|
|
225
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Write"),
|
|
226
|
-
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Read"),
|
|
227
180
|
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/OpenCount"),
|
|
228
181
|
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Size")
|
|
229
182
|
];
|
|
230
|
-
const results =
|
|
183
|
+
const results = await this.session.translateBrowsePath(browsePaths);
|
|
231
184
|
if (results[0].statusCode.isNotGood()) {
|
|
232
|
-
throw new Error("fileType object does not expose mandatory
|
|
185
|
+
throw new Error("fileType object does not expose mandatory OpenCount Property");
|
|
233
186
|
}
|
|
234
187
|
if (results[1].statusCode.isNotGood()) {
|
|
235
|
-
throw new Error("fileType object does not expose mandatory
|
|
236
|
-
}
|
|
237
|
-
if (results[2].statusCode.isNotGood()) {
|
|
238
|
-
throw new Error("fileType object does not expose mandatory SetPosition Method");
|
|
239
|
-
}
|
|
240
|
-
if (results[3].statusCode.isNotGood()) {
|
|
241
|
-
throw new Error("fileType object does not expose mandatory GetPosition Method");
|
|
188
|
+
throw new Error("fileType object does not expose mandatory Size Property");
|
|
242
189
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
}
|
|
190
|
+
this.openCountNodeId = results[0].targets[0].targetId;
|
|
191
|
+
this.sizeNodeId = results[1].targets[0].targetId;
|
|
192
|
+
return;
|
|
193
|
+
}
|
|
194
|
+
const browsePaths = [
|
|
195
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Open"),
|
|
196
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Close"),
|
|
197
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/SetPosition"),
|
|
198
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/GetPosition"),
|
|
199
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Write"),
|
|
200
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Read"),
|
|
201
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/OpenCount"),
|
|
202
|
+
(0, node_opcua_service_translate_browse_path_1.makeBrowsePath)(this.fileNodeId, "/Size")
|
|
203
|
+
];
|
|
204
|
+
const results = await this.session.translateBrowsePath(browsePaths);
|
|
205
|
+
if (results[0].statusCode.isNotGood()) {
|
|
206
|
+
throw new Error("fileType object does not expose mandatory Open Method");
|
|
207
|
+
}
|
|
208
|
+
if (results[1].statusCode.isNotGood()) {
|
|
209
|
+
throw new Error("fileType object does not expose mandatory Close Method");
|
|
210
|
+
}
|
|
211
|
+
if (results[2].statusCode.isNotGood()) {
|
|
212
|
+
throw new Error("fileType object does not expose mandatory SetPosition Method");
|
|
213
|
+
}
|
|
214
|
+
if (results[3].statusCode.isNotGood()) {
|
|
215
|
+
throw new Error("fileType object does not expose mandatory GetPosition Method");
|
|
216
|
+
}
|
|
217
|
+
if (results[4].statusCode.isNotGood()) {
|
|
218
|
+
throw new Error("fileType object does not expose mandatory Write Method");
|
|
219
|
+
}
|
|
220
|
+
if (results[5].statusCode.isNotGood()) {
|
|
221
|
+
throw new Error("fileType object does not expose mandatory Read Method");
|
|
222
|
+
}
|
|
223
|
+
if (results[6].statusCode.isNotGood()) {
|
|
224
|
+
throw new Error("fileType object does not expose mandatory OpenCount Variable");
|
|
225
|
+
}
|
|
226
|
+
if (results[7].statusCode.isNotGood()) {
|
|
227
|
+
throw new Error("fileType object does not expose mandatory Size Variable");
|
|
228
|
+
}
|
|
229
|
+
if (false && doDebug) {
|
|
230
|
+
results.map((x) => debugLog(x.toString()));
|
|
231
|
+
}
|
|
232
|
+
this.openMethodNodeId = results[0].targets[0].targetId;
|
|
233
|
+
this.closeMethodNodeId = results[1].targets[0].targetId;
|
|
234
|
+
this.setPositionNodeId = results[2].targets[0].targetId;
|
|
235
|
+
this.getPositionNodeId = results[3].targets[0].targetId;
|
|
236
|
+
this.writeNodeId = results[4].targets[0].targetId;
|
|
237
|
+
this.readNodeId = results[5].targets[0].targetId;
|
|
238
|
+
this.openCountNodeId = results[6].targets[0].targetId;
|
|
239
|
+
this.sizeNodeId = results[7].targets[0].targetId;
|
|
267
240
|
}
|
|
268
|
-
ensureInitialized() {
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
}
|
|
273
|
-
});
|
|
241
|
+
async ensureInitialized() {
|
|
242
|
+
if (!this.openMethodNodeId) {
|
|
243
|
+
await this.extractMethodsIds();
|
|
244
|
+
}
|
|
274
245
|
}
|
|
275
246
|
}
|
|
276
247
|
exports.ClientFile = ClientFile;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"client_file.js","sourceRoot":"","sources":["../../source/client/client_file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"client_file.js","sourceRoot":"","sources":["../../source/client/client_file.ts"],"names":[],"mappings":";;;AAAA;;GAEG;AACH,mEAAiG;AACjG,iEAAqD;AACrD,yDAA0D;AAG1D,uGAAsF;AACtF,2DAAgE;AAChE,+DAAiD;AAEjD,uDAAgF;AAEhF,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,QAAQ,GAAG,IAAA,gCAAa,EAAC,UAAU,CAAC,CAAC;AAC3C,MAAM,OAAO,GAAG,IAAA,iCAAc,EAAC,UAAU,CAAC,CAAC;AAE3C,4CAA4C;AAC5C,0CAA4C;AAAnC,yGAAA,YAAY,OAAA;AA4BrB;;;GAGG;AACH,MAAa,UAAU;IAgBnB,YAAY,OAAsB,EAAE,MAAc;QAb3C,eAAU,GAAG,CAAC,CAAC;QAclB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,UAAU,GAAG,MAAM,CAAC;IAC7B,CAAC;IAEM,KAAK,CAAC,IAAI,CAAC,IAAkB;QAChC,IAAI,IAAI,KAAK,IAAI,IAAI,IAAI,KAAK,SAAS,EAAE;YACrC,MAAM,IAAI,KAAK,CAAC,wBAAwB,GAAG,wBAAY,CAAC,IAAI,CAAC,CAAC,CAAC;SAClE;QACD,IAAI,IAAI,CAAC,UAAU,EAAE;YACjB,MAAM,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC;SACjD;QACD,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;QAE/B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC;YACnC,cAAc,EAAE,CAAC,EAAE,QAAQ,EAAE,6BAAQ,CAAC,IAAI,EAAE,KAAK,EAAE,IAAY,EAAE,CAAC;YAClE,QAAQ,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AAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACzD,IAAI,CAAC,iBAAiB,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACzD,IAAI,CAAC,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACnD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QAClD,IAAI,CAAC,eAAe,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;QACvD,IAAI,CAAC,UAAU,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC,OAAQ,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC;IACtD,CAAC;IAES,KAAK,CAAC,iBAAiB;QAC7B,IAAI,CAAC,IAAI,CAAC,gBAAgB,EAAE;YACxB,MAAM,IAAI,CAAC,iBAAiB,EAAE,CAAC;SAClC;IACL,CAAC;;AA/PL,gCAgQC;AA/PiB,0BAAe,GAAG,KAAK,AAAR,CAAS;AAoQ1C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG"}
|
package/dist/client/read_file.js
CHANGED
|
@@ -1,13 +1,4 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
3
|
exports.readOPCUAFile = exports.readFile = void 0;
|
|
13
4
|
const node_opcua_basic_types_1 = require("node-opcua-basic-types");
|
|
@@ -16,45 +7,41 @@ const read_max_byte_string_length_1 = require("./read_max_byte_string_length");
|
|
|
16
7
|
function getTransportMaxMessageSize(session) {
|
|
17
8
|
return session.getTransportSettings ? session.getTransportSettings().maxMessageSize : 0;
|
|
18
9
|
}
|
|
19
|
-
function readFile(clientFile, options) {
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
return data;
|
|
35
|
-
}
|
|
36
|
-
// wee need to loop to complete the read
|
|
37
|
-
const chunks = [data];
|
|
38
|
-
let remaining = fileSize - data.length;
|
|
39
|
-
while (remaining > 0) {
|
|
40
|
-
const buf = yield clientFile.read(Math.min(remaining, maxBlockSize));
|
|
41
|
-
if (buf.length === 0)
|
|
42
|
-
break;
|
|
43
|
-
chunks.push(buf);
|
|
44
|
-
remaining -= buf.length;
|
|
45
|
-
}
|
|
46
|
-
return Buffer.concat(chunks);
|
|
10
|
+
async function readFile(clientFile, options) {
|
|
11
|
+
options = options || { chunkSize: await (0, read_max_byte_string_length_1.readMaxByteStringLength)(clientFile.session) };
|
|
12
|
+
let maxBlockSize = options.chunkSize || 1024;
|
|
13
|
+
const transportMaxSize = getTransportMaxMessageSize(clientFile.session);
|
|
14
|
+
maxBlockSize = transportMaxSize > 0 ? Math.min(maxBlockSize, transportMaxSize) : maxBlockSize;
|
|
15
|
+
await clientFile.open(client_file_1.OpenFileMode.Read);
|
|
16
|
+
try {
|
|
17
|
+
const fileSize = (0, node_opcua_basic_types_1.coerceInt32)(await clientFile.size());
|
|
18
|
+
/**
|
|
19
|
+
* Read file
|
|
20
|
+
*/
|
|
21
|
+
const data = await clientFile.read(Math.min(fileSize, maxBlockSize));
|
|
22
|
+
if (data.length >= fileSize) {
|
|
23
|
+
// everything has been read
|
|
24
|
+
return data;
|
|
47
25
|
}
|
|
48
|
-
|
|
49
|
-
|
|
26
|
+
// wee need to loop to complete the read
|
|
27
|
+
const chunks = [data];
|
|
28
|
+
let remaining = fileSize - data.length;
|
|
29
|
+
while (remaining > 0) {
|
|
30
|
+
const buf = await clientFile.read(Math.min(remaining, maxBlockSize));
|
|
31
|
+
if (buf.length === 0)
|
|
32
|
+
break;
|
|
33
|
+
chunks.push(buf);
|
|
34
|
+
remaining -= buf.length;
|
|
50
35
|
}
|
|
51
|
-
|
|
36
|
+
return Buffer.concat(chunks);
|
|
37
|
+
}
|
|
38
|
+
finally {
|
|
39
|
+
await clientFile.close();
|
|
40
|
+
}
|
|
52
41
|
}
|
|
53
42
|
exports.readFile = readFile;
|
|
54
|
-
function readOPCUAFile(clientFile) {
|
|
55
|
-
return
|
|
56
|
-
return yield readFile(clientFile);
|
|
57
|
-
});
|
|
43
|
+
async function readOPCUAFile(clientFile) {
|
|
44
|
+
return await readFile(clientFile);
|
|
58
45
|
}
|
|
59
46
|
exports.readOPCUAFile = readOPCUAFile;
|
|
60
47
|
//# sourceMappingURL=read_file.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"read_file.js","sourceRoot":"","sources":["../../source/client/read_file.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"read_file.js","sourceRoot":"","sources":["../../source/client/read_file.ts"],"names":[],"mappings":";;;AAAA,mEAAqD;AAErD,+CAA0D;AAC1D,+EAAwE;AAExE,SAAS,0BAA0B,CAAC,OAAsB;IACtD,OAAO,OAAO,CAAC,oBAAoB,CAAC,CAAC,C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