@operato/scene-manufacturing 7.3.16 → 7.3.19

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/src/index.ts DELETED
@@ -1 +0,0 @@
1
- export { default as TactTimer } from './tact-timer'
@@ -1,47 +0,0 @@
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
- }
@@ -1,34 +0,0 @@
1
- export const MASK: string = `
2
- <svg id="Layer_1" data-name="Layer 1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" viewBox="0 0 95 23">
3
- <defs>
4
- <style>
5
- .cls-1 {
6
- fill: url(#linear-gradient);
7
- }
8
-
9
- .cls-1, .cls-2 {
10
- stroke-width: 0px;
11
- }
12
-
13
- .cls-2 {
14
- fill: {{fillColor}};
15
- }
16
- </style>
17
- <linearGradient id="linear-gradient" x1="47.4" y1="85.6" x2="47.4" y2="95" gradientTransform="translate(0 -74)" gradientUnits="userSpaceOnUse">
18
- <stop offset="0" stop-color="#000" stop-opacity="0"/>
19
- <stop offset=".9" stop-color="#000" stop-opacity=".2"/>
20
- </linearGradient>
21
- </defs>
22
- <rect class="cls-1" x="1.4" y="11.6" width="92.1" height="9.5" rx="2.6" ry="2.6"/>
23
- <path class="cls-2" d="M95,0H0v23h95V0ZM92.5,17.9c0,1.4-1.2,2.6-2.6,2.6H5.1c-1.4,0-2.6-1.2-2.6-2.6V5.1c0-1.4,1.2-2.6,2.6-2.6h84.8c1.4,0,2.6,1.2,2.6,2.6v12.8Z"/>
24
- <path class="cls-2" d="M47.9,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
25
- <path class="cls-2" d="M38.6,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
26
- <path class="cls-2" d="M29.3,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
27
- <path class="cls-2" d="M19.9,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
28
- <path class="cls-2" d="M11,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
29
- <path class="cls-2" d="M84.9,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
30
- <path class="cls-2" d="M75.6,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
31
- <path class="cls-2" d="M66.4,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
32
- <path class="cls-2" d="M57.2,3.1c0-.6.7-.6.7-.6v-.7h-2.5v.7s.7,0,.7.6v16.7s0,.7-.7.8v.6h2.5v-.6c-.7-.1-.7-.8-.7-.8V3.1Z"/>
33
- </svg>
34
- `
package/src/tact-timer.ts DELETED
@@ -1,320 +0,0 @@
1
- import { Component, ComponentNature, Properties, RectPath, Shape } from '@hatiolab/things-scene'
2
- import format from './libs/format'
3
- import { MASK } from './tact-timer-mask'
4
-
5
- const NATURE: ComponentNature = {
6
- mutable: false,
7
- resizable: true,
8
- rotatable: true,
9
- properties: [
10
- {
11
- type: 'string',
12
- label: 'start-time',
13
- name: 'startTime',
14
- placeholder: 'YYYYMMDDhhmmss'
15
- },
16
- {
17
- type: 'string',
18
- label: 'end-time',
19
- name: 'endTime',
20
- placeholder: 'YYYYMMDDhhmmss'
21
- },
22
- {
23
- type: 'string',
24
- label: 'format',
25
- name: 'format',
26
- placeholder: 'hh:mm:ss'
27
- },
28
- {
29
- type: 'select',
30
- label: 'progress-direction',
31
- name: 'progressDirection',
32
- property: {
33
- options: ['', 'increase', 'decrease']
34
- }
35
- },
36
- {
37
- type: 'color',
38
- label: 'tact-timer-mask-color',
39
- name: 'maskColor'
40
- },
41
- {
42
- type: 'color',
43
- label: 'before-due-progress-color',
44
- name: 'beforeDueProgressColor'
45
- },
46
- {
47
- type: 'color',
48
- label: 'over-due-progress-color',
49
- name: 'overDueProgressColor'
50
- },
51
- {
52
- type: 'color',
53
- label: 'before-due-font-color',
54
- name: 'beforeDueFontColor'
55
- },
56
- {
57
- type: 'color',
58
- label: 'over-due-font-color',
59
- name: 'overDueFontColor'
60
- },
61
- {
62
- type: 'color',
63
- label: 'under-threshold-color',
64
- name: 'underThresholdColor'
65
- },
66
- {
67
- type: 'number',
68
- label: 'progress-threshold',
69
- name: 'progressThreshold',
70
- placeholder: '%'
71
- },
72
- {
73
- type: 'number',
74
- label: 'round',
75
- name: 'round'
76
- },
77
- {
78
- type: 'boolean',
79
- label: 'auto-start',
80
- name: 'autoStart'
81
- },
82
- {
83
- type: 'boolean',
84
- label: 'show-progress',
85
- name: 'showProgress'
86
- },
87
- {
88
- type: 'boolean',
89
- label: 'show-timer',
90
- name: 'showTimer'
91
- }
92
- ],
93
- help: 'scene/component/manufacturing/tact-timer'
94
- }
95
-
96
- export default class TactTimer extends RectPath(Shape) {
97
- private _start: number = 0
98
- private _due: number = 0
99
- private imageElement?: HTMLImageElement
100
-
101
- get nature() {
102
- return NATURE
103
- }
104
-
105
- ready() {
106
- if (!this.app.isViewMode) {
107
- return
108
- }
109
-
110
- const { autoStart, started } = this.state
111
-
112
- if (autoStart || started) {
113
- this.start()
114
- }
115
- }
116
-
117
- start() {
118
- const { startTime, endTime, hidden } = this.state
119
- const start = this.parseTime(startTime)
120
- const end = this.parseTime(endTime)
121
-
122
- if (start && end && !hidden) {
123
- this._due = end.getTime()
124
- this._start = start.getTime()
125
- this.counting()
126
- }
127
- }
128
-
129
- stop() {
130
- this.started = false
131
- }
132
-
133
- onchange(after: Properties) {
134
- if ('startTime' in after || 'endTime' in after || 'hidden' in after) {
135
- this.start()
136
- }
137
-
138
- if ('maskColor' in after) {
139
- delete this.imageElement
140
- }
141
- }
142
-
143
- getImageElement(): HTMLImageElement | undefined {
144
- if (!this.imageElement) {
145
- const { maskColor = 'black' } = this.state
146
-
147
- this.imageElement = new Image()
148
- this.imageElement.src =
149
- 'data:image/svg+xml;charset=UTF-8;base64,' + btoa(MASK.replace(/{{fillColor}}/g, maskColor))
150
- }
151
-
152
- return this.imageElement
153
- }
154
-
155
- counting() {
156
- const { hidden, started } = this.state
157
- if (this.disposed || hidden || !started) {
158
- return
159
- }
160
-
161
- requestAnimationFrame(() => {
162
- const { showTimer, beforeDueFontColor, overDueFontColor, fontColor } = this.state
163
- const countdown = this.countdown
164
-
165
- this.setState('fontColor', (this.countdown > 0 ? beforeDueFontColor : overDueFontColor) || fontColor)
166
-
167
- if (showTimer) {
168
- const text = format(Math.abs(countdown), this.getState('format'))
169
- this.text = text
170
- } else {
171
- this.text = ''
172
- }
173
-
174
- this.setState('data', this.countdown)
175
-
176
- setTimeout(() => {
177
- this.counting()
178
- }, 1000)
179
- })
180
- }
181
-
182
- render(context: CanvasRenderingContext2D) {
183
- var {
184
- top,
185
- left,
186
- height,
187
- width,
188
- round = 0,
189
- fontColor,
190
- maskColor,
191
- beforeDueFontColor,
192
- overDueFontColor,
193
- beforeDueProgressColor = 'transparent',
194
- overDueProgressColor = 'transparent',
195
- underThresholdColor = 'transparent',
196
- progressDirection = 'increase',
197
- progressThreshold = 0,
198
- showProgress
199
- } = this.state
200
-
201
- const increase = this.countdown > 0
202
- const totalDuration = (this._due - this._start) / 1000
203
- const underThreshold = this.countdown / totalDuration < progressThreshold / 100
204
-
205
- // progress의 색상
206
- context.beginPath()
207
- context.roundRect(left, top, width, height, round)
208
- context.clip()
209
- this.drawFill(context)
210
-
211
- // value의 색상
212
- context.beginPath()
213
-
214
- if (!showProgress) {
215
- return
216
- }
217
-
218
- var progress = Math.abs((this.countdown / totalDuration) * 100)
219
-
220
- if (!isNaN(progress)) {
221
- progress = width - (width * progress) / 100
222
- progress = Math.max(Math.min(progress, width), 0)
223
-
224
- if (progressDirection == 'increase') {
225
- context.rect(left, top, progress, height)
226
- } else {
227
- context.rect(left + progress, top, width - progress, height)
228
- }
229
-
230
- context.fillStyle = increase
231
- ? underThreshold
232
- ? underThresholdColor
233
- : beforeDueProgressColor
234
- : overDueProgressColor
235
- context.fill()
236
-
237
- context.beginPath()
238
- }
239
-
240
- const image = this.getImageElement()
241
- this.drawImage(context, image!, left - 2, top - 2, width + 4, height + 4)
242
-
243
- context.roundRect(left, top, width, height, round)
244
-
245
- this.setState('fontColor', (increase ? beforeDueFontColor : overDueFontColor) || fontColor)
246
- }
247
-
248
- postrender(context: CanvasRenderingContext2D) {
249
- this.drawStroke(context)
250
- this.drawText(context)
251
- }
252
-
253
- parseTime(timeString: string): Date | undefined {
254
- if (!timeString || timeString.length !== 14) {
255
- return undefined
256
- }
257
- const year = parseInt(timeString.slice(0, 4), 10)
258
- const month = parseInt(timeString.slice(4, 6), 10) - 1
259
- const day = parseInt(timeString.slice(6, 8), 10)
260
- const hour = parseInt(timeString.slice(8, 10), 10)
261
- const minute = parseInt(timeString.slice(10, 12), 10)
262
- const second = parseInt(timeString.slice(12, 14), 10)
263
-
264
- return new Date(year, month, day, hour, minute, second)
265
- }
266
-
267
- get countdown(): number {
268
- const due = this._due || 0
269
- const now = Date.now()
270
-
271
- return Math.round((due - now) / 1000)
272
- }
273
-
274
- get value() {
275
- const { startTime, endTime } = this.state
276
- return [startTime, endTime]
277
- }
278
-
279
- set value(v) {
280
- if (v instanceof Array) {
281
- const [startTime, endTime] = v
282
- this.setState({
283
- startTime,
284
- endTime
285
- })
286
- } else if (typeof v == 'object') {
287
- const { startTime, endTime } = v
288
- this.setState({
289
- startTime,
290
- endTime
291
- })
292
- } else if (typeof v == 'string') {
293
- const [startTime, endTime] = (v as string).split(/[-+/%$#_,]+/)
294
- this.setState({
295
- startTime,
296
- endTime
297
- })
298
- } else {
299
- this.setState({
300
- startTime: undefined,
301
- endTime: undefined
302
- })
303
- }
304
- }
305
-
306
- get started() {
307
- return this.getState('started')
308
- }
309
-
310
- set started(started) {
311
- if (this.started !== started) {
312
- this.setState('started', started)
313
- if (started) {
314
- this.start()
315
- }
316
- }
317
- }
318
- }
319
-
320
- Component.register('tact-timer', TactTimer)
@@ -1,3 +0,0 @@
1
- import tactTimer from './tact-timer'
2
-
3
- export default [tactTimer]
@@ -1,27 +0,0 @@
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
- showProgress: true,
18
- showTimer: true,
19
- progressDirection: 'decrease',
20
- increaseProgressColor: 'green',
21
- decreaseProgressColor: 'red',
22
- increaseFontColor: 'navy',
23
- decreaseFontColor: 'orange',
24
- underThresholdColor: 'yellow',
25
- progressThreshold: 30
26
- }
27
- }
package/tsconfig.json DELETED
@@ -1,22 +0,0 @@
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
- "allowJs": true,
11
- "allowSyntheticDefaultImports": true,
12
- "experimentalDecorators": true,
13
- "importHelpers": true,
14
- "outDir": "dist",
15
- "sourceMap": true,
16
- "inlineSources": true,
17
- "rootDir": "src",
18
- "declaration": true,
19
- "incremental": true
20
- },
21
- "include": ["**/*.ts", "*.d.ts"]
22
- }