@fmsim/machine 1.0.17 → 1.0.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/dist/carrier.js +168 -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/features/mcs-status-default.js +3 -3
- package/dist/features/mcs-status-default.js.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/mcs-carrier-holder.js +20 -111
- package/dist/mcs-carrier-holder.js.map +1 -1
- package/dist/mcs-unit.js +2 -2
- package/dist/mcs-unit.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 +213 -0
- package/src/features/animation-default.ts +27 -0
- package/src/features/mcs-status-default.ts +3 -3
- package/src/index.ts +1 -0
- package/src/mcs-carrier-holder.ts +25 -153
- package/src/mcs-unit.ts +2 -2
- 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
package/dist/carrier.js
ADDED
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
import JSON5 from 'json5';
|
|
2
|
+
import { Component, Shape } from '@hatiolab/things-scene';
|
|
3
|
+
import { ANIMATION_DEFAULT } from './features/animation-default.js';
|
|
4
|
+
import { LEGEND_CARRIER } from './features/mcs-status-default.js';
|
|
5
|
+
import { MCSStatusMixin } from './features/mcs-status-mixin.js';
|
|
6
|
+
const NATURE = {
|
|
7
|
+
mutable: false,
|
|
8
|
+
resizable: false,
|
|
9
|
+
rotatable: false
|
|
10
|
+
};
|
|
11
|
+
export default class Carrier extends MCSStatusMixin(Shape) {
|
|
12
|
+
static get nature() {
|
|
13
|
+
return NATURE;
|
|
14
|
+
}
|
|
15
|
+
get path() {
|
|
16
|
+
const { left, top, width, height } = this.calculateShrunkRectangle(this.parent.bounds);
|
|
17
|
+
return [
|
|
18
|
+
{ x: left, y: top },
|
|
19
|
+
{ x: left + width / 2, y: top },
|
|
20
|
+
{ x: left + width, y: top + height / 2 },
|
|
21
|
+
{ x: left + width, y: top + height },
|
|
22
|
+
{ x: left, y: top + height }
|
|
23
|
+
];
|
|
24
|
+
}
|
|
25
|
+
set path(path) { }
|
|
26
|
+
onchangeData(after, before) {
|
|
27
|
+
var _a;
|
|
28
|
+
const { CARRIERNAME, CARRIERTYPE = '', EMPTYTYPE, CARRIERSTATUS } = this.data || {};
|
|
29
|
+
this.setState('id', CARRIERNAME);
|
|
30
|
+
this.emptyType = EMPTYTYPE;
|
|
31
|
+
this.carrierStatus = CARRIERSTATUS;
|
|
32
|
+
// TODO carrierstatus에 따라서 매핑되는 애니메이션 테마 수행
|
|
33
|
+
if (after.data.CARRIERSTATUS !== ((_a = before.data) === null || _a === void 0 ? void 0 : _a.CARRIERSTATUS)) {
|
|
34
|
+
const { CARRIERSTATUS: lastCarrierStatus } = before.data || {};
|
|
35
|
+
const lastAnimationConfig = lastCarrierStatus && this.getAnimationConfig(lastCarrierStatus);
|
|
36
|
+
if (lastAnimationConfig) {
|
|
37
|
+
let { animation, decorator, border, arrow } = lastAnimationConfig;
|
|
38
|
+
if (animation) {
|
|
39
|
+
;
|
|
40
|
+
this.started = false;
|
|
41
|
+
this._animation = null;
|
|
42
|
+
this.setState('animation', {
|
|
43
|
+
oncreate: null
|
|
44
|
+
});
|
|
45
|
+
}
|
|
46
|
+
if (decorator) {
|
|
47
|
+
this.trigger('iconoff');
|
|
48
|
+
}
|
|
49
|
+
if (border) {
|
|
50
|
+
this.trigger('borderoff');
|
|
51
|
+
}
|
|
52
|
+
if (arrow) {
|
|
53
|
+
this.trigger('bouncingoff');
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
const animationConfig = this.getAnimationConfig(this.carrierStatus);
|
|
57
|
+
if (animationConfig) {
|
|
58
|
+
let { animation, decorator, border, arrow } = animationConfig;
|
|
59
|
+
if (animation) {
|
|
60
|
+
;
|
|
61
|
+
this.started = false;
|
|
62
|
+
this._animation = null;
|
|
63
|
+
this.setState('animation', {
|
|
64
|
+
oncreate: animation
|
|
65
|
+
});
|
|
66
|
+
this.started = true;
|
|
67
|
+
}
|
|
68
|
+
if (decorator) {
|
|
69
|
+
this.trigger('iconoff');
|
|
70
|
+
this.trigger('icon', decorator);
|
|
71
|
+
}
|
|
72
|
+
if (border) {
|
|
73
|
+
this.trigger('borderoff');
|
|
74
|
+
this.trigger('border', border);
|
|
75
|
+
}
|
|
76
|
+
if (arrow) {
|
|
77
|
+
this.trigger('bouncingoff');
|
|
78
|
+
this.trigger('bouncing', arrow);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
get status() {
|
|
84
|
+
return this.emptyType;
|
|
85
|
+
}
|
|
86
|
+
get legend() {
|
|
87
|
+
var _a, _b;
|
|
88
|
+
const { carrierLegendName } = ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.state) || {};
|
|
89
|
+
if (carrierLegendName) {
|
|
90
|
+
return (_b = this.root) === null || _b === void 0 ? void 0 : _b.style[carrierLegendName];
|
|
91
|
+
}
|
|
92
|
+
return LEGEND_CARRIER;
|
|
93
|
+
}
|
|
94
|
+
getAnimationConfig(carrierStatus) {
|
|
95
|
+
const config = this.animationPreset[carrierStatus || 'default'];
|
|
96
|
+
if (config && typeof config == 'string') {
|
|
97
|
+
try {
|
|
98
|
+
return JSON5.parse(config);
|
|
99
|
+
}
|
|
100
|
+
catch (e) {
|
|
101
|
+
console.error(e);
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
else {
|
|
105
|
+
return config || null;
|
|
106
|
+
}
|
|
107
|
+
return null;
|
|
108
|
+
}
|
|
109
|
+
get animationPreset() {
|
|
110
|
+
var _a, _b;
|
|
111
|
+
const { carrierAnimationName } = ((_a = this.parent) === null || _a === void 0 ? void 0 : _a.state) || {};
|
|
112
|
+
if (carrierAnimationName) {
|
|
113
|
+
return ((_b = this.parent.root) === null || _b === void 0 ? void 0 : _b.style[carrierAnimationName]) || ANIMATION_DEFAULT;
|
|
114
|
+
}
|
|
115
|
+
return ANIMATION_DEFAULT;
|
|
116
|
+
}
|
|
117
|
+
calculateShrunkRectangle(originalRect) {
|
|
118
|
+
const shrunkRect = Object.assign({}, originalRect);
|
|
119
|
+
shrunkRect.left = originalRect.width * 0.1;
|
|
120
|
+
shrunkRect.width *= 0.8;
|
|
121
|
+
shrunkRect.top = originalRect.height * 0.1;
|
|
122
|
+
shrunkRect.height *= 0.8;
|
|
123
|
+
return shrunkRect;
|
|
124
|
+
}
|
|
125
|
+
contains(x, y) {
|
|
126
|
+
if (!this.emptyType) {
|
|
127
|
+
return false;
|
|
128
|
+
}
|
|
129
|
+
const rect = this.bounds;
|
|
130
|
+
x -= rect.left;
|
|
131
|
+
y -= rect.top;
|
|
132
|
+
if (x < 0 || y < 0 || x > rect.width || y > rect.height) {
|
|
133
|
+
return false;
|
|
134
|
+
}
|
|
135
|
+
// 윗변 중앙 좌표
|
|
136
|
+
const topCenterX = rect.width / 2;
|
|
137
|
+
const topCenterY = 0;
|
|
138
|
+
// 오른쪽 변 중앙 좌표
|
|
139
|
+
const rightCenterX = rect.width;
|
|
140
|
+
const rightCenterY = rect.height / 2;
|
|
141
|
+
// 기울기 m = (y2 - y1) / (x2 - x1)
|
|
142
|
+
const m = (rightCenterY - topCenterY) / (rightCenterX - topCenterX);
|
|
143
|
+
// y 절편 b = y - mx
|
|
144
|
+
const b = topCenterY - m * topCenterX;
|
|
145
|
+
// 점(px, py)이 선 아래(좌하부)에 있는지 확인
|
|
146
|
+
return y > m * x + b;
|
|
147
|
+
}
|
|
148
|
+
render(ctx) {
|
|
149
|
+
if (!this.emptyType) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
const { width, height } = this.bounds;
|
|
153
|
+
const path = this.path;
|
|
154
|
+
ctx.beginPath();
|
|
155
|
+
ctx.moveTo(path[0].x, path[0].y);
|
|
156
|
+
path.slice(1).forEach(({ x, y }) => {
|
|
157
|
+
ctx.lineTo(x, y);
|
|
158
|
+
});
|
|
159
|
+
ctx.closePath();
|
|
160
|
+
ctx.lineWidth = Math.round(Math.min(width, height) * 0.1) > 5 ? 1 : 0.5;
|
|
161
|
+
ctx.fillStyle = this.statusColor || 'transparent';
|
|
162
|
+
ctx.strokeStyle = this.auxColor || 'transparent';
|
|
163
|
+
ctx.fill();
|
|
164
|
+
ctx.stroke();
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
Component.register('Carrier', Carrier);
|
|
168
|
+
//# sourceMappingURL=carrier.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"carrier.js","sourceRoot":"","sources":["../src/carrier.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAA;AAEzB,OAAO,EAAU,SAAS,EAA6B,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC5F,OAAO,EAAE,iBAAiB,EAAoC,MAAM,iCAAiC,CAAA;AACrG,OAAO,EAAE,cAAc,EAAU,MAAM,kCAAkC,CAAA;AACzE,OAAO,EAAE,cAAc,EAAE,MAAM,gCAAgC,CAAA;AAE/D,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,KAAK;IAChB,SAAS,EAAE,KAAK;CACjB,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,OAAQ,SAAQ,cAAc,CAAC,KAAK,CAAC;IACxD,MAAM,KAAK,MAAM;QACf,OAAO,MAAM,CAAA;IACf,CAAC;IAMD,IAAI,IAAI;QACN,MAAM,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,wBAAwB,CAAC,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,CAAA;QAEtF,OAAO;YACL,EA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olab/things-scene'\nimport { ANIMATION_DEFAULT, AnimationPreset, AnimationConfig } from './features/animation-default.js'\nimport { LEGEND_CARRIER, Legend } from './features/mcs-status-default.js'\nimport { MCSStatusMixin } from './features/mcs-status-mixin.js'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: false,\n rotatable: false\n}\n\nexport default class Carrier extends MCSStatusMixin(Shape) {\n static get nature() {\n return NATURE\n }\n\n id?: string\n emptyType?: 'FULL' | 'EMPTY' | 'EMPTYEMPTY'\n carrierStatus?: string\n\n get path() {\n const { left, top, width, height } = this.calculateShrunkRectangle(this.parent.bounds)\n\n return [\n { x: left, y: top },\n { x: left + width / 2, y: top },\n { x: left + width, y: top + height / 2 },\n { x: left + width, y: top + height },\n { x: left, y: top + height }\n ]\n }\n\n set path(path) {}\n\n onchangeData(after, before) {\n const { CARRIERNAME, CARRIERTYPE = '', EMPTYTYPE, CARRIERSTATUS } = this.data || {}\n\n this.setState('id', CARRIERNAME)\n\n this.emptyType = EMPTYTYPE\n this.carrierStatus = CARRIERSTATUS\n\n // TODO carrierstatus에 따라서 매핑되는 애니메이션 테마 수행\n if (after.data.CARRIERSTATUS !== before.data?.CARRIERSTATUS) {\n const { CARRIERSTATUS: lastCarrierStatus } = before.data || {}\n const lastAnimationConfig = lastCarrierStatus && this.getAnimationConfig(lastCarrierStatus)\n\n if (lastAnimationConfig) {\n let { animation, decorator, border, arrow } = lastAnimationConfig\n if (animation) {\n ;(this as any).started = false\n ;(this as any)._animation = null\n this.setState('animation', {\n oncreate: null\n })\n }\n\n if (decorator) {\n this.trigger('iconoff')\n }\n\n if (border) {\n this.trigger('borderoff')\n }\n\n if (arrow) {\n this.trigger('bouncingoff')\n }\n }\n\n const animationConfig = this.getAnimationConfig(this.carrierStatus)\n\n if (animationConfig) {\n let { animation, decorator, border, arrow } = animationConfig\n if (animation) {\n ;(this as any).started = false\n ;(this as any)._animation = null\n this.setState('animation', {\n oncreate: animation\n })\n ;(this as any).started = true\n }\n\n if (decorator) {\n this.trigger('iconoff')\n this.trigger('icon', decorator)\n }\n\n if (border) {\n this.trigger('borderoff')\n this.trigger('border', border)\n }\n\n if (arrow) {\n this.trigger('bouncingoff')\n this.trigger('bouncing', arrow)\n }\n }\n }\n }\n\n get status() {\n return this.emptyType\n }\n\n get legend(): Legend {\n const { carrierLegendName } = this.parent?.state || {}\n\n if (carrierLegendName) {\n return (this.root as any)?.style[carrierLegendName]\n }\n\n return LEGEND_CARRIER\n }\n\n getAnimationConfig(carrierStatus): AnimationConfig | null {\n const config = this.animationPreset[carrierStatus || 'default']\n\n if (config && typeof config == 'string') {\n try {\n return JSON5.parse(config)\n } catch (e) {\n console.error(e)\n }\n } else {\n return (config as AnimationConfig) || null\n }\n\n return null\n }\n\n get animationPreset(): AnimationPreset {\n const { carrierAnimationName } = this.parent?.state || {}\n\n if (carrierAnimationName) {\n return (this.parent.root as any)?.style[carrierAnimationName] || ANIMATION_DEFAULT\n }\n\n return ANIMATION_DEFAULT\n }\n\n calculateShrunkRectangle(originalRect: BOUNDS): BOUNDS {\n const shrunkRect: BOUNDS = { ...originalRect }\n\n shrunkRect.left = originalRect.width * 0.1\n shrunkRect.width *= 0.8\n\n shrunkRect.top = originalRect.height * 0.1\n shrunkRect.height *= 0.8\n\n return shrunkRect\n }\n\n contains(x, y) {\n if (!this.emptyType) {\n return false\n }\n\n const rect = this.bounds\n x -= rect.left\n y -= rect.top\n\n if (x < 0 || y < 0 || x > rect.width || y > rect.height) {\n return false\n }\n\n // 윗변 중앙 좌표\n const topCenterX = rect.width / 2\n const topCenterY = 0\n\n // 오른쪽 변 중앙 좌표\n const rightCenterX = rect.width\n const rightCenterY = rect.height / 2\n\n // 기울기 m = (y2 - y1) / (x2 - x1)\n const m = (rightCenterY - topCenterY) / (rightCenterX - topCenterX)\n\n // y 절편 b = y - mx\n const b = topCenterY - m * topCenterX\n\n // 점(px, py)이 선 아래(좌하부)에 있는지 확인\n return y > m * x + b\n }\n\n render(ctx: CanvasRenderingContext2D) {\n if (!this.emptyType) {\n return\n }\n\n const { width, height } = this.bounds\n const path = this.path\n\n ctx.beginPath()\n ctx.moveTo(path[0].x, path[0].y)\n\n path.slice(1).forEach(({ x, y }) => {\n ctx.lineTo(x, y)\n })\n\n ctx.closePath()\n\n ctx.lineWidth = Math.round(Math.min(width, height) * 0.1) > 5 ? 1 : 0.5\n ctx.fillStyle = this.statusColor || 'transparent'\n ctx.strokeStyle = this.auxColor || 'transparent'\n\n ctx.fill()\n ctx.stroke()\n }\n}\n\nComponent.register('Carrier', Carrier)\n"]}
|
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export const ANIMATION_DEFAULT = {
|
|
2
|
+
WARN: {
|
|
3
|
+
animation: {
|
|
4
|
+
type: 'vibration',
|
|
5
|
+
duration: 1000,
|
|
6
|
+
theta: 0.3,
|
|
7
|
+
repeat: true
|
|
8
|
+
}
|
|
9
|
+
},
|
|
10
|
+
CRITICAL: {
|
|
11
|
+
animation: {
|
|
12
|
+
type: 'vibration',
|
|
13
|
+
duration: 500,
|
|
14
|
+
theta: 0.5,
|
|
15
|
+
repeat: true
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
default: null
|
|
19
|
+
};
|
|
20
|
+
//# sourceMappingURL=animation-default.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"animation-default.js","sourceRoot":"","sources":["../../src/features/animation-default.ts"],"names":[],"mappings":"AAQA,MAAM,CAAC,MAAM,iBAAiB,GAAoB;IAChD,IAAI,EAAE;QACJ,SAAS,EAAE;YACT,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,IAAI;YACd,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,IAAI;SACb;KACF;IACD,QAAQ,EAAE;QACR,SAAS,EAAE;YACT,IAAI,EAAE,WAAW;YACjB,QAAQ,EAAE,GAAG;YACb,KAAK,EAAE,GAAG;YACV,MAAM,EAAE,IAAI;SACb;KACF;IACD,OAAO,EAAE,IAAI;CACd,CAAA","sourcesContent":["export type AnimationConfig = {\n [key: string]: any\n}\n\nexport interface AnimationPreset {\n [state: string]: AnimationConfig | string | null\n}\n\nexport const ANIMATION_DEFAULT: AnimationPreset = {\n WARN: {\n animation: {\n type: 'vibration',\n duration: 1000,\n theta: 0.3,\n repeat: true\n }\n },\n CRITICAL: {\n animation: {\n type: 'vibration',\n duration: 500,\n theta: 0.5,\n repeat: true\n }\n },\n default: null\n}\n"]}
|
|
@@ -46,9 +46,9 @@ export const LEGEND_CRANE = {
|
|
|
46
46
|
default: '#F0F0F0'
|
|
47
47
|
};
|
|
48
48
|
export const LEGEND_CARRIER = {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
FULL: '#4AA7FE',
|
|
50
|
+
EMPTY: '#8BDA5B',
|
|
51
|
+
EMPTYEMPTY: '#019D59',
|
|
52
52
|
default: '#F0F0F0'
|
|
53
53
|
};
|
|
54
54
|
export const LEGEND_CAPACITY = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcs-status-default.js","sourceRoot":"","sources":["../../src/features/mcs-status-default.ts"],"names":[],"mappings":"AAIA,MAAM,CAAC,MAAM,WAAW,GAAW,EAAE,OAAO,EAAE,SAAS,EAAE,CAAA;AAEzD,MAAM,CAAC,MAAM,cAAc,GAAW;IACpC,MAAM,EAAE,SAAS,EAAE,eAAe;IAClC,MAAM,EAAE,SAAS,EAAE,KAAK;IACxB,MAAM,EAAE,SAAS,EAAE,eAAe;IAClC,MAAM,EAAE,SAAS,EAAE,KAAK;IACxB,MAAM,EAAE,SAAS,EAAE,YAAY;IAC/B,MAAM,EAAE,SAAS,EAAE,OAAO;IAC1B,MAAM,EAAE,SAAS,EAAE,UAAU;IAC7B,MAAM,EAAE,SAAS,EAAE,QAAQ;IAC3B,MAAM,EAAE,SAAS,EAAE,OAAO;IAC1B,OAAO,EAAE,SAAS;CACnB,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAW;IACpC,MAAM,EAAE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n}\n\nexport const LEGEND_NULL: Legend = { default: '#F0F0F0' }\n\nexport const LEGEND_MACHINE: Legend = {\n '1000': '#707070', // DISCONNECTED\n '1001': '#8BDA5B', // UP\n '1002': '#EB3245', // OUTOFSERVICE\n '1003': '#5630D0', // PM\n '1004': '#FFFFFF', // NOTONLINE\n '1005': '#404040', // DOWN\n '1006': '#F4F226', // NOTAUTO\n '1007': '#FD9B00', // ALARM\n '1008': '#4AA7FE', // FULL\n default: '#F0F0F0'\n}\n\nexport const LEGEND_VEHICLE: Legend = {\n '4000': '#EB3245', // OUTOFSERVICE\n '4001': '#8BDA5B', // ASSIGNED\n // '4002': '#cbf266', // ASSIGNED_ACQUIRING\n // '4003': '#cbf266', // ASSIGNED_DEPOSITING\n // '4004': '#cbf266', // ASSIGNED_ENROUTE\n // '4005': '#cbf266', // ASSIGNED_PARKED\n '4006': '#FD9B00', // NOTASSIGNED\n '4007': '#32D1C4', // INSTALLED\n '4008': '#9790EC', // CHARGING\n '4009': '#4AA7FE', // CHARGED\n '4010': '#404040', // REMOVED\n default: '#F0F0F0'\n}\n\nexport const LEGEND_UNIT: Legend = {\n '2000': '#FD9B00', // BANNED\n '2001': '#404040', // DOWN\n '2002': '#8BDA5B', // EMPTY\n '2003': '#FFFFFF', // EMPTY_RESERVED\n '2004': '#32D1C4', // FULL_RESERVED\n '2005': '#4AA7FE', // FULL\n '2006': '#EB3245', // NOTINSERVICE\n default: '#F0F0F0'\n}\n\nexport const LEGEND_CRANE: Legend = {\n '3000': '#EB3245', // OUTOFSERVICE\n // '3001': '#404040', // DOWN\n // '3002': '#8BDA5B', // EMPTY\n '3003': '#FFFFFF', // IDLE\n '3004': '#32D1C4', // ACTIVE\n // '3005': '#4AA7FE', // FULL\n // '3006': '#EB3245', // NOTINSERVICE\n default: '#F0F0F0'\n}\n\nexport const LEGEND_CARRIER: Legend = {\n
|
|
1
|
+
{"version":3,"file":"mcs-status-default.js","sourceRoot":"","sources":["../../src/features/mcs-status-default.ts"],"names":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M,YAAY,GAAW;IAClC,MAAM,EAAE,SAAS,EAAE,eAAe;IAClC,6BAA6B;IAC7B,8BAA8B;IAC9B,MAAM,EAAE,SAAS,EAAE,OAAO;IAC1B,MAAM,EAAE,SAAS,EAAE,SAAS;IAC5B,6BAA6B;IAC7B,qCAAqC;IACrC,OAAO,EAAE,SAAS;CACnB,CAAA;AAED,MAAM,CAAC,MAAM,cAAc,GAAW;IACpC,IAAI,EAAE,SAAS;IACf,KAAK,EAAE,SAAS;IAChB,UAAU,EAAE,SAAS;IACrB,OAAO,EAAE,SAAS;CACnB,CAAA;AAED,MAAM,CAAC,MAAM,eAAe,GAAW;IACrC,MAAM,EAAE,SAAS;IACjB,OAAO,EAAE,SAAS;IAClB,QAAQ,EAAE,SAAS;IACnB,OAAO,EAAE,SAAS;CACnB,CAAA","sourcesContent":["export interface Legend {\n [key: string]: string\n}\n\nexport const LEGEND_NULL: Legend = { default: '#F0F0F0' }\n\nexport const LEGEND_MACHINE: Legend = {\n '1000': '#707070', // DISCONNECTED\n '1001': '#8BDA5B', // UP\n '1002': '#EB3245', // OUTOFSERVICE\n '1003': '#5630D0', // PM\n '1004': '#FFFFFF', // NOTONLINE\n '1005': '#404040', // DOWN\n '1006': '#F4F226', // NOTAUTO\n '1007': '#FD9B00', // ALARM\n '1008': '#4AA7FE', // FULL\n default: '#F0F0F0'\n}\n\nexport const LEGEND_VEHICLE: Legend = {\n '4000': '#EB3245', // OUTOFSERVICE\n '4001': '#8BDA5B', // ASSIGNED\n // '4002': '#cbf266', // ASSIGNED_ACQUIRING\n // '4003': '#cbf266', // ASSIGNED_DEPOSITING\n // '4004': '#cbf266', // ASSIGNED_ENROUTE\n // '4005': '#cbf266', // ASSIGNED_PARKED\n '4006': '#FD9B00', // NOTASSIGNED\n '4007': '#32D1C4', // INSTALLED\n '4008': '#9790EC', // CHARGING\n '4009': '#4AA7FE', // CHARGED\n '4010': '#404040', // REMOVED\n default: '#F0F0F0'\n}\n\nexport const LEGEND_UNIT: Legend = {\n '2000': '#FD9B00', // BANNED\n '2001': '#404040', // DOWN\n '2002': '#8BDA5B', // EMPTY\n '2003': '#FFFFFF', // EMPTY_RESERVED\n '2004': '#32D1C4', // FULL_RESERVED\n '2005': '#4AA7FE', // FULL\n '2006': '#EB3245', // NOTINSERVICE\n default: '#F0F0F0'\n}\n\nexport const LEGEND_CRANE: Legend = {\n '3000': '#EB3245', // OUTOFSERVICE\n // '3001': '#404040', // DOWN\n // '3002': '#8BDA5B', // EMPTY\n '3003': '#FFFFFF', // IDLE\n '3004': '#32D1C4', // ACTIVE\n // '3005': '#4AA7FE', // FULL\n // '3006': '#EB3245', // NOTINSERVICE\n default: '#F0F0F0'\n}\n\nexport const LEGEND_CARRIER: Legend = {\n FULL: '#4AA7FE',\n EMPTY: '#8BDA5B',\n EMPTYEMPTY: '#019D59',\n default: '#F0F0F0'\n}\n\nexport const LEGEND_CAPACITY: Legend = {\n '0~20': '#5630D0',\n '20~80': '#8BDA5B',\n '80~100': '#FD9B00',\n default: '#F0F0F0'\n}\n"]}
|
package/dist/index.js
CHANGED
|
@@ -20,4 +20,5 @@ export { default as Shuttle } from './shuttle';
|
|
|
20
20
|
export { default as Port } from './port';
|
|
21
21
|
export { default as Crane } from './crane';
|
|
22
22
|
export { default as Shelf } from './shelf';
|
|
23
|
+
export { default as Carrier } from './carrier';
|
|
23
24
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAEnD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA","sourcesContent":["export { default as MachineGroups } from './groups'\n\nexport { default as MCSMachine } from './mcs-machine'\nexport { default as MCSUnit } from './mcs-unit'\nexport { default as MCSCarrierHolder } from './mcs-carrier-holder'\nexport { default as MCSVehicle } from './mcs-vehicle'\nexport { default as MCSTransport } from './mcs-transport'\nexport { default as ZoneCapacityBar } from './zone-capacity-bar'\nexport { default as StockerCapacityBar } from './stocker-capacity-bar'\nexport { default as PortFlow } from './port-flow'\n\nexport { default as AGVLine } from './agv-line'\nexport { default as Buffer } from './buffer'\nexport { default as Conveyor } from './conveyor'\nexport { default as ConveyorJoin } from './conveyor-join'\nexport { default as Equipment } from './equipment'\nexport { default as OHTLine } from './oht-line'\nexport { default as Stocker } from './stocker'\n\nexport { default as AGV } from './agv'\nexport { default as OHT } from './oht'\nexport { default as Shuttle } from './shuttle'\n\nexport { default as Port } from './port'\nexport { default as Crane } from './crane'\nexport { default as Shelf } from './shelf'\n"]}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,IAAI,aAAa,EAAE,MAAM,UAAU,CAAA;AAEnD,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAClE,OAAO,EAAE,OAAO,IAAI,UAAU,EAAE,MAAM,eAAe,CAAA;AACrD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAChE,OAAO,EAAE,OAAO,IAAI,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AACtE,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,aAAa,CAAA;AAEjD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,MAAM,EAAE,MAAM,UAAU,CAAA;AAC5C,OAAO,EAAE,OAAO,IAAI,QAAQ,EAAE,MAAM,YAAY,CAAA;AAChD,OAAO,EAAE,OAAO,IAAI,YAAY,EAAE,MAAM,iBAAiB,CAAA;AACzD,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,aAAa,CAAA;AAClD,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,YAAY,CAAA;AAC/C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,OAAO,IAAI,GAAG,EAAE,MAAM,OAAO,CAAA;AACtC,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA;AAE9C,OAAO,EAAE,OAAO,IAAI,IAAI,EAAE,MAAM,QAAQ,CAAA;AACxC,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,KAAK,EAAE,MAAM,SAAS,CAAA;AAC1C,OAAO,EAAE,OAAO,IAAI,OAAO,EAAE,MAAM,WAAW,CAAA","sourcesContent":["export { default as MachineGroups } from './groups'\n\nexport { default as MCSMachine } from './mcs-machine'\nexport { default as MCSUnit } from './mcs-unit'\nexport { default as MCSCarrierHolder } from './mcs-carrier-holder'\nexport { default as MCSVehicle } from './mcs-vehicle'\nexport { default as MCSTransport } from './mcs-transport'\nexport { default as ZoneCapacityBar } from './zone-capacity-bar'\nexport { default as StockerCapacityBar } from './stocker-capacity-bar'\nexport { default as PortFlow } from './port-flow'\n\nexport { default as AGVLine } from './agv-line'\nexport { default as Buffer } from './buffer'\nexport { default as Conveyor } from './conveyor'\nexport { default as ConveyorJoin } from './conveyor-join'\nexport { default as Equipment } from './equipment'\nexport { default as OHTLine } from './oht-line'\nexport { default as Stocker } from './stocker'\n\nexport { default as AGV } from './agv'\nexport { default as OHT } from './oht'\nexport { default as Shuttle } from './shuttle'\n\nexport { default as Port } from './port'\nexport { default as Crane } from './crane'\nexport { default as Shelf } from './shelf'\nexport { default as Carrier } from './carrier'\n"]}
|
|
@@ -1,100 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import
|
|
4
|
-
import MCSUnit from './mcs-unit';
|
|
5
|
-
export class Carrier extends MCSStatusMixin(Object) {
|
|
6
|
-
constructor(host) {
|
|
7
|
-
super();
|
|
8
|
-
this.type = [];
|
|
9
|
-
this.host = host;
|
|
10
|
-
}
|
|
11
|
-
set data(data) {
|
|
12
|
-
const { CARRIERID, CARRIERTYPE = '', EMPTYTYPE } = data || {};
|
|
13
|
-
this.id = CARRIERID;
|
|
14
|
-
this.type = CARRIERTYPE.split(';');
|
|
15
|
-
this.emptyType = EMPTYTYPE;
|
|
16
|
-
}
|
|
17
|
-
get status() {
|
|
18
|
-
return this.emptyType;
|
|
19
|
-
}
|
|
20
|
-
get legend() {
|
|
21
|
-
var _a;
|
|
22
|
-
const { carrierLegendName } = this.host.state;
|
|
23
|
-
if (carrierLegendName) {
|
|
24
|
-
return (_a = this.host.root) === null || _a === void 0 ? void 0 : _a.style[carrierLegendName];
|
|
25
|
-
}
|
|
26
|
-
return LEGEND_CARRIER;
|
|
27
|
-
}
|
|
28
|
-
calculateShrunkRectangle(originalRect) {
|
|
29
|
-
const shrunkRect = Object.assign({}, originalRect);
|
|
30
|
-
shrunkRect.left += originalRect.width * 0.1;
|
|
31
|
-
shrunkRect.width *= 0.8;
|
|
32
|
-
shrunkRect.top += originalRect.height * 0.1;
|
|
33
|
-
shrunkRect.height *= 0.8;
|
|
34
|
-
return shrunkRect;
|
|
35
|
-
}
|
|
36
|
-
isPointOnCarrier(x, y, { left, top, width, height }) {
|
|
37
|
-
const rect = this.calculateShrunkRectangle({ left, top, width, height });
|
|
38
|
-
x -= rect.left;
|
|
39
|
-
y -= rect.top;
|
|
40
|
-
if (x < 0 || y < 0 || x > rect.width || y > rect.height) {
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
// 윗변 중앙 좌표
|
|
44
|
-
const topCenterX = rect.width / 2;
|
|
45
|
-
const topCenterY = 0;
|
|
46
|
-
// 오른쪽 변 중앙 좌표
|
|
47
|
-
const rightCenterX = rect.width;
|
|
48
|
-
const rightCenterY = rect.height / 2;
|
|
49
|
-
// 기울기 m = (y2 - y1) / (x2 - x1)
|
|
50
|
-
const m = (rightCenterY - topCenterY) / (rightCenterX - topCenterX);
|
|
51
|
-
// y 절편 b = y - mx
|
|
52
|
-
const b = topCenterY - m * topCenterX;
|
|
53
|
-
// 점(px, py)이 선 아래(좌하부)에 있는지 확인
|
|
54
|
-
return y > m * x + b;
|
|
55
|
-
}
|
|
56
|
-
render(ctx) {
|
|
57
|
-
if (!this.emptyType) {
|
|
58
|
-
return;
|
|
59
|
-
}
|
|
60
|
-
const { left, top, width, height } = this.calculateShrunkRectangle(this.host.bounds);
|
|
61
|
-
const radius = Math.round(Math.min(width, height) * 0.1);
|
|
62
|
-
// 시작점 설정
|
|
63
|
-
ctx.beginPath();
|
|
64
|
-
ctx.moveTo(left + radius, top);
|
|
65
|
-
// 상단 가로선 그리기
|
|
66
|
-
ctx.lineTo(left + width / 2, top);
|
|
67
|
-
// 우측 세로선 그리기
|
|
68
|
-
ctx.lineTo(left + width, top + height / 2);
|
|
69
|
-
ctx.lineTo(left + width, top + height);
|
|
70
|
-
// 하단 가로선 그리기
|
|
71
|
-
ctx.lineTo(left, top + height);
|
|
72
|
-
// 좌측 세로선 그리기
|
|
73
|
-
ctx.lineTo(left, top);
|
|
74
|
-
// 경로 닫기 및 그리기
|
|
75
|
-
ctx.closePath();
|
|
76
|
-
ctx.lineWidth = radius > 5 ? 1 : 0.5;
|
|
77
|
-
ctx.fillStyle = this.statusColor || 'transparent';
|
|
78
|
-
ctx.strokeStyle = this.auxColor || 'transparent';
|
|
79
|
-
ctx.fill();
|
|
80
|
-
ctx.stroke();
|
|
81
|
-
ctx.beginPath();
|
|
82
|
-
const text = this.emptyType == 'Full' ? 'F' : this.emptyType == 'Empty' ? 'E' : this.emptyType == 'EmptyEmpty' ? 'X' : '';
|
|
83
|
-
if (text) {
|
|
84
|
-
const { x: cx, y: cy } = this.host.center;
|
|
85
|
-
ctx.fillStyle = 'black';
|
|
86
|
-
ctx.font = `normal ${Math.round(radius * 8)}px Arial`;
|
|
87
|
-
ctx.textAlign = 'center';
|
|
88
|
-
ctx.textBaseline = 'middle';
|
|
89
|
-
ctx.fillText(text, cx - width / 8, cy + height / 8);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
92
|
-
}
|
|
1
|
+
import { Model } from '@hatiolab/things-scene';
|
|
2
|
+
import { themesColorMap, themesAnimationMap } from '@fmsim/api';
|
|
3
|
+
import MCSUnit from './mcs-unit.js';
|
|
93
4
|
export default class MCSCarrierHolder extends MCSUnit {
|
|
94
|
-
constructor() {
|
|
95
|
-
super(...arguments);
|
|
96
|
-
this.carrier = new Carrier(this);
|
|
97
|
-
}
|
|
98
5
|
static get properties() {
|
|
99
6
|
return [
|
|
100
7
|
...MCSUnit.properties,
|
|
@@ -105,30 +12,32 @@ export default class MCSCarrierHolder extends MCSUnit {
|
|
|
105
12
|
property: {
|
|
106
13
|
options: themesColorMap
|
|
107
14
|
}
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'select',
|
|
18
|
+
label: 'carrier-animation-name',
|
|
19
|
+
name: 'carrierAnimationName',
|
|
20
|
+
property: {
|
|
21
|
+
options: themesAnimationMap
|
|
22
|
+
}
|
|
108
23
|
}
|
|
109
24
|
];
|
|
110
25
|
}
|
|
111
26
|
ready() {
|
|
27
|
+
super.ready();
|
|
28
|
+
this.carrier = Model.compile({ type: 'Carrier' }, this.root.app);
|
|
112
29
|
this.carrier.data = this.data;
|
|
30
|
+
this.addComponent(this.carrier);
|
|
113
31
|
}
|
|
114
|
-
|
|
115
|
-
this.carrier
|
|
116
|
-
super.
|
|
32
|
+
dispose() {
|
|
33
|
+
this.carrier = null;
|
|
34
|
+
super.dispose();
|
|
117
35
|
}
|
|
118
36
|
onchangeData(after, before) {
|
|
119
|
-
this.carrier
|
|
120
|
-
|
|
121
|
-
}
|
|
122
|
-
isPointOnCarrier(x, y) {
|
|
123
|
-
const { CARRIERID } = this.data || {};
|
|
124
|
-
if (!CARRIERID) {
|
|
125
|
-
return false;
|
|
37
|
+
if (this.carrier) {
|
|
38
|
+
this.carrier.data = this.data;
|
|
126
39
|
}
|
|
127
|
-
|
|
128
|
-
const { left, top, width, height } = this.bounds;
|
|
129
|
-
point.x -= left;
|
|
130
|
-
point.y -= top;
|
|
131
|
-
return this.carrier.isPointOnCarrier(point.x, point.y, { left: 0, top: 0, width, height });
|
|
40
|
+
super.onchangeData(after, before);
|
|
132
41
|
}
|
|
133
42
|
}
|
|
134
43
|
//# sourceMappingURL=mcs-carrier-holder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcs-carrier-holder.js","sourceRoot":"","sources":["../src/mcs-carrier-holder.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"mcs-carrier-holder.js","sourceRoot":"","sources":["../src/mcs-carrier-holder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AAC9C,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,OAAO,MAAM,eAAe,CAAA;AAGnC,MAAM,CAAC,OAAO,OAAO,gBAAiB,SAAQ,OAAO;IACnD,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,OAAO,CAAC,UAAU;YACrB;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,qBAAqB;gBAC5B,IAAI,EAAE,mBAAmB;gBACzB,QAAQ,EAAE;oBACR,OAAO,EAAE,cAAc;iBACxB;aACF;YACD;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,wBAAwB;gBAC/B,IAAI,EAAE,sBAAsB;gBAC5B,QAAQ,EAAE;oBACR,OAAO,EAAE,kBAAkB;iBAC5B;aACF;SACF,CAAA;IACH,CAAC;IAID,KAAK;QACH,KAAK,CAAC,KAAK,EAAE,CAAA;QAEb,IAAI,CAAC,OAAO,GAAG,KAAK,CAAC,OAAO,CAAC,EAAE,IAAI,EAAE,SAAS,EAAE,EAAE,IAAI,CAAC,IAAI,CAAC,GAAG,CAAQ,CAAA;QAEvE,IAAI,CAAC,OAAQ,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QAE9B,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,OAAQ,CAAC,CAAA;IAClC,CAAC;IAED,OAAO;QACL,IAAI,CAAC,OAAO,GAAG,IAAI,CAAA;QAEnB,KAAK,CAAC,OAAO,EAAE,CAAA;IACjB,CAAC;IAED,YAAY,CAAC,KAAU,EAAE,MAAW;QAClC,IAAI,IAAI,CAAC,OAAO,EAAE,CAAC;YACjB,IAAI,CAAC,OAAO,CAAC,IAAI,GAAG,IAAI,CAAC,IAAI,CAAA;QAC/B,CAAC;QAED,KAAK,CAAC,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;IACnC,CAAC;CACF","sourcesContent":["import { Model } from '@hatiolab/things-scene'\nimport { themesColorMap, themesAnimationMap } from '@fmsim/api'\nimport MCSUnit from './mcs-unit.js'\nimport Carrier from './carrier.js'\n\nexport default class MCSCarrierHolder extends MCSUnit {\n static get properties(): any {\n return [\n ...MCSUnit.properties,\n {\n type: 'select',\n label: 'carrier-legend-name',\n name: 'carrierLegendName',\n property: {\n options: themesColorMap\n }\n },\n {\n type: 'select',\n label: 'carrier-animation-name',\n name: 'carrierAnimationName',\n property: {\n options: themesAnimationMap\n }\n }\n ]\n }\n\n carrier?: Carrier | null\n\n ready() {\n super.ready()\n\n this.carrier = Model.compile({ type: 'Carrier' }, this.root.app) as any\n\n this.carrier!.data = this.data\n\n this.addComponent(this.carrier!)\n }\n\n dispose(): void {\n this.carrier = null\n\n super.dispose()\n }\n\n onchangeData(after: any, before: any) {\n if (this.carrier) {\n this.carrier.data = this.data\n }\n\n super.onchangeData(after, before)\n }\n}\n"]}
|
package/dist/mcs-unit.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { ContainerAbstract } from '@hatiolab/things-scene';
|
|
2
2
|
import { getPopupData } from '@fmsim/api';
|
|
3
3
|
import { MCSStatusMixin, MCSStatusMixinProperties } from './features/mcs-status-mixin';
|
|
4
4
|
import { LEGEND_UNIT } from './features/mcs-status-default';
|
|
@@ -6,7 +6,7 @@ import { ParentObjectMixin, ParentObjectMixinProperties } from './features/paren
|
|
|
6
6
|
/**
|
|
7
7
|
* MCS용 Unit들의 공통 속성을 정의한 오브젝트
|
|
8
8
|
*/
|
|
9
|
-
export default class MCSUnit extends MCSStatusMixin(ParentObjectMixin(
|
|
9
|
+
export default class MCSUnit extends MCSStatusMixin(ParentObjectMixin(ContainerAbstract)) {
|
|
10
10
|
static get properties() {
|
|
11
11
|
return [...MCSStatusMixinProperties, ...ParentObjectMixinProperties];
|
|
12
12
|
}
|
package/dist/mcs-unit.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcs-unit.js","sourceRoot":"","sources":["../src/mcs-unit.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"mcs-unit.js","sourceRoot":"","sources":["../src/mcs-unit.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AACrE,OAAO,EAAE,YAAY,EAAE,MAAM,YAAY,CAAA;AAEzC,OAAO,EAAE,cAAc,EAAE,wBAAwB,EAAE,MAAM,6BAA6B,CAAA;AACtF,OAAO,EAAE,WAAW,EAAU,MAAM,+BAA+B,CAAA;AACnE,OAAO,EAAE,iBAAiB,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAA;AAE/F;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,OAAQ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EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAE/B,IAAI,CAAC,EAAE,EAAE,CAAC;YACR,OAAM;QACR,CAAC;QAED,OAAO,MAAM,YAAY,CAAC,IAAI,EAAE,EAAE,CAAC,CAAA;IACrC,CAAC;CACF","sourcesContent":["import { Component, ContainerAbstract } from '@hatiolab/things-scene'\nimport { getPopupData } from '@fmsim/api'\n\nimport { MCSStatusMixin, MCSStatusMixinProperties } from './features/mcs-status-mixin'\nimport { LEGEND_UNIT, Legend } from './features/mcs-status-default'\nimport { ParentObjectMixin, ParentObjectMixinProperties } from './features/parent-object-mixin'\n\n/**\n * MCS용 Unit들의 공통 속성을 정의한 오브젝트\n */\nexport default class MCSUnit extends MCSStatusMixin(ParentObjectMixin(ContainerAbstract)) {\n static get properties(): any {\n return [...MCSStatusMixinProperties, ...ParentObjectMixinProperties]\n }\n\n get hasTextProperty() {\n return true\n }\n\n get reactionDecorators() {\n return ['bouncing-arrow']\n }\n\n get decorators() {\n return ['decotag']\n }\n\n getTheme() {\n const { legendName } = this.state\n\n if (legendName) {\n return (this.root as any)?.style?.[legendName]\n }\n }\n\n get status() {\n return this.data?.STATUS\n }\n\n get auxStatus() {\n return this.data?.STATUS\n }\n\n get legend(): Legend {\n return this.getTheme() || this.getLegendFallback()\n }\n\n get auxLegend() {\n return this.legend\n }\n\n getLegendFallback() {\n return LEGEND_UNIT\n }\n\n contains(x, y) {\n var { left, top, width, height, lineWidth = 0 } = this.state\n var extend = lineWidth / 2\n\n return (\n x < Math.max(left + width, left) + extend &&\n x > Math.min(left + width, left) - extend &&\n y < Math.max(top + height, top) + extend &&\n y > Math.min(top + height, top) - extend\n )\n }\n\n set path(path) {\n var left_top = path[0]\n var right_bottom = path[2]\n\n this.set({\n left: left_top.x,\n top: left_top.y,\n width: right_bottom.x - left_top.x,\n height: right_bottom.y - left_top.y\n })\n }\n\n get path() {\n var { left = 0, top = 0, width = 0, height = 0 } = this.state\n\n return [\n {\n x: left,\n y: top\n },\n {\n x: left + width,\n y: top\n },\n {\n x: left + width,\n y: top + height\n },\n {\n x: left,\n y: top + height\n }\n ]\n }\n\n async detailInfo() {\n const { type, id } = this.state\n\n if (!id) {\n return\n }\n\n return await getPopupData(type, id)\n }\n}\n"]}
|