@things-factory/integration-opc 6.1.120

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.
Files changed (70) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/README.md +0 -0
  3. package/dist-server/engine/connector/index.js +5 -0
  4. package/dist-server/engine/connector/index.js.map +1 -0
  5. package/dist-server/engine/connector/opc-ua-server.js +124 -0
  6. package/dist-server/engine/connector/opc-ua-server.js.map +1 -0
  7. package/dist-server/engine/connector/opc-ua.js +152 -0
  8. package/dist-server/engine/connector/opc-ua.js.map +1 -0
  9. package/dist-server/engine/index.js +5 -0
  10. package/dist-server/engine/index.js.map +1 -0
  11. package/dist-server/engine/task/index.js +7 -0
  12. package/dist-server/engine/task/index.js.map +1 -0
  13. package/dist-server/engine/task/opc-ua-read.js +26 -0
  14. package/dist-server/engine/task/opc-ua-read.js.map +1 -0
  15. package/dist-server/engine/task/opc-ua-start-monitor.js +44 -0
  16. package/dist-server/engine/task/opc-ua-start-monitor.js.map +1 -0
  17. package/dist-server/engine/task/opc-ua-stop-monitor.js +24 -0
  18. package/dist-server/engine/task/opc-ua-stop-monitor.js.map +1 -0
  19. package/dist-server/engine/task/opc-ua-write.js +30 -0
  20. package/dist-server/engine/task/opc-ua-write.js.map +1 -0
  21. package/dist-server/index.js +5 -0
  22. package/dist-server/index.js.map +1 -0
  23. package/dist-server/tsconfig.tsbuildinfo +1 -0
  24. package/helps/integration/connector/opc-ua-server.ja.md +22 -0
  25. package/helps/integration/connector/opc-ua-server.ko.md +22 -0
  26. package/helps/integration/connector/opc-ua-server.md +22 -0
  27. package/helps/integration/connector/opc-ua-server.ms.md +22 -0
  28. package/helps/integration/connector/opc-ua-server.zh.md +22 -0
  29. package/helps/integration/connector/opc-ua.ja.md +41 -0
  30. package/helps/integration/connector/opc-ua.ko.md +41 -0
  31. package/helps/integration/connector/opc-ua.md +41 -0
  32. package/helps/integration/connector/opc-ua.ms.md +43 -0
  33. package/helps/integration/connector/opc-ua.zh.md +41 -0
  34. package/helps/integration/task/opc-ua-read.ja.md +11 -0
  35. package/helps/integration/task/opc-ua-read.ko.md +11 -0
  36. package/helps/integration/task/opc-ua-read.md +11 -0
  37. package/helps/integration/task/opc-ua-read.ms.md +11 -0
  38. package/helps/integration/task/opc-ua-read.zh.md +11 -0
  39. package/helps/integration/task/opc-ua-start-monitor.ja.md +14 -0
  40. package/helps/integration/task/opc-ua-start-monitor.ko.md +14 -0
  41. package/helps/integration/task/opc-ua-start-monitor.md +14 -0
  42. package/helps/integration/task/opc-ua-start-monitor.ms.md +14 -0
  43. package/helps/integration/task/opc-ua-start-monitor.zh.md +14 -0
  44. package/helps/integration/task/opc-ua-stop-monitor.ja.md +12 -0
  45. package/helps/integration/task/opc-ua-stop-monitor.ko.md +12 -0
  46. package/helps/integration/task/opc-ua-stop-monitor.md +12 -0
  47. package/helps/integration/task/opc-ua-stop-monitor.ms.md +12 -0
  48. package/helps/integration/task/opc-ua-stop-monitor.zh.md +12 -0
  49. package/helps/integration/task/opc-ua-write.ja.md +13 -0
  50. package/helps/integration/task/opc-ua-write.ko.md +13 -0
  51. package/helps/integration/task/opc-ua-write.md +13 -0
  52. package/helps/integration/task/opc-ua-write.ms.md +13 -0
  53. package/helps/integration/task/opc-ua-write.zh.md +13 -0
  54. package/package.json +30 -0
  55. package/server/engine/connector/index.ts +2 -0
  56. package/server/engine/connector/opc-ua-server.ts +145 -0
  57. package/server/engine/connector/opc-ua.ts +206 -0
  58. package/server/engine/index.ts +2 -0
  59. package/server/engine/task/index.ts +4 -0
  60. package/server/engine/task/opc-ua-read.ts +33 -0
  61. package/server/engine/task/opc-ua-start-monitor.ts +57 -0
  62. package/server/engine/task/opc-ua-stop-monitor.ts +31 -0
  63. package/server/engine/task/opc-ua-write.ts +38 -0
  64. package/server/index.ts +2 -0
  65. package/things-factory.config.js +1 -0
  66. package/translations/en.json +19 -0
  67. package/translations/ja.json +19 -0
  68. package/translations/ko.json +19 -0
  69. package/translations/ms.json +19 -0
  70. package/translations/zh.json +19 -0
package/CHANGELOG.md ADDED
@@ -0,0 +1,8 @@
1
+ # Changelog
2
+
3
+ All notable changes to this project will be documented in this file.
4
+
5
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
6
+ and adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
7
+
8
+ <!-- ## [Unreleased] -->
package/README.md ADDED
File without changes
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./opc-ua");
4
+ require("./opc-ua-server");
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/connector/index.ts"],"names":[],"mappings":";;AAAA,oBAAiB;AACjB,2BAAwB","sourcesContent":["import './opc-ua'\nimport './opc-ua-server'\n"]}
@@ -0,0 +1,124 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPCUAServerConnector = void 0;
4
+ const node_opcua_1 = require("node-opcua");
5
+ const integration_base_1 = require("@things-factory/integration-base");
6
+ class OPCUAServerConnector {
7
+ async ready(connectionConfigs) {
8
+ await Promise.all(connectionConfigs.map(this.connect));
9
+ integration_base_1.ConnectionManager.logger.info('opc-ua-servers are ready');
10
+ }
11
+ async connect(config) {
12
+ var { name: productName, endpoint: port, // the port of the listening socket of the server
13
+ params: { resourcePath, // this path will be added to the endpoint resource name
14
+ buildNumber, buildDate } } = config;
15
+ const server = new node_opcua_1.OPCUAServer({
16
+ port,
17
+ resourcePath,
18
+ buildInfo: {
19
+ productName,
20
+ buildNumber,
21
+ buildDate: buildDate ? new Date(buildDate) : new Date()
22
+ }
23
+ });
24
+ await server.initialize();
25
+ integration_base_1.ConnectionManager.logger.log('initialized');
26
+ const addressSpace = server.engine.addressSpace;
27
+ const namespace = addressSpace.getOwnNamespace();
28
+ // declare a new object
29
+ const device = namespace.addObject({
30
+ organizedBy: addressSpace.rootFolder.objects,
31
+ browseName: 'MyDevice'
32
+ });
33
+ // add some variables
34
+ // add a variable named MyVariable1 to the newly created folder "MyDevice"
35
+ let variable1 = 1;
36
+ // emulate variable1 changing every 500 ms
37
+ setInterval(() => {
38
+ variable1 += 1;
39
+ }, 500);
40
+ namespace.addVariable({
41
+ componentOf: device,
42
+ browseName: 'MyVariable1',
43
+ dataType: 'Double',
44
+ value: {
45
+ get: () => new node_opcua_1.Variant({ dataType: node_opcua_1.DataType.Double, value: variable1 })
46
+ }
47
+ });
48
+ // add a variable named MyVariable2 to the newly created folder "MyDevice"
49
+ let variable2 = 10.0;
50
+ namespace.addVariable({
51
+ componentOf: device,
52
+ nodeId: 'ns=1;b=1020FFAA',
53
+ browseName: 'MyVariable2',
54
+ dataType: 'Double',
55
+ minimumSamplingInterval: 1234,
56
+ value: {
57
+ get: () => new node_opcua_1.Variant({ dataType: node_opcua_1.DataType.Double, value: variable2 }),
58
+ set: variant => {
59
+ variable2 = parseFloat(variant.value);
60
+ return node_opcua_1.StatusCodes.Good;
61
+ }
62
+ }
63
+ });
64
+ const os = require('os');
65
+ /**
66
+ * returns the percentage of free memory on the running machine
67
+ * @return {double}
68
+ */
69
+ function available_memory() {
70
+ // var value = process.memoryUsage().heapUsed / 1000000;
71
+ const percentageMemUsed = (os.freemem() / os.totalmem()) * 100.0;
72
+ return percentageMemUsed;
73
+ }
74
+ namespace.addVariable({
75
+ componentOf: device,
76
+ nodeId: 's=free_memory',
77
+ browseName: 'FreeMemory',
78
+ dataType: 'Double',
79
+ value: {
80
+ get: () => new node_opcua_1.Variant({ dataType: node_opcua_1.DataType.Double, value: available_memory() })
81
+ }
82
+ });
83
+ server.start(function () {
84
+ integration_base_1.ConnectionManager.logger.log('Server is now listening ... ( press CTRL+C to stop)');
85
+ integration_base_1.ConnectionManager.logger.log('port ', server.endpoints[0].port);
86
+ const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl;
87
+ integration_base_1.ConnectionManager.logger.log(' the primary server endpoint url is ', endpointUrl);
88
+ });
89
+ integration_base_1.ConnectionManager.addConnectionInstance(config, server);
90
+ integration_base_1.ConnectionManager.logger.info(`opc-ua-server connection(${config.name}:${port}) is connected`);
91
+ }
92
+ async disconnect(connection) {
93
+ var server = integration_base_1.ConnectionManager.removeConnectionInstance(connection);
94
+ server && server._server.close();
95
+ integration_base_1.ConnectionManager.logger.info(`opc-ua-server connection(${connection.name}) is disconnected`);
96
+ }
97
+ get parameterSpec() {
98
+ return [
99
+ {
100
+ type: 'number',
101
+ name: 'port',
102
+ label: 'port'
103
+ },
104
+ {
105
+ type: 'string',
106
+ name: 'productName',
107
+ label: 'product-name'
108
+ },
109
+ {
110
+ type: 'string',
111
+ name: 'buildNumber',
112
+ label: 'build-number'
113
+ },
114
+ {
115
+ type: 'string',
116
+ name: 'buildDate',
117
+ label: 'build-date'
118
+ }
119
+ ];
120
+ }
121
+ }
122
+ exports.OPCUAServerConnector = OPCUAServerConnector;
123
+ integration_base_1.ConnectionManager.registerConnector('opc-ua-server', new OPCUAServerConnector());
124
+ //# sourceMappingURL=opc-ua-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opc-ua-server.js","sourceRoot":"","sources":["../../../server/engine/connector/opc-ua-server.ts"],"names":[],"mappings":";;;AAAA,2CAAwE;AACxE,uEAA2F;AAE3F,MAAa,oBAAoB;IAC/B,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,0BAA0B,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAM;QAClB,IAAI,EACF,IAAI,EAAE,WAAW,EACjB,QAAQ,EAAE,IAAI,EAAE,iDAAiD;QACjE,MAAM,EAAE,EACN,YAAY,EAAE,wDAAwD;QACtE,WAAW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C,CAAC,CAAC,CAAC,oBAAoB,EAAE,CAAC,CAAC,CAAC,CAAC,WAAW,CAAA;YAC7E,oCAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,sCAAsC,EAAE,WAAW,CAAC,CAAA;QACnF,CAAC,CAAC,CAAA;QAEF,oCAAiB,CAAC,qBAAqB,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;QAEvD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,MAAM,CAAC,IAAI,IAAI,IAAI,gBAAgB,CAAC,CAAA;IAChG,CAAC;IAED,KAAK,CAAC,UAAU,CAAC,UAAsB;QACrC,IAAI,MAAM,GAAG,oCAAiB,CAAC,wBAAwB,CAAC,UAAU,CAAC,CAAA;QACnE,MAAM,IAAI,MAAM,CAAC,OAAO,CAAC,KAAK,EAAE,CAAA;QAEhC,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,4BAA4B,UAAU,CAAC,IAAI,mBAAmB,CAAC,CAAA;IAC/F,CAAC;IAED,IAAI,aAAa;QACf,OAAO;YACL;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,MAAM;gBACZ,KAAK,EAAE,MAAM;aACd;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,cAAc;aACtB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,aAAa;gBACnB,KAAK,EAAE,cAAc;aACtB;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,WAAW;gBACjB,KAAK,EAAE,YAAY;aACpB;SACF,CAAA;IACH,CAAC;CACF;AA3ID,oDA2IC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,eAAe,EAAE,IAAI,oBAAoB,EAAE,CAAC,CAAA","sourcesContent":["import { StatusCodes, OPCUAServer, Variant, DataType } from 'node-opcua'\nimport { ConnectionManager, Connector, Connection } from '@things-factory/integration-base'\n\nexport class OPCUAServerConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('opc-ua-servers are ready')\n }\n\n async connect(config) {\n var {\n name: productName,\n endpoint: port, // the port of the listening socket of the server\n params: {\n resourcePath, // this path will be added to the endpoint resource name\n buildNumber,\n buildDate\n }\n } = config\n\n const server = new OPCUAServer({\n port,\n resourcePath,\n buildInfo: {\n productName,\n buildNumber,\n buildDate: buildDate ? new Date(buildDate) : new Date()\n }\n })\n\n await server.initialize()\n ConnectionManager.logger.log('initialized')\n\n const addressSpace = server.engine.addressSpace\n const namespace = addressSpace.getOwnNamespace()\n\n // declare a new object\n const device = namespace.addObject({\n organizedBy: addressSpace.rootFolder.objects,\n browseName: 'MyDevice'\n })\n\n // add some variables\n // add a variable named MyVariable1 to the newly created folder \"MyDevice\"\n let variable1 = 1\n\n // emulate variable1 changing every 500 ms\n setInterval(() => {\n variable1 += 1\n }, 500)\n\n namespace.addVariable({\n componentOf: device,\n browseName: 'MyVariable1',\n dataType: 'Double',\n value: {\n get: () => new Variant({ dataType: DataType.Double, value: variable1 })\n }\n })\n\n // add a variable named MyVariable2 to the newly created folder \"MyDevice\"\n let variable2 = 10.0\n\n namespace.addVariable({\n componentOf: device,\n nodeId: 'ns=1;b=1020FFAA', // some opaque NodeId in namespace 4\n browseName: 'MyVariable2',\n dataType: 'Double',\n minimumSamplingInterval: 1234, // we need to specify a minimumSamplingInterval when using a getter\n value: {\n get: () => new Variant({ dataType: DataType.Double, value: variable2 }),\n set: variant => {\n variable2 = parseFloat(variant.value)\n return StatusCodes.Good\n }\n }\n })\n const os = require('os')\n /**\n * returns the percentage of free memory on the running machine\n * @return {double}\n */\n function available_memory() {\n // var value = process.memoryUsage().heapUsed / 1000000;\n const percentageMemUsed = (os.freemem() / os.totalmem()) * 100.0\n return percentageMemUsed\n }\n namespace.addVariable({\n componentOf: device,\n\n nodeId: 's=free_memory', // a string nodeID\n browseName: 'FreeMemory',\n dataType: 'Double',\n value: {\n get: () => new Variant({ dataType: DataType.Double, value: available_memory() })\n }\n })\n\n server.start(function () {\n ConnectionManager.logger.log('Server is now listening ... ( press CTRL+C to stop)')\n ConnectionManager.logger.log('port ', server.endpoints[0].port)\n const endpointUrl = server.endpoints[0].endpointDescriptions()[0].endpointUrl\n ConnectionManager.logger.log(' the primary server endpoint url is ', endpointUrl)\n })\n\n ConnectionManager.addConnectionInstance(config, server)\n\n ConnectionManager.logger.info(`opc-ua-server connection(${config.name}:${port}) is connected`)\n }\n\n async disconnect(connection: Connection) {\n var server = ConnectionManager.removeConnectionInstance(connection)\n server && server._server.close()\n\n ConnectionManager.logger.info(`opc-ua-server connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'number',\n name: 'port',\n label: 'port'\n },\n {\n type: 'string',\n name: 'productName',\n label: 'product-name'\n },\n {\n type: 'string',\n name: 'buildNumber',\n label: 'build-number'\n },\n {\n type: 'string',\n name: 'buildDate',\n label: 'build-date'\n }\n ]\n }\n}\n\nConnectionManager.registerConnector('opc-ua-server', new OPCUAServerConnector())\n"]}
@@ -0,0 +1,152 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.OPCUAConnector = void 0;
4
+ const node_opcua_1 = require("node-opcua");
5
+ const integration_base_1 = require("@things-factory/integration-base");
6
+ class OPCUAConnector {
7
+ async ready(connectionConfigs) {
8
+ await Promise.all(connectionConfigs.map(this.connect));
9
+ integration_base_1.ConnectionManager.logger.info('opc-ua connections are ready');
10
+ }
11
+ async connect(config) {
12
+ var { name, endpoint, params: { maxRetry = 2, initialDelay = 2000, maxDelay = 10 * 1000, requestedPublishingInterval = 1000, requestedLifetimeCount = 100, requestedMaxKeepAliveCount = 20, maxNotificationsPerPublish = 10, publishingEnabled = true, priority = 10 } } = config;
13
+ const client = node_opcua_1.OPCUAClient.create({
14
+ endpoint_must_exist: false,
15
+ connectionStrategy: {
16
+ maxRetry,
17
+ initialDelay,
18
+ maxDelay
19
+ }
20
+ });
21
+ client.on('backoff', () => integration_base_1.ConnectionManager.logger.log('retrying connection'));
22
+ await client.connect(endpoint);
23
+ const session = await client.createSession();
24
+ const browseResult = (await session.browse('RootFolder'));
25
+ integration_base_1.ConnectionManager.logger.log(browseResult.references.map((r) => r.browseName.toString()).join('\n'));
26
+ const subscription = await session.createSubscription2({
27
+ requestedPublishingInterval,
28
+ requestedLifetimeCount,
29
+ requestedMaxKeepAliveCount,
30
+ maxNotificationsPerPublish,
31
+ publishingEnabled,
32
+ priority
33
+ });
34
+ subscription
35
+ .on('started', () => integration_base_1.ConnectionManager.logger.log('subscription started - subscriptionId=', subscription.subscriptionId))
36
+ .on('keepalive', () => integration_base_1.ConnectionManager.logger.log('keepalive'))
37
+ .on('terminated', () => integration_base_1.ConnectionManager.logger.log('subscription terminated'));
38
+ try {
39
+ integration_base_1.ConnectionManager.addConnectionInstance(config, {
40
+ read: async function (node, { logger }) {
41
+ const dataValue = await session.read({ nodeId: node, attributeId: node_opcua_1.AttributeIds.Value });
42
+ if (dataValue.statusCode !== node_opcua_1.StatusCodes.Good) {
43
+ logger.log('Could not read ', node);
44
+ }
45
+ logger.log(` dataValue = ${dataValue.value.toString()}`);
46
+ return dataValue;
47
+ },
48
+ write: async function (node, value, { logger }) {
49
+ const statusCode = await session.write({
50
+ nodeId: node,
51
+ attributeId: node_opcua_1.AttributeIds.Value,
52
+ value: {
53
+ statusCode: node_opcua_1.StatusCodes.Good,
54
+ sourceTimestamp: new Date(),
55
+ value
56
+ }
57
+ });
58
+ logger.log('statusCode = ', statusCode.toString());
59
+ return statusCode;
60
+ },
61
+ startMonitor: async function (node, callback, options, { logger }) {
62
+ const { samplingInterval = 100, discardOldest = true, queueSize = 10 } = options || {};
63
+ const monitoredItem = await subscription.monitor({
64
+ nodeId: node,
65
+ attributeId: node_opcua_1.AttributeIds.Value
66
+ }, {
67
+ samplingInterval,
68
+ discardOldest,
69
+ queueSize
70
+ }, node_opcua_1.TimestampsToReturn.Both);
71
+ monitoredItem.on('changed', callback);
72
+ return monitoredItem;
73
+ },
74
+ stopMonitor: async function (monitoredItem, { logger }) {
75
+ await monitoredItem.terminate();
76
+ },
77
+ close: async function () {
78
+ await (subscription === null || subscription === void 0 ? void 0 : subscription.terminate());
79
+ await (session === null || session === void 0 ? void 0 : session.close());
80
+ await (client === null || client === void 0 ? void 0 : client.disconnect());
81
+ }
82
+ });
83
+ integration_base_1.ConnectionManager.logger.info(`opc-ua connection(${name}:${endpoint}) is connected`);
84
+ }
85
+ catch (error) {
86
+ integration_base_1.ConnectionManager.logger.info(`opc-ua connection(${name}:${endpoint}) failed to connect`);
87
+ }
88
+ }
89
+ async disconnect(connection) {
90
+ var { close } = integration_base_1.ConnectionManager.removeConnectionInstance(connection);
91
+ await close();
92
+ integration_base_1.ConnectionManager.logger.info(`opc-ua connection(${connection.name}) is disconnected`);
93
+ }
94
+ get parameterSpec() {
95
+ return [
96
+ {
97
+ type: 'number',
98
+ name: 'maxRetry',
99
+ label: 'max-retry'
100
+ },
101
+ {
102
+ type: 'number',
103
+ name: 'initialDelay',
104
+ label: 'initial-delay'
105
+ },
106
+ {
107
+ type: 'number',
108
+ name: 'maxDelay',
109
+ label: 'max-delay'
110
+ },
111
+ {
112
+ type: 'number',
113
+ name: 'requestedPublishingInterval',
114
+ label: 'requested-publishing-interval'
115
+ },
116
+ {
117
+ type: 'number',
118
+ name: 'requestedLifetimeCount',
119
+ label: 'requested-lifetime-count'
120
+ },
121
+ {
122
+ type: 'number',
123
+ name: 'requestedMaxKeepAliveCount',
124
+ label: 'requested-max-keep-alive-count'
125
+ },
126
+ {
127
+ type: 'number',
128
+ name: 'maxNotificationsPerPublish',
129
+ label: 'max-notifications-per-publish'
130
+ },
131
+ {
132
+ type: 'boolean',
133
+ name: 'publishingEnabled',
134
+ label: 'publishing-enabled'
135
+ },
136
+ {
137
+ type: 'number',
138
+ name: 'priority',
139
+ label: 'priority'
140
+ }
141
+ ];
142
+ }
143
+ get taskPrefixes() {
144
+ return ['opc-ua'];
145
+ }
146
+ get help() {
147
+ return 'integration/connector/opc-ua';
148
+ }
149
+ }
150
+ exports.OPCUAConnector = OPCUAConnector;
151
+ integration_base_1.ConnectionManager.registerConnector('opc-ua', new OPCUAConnector());
152
+ //# sourceMappingURL=opc-ua.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opc-ua.js","sourceRoot":"","sources":["../../../server/engine/connector/opc-ua.ts"],"names":[],"mappings":";;;AAAA,2CAUmB;AAEnB,uEAA2F;AAE3F,MAAa,cAAc;IACzB,KAAK,CAAC,KAAK,CAAC,iBAAiB;QAC3B,MAAM,OAAO,CAAC,GAAG,CAAC,iBAAiB,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,CAAA;QAEtD,oCAAiB,CAAC,MAAM,CAAC,IAAI,CAAC,8BAA8B,CAAC,CAAA;IAC/D,CAAC;IAED,KAAK,CAAC,OAAO,CAAC,MAAM;QAClB,IAAI,EACF,IAAI,EACJ,QAAQ,EACR,MAAM,EAAE,EACN,QAAQ,GAAG,CAAC,EACZ,YAAY,GAAG,IAAI,EACnB,QAAQ,GAAG,EAAE,GAAG,IAAI,EACpB,2BAA2B,GAAG,IAAI,EAClC,sBAAsB,GAAG,GAAG,EAC5B,0BAA0B,GAAG,EAAE,EAC/B,0BAA0B,GAAG,EAAE,EAC/B,iBAAiB,GAAG,IAAI,EACxB,QAAQ,GAAG,EAAE,EACd,EACF,GAAG,MAAM,CAAA;QAEV,MAAM,MAAM,GAAG,wBAAW,CAAC,MAAM,CAAC;YAChC,mBAAmB,EAAE,KAAK;YAC1B,kBAAkB,EAAE;gBAClB,QAAQ;gBACR,YAAY;gBACZ,QAAQ;aACT;SACF,CAAC,CAAA;QAEF,MAAM,CAAC,EAAE,CAAC,SAAS,EAAE,GAAG,EAAE,CAAC,oCAAiB,CAAC,MAAM,CAAC,GAAG,CAAC,qBAAqB,CAAC,CAAC,CAAA;QAE/E,MAAM,MAAM,CAAC,OAAO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BACd,IAAI,EAAE,wBAAwB;gBAC9B,KAAK,EAAE,0BAA0B;aAClC;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,4BAA4B;gBAClC,KAAK,EAAE,gCAAgC;aACxC;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,4BAA4B;gBAClC,KAAK,EAAE,+BAA+B;aACvC;YACD;gBACE,IAAI,EAAE,SAAS;gBACf,IAAI,EAAE,mBAAmB;gBACzB,KAAK,EAAE,oBAAoB;aAC5B;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,IAAI,EAAE,UAAU;gBAChB,KAAK,EAAE,UAAU;aAClB;SACF,CAAA;IACH,CAAC;IAED,IAAI,YAAY;QACd,OAAO,CAAC,QAAQ,CAAC,CAAA;IACnB,CAAC;IAED,IAAI,IAAI;QACN,OAAO,8BAA8B,CAAA;IACvC,CAAC;CACF;AA7LD,wCA6LC;AAED,oCAAiB,CAAC,iBAAiB,CAAC,QAAQ,EAAE,IAAI,cAAc,EAAE,CAAC,CAAA","sourcesContent":["import {\n OPCUAClient,\n BrowseResult,\n ReferenceDescription,\n AttributeIds,\n StatusCodes,\n TimestampsToReturn,\n DataValue,\n StatusCode,\n ClientMonitoredItem\n} from 'node-opcua'\n\nimport { Connection, ConnectionManager, Connector } from '@things-factory/integration-base'\n\nexport class OPCUAConnector implements Connector {\n async ready(connectionConfigs) {\n await Promise.all(connectionConfigs.map(this.connect))\n\n ConnectionManager.logger.info('opc-ua connections are ready')\n }\n\n async connect(config) {\n var {\n name,\n endpoint,\n params: {\n maxRetry = 2,\n initialDelay = 2000,\n maxDelay = 10 * 1000,\n requestedPublishingInterval = 1000,\n requestedLifetimeCount = 100,\n requestedMaxKeepAliveCount = 20,\n maxNotificationsPerPublish = 10,\n publishingEnabled = true,\n priority = 10\n }\n } = config\n\n const client = OPCUAClient.create({\n endpoint_must_exist: false,\n connectionStrategy: {\n maxRetry,\n initialDelay,\n maxDelay\n }\n })\n\n client.on('backoff', () => ConnectionManager.logger.log('retrying connection'))\n\n await client.connect(endpoint)\n\n const session = await client.createSession()\n\n const browseResult: BrowseResult = (await session.browse('RootFolder')) as BrowseResult\n\n ConnectionManager.logger.log(\n browseResult.references.map((r: ReferenceDescription) => r.browseName.toString()).join('\\n')\n )\n\n const subscription = await session.createSubscription2({\n requestedPublishingInterval,\n requestedLifetimeCount,\n requestedMaxKeepAliveCount,\n maxNotificationsPerPublish,\n publishingEnabled,\n priority\n })\n\n subscription\n .on('started', () =>\n ConnectionManager.logger.log('subscription started - subscriptionId=', subscription.subscriptionId)\n )\n .on('keepalive', () => ConnectionManager.logger.log('keepalive'))\n .on('terminated', () => ConnectionManager.logger.log('subscription terminated'))\n\n try {\n ConnectionManager.addConnectionInstance(config, {\n read: async function (node, { logger }): Promise<DataValue> {\n const dataValue = await session.read({ nodeId: node, attributeId: AttributeIds.Value })\n if (dataValue.statusCode !== StatusCodes.Good) {\n logger.log('Could not read ', node)\n }\n logger.log(` dataValue = ${dataValue.value.toString()}`)\n\n return dataValue\n },\n write: async function (node, value, { logger }): Promise<StatusCode> {\n const statusCode = await session.write({\n nodeId: node,\n attributeId: AttributeIds.Value,\n value: {\n statusCode: StatusCodes.Good,\n sourceTimestamp: new Date(),\n value\n }\n })\n\n logger.log('statusCode = ', statusCode.toString())\n return statusCode\n },\n startMonitor: async function (\n node,\n callback: (dataValue: DataValue) => void,\n options: { samplingInterval: number; discardOldest: boolean; queueSize: number },\n { logger }\n ): Promise<ClientMonitoredItem> {\n const { samplingInterval = 100, discardOldest = true, queueSize = 10 } = options || {}\n const monitoredItem = await subscription.monitor(\n {\n nodeId: node,\n attributeId: AttributeIds.Value\n },\n {\n samplingInterval,\n discardOldest,\n queueSize\n },\n TimestampsToReturn.Both\n )\n\n monitoredItem.on('changed', callback)\n return monitoredItem\n },\n stopMonitor: async function (monitoredItem, { logger }): Promise<void> {\n await monitoredItem.terminate()\n },\n close: async function (): Promise<void> {\n await subscription?.terminate()\n await session?.close()\n await client?.disconnect()\n }\n })\n\n ConnectionManager.logger.info(`opc-ua connection(${name}:${endpoint}) is connected`)\n } catch (error) {\n ConnectionManager.logger.info(`opc-ua connection(${name}:${endpoint}) failed to connect`)\n }\n }\n\n async disconnect(connection: Connection) {\n var { close } = ConnectionManager.removeConnectionInstance(connection)\n await close()\n\n ConnectionManager.logger.info(`opc-ua connection(${connection.name}) is disconnected`)\n }\n\n get parameterSpec() {\n return [\n {\n type: 'number',\n name: 'maxRetry',\n label: 'max-retry'\n },\n {\n type: 'number',\n name: 'initialDelay',\n label: 'initial-delay'\n },\n {\n type: 'number',\n name: 'maxDelay',\n label: 'max-delay'\n },\n {\n type: 'number',\n name: 'requestedPublishingInterval',\n label: 'requested-publishing-interval'\n },\n {\n type: 'number',\n name: 'requestedLifetimeCount',\n label: 'requested-lifetime-count'\n },\n {\n type: 'number',\n name: 'requestedMaxKeepAliveCount',\n label: 'requested-max-keep-alive-count'\n },\n {\n type: 'number',\n name: 'maxNotificationsPerPublish',\n label: 'max-notifications-per-publish'\n },\n {\n type: 'boolean',\n name: 'publishingEnabled',\n label: 'publishing-enabled'\n },\n {\n type: 'number',\n name: 'priority',\n label: 'priority'\n }\n ]\n }\n\n get taskPrefixes() {\n return ['opc-ua']\n }\n\n get help() {\n return 'integration/connector/opc-ua'\n }\n}\n\nConnectionManager.registerConnector('opc-ua', new OPCUAConnector())\n"]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./connector");
4
+ require("./task");
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../server/engine/index.ts"],"names":[],"mappings":";;AAAA,uBAAoB;AACpB,kBAAe","sourcesContent":["import './connector'\nimport './task'\n"]}
@@ -0,0 +1,7 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./opc-ua-read");
4
+ require("./opc-ua-write");
5
+ require("./opc-ua-start-monitor");
6
+ require("./opc-ua-stop-monitor");
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,0BAAuB;AACvB,kCAA+B;AAC/B,iCAA8B","sourcesContent":["import './opc-ua-read'\nimport './opc-ua-write'\nimport './opc-ua-start-monitor'\nimport './opc-ua-stop-monitor'\n"]}
@@ -0,0 +1,26 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const integration_base_1 = require("@things-factory/integration-base");
4
+ async function OPCUARead(step, { logger, domain }) {
5
+ var { connection, params: { node } } = step;
6
+ var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
7
+ if (!client) {
8
+ throw new Error(`no connection : ${connection}`);
9
+ }
10
+ if (!node) {
11
+ throw new Error('node parameter should be defined');
12
+ }
13
+ var { read } = client;
14
+ var content = await read(node, { logger });
15
+ return content;
16
+ }
17
+ OPCUARead.parameterSpec = [
18
+ {
19
+ type: 'string',
20
+ name: 'node',
21
+ label: 'node'
22
+ }
23
+ ];
24
+ OPCUARead.help = 'integration/task/opc-ua-read';
25
+ integration_base_1.TaskRegistry.registerTaskHandler('opc-ua-read', OPCUARead);
26
+ //# sourceMappingURL=opc-ua-read.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opc-ua-read.js","sourceRoot":"","sources":["../../../server/engine/task/opc-ua-read.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAElF,KAAK,UAAU,SAAS,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE;IAC/C,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,IAAI,EAAE,EACjB,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,IAAI,CAAC,IAAI,EAAE;QACT,MAAM,IAAI,KAAK,CAAC,kCAAkC,CAAC,CAAA;KACpD;IAED,IAAI,EAAE,IAAI,EAAE,GAAG,MAAM,CAAA;IACrB,IAAI,OAAO,GAAG,MAAM,IAAI,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IAC1C,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,SAAS,CAAC,aAAa,GAAG;IACxB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;CACF,CAAA;AAED,SAAS,CAAC,IAAI,GAAG,8BAA8B,CAAA;AAE/C,+BAAY,CAAC,mBAAmB,CAAC,aAAa,EAAE,SAAS,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\n\nasync function OPCUARead(step, { logger, domain }) {\n var {\n connection,\n params: { node }\n } = step\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n if (!node) {\n throw new Error('node parameter should be defined')\n }\n\n var { read } = client\n var content = await read(node, { logger })\n return content\n}\n\nOPCUARead.parameterSpec = [\n {\n type: 'string',\n name: 'node',\n label: 'node'\n }\n]\n\nOPCUARead.help = 'integration/task/opc-ua-read'\n\nTaskRegistry.registerTaskHandler('opc-ua-read', OPCUARead)\n"]}
@@ -0,0 +1,44 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const integration_base_1 = require("@things-factory/integration-base");
4
+ async function OPCUAStartMonitor(step, { logger, domain, data }) {
5
+ var { connection, params: { node, samplingInterval, discardOldest, queueSize } } = step;
6
+ var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
7
+ if (!client) {
8
+ throw new Error(`no connection : ${connection}`);
9
+ }
10
+ const callback = (dataValue) => {
11
+ logger.log('monitored value: %s', dataValue);
12
+ };
13
+ var { startMonitor } = client;
14
+ return await startMonitor(node, callback, {
15
+ samplingInterval,
16
+ discardOldest,
17
+ queueSize
18
+ }, { logger });
19
+ }
20
+ OPCUAStartMonitor.parameterSpec = [
21
+ {
22
+ type: 'string',
23
+ name: 'node',
24
+ label: 'node'
25
+ },
26
+ {
27
+ type: 'number',
28
+ name: 'samplingInterval',
29
+ label: 'sampling-interval'
30
+ },
31
+ {
32
+ type: 'boolean',
33
+ name: 'discardOldest',
34
+ label: 'discard-oldest'
35
+ },
36
+ {
37
+ type: 'number',
38
+ name: 'queueSize',
39
+ label: 'queue-size'
40
+ }
41
+ ];
42
+ OPCUAStartMonitor.help = 'integration/task/opc-ua-start-monitor';
43
+ integration_base_1.TaskRegistry.registerTaskHandler('opc-ua-start-monitor', OPCUAStartMonitor);
44
+ //# sourceMappingURL=opc-ua-start-monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opc-ua-start-monitor.js","sourceRoot":"","sources":["../../../server/engine/task/opc-ua-start-monitor.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAGlF,KAAK,UAAU,iBAAiB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IAC7D,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,EAC7D,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,MAAM,QAAQ,GAAG,CAAC,SAAoB,EAAE,EAAE;QACxC,MAAM,CAAC,GAAG,CAAC,qBAAqB,EAAE,SAAS,CAAC,CAAA;IAC9C,CAAC,CAAA;IAED,IAAI,EAAE,YAAY,EAAE,GAAG,MAAM,CAAA;IAC7B,OAAO,MAAM,YAAY,CACvB,IAAI,EACJ,QAAQ,EACR;QACE,gBAAgB;QAChB,aAAa;QACb,SAAS;KACV,EACD,EAAE,MAAM,EAAE,CACX,CAAA;AACH,CAAC;AAED,iBAAiB,CAAC,aAAa,GAAG;IAChC;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,kBAAkB;QACxB,KAAK,EAAE,mBAAmB;KAC3B;IACD;QACE,IAAI,EAAE,SAAS;QACf,IAAI,EAAE,eAAe;QACrB,KAAK,EAAE,gBAAgB;KACxB;IACD;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,WAAW;QACjB,KAAK,EAAE,YAAY;KACpB;CACF,CAAA;AAED,iBAAiB,CAAC,IAAI,GAAG,uCAAuC,CAAA;AAEhE,+BAAY,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\nimport { DataValue } from 'node-opcua'\n\nasync function OPCUAStartMonitor(step, { logger, domain, data }) {\n var {\n connection,\n params: { node, samplingInterval, discardOldest, queueSize }\n } = step\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n const callback = (dataValue: DataValue) => {\n logger.log('monitored value: %s', dataValue)\n }\n\n var { startMonitor } = client\n return await startMonitor(\n node,\n callback,\n {\n samplingInterval,\n discardOldest,\n queueSize\n },\n { logger }\n )\n}\n\nOPCUAStartMonitor.parameterSpec = [\n {\n type: 'string',\n name: 'node',\n label: 'node'\n },\n {\n type: 'number',\n name: 'samplingInterval',\n label: 'sampling-interval'\n },\n {\n type: 'boolean',\n name: 'discardOldest',\n label: 'discard-oldest'\n },\n {\n type: 'number',\n name: 'queueSize',\n label: 'queue-size'\n }\n]\n\nOPCUAStartMonitor.help = 'integration/task/opc-ua-start-monitor'\n\nTaskRegistry.registerTaskHandler('opc-ua-start-monitor', OPCUAStartMonitor)\n"]}
@@ -0,0 +1,24 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@things-factory/utils");
4
+ const integration_base_1 = require("@things-factory/integration-base");
5
+ async function OPCUAStopMonitor(step, { logger, domain, data }) {
6
+ var { connection, params: { monitorItem } } = step;
7
+ var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
8
+ if (!client) {
9
+ throw new Error(`no connection : ${connection}`);
10
+ }
11
+ const item = (0, utils_1.access)(monitorItem, data);
12
+ var { stopMonitor } = client;
13
+ return await stopMonitor(item, { logger });
14
+ }
15
+ OPCUAStopMonitor.parameterSpec = [
16
+ {
17
+ type: 'scenario-step-input',
18
+ name: 'monitorItem',
19
+ label: 'monitor-item'
20
+ }
21
+ ];
22
+ OPCUAStopMonitor.help = 'integration/task/opc-ua-stop-monitor';
23
+ integration_base_1.TaskRegistry.registerTaskHandler('opc-ua-stop-monitor', OPCUAStopMonitor);
24
+ //# sourceMappingURL=opc-ua-stop-monitor.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opc-ua-stop-monitor.js","sourceRoot":"","sources":["../../../server/engine/task/opc-ua-stop-monitor.ts"],"names":[],"mappings":";;AAAA,iDAA8C;AAC9C,uEAAkF;AAElF,KAAK,UAAU,gBAAgB,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IAC5D,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,WAAW,EAAE,EACxB,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,MAAM,IAAI,GAAG,IAAA,cAAM,EAAC,WAAW,EAAE,IAAI,CAAC,CAAA;IAEtC,IAAI,EAAE,WAAW,EAAE,GAAG,MAAM,CAAA;IAC5B,OAAO,MAAM,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;AAC5C,CAAC;AAED,gBAAgB,CAAC,aAAa,GAAG;IAC/B;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,aAAa;QACnB,KAAK,EAAE,cAAc;KACtB;CACF,CAAA;AAED,gBAAgB,CAAC,IAAI,GAAG,sCAAsC,CAAA;AAE9D,+BAAY,CAAC,mBAAmB,CAAC,qBAAqB,EAAE,gBAAgB,CAAC,CAAA","sourcesContent":["import { access } from '@things-factory/utils'\nimport { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\n\nasync function OPCUAStopMonitor(step, { logger, domain, data }) {\n var {\n connection,\n params: { monitorItem }\n } = step\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n const item = access(monitorItem, data)\n\n var { stopMonitor } = client\n return await stopMonitor(item, { logger })\n}\n\nOPCUAStopMonitor.parameterSpec = [\n {\n type: 'scenario-step-input',\n name: 'monitorItem',\n label: 'monitor-item'\n }\n]\n\nOPCUAStopMonitor.help = 'integration/task/opc-ua-stop-monitor'\n\nTaskRegistry.registerTaskHandler('opc-ua-stop-monitor', OPCUAStopMonitor)\n"]}
@@ -0,0 +1,30 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const utils_1 = require("@things-factory/utils");
4
+ const integration_base_1 = require("@things-factory/integration-base");
5
+ async function OPCUAWrite(step, { logger, domain, data }) {
6
+ var { connection, params: { node, accessor } } = step;
7
+ var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
8
+ if (!client) {
9
+ throw new Error(`no connection : ${connection}`);
10
+ }
11
+ const value = (0, utils_1.access)(accessor, data);
12
+ var { write } = client;
13
+ var content = await write(node, value, { logger });
14
+ return content;
15
+ }
16
+ OPCUAWrite.parameterSpec = [
17
+ {
18
+ type: 'string',
19
+ name: 'node',
20
+ label: 'node'
21
+ },
22
+ {
23
+ type: 'scenario-step-input',
24
+ name: 'accessor',
25
+ label: 'accessor'
26
+ }
27
+ ];
28
+ OPCUAWrite.help = 'integration/task/opc-ua-write';
29
+ integration_base_1.TaskRegistry.registerTaskHandler('opc-ua-write', OPCUAWrite);
30
+ //# sourceMappingURL=opc-ua-write.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"opc-ua-write.js","sourceRoot":"","sources":["../../../server/engine/task/opc-ua-write.ts"],"names":[],"mappings":";;AAAA,iDAA8C;AAC9C,uEAAkF;AAElF,KAAK,UAAU,UAAU,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE;IACtD,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,IAAI,EAAE,QAAQ,EAAE,EAC3B,GAAG,IAAI,CAAA;IAER,IAAI,MAAM,GAAG,oCAAiB,CAAC,2BAA2B,CAAC,MAAM,EAAE,UAAU,CAAC,CAAA;IAC9E,IAAI,CAAC,MAAM,EAAE;QACX,MAAM,IAAI,KAAK,CAAC,mBAAmB,UAAU,EAAE,CAAC,CAAA;KACjD;IAED,MAAM,KAAK,GAAG,IAAA,cAAM,EAAC,QAAQ,EAAE,IAAI,CAAC,CAAA;IAEpC,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,CAAA;IACtB,IAAI,OAAO,GAAG,MAAM,KAAK,CAAC,IAAI,EAAE,KAAK,EAAE,EAAE,MAAM,EAAE,CAAC,CAAA;IAElD,OAAO,OAAO,CAAA;AAChB,CAAC;AAED,UAAU,CAAC,aAAa,GAAG;IACzB;QACE,IAAI,EAAE,QAAQ;QACd,IAAI,EAAE,MAAM;QACZ,KAAK,EAAE,MAAM;KACd;IACD;QACE,IAAI,EAAE,qBAAqB;QAC3B,IAAI,EAAE,UAAU;QAChB,KAAK,EAAE,UAAU;KAClB;CACF,CAAA;AAED,UAAU,CAAC,IAAI,GAAG,+BAA+B,CAAA;AAEjD,+BAAY,CAAC,mBAAmB,CAAC,cAAc,EAAE,UAAU,CAAC,CAAA","sourcesContent":["import { access } from '@things-factory/utils'\nimport { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\n\nasync function OPCUAWrite(step, { logger, domain, data }) {\n var {\n connection,\n params: { node, accessor }\n } = step\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n const value = access(accessor, data)\n\n var { write } = client\n var content = await write(node, value, { logger })\n\n return content\n}\n\nOPCUAWrite.parameterSpec = [\n {\n type: 'string',\n name: 'node',\n label: 'node'\n },\n {\n type: 'scenario-step-input',\n name: 'accessor',\n label: 'accessor'\n }\n]\n\nOPCUAWrite.help = 'integration/task/opc-ua-write'\n\nTaskRegistry.registerTaskHandler('opc-ua-write', OPCUAWrite)\n"]}
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ require("./engine");
4
+ require("./engine");
5
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../server/index.ts"],"names":[],"mappings":";;AAAA,oBAAiB;AACjB,oBAAiB","sourcesContent":["import './engine'\nimport './engine'\n"]}