@fmsim/machine 1.0.10 → 1.0.12

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.
@@ -0,0 +1,203 @@
1
+ import { Component, ComponentNature, RectPath, Shape } from '@hatiolab/things-scene'
2
+ import { ParentObjectMixin, ParentObjectMixinProperties } from './features/parent-object-mixin'
3
+
4
+ const NATURE: ComponentNature = {
5
+ mutable: false,
6
+ resizable: true,
7
+ rotatable: true,
8
+ properties: [
9
+ ...ParentObjectMixinProperties,
10
+ {
11
+ type: 'select',
12
+ name: 'orientation',
13
+ label: 'orientation',
14
+ property: {
15
+ options: ['left-right', 'right-left', 'top-bottom', 'bottom-top']
16
+ }
17
+ },
18
+ {
19
+ type: 'select',
20
+ name: 'labelPosition',
21
+ label: 'label-position',
22
+ property: {
23
+ options: ['left', 'right', 'top', 'bottom']
24
+ }
25
+ },
26
+ {
27
+ type: 'select',
28
+ name: 'direction',
29
+ label: 'direction',
30
+ property: {
31
+ options: ['in', 'out', 'inout']
32
+ }
33
+ }
34
+ ]
35
+ }
36
+
37
+ export default class PortFlow extends ParentObjectMixin(RectPath(Shape)) {
38
+ static get nature() {
39
+ return NATURE
40
+ }
41
+
42
+ get textBounds() {
43
+ const { left, top, width, height } = this.bounds
44
+ const { labelPosition = 'top' } = this.state
45
+
46
+ switch (labelPosition) {
47
+ case 'top':
48
+ return {
49
+ ...this.bounds,
50
+ top: top - 24,
51
+ height: 24
52
+ }
53
+ case 'bottom':
54
+ return {
55
+ ...this.bounds,
56
+ top: top + height,
57
+ height: 24
58
+ }
59
+ case 'left':
60
+ return {
61
+ ...this.bounds,
62
+ left: left - 60,
63
+ width: 60
64
+ }
65
+ case 'right':
66
+ return {
67
+ ...this.bounds,
68
+ left: left + width,
69
+ width: 60
70
+ }
71
+ default:
72
+ return {
73
+ ...this.bounds,
74
+ top: top - 24,
75
+ height: 24
76
+ }
77
+ }
78
+ }
79
+
80
+ get text() {
81
+ const { direction = 'in' } = this.state
82
+
83
+ return direction.toUpperCase()
84
+ }
85
+
86
+ render(ctx) {
87
+ const { left, top, width, height } = this.bounds
88
+ const { orientation = 'left-right', direction = 'in' }: { orientation?: string; direction?: string } = this.state
89
+
90
+ ctx.beginPath()
91
+
92
+ const arrowSize = Math.min(width, height) * 0.3
93
+ const bodyWidth = orientation === 'left-right' || orientation === 'right-left' ? height * 0.2 : width * 0.2
94
+ const centerX = left + width / 2
95
+ const centerY = top + height / 2
96
+
97
+ let startX, startY, endX, endY
98
+ let reverse = 1
99
+
100
+ switch (orientation) {
101
+ case 'left-right':
102
+ startX = left
103
+ endX = left + width
104
+ startY = centerY
105
+ endY = centerY
106
+ break
107
+ case 'right-left':
108
+ startX = left + width
109
+ endX = left
110
+ startY = centerY
111
+ endY = centerY
112
+ reverse = -1
113
+ break
114
+ case 'top-bottom':
115
+ startX = centerX
116
+ endX = centerX
117
+ startY = top
118
+ endY = top + height
119
+ break
120
+ case 'bottom-top':
121
+ startX = centerX
122
+ endX = centerX
123
+ startY = top + height
124
+ endY = top
125
+ reverse = -1
126
+ break
127
+ }
128
+
129
+ ctx.lineTo(startX, startY)
130
+
131
+ if (orientation.includes('left')) {
132
+ if (direction === 'out' || direction === 'inout') {
133
+ ctx.lineTo(startX + arrowSize * reverse, startY - bodyWidth * reverse * 2)
134
+ } else {
135
+ ctx.lineTo(startX, startY - bodyWidth * reverse)
136
+ }
137
+
138
+ ctx.lineTo(startX + arrowSize * reverse, startY - bodyWidth * reverse)
139
+ ctx.lineTo(endX - arrowSize * reverse, endY - bodyWidth * reverse)
140
+
141
+ if (direction === 'in' || direction === 'inout') {
142
+ ctx.lineTo(endX - arrowSize * reverse, endY - bodyWidth * 2 * reverse)
143
+ } else {
144
+ ctx.lineTo(endX, endY - bodyWidth * reverse)
145
+ }
146
+
147
+ ctx.lineTo(endX, endY)
148
+
149
+ if (direction === 'in' || direction === 'inout') {
150
+ ctx.lineTo(endX - arrowSize * reverse, endY + bodyWidth * 2 * reverse)
151
+ } else {
152
+ ctx.lineTo(endX, endY + bodyWidth * reverse)
153
+ }
154
+
155
+ ctx.lineTo(endX - arrowSize * reverse, endY + bodyWidth * reverse)
156
+ ctx.lineTo(startX + arrowSize * reverse, startY + bodyWidth * reverse)
157
+
158
+ if (direction === 'out' || direction === 'inout') {
159
+ ctx.lineTo(startX + arrowSize * reverse, startY + bodyWidth * 2 * reverse)
160
+ } else {
161
+ ctx.lineTo(startX, startY + bodyWidth * reverse)
162
+ }
163
+ } else {
164
+ if (direction === 'out' || direction === 'inout') {
165
+ ctx.lineTo(startX - bodyWidth * reverse * 2, startY + arrowSize * reverse)
166
+ } else {
167
+ ctx.lineTo(startX - bodyWidth * reverse, startY)
168
+ }
169
+
170
+ ctx.lineTo(startX - bodyWidth * reverse, startY + arrowSize * reverse)
171
+ ctx.lineTo(endX - bodyWidth * reverse, endY - arrowSize * reverse)
172
+
173
+ if (direction === 'in' || direction === 'inout') {
174
+ ctx.lineTo(endX - bodyWidth * 2 * reverse, endY - arrowSize * reverse)
175
+ } else {
176
+ ctx.lineTo(endX - bodyWidth * reverse, endY)
177
+ }
178
+
179
+ ctx.lineTo(endX, endY)
180
+
181
+ if (direction === 'in' || direction === 'inout') {
182
+ ctx.lineTo(endX + bodyWidth * 2 * reverse, endY - arrowSize * reverse)
183
+ } else {
184
+ ctx.lineTo(endX + bodyWidth * reverse, endY)
185
+ }
186
+
187
+ ctx.lineTo(endX + bodyWidth * reverse, endY - arrowSize * reverse)
188
+ ctx.lineTo(startX + bodyWidth * reverse, startY + arrowSize * reverse)
189
+
190
+ if (direction === 'out' || direction === 'inout') {
191
+ ctx.lineTo(startX + bodyWidth * 2 * reverse, startY + arrowSize * reverse)
192
+ } else {
193
+ ctx.lineTo(startX + bodyWidth * reverse, startY)
194
+ }
195
+ }
196
+
197
+ ctx.closePath()
198
+
199
+ this.drawStroke(ctx)
200
+ }
201
+ }
202
+
203
+ Component.register('PortFlow', PortFlow)
@@ -1,6 +1,6 @@
1
- // import StockerCapacityCircle from './stocker-capacity-circle'
2
1
  import StockerCapacityBar from './stocker-capacity-bar'
3
2
  import ZoneCapacityBar from './zone-capacity-bar'
3
+ import PortFlow from './port-flow'
4
4
 
5
5
  import AGV from './agv'
6
6
  import Buffer from './buffer'
@@ -17,14 +17,10 @@ import agvLine from './agv-line'
17
17
  import ohtLine from './oht-line'
18
18
  import conveyor from './conveyor'
19
19
 
20
- import DataSubscription from './data-subscription'
21
-
22
20
  export default [
23
- DataSubscription,
24
-
25
- // StockerCapacityCircle,
26
21
  StockerCapacityBar,
27
22
  ZoneCapacityBar,
23
+ PortFlow,
28
24
 
29
25
  Buffer,
30
26
  Stocker,
@@ -0,0 +1,15 @@
1
+ const port = new URL('../../icons/port-flow.png', import.meta.url).href
2
+
3
+ export default {
4
+ type: 'PortFlow',
5
+ description: 'port flow',
6
+ icon: port,
7
+ group: ['etc'],
8
+ model: {
9
+ type: 'PortFlow',
10
+ left: 100,
11
+ top: 100,
12
+ width: 80,
13
+ height: 20
14
+ }
15
+ }
@@ -4,6 +4,7 @@ import { LEGEND_CAPACITY } from './features/mcs-status-default'
4
4
  import { safeRound } from './utils/safe-round'
5
5
  import { getVaueOnRanges } from './utils/get-value-on-ranges'
6
6
  import { MCSZoneMixin, MCSZoneMixinProperties } from './features/mcs-zone-mixin'
7
+ import { ParentObjectMixinProperties } from './features/parent-object-mixin'
7
8
  import MCSUnit from './mcs-unit'
8
9
 
9
10
  const NATURE: ComponentNature = {
@@ -12,6 +13,7 @@ const NATURE: ComponentNature = {
12
13
  rotatable: true,
13
14
  properties: [
14
15
  ...MCSZoneMixinProperties,
16
+ ...ParentObjectMixinProperties,
15
17
  {
16
18
  type: 'select',
17
19
  label: 'legend-name',
@@ -18,6 +18,8 @@
18
18
  "label.manual": "manual",
19
19
  "label.reserved": "reserver",
20
20
  "label.occupied": "occupied",
21
+ "label.orientation": "orientation",
22
+ "label.label-position": "label pos.",
21
23
  "label.access-mode": "access mode",
22
24
  "label.carrier": "carrier",
23
25
  "label.carrier-state": "carrier state",
@@ -18,6 +18,8 @@
18
18
  "label.manual": "manual",
19
19
  "label.reserved": "reserver",
20
20
  "label.occupied": "occupied",
21
+ "label.orientation": "orientation",
22
+ "label.label-position": "label pos.",
21
23
  "label.access-mode": "access mode",
22
24
  "label.carrier": "carrier",
23
25
  "label.carrier-state": "carrier state",
@@ -19,6 +19,8 @@
19
19
  "label.manual": "manual",
20
20
  "label.reserved": "reserver",
21
21
  "label.occupied": "occupied",
22
+ "label.orientation": "방향",
23
+ "label.label-position": "라벨 위치",
22
24
  "label.access-mode": "access mode",
23
25
  "label.carrier": "carrier",
24
26
  "label.carrier-state": "carrier state",
@@ -18,6 +18,8 @@
18
18
  "label.manual": "manual",
19
19
  "label.reserved": "reserver",
20
20
  "label.occupied": "occupied",
21
+ "label.orientation": "orientation",
22
+ "label.label-position": "label pos.",
21
23
  "label.access-mode": "access mode",
22
24
  "label.carrier": "carrier",
23
25
  "label.carrier-state": "carrier state",
@@ -18,6 +18,8 @@
18
18
  "label.manual": "manual",
19
19
  "label.reserved": "reserver",
20
20
  "label.occupied": "occupied",
21
+ "label.orientation": "orientation",
22
+ "label.label-position": "label pos.",
21
23
  "label.access-mode": "access mode",
22
24
  "label.carrier": "carrier",
23
25
  "label.carrier-state": "carrier state",