@fmsim/machine 1.0.16 → 1.0.18
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/dist/carrier.js +154 -0
- package/dist/carrier.js.map +1 -0
- package/dist/features/animation-default.js +20 -0
- package/dist/features/animation-default.js.map +1 -0
- package/dist/mcs-carrier-holder.js +99 -17
- package/dist/mcs-carrier-holder.js.map +1 -1
- package/dist/port-flow.js +22 -17
- package/dist/port-flow.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +3 -3
- package/src/carrier.ts +202 -0
- package/src/features/animation-default.ts +27 -0
- package/src/mcs-carrier-holder.ts +118 -20
- package/src/port-flow.ts +23 -17
- package/translations/en.json +1 -0
- package/translations/ja.json +1 -0
- package/translations/ko.json +2 -1
- package/translations/ms.json +1 -0
- package/translations/zh.json +1 -0
|
@@ -1,16 +1,20 @@
|
|
|
1
|
+
import JSON5 from 'json5'
|
|
2
|
+
|
|
1
3
|
import { BOUNDS, Component } from '@hatiolab/things-scene'
|
|
2
|
-
import { themesColorMap } from '@fmsim/api'
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import
|
|
4
|
+
import { themesColorMap, themesAnimationMap } from '@fmsim/api'
|
|
5
|
+
import { ANIMATION_DEFAULT, AnimationPreset, AnimationConfig } from './features/animation-default.js'
|
|
6
|
+
import { LEGEND_CARRIER, Legend } from './features/mcs-status-default.js'
|
|
7
|
+
import { MCSStatusMixin } from './features/mcs-status-mixin.js'
|
|
8
|
+
import MCSUnit from './mcs-unit.js'
|
|
6
9
|
|
|
7
10
|
export class Carrier extends MCSStatusMixin(Object) {
|
|
8
11
|
host: Component
|
|
9
12
|
|
|
10
13
|
id?: string
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
+
emptyType?: 'FULL' | 'EMPTY' | 'EMPTYEMPTY'
|
|
15
|
+
carrierStatus?: string
|
|
16
|
+
|
|
17
|
+
lastCarrierStatus?: string
|
|
14
18
|
|
|
15
19
|
constructor(host: Component) {
|
|
16
20
|
super()
|
|
@@ -18,11 +22,71 @@ export class Carrier extends MCSStatusMixin(Object) {
|
|
|
18
22
|
}
|
|
19
23
|
|
|
20
24
|
set data(data: any) {
|
|
21
|
-
const {
|
|
25
|
+
const { CARRIERNAME, CARRIERTYPE = '', EMPTYTYPE, CARRIERSTATUS } = data || {}
|
|
22
26
|
|
|
23
|
-
this.id =
|
|
24
|
-
this.type = CARRIERTYPE.split(';')
|
|
27
|
+
this.id = CARRIERNAME
|
|
25
28
|
this.emptyType = EMPTYTYPE
|
|
29
|
+
this.carrierStatus = CARRIERSTATUS
|
|
30
|
+
|
|
31
|
+
// TODO carrierstatus에 따라서 매핑되는 애니메이션 테마 수행
|
|
32
|
+
if (this.lastCarrierStatus !== this.carrierStatus) {
|
|
33
|
+
const lastAnimationConfig = this.getAnimationConfig(this.lastCarrierStatus)
|
|
34
|
+
const target = this.host as any
|
|
35
|
+
|
|
36
|
+
if (lastAnimationConfig) {
|
|
37
|
+
let { animation, decorator, border, arrow } = lastAnimationConfig
|
|
38
|
+
if (animation) {
|
|
39
|
+
target.started = false
|
|
40
|
+
target._animation = null
|
|
41
|
+
target.setState('animation', {
|
|
42
|
+
oncreate: null
|
|
43
|
+
})
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
if (decorator) {
|
|
47
|
+
target.trigger('iconoff')
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
if (border) {
|
|
51
|
+
target.trigger('borderoff')
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
if (arrow) {
|
|
55
|
+
target.trigger('bouncingoff')
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
const animationConfig = this.getAnimationConfig(this.carrierStatus)
|
|
60
|
+
|
|
61
|
+
if (animationConfig) {
|
|
62
|
+
let { animation, decorator, border, arrow } = animationConfig
|
|
63
|
+
if (animation) {
|
|
64
|
+
target.started = false
|
|
65
|
+
target._animation = null
|
|
66
|
+
target.setState('animation', {
|
|
67
|
+
oncreate: animation
|
|
68
|
+
})
|
|
69
|
+
target.started = true
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
if (decorator) {
|
|
73
|
+
target.trigger('iconoff')
|
|
74
|
+
target.trigger('icon', decorator)
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
if (border) {
|
|
78
|
+
target.trigger('borderoff')
|
|
79
|
+
target.trigger('border', border)
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
if (arrow) {
|
|
83
|
+
target.trigger('bouncingoff')
|
|
84
|
+
target.trigger('bouncing', arrow)
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
this.lastCarrierStatus = this.carrierStatus
|
|
26
90
|
}
|
|
27
91
|
|
|
28
92
|
get status() {
|
|
@@ -39,6 +103,32 @@ export class Carrier extends MCSStatusMixin(Object) {
|
|
|
39
103
|
return LEGEND_CARRIER
|
|
40
104
|
}
|
|
41
105
|
|
|
106
|
+
getAnimationConfig(carrierStatus): AnimationConfig | null {
|
|
107
|
+
const config = this.animationPreset[carrierStatus || 'default']
|
|
108
|
+
|
|
109
|
+
if (config && typeof config == 'string') {
|
|
110
|
+
try {
|
|
111
|
+
return JSON5.parse(config)
|
|
112
|
+
} catch (e) {
|
|
113
|
+
console.error(e)
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
return (config as AnimationConfig) || null
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
return null
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
get animationPreset(): AnimationPreset {
|
|
123
|
+
const { carrierAnimationName } = this.host.state
|
|
124
|
+
|
|
125
|
+
if (carrierAnimationName) {
|
|
126
|
+
return (this.host.root as any)?.style[carrierAnimationName] || ANIMATION_DEFAULT
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
return ANIMATION_DEFAULT
|
|
130
|
+
}
|
|
131
|
+
|
|
42
132
|
calculateShrunkRectangle(originalRect: BOUNDS): BOUNDS {
|
|
43
133
|
const shrunkRect: BOUNDS = { ...originalRect }
|
|
44
134
|
|
|
@@ -116,19 +206,19 @@ export class Carrier extends MCSStatusMixin(Object) {
|
|
|
116
206
|
|
|
117
207
|
ctx.beginPath()
|
|
118
208
|
|
|
119
|
-
const text =
|
|
120
|
-
|
|
209
|
+
// const text =
|
|
210
|
+
// this.emptyType == 'FULL' ? 'F' : this.emptyType == 'EMPTY' ? 'E' : this.emptyType == 'EMPTYEMPTY' ? 'X' : ''
|
|
121
211
|
|
|
122
|
-
if (text) {
|
|
123
|
-
|
|
212
|
+
// if (text) {
|
|
213
|
+
// const { x: cx, y: cy } = this.host.center
|
|
124
214
|
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
215
|
+
// ctx.fillStyle = 'black'
|
|
216
|
+
// ctx.font = `normal ${Math.round(radius * 8)}px Arial`
|
|
217
|
+
// ctx.textAlign = 'center'
|
|
218
|
+
// ctx.textBaseline = 'middle'
|
|
129
219
|
|
|
130
|
-
|
|
131
|
-
}
|
|
220
|
+
// ctx.fillText(text, cx - width / 8, cy + height / 8)
|
|
221
|
+
// }
|
|
132
222
|
}
|
|
133
223
|
}
|
|
134
224
|
|
|
@@ -143,6 +233,14 @@ export default class MCSCarrierHolder extends MCSUnit {
|
|
|
143
233
|
property: {
|
|
144
234
|
options: themesColorMap
|
|
145
235
|
}
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
type: 'select',
|
|
239
|
+
label: 'carrier-animation-name',
|
|
240
|
+
name: 'carrierAnimationName',
|
|
241
|
+
property: {
|
|
242
|
+
options: themesAnimationMap
|
|
243
|
+
}
|
|
146
244
|
}
|
|
147
245
|
]
|
|
148
246
|
}
|
package/src/port-flow.ts
CHANGED
|
@@ -12,7 +12,7 @@ const NATURE: ComponentNature = {
|
|
|
12
12
|
name: 'orientation',
|
|
13
13
|
label: 'orientation',
|
|
14
14
|
property: {
|
|
15
|
-
options: ['left
|
|
15
|
+
options: ['left to right', 'right to left', 'top to bottom', 'bottom to top']
|
|
16
16
|
}
|
|
17
17
|
},
|
|
18
18
|
{
|
|
@@ -28,7 +28,7 @@ const NATURE: ComponentNature = {
|
|
|
28
28
|
name: 'direction',
|
|
29
29
|
label: 'direction',
|
|
30
30
|
property: {
|
|
31
|
-
options: ['
|
|
31
|
+
options: ['IN', 'OUT', 'BOTH']
|
|
32
32
|
}
|
|
33
33
|
}
|
|
34
34
|
]
|
|
@@ -78,19 +78,25 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
get text() {
|
|
81
|
-
const { direction = '
|
|
81
|
+
const { direction = 'IN' } = this.state
|
|
82
82
|
|
|
83
83
|
return direction.toUpperCase()
|
|
84
84
|
}
|
|
85
85
|
|
|
86
86
|
render(ctx) {
|
|
87
87
|
const { left, top, width, height } = this.bounds
|
|
88
|
-
|
|
88
|
+
var { orientation = 'left to right', direction = 'IN' }: { orientation?: string; direction?: string } = this.state
|
|
89
|
+
const { INOUTTYPE } = this.data
|
|
90
|
+
|
|
91
|
+
if (INOUTTYPE) {
|
|
92
|
+
// TODO bothtype value 조정하기.
|
|
93
|
+
direction = INOUTTYPE /* IN | OUT | BOTH */
|
|
94
|
+
}
|
|
89
95
|
|
|
90
96
|
ctx.beginPath()
|
|
91
97
|
|
|
92
98
|
const arrowSize = Math.min(width, height) * 0.3
|
|
93
|
-
const bodyWidth = orientation === 'left
|
|
99
|
+
const bodyWidth = orientation === 'left to right' || orientation === 'right to left' ? height * 0.2 : width * 0.2
|
|
94
100
|
const centerX = left + width / 2
|
|
95
101
|
const centerY = top + height / 2
|
|
96
102
|
|
|
@@ -98,26 +104,26 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
98
104
|
let reverse = 1
|
|
99
105
|
|
|
100
106
|
switch (orientation) {
|
|
101
|
-
case 'left
|
|
107
|
+
case 'left to right':
|
|
102
108
|
startX = left
|
|
103
109
|
endX = left + width
|
|
104
110
|
startY = centerY
|
|
105
111
|
endY = centerY
|
|
106
112
|
break
|
|
107
|
-
case 'right
|
|
113
|
+
case 'right to left':
|
|
108
114
|
startX = left + width
|
|
109
115
|
endX = left
|
|
110
116
|
startY = centerY
|
|
111
117
|
endY = centerY
|
|
112
118
|
reverse = -1
|
|
113
119
|
break
|
|
114
|
-
case 'top
|
|
120
|
+
case 'top to bottom':
|
|
115
121
|
startX = centerX
|
|
116
122
|
endX = centerX
|
|
117
123
|
startY = top
|
|
118
124
|
endY = top + height
|
|
119
125
|
break
|
|
120
|
-
case 'bottom
|
|
126
|
+
case 'bottom to top':
|
|
121
127
|
startX = centerX
|
|
122
128
|
endX = centerX
|
|
123
129
|
startY = top + height
|
|
@@ -129,7 +135,7 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
129
135
|
ctx.lineTo(startX, startY)
|
|
130
136
|
|
|
131
137
|
if (orientation.includes('left')) {
|
|
132
|
-
if (direction === '
|
|
138
|
+
if (direction === 'OUT' || direction === 'BOTH') {
|
|
133
139
|
ctx.lineTo(startX + arrowSize * reverse, startY - bodyWidth * reverse * 2)
|
|
134
140
|
} else {
|
|
135
141
|
ctx.lineTo(startX, startY - bodyWidth * reverse)
|
|
@@ -138,7 +144,7 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
138
144
|
ctx.lineTo(startX + arrowSize * reverse, startY - bodyWidth * reverse)
|
|
139
145
|
ctx.lineTo(endX - arrowSize * reverse, endY - bodyWidth * reverse)
|
|
140
146
|
|
|
141
|
-
if (direction === '
|
|
147
|
+
if (direction === 'IN' || direction === 'BOTH') {
|
|
142
148
|
ctx.lineTo(endX - arrowSize * reverse, endY - bodyWidth * 2 * reverse)
|
|
143
149
|
} else {
|
|
144
150
|
ctx.lineTo(endX, endY - bodyWidth * reverse)
|
|
@@ -146,7 +152,7 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
146
152
|
|
|
147
153
|
ctx.lineTo(endX, endY)
|
|
148
154
|
|
|
149
|
-
if (direction === '
|
|
155
|
+
if (direction === 'IN' || direction === 'BOTH') {
|
|
150
156
|
ctx.lineTo(endX - arrowSize * reverse, endY + bodyWidth * 2 * reverse)
|
|
151
157
|
} else {
|
|
152
158
|
ctx.lineTo(endX, endY + bodyWidth * reverse)
|
|
@@ -155,13 +161,13 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
155
161
|
ctx.lineTo(endX - arrowSize * reverse, endY + bodyWidth * reverse)
|
|
156
162
|
ctx.lineTo(startX + arrowSize * reverse, startY + bodyWidth * reverse)
|
|
157
163
|
|
|
158
|
-
if (direction === '
|
|
164
|
+
if (direction === 'OUT' || direction === 'BOTH') {
|
|
159
165
|
ctx.lineTo(startX + arrowSize * reverse, startY + bodyWidth * 2 * reverse)
|
|
160
166
|
} else {
|
|
161
167
|
ctx.lineTo(startX, startY + bodyWidth * reverse)
|
|
162
168
|
}
|
|
163
169
|
} else {
|
|
164
|
-
if (direction === '
|
|
170
|
+
if (direction === 'OUT' || direction === 'BOTH') {
|
|
165
171
|
ctx.lineTo(startX - bodyWidth * reverse * 2, startY + arrowSize * reverse)
|
|
166
172
|
} else {
|
|
167
173
|
ctx.lineTo(startX - bodyWidth * reverse, startY)
|
|
@@ -170,7 +176,7 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
170
176
|
ctx.lineTo(startX - bodyWidth * reverse, startY + arrowSize * reverse)
|
|
171
177
|
ctx.lineTo(endX - bodyWidth * reverse, endY - arrowSize * reverse)
|
|
172
178
|
|
|
173
|
-
if (direction === '
|
|
179
|
+
if (direction === 'IN' || direction === 'BOTH') {
|
|
174
180
|
ctx.lineTo(endX - bodyWidth * 2 * reverse, endY - arrowSize * reverse)
|
|
175
181
|
} else {
|
|
176
182
|
ctx.lineTo(endX - bodyWidth * reverse, endY)
|
|
@@ -178,7 +184,7 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
178
184
|
|
|
179
185
|
ctx.lineTo(endX, endY)
|
|
180
186
|
|
|
181
|
-
if (direction === '
|
|
187
|
+
if (direction === 'IN' || direction === 'BOTH') {
|
|
182
188
|
ctx.lineTo(endX + bodyWidth * 2 * reverse, endY - arrowSize * reverse)
|
|
183
189
|
} else {
|
|
184
190
|
ctx.lineTo(endX + bodyWidth * reverse, endY)
|
|
@@ -187,7 +193,7 @@ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
|
|
|
187
193
|
ctx.lineTo(endX + bodyWidth * reverse, endY - arrowSize * reverse)
|
|
188
194
|
ctx.lineTo(startX + bodyWidth * reverse, startY + arrowSize * reverse)
|
|
189
195
|
|
|
190
|
-
if (direction === '
|
|
196
|
+
if (direction === 'OUT' || direction === 'BOTH') {
|
|
191
197
|
ctx.lineTo(startX + bodyWidth * 2 * reverse, startY + arrowSize * reverse)
|
|
192
198
|
} else {
|
|
193
199
|
ctx.lineTo(startX + bodyWidth * reverse, startY)
|
package/translations/en.json
CHANGED
|
@@ -4,6 +4,7 @@
|
|
|
4
4
|
"label.high-watermark": "high watermark",
|
|
5
5
|
"label.legend-name": "legend",
|
|
6
6
|
"label.max-capacity": "max capacity",
|
|
7
|
+
"label.carrier-animation-name": "carrier animation",
|
|
7
8
|
"label.carrier-legend-name": "carrier legend",
|
|
8
9
|
"label.sc-state": "sc state",
|
|
9
10
|
"label.full-rate": "full rate",
|
package/translations/ja.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"label.low-watermark": "low watermark",
|
|
6
6
|
"label.legend-name": "legend",
|
|
7
7
|
"label.max-capacity": "max capacity",
|
|
8
|
+
"label.carrier-animation-name": "carrier animation",
|
|
8
9
|
"label.carrier-legend-name": "carrier legend",
|
|
9
10
|
"label.sc-state": "sc state",
|
|
10
11
|
"label.full-rate": "full rate",
|
package/translations/ko.json
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|
"label.low-watermark": "저수위워터마크",
|
|
6
6
|
"label.legend-name": "레전드",
|
|
7
7
|
"label.max-capacity": "최대 용량",
|
|
8
|
-
"label.carrier-
|
|
8
|
+
"label.carrier-animation-name": "캐리어 애니메이션",
|
|
9
|
+
"label.carrier-legend-name": "캐리어 레전드",
|
|
9
10
|
"label.sc-state": "sc state",
|
|
10
11
|
"label.full-rate": "full rate",
|
|
11
12
|
"label.reserved-carrier": "reserved carrier",
|
package/translations/ms.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"label.low-watermark": "low watermark",
|
|
6
6
|
"label.legend-name": "legend",
|
|
7
7
|
"label.max-capacity": "max capacity",
|
|
8
|
+
"label.carrier-animation-name": "carrier animation",
|
|
8
9
|
"label.carrier-legend-name": "carrier legend",
|
|
9
10
|
"label.sc-state": "sc state",
|
|
10
11
|
"label.full-rate": "full rate",
|
package/translations/zh.json
CHANGED
|
@@ -5,6 +5,7 @@
|
|
|
5
5
|
"label.low-watermark": "low watermark",
|
|
6
6
|
"label.legend-name": "legend",
|
|
7
7
|
"label.max-capacity": "max capacity",
|
|
8
|
+
"label.carrier-animation-name": "carrier animation",
|
|
8
9
|
"label.carrier-legend-name": "carrier legend",
|
|
9
10
|
"label.sc-state": "sc state",
|
|
10
11
|
"label.full-rate": "full rate",
|