@machinemetrics/io-adapter-lib 2.32.1 → 2.32.2
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 +3 -0
- package/lib/config/adapterConfig.js +3 -0
- package/package.json +1 -1
- package/test/.eslintrc.json +2 -1
- package/test/conditions.test.js +31 -0
- package/test/configFiles/conditions.yml +10 -0
package/CHANGELOG.md
CHANGED
|
@@ -350,6 +350,9 @@ class AdapterConfig {
|
|
|
350
350
|
if (item['reclassify-fault']) {
|
|
351
351
|
source.reclassifyFault = allowDenyList.parseWildcardKeyList(item['reclassify-fault'], `conditions.${key}.reclassify-fault-codes`);
|
|
352
352
|
}
|
|
353
|
+
if (item['reclassify-normal']) {
|
|
354
|
+
source.reclassifyNormal = allowDenyList.parseWildcardKeyList(item['reclassify-normal'], `conditions.${key}.reclassify-normal-codes`);
|
|
355
|
+
}
|
|
353
356
|
|
|
354
357
|
if (item.overrides) {
|
|
355
358
|
if (!_.isArray(item.overrides)) {
|
package/package.json
CHANGED
package/test/.eslintrc.json
CHANGED
package/test/conditions.test.js
CHANGED
|
@@ -72,6 +72,37 @@ describe('data items', async function () {
|
|
|
72
72
|
validateCondition(captured[10], 'cond1', 'FAULT', 5000, 'A2', 'Code A2');
|
|
73
73
|
validateCondition(captured[11], 'cond2', 'FAULT', 6000, 'B33', 'Code B33');
|
|
74
74
|
});
|
|
75
|
+
|
|
76
|
+
it('loads reclassification config', async function () {
|
|
77
|
+
expect(config.adapter.passthroughConditions).to.exist;
|
|
78
|
+
expect(config.adapter.passthroughConditions.system).to.exist;
|
|
79
|
+
expect(config.adapter.passthroughConditions.system.length).to.eq(1);
|
|
80
|
+
|
|
81
|
+
const source = config.adapter.passthroughConditions.system[0];
|
|
82
|
+
expect(source.name).to.eq('cond4');
|
|
83
|
+
expect(source.reclassifyFault).to.exist;
|
|
84
|
+
expect(source.reclassifyWarning).to.exist;
|
|
85
|
+
expect(source.reclassifyNormal).to.exist;
|
|
86
|
+
});
|
|
87
|
+
|
|
88
|
+
it('reclassifies codes based on patterns', async function () {
|
|
89
|
+
const source = config.adapter.passthroughConditions.system[0];
|
|
90
|
+
|
|
91
|
+
// Test FAULT reclassification
|
|
92
|
+
expect(source.reclassifyFault[0].test('HIGH_TEMP')).to.eq(true);
|
|
93
|
+
expect(source.reclassifyFault[0].test('HIGH_PRESSURE')).to.eq(true);
|
|
94
|
+
expect(source.reclassifyFault[0].test('MEDIUM_TEMP')).to.eq(false);
|
|
95
|
+
|
|
96
|
+
// Test WARNING reclassification
|
|
97
|
+
expect(source.reclassifyWarning[0].test('MEDIUM_TEMP')).to.eq(true);
|
|
98
|
+
expect(source.reclassifyWarning[0].test('MEDIUM_PRESSURE')).to.eq(true);
|
|
99
|
+
expect(source.reclassifyWarning[0].test('LOW_TEMP')).to.eq(false);
|
|
100
|
+
|
|
101
|
+
// Test NORMAL reclassification
|
|
102
|
+
expect(source.reclassifyNormal[0].test('LOW_TEMP')).to.eq(true);
|
|
103
|
+
expect(source.reclassifyNormal[0].test('LOW_PRESSURE')).to.eq(true);
|
|
104
|
+
expect(source.reclassifyNormal[0].test('HIGH_TEMP')).to.eq(false);
|
|
105
|
+
});
|
|
75
106
|
});
|
|
76
107
|
|
|
77
108
|
function validateCondition(entry, key, value, time, code, message) {
|
|
@@ -5,6 +5,8 @@ declare-keys:
|
|
|
5
5
|
- key2
|
|
6
6
|
- key3
|
|
7
7
|
- key4
|
|
8
|
+
- system:
|
|
9
|
+
type: condition
|
|
8
10
|
variables:
|
|
9
11
|
keymod:
|
|
10
12
|
- source: key2
|
|
@@ -35,3 +37,11 @@ conditions:
|
|
|
35
37
|
override-message: ${this} coolant=${key1}
|
|
36
38
|
- override-code: Y
|
|
37
39
|
override-message: Z
|
|
40
|
+
cond4:
|
|
41
|
+
source: system
|
|
42
|
+
reclassify-fault:
|
|
43
|
+
- HIGH*
|
|
44
|
+
reclassify-warning:
|
|
45
|
+
- MEDIUM*
|
|
46
|
+
reclassify-normal:
|
|
47
|
+
- LOW*
|