@fmsim/machine 0.0.49
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/agv-line.js +48 -0
- package/dist/agv-line.js.map +1 -0
- package/dist/agv.js +43 -0
- package/dist/agv.js.map +1 -0
- package/dist/buffer.js +40 -0
- package/dist/buffer.js.map +1 -0
- package/dist/conveyor-join.js +169 -0
- package/dist/conveyor-join.js.map +1 -0
- package/dist/conveyor.js +84 -0
- package/dist/conveyor.js.map +1 -0
- package/dist/crane.js +55 -0
- package/dist/crane.js.map +1 -0
- package/dist/data-subscription.js +126 -0
- package/dist/data-subscription.js.map +1 -0
- package/dist/editors/index.js +2 -0
- package/dist/editors/index.js.map +1 -0
- package/dist/equipment.js +18 -0
- package/dist/equipment.js.map +1 -0
- package/dist/features/client-api.js +45 -0
- package/dist/features/client-api.js.map +1 -0
- package/dist/features/conveyor-mixin.js +54 -0
- package/dist/features/conveyor-mixin.js.map +1 -0
- package/dist/features/mcs-event-handler-mixin.js +65 -0
- package/dist/features/mcs-event-handler-mixin.js.map +1 -0
- package/dist/features/mcs-status-default.js +67 -0
- package/dist/features/mcs-status-default.js.map +1 -0
- package/dist/features/mcs-status-mixin.js +39 -0
- package/dist/features/mcs-status-mixin.js.map +1 -0
- package/dist/features/mcs-transport-mixin.js +39 -0
- package/dist/features/mcs-transport-mixin.js.map +1 -0
- package/dist/features/mcs-zone-mixin.js +18 -0
- package/dist/features/mcs-zone-mixin.js.map +1 -0
- package/dist/groups/index.js +10 -0
- package/dist/groups/index.js.map +1 -0
- package/dist/groups/mcs-acs.js +24 -0
- package/dist/groups/mcs-acs.js.map +1 -0
- package/dist/groups/mcs-bcs.js +27 -0
- package/dist/groups/mcs-bcs.js.map +1 -0
- package/dist/groups/mcs-ccs.js +25 -0
- package/dist/groups/mcs-ccs.js.map +1 -0
- package/dist/groups/mcs-ecs.js +23 -0
- package/dist/groups/mcs-ecs.js.map +1 -0
- package/dist/groups/mcs-ocs.js +25 -0
- package/dist/groups/mcs-ocs.js.map +1 -0
- package/dist/groups/mcs-path.js +28 -0
- package/dist/groups/mcs-path.js.map +1 -0
- package/dist/groups/mcs-scs.js +26 -0
- package/dist/groups/mcs-scs.js.map +1 -0
- package/dist/groups/mcs-shape.js +26 -0
- package/dist/groups/mcs-shape.js.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/mcs-carrier-holder.js +107 -0
- package/dist/mcs-carrier-holder.js.map +1 -0
- package/dist/mcs-gauge-capacity-bar.js +170 -0
- package/dist/mcs-gauge-capacity-bar.js.map +1 -0
- package/dist/mcs-gauge-capacity-circle.js +91 -0
- package/dist/mcs-gauge-capacity-circle.js.map +1 -0
- package/dist/mcs-machine.js +84 -0
- package/dist/mcs-machine.js.map +1 -0
- package/dist/mcs-popup.js +82 -0
- package/dist/mcs-popup.js.map +1 -0
- package/dist/mcs-transport.js +18 -0
- package/dist/mcs-transport.js.map +1 -0
- package/dist/mcs-unit.js +78 -0
- package/dist/mcs-unit.js.map +1 -0
- package/dist/mcs-vehicle.js +69 -0
- package/dist/mcs-vehicle.js.map +1 -0
- package/dist/mcs-zone-unit.js +11 -0
- package/dist/mcs-zone-unit.js.map +1 -0
- package/dist/oht-line.js +32 -0
- package/dist/oht-line.js.map +1 -0
- package/dist/oht.js +42 -0
- package/dist/oht.js.map +1 -0
- package/dist/port.js +32 -0
- package/dist/port.js.map +1 -0
- package/dist/rtv-rail.js +36 -0
- package/dist/rtv-rail.js.map +1 -0
- package/dist/shelf.js +41 -0
- package/dist/shelf.js.map +1 -0
- package/dist/shuttle.js +49 -0
- package/dist/shuttle.js.map +1 -0
- package/dist/stocker-capacity-bar.js +171 -0
- package/dist/stocker-capacity-bar.js.map +1 -0
- package/dist/stocker.js +36 -0
- package/dist/stocker.js.map +1 -0
- package/dist/templates/agv-line-corner.js +34 -0
- package/dist/templates/agv-line-corner.js.map +1 -0
- package/dist/templates/agv-line-cross.js +34 -0
- package/dist/templates/agv-line-cross.js.map +1 -0
- package/dist/templates/agv-line-horizontal.js +34 -0
- package/dist/templates/agv-line-horizontal.js.map +1 -0
- package/dist/templates/agv-line-vertical.js +34 -0
- package/dist/templates/agv-line-vertical.js.map +1 -0
- package/dist/templates/agv-line.js +15 -0
- package/dist/templates/agv-line.js.map +1 -0
- package/dist/templates/agv.js +15 -0
- package/dist/templates/agv.js.map +1 -0
- package/dist/templates/buffer.js +15 -0
- package/dist/templates/buffer.js.map +1 -0
- package/dist/templates/conveyor-corner.js +33 -0
- package/dist/templates/conveyor-corner.js.map +1 -0
- package/dist/templates/conveyor-join.js +21 -0
- package/dist/templates/conveyor-join.js.map +1 -0
- package/dist/templates/conveyor-left.js +33 -0
- package/dist/templates/conveyor-left.js.map +1 -0
- package/dist/templates/conveyor-middle.js +33 -0
- package/dist/templates/conveyor-middle.js.map +1 -0
- package/dist/templates/conveyor-right.js +33 -0
- package/dist/templates/conveyor-right.js.map +1 -0
- package/dist/templates/conveyor.js +18 -0
- package/dist/templates/conveyor.js.map +1 -0
- package/dist/templates/crane.js +15 -0
- package/dist/templates/crane.js.map +1 -0
- package/dist/templates/data-subscription.js +16 -0
- package/dist/templates/data-subscription.js.map +1 -0
- package/dist/templates/equipment.js +15 -0
- package/dist/templates/equipment.js.map +1 -0
- package/dist/templates/index.js +35 -0
- package/dist/templates/index.js.map +1 -0
- package/dist/templates/mcs-gauge-capacity-bar.js +18 -0
- package/dist/templates/mcs-gauge-capacity-bar.js.map +1 -0
- package/dist/templates/mcs-gauge-capacity-circle.js +18 -0
- package/dist/templates/mcs-gauge-capacity-circle.js.map +1 -0
- package/dist/templates/oht-line-corner.js +34 -0
- package/dist/templates/oht-line-corner.js.map +1 -0
- package/dist/templates/oht-line-cross.js +34 -0
- package/dist/templates/oht-line-cross.js.map +1 -0
- package/dist/templates/oht-line-horizontal.js +34 -0
- package/dist/templates/oht-line-horizontal.js.map +1 -0
- package/dist/templates/oht-line-vertical.js +34 -0
- package/dist/templates/oht-line-vertical.js.map +1 -0
- package/dist/templates/oht-line.js +15 -0
- package/dist/templates/oht-line.js.map +1 -0
- package/dist/templates/oht.js +15 -0
- package/dist/templates/oht.js.map +1 -0
- package/dist/templates/port.js +15 -0
- package/dist/templates/port.js.map +1 -0
- package/dist/templates/rtv-corner.js +33 -0
- package/dist/templates/rtv-corner.js.map +1 -0
- package/dist/templates/rtv-left.js +33 -0
- package/dist/templates/rtv-left.js.map +1 -0
- package/dist/templates/rtv-middle.js +33 -0
- package/dist/templates/rtv-middle.js.map +1 -0
- package/dist/templates/rtv-rail.js +15 -0
- package/dist/templates/rtv-rail.js.map +1 -0
- package/dist/templates/rtv-right.js +33 -0
- package/dist/templates/rtv-right.js.map +1 -0
- package/dist/templates/rtv.js +15 -0
- package/dist/templates/rtv.js.map +1 -0
- package/dist/templates/shelf.js +15 -0
- package/dist/templates/shelf.js.map +1 -0
- package/dist/templates/shuttle.js +15 -0
- package/dist/templates/shuttle.js.map +1 -0
- package/dist/templates/stocker-capacity-bar.js +18 -0
- package/dist/templates/stocker-capacity-bar.js.map +1 -0
- package/dist/templates/stocker-capacity-circle.js +18 -0
- package/dist/templates/stocker-capacity-circle.js.map +1 -0
- package/dist/templates/stocker.js +16 -0
- package/dist/templates/stocker.js.map +1 -0
- package/dist/templates/zone-capacity-bar.js +19 -0
- package/dist/templates/zone-capacity-bar.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/utils/get-locale.js +19 -0
- package/dist/utils/get-locale.js.map +1 -0
- package/dist/utils/get-value-on-ranges.js +23 -0
- package/dist/utils/get-value-on-ranges.js.map +1 -0
- package/dist/utils/normalize-angle.js +11 -0
- package/dist/utils/normalize-angle.js.map +1 -0
- package/dist/utils/safe-round.js +9 -0
- package/dist/utils/safe-round.js.map +1 -0
- package/dist/zone-capacity-bar.js +162 -0
- package/dist/zone-capacity-bar.js.map +1 -0
- package/icons/agv-line.png +0 -0
- package/icons/agv.png +0 -0
- package/icons/buffer.png +0 -0
- package/icons/conveyor-corner.png +0 -0
- package/icons/conveyor-corner.svg +10 -0
- package/icons/conveyor-join.png +0 -0
- package/icons/conveyor-left.png +0 -0
- package/icons/conveyor-left.svg +6 -0
- package/icons/conveyor-middle.png +0 -0
- package/icons/conveyor-middle.svg +5 -0
- package/icons/conveyor-right.png +0 -0
- package/icons/conveyor-right.svg +6 -0
- package/icons/conveyor.png +0 -0
- package/icons/crane.png +0 -0
- package/icons/equipment.png +0 -0
- package/icons/icon-data-subscription.png +0 -0
- package/icons/oht-line.png +0 -0
- package/icons/oht.png +0 -0
- package/icons/pallet-empty.svg +3 -0
- package/icons/pallet.svg +11 -0
- package/icons/path-position.svg +5 -0
- package/icons/port.png +0 -0
- package/icons/process.png +0 -0
- package/icons/rtv-rail.png +0 -0
- package/icons/rtv.png +0 -0
- package/icons/shelf.png +0 -0
- package/icons/shuttle.png +0 -0
- package/icons/stocker-capacity-bar.png +0 -0
- package/icons/stocker-capacity-circle.png +0 -0
- package/icons/stocker.png +0 -0
- package/icons/symbol-data-subscription.png +0 -0
- package/icons/vehicle.png +0 -0
- package/icons/zone-capacity-bar.png +0 -0
- package/migration-samples/model.json +7964 -0
- package/package.json +59 -0
- package/src/agv-line.ts +59 -0
- package/src/agv.ts +56 -0
- package/src/buffer.ts +50 -0
- package/src/conveyor-join.ts +208 -0
- package/src/conveyor.ts +101 -0
- package/src/crane.ts +72 -0
- package/src/data-subscription.ts +150 -0
- package/src/editors/index.ts +0 -0
- package/src/equipment.ts +21 -0
- package/src/features/client-api.ts +52 -0
- package/src/features/conveyor-mixin.ts +75 -0
- package/src/features/mcs-status-default.ts +76 -0
- package/src/features/mcs-status-mixin.ts +53 -0
- package/src/features/mcs-zone-mixin.ts +23 -0
- package/src/groups/index.ts +10 -0
- package/src/groups/mcs-acs.ts +24 -0
- package/src/groups/mcs-bcs.ts +27 -0
- package/src/groups/mcs-ccs.ts +25 -0
- package/src/groups/mcs-ecs.ts +23 -0
- package/src/groups/mcs-ocs.ts +25 -0
- package/src/groups/mcs-path.ts +28 -0
- package/src/groups/mcs-scs.ts +26 -0
- package/src/groups/mcs-shape.ts +26 -0
- package/src/index.ts +29 -0
- package/src/mcs-carrier-holder.ts +141 -0
- package/src/mcs-gauge-capacity-circle.ts +113 -0
- package/src/mcs-machine.ts +101 -0
- package/src/mcs-popup.ts +99 -0
- package/src/mcs-transport.ts +20 -0
- package/src/mcs-unit.ts +91 -0
- package/src/mcs-vehicle.ts +79 -0
- package/src/oht-line.ts +43 -0
- package/src/oht.ts +55 -0
- package/src/port.ts +41 -0
- package/src/shelf.ts +53 -0
- package/src/shuttle.ts +65 -0
- package/src/stocker-capacity-bar.ts +220 -0
- package/src/stocker.ts +45 -0
- package/src/templates/agv-line.ts +15 -0
- package/src/templates/agv.ts +15 -0
- package/src/templates/buffer.ts +15 -0
- package/src/templates/conveyor.ts +18 -0
- package/src/templates/crane.ts +15 -0
- package/src/templates/data-subscription.js +16 -0
- package/src/templates/equipment.ts +15 -0
- package/src/templates/index.ts +43 -0
- package/src/templates/oht-line.ts +15 -0
- package/src/templates/oht.ts +15 -0
- package/src/templates/port.ts +15 -0
- package/src/templates/shelf.ts +15 -0
- package/src/templates/shuttle.ts +15 -0
- package/src/templates/stocker-capacity-bar.ts +18 -0
- package/src/templates/stocker-capacity-circle.ts +18 -0
- package/src/templates/stocker.ts +16 -0
- package/src/templates/zone-capacity-bar.ts +19 -0
- package/src/utils/get-locale.ts +22 -0
- package/src/utils/get-value-on-ranges.ts +25 -0
- package/src/utils/normalize-angle.ts +9 -0
- package/src/utils/safe-round.ts +8 -0
- package/src/zone-capacity-bar.ts +209 -0
- package/things-scene.config.js +7 -0
- package/translations/en.json +7 -0
- package/translations/ja.json +7 -0
- package/translations/ko.json +7 -0
- package/translations/ms.json +7 -0
- package/translations/zh.json +7 -0
package/package.json
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@fmsim/machine",
|
|
3
|
+
"description": "Layout View를 구성하는 설비(machine)들과 유닛을 구현한 모듈입니다.",
|
|
4
|
+
"author": "heartyoh",
|
|
5
|
+
"version": "0.0.49",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"module": "dist/index.js",
|
|
8
|
+
"things-scene": true,
|
|
9
|
+
"publishConfig": {
|
|
10
|
+
"access": "public",
|
|
11
|
+
"@fmsim:registry": "https://registry.npmjs.org"
|
|
12
|
+
},
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/heartyoh/fmsim.git",
|
|
16
|
+
"directory": "packages/machine"
|
|
17
|
+
},
|
|
18
|
+
"scripts": {
|
|
19
|
+
"serve": "tsc && things-factory-dev",
|
|
20
|
+
"start": "tsc && concurrently -k -r \"tsc --watch --preserveWatchOutput\" \"wds\"",
|
|
21
|
+
"build": "tsc",
|
|
22
|
+
"prepublish": "tsc",
|
|
23
|
+
"lint": "eslint --ext .ts,.html . --ignore-path .gitignore && prettier \"**/*.ts\" --check --ignore-path .gitignore",
|
|
24
|
+
"format": "eslint --ext .ts,.html . --fix --ignore-path .gitignore && prettier \"**/*.ts\" --write --ignore-path .gitignore",
|
|
25
|
+
"migration": "things-factory-migration"
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"@hatiolab/things-scene": "^3.2.0",
|
|
29
|
+
"subscriptions-transport-ws": "^0.11.0"
|
|
30
|
+
},
|
|
31
|
+
"devDependencies": {
|
|
32
|
+
"@hatiolab/prettier-config": "^1.0.0",
|
|
33
|
+
"@things-factory/builder": "^6.0.0",
|
|
34
|
+
"@typescript-eslint/eslint-plugin": "^4.33.0",
|
|
35
|
+
"@typescript-eslint/parser": "^4.33.0",
|
|
36
|
+
"@web/dev-server": "^0.2.1",
|
|
37
|
+
"concurrently": "^8.0.1",
|
|
38
|
+
"eslint": "^8.39.0",
|
|
39
|
+
"eslint-config-prettier": "^8.3.0",
|
|
40
|
+
"husky": "^8.0.3",
|
|
41
|
+
"lint-staged": "^13.2.2",
|
|
42
|
+
"prettier": "^2.4.1",
|
|
43
|
+
"tslib": "^2.3.1",
|
|
44
|
+
"typescript": "^5.0.4"
|
|
45
|
+
},
|
|
46
|
+
"prettier": "@hatiolab/prettier-config",
|
|
47
|
+
"husky": {
|
|
48
|
+
"hooks": {
|
|
49
|
+
"pre-commit": "lint-staged"
|
|
50
|
+
}
|
|
51
|
+
},
|
|
52
|
+
"lint-staged": {
|
|
53
|
+
"*.ts": [
|
|
54
|
+
"eslint --fix",
|
|
55
|
+
"prettier --write"
|
|
56
|
+
]
|
|
57
|
+
},
|
|
58
|
+
"gitHead": "59b7cd248a3b0e637d4e124a28829441c4b258b2"
|
|
59
|
+
}
|
package/src/agv-line.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { Component, ComponentNature } from '@hatiolab/things-scene'
|
|
2
|
+
import MCSTransport from './mcs-transport'
|
|
3
|
+
|
|
4
|
+
const NATURE: ComponentNature = {
|
|
5
|
+
mutable: false,
|
|
6
|
+
resizable: true,
|
|
7
|
+
rotatable: true,
|
|
8
|
+
properties: [...MCSTransport.properties]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default class AGVLine extends MCSTransport {
|
|
12
|
+
static get nature() {
|
|
13
|
+
return NATURE
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
containable(component: Component) {
|
|
17
|
+
return ['AGV'].includes(component.state.type)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
get auxColor() {
|
|
21
|
+
return '#333'
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
render(context: CanvasRenderingContext2D) {
|
|
25
|
+
const { left, top, width, height } = this.bounds
|
|
26
|
+
|
|
27
|
+
context.beginPath()
|
|
28
|
+
|
|
29
|
+
context.translate(left, top)
|
|
30
|
+
|
|
31
|
+
context.fillStyle = this.statusColor!
|
|
32
|
+
context.strokeStyle = this.auxColor!
|
|
33
|
+
context.setLineDash([3])
|
|
34
|
+
|
|
35
|
+
context.fillRect(0, 0, width, height)
|
|
36
|
+
|
|
37
|
+
if (width > height) {
|
|
38
|
+
context.moveTo(0, 0)
|
|
39
|
+
context.lineTo(width, 0)
|
|
40
|
+
// context.moveTo(0, height / 2)
|
|
41
|
+
// context.lineTo(width, height / 2)
|
|
42
|
+
context.moveTo(0, height)
|
|
43
|
+
context.lineTo(width, height)
|
|
44
|
+
} else {
|
|
45
|
+
context.moveTo(0, 0)
|
|
46
|
+
context.lineTo(0, height)
|
|
47
|
+
// context.moveTo(width / 2, 0)
|
|
48
|
+
// context.lineTo(width / 2, height)
|
|
49
|
+
context.moveTo(width, 0)
|
|
50
|
+
context.lineTo(width, height)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
context.stroke()
|
|
54
|
+
|
|
55
|
+
context.translate(-left, -top)
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
Component.register('AGVLine', AGVLine)
|
package/src/agv.ts
ADDED
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { Component, ComponentNature, Properties } from '@hatiolab/things-scene'
|
|
2
|
+
import MCSVehicle from './mcs-vehicle'
|
|
3
|
+
|
|
4
|
+
const NATURE: ComponentNature = {
|
|
5
|
+
mutable: false,
|
|
6
|
+
resizable: true,
|
|
7
|
+
rotatable: true,
|
|
8
|
+
properties: [...MCSVehicle.properties]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const GAP = 2
|
|
12
|
+
export default class AGV extends MCSVehicle {
|
|
13
|
+
static get nature() {
|
|
14
|
+
return NATURE
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
get auxColor() {
|
|
18
|
+
return 'black'
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
render(ctx: CanvasRenderingContext2D) {
|
|
22
|
+
var { left, top, width, height } = this.bounds
|
|
23
|
+
|
|
24
|
+
ctx.translate(left, top)
|
|
25
|
+
ctx.beginPath()
|
|
26
|
+
|
|
27
|
+
ctx.strokeStyle = this.auxColor
|
|
28
|
+
ctx.fillStyle = this.statusColor!
|
|
29
|
+
ctx.lineWidth = 1
|
|
30
|
+
ctx.lineCap = 'round'
|
|
31
|
+
ctx.setLineDash([])
|
|
32
|
+
|
|
33
|
+
const radius = Math.round(Math.min(width, height) * 0.1)
|
|
34
|
+
ctx.roundRect(1, 0, width - 2, height, radius)
|
|
35
|
+
ctx.roundRect(GAP + 1, GAP, width - (GAP + 1) * 2, height - GAP * 2, radius - 1)
|
|
36
|
+
|
|
37
|
+
ctx.fill()
|
|
38
|
+
ctx.stroke()
|
|
39
|
+
|
|
40
|
+
ctx.beginPath()
|
|
41
|
+
|
|
42
|
+
// draw wheel metapore
|
|
43
|
+
ctx.strokeStyle = 'black'
|
|
44
|
+
|
|
45
|
+
ctx.moveTo(0, (height * 1) / 3)
|
|
46
|
+
ctx.lineTo(0, (height * 2) / 3)
|
|
47
|
+
ctx.moveTo(width, (height * 1) / 3)
|
|
48
|
+
ctx.lineTo(width, (height * 2) / 3)
|
|
49
|
+
|
|
50
|
+
ctx.stroke()
|
|
51
|
+
|
|
52
|
+
ctx.translate(-left, -top)
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
Component.register('AGV', AGV)
|
package/src/buffer.ts
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { Component, ComponentNature } from '@hatiolab/things-scene'
|
|
2
|
+
import MCSMachine from './mcs-machine'
|
|
3
|
+
|
|
4
|
+
const NATURE: ComponentNature = {
|
|
5
|
+
mutable: false,
|
|
6
|
+
resizable: true,
|
|
7
|
+
rotatable: true,
|
|
8
|
+
properties: [...MCSMachine.properties]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export default class Buffer extends MCSMachine {
|
|
12
|
+
static get nature() {
|
|
13
|
+
return NATURE
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
containable(component: Component) {
|
|
17
|
+
return super.containable(component) || ['Port'].includes(component.state.type)
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
render(ctx) {
|
|
21
|
+
var { lineWidth } = this.state
|
|
22
|
+
var { left, top, width, height } = this.bounds
|
|
23
|
+
|
|
24
|
+
const offset = Math.round(Math.min(width, height) * 0.2)
|
|
25
|
+
|
|
26
|
+
ctx.beginPath()
|
|
27
|
+
ctx.translate(left, top)
|
|
28
|
+
|
|
29
|
+
ctx.strokeStyle = this.auxColor
|
|
30
|
+
ctx.fillStyle = this.statusColor!
|
|
31
|
+
ctx.lineWidth = lineWidth || 1
|
|
32
|
+
ctx.lineCap = 'round'
|
|
33
|
+
ctx.setLineDash([])
|
|
34
|
+
|
|
35
|
+
ctx.moveTo(offset, 0)
|
|
36
|
+
ctx.lineTo(width - offset, 0)
|
|
37
|
+
ctx.lineTo(width, height / 2)
|
|
38
|
+
ctx.lineTo(width - offset, height)
|
|
39
|
+
ctx.lineTo(offset, height)
|
|
40
|
+
ctx.lineTo(0, height / 2)
|
|
41
|
+
ctx.lineTo(offset, 0)
|
|
42
|
+
|
|
43
|
+
ctx.translate(-left, -top)
|
|
44
|
+
|
|
45
|
+
ctx.fill()
|
|
46
|
+
ctx.stroke()
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
Component.register('Buffer', Buffer)
|
|
@@ -0,0 +1,208 @@
|
|
|
1
|
+
import { Component, ComponentNature, Control, POSITION } from '@hatiolab/things-scene'
|
|
2
|
+
import MCSTransport from './mcs-transport'
|
|
3
|
+
import { ConveyorMixin } from './features/conveyor-mixin'
|
|
4
|
+
import { normalizeAngle } from './utils/normalize-angle'
|
|
5
|
+
|
|
6
|
+
const NATURE: ComponentNature = {
|
|
7
|
+
mutable: false,
|
|
8
|
+
resizable: true,
|
|
9
|
+
rotatable: true,
|
|
10
|
+
properties: [
|
|
11
|
+
...MCSTransport.properties,
|
|
12
|
+
{
|
|
13
|
+
type: 'angle',
|
|
14
|
+
label: 'start-angle',
|
|
15
|
+
name: 'startAngle'
|
|
16
|
+
},
|
|
17
|
+
{
|
|
18
|
+
type: 'angle',
|
|
19
|
+
label: 'end-angle',
|
|
20
|
+
name: 'endAngle'
|
|
21
|
+
},
|
|
22
|
+
{
|
|
23
|
+
type: 'number',
|
|
24
|
+
label: 'ratio',
|
|
25
|
+
name: 'ratio'
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
type: 'number',
|
|
29
|
+
label: 'roll-width',
|
|
30
|
+
name: 'rollWidth'
|
|
31
|
+
}
|
|
32
|
+
]
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
var controlHandler = {
|
|
36
|
+
ondragmove: function (point: POSITION, index: number, component: Component) {
|
|
37
|
+
var { cx, cy, rx, ry, startAngle, endAngle } = component.model
|
|
38
|
+
|
|
39
|
+
var { x, y } = component.transcoordP2S(point.x, point.y)
|
|
40
|
+
|
|
41
|
+
const angle = (startAngle + endAngle) / 2
|
|
42
|
+
|
|
43
|
+
/* 원점으로부터 최대 거리 */
|
|
44
|
+
const dx = Math.abs(rx * Math.sin(angle))
|
|
45
|
+
const dy = Math.abs(ry * Math.cos(angle))
|
|
46
|
+
const distance = Math.sqrt(dx * dx + dy * dy)
|
|
47
|
+
|
|
48
|
+
/* 원점으로부터 현재 컨트롤 위치까지의 거리 */
|
|
49
|
+
const px = Math.abs(cx - x)
|
|
50
|
+
const py = Math.abs(cy - y)
|
|
51
|
+
const pdistance = Math.sqrt(px * px + py * py)
|
|
52
|
+
|
|
53
|
+
var ratio = (pdistance / distance) * 100
|
|
54
|
+
|
|
55
|
+
ratio = ratio >= 100 || ratio <= -100 ? 100 : Math.abs(ratio)
|
|
56
|
+
|
|
57
|
+
component.set({ ratio })
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
var antiClockWiseControlHandler = {
|
|
62
|
+
ondragmove: function (point: POSITION, index: number, component: Component) {
|
|
63
|
+
var { cx, cy } = component.model
|
|
64
|
+
|
|
65
|
+
var transcoorded = component.transcoordP2S(point.x, point.y)
|
|
66
|
+
|
|
67
|
+
var theta = Math.atan2(-(transcoorded.y - cy), transcoorded.x - cx)
|
|
68
|
+
|
|
69
|
+
if (theta > 0 && theta <= Math.PI / 2) theta = Math.PI / 2
|
|
70
|
+
if (theta < 0 && theta >= -Math.PI / 2) theta = -Math.PI / 2
|
|
71
|
+
|
|
72
|
+
const startAngle = (-theta + Math.PI / 2 - Math.PI * 2) % (Math.PI * 2)
|
|
73
|
+
|
|
74
|
+
component.set({ startAngle })
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
var clockwiseControlHandler = {
|
|
79
|
+
ondragmove: function (point: POSITION, index: number, component: Component) {
|
|
80
|
+
var { cx, cy } = component.model
|
|
81
|
+
|
|
82
|
+
var transcoorded = component.transcoordP2S(point.x, point.y)
|
|
83
|
+
|
|
84
|
+
var theta = Math.atan2(-(transcoorded.y - cy), transcoorded.x - cx)
|
|
85
|
+
|
|
86
|
+
if (theta > 0) if (theta >= Math.PI / 2) theta = Math.PI / 2
|
|
87
|
+
if (theta < 0) if (theta <= -Math.PI / 2) theta = -Math.PI / 2
|
|
88
|
+
|
|
89
|
+
var endAngle = -theta + Math.PI / 2
|
|
90
|
+
|
|
91
|
+
component.set({ endAngle })
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
export default class ConveyorJoin extends ConveyorMixin(MCSTransport) {
|
|
96
|
+
get nature() {
|
|
97
|
+
return NATURE
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
containable(component: Component) {
|
|
101
|
+
return ['Shuttle', 'Port'].includes(component.state.type)
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
contains(x: number, y: number) {
|
|
105
|
+
var { cx, cy, rx, ry, ratio, startAngle, endAngle } = this.state
|
|
106
|
+
rx = Math.abs(rx)
|
|
107
|
+
ry = Math.abs(ry)
|
|
108
|
+
|
|
109
|
+
const normx = (x - cx) / (rx * 2 - 0.5)
|
|
110
|
+
const normy = (y - cy) / (ry * 2 - 0.5)
|
|
111
|
+
const ratiox = (x - cx) / ((rx / 100) * ratio * 2 - 0.5)
|
|
112
|
+
const ratioy = (y - cy) / ((ry / 100) * ratio * 2 - 0.5)
|
|
113
|
+
|
|
114
|
+
if (normx * normx + normy * normy < 0.25 && ratiox * ratiox + ratioy * ratioy > 0.25) {
|
|
115
|
+
const angle = normalizeAngle(Math.atan2(-normy, normx) - Math.PI / 2)
|
|
116
|
+
|
|
117
|
+
if (angle >= startAngle && angle <= endAngle) {
|
|
118
|
+
return true
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
|
|
122
|
+
return false
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
render(context: CanvasRenderingContext2D) {
|
|
126
|
+
var { ratio = 50, cx, cy, rx, ry, startAngle = 0, endAngle = Math.PI / 2 } = this.state
|
|
127
|
+
|
|
128
|
+
context.beginPath()
|
|
129
|
+
|
|
130
|
+
startAngle -= Math.PI / 2
|
|
131
|
+
endAngle -= Math.PI / 2
|
|
132
|
+
|
|
133
|
+
/* outer ellipse and inner ellipse */
|
|
134
|
+
context.ellipse(cx, cy, Math.abs(rx), Math.abs(ry), 0, startAngle, endAngle)
|
|
135
|
+
context.ellipse(cx, cy, Math.abs((rx / 100) * ratio), Math.abs((ry / 100) * ratio), 0, endAngle, startAngle, true)
|
|
136
|
+
|
|
137
|
+
context.lineTo(rx * Math.cos(startAngle) + cx, ry * Math.sin(startAngle) + cy)
|
|
138
|
+
|
|
139
|
+
this.drawFill(context)
|
|
140
|
+
this.drawStroke(context)
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
get path() {
|
|
144
|
+
var { cx, cy, rx, ry } = this.state
|
|
145
|
+
|
|
146
|
+
return [
|
|
147
|
+
{
|
|
148
|
+
x: cx - rx,
|
|
149
|
+
y: cy - ry
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
x: cx + rx,
|
|
153
|
+
y: cy - ry
|
|
154
|
+
},
|
|
155
|
+
{
|
|
156
|
+
x: cx + rx,
|
|
157
|
+
y: cy + ry
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
x: cx - rx,
|
|
161
|
+
y: cy + ry
|
|
162
|
+
}
|
|
163
|
+
]
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
set path(path) {
|
|
167
|
+
var left_top = path[0]
|
|
168
|
+
var right_bottom = path[2]
|
|
169
|
+
|
|
170
|
+
this.set({
|
|
171
|
+
cx: left_top.x + (right_bottom.x - left_top.x) / 2,
|
|
172
|
+
cy: left_top.y + (right_bottom.y - left_top.y) / 2,
|
|
173
|
+
rx: (right_bottom.x - left_top.x) / 2,
|
|
174
|
+
ry: (right_bottom.y - left_top.y) / 2
|
|
175
|
+
})
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
get controls(): Control[] {
|
|
179
|
+
var { cx, cy, rx, ry, ratio, startAngle, endAngle } = this.state
|
|
180
|
+
|
|
181
|
+
var controls = [] as Control[]
|
|
182
|
+
|
|
183
|
+
controls.push({
|
|
184
|
+
x: cx + ((rx + (rx * ratio) / 100) / 2) * Math.sin(startAngle),
|
|
185
|
+
y: cy - ((ry + (ry * ratio) / 100) / 2) * Math.cos(startAngle),
|
|
186
|
+
handler: antiClockWiseControlHandler
|
|
187
|
+
})
|
|
188
|
+
|
|
189
|
+
controls.push({
|
|
190
|
+
x: cx + ((rx + (rx * ratio) / 100) / 2) * Math.sin(endAngle),
|
|
191
|
+
y: cy - ((ry + (ry * ratio) / 100) / 2) * Math.cos(endAngle),
|
|
192
|
+
handler: clockwiseControlHandler
|
|
193
|
+
})
|
|
194
|
+
|
|
195
|
+
const angle = (startAngle + endAngle) / 2
|
|
196
|
+
controls.push({
|
|
197
|
+
x: cx + ((rx * ratio) / 100) * Math.sin(angle),
|
|
198
|
+
y: cy - ((ry * ratio) / 100) * Math.cos(angle),
|
|
199
|
+
handler: controlHandler
|
|
200
|
+
})
|
|
201
|
+
|
|
202
|
+
return controls
|
|
203
|
+
}
|
|
204
|
+
}
|
|
205
|
+
|
|
206
|
+
Component.memoize(ConveyorJoin.prototype, 'controls', false)
|
|
207
|
+
|
|
208
|
+
Component.register('ConveyorJoin', ConveyorJoin as any)
|
package/src/conveyor.ts
ADDED
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import { Component, ComponentNature } from '@hatiolab/things-scene'
|
|
2
|
+
import MCSTransport from './mcs-transport'
|
|
3
|
+
|
|
4
|
+
const NATURE: ComponentNature = {
|
|
5
|
+
mutable: false,
|
|
6
|
+
resizable: true,
|
|
7
|
+
rotatable: true,
|
|
8
|
+
properties: [
|
|
9
|
+
{
|
|
10
|
+
type: 'select',
|
|
11
|
+
label: 'conveyor-type',
|
|
12
|
+
name: 'conveyorType',
|
|
13
|
+
property: {
|
|
14
|
+
options: ['', 'conveyor', 'rail']
|
|
15
|
+
}
|
|
16
|
+
},
|
|
17
|
+
...MCSTransport.properties
|
|
18
|
+
],
|
|
19
|
+
help: 'scene/component/conveyor'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export default class Conveyor extends MCSTransport {
|
|
23
|
+
static get nature() {
|
|
24
|
+
return NATURE
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
get auxColor() {
|
|
28
|
+
return '#777'
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
containable(component: Component) {
|
|
32
|
+
return ['Shuttle', 'Port'].includes(component.state.type)
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
renderConveyor(ctx: CanvasRenderingContext2D) {
|
|
36
|
+
const { left, top, width, height } = this.bounds
|
|
37
|
+
|
|
38
|
+
const rollWidth = Math.max(10, Math.min(width, height) / 2)
|
|
39
|
+
|
|
40
|
+
ctx.beginPath()
|
|
41
|
+
ctx.fillStyle = this.statusColor!
|
|
42
|
+
ctx.strokeStyle = this.auxColor!
|
|
43
|
+
ctx.lineWidth = 1
|
|
44
|
+
|
|
45
|
+
ctx.translate(left, top)
|
|
46
|
+
ctx.rect(0, 0, width, height)
|
|
47
|
+
ctx.fill()
|
|
48
|
+
ctx.stroke()
|
|
49
|
+
|
|
50
|
+
ctx.beginPath()
|
|
51
|
+
ctx.strokeStyle = '#aaa'
|
|
52
|
+
|
|
53
|
+
if (width > height) {
|
|
54
|
+
for (let d = 0; d < width; d += rollWidth) {
|
|
55
|
+
ctx.moveTo(d, 0)
|
|
56
|
+
ctx.lineTo(d, height)
|
|
57
|
+
}
|
|
58
|
+
} else {
|
|
59
|
+
for (let d = 0; d < height; d += rollWidth) {
|
|
60
|
+
ctx.moveTo(0, d)
|
|
61
|
+
ctx.lineTo(width, d)
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
ctx.stroke()
|
|
66
|
+
|
|
67
|
+
ctx.translate(-left, -top)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
renderRtvRail(ctx: CanvasRenderingContext2D) {
|
|
71
|
+
const { left, top, width, height } = this.bounds
|
|
72
|
+
|
|
73
|
+
ctx.beginPath()
|
|
74
|
+
|
|
75
|
+
ctx.translate(left, top)
|
|
76
|
+
|
|
77
|
+
ctx.fillStyle = this.statusColor!
|
|
78
|
+
|
|
79
|
+
if (width > height) {
|
|
80
|
+
ctx.fillRect(0, 0, width, (height * 1) / 5)
|
|
81
|
+
ctx.fillRect(0, (height * 4) / 5, width, (height * 1) / 5)
|
|
82
|
+
} else {
|
|
83
|
+
ctx.fillRect(0, 0, (width * 1) / 5, height)
|
|
84
|
+
ctx.fillRect((width * 4) / 5, 0, (width * 1) / 5, height)
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
ctx.translate(-left, -top)
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
render(ctx: CanvasRenderingContext2D) {
|
|
91
|
+
const { conveyorType } = this.state
|
|
92
|
+
|
|
93
|
+
if (conveyorType == 'rail') {
|
|
94
|
+
this.renderRtvRail(ctx)
|
|
95
|
+
} else {
|
|
96
|
+
this.renderConveyor(ctx)
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
Component.register('Conveyor', Conveyor)
|
package/src/crane.ts
ADDED
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { Component, ComponentNature, Properties } from '@hatiolab/things-scene'
|
|
2
|
+
import MCSVehicle from './mcs-vehicle'
|
|
3
|
+
|
|
4
|
+
const NATURE: ComponentNature = {
|
|
5
|
+
mutable: false,
|
|
6
|
+
resizable: true,
|
|
7
|
+
rotatable: true,
|
|
8
|
+
properties: [...MCSVehicle.properties]
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
const GAP = 2
|
|
12
|
+
|
|
13
|
+
export default class Crane extends MCSVehicle {
|
|
14
|
+
static get nature() {
|
|
15
|
+
return NATURE
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
get auxColor() {
|
|
19
|
+
return 'black'
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
render(ctx: CanvasRenderingContext2D) {
|
|
23
|
+
var { left, top, width, height } = this.bounds
|
|
24
|
+
const { x: cx, y: cy } = this.center
|
|
25
|
+
const rx = width / 2
|
|
26
|
+
const ry = height / 2
|
|
27
|
+
|
|
28
|
+
const round = Math.min(rx, ry) * 0.5
|
|
29
|
+
|
|
30
|
+
ctx.translate(left, top)
|
|
31
|
+
ctx.beginPath()
|
|
32
|
+
|
|
33
|
+
ctx.strokeStyle = this.auxColor
|
|
34
|
+
ctx.fillStyle = this.statusColor!
|
|
35
|
+
ctx.lineWidth = 1
|
|
36
|
+
ctx.lineCap = 'round'
|
|
37
|
+
ctx.setLineDash([])
|
|
38
|
+
|
|
39
|
+
const radius = Math.round(Math.min(width, height) * 0.1)
|
|
40
|
+
ctx.roundRect(1, 0, width - 2, height, radius)
|
|
41
|
+
ctx.roundRect(GAP + 1, GAP, width - (GAP + 1) * 2, height - GAP * 2, radius - 1)
|
|
42
|
+
ctx.fill()
|
|
43
|
+
ctx.stroke()
|
|
44
|
+
|
|
45
|
+
ctx.beginPath()
|
|
46
|
+
ctx.arc(cx - left, cy - top, round, 0, Math.PI * 2)
|
|
47
|
+
ctx.stroke()
|
|
48
|
+
|
|
49
|
+
ctx.beginPath()
|
|
50
|
+
ctx.roundRect(width / 2 - (round * 2) / 4 - round / 8, height / 2 - (round * 6) / 5, round / 4, (round * 6) / 5, 1)
|
|
51
|
+
ctx.roundRect(width / 2 + (round * 2) / 4 - round / 8, height / 2 - (round * 6) / 5, round / 4, (round * 6) / 5, 1)
|
|
52
|
+
|
|
53
|
+
ctx.fill()
|
|
54
|
+
ctx.stroke()
|
|
55
|
+
|
|
56
|
+
ctx.beginPath()
|
|
57
|
+
|
|
58
|
+
// draw crane bar metapore
|
|
59
|
+
ctx.strokeStyle = 'black'
|
|
60
|
+
ctx.lineWidth = 3
|
|
61
|
+
ctx.lineCap = 'butt'
|
|
62
|
+
|
|
63
|
+
ctx.moveTo(GAP * 3, height / 2)
|
|
64
|
+
ctx.lineTo(width - GAP * 3, height / 2)
|
|
65
|
+
|
|
66
|
+
ctx.stroke()
|
|
67
|
+
|
|
68
|
+
ctx.translate(-left, -top)
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
Component.register('Crane', Crane)
|