node-opcua-file-transfer 2.63.2 → 2.64.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/package.json +58 -57
- package/readme.md +2 -2
package/package.json
CHANGED
|
@@ -1,58 +1,59 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
"
|
|
12
|
-
"
|
|
13
|
-
"
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
"
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
"
|
|
44
|
-
"
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
"
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
"
|
|
57
|
-
|
|
58
|
-
}
|
|
2
|
+
"name": "node-opcua-file-transfer",
|
|
3
|
+
"version": "2.64.0",
|
|
4
|
+
"description": "pure nodejs OPCUA SDK - module -server",
|
|
5
|
+
"main": "./dist/index.js",
|
|
6
|
+
"types": "./dist/index.d.ts",
|
|
7
|
+
"dependencies": {
|
|
8
|
+
"node-opcua-address-space": "2.64.0",
|
|
9
|
+
"node-opcua-assert": "2.64.0",
|
|
10
|
+
"node-opcua-basic-types": "2.64.0",
|
|
11
|
+
"node-opcua-client": "2.64.0",
|
|
12
|
+
"node-opcua-constants": "2.64.0",
|
|
13
|
+
"node-opcua-data-model": "2.64.0",
|
|
14
|
+
"node-opcua-debug": "2.64.0",
|
|
15
|
+
"node-opcua-nodeid": "2.64.0",
|
|
16
|
+
"node-opcua-nodesets": "2.64.0",
|
|
17
|
+
"node-opcua-pki": "^2.13.0",
|
|
18
|
+
"node-opcua-pseudo-session": "2.64.0",
|
|
19
|
+
"node-opcua-secure-channel": "2.64.0",
|
|
20
|
+
"node-opcua-server": "2.64.0",
|
|
21
|
+
"node-opcua-service-call": "2.64.0",
|
|
22
|
+
"node-opcua-service-read": "2.64.0",
|
|
23
|
+
"node-opcua-service-translate-browse-path": "2.64.0",
|
|
24
|
+
"node-opcua-status-code": "2.64.0",
|
|
25
|
+
"node-opcua-types": "2.64.0",
|
|
26
|
+
"node-opcua-variant": "2.64.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"memfs": "^3.4.1",
|
|
30
|
+
"node-opcua-binary-stream": "2.64.0",
|
|
31
|
+
"node-opcua-data-value": "2.64.0",
|
|
32
|
+
"node-opcua-leak-detector": "2.64.0",
|
|
33
|
+
"should": "^13.2.3",
|
|
34
|
+
"sinon": "^13.0.1"
|
|
35
|
+
},
|
|
36
|
+
"author": "Etienne Rossignon",
|
|
37
|
+
"license": "MIT",
|
|
38
|
+
"repository": {
|
|
39
|
+
"type": "git",
|
|
40
|
+
"url": "git://github.com/node-opcua/node-opcua.git"
|
|
41
|
+
},
|
|
42
|
+
"keywords": [
|
|
43
|
+
"OPCUA",
|
|
44
|
+
"opcua",
|
|
45
|
+
"m2m",
|
|
46
|
+
"iot",
|
|
47
|
+
"opc ua",
|
|
48
|
+
"internet of things"
|
|
49
|
+
],
|
|
50
|
+
"homepage": "http://node-opcua.github.io/",
|
|
51
|
+
"gitHead": "07dcdd8e8c7f2b55544c6e23023093e35674829c",
|
|
52
|
+
"scripts": {
|
|
53
|
+
"build": "tsc -b",
|
|
54
|
+
"lint": "eslint source/**/*.ts",
|
|
55
|
+
"clean": "node -e \"require('rimraf').sync('dist');\"",
|
|
56
|
+
"test": "mocha"
|
|
57
|
+
},
|
|
58
|
+
"readme": "## introduction\n\nthis package provides an implementation of the OPCUA File Transfer\nspecification as per OPCUA 1.0.4 part 5 Annex C (page 99)\n \n\n## installation\n\n```bash\n$ npm install node-opcua\n$ npm install node-opcua-file-transfer\n```\n\n## exposing a File node in the addressSpace\n\n```javascript\nimport { OPCUAServer, UAFile } from \"node-opcua\";\nimport { installFileType } from \"node-opcua-file-transfer\";\n\n```\n\n```typescript\n\nconst server = new OPCUAServer({\n\n});\n\nawait server.initialize();\n\n\n// let say we want to create a access to this file:\nconst my_data_filename = \"/data/someFile.txt\";\nawait promisify(fs.writeFile)(my_data_filename, \"some content\", \"utf8\");\n\n\n// now add a file object in the address Space\nconst addressSpace = server.engine.addressSpace;\n\n// retrieve the FileType UAObjectType\nconst fileType = addressSpace.findObjectType(\"FileType\")!;\n\n// create a instance of FileType \nconst myFile = fileType.instantiate({\n nodeId: \"s=MyFile\",\n browseName: \"MyFile\",\n organizedBy: addressSpace.rootFolder.objects\n}) as UAFile;\n\n// now bind the opcuaFile object with our file\ninstallFileType(opcuaFile, { \n filename: my_data_filename\n});\n\n```\n\n\n## accessing a File node from a node-opcua client : ClientFile\n\nWe assume that we have a valid OPCUA Client Session\n\n```javascript\nimport { OPCUAClient } from \"node-opcua\";\nimport { ClientFile } from \"node-opcua-file-transfer\";\n\nconst client = OPCUAClient.create({});\n\nawait client.connect();\nconst session = await client.createSession();\n```\n\nLet's assume that the nodeId of the file object is \"ns=1;s=MyFile\"\n\n```javascript\nimport {ClientFile,OpenFileMode } from \"node-opcua-file-transfer\";\n\n// \nconst fileNodeId = \"ns=1;s=MyFile\";\n\n// let's create a client file object from the session and nodeId\nconst clientFile = new ClientFile(session, fileNodeId);\n\n// let's open the file\nconst mode = OpenFileMode.ReadWriteAppend;\nawait clientFile.open(mode);\n\n// ... do some reading or writing\n\n// don't forget to close the file when done\nawait clientFile.close();\n```\n\n### operations\n\n#### ClientFile#size(): Promise<UInt64> : get file size\n\nYou can read the size of the file at any time.\n``` javascript\nconst clientFile = new ClientFile(session, fileNodeId);\n\nconst size = await clientFile.size();\nconsole.log(\"the current file size is : \",size,\" bytes);\n```\n\n#### ClientFile#open(mode: OpenFileMode) : open a file\n\n```javascript \nconst mode = OpenFileMode.ReadWriteAppend;\nawait clientFile.open(mode);\n```\n\n#### OpenFileMode enumeration\n\n| Mode | Description |\n|------|-------------|\n| Read |The file is opened for reading. the Write method cannot be executed. |\n| Write|The file is opened for writing. the Read cannot be executed. |\n| ReadWrite| The file is opened for reading an writing |\n| WriteEraseExisting | File is opened for writing only. The existing content of the file is erased and an empty file is provided. |\n| ReadWriteEraseExisting | File is opened for reading and writing. The existing content of the file is erased and an empty file is provided.|\n| WriteAppend | File is opened for writing only and position is set at the end of the file |\n| ReadWriteAppend | File is opened for reading and writing and position is set at the end of the file |\n}\n#### ClientFile#close() : close a file\n\n```javascript \nconst mode = OpenFileMode.ReadWriteAppend;\nawait clientFile.open(mode);\n\n// ... do some reading or writing\n\n// don't forget to close the file when done\nawait clientFile.close();\n```\n#### ClientFile#setPosition(pos: UInt64) : Setting read/write position\n\nOnce the file is opened, the position for reading or writing can be set\nusing setPosition. \n* setPosition expect a UInt64 parameter (see note below)\n* setPosition will throw an exception if file is not opened\n\n``` javascript\nconst clientFile = new ClientFile(session, fileNodeId);\n\nconst mode = OpenFileMode.ReadWriteAppend;\nawait clientFile.open(mode);\n\nawait client.setPosition([0,32]);\n\n```\n\n#### ClientFile#getPosition(): Promise<UInt64> Getting read/write position\nOnce the file is opened, the position for reading or writing can be retrieved\nusing getPosition. \n* getPosition returns a UInt64 parameter (see note below)\n* getPosition will throw an exception if file is not opened\n\n``` javascript\nconst clientFile = new ClientFile(session, fileNodeId);\n\nconst mode = OpenFileMode.ReadWriteAppend;\nawait clientFile.open(mode);\n\nawait client.setPosition(32);\n\n```\n\n#### ClientFile#write(buf: Buffer) : Writing data to the file\n\nData can be writing to the file at the current cursor position.\nData must be passed in a buffer.\n* write will throw an exception if file is not opened\n\n```javascript\nconst dataToWrite = Buffer.from(\"Some data\");\n\nconst mode = OpenFileMode.ReadWriteAppend;\nawait clientFile.open(mode);\nawait clientFile.write(dataToWrite);\n```\n\n\n#### ClientFile#read(): Promise<Buffer> :reading data to the file\n\nData can be writing to the file at the current cursor position.\nData must be passed in a buffer.\n* read will throw an exception if file is not opened\n\n```javascript\n\nconst mode = OpenFileMode.ReadWriteAppend;\nawait clientFile.open(mode);\n\n// read 200 bytes from position 32\nawait clientFile.setPosition([0,32]);\nconst data: Buffer = await clientFile.read(200);\n```\n\n### notes\n\nUInt64\n* At this time BigInt, is not supported by all version of nodeJs that are targeted by node-opcua.\nUInt64 values are currently stored into a array of 2 32bits numbers : [ High,Low]\n\n\n"
|
|
59
|
+
}
|
package/readme.md
CHANGED
|
@@ -14,7 +14,7 @@ $ npm install node-opcua-file-transfer
|
|
|
14
14
|
## exposing a File node in the addressSpace
|
|
15
15
|
|
|
16
16
|
```javascript
|
|
17
|
-
import { OPCUAServer,
|
|
17
|
+
import { OPCUAServer, UAFile } from "node-opcua";
|
|
18
18
|
import { installFileType } from "node-opcua-file-transfer";
|
|
19
19
|
|
|
20
20
|
```
|
|
@@ -44,7 +44,7 @@ const myFile = fileType.instantiate({
|
|
|
44
44
|
nodeId: "s=MyFile",
|
|
45
45
|
browseName: "MyFile",
|
|
46
46
|
organizedBy: addressSpace.rootFolder.objects
|
|
47
|
-
}) as
|
|
47
|
+
}) as UAFile;
|
|
48
48
|
|
|
49
49
|
// now bind the opcuaFile object with our file
|
|
50
50
|
installFileType(opcuaFile, {
|