@fmsim/machine 1.0.46 → 1.0.48

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/carrier.ts CHANGED
@@ -3,6 +3,7 @@ import { getPopupData } from '@fmsim/api'
3
3
 
4
4
  import { BOUNDS, Component, ComponentNature, Properties, Shape } from '@hatiolab/things-scene'
5
5
  import { ANIMATION_DEFAULT, AnimationPreset, AnimationConfig } from './features/animation-default.js'
6
+ import { ParentObjectMixin } from './features/parent-object-mixin.js'
6
7
  import { LEGEND_CARRIER, Legend } from './features/mcs-status-default.js'
7
8
  import { MCSStatusMixin } from './features/mcs-status-mixin.js'
8
9
 
@@ -12,7 +13,7 @@ const NATURE: ComponentNature = {
12
13
  rotatable: false
13
14
  }
14
15
 
15
- export default class Carrier extends MCSStatusMixin(Shape) {
16
+ export default class Carrier extends MCSStatusMixin(ParentObjectMixin(Shape)) {
16
17
  static get nature() {
17
18
  return NATURE
18
19
  }
@@ -58,7 +59,7 @@ export default class Carrier extends MCSStatusMixin(Shape) {
58
59
  }
59
60
 
60
61
  if (decorator || border || arrow) {
61
- this.trigger('animatoroff')
62
+ this.trigger('deco-off')
62
63
  }
63
64
  }
64
65
 
@@ -75,18 +76,18 @@ export default class Carrier extends MCSStatusMixin(Shape) {
75
76
  }
76
77
 
77
78
  if (decorator) {
78
- this.trigger('animatoroff')
79
- this.trigger('icon', decorator)
79
+ this.trigger('deco-icon-off')
80
+ this.trigger('deco-icon', decorator)
80
81
  }
81
82
 
82
83
  if (border) {
83
- this.trigger('animatoroff')
84
- this.trigger('border', border)
84
+ this.trigger('deco-border-off')
85
+ this.trigger('deco-border', border)
85
86
  }
86
87
 
87
88
  if (arrow) {
88
- this.trigger('animatoroff')
89
- this.trigger('bouncing', arrow)
89
+ this.trigger('deco-arrow-off')
90
+ this.trigger('deco-arrow', arrow)
90
91
  }
91
92
  }
92
93
  }
package/src/conveyor.ts CHANGED
@@ -32,7 +32,7 @@ export default class Conveyor extends MCSTransport {
32
32
  }
33
33
 
34
34
  containable(component: Component) {
35
- return ['Shuttle', 'Port'].includes(component.state.type)
35
+ return ['Shuttle', 'Port', 'Node'].includes(component.state.type)
36
36
  }
37
37
 
38
38
  renderConveyor(ctx: CanvasRenderingContext2D) {
@@ -20,6 +20,10 @@ export const MCSStatusMixinProperties = [
20
20
 
21
21
  export function MCSStatusMixin<TBase extends Constructor>(Base: TBase) {
22
22
  return class extends Base {
23
+ isLVComponent() {
24
+ return true
25
+ }
26
+
23
27
  get status(): string | undefined {
24
28
  return
25
29
  }
@@ -30,10 +30,6 @@ export default class MCSMachine extends MCSStatusMixin(ContainerAbstract) {
30
30
  return ['rect', 'ellipse'].includes(component.state.type)
31
31
  }
32
32
 
33
- get reactionDecorators() {
34
- return ['bouncing-arrow']
35
- }
36
-
37
33
  get decorators() {
38
34
  return ['decotag']
39
35
  }
package/src/mcs-unit.ts CHANGED
@@ -17,10 +17,6 @@ export default class MCSUnit extends MCSStatusMixin(ParentObjectMixin(ContainerA
17
17
  return true
18
18
  }
19
19
 
20
- get reactionDecorators() {
21
- return ['bouncing-arrow']
22
- }
23
-
24
20
  get decorators() {
25
21
  return ['decotag']
26
22
  }
@@ -1,8 +1,22 @@
1
+ import { Properties } from '@hatiolab/things-scene'
1
2
  import { LEGEND_VEHICLE, Legend } from './features/mcs-status-default'
2
3
  import MCSCarrierHolder from './mcs-carrier-holder'
4
+ import Node from './node'
3
5
 
4
6
  const DIRECTION_GAP = 3
5
7
 
8
+ function findNode(vehicle: MCSVehicle, nodeId: string, nodeMachine: string) {
9
+ if (!nodeId || !nodeMachine) {
10
+ return null
11
+ }
12
+
13
+ const nodes = vehicle.root.findAllById(nodeId).filter(node => node.state.type == 'Node') as Node[]
14
+
15
+ return nodes.find((node: Node) => {
16
+ return node.nodeMachine === nodeMachine
17
+ })
18
+ }
19
+
6
20
  /**
7
21
  * MCS용 Unit > Transport들의 공통 속성을 정의한 오브젝트
8
22
  */
@@ -21,6 +35,8 @@ export default class MCSVehicle extends MCSCarrierHolder {
21
35
  ]
22
36
  }
23
37
 
38
+ private lastWaypoint: { NodeId: string; NodeMachine: string } | null = null
39
+
24
40
  getLegendFallback(): Legend {
25
41
  return LEGEND_VEHICLE
26
42
  }
@@ -77,4 +93,39 @@ export default class MCSVehicle extends MCSCarrierHolder {
77
93
  super.postrender(ctx)
78
94
  // this.renderDirection(ctx)
79
95
  }
96
+
97
+ onchangeData(after: Properties, before: Properties): void {
98
+ super.onchangeData(after, before)
99
+
100
+ const { NodeId: beforeNodeId, NodeMachine: beforeNodeMachine } = before.data || {}
101
+ const { NodeId, NodeMachine } = after.data || {}
102
+
103
+ if (
104
+ NodeId === undefined ||
105
+ NodeMachine === undefined ||
106
+ (beforeNodeId === NodeId && beforeNodeMachine === NodeMachine) ||
107
+ (this.lastWaypoint && this.lastWaypoint.NodeId === NodeId && this.lastWaypoint.NodeMachine === NodeMachine)
108
+ ) {
109
+ return // not changed
110
+ }
111
+
112
+ const afterNode = findNode(this, NodeId, NodeMachine)
113
+ if (!afterNode) {
114
+ console.warn(`Node not found. NodeId: ${NodeId}, NodeMachine: ${NodeMachine}`)
115
+ return
116
+ }
117
+
118
+ const beforeNode = this.lastWaypoint
119
+ ? findNode(this, this.lastWaypoint.NodeId, this.lastWaypoint.NodeMachine)
120
+ : afterNode
121
+
122
+ // 실제 존재하는 노드 중 가장 최근에 이동한 노드
123
+ this.lastWaypoint = { NodeId, NodeMachine }
124
+
125
+ this.trigger('waypoint', {
126
+ from: beforeNode,
127
+ to: afterNode,
128
+ duration: 5000
129
+ })
130
+ }
80
131
  }
package/src/node.ts CHANGED
@@ -3,12 +3,24 @@
3
3
  */
4
4
 
5
5
  import { Component, Shape } from '@hatiolab/things-scene'
6
+ import MCSMachine from './mcs-machine'
6
7
 
7
8
  const NATURE = {
8
9
  mutable: false,
9
10
  resizable: false,
10
11
  rotatable: false,
11
- properties: []
12
+ properties: [
13
+ {
14
+ type: 'string',
15
+ name: 'NodeIDs',
16
+ label: 'node-ids'
17
+ },
18
+ {
19
+ type: 'string',
20
+ name: 'NodeMachine',
21
+ label: 'node-machine'
22
+ }
23
+ ]
12
24
  }
13
25
 
14
26
  export default class Node extends Shape {
@@ -65,6 +77,18 @@ export default class Node extends Shape {
65
77
  })
66
78
  }
67
79
 
80
+ get nodeMachine() {
81
+ if (this.state.NodeMachine) {
82
+ return this.state.NodeMachine
83
+ }
84
+
85
+ const parent = this.parent
86
+
87
+ if (parent && parent instanceof MCSMachine) {
88
+ return parent.state.id
89
+ }
90
+ }
91
+
68
92
  contains(x, y) {
69
93
  var { cx, cy } = this.state
70
94
 
package/src/oht-line.ts CHANGED
@@ -22,7 +22,7 @@ export default class OHTLine extends MCSTransport {
22
22
  }
23
23
 
24
24
  containable(component: Component) {
25
- return ['OHT'].includes(component.state.type)
25
+ return ['OHT', 'Node'].includes(component.state.type)
26
26
  }
27
27
 
28
28
  render(context: CanvasRenderingContext2D) {