@operato/scene-manufacturing 1.3.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.
Files changed (53) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/README.md +13 -0
  3. package/assets/favicon.ico +0 -0
  4. package/assets/images/spinner.png +0 -0
  5. package/db.sqlite +0 -0
  6. package/dist/editors/index.d.ts +0 -0
  7. package/dist/editors/index.js +2 -0
  8. package/dist/editors/index.js.map +1 -0
  9. package/dist/groups/index.d.ts +0 -0
  10. package/dist/groups/index.js +2 -0
  11. package/dist/groups/index.js.map +1 -0
  12. package/dist/index.d.ts +1 -0
  13. package/dist/index.js +2 -0
  14. package/dist/index.js.map +1 -0
  15. package/dist/libs/format.d.ts +7 -0
  16. package/dist/libs/format.js +42 -0
  17. package/dist/libs/format.js.map +1 -0
  18. package/dist/tact-timer.d.ts +16 -0
  19. package/dist/tact-timer.js +141 -0
  20. package/dist/tact-timer.js.map +1 -0
  21. package/dist/templates/index.d.ts +17 -0
  22. package/dist/templates/index.js +3 -0
  23. package/dist/templates/index.js.map +1 -0
  24. package/dist/templates/tact-timer.d.ts +17 -0
  25. package/dist/templates/tact-timer.js +18 -0
  26. package/dist/templates/tact-timer.js.map +1 -0
  27. package/helps/scene/component/manufacturing/tact-timer.ja.md +34 -0
  28. package/helps/scene/component/manufacturing/tact-timer.ko.md +34 -0
  29. package/helps/scene/component/manufacturing/tact-timer.md +34 -0
  30. package/helps/scene/component/manufacturing/tact-timer.ms.md +34 -0
  31. package/helps/scene/component/manufacturing/tact-timer.zh.md +34 -0
  32. package/icons/tact-timer.png +0 -0
  33. package/logs/.08636eb59927f12972f6774f5947c8507b3564c2-audit.json +25 -0
  34. package/logs/.5e5d741d8b7784a2fbad65eedc0fd46946aaf6f2-audit.json +15 -0
  35. package/logs/application-2023-12-01-00.log +9 -0
  36. package/logs/application-2023-12-01-01.log +3 -0
  37. package/logs/application-2023-12-01-02.log +1 -0
  38. package/logs/connections-2023-12-01-00.log +41 -0
  39. package/package.json +61 -0
  40. package/schema.graphql +3963 -0
  41. package/src/index.ts +1 -0
  42. package/src/libs/format.ts +47 -0
  43. package/src/tact-timer.ts +184 -0
  44. package/src/templates/index.ts +3 -0
  45. package/src/templates/tact-timer.ts +18 -0
  46. package/things-scene.config.js +5 -0
  47. package/translations/en.json +10 -0
  48. package/translations/ja.json +10 -0
  49. package/translations/ko.json +9 -0
  50. package/translations/ms.json +10 -0
  51. package/translations/zh.json +10 -0
  52. package/tsconfig.json +21 -0
  53. package/tsconfig.tsbuildinfo +1 -0
package/src/index.ts ADDED
@@ -0,0 +1 @@
1
+ export { default as TactTimer } from './tact-timer'
@@ -0,0 +1,47 @@
1
+ /**
2
+ * 문자열 길이를 늘려주는 함수
3
+ *
4
+ * @param {String} i
5
+ * @param {Number} len
6
+ */
7
+ function ii(i: string, len?: number) {
8
+ var s = i
9
+ len = len || 2
10
+ while (s.length < len) s = '0' + s
11
+ return s
12
+ }
13
+
14
+ /**
15
+ * 시간 표시 포맷을 맞추는 함수
16
+ *
17
+ * @param {Number} seconds seconds
18
+ * @param {string} timeFormat hh:mm:ss
19
+ */
20
+ export default function formatTime(seconds = 0, timeFormat = '') {
21
+ var h = 0,
22
+ m = 0,
23
+ s = 0
24
+ var formatted = ''
25
+
26
+ h = Math.floor(seconds / 3600)
27
+ formatted = timeFormat.replace(/(^|[^\\])hh+/g, '$1' + ii(h.toString()))
28
+ formatted = formatted.replace(/(^|[^\\])h/g, '$1' + h)
29
+ if (timeFormat !== formatted) {
30
+ timeFormat = formatted
31
+ seconds %= 3600
32
+ }
33
+
34
+ m = Math.floor(seconds / 60)
35
+ formatted = timeFormat.replace(/(^|[^\\])mm+/g, '$1' + ii(m.toString()))
36
+ formatted = formatted.replace(/(^|[^\\])m/g, '$1' + m)
37
+ if (timeFormat !== formatted) {
38
+ timeFormat = formatted
39
+ seconds %= 60
40
+ }
41
+
42
+ s = seconds
43
+ formatted = timeFormat.replace(/(^|[^\\])ss+/g, '$1' + ii(s.toString()))
44
+ formatted = formatted.replace(/(^|[^\\])s/g, '$1' + s)
45
+
46
+ return formatted
47
+ }
@@ -0,0 +1,184 @@
1
+ /*
2
+ * Copyright © HatioLab Inc. All rights reserved.
3
+ */
4
+
5
+ import { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'
6
+
7
+ import format from './libs/format'
8
+
9
+ const NATURE: ComponentNature = {
10
+ mutable: false,
11
+ resizable: true,
12
+ rotatable: true,
13
+ properties: [
14
+ {
15
+ type: 'number',
16
+ label: 'tact-time',
17
+ name: 'tactTime',
18
+ placeholder: 'seconds'
19
+ },
20
+ {
21
+ type: 'string',
22
+ label: 'format',
23
+ name: 'format',
24
+ placeholder: 'hh:mm:ss'
25
+ },
26
+ {
27
+ type: 'select',
28
+ label: 'progress-direction',
29
+ name: 'progressDirection',
30
+ property: {
31
+ options: ['', 'increase', 'decrease']
32
+ }
33
+ },
34
+ {
35
+ type: 'color',
36
+ label: 'increase-progress-color',
37
+ name: 'increaseProgressColor'
38
+ },
39
+ {
40
+ type: 'color',
41
+ label: 'decrease-progress-color',
42
+ name: 'decreaseProgressColor'
43
+ },
44
+ {
45
+ type: 'color',
46
+ label: 'increase-font-color',
47
+ name: 'increaseFontColor'
48
+ },
49
+ {
50
+ type: 'color',
51
+ label: 'decrese-font-color',
52
+ name: 'decreaseFontColor'
53
+ },
54
+ {
55
+ type: 'boolean',
56
+ label: 'auto-start',
57
+ name: 'autoStart'
58
+ },
59
+ {
60
+ type: 'number',
61
+ label: 'round',
62
+ name: 'round'
63
+ }
64
+ ],
65
+ 'value-property': 'tactTime',
66
+ help: 'scene/component/manufacturing/tact-timer'
67
+ }
68
+
69
+ export default class TactTimer extends RectPath(Shape) {
70
+ private _due?: number
71
+
72
+ get nature() {
73
+ return NATURE
74
+ }
75
+
76
+ ready() {
77
+ if (!this.app.isViewMode) {
78
+ return
79
+ }
80
+
81
+ const { autoStart } = this.state
82
+
83
+ if (autoStart) {
84
+ this.start()
85
+ }
86
+ }
87
+
88
+ start() {
89
+ this._due = Date.now() + this.tactTime * 1000
90
+ this.counting()
91
+ }
92
+
93
+ onchange(after: Properties) {
94
+ if ('tactTime' in after) {
95
+ this.start()
96
+ }
97
+ }
98
+
99
+ counting() {
100
+ // @ts-ignore
101
+ if (this.disposed || this.countdown < -this.tactTime) {
102
+ return
103
+ }
104
+
105
+ requestAnimationFrame(() => {
106
+ const countdown = this.countdown
107
+
108
+ const text = format(Math.abs(countdown), this.getState('format'))
109
+ this.text = text
110
+
111
+ this.setState('data', this.countdown)
112
+
113
+ setTimeout(() => {
114
+ this.counting()
115
+ }, 1000)
116
+ })
117
+ }
118
+
119
+ render(context: CanvasRenderingContext2D) {
120
+ var {
121
+ tactTime,
122
+ top,
123
+ left,
124
+ height,
125
+ width,
126
+ round = 0,
127
+ fontColor,
128
+ increaseFontColor,
129
+ decreaseFontColor,
130
+ increaseProgressColor = 'transparent',
131
+ decreaseProgressColor = 'transparent'
132
+ } = this.state
133
+
134
+ const increase = this.countdown > 0 && this.countdown / tactTime > 0.2
135
+
136
+ // progress의 색상
137
+ context.beginPath()
138
+ context.roundRect(left, top, width, height, round)
139
+ context.clip()
140
+ this.drawFill(context)
141
+
142
+ // value의 색상
143
+ context.beginPath()
144
+
145
+ var progress = Math.abs((this.countdown / tactTime) * 100)
146
+
147
+ if (!isNaN(progress)) {
148
+ progress = width - (width * progress) / 100
149
+ progress = Math.max(Math.min(progress, width), 0)
150
+
151
+ context.rect(left, top, progress, height)
152
+ context.fillStyle = increase ? increaseProgressColor : decreaseProgressColor
153
+ context.fill()
154
+
155
+ context.beginPath()
156
+ }
157
+
158
+ context.roundRect(left, top, width, height)
159
+
160
+ this.setState('fontColor', (increase ? increaseFontColor : decreaseFontColor) || fontColor)
161
+ }
162
+
163
+ postrender(context: CanvasRenderingContext2D) {
164
+ this.drawStroke(context)
165
+ this.drawText(context)
166
+ }
167
+
168
+ get tactTime() {
169
+ return Number(this.getState('tactTime') || 0)
170
+ }
171
+
172
+ set tactTime(tactTime) {
173
+ this.setState('tactTime', Number(tactTime) || 0)
174
+ }
175
+
176
+ get countdown() {
177
+ const due = this._due || 0
178
+ const now = Date.now()
179
+
180
+ return Math.round((due - now) / 1000)
181
+ }
182
+ }
183
+
184
+ Component.register('tact-timer', TactTimer)
@@ -0,0 +1,3 @@
1
+ import tactTimer from './tact-timer'
2
+
3
+ export default [tactTimer]
@@ -0,0 +1,18 @@
1
+ const icon = new URL('../../icons/tact-timer.png', import.meta.url).href
2
+
3
+ export default {
4
+ type: 'tact timer',
5
+ description: 'tact timer',
6
+ group: 'etc' /* line|shape|textAndMedia|chartAndGauge|table|container|dataSource|IoT|3D|warehouse|form|etc */,
7
+ icon,
8
+ model: {
9
+ type: 'tact-timer',
10
+ left: 100,
11
+ top: 100,
12
+ width: 200,
13
+ height: 40,
14
+ fontSize: 80,
15
+ lineWidth: 1,
16
+ round: 10
17
+ }
18
+ }
@@ -0,0 +1,5 @@
1
+ import templates from './dist/templates'
2
+
3
+ export default {
4
+ templates
5
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "label.data-reflection": "data reflection",
3
+ "label.decrease-progress-color": "decrease progress color",
4
+ "label.decrese-font-color": "decrese font color",
5
+ "label.format": "format",
6
+ "label.increase-font-color": "increase font color",
7
+ "label.increase-progress-color": "increase progress color",
8
+ "label.progress-direction": "progress direction",
9
+ "label.tact-time": "tact time"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "label.data-reflection": "data reflection",
3
+ "label.decrease-progress-color": "decrease progress color",
4
+ "label.decrese-font-color": "decrese font color",
5
+ "label.format": "format",
6
+ "label.increase-font-color": "increase font color",
7
+ "label.increase-progress-color": "increase progress color",
8
+ "label.progress-direction": "progress direction",
9
+ "label.tact-time": "tact time"
10
+ }
@@ -0,0 +1,9 @@
1
+ {
2
+ "label.decrease-progress-color": "감소 진행 색상",
3
+ "label.decrese-font-color": "감소 폰트 색상",
4
+ "label.format": "포맷",
5
+ "label.increase-font-color": "증가시 폰트 색상",
6
+ "label.increase-progress-color": "증가시 진행 색상",
7
+ "label.progress-direction": "진행 방향",
8
+ "label.tact-time": "tact time"
9
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "label.data-reflection": "data reflection",
3
+ "label.decrease-progress-color": "decrease progress color",
4
+ "label.decrese-font-color": "decrese font color",
5
+ "label.format": "format",
6
+ "label.increase-font-color": "increase font color",
7
+ "label.increase-progress-color": "increase progress color",
8
+ "label.progress-direction": "progress direction",
9
+ "label.tact-time": "tact time"
10
+ }
@@ -0,0 +1,10 @@
1
+ {
2
+ "label.data-reflection": "data reflection",
3
+ "label.decrease-progress-color": "decrease progress color",
4
+ "label.decrese-font-color": "decrese font color",
5
+ "label.format": "format",
6
+ "label.increase-font-color": "increase font color",
7
+ "label.increase-progress-color": "increase progress color",
8
+ "label.progress-direction": "progress direction",
9
+ "label.tact-time": "tact time"
10
+ }
package/tsconfig.json ADDED
@@ -0,0 +1,21 @@
1
+ {
2
+ "compilerOptions": {
3
+ "target": "es2018",
4
+ "module": "esnext",
5
+ "moduleResolution": "node",
6
+ "noEmitOnError": true,
7
+ "lib": ["es2019", "dom"],
8
+ "strict": true,
9
+ "esModuleInterop": false,
10
+ "allowSyntheticDefaultImports": true,
11
+ "experimentalDecorators": true,
12
+ "importHelpers": true,
13
+ "outDir": "dist",
14
+ "sourceMap": true,
15
+ "inlineSources": true,
16
+ "rootDir": "src",
17
+ "declaration": true,
18
+ "incremental": true
19
+ },
20
+ "include": ["**/*.ts", "*.d.ts"]
21
+ }