@machinemetrics/io-adapter-lib 2.32.2 → 2.32.3
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/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,9 @@
|
|
|
2
2
|
|
|
3
3
|
const _ = require('lodash');
|
|
4
4
|
const ConfigError = require('../configError');
|
|
5
|
+
const AllowDenyList = require('../common/allowDenyList');
|
|
6
|
+
|
|
7
|
+
const allowDenyList = new AllowDenyList();
|
|
5
8
|
|
|
6
9
|
// Pattern to match valid OPC-UA node ID paths, as supported by node-opcua
|
|
7
10
|
// Our validation may be slightly stricter on some value validation.
|
|
@@ -144,6 +147,28 @@ class OpcuaConfig {
|
|
|
144
147
|
result.warningThreshold = warningThreshold;
|
|
145
148
|
}
|
|
146
149
|
|
|
150
|
+
result.codeFormat = '{conditionName}_{conditionIdHash}';
|
|
151
|
+
if (_.has(conditions, 'code-format')) {
|
|
152
|
+
const codeFormat = conditions['code-format'];
|
|
153
|
+
if (_.isEmpty(codeFormat) || !_.isString(codeFormat)) {
|
|
154
|
+
throw new ConfigError('code-format cannot be empty').atAttribute('code-format');
|
|
155
|
+
}
|
|
156
|
+
result.codeFormat = codeFormat;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
if (_.has(conditions, 'allow-condition-nodes')) {
|
|
160
|
+
result.allowConditionNodes = allowDenyList.parseWildcardKeyList(conditions['allow-condition-nodes'], 'allow-condition-nodes');
|
|
161
|
+
}
|
|
162
|
+
if (_.has(conditions, 'deny-condition-nodes')) {
|
|
163
|
+
result.denyConditionNodes = allowDenyList.parseWildcardKeyList(conditions['deny-condition-nodes'], 'deny-condition-nodes');
|
|
164
|
+
}
|
|
165
|
+
if (_.has(conditions, 'allow-source-nodes')) {
|
|
166
|
+
result.allowSourceNodes = allowDenyList.parseWildcardKeyList(conditions['allow-source-nodes'], 'allow-source-nodes');
|
|
167
|
+
}
|
|
168
|
+
if (_.has(conditions, 'deny-source-nodes')) {
|
|
169
|
+
result.denySourceNodes = allowDenyList.parseWildcardKeyList(conditions['deny-source-nodes'], 'deny-source-nodes');
|
|
170
|
+
}
|
|
171
|
+
|
|
147
172
|
return result;
|
|
148
173
|
} catch (error) {
|
|
149
174
|
if (error instanceof ConfigError) {
|
package/package.json
CHANGED
|
@@ -8,11 +8,13 @@ describe('OPC-UA config tests', function () {
|
|
|
8
8
|
let config;
|
|
9
9
|
let defaultConfig;
|
|
10
10
|
let conditionsConfig;
|
|
11
|
+
let conditionsDefaultConfig;
|
|
11
12
|
|
|
12
13
|
before(async () => {
|
|
13
14
|
defaultConfig = await testUtils.loadConfig('device/opcua-default.yml');
|
|
14
15
|
config = await testUtils.loadConfig('device/opcua-std.yml');
|
|
15
16
|
conditionsConfig = await testUtils.loadConfig('device/opcua-conditions.yml');
|
|
17
|
+
conditionsDefaultConfig = await testUtils.loadConfig('device/opcua-conditions-default.yml');
|
|
16
18
|
});
|
|
17
19
|
|
|
18
20
|
it('loads minimal config with defaults', async function () {
|
|
@@ -104,12 +106,27 @@ describe('OPC-UA config tests', function () {
|
|
|
104
106
|
testPath('nsu=http://test.org/UA/Data/;i=10853');
|
|
105
107
|
});
|
|
106
108
|
|
|
109
|
+
it('loads opcua-conditions with default properties', async function () {
|
|
110
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.key).to.eq('system');
|
|
111
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.faultThreshold).to.eq(undefined);
|
|
112
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.warningThreshold).to.eq(undefined);
|
|
113
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.codeFormat).to.eq('{conditionName}_{conditionIdHash}');
|
|
114
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.allowConditionNodes).to.eq(undefined);
|
|
115
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.denyConditionNodes).to.eq(undefined);
|
|
116
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.allowSourceNodes).to.eq(undefined);
|
|
117
|
+
expect(conditionsDefaultConfig.device.opcuaConditions.denySourceNodes).to.eq(undefined);
|
|
118
|
+
expect(conditionsDefaultConfig.device.conditionKey).to.eq('system');
|
|
119
|
+
});
|
|
120
|
+
|
|
107
121
|
it('loads opcua-conditions with all properties', async function () {
|
|
108
|
-
expect(conditionsConfig.device.opcuaConditions).to.
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
122
|
+
expect(conditionsConfig.device.opcuaConditions.key).to.eq('system');
|
|
123
|
+
expect(conditionsConfig.device.opcuaConditions.faultThreshold).to.eq(100);
|
|
124
|
+
expect(conditionsConfig.device.opcuaConditions.warningThreshold).to.eq(50);
|
|
125
|
+
expect(conditionsConfig.device.opcuaConditions.codeFormat).to.eq('{conditionName}');
|
|
126
|
+
expect(conditionsConfig.device.opcuaConditions.allowConditionNodes).to.have.lengthOf(1);
|
|
127
|
+
expect(conditionsConfig.device.opcuaConditions.denyConditionNodes).to.have.lengthOf(1);
|
|
128
|
+
expect(conditionsConfig.device.opcuaConditions.allowSourceNodes).to.have.lengthOf(1);
|
|
129
|
+
expect(conditionsConfig.device.opcuaConditions.denySourceNodes).to.have.lengthOf(1);
|
|
113
130
|
expect(conditionsConfig.device.conditionKey).to.eq('system');
|
|
114
131
|
});
|
|
115
132
|
});
|
|
@@ -5,3 +5,12 @@ opcua-conditions:
|
|
|
5
5
|
key: system
|
|
6
6
|
fault-threshold: 100
|
|
7
7
|
warning-threshold: 50
|
|
8
|
+
code-format: "{conditionName}"
|
|
9
|
+
allow-condition-nodes:
|
|
10
|
+
- ns=2;s=Flames/*
|
|
11
|
+
deny-condition-nodes:
|
|
12
|
+
- ns=2;s=Flames/ControlledFacilityComponents/*
|
|
13
|
+
allow-source-nodes:
|
|
14
|
+
- ns=2;s=Flames/*
|
|
15
|
+
deny-source-nodes:
|
|
16
|
+
- ns=2;s=Flames/ControlledFacilityComponents/*
|