@things-factory/integration-opc 6.1.129 → 6.1.138
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-server/engine/task/index.js +1 -1
- package/dist-server/engine/task/index.js.map +1 -1
- package/dist-server/engine/task/opc-ua-start-monitor.js +35 -11
- package/dist-server/engine/task/opc-ua-start-monitor.js.map +1 -1
- package/dist-server/tsconfig.tsbuildinfo +1 -1
- package/helps/integration/connector/opc-ua.ja.md +4 -6
- package/helps/integration/connector/opc-ua.ko.md +3 -5
- package/helps/integration/connector/opc-ua.md +4 -6
- package/helps/integration/connector/opc-ua.ms.md +5 -7
- package/helps/integration/connector/opc-ua.zh.md +6 -8
- package/package.json +3 -3
- package/server/engine/task/index.ts +1 -1
- package/server/engine/task/opc-ua-start-monitor.ts +45 -16
|
@@ -3,6 +3,6 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
require("./opc-ua-read");
|
|
4
4
|
require("./opc-ua-write");
|
|
5
5
|
require("./opc-ua-start-monitor");
|
|
6
|
-
|
|
6
|
+
//import './opc-ua-stop-monitor'
|
|
7
7
|
require("./utils");
|
|
8
8
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +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,
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../server/engine/task/index.ts"],"names":[],"mappings":";;AAAA,yBAAsB;AACtB,0BAAuB;AACvB,kCAA+B;AAC/B,gCAAgC;AAChC,mBAAgB","sourcesContent":["import './opc-ua-read'\nimport './opc-ua-write'\nimport './opc-ua-start-monitor'\n//import './opc-ua-stop-monitor'\nimport './utils'\n"]}
|
|
@@ -1,22 +1,46 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
const integration_base_1 = require("@things-factory/integration-base");
|
|
4
|
-
|
|
4
|
+
const utils_1 = require("@things-factory/utils");
|
|
5
|
+
async function OPCUAStartMonitor(step, context) {
|
|
5
6
|
var { connection, params: { node, samplingInterval, discardOldest, queueSize } } = step;
|
|
7
|
+
const { logger, domain, closures, __opcua_moinitor } = context;
|
|
8
|
+
if (!__opcua_moinitor) {
|
|
9
|
+
context.__opcua_moinitor = {};
|
|
10
|
+
}
|
|
6
11
|
var client = integration_base_1.ConnectionManager.getConnectionInstanceByName(domain, connection);
|
|
7
12
|
if (!client) {
|
|
8
13
|
throw new Error(`no connection : ${connection}`);
|
|
9
14
|
}
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
15
|
+
if (!context.__opcua_moinitor[node]) {
|
|
16
|
+
var MONINTORED_VALUE;
|
|
17
|
+
context.__opcua_moinitor[node] = async () => {
|
|
18
|
+
while (!MONINTORED_VALUE) {
|
|
19
|
+
await (0, utils_1.sleep)(100);
|
|
20
|
+
}
|
|
21
|
+
var monitoringValue = MONINTORED_VALUE;
|
|
22
|
+
MONINTORED_VALUE = null;
|
|
23
|
+
return monitoringValue;
|
|
24
|
+
};
|
|
25
|
+
var { startMonitor, stopMonitor } = client;
|
|
26
|
+
var monitoredItem = await startMonitor(node, (dataValue) => {
|
|
27
|
+
MONINTORED_VALUE = dataValue === null || dataValue === void 0 ? void 0 : dataValue.value.value;
|
|
28
|
+
}, {
|
|
29
|
+
samplingInterval,
|
|
30
|
+
discardOldest,
|
|
31
|
+
queueSize
|
|
32
|
+
}, { logger });
|
|
33
|
+
closures.push(async () => {
|
|
34
|
+
try {
|
|
35
|
+
monitoredItem && (await stopMonitor(monitoredItem, { logger }));
|
|
36
|
+
}
|
|
37
|
+
catch (e) {
|
|
38
|
+
logger.error(e);
|
|
39
|
+
}
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
var monitoringValue = await context.__opcua_moinitor[node]();
|
|
43
|
+
return { data: monitoringValue };
|
|
20
44
|
}
|
|
21
45
|
OPCUAStartMonitor.parameterSpec = [
|
|
22
46
|
{
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"opc-ua-start-monitor.js","sourceRoot":"","sources":["../../../server/engine/task/opc-ua-start-monitor.ts"],"names":[],"mappings":";;AAAA,uEAAkF;
|
|
1
|
+
{"version":3,"file":"opc-ua-start-monitor.js","sourceRoot":"","sources":["../../../server/engine/task/opc-ua-start-monitor.ts"],"names":[],"mappings":";;AAAA,uEAAkF;AAElF,iDAA6C;AAE7C,KAAK,UAAU,iBAAiB,CAAC,IAAI,EAAE,OAAO;IAC5C,IAAI,EACF,UAAU,EACV,MAAM,EAAE,EAAE,IAAI,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,EAC7D,GAAG,IAAI,CAAA;IAER,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,QAAQ,EAAE,gBAAgB,EAAE,GAAG,OAAO,CAAA;IAC9D,IAAI,CAAC,gBAAgB,EAAE;QACrB,OAAO,CAAC,gBAAgB,GAAG,EAAE,CAAA;KAC9B;IAED,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,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,EAAE;QACnC,IAAI,gBAAgB,CAAA;QACpB,OAAO,CAAC,gBAAgB,CAAC,IAAI,CAAC,GAAG,KAAK,IAAI,EAAE;YAC1C,OAAO,CAAC,gBAAgB,EAAE;gBACxB,MAAM,IAAA,aAAK,EAAC,GAAG,CAAC,CAAA;aACjB;YAED,IAAI,eAAe,GAAG,g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EhE,+BAAY,CAAC,mBAAmB,CAAC,sBAAsB,EAAE,iBAAiB,CAAC,CAAA","sourcesContent":["import { ConnectionManager, TaskRegistry } from '@things-factory/integration-base'\nimport { DataValue } from 'node-opcua'\nimport { sleep } from '@things-factory/utils'\n\nasync function OPCUAStartMonitor(step, context) {\n var {\n connection,\n params: { node, samplingInterval, discardOldest, queueSize }\n } = step\n\n const { logger, domain, closures, __opcua_moinitor } = context\n if (!__opcua_moinitor) {\n context.__opcua_moinitor = {}\n }\n\n var client = ConnectionManager.getConnectionInstanceByName(domain, connection)\n if (!client) {\n throw new Error(`no connection : ${connection}`)\n }\n\n if (!context.__opcua_moinitor[node]) {\n var MONINTORED_VALUE\n context.__opcua_moinitor[node] = async () => {\n while (!MONINTORED_VALUE) {\n await sleep(100)\n }\n\n var monitoringValue = MONINTORED_VALUE\n\n MONINTORED_VALUE = null\n\n return monitoringValue\n }\n\n var { startMonitor, stopMonitor } = client\n var monitoredItem = await startMonitor(\n node,\n (dataValue: DataValue) => {\n MONINTORED_VALUE = dataValue?.value.value\n },\n {\n samplingInterval,\n discardOldest,\n queueSize\n },\n { logger }\n )\n\n closures.push(async () => {\n try {\n monitoredItem && (await stopMonitor(monitoredItem, { logger }))\n } catch (e) {\n logger.error(e)\n }\n })\n }\n\n var monitoringValue = await context.__opcua_moinitor[node]()\n\n return { data: monitoringValue }\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"]}
|