@machinemetrics/io-adapter-lib 2.32.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/.circleci/config.yml +141 -0
- package/.eslintrc.json +36 -0
- package/.gitattributes +12 -0
- package/CHANGELOG.md +544 -0
- package/README.md +2 -0
- package/index.js +17 -0
- package/lib/config/adapterConfig.js +535 -0
- package/lib/config/common/allowDenyList.js +58 -0
- package/lib/config/common/jsonPath.js +44 -0
- package/lib/config/common/labjackU3T4Common.js +227 -0
- package/lib/config/common/validations.js +142 -0
- package/lib/config/configError.js +32 -0
- package/lib/config/device/adam-6052Config.js +103 -0
- package/lib/config/device/brotherHTTPConfig.js +215 -0
- package/lib/config/device/ethernetIPConfig.js +191 -0
- package/lib/config/device/ifmIotConfig.js +245 -0
- package/lib/config/device/jsonHttpConfig.js +76 -0
- package/lib/config/device/labjackT4Config.js +39 -0
- package/lib/config/device/labjackT7Config.js +192 -0
- package/lib/config/device/labjackU3Config.js +32 -0
- package/lib/config/device/modbusTcpConfig.js +336 -0
- package/lib/config/device/mqttBaseConfig.js +70 -0
- package/lib/config/device/mqttConfig.js +113 -0
- package/lib/config/device/mqttLincolnConfig.js +62 -0
- package/lib/config/device/mtconnectAdapterConfig.js +42 -0
- package/lib/config/device/mtconnectBaseConfig.js +136 -0
- package/lib/config/device/mtconnectConfig.js +52 -0
- package/lib/config/device/mtconnectHaasConfig.js +15 -0
- package/lib/config/device/nullConfig.js +81 -0
- package/lib/config/device/opcuaConfig.js +205 -0
- package/lib/config/device/pcccConfig.js +88 -0
- package/lib/config/engineConfigV1.js +382 -0
- package/lib/config/engineConfigV2.js +106 -0
- package/lib/config/generator/counterGenConfig.js +15 -0
- package/lib/config/generator/cronGenConfig.js +33 -0
- package/lib/config/generator/dateTimeGenConfig.js +33 -0
- package/lib/config/index.js +339 -0
- package/lib/config/transformConfigUtil.js +296 -0
- package/lib/engine/dataOutput.js +357 -0
- package/lib/engine/deviceOutput.js +186 -0
- package/lib/engine/engineV1.js +480 -0
- package/lib/engine/engineV2.js +719 -0
- package/lib/engine/index.js +34 -0
- package/lib/engine/transformBuilderV1.js +111 -0
- package/lib/engine/transformBuilderV2.js +74 -0
- package/lib/expressionService.js +330 -0
- package/lib/math.js +142 -0
- package/lib/transform/accumulate.js +98 -0
- package/lib/transform/average.js +56 -0
- package/lib/transform/debounce.js +152 -0
- package/lib/transform/downsample.js +69 -0
- package/lib/transform/edge.js +34 -0
- package/lib/transform/expression.js +91 -0
- package/lib/transform/fallingEdge.js +70 -0
- package/lib/transform/fromBuffer.js +89 -0
- package/lib/transform/hash.js +41 -0
- package/lib/transform/ignoreValue.js +118 -0
- package/lib/transform/index.js +93 -0
- package/lib/transform/invert.js +25 -0
- package/lib/transform/latch.js +99 -0
- package/lib/transform/latchValue.js +115 -0
- package/lib/transform/logicAnd.js +67 -0
- package/lib/transform/logicOr.js +67 -0
- package/lib/transform/map.js +115 -0
- package/lib/transform/max.js +57 -0
- package/lib/transform/maxLength.js +39 -0
- package/lib/transform/min.js +57 -0
- package/lib/transform/minDelta.js +40 -0
- package/lib/transform/offDelay.js +89 -0
- package/lib/transform/onDelay.js +89 -0
- package/lib/transform/patternEscape.js +24 -0
- package/lib/transform/patternMatch.js +194 -0
- package/lib/transform/patternReplace.js +170 -0
- package/lib/transform/patternTest.js +85 -0
- package/lib/transform/rateOfChange.js +56 -0
- package/lib/transform/reject.js +115 -0
- package/lib/transform/resample.js +96 -0
- package/lib/transform/risingEdge.js +90 -0
- package/lib/transform/risingEdgeCounter.js +179 -0
- package/lib/transform/sampleInterval.js +12 -0
- package/lib/transform/source.js +116 -0
- package/lib/transform/state.js +201 -0
- package/lib/transform/threshold.js +52 -0
- package/lib/transform/toBuffer.js +159 -0
- package/lib/transform/toggle.js +118 -0
- package/lib/transform/transformState.js +193 -0
- package/lib/transform/trim.js +27 -0
- package/lib/transform/util/chainSource.js +96 -0
- package/lib/transform/util/ringBuffer.js +34 -0
- package/lib/transform/valueChange.js +34 -0
- package/lib/transform/valueDecrease.js +38 -0
- package/lib/transform/valueIncrease.js +38 -0
- package/lib/transform/valueIncreaseDiff.js +66 -0
- package/lib/transform/whenUnavailable.js +73 -0
- package/lib/transform/windowCount.js +86 -0
- package/lib/util/fileUtil.js +44 -0
- package/package.json +38 -0
- package/test/.eslintrc.json +15 -0
- package/test/chainedTransform.test.js +88 -0
- package/test/conditions.test.js +118 -0
- package/test/config/ab-pccc.test.js +41 -0
- package/test/config/adam-6052.test.js +16 -0
- package/test/config/adapter.test.js +109 -0
- package/test/config/brother-http.test.js +19 -0
- package/test/config/ethernet-ip.test.js +19 -0
- package/test/config/ifm-iot.test.js +20 -0
- package/test/config/json-http.test.js +47 -0
- package/test/config/labjack-t4.test.js +78 -0
- package/test/config/labjack-t7.test.js +18 -0
- package/test/config/labjack-u3.test.js +17 -0
- package/test/config/modbusTcp.test.js +87 -0
- package/test/config/mqtt.test.js +19 -0
- package/test/config/mqttLincoln.test.js +29 -0
- package/test/config/mtconnect.test.js +63 -0
- package/test/config/mtconnectAdapter.test.js +124 -0
- package/test/config/mtconnectHaas.test.js +15 -0
- package/test/config/null.test.js +16 -0
- package/test/config/opcua.test.js +97 -0
- package/test/config-tests.js +102 -0
- package/test/configFiles/conditions.yml +37 -0
- package/test/configFiles/data-items-legacy.yml +24 -0
- package/test/configFiles/data-items-shorthand.yml +14 -0
- package/test/configFiles/data-items.yml +12 -0
- package/test/configFiles/device/ab-pccc-default.yml +3 -0
- package/test/configFiles/device/ab-pccc-full.yml +13 -0
- package/test/configFiles/device/adam-6052-default.yml +2 -0
- package/test/configFiles/device/brother-http-default.yml +3 -0
- package/test/configFiles/device/ethernet-ip-default.yml +2 -0
- package/test/configFiles/device/ifm-iot-default.yml +2 -0
- package/test/configFiles/device/json-http-bad-prop.yml +13 -0
- package/test/configFiles/device/json-http-bad-prop2.yml +13 -0
- package/test/configFiles/device/json-http-default.yml +3 -0
- package/test/configFiles/device/json-http-std.yml +13 -0
- package/test/configFiles/device/labjack-t4-condition-exprs.yaml +46 -0
- package/test/configFiles/device/labjack-t4-default.yml +3 -0
- package/test/configFiles/device/labjack-t4-pins-alt.yaml +41 -0
- package/test/configFiles/device/labjack-t4-pins.yaml +40 -0
- package/test/configFiles/device/labjack-t4-v1.yaml +29 -0
- package/test/configFiles/device/labjack-t7-default.yml +2 -0
- package/test/configFiles/device/labjack-u3-default.yml +2 -0
- package/test/configFiles/device/modbus-partial.yml +4 -0
- package/test/configFiles/device/modbus-std-extended.yaml +23 -0
- package/test/configFiles/device/modbus-std.yaml +34 -0
- package/test/configFiles/device/modbus-tcp-default.yml +3 -0
- package/test/configFiles/device/mqtt-default.yml +2 -0
- package/test/configFiles/device/mqtt-lincoln-default.yml +3 -0
- package/test/configFiles/device/mqtt-lincoln-full.yml +7 -0
- package/test/configFiles/device/mtconnect-adapter-default.yml +3 -0
- package/test/configFiles/device/mtconnect-adapter-keys.yaml +18 -0
- package/test/configFiles/device/mtconnect-complex-keys.yaml +17 -0
- package/test/configFiles/device/mtconnect-default.yml +3 -0
- package/test/configFiles/device/mtconnect-duplicate-allow-keys.yaml +10 -0
- package/test/configFiles/device/mtconnect-duplicate-declare-keys.yaml +8 -0
- package/test/configFiles/device/mtconnect-duplicate-deny-keys.yaml +10 -0
- package/test/configFiles/device/mtconnect-haas-default.yml +3 -0
- package/test/configFiles/device/mtconnect-std.yaml +18 -0
- package/test/configFiles/device/null-default.yml +1 -0
- package/test/configFiles/device/opcua-bad-tag.yml +18 -0
- package/test/configFiles/device/opcua-bad-tag2.yml +18 -0
- package/test/configFiles/device/opcua-default.yml +3 -0
- package/test/configFiles/device/opcua-std.yml +18 -0
- package/test/configFiles/dump-test.yml +11 -0
- package/test/configFiles/expressionCond.yml +46 -0
- package/test/configFiles/min-config-t4.yaml +4 -0
- package/test/configFiles/min-config-u3.yaml +3 -0
- package/test/configFiles/missing-device.yaml +2 -0
- package/test/configFiles/parse-error1.yml +9 -0
- package/test/configFiles/parse-error2.yml +9 -0
- package/test/configFiles/repro/buffer-convert-repro.yml +15 -0
- package/test/configFiles/repro/chained-delay-timing-repro.yml +13 -0
- package/test/configFiles/repro/count-init-repro.yml +45 -0
- package/test/configFiles/repro/cycle-break-repro.yml +44 -0
- package/test/configFiles/repro/debounce-repro.yml +46 -0
- package/test/configFiles/repro/diff-count-repro.yml +34 -0
- package/test/configFiles/repro/engine-hang-repro.yml +9 -0
- package/test/configFiles/repro/latch-apm-repro.yml +26 -0
- package/test/configFiles/repro/lockout-count-repro.yml +33 -0
- package/test/configFiles/repro/program-extract-repro.yml +38 -0
- package/test/configFiles/repro/state-latch-repro.yml +47 -0
- package/test/configFiles/repro/ternary-repro.yml +26 -0
- package/test/configFiles/transform/debounce.yml +12 -0
- package/test/configFiles/transform/expression.yml +34 -0
- package/test/configFiles/transform/ignoreValue.yml +31 -0
- package/test/configFiles/transform/latch.yml +11 -0
- package/test/configFiles/transform/latchValue.yml +31 -0
- package/test/configFiles/transform/logicAnd.yml +14 -0
- package/test/configFiles/transform/logicOr.yml +14 -0
- package/test/configFiles/transform/map.yml +19 -0
- package/test/configFiles/transform/maxLength.yml +13 -0
- package/test/configFiles/transform/offDelay.yml +12 -0
- package/test/configFiles/transform/pattern-escape.yml +10 -0
- package/test/configFiles/transform/pattern-match.yml +57 -0
- package/test/configFiles/transform/pattern-replace.yml +34 -0
- package/test/configFiles/transform/pattern-test.yml +25 -0
- package/test/configFiles/transform/reject.yml +24 -0
- package/test/configFiles/transform/risingEdgeCounter.yml +36 -0
- package/test/configFiles/transform/source.yml +20 -0
- package/test/configFiles/transform/state.yml +56 -0
- package/test/configFiles/transform/toggle.yml +19 -0
- package/test/configFiles/transform/whenUnavailable.yml +19 -0
- package/test/dataFiles/noisy-pulse.txt +11330 -0
- package/test/dataItems.test.js +140 -0
- package/test/engine-v1-tests.js +418 -0
- package/test/engine-v2-tests.js +284 -0
- package/test/expression-tests.js +171 -0
- package/test/expressionService.test.js +154 -0
- package/test/expressionServiceCondition.test.js +130 -0
- package/test/repro/buffer-convert-repro.test.js +38 -0
- package/test/repro/chained-delay-timing-repro.test.js +34 -0
- package/test/repro/count-init-repro.test.js +46 -0
- package/test/repro/cylce-break-repro.test.js +57 -0
- package/test/repro/debounce-repro.test.js +65 -0
- package/test/repro/diff-count-repro.test.js +79 -0
- package/test/repro/engine-hang-repro.test.js +38 -0
- package/test/repro/latch-apm-repro.test.js +119 -0
- package/test/repro/lockout-count-repro.test.js +84 -0
- package/test/repro/program-extract-repro.test.js +40 -0
- package/test/repro/state-latch-repro.test.js +63 -0
- package/test/repro/ternary-repro.test.js +43 -0
- package/test/transform/accumulte.test.js +18 -0
- package/test/transform/average.test.js +22 -0
- package/test/transform/debounce.test.js +70 -0
- package/test/transform/downsample.test.js +30 -0
- package/test/transform/edge.test.js +27 -0
- package/test/transform/expression.test.js +189 -0
- package/test/transform/fallingEdge.test.js +59 -0
- package/test/transform/fromBuffer.test.js +60 -0
- package/test/transform/hash.test.js +34 -0
- package/test/transform/ignoreValue.test.js +123 -0
- package/test/transform/invert.test.js +26 -0
- package/test/transform/latch.test.js +33 -0
- package/test/transform/latchValue.test.js +126 -0
- package/test/transform/logicAnd.test.js +80 -0
- package/test/transform/logicOr.test.js +80 -0
- package/test/transform/map.test.js +42 -0
- package/test/transform/max.test.js +30 -0
- package/test/transform/maxLength.test.js +32 -0
- package/test/transform/min.test.js +30 -0
- package/test/transform/minDelta.test.js +14 -0
- package/test/transform/offDelay.test.js +123 -0
- package/test/transform/onDelay.test.js +105 -0
- package/test/transform/patternEscape.test.js +18 -0
- package/test/transform/patternMatch.test.js +177 -0
- package/test/transform/patternReplace.test.js +95 -0
- package/test/transform/patternTest.test.js +105 -0
- package/test/transform/rateOfChange.test.js +34 -0
- package/test/transform/reject.test.js +56 -0
- package/test/transform/resample.test.js +193 -0
- package/test/transform/risingEdge.test.js +60 -0
- package/test/transform/risingEdgeCounter.test.js +227 -0
- package/test/transform/sampleInterval.test.js +22 -0
- package/test/transform/source.test.js +137 -0
- package/test/transform/state.test.js +248 -0
- package/test/transform/threshold.test.js +78 -0
- package/test/transform/toBuffer.test.js +60 -0
- package/test/transform/toggle.test.js +92 -0
- package/test/transform/trim.test.js +30 -0
- package/test/transform/valueChange.test.js +14 -0
- package/test/transform/valueDecrease.test.js +32 -0
- package/test/transform/valueIncrease.test.js +32 -0
- package/test/transform/valueIncreaseDiff.test.js +32 -0
- package/test/transform/whenUnavailable.test.js +93 -0
- package/test/transform/windowCount.test.js +26 -0
- package/test/util/testUtils.js +405 -0
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EngineV2 = require('../../lib/engine/engineV2');
|
|
4
|
+
const Builder = require('../../lib/engine/transformBuilderV2');
|
|
5
|
+
const testUtils = require('../util/testUtils');
|
|
6
|
+
|
|
7
|
+
describe('repro engine counter lockout example', async function () {
|
|
8
|
+
let config;
|
|
9
|
+
before(async () => {
|
|
10
|
+
config = await testUtils.loadConfig('repro/lockout-count-repro.yml');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('completes successfully', async function () {
|
|
14
|
+
const engine = new EngineV2(config);
|
|
15
|
+
const builder = new Builder(config);
|
|
16
|
+
builder.build(engine);
|
|
17
|
+
|
|
18
|
+
const source = testUtils.valueSource();
|
|
19
|
+
testUtils.attachEngineTransformValidator(engine, null, source);
|
|
20
|
+
|
|
21
|
+
source.sendValue('AIN0', 0, 0);
|
|
22
|
+
source.sendValue('AIN1', 0, 0);
|
|
23
|
+
|
|
24
|
+
source.sendValue('AIN0', 8, 1);
|
|
25
|
+
source.sendValue('AIN1', 0, 1);
|
|
26
|
+
source.sendValue('AIN0', 0, 1);
|
|
27
|
+
|
|
28
|
+
source.sendValue('AIN0', 8, 2);
|
|
29
|
+
source.sendValue('AIN1', 0, 2);
|
|
30
|
+
source.sendValue('AIN0', 0, 2);
|
|
31
|
+
|
|
32
|
+
source.sendValue('AIN0', 8, 3);
|
|
33
|
+
source.sendValue('AIN1', 8, 3);
|
|
34
|
+
source.sendValue('AIN0', 0, 3);
|
|
35
|
+
source.sendValue('AIN1', 0, 3);
|
|
36
|
+
|
|
37
|
+
source.sendValue('AIN0', 8, 4);
|
|
38
|
+
source.sendValue('AIN1', 8, 4);
|
|
39
|
+
source.sendValue('AIN0', 0, 4);
|
|
40
|
+
source.sendValue('AIN1', 0, 4);
|
|
41
|
+
|
|
42
|
+
source.sendValue('AIN0', 8, 5);
|
|
43
|
+
source.sendValue('AIN1', 8, 5);
|
|
44
|
+
source.sendValue('AIN0', 0, 5);
|
|
45
|
+
source.sendValue('AIN1', 0, 5);
|
|
46
|
+
|
|
47
|
+
source.sendValue('AIN0', 0, 6);
|
|
48
|
+
source.sendValue('AIN1', 8, 6);
|
|
49
|
+
source.sendValue('AIN1', 0, 6);
|
|
50
|
+
|
|
51
|
+
source.sendValue('AIN0', 0, 7);
|
|
52
|
+
source.sendValue('AIN1', 8, 7);
|
|
53
|
+
source.sendValue('AIN1', 0, 7);
|
|
54
|
+
|
|
55
|
+
source.sendValue('AIN0', 0, 8);
|
|
56
|
+
source.sendValue('AIN1', 0, 8);
|
|
57
|
+
|
|
58
|
+
source.sendValue('AIN0', 0, 70);
|
|
59
|
+
source.sendValue('AIN1', 8, 70);
|
|
60
|
+
source.sendValue('AIN1', 0, 70);
|
|
61
|
+
|
|
62
|
+
source.sendValue('AIN0', 8, 71);
|
|
63
|
+
source.sendValue('AIN1', 8, 71);
|
|
64
|
+
source.sendValue('AIN0', 0, 71);
|
|
65
|
+
source.sendValue('AIN1', 0, 71);
|
|
66
|
+
|
|
67
|
+
source.sendValue('AIN0', 8, 72);
|
|
68
|
+
source.sendValue('AIN0', 0, 72);
|
|
69
|
+
source.sendValue('AIN1', 0, 72);
|
|
70
|
+
|
|
71
|
+
// engine.printEngineUpdates();
|
|
72
|
+
|
|
73
|
+
engine.validateEngine('part-count', [
|
|
74
|
+
[0, 0],
|
|
75
|
+
[1, 1],
|
|
76
|
+
[2, 2],
|
|
77
|
+
[3, 3],
|
|
78
|
+
[4, 4],
|
|
79
|
+
[5, 5],
|
|
80
|
+
[6, 70],
|
|
81
|
+
[7, 71],
|
|
82
|
+
]);
|
|
83
|
+
});
|
|
84
|
+
});
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EngineV2 = require('../../lib/engine/engineV2');
|
|
4
|
+
const Builder = require('../../lib/engine/transformBuilderV2');
|
|
5
|
+
const testUtils = require('../util/testUtils');
|
|
6
|
+
|
|
7
|
+
describe('repro extract program names', async function () {
|
|
8
|
+
let config;
|
|
9
|
+
before(async () => {
|
|
10
|
+
config = await testUtils.loadConfig('repro/program-extract-repro.yml');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const replayStream = (source) => {
|
|
14
|
+
source.sendValue('part_variant', '45', normalizeTime('2020-08-25T17:48:02.594+00:00'));
|
|
15
|
+
source.sendValue(
|
|
16
|
+
'program_comment',
|
|
17
|
+
'O4745\n(AS475045B326M.BW1)\n(DNCIDAS475045B326M.BW1) \n(ALPHATEC*15005-04-075-XXX-SHANK)\n(VER.1)\n(MAIN*SPINDLE)\n',
|
|
18
|
+
normalizeTime('2020-08-25T17:48:02.594+00:00')
|
|
19
|
+
);
|
|
20
|
+
};
|
|
21
|
+
|
|
22
|
+
it('emits extracted program name', async function () {
|
|
23
|
+
const engine = new EngineV2(config);
|
|
24
|
+
const builder = new Builder(config);
|
|
25
|
+
builder.build(engine);
|
|
26
|
+
|
|
27
|
+
const source = testUtils.valueSource();
|
|
28
|
+
testUtils.attachEngineTransformValidator(engine, null, source);
|
|
29
|
+
|
|
30
|
+
replayStream(source);
|
|
31
|
+
|
|
32
|
+
engine.validateEngine('part_name', [
|
|
33
|
+
['15005-04-075-045', normalizeTime('2020-08-25T17:48:02.594+00:00')],
|
|
34
|
+
]);
|
|
35
|
+
});
|
|
36
|
+
});
|
|
37
|
+
|
|
38
|
+
function normalizeTime(time) {
|
|
39
|
+
return Date.parse(time) / 1000.0;
|
|
40
|
+
}
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EngineV2 = require('../../lib/engine/engineV2');
|
|
4
|
+
const Builder = require('../../lib/engine/transformBuilderV2');
|
|
5
|
+
const testUtils = require('../util/testUtils');
|
|
6
|
+
|
|
7
|
+
describe('repro creating a state latch', async function () {
|
|
8
|
+
let config;
|
|
9
|
+
before(async () => {
|
|
10
|
+
config = await testUtils.loadConfig('repro/state-latch-repro.yml');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
it('completes successfully', async function () {
|
|
14
|
+
const engine = new EngineV2(config);
|
|
15
|
+
const builder = new Builder(config);
|
|
16
|
+
builder.build(engine);
|
|
17
|
+
|
|
18
|
+
const source = testUtils.valueSource();
|
|
19
|
+
testUtils.attachEngineTransformValidator(engine, null, source);
|
|
20
|
+
|
|
21
|
+
source.sendValue('AIN0', 0, 0);
|
|
22
|
+
source.sendValue('AIN1', 0, 0);
|
|
23
|
+
source.sendValue('AIN2', 0, 0);
|
|
24
|
+
source.sendValue('AIN3', 0, 0);
|
|
25
|
+
|
|
26
|
+
source.sendValue('AIN0', 8, 1);
|
|
27
|
+
source.sendValue('AIN1', 0, 1);
|
|
28
|
+
source.sendValue('AIN0', 0, 1);
|
|
29
|
+
|
|
30
|
+
source.sendValue('AIN0', 8, 2);
|
|
31
|
+
source.sendValue('AIN1', 0, 2);
|
|
32
|
+
source.sendValue('AIN0', 0, 2);
|
|
33
|
+
|
|
34
|
+
source.sendValue('AIN0', 8, 3);
|
|
35
|
+
source.sendValue('AIN1', 8, 3);
|
|
36
|
+
source.sendValue('AIN0', 0, 3);
|
|
37
|
+
source.sendValue('AIN1', 0, 3);
|
|
38
|
+
|
|
39
|
+
source.sendValue('AIN0', 0, 20);
|
|
40
|
+
source.sendValue('AIN1', 8, 20);
|
|
41
|
+
source.sendValue('AIN1', 0, 20);
|
|
42
|
+
|
|
43
|
+
source.sendValue('AIN0', 8, 21);
|
|
44
|
+
source.sendValue('AIN1', 8, 21);
|
|
45
|
+
source.sendValue('AIN0', 0, 21);
|
|
46
|
+
source.sendValue('AIN1', 0, 21);
|
|
47
|
+
|
|
48
|
+
source.sendValue('AIN0', 8, 22);
|
|
49
|
+
source.sendValue('AIN1', 0, 22);
|
|
50
|
+
source.sendValue('AIN0', 0, 22);
|
|
51
|
+
|
|
52
|
+
// engine.printEngineUpdates();
|
|
53
|
+
|
|
54
|
+
engine.validateEngine('part-count', [
|
|
55
|
+
[0, 0.1],
|
|
56
|
+
[1, 1],
|
|
57
|
+
[2, 2],
|
|
58
|
+
[3, 3],
|
|
59
|
+
[4, 20],
|
|
60
|
+
[5, 21],
|
|
61
|
+
]);
|
|
62
|
+
});
|
|
63
|
+
});
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const EngineV2 = require('../../lib/engine/engineV2');
|
|
4
|
+
const Builder = require('../../lib/engine/transformBuilderV2');
|
|
5
|
+
const testUtils = require('../util/testUtils');
|
|
6
|
+
|
|
7
|
+
describe('repro ternary not triggering', async function () {
|
|
8
|
+
let config;
|
|
9
|
+
before(async () => {
|
|
10
|
+
config = await testUtils.loadConfig('repro/ternary-repro.yml');
|
|
11
|
+
});
|
|
12
|
+
|
|
13
|
+
const replayStream = (source) => {
|
|
14
|
+
source.sendValue('program_comment', 'O1012 \n\n(PART 10464)\n(REV C) \n(SR-32J)\n(04-16-2019)\n', normalizeTime('2020-08-25T17:48:02.594+00:00'));
|
|
15
|
+
};
|
|
16
|
+
|
|
17
|
+
// Tests that a value is returned from the ternary expression with the options are named variables.
|
|
18
|
+
// Previously they were not matched due to being adjacent to a colon
|
|
19
|
+
it('emits result of ternary operation', async function () {
|
|
20
|
+
const engine = new EngineV2(config);
|
|
21
|
+
const builder = new Builder(config);
|
|
22
|
+
builder.build(engine);
|
|
23
|
+
|
|
24
|
+
const source = testUtils.valueSource();
|
|
25
|
+
testUtils.attachEngineTransformValidator(engine, null, source);
|
|
26
|
+
|
|
27
|
+
replayStream(source);
|
|
28
|
+
|
|
29
|
+
engine.validateEngine('parsed_program1', [
|
|
30
|
+
['', normalizeTime('2020-08-25T17:48:02.594+00:00')],
|
|
31
|
+
]);
|
|
32
|
+
engine.validateEngine('parsed_program2', [
|
|
33
|
+
['PART 10464', normalizeTime('2020-08-25T17:48:02.594+00:00')],
|
|
34
|
+
]);
|
|
35
|
+
engine.validateEngine('parsed_program', [
|
|
36
|
+
['PART 10464', normalizeTime('2020-08-25T17:48:02.594+00:00')],
|
|
37
|
+
]);
|
|
38
|
+
});
|
|
39
|
+
});
|
|
40
|
+
|
|
41
|
+
function normalizeTime(time) {
|
|
42
|
+
return Date.parse(time) / 1000.0;
|
|
43
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Accumulate = require('../../lib/transform').accumulate;
|
|
4
|
+
const testUtils = require('../util/testUtils');
|
|
5
|
+
|
|
6
|
+
describe('accumulate transform tests', function () {
|
|
7
|
+
it('accumulate irregular digital', function () {
|
|
8
|
+
const filter = new Accumulate(testUtils.standardBuilderArgs(null, 'test1'));
|
|
9
|
+
testUtils.attachTransformValidator(filter);
|
|
10
|
+
|
|
11
|
+
filter.test([
|
|
12
|
+
[1, 2], [1, 4], [2, 6], [4, 10], [0, 14], [9, 15], [10, 16], [11, 21],
|
|
13
|
+
]);
|
|
14
|
+
filter.validate([
|
|
15
|
+
[1, 2], [2, 4], [4, 6], [8, 10], [8, 14], [17, 15], [27, 16], [38, 21],
|
|
16
|
+
]);
|
|
17
|
+
});
|
|
18
|
+
});
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Average = require('../../lib/transform').average;
|
|
4
|
+
const testUtils = require('../util/testUtils');
|
|
5
|
+
|
|
6
|
+
describe('average transform tests', function () {
|
|
7
|
+
it('average regular 1', function () {
|
|
8
|
+
const filter = new Average(1);
|
|
9
|
+
testUtils.attachTransformValidator(filter);
|
|
10
|
+
|
|
11
|
+
filter.testAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1);
|
|
12
|
+
filter.valdAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('average regular 2', function () {
|
|
16
|
+
const filter = new Average(2);
|
|
17
|
+
testUtils.attachTransformValidator(filter);
|
|
18
|
+
|
|
19
|
+
filter.testAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1);
|
|
20
|
+
filter.valdAnalog([0.5, 2, 4, 6, 8, 5.5, 3, 5, 7, 4], 1);
|
|
21
|
+
});
|
|
22
|
+
});
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Debounce = require('../../lib/transform').debounce;
|
|
4
|
+
const EngineV2 = require('../../lib/engine/engineV2');
|
|
5
|
+
const Builder = require('../../lib/engine/transformBuilderV2');
|
|
6
|
+
const testUtils = require('../util/testUtils');
|
|
7
|
+
|
|
8
|
+
describe('debounce transform tests', function () {
|
|
9
|
+
it('debounce regular 1', function () {
|
|
10
|
+
const filter = new Debounce(1);
|
|
11
|
+
testUtils.attachTransformValidator(filter);
|
|
12
|
+
|
|
13
|
+
filter.testDigital('^_^_^^^_^^^_^___^___^_^_^^^^', 1);
|
|
14
|
+
filter.valdDigital('_____^^^^^^^^^___________^^^', 1, false);
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
it('debounce regular 2', function () {
|
|
18
|
+
const filter = new Debounce(2);
|
|
19
|
+
testUtils.attachTransformValidator(filter);
|
|
20
|
+
|
|
21
|
+
filter.testDigital('^_^_^^^_^^^_^___^___^_^_^^^^__^^^', 1);
|
|
22
|
+
filter.valdDigital('______^^^^^^^^^___________^^^^^^^', 1, false);
|
|
23
|
+
});
|
|
24
|
+
|
|
25
|
+
it('debounce irregular', function () {
|
|
26
|
+
const filter = new Debounce(1);
|
|
27
|
+
testUtils.attachTransformValidator(filter);
|
|
28
|
+
|
|
29
|
+
filter.test([
|
|
30
|
+
[true, 1], [false, 2], [true, 3], [false, 4], [true, 5], [false, 8], [true, 9], [false, 12], [true, 13],
|
|
31
|
+
[false, 14], [true, 17], [false, 18], [true, 21], [false, 22], [true, 23], [false, 24], [true, 25],
|
|
32
|
+
]);
|
|
33
|
+
filter.validate([
|
|
34
|
+
[false, 1], [false, 2], [false, 3], [false, 4], [false, 5],
|
|
35
|
+
[true, 6], [true, 8], [true, 9], [true, 12], [true, 13],
|
|
36
|
+
[true, 14], [false, 15], [false, 17], [false, 18], [false, 21],
|
|
37
|
+
[false, 22], [false, 23], [false, 24], [false, 25],
|
|
38
|
+
]);
|
|
39
|
+
});
|
|
40
|
+
});
|
|
41
|
+
|
|
42
|
+
describe('debounce transform full engine tests', function () {
|
|
43
|
+
let config;
|
|
44
|
+
before(async () => {
|
|
45
|
+
config = await testUtils.loadConfig('transform/debounce.yml');
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
it('handles engine probe', function () {
|
|
49
|
+
const engine = new EngineV2(config);
|
|
50
|
+
const builder = new Builder(config);
|
|
51
|
+
builder.build(engine);
|
|
52
|
+
|
|
53
|
+
const source = testUtils.valueSource();
|
|
54
|
+
testUtils.attachEngineTransformValidator(engine, engine.variablePool.var1, source);
|
|
55
|
+
|
|
56
|
+
source.sendValues('active', [[false, 0], [true, 2], [false, 4], [true, 10], [false, 12]]);
|
|
57
|
+
source.probe(15);
|
|
58
|
+
source.probe(18);
|
|
59
|
+
source.sendValue('active', true, 18);
|
|
60
|
+
source.sendValue('active', false, 24);
|
|
61
|
+
source.sendValues('active', [[true, 26], [false, 28], [true, 30]]);
|
|
62
|
+
|
|
63
|
+
engine.validateFilter([
|
|
64
|
+
[false, 0], [false, 2], [false, 4], [false, 10], [false, 12],
|
|
65
|
+
[false, 18],
|
|
66
|
+
[true, 23], [true, 24],
|
|
67
|
+
[true, 26], [true, 28], [true, 30],
|
|
68
|
+
]);
|
|
69
|
+
});
|
|
70
|
+
});
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Downsample = require('../../lib/transform').downsample;
|
|
4
|
+
const testUtils = require('../util/testUtils');
|
|
5
|
+
|
|
6
|
+
describe('downsample transform tests', function () {
|
|
7
|
+
it('downsample regular 2', function () {
|
|
8
|
+
const filter = new Downsample(2);
|
|
9
|
+
testUtils.attachTransformValidator(filter);
|
|
10
|
+
|
|
11
|
+
filter.testAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1);
|
|
12
|
+
filter.valdAnalog([3, 7, 2, 6, 0], 2);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('downsample regular 2.25', function () {
|
|
16
|
+
const filter = new Downsample(2.25);
|
|
17
|
+
testUtils.attachTransformValidator(filter);
|
|
18
|
+
|
|
19
|
+
filter.testAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1);
|
|
20
|
+
filter.valdAnalog([3.5, 8, 3.5, 8], 2.25);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('downsample regular 3', function () {
|
|
24
|
+
const filter = new Downsample(3);
|
|
25
|
+
testUtils.attachTransformValidator(filter);
|
|
26
|
+
|
|
27
|
+
filter.testAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1);
|
|
28
|
+
filter.valdAnalog([5, 2, 8], 3);
|
|
29
|
+
});
|
|
30
|
+
});
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const Edge = require('../../lib/transform').edge;
|
|
4
|
+
const testUtils = require('../util/testUtils');
|
|
5
|
+
|
|
6
|
+
describe('edge transform tests', function () {
|
|
7
|
+
it('edge regular', function () {
|
|
8
|
+
const filter = new Edge();
|
|
9
|
+
testUtils.attachTransformValidator(filter);
|
|
10
|
+
|
|
11
|
+
filter.testDigital('__^^__^^^^____^_^^^^^_', 1);
|
|
12
|
+
filter.valdDigital('__|_|_|___|___|||____|', 1);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('edge irregular', function () {
|
|
16
|
+
const filter = new Edge();
|
|
17
|
+
testUtils.attachTransformValidator(filter);
|
|
18
|
+
|
|
19
|
+
filter.test([
|
|
20
|
+
[true, 2], [false, 4], [true, 6], [false, 10], [true, 14], [false, 15], [true, 16], [false, 21],
|
|
21
|
+
]);
|
|
22
|
+
filter.validate([
|
|
23
|
+
[true, 2], [false, 2], [true, 4], [false, 4], [true, 6], [false, 6], [true, 10], [false, 10],
|
|
24
|
+
[true, 14], [false, 14], [true, 15], [false, 15], [true, 16], [false, 16], [true, 21], [false, 21],
|
|
25
|
+
]);
|
|
26
|
+
});
|
|
27
|
+
});
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const _ = require('lodash');
|
|
4
|
+
const { expect } = require('chai');
|
|
5
|
+
const EventEmitter = require('eventemitter3');
|
|
6
|
+
const Builder = require('../../lib/engine/transformBuilderV2');
|
|
7
|
+
const Expression = require('../../lib/transform').expression;
|
|
8
|
+
const EngineV2 = require('../../lib/engine/engineV2');
|
|
9
|
+
const testUtils = require('../util/testUtils');
|
|
10
|
+
const math = require('../../lib/math');
|
|
11
|
+
|
|
12
|
+
describe('expression transform tests', function () {
|
|
13
|
+
let config;
|
|
14
|
+
before(async () => {
|
|
15
|
+
config = await testUtils.loadConfig('transform/expression.yml');
|
|
16
|
+
});
|
|
17
|
+
|
|
18
|
+
it('expression regular 1', function () {
|
|
19
|
+
const engine = new EngineV2(config);
|
|
20
|
+
const source = new ValueSource();
|
|
21
|
+
engine.addValueSource(source);
|
|
22
|
+
|
|
23
|
+
const filter = new Expression({
|
|
24
|
+
engine,
|
|
25
|
+
path: 'variables.var1.1.expression',
|
|
26
|
+
args: { compiledExpression: math.compile('this + 5') },
|
|
27
|
+
});
|
|
28
|
+
testUtils.attachTransformValidator(filter);
|
|
29
|
+
|
|
30
|
+
filter.testAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1);
|
|
31
|
+
filter.valdAnalog([6, 8, 10, 12, 14, 7, 9, 11, 13, 5], 1);
|
|
32
|
+
});
|
|
33
|
+
|
|
34
|
+
it('expression regular 2', function () {
|
|
35
|
+
const engine = new EngineV2(config);
|
|
36
|
+
const source = new ValueSource();
|
|
37
|
+
engine.addValueSource(source);
|
|
38
|
+
|
|
39
|
+
source.sendValue('counter', 0, 0);
|
|
40
|
+
|
|
41
|
+
const filter = new Expression({
|
|
42
|
+
engine,
|
|
43
|
+
path: 'variables.var2.1.expression',
|
|
44
|
+
args: { compiledExpression: math.compile('this > 5 ? 0 : this + counter') },
|
|
45
|
+
});
|
|
46
|
+
testUtils.attachTransformValidator(filter);
|
|
47
|
+
|
|
48
|
+
filter.testAnalog([1, 3, 5, 7, 9, 2, 4, 6, 8, 0], 1, 0, {
|
|
49
|
+
itemPreProcess: (value, time) => { engine.getState('counter').value = time; },
|
|
50
|
+
});
|
|
51
|
+
filter.valdAnalog([1, 4, 7, 0, 0, 7, 10, 0, 0, 9], 1);
|
|
52
|
+
});
|
|
53
|
+
|
|
54
|
+
// NB: An expression filter can accept and emit any type, and is not type-checkable.
|
|
55
|
+
it('expression irregular', function () {
|
|
56
|
+
const engine = new EngineV2(config);
|
|
57
|
+
const source = new ValueSource();
|
|
58
|
+
engine.addValueSource(source);
|
|
59
|
+
|
|
60
|
+
source.sendValue('counter', 0, 0);
|
|
61
|
+
|
|
62
|
+
const filter = new Expression({
|
|
63
|
+
engine,
|
|
64
|
+
path: 'variables.var3.1.expression',
|
|
65
|
+
args: { compiledExpression: math.compile('counter + 10') },
|
|
66
|
+
});
|
|
67
|
+
testUtils.attachTransformValidator(filter);
|
|
68
|
+
|
|
69
|
+
filter.test([
|
|
70
|
+
[true, 1], [false, 2], [true, 5], [false, 8], [true, 10], [false, 11], [true, 12], [false, 15], [true, 18],
|
|
71
|
+
], {
|
|
72
|
+
itemPreProcess: (value, time) => { engine.getState('counter').value = time; },
|
|
73
|
+
});
|
|
74
|
+
filter.validate([
|
|
75
|
+
[11, 1], [12, 2], [15, 5], [18, 8], [20, 10], [21, 11], [22, 12], [25, 15], [28, 18],
|
|
76
|
+
]);
|
|
77
|
+
});
|
|
78
|
+
|
|
79
|
+
it('expression arrays', function () {
|
|
80
|
+
const engine = new EngineV2(config);
|
|
81
|
+
const source = new ValueSource();
|
|
82
|
+
engine.addValueSource(source);
|
|
83
|
+
|
|
84
|
+
source.sendValue('counter', [0, 0], 0);
|
|
85
|
+
|
|
86
|
+
const filter = new Expression({
|
|
87
|
+
engine,
|
|
88
|
+
path: 'variables.var3.1.expression',
|
|
89
|
+
args: { compiledExpression: math.compile('sum(this)') },
|
|
90
|
+
});
|
|
91
|
+
testUtils.attachTransformValidator(filter);
|
|
92
|
+
|
|
93
|
+
filter.test([
|
|
94
|
+
[[1, 3], 1], [[4, 6], 2], [[8, 4], 5], [[10, 10], 8], [[10, 11], 10], [[13, 15], 11], [[15, 15], 12],
|
|
95
|
+
[[16, 17], 15], [[20, 25], 18],
|
|
96
|
+
]);
|
|
97
|
+
filter.validate([
|
|
98
|
+
[4, 1], [10, 2], [12, 5], [20, 8], [21, 10], [28, 11], [30, 12], [33, 15], [45, 18],
|
|
99
|
+
]);
|
|
100
|
+
});
|
|
101
|
+
|
|
102
|
+
it('expression as source', function () {
|
|
103
|
+
const engine = new EngineV2(config);
|
|
104
|
+
const builder = new Builder(config);
|
|
105
|
+
builder.build(engine);
|
|
106
|
+
|
|
107
|
+
const source = testUtils.valueSource();
|
|
108
|
+
testUtils.attachEngineTransformValidator(engine, engine.variablePool.var4, source);
|
|
109
|
+
|
|
110
|
+
source.sendValues('xact', [[1, 0], [3, 1], [5, 2], [7, 3], [9, 4], [2, 5], [4, 6], [6, 7], [8, 8], [0, 9]]);
|
|
111
|
+
engine.validateFilter([[6, 0], [8, 1], [10, 2], [12, 3], [14, 4], [7, 5], [9, 6], [11, 7], [13, 8], [5, 9]]);
|
|
112
|
+
});
|
|
113
|
+
|
|
114
|
+
// Expression will silently swallow the eval error and not emit updates
|
|
115
|
+
it('expression as source cant use this', function () {
|
|
116
|
+
const engine = new EngineV2(config);
|
|
117
|
+
const builder = new Builder(config);
|
|
118
|
+
builder.build(engine);
|
|
119
|
+
|
|
120
|
+
const source = testUtils.valueSource();
|
|
121
|
+
testUtils.attachEngineTransformValidator(engine, engine.variablePool.var5, source);
|
|
122
|
+
|
|
123
|
+
source.sendValues('xact', [[1, 0], [3, 1], [5, 2], [7, 3], [9, 4], [2, 5], [4, 6], [6, 7], [8, 8], [0, 9]]);
|
|
124
|
+
expect(engine.variablePool.var5.lastSampleTime).to.eq(9);
|
|
125
|
+
expect(engine.variablePool.var5.lastSuppliedValue).to.eq(0);
|
|
126
|
+
expect(engine.variablePool.var5.available).to.eq(false);
|
|
127
|
+
engine.validateFilter([]);
|
|
128
|
+
});
|
|
129
|
+
|
|
130
|
+
it('expression object key', function () {
|
|
131
|
+
const engine = new EngineV2(config);
|
|
132
|
+
const builder = new Builder(config);
|
|
133
|
+
builder.build(engine);
|
|
134
|
+
|
|
135
|
+
const source = testUtils.valueSource();
|
|
136
|
+
testUtils.attachEngineTransformValidator(engine, engine.variablePool.var6, source);
|
|
137
|
+
|
|
138
|
+
const fill = (n) => {
|
|
139
|
+
return _.times(n).map(i => {
|
|
140
|
+
return [{ foo: i * 2 }, i];
|
|
141
|
+
});
|
|
142
|
+
};
|
|
143
|
+
|
|
144
|
+
source.sendValues('data1', fill(8));
|
|
145
|
+
engine.validateFilter([[5, 0], [7, 1], [9, 2], [11, 3], [13, 4], [15, 5], [17, 6], [19, 7]]);
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
it('expression object sub-key', function () {
|
|
149
|
+
const engine = new EngineV2(config);
|
|
150
|
+
const builder = new Builder(config);
|
|
151
|
+
builder.build(engine);
|
|
152
|
+
|
|
153
|
+
const source = testUtils.valueSource();
|
|
154
|
+
testUtils.attachEngineTransformValidator(engine, engine.variablePool.var7, source);
|
|
155
|
+
|
|
156
|
+
const fill = (n) => {
|
|
157
|
+
return _.times(n).map(i => {
|
|
158
|
+
return [{ foo: { bar: i * 2 }, baz: 'xyz' }, i];
|
|
159
|
+
});
|
|
160
|
+
};
|
|
161
|
+
|
|
162
|
+
source.sendValues('data2', fill(8));
|
|
163
|
+
engine.validateFilter([[5, 0], [7, 1], [9, 2], [11, 3], [13, 4], [15, 5], [17, 6], [19, 7]]);
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
it('expression object sub-key separated', function () {
|
|
167
|
+
const engine = new EngineV2(config);
|
|
168
|
+
const builder = new Builder(config);
|
|
169
|
+
builder.build(engine);
|
|
170
|
+
|
|
171
|
+
const source = testUtils.valueSource();
|
|
172
|
+
testUtils.attachEngineTransformValidator(engine, engine.variablePool.var8, source);
|
|
173
|
+
|
|
174
|
+
const fill = (n) => {
|
|
175
|
+
return _.times(n).map(i => {
|
|
176
|
+
return [{ foo: { bar: i * 2 }, baz: 'xyz' }, i];
|
|
177
|
+
});
|
|
178
|
+
};
|
|
179
|
+
|
|
180
|
+
source.sendValues('data3', fill(8));
|
|
181
|
+
engine.validateFilter([[5, 0], [7, 1], [9, 2], [11, 3], [13, 4], [15, 5], [17, 6], [19, 7]]);
|
|
182
|
+
});
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
class ValueSource extends EventEmitter {
|
|
186
|
+
sendValue(name, value, time) {
|
|
187
|
+
this.emit('update', name, value, time);
|
|
188
|
+
}
|
|
189
|
+
}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const FallingEdge = require('../../lib/transform').fallingEdge;
|
|
4
|
+
const testUtils = require('../util/testUtils');
|
|
5
|
+
|
|
6
|
+
describe('falling-edge transform tests', function () {
|
|
7
|
+
it('falling-edge regular', function () {
|
|
8
|
+
const filter = new FallingEdge();
|
|
9
|
+
testUtils.attachTransformValidator(filter);
|
|
10
|
+
|
|
11
|
+
filter.testDigital('__^^__^^^^____^_^^^^^_', 1);
|
|
12
|
+
filter.valdDigital('____|_____|____|_____|', 1);
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
it('falling-edge regular high start', function () {
|
|
16
|
+
const filter = new FallingEdge();
|
|
17
|
+
testUtils.attachTransformValidator(filter);
|
|
18
|
+
|
|
19
|
+
filter.testDigital('^^^^__^^^^____^_^^^^^_', 1);
|
|
20
|
+
filter.valdDigital('____|_____|____|_____|', 1);
|
|
21
|
+
});
|
|
22
|
+
|
|
23
|
+
it('falling-edge irregular', function () {
|
|
24
|
+
const filter = new FallingEdge();
|
|
25
|
+
testUtils.attachTransformValidator(filter);
|
|
26
|
+
|
|
27
|
+
filter.test([
|
|
28
|
+
[true, 2], [false, 4], [true, 6], [false, 10], [true, 14], [false, 15], [true, 16], [false, 21],
|
|
29
|
+
]);
|
|
30
|
+
filter.validate([
|
|
31
|
+
[false, 2], [true, 4], [false, 4], [false, 6], [true, 10], [false, 10], [false, 14], [true, 15],
|
|
32
|
+
[false, 15], [false, 16], [true, 21], [false, 21],
|
|
33
|
+
]);
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
it('falling-edge regular min-dwell 3', function () {
|
|
37
|
+
const filter = new FallingEdge({ minDwell: 3 });
|
|
38
|
+
testUtils.attachTransformValidator(filter);
|
|
39
|
+
|
|
40
|
+
filter.testDigital('__^^__^^^^____^_^^^^^___^^^_', 1);
|
|
41
|
+
filter.valdDigital('__________|__________|_____|', 1);
|
|
42
|
+
});
|
|
43
|
+
|
|
44
|
+
it('falling-edge regular max-dwell 3', function () {
|
|
45
|
+
const filter = new FallingEdge({ maxDwell: 3 });
|
|
46
|
+
testUtils.attachTransformValidator(filter);
|
|
47
|
+
|
|
48
|
+
filter.testDigital('__^^__^^^^____^_^^^^^___^^^_', 1);
|
|
49
|
+
filter.valdDigital('____|__________|___________|', 1);
|
|
50
|
+
});
|
|
51
|
+
|
|
52
|
+
it('falling-edge regular dwell 2 3', function () {
|
|
53
|
+
const filter = new FallingEdge({ minDwell: 2, maxDwell: 3 });
|
|
54
|
+
testUtils.attachTransformValidator(filter);
|
|
55
|
+
|
|
56
|
+
filter.testDigital('__^^__^^^^____^_^^^^^___^^^_', 1);
|
|
57
|
+
filter.valdDigital('____|______________________|', 1);
|
|
58
|
+
});
|
|
59
|
+
});
|