@things-factory/ccp 8.0.0-beta.8 → 8.0.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/package.json
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
{
|
2
2
|
"name": "@things-factory/ccp",
|
3
|
-
"version": "8.0.0
|
3
|
+
"version": "8.0.0",
|
4
4
|
"main": "dist-server/index.js",
|
5
5
|
"browser": "client/index.js",
|
6
6
|
"things-factory": true,
|
@@ -24,9 +24,9 @@
|
|
24
24
|
"migration:create": "node ../../node_modules/typeorm/cli.js migration:create ./server/migrations/migration"
|
25
25
|
},
|
26
26
|
"dependencies": {
|
27
|
-
"@operato/dataset": "^8.0.0
|
28
|
-
"@things-factory/dataset": "^8.0.0
|
29
|
-
"@things-factory/shell": "^8.0.0
|
27
|
+
"@operato/dataset": "^8.0.0",
|
28
|
+
"@things-factory/dataset": "^8.0.0",
|
29
|
+
"@things-factory/shell": "^8.0.0"
|
30
30
|
},
|
31
|
-
"gitHead": "
|
31
|
+
"gitHead": "07ef27d272dd9a067a9648ac7013748510556a18"
|
32
32
|
}
|
@@ -0,0 +1,88 @@
|
|
1
|
+
import { DataItemSpecSet, DataUseCase, EvaluationResult } from '@things-factory/dataset'
|
2
|
+
|
3
|
+
export class DataUseCaseCCP implements DataUseCase {
|
4
|
+
getSpecification(): DataItemSpecSet {
|
5
|
+
return {
|
6
|
+
name: 'CCP',
|
7
|
+
description: 'Critical Control Point Data Spec',
|
8
|
+
help: '',
|
9
|
+
specs: [
|
10
|
+
{
|
11
|
+
type: 'ccp-limits' /* A value which seperates acceptability from unacceptability */,
|
12
|
+
label: 'critical limits',
|
13
|
+
name: 'criticalLimits'
|
14
|
+
},
|
15
|
+
{
|
16
|
+
type: 'ccp-limits',
|
17
|
+
label: 'target limits',
|
18
|
+
name: 'targetLimits'
|
19
|
+
}
|
20
|
+
]
|
21
|
+
}
|
22
|
+
}
|
23
|
+
|
24
|
+
evaluate(spec: any, values: any | any[]): EvaluationResult {
|
25
|
+
if (!spec || values == null) {
|
26
|
+
return
|
27
|
+
}
|
28
|
+
|
29
|
+
if (!(values instanceof Array)) {
|
30
|
+
values = [values]
|
31
|
+
}
|
32
|
+
|
33
|
+
const {
|
34
|
+
minimum: criticalMinimum,
|
35
|
+
maximum: criticalMaximum,
|
36
|
+
acceptables: criticalAcceptables
|
37
|
+
} = spec['criticalLimits'] || {}
|
38
|
+
|
39
|
+
const {
|
40
|
+
minimum: targetMinimum,
|
41
|
+
maximum: targetMaximum,
|
42
|
+
acceptables: targetAcceptables
|
43
|
+
} = spec['targetLimits'] || {}
|
44
|
+
|
45
|
+
var oos = false
|
46
|
+
var ooc = false
|
47
|
+
|
48
|
+
for (let i = 0; i < values.length; i++) {
|
49
|
+
const value = values[i]
|
50
|
+
|
51
|
+
if (criticalMinimum != null && value < criticalMinimum) {
|
52
|
+
oos = true
|
53
|
+
break
|
54
|
+
}
|
55
|
+
|
56
|
+
if (criticalMaximum != null && value > criticalMaximum) {
|
57
|
+
oos = true
|
58
|
+
break
|
59
|
+
}
|
60
|
+
|
61
|
+
if (criticalAcceptables != null && !criticalAcceptables.includes(value)) {
|
62
|
+
oos = true
|
63
|
+
break
|
64
|
+
}
|
65
|
+
}
|
66
|
+
|
67
|
+
for (let i = 0; i < values.length; i++) {
|
68
|
+
const value = values[i]
|
69
|
+
|
70
|
+
if (targetMinimum != null && value < targetMinimum) {
|
71
|
+
ooc = true
|
72
|
+
break
|
73
|
+
}
|
74
|
+
|
75
|
+
if (targetMaximum != null && value > targetMaximum) {
|
76
|
+
ooc = true
|
77
|
+
break
|
78
|
+
}
|
79
|
+
|
80
|
+
if (targetAcceptables != null && !targetAcceptables.includes(value)) {
|
81
|
+
ooc = true
|
82
|
+
break
|
83
|
+
}
|
84
|
+
}
|
85
|
+
|
86
|
+
return { oos, ooc }
|
87
|
+
}
|
88
|
+
}
|
@@ -0,0 +1 @@
|
|
1
|
+
export * from './data-use-case-ccp'
|
package/server/index.ts
ADDED
@@ -0,0 +1,9 @@
|
|
1
|
+
import { DataUseCase } from '@things-factory/dataset'
|
2
|
+
|
3
|
+
import { DataUseCaseCCP } from './controllers'
|
4
|
+
|
5
|
+
process.on('bootstrap-module-start' as any, async ({ app, config, schema }: any) => {
|
6
|
+
DataUseCase.registerUseCase('CCP', new DataUseCaseCCP())
|
7
|
+
|
8
|
+
console.log('[ccp:bootstrap] CCP has just registered as a DataUseCase.')
|
9
|
+
})
|