@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/dist/agv-line.js
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import { Component } from '@hatiolab/things-scene';
|
|
2
|
+
import MCSTransport from './mcs-transport';
|
|
3
|
+
const NATURE = {
|
|
4
|
+
mutable: false,
|
|
5
|
+
resizable: true,
|
|
6
|
+
rotatable: true,
|
|
7
|
+
properties: [...MCSTransport.properties]
|
|
8
|
+
};
|
|
9
|
+
export default class AGVLine extends MCSTransport {
|
|
10
|
+
static get nature() {
|
|
11
|
+
return NATURE;
|
|
12
|
+
}
|
|
13
|
+
containable(component) {
|
|
14
|
+
return ['AGV'].includes(component.state.type);
|
|
15
|
+
}
|
|
16
|
+
get auxColor() {
|
|
17
|
+
return '#333';
|
|
18
|
+
}
|
|
19
|
+
render(context) {
|
|
20
|
+
const { left, top, width, height } = this.bounds;
|
|
21
|
+
context.beginPath();
|
|
22
|
+
context.translate(left, top);
|
|
23
|
+
context.fillStyle = this.statusColor;
|
|
24
|
+
context.strokeStyle = this.auxColor;
|
|
25
|
+
context.setLineDash([3]);
|
|
26
|
+
context.fillRect(0, 0, width, height);
|
|
27
|
+
if (width > height) {
|
|
28
|
+
context.moveTo(0, 0);
|
|
29
|
+
context.lineTo(width, 0);
|
|
30
|
+
// context.moveTo(0, height / 2)
|
|
31
|
+
// context.lineTo(width, height / 2)
|
|
32
|
+
context.moveTo(0, height);
|
|
33
|
+
context.lineTo(width, height);
|
|
34
|
+
}
|
|
35
|
+
else {
|
|
36
|
+
context.moveTo(0, 0);
|
|
37
|
+
context.lineTo(0, height);
|
|
38
|
+
// context.moveTo(width / 2, 0)
|
|
39
|
+
// context.lineTo(width / 2, height)
|
|
40
|
+
context.moveTo(width, 0);
|
|
41
|
+
context.lineTo(width, height);
|
|
42
|
+
}
|
|
43
|
+
context.stroke();
|
|
44
|
+
context.translate(-left, -top);
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
Component.register('AGVLine', AGVLine);
|
|
48
|
+
//# sourceMappingURL=agv-line.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agv-line.js","sourceRoot":"","sources":["../src/agv-line.ts"],"names":[],"mappings":"AAAA,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EAAE,MAAM,CAAC,CAAA;YACzB,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;SAC9B;aAAM;YACL,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;YACpB,OAAO,CAAC,MAAM,CAAC,CAAC,EAAE,MAAM,CAAC,CAAA;YACzB,+BAA+B;YAC/B,oCAAoC;YACpC,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,CAAC,CAAA;YACxB,OAAO,CAAC,MAAM,CAAC,KAAK,EAAE,MAAM,CAAC,CAAA;SAC9B;QAED,OAAO,CAAC,MAAM,EAAE,CAAA;QAEhB,OAAO,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;IAChC,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature } from '@hatiolab/things-scene'\nimport MCSTransport from './mcs-transport'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [...MCSTransport.properties]\n}\n\nexport default class AGVLine extends MCSTransport {\n static get nature() {\n return NATURE\n }\n\n containable(component: Component) {\n return ['AGV'].includes(component.state.type)\n }\n\n get auxColor() {\n return '#333'\n }\n\n render(context: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n\n context.beginPath()\n\n context.translate(left, top)\n\n context.fillStyle = this.statusColor!\n context.strokeStyle = this.auxColor!\n context.setLineDash([3])\n\n context.fillRect(0, 0, width, height)\n\n if (width > height) {\n context.moveTo(0, 0)\n context.lineTo(width, 0)\n // context.moveTo(0, height / 2)\n // context.lineTo(width, height / 2)\n context.moveTo(0, height)\n context.lineTo(width, height)\n } else {\n context.moveTo(0, 0)\n context.lineTo(0, height)\n // context.moveTo(width / 2, 0)\n // context.lineTo(width / 2, height)\n context.moveTo(width, 0)\n context.lineTo(width, height)\n }\n\n context.stroke()\n\n context.translate(-left, -top)\n }\n}\n\nComponent.register('AGVLine', AGVLine)\n"]}
|
package/dist/agv.js
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { Component } from '@hatiolab/things-scene';
|
|
2
|
+
import MCSVehicle from './mcs-vehicle';
|
|
3
|
+
const NATURE = {
|
|
4
|
+
mutable: false,
|
|
5
|
+
resizable: true,
|
|
6
|
+
rotatable: true,
|
|
7
|
+
properties: [...MCSVehicle.properties]
|
|
8
|
+
};
|
|
9
|
+
const GAP = 2;
|
|
10
|
+
export default class AGV extends MCSVehicle {
|
|
11
|
+
static get nature() {
|
|
12
|
+
return NATURE;
|
|
13
|
+
}
|
|
14
|
+
get auxColor() {
|
|
15
|
+
return 'black';
|
|
16
|
+
}
|
|
17
|
+
render(ctx) {
|
|
18
|
+
var { left, top, width, height } = this.bounds;
|
|
19
|
+
ctx.translate(left, top);
|
|
20
|
+
ctx.beginPath();
|
|
21
|
+
ctx.strokeStyle = this.auxColor;
|
|
22
|
+
ctx.fillStyle = this.statusColor;
|
|
23
|
+
ctx.lineWidth = 1;
|
|
24
|
+
ctx.lineCap = 'round';
|
|
25
|
+
ctx.setLineDash([]);
|
|
26
|
+
const radius = Math.round(Math.min(width, height) * 0.1);
|
|
27
|
+
ctx.roundRect(1, 0, width - 2, height, radius);
|
|
28
|
+
ctx.roundRect(GAP + 1, GAP, width - (GAP + 1) * 2, height - GAP * 2, radius - 1);
|
|
29
|
+
ctx.fill();
|
|
30
|
+
ctx.stroke();
|
|
31
|
+
ctx.beginPath();
|
|
32
|
+
// draw wheel metapore
|
|
33
|
+
ctx.strokeStyle = 'black';
|
|
34
|
+
ctx.moveTo(0, (height * 1) / 3);
|
|
35
|
+
ctx.lineTo(0, (height * 2) / 3);
|
|
36
|
+
ctx.moveTo(width, (height * 1) / 3);
|
|
37
|
+
ctx.lineTo(width, (height * 2) / 3);
|
|
38
|
+
ctx.stroke();
|
|
39
|
+
ctx.translate(-left, -top);
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
Component.register('AGV', AGV);
|
|
43
|
+
//# sourceMappingURL=agv.js.map
|
package/dist/agv.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"agv.js","sourceRoot":"","sources":["../src/agv.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,wBAAwB,CAAA;AAC/E,OAAO,UAAU,MAAM,eAAe,CAAA;AAEtC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC;CACvC,CAAA;AAED,MAAM,GAAG,GAAG,CAAC,CAAA;AACb,MAAM,CAAC,OAAO,OAAO,GAAI,SAAQ,UAAU;IACzC,MAAM,KAAK,MAAM;QACf,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAAI,QAAQ;QACV,OAAO,OAAO,CAAA;IAChB,CAAC;IAED,MAAM,CAAC,GAA6B;QAClC,IAAI,EAAE,IAAI,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,IAAI,CAAC,MAAM,CAAA;QAE9C,GAAG,CAAC,SAAS,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;QACxB,GAAG,CAAC,SAAS,EAAE,CAAA;QAEf,GAAG,CAAC,WAAW,GAAG,IAAI,CAAC,QAAQ,CAAA;QAC/B,GAAG,CAAC,SAAS,GAAG,IAAI,CAAC,WAAY,CAAA;QACjC,GAAG,CAAC,SAAS,GAAG,CAAC,CAAA;QACjB,GAAG,CAAC,OAAO,GAAG,OAAO,CAAA;QACrB,GAAG,CAAC,WAAW,CAAC,EAAE,CAAC,CAAA;QAEnB,MAAM,MAAM,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,GAAG,GAAG,CAAC,CAAA;QACxD,GAAG,CAAC,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;QAC9C,GAAG,CAAC,SAAS,CAAC,GAAG,GAAG,CAAC,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC,GAAG,GAAG,CAAC,CAAC,GAAG,CAAC,EAAE,MAAM,GAAG,GAAG,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAA;QAEhF,GAAG,CAAC,IAAI,EAAE,CAAA;QACV,GAAG,CAAC,MAAM,EAAE,CAAA;QAEZ,GAAG,CAAC,SAAS,EAAE,CAAA;QAEf,sBAAsB;QACtB,GAAG,CAAC,WAAW,GAAG,OAAO,CAAA;QAEzB,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/B,GAAG,CAAC,MAAM,CAAC,CAAC,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QAC/B,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QACnC,GAAG,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC,MAAM,GAAG,CAAC,CAAC,GAAG,CAAC,CAAC,CAAA;QAEnC,GAAG,CAAC,MAAM,EAAE,CAAA;QAEZ,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE,GAAG,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, Properties } from '@hatiolab/things-scene'\nimport MCSVehicle from './mcs-vehicle'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [...MCSVehicle.properties]\n}\n\nconst GAP = 2\nexport default class AGV extends MCSVehicle {\n static get nature() {\n return NATURE\n }\n\n get auxColor() {\n return 'black'\n }\n\n render(ctx: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n\n ctx.translate(left, top)\n ctx.beginPath()\n\n ctx.strokeStyle = this.auxColor\n ctx.fillStyle = this.statusColor!\n ctx.lineWidth = 1\n ctx.lineCap = 'round'\n ctx.setLineDash([])\n\n const radius = Math.round(Math.min(width, height) * 0.1)\n ctx.roundRect(1, 0, width - 2, height, radius)\n ctx.roundRect(GAP + 1, GAP, width - (GAP + 1) * 2, height - GAP * 2, radius - 1)\n\n ctx.fill()\n ctx.stroke()\n\n ctx.beginPath()\n\n // draw wheel metapore\n ctx.strokeStyle = 'black'\n\n ctx.moveTo(0, (height * 1) / 3)\n ctx.lineTo(0, (height * 2) / 3)\n ctx.moveTo(width, (height * 1) / 3)\n ctx.lineTo(width, (height * 2) / 3)\n\n ctx.stroke()\n\n ctx.translate(-left, -top)\n }\n}\n\nComponent.register('AGV', AGV)\n"]}
|
package/dist/buffer.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { Component } from '@hatiolab/things-scene';
|
|
2
|
+
import MCSMachine from './mcs-machine';
|
|
3
|
+
const NATURE = {
|
|
4
|
+
mutable: false,
|
|
5
|
+
resizable: true,
|
|
6
|
+
rotatable: true,
|
|
7
|
+
properties: [...MCSMachine.properties]
|
|
8
|
+
};
|
|
9
|
+
export default class Buffer extends MCSMachine {
|
|
10
|
+
static get nature() {
|
|
11
|
+
return NATURE;
|
|
12
|
+
}
|
|
13
|
+
containable(component) {
|
|
14
|
+
return super.containable(component) || ['Port'].includes(component.state.type);
|
|
15
|
+
}
|
|
16
|
+
render(ctx) {
|
|
17
|
+
var { lineWidth } = this.state;
|
|
18
|
+
var { left, top, width, height } = this.bounds;
|
|
19
|
+
const offset = Math.round(Math.min(width, height) * 0.2);
|
|
20
|
+
ctx.beginPath();
|
|
21
|
+
ctx.translate(left, top);
|
|
22
|
+
ctx.strokeStyle = this.auxColor;
|
|
23
|
+
ctx.fillStyle = this.statusColor;
|
|
24
|
+
ctx.lineWidth = lineWidth || 1;
|
|
25
|
+
ctx.lineCap = 'round';
|
|
26
|
+
ctx.setLineDash([]);
|
|
27
|
+
ctx.moveTo(offset, 0);
|
|
28
|
+
ctx.lineTo(width - offset, 0);
|
|
29
|
+
ctx.lineTo(width, height / 2);
|
|
30
|
+
ctx.lineTo(width - offset, height);
|
|
31
|
+
ctx.lineTo(offset, height);
|
|
32
|
+
ctx.lineTo(0, height / 2);
|
|
33
|
+
ctx.lineTo(offset, 0);
|
|
34
|
+
ctx.translate(-left, -top);
|
|
35
|
+
ctx.fill();
|
|
36
|
+
ctx.stroke();
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
Component.register('Buffer', Buffer);
|
|
40
|
+
//# sourceMappingURL=buffer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"buffer.js","sourceRoot":"","sources":["../src/buffer.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,wBAAwB,CAAA;AACnE,OAAO,UAAU,MAAM,eAAe,CAAA;AAEtC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,UAAU,CAAC;CACvC,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,MAAO,SAAQ,UAAU;IAC5C,MAAM,KAAK,MAAM;QACf,OAAO,MAAM,CAAA;IACf,CAAC;IAED,WAAW,CAAC,SAAoB;QAC9B,OAAO,KAAK,CAAC,WAAW,CAAC,SAAS,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,QAAQ,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,CAAC,CAAA;IAChF,CAAC;IAED,MAAM,CAAC,GAAG;QACR,IAAI,EAAE,SAAS,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAC9B,IAAI,EAAE,I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,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature } from '@hatiolab/things-scene'\nimport MCSMachine from './mcs-machine'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [...MCSMachine.properties]\n}\n\nexport default class Buffer extends MCSMachine {\n static get nature() {\n return NATURE\n }\n\n containable(component: Component) {\n return super.containable(component) || ['Port'].includes(component.state.type)\n }\n\n render(ctx) {\n var { lineWidth } = this.state\n var { left, top, width, height } = this.bounds\n\n const offset = Math.round(Math.min(width, height) * 0.2)\n\n ctx.beginPath()\n ctx.translate(left, top)\n\n ctx.strokeStyle = this.auxColor\n ctx.fillStyle = this.statusColor!\n ctx.lineWidth = lineWidth || 1\n ctx.lineCap = 'round'\n ctx.setLineDash([])\n\n ctx.moveTo(offset, 0)\n ctx.lineTo(width - offset, 0)\n ctx.lineTo(width, height / 2)\n ctx.lineTo(width - offset, height)\n ctx.lineTo(offset, height)\n ctx.lineTo(0, height / 2)\n ctx.lineTo(offset, 0)\n\n ctx.translate(-left, -top)\n\n ctx.fill()\n ctx.stroke()\n }\n}\n\nComponent.register('Buffer', Buffer)\n"]}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
import { Component } 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
|
+
const NATURE = {
|
|
6
|
+
mutable: false,
|
|
7
|
+
resizable: true,
|
|
8
|
+
rotatable: true,
|
|
9
|
+
properties: [
|
|
10
|
+
...MCSTransport.properties,
|
|
11
|
+
{
|
|
12
|
+
type: 'angle',
|
|
13
|
+
label: 'start-angle',
|
|
14
|
+
name: 'startAngle'
|
|
15
|
+
},
|
|
16
|
+
{
|
|
17
|
+
type: 'angle',
|
|
18
|
+
label: 'end-angle',
|
|
19
|
+
name: 'endAngle'
|
|
20
|
+
},
|
|
21
|
+
{
|
|
22
|
+
type: 'number',
|
|
23
|
+
label: 'ratio',
|
|
24
|
+
name: 'ratio'
|
|
25
|
+
},
|
|
26
|
+
{
|
|
27
|
+
type: 'number',
|
|
28
|
+
label: 'roll-width',
|
|
29
|
+
name: 'rollWidth'
|
|
30
|
+
}
|
|
31
|
+
]
|
|
32
|
+
};
|
|
33
|
+
var controlHandler = {
|
|
34
|
+
ondragmove: function (point, index, component) {
|
|
35
|
+
var { cx, cy, rx, ry, startAngle, endAngle } = component.model;
|
|
36
|
+
var { x, y } = component.transcoordP2S(point.x, point.y);
|
|
37
|
+
const angle = (startAngle + endAngle) / 2;
|
|
38
|
+
/* 원점으로부터 최대 거리 */
|
|
39
|
+
const dx = Math.abs(rx * Math.sin(angle));
|
|
40
|
+
const dy = Math.abs(ry * Math.cos(angle));
|
|
41
|
+
const distance = Math.sqrt(dx * dx + dy * dy);
|
|
42
|
+
/* 원점으로부터 현재 컨트롤 위치까지의 거리 */
|
|
43
|
+
const px = Math.abs(cx - x);
|
|
44
|
+
const py = Math.abs(cy - y);
|
|
45
|
+
const pdistance = Math.sqrt(px * px + py * py);
|
|
46
|
+
var ratio = (pdistance / distance) * 100;
|
|
47
|
+
ratio = ratio >= 100 || ratio <= -100 ? 100 : Math.abs(ratio);
|
|
48
|
+
component.set({ ratio });
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var antiClockWiseControlHandler = {
|
|
52
|
+
ondragmove: function (point, index, component) {
|
|
53
|
+
var { cx, cy } = component.model;
|
|
54
|
+
var transcoorded = component.transcoordP2S(point.x, point.y);
|
|
55
|
+
var theta = Math.atan2(-(transcoorded.y - cy), transcoorded.x - cx);
|
|
56
|
+
if (theta > 0 && theta <= Math.PI / 2)
|
|
57
|
+
theta = Math.PI / 2;
|
|
58
|
+
if (theta < 0 && theta >= -Math.PI / 2)
|
|
59
|
+
theta = -Math.PI / 2;
|
|
60
|
+
const startAngle = (-theta + Math.PI / 2 - Math.PI * 2) % (Math.PI * 2);
|
|
61
|
+
component.set({ startAngle });
|
|
62
|
+
}
|
|
63
|
+
};
|
|
64
|
+
var clockwiseControlHandler = {
|
|
65
|
+
ondragmove: function (point, index, component) {
|
|
66
|
+
var { cx, cy } = component.model;
|
|
67
|
+
var transcoorded = component.transcoordP2S(point.x, point.y);
|
|
68
|
+
var theta = Math.atan2(-(transcoorded.y - cy), transcoorded.x - cx);
|
|
69
|
+
if (theta > 0)
|
|
70
|
+
if (theta >= Math.PI / 2)
|
|
71
|
+
theta = Math.PI / 2;
|
|
72
|
+
if (theta < 0)
|
|
73
|
+
if (theta <= -Math.PI / 2)
|
|
74
|
+
theta = -Math.PI / 2;
|
|
75
|
+
var endAngle = -theta + Math.PI / 2;
|
|
76
|
+
component.set({ endAngle });
|
|
77
|
+
}
|
|
78
|
+
};
|
|
79
|
+
export default class ConveyorJoin extends ConveyorMixin(MCSTransport) {
|
|
80
|
+
get nature() {
|
|
81
|
+
return NATURE;
|
|
82
|
+
}
|
|
83
|
+
containable(component) {
|
|
84
|
+
return ['Shuttle', 'Port'].includes(component.state.type);
|
|
85
|
+
}
|
|
86
|
+
contains(x, y) {
|
|
87
|
+
var { cx, cy, rx, ry, ratio, startAngle, endAngle } = this.state;
|
|
88
|
+
rx = Math.abs(rx);
|
|
89
|
+
ry = Math.abs(ry);
|
|
90
|
+
const normx = (x - cx) / (rx * 2 - 0.5);
|
|
91
|
+
const normy = (y - cy) / (ry * 2 - 0.5);
|
|
92
|
+
const ratiox = (x - cx) / ((rx / 100) * ratio * 2 - 0.5);
|
|
93
|
+
const ratioy = (y - cy) / ((ry / 100) * ratio * 2 - 0.5);
|
|
94
|
+
if (normx * normx + normy * normy < 0.25 && ratiox * ratiox + ratioy * ratioy > 0.25) {
|
|
95
|
+
const angle = normalizeAngle(Math.atan2(-normy, normx) - Math.PI / 2);
|
|
96
|
+
if (angle >= startAngle && angle <= endAngle) {
|
|
97
|
+
return true;
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
return false;
|
|
101
|
+
}
|
|
102
|
+
render(context) {
|
|
103
|
+
var { ratio = 50, cx, cy, rx, ry, startAngle = 0, endAngle = Math.PI / 2 } = this.state;
|
|
104
|
+
context.beginPath();
|
|
105
|
+
startAngle -= Math.PI / 2;
|
|
106
|
+
endAngle -= Math.PI / 2;
|
|
107
|
+
/* outer ellipse and inner ellipse */
|
|
108
|
+
context.ellipse(cx, cy, Math.abs(rx), Math.abs(ry), 0, startAngle, endAngle);
|
|
109
|
+
context.ellipse(cx, cy, Math.abs((rx / 100) * ratio), Math.abs((ry / 100) * ratio), 0, endAngle, startAngle, true);
|
|
110
|
+
context.lineTo(rx * Math.cos(startAngle) + cx, ry * Math.sin(startAngle) + cy);
|
|
111
|
+
this.drawFill(context);
|
|
112
|
+
this.drawStroke(context);
|
|
113
|
+
}
|
|
114
|
+
get path() {
|
|
115
|
+
var { cx, cy, rx, ry } = this.state;
|
|
116
|
+
return [
|
|
117
|
+
{
|
|
118
|
+
x: cx - rx,
|
|
119
|
+
y: cy - ry
|
|
120
|
+
},
|
|
121
|
+
{
|
|
122
|
+
x: cx + rx,
|
|
123
|
+
y: cy - ry
|
|
124
|
+
},
|
|
125
|
+
{
|
|
126
|
+
x: cx + rx,
|
|
127
|
+
y: cy + ry
|
|
128
|
+
},
|
|
129
|
+
{
|
|
130
|
+
x: cx - rx,
|
|
131
|
+
y: cy + ry
|
|
132
|
+
}
|
|
133
|
+
];
|
|
134
|
+
}
|
|
135
|
+
set path(path) {
|
|
136
|
+
var left_top = path[0];
|
|
137
|
+
var right_bottom = path[2];
|
|
138
|
+
this.set({
|
|
139
|
+
cx: left_top.x + (right_bottom.x - left_top.x) / 2,
|
|
140
|
+
cy: left_top.y + (right_bottom.y - left_top.y) / 2,
|
|
141
|
+
rx: (right_bottom.x - left_top.x) / 2,
|
|
142
|
+
ry: (right_bottom.y - left_top.y) / 2
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
get controls() {
|
|
146
|
+
var { cx, cy, rx, ry, ratio, startAngle, endAngle } = this.state;
|
|
147
|
+
var controls = [];
|
|
148
|
+
controls.push({
|
|
149
|
+
x: cx + ((rx + (rx * ratio) / 100) / 2) * Math.sin(startAngle),
|
|
150
|
+
y: cy - ((ry + (ry * ratio) / 100) / 2) * Math.cos(startAngle),
|
|
151
|
+
handler: antiClockWiseControlHandler
|
|
152
|
+
});
|
|
153
|
+
controls.push({
|
|
154
|
+
x: cx + ((rx + (rx * ratio) / 100) / 2) * Math.sin(endAngle),
|
|
155
|
+
y: cy - ((ry + (ry * ratio) / 100) / 2) * Math.cos(endAngle),
|
|
156
|
+
handler: clockwiseControlHandler
|
|
157
|
+
});
|
|
158
|
+
const angle = (startAngle + endAngle) / 2;
|
|
159
|
+
controls.push({
|
|
160
|
+
x: cx + ((rx * ratio) / 100) * Math.sin(angle),
|
|
161
|
+
y: cy - ((ry * ratio) / 100) * Math.cos(angle),
|
|
162
|
+
handler: controlHandler
|
|
163
|
+
});
|
|
164
|
+
return controls;
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
Component.memoize(ConveyorJoin.prototype, 'controls', false);
|
|
168
|
+
Component.register('ConveyorJoin', ConveyorJoin);
|
|
169
|
+
//# sourceMappingURL=conveyor-join.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conveyor-join.js","sourceRoot":"","sources":["../src/conveyor-join.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAsC,MAAM,wBAAwB,CAAA;AACtF,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,EAAE,cAAc,EAAE,MAAM,yBAAyB,CAAA;AAExD,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV,GAAG,YAAY,CAAC,UAAU;QAC1B;YACE,IAAI,EAAE,OAAO;YACb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CAAC,cAAc,EAAE,YAAmB,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, Control, POSITION } from '@hatiolab/things-scene'\nimport MCSTransport from './mcs-transport'\nimport { ConveyorMixin } from './features/conveyor-mixin'\nimport { normalizeAngle } from './utils/normalize-angle'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n ...MCSTransport.properties,\n {\n type: 'angle',\n label: 'start-angle',\n name: 'startAngle'\n },\n {\n type: 'angle',\n label: 'end-angle',\n name: 'endAngle'\n },\n {\n type: 'number',\n label: 'ratio',\n name: 'ratio'\n },\n {\n type: 'number',\n label: 'roll-width',\n name: 'rollWidth'\n }\n ]\n}\n\nvar controlHandler = {\n ondragmove: function (point: POSITION, index: number, component: Component) {\n var { cx, cy, rx, ry, startAngle, endAngle } = component.model\n\n var { x, y } = component.transcoordP2S(point.x, point.y)\n\n const angle = (startAngle + endAngle) / 2\n\n /* 원점으로부터 최대 거리 */\n const dx = Math.abs(rx * Math.sin(angle))\n const dy = Math.abs(ry * Math.cos(angle))\n const distance = Math.sqrt(dx * dx + dy * dy)\n\n /* 원점으로부터 현재 컨트롤 위치까지의 거리 */\n const px = Math.abs(cx - x)\n const py = Math.abs(cy - y)\n const pdistance = Math.sqrt(px * px + py * py)\n\n var ratio = (pdistance / distance) * 100\n\n ratio = ratio >= 100 || ratio <= -100 ? 100 : Math.abs(ratio)\n\n component.set({ ratio })\n }\n}\n\nvar antiClockWiseControlHandler = {\n ondragmove: function (point: POSITION, index: number, component: Component) {\n var { cx, cy } = component.model\n\n var transcoorded = component.transcoordP2S(point.x, point.y)\n\n var theta = Math.atan2(-(transcoorded.y - cy), transcoorded.x - cx)\n\n if (theta > 0 && theta <= Math.PI / 2) theta = Math.PI / 2\n if (theta < 0 && theta >= -Math.PI / 2) theta = -Math.PI / 2\n\n const startAngle = (-theta + Math.PI / 2 - Math.PI * 2) % (Math.PI * 2)\n\n component.set({ startAngle })\n }\n}\n\nvar clockwiseControlHandler = {\n ondragmove: function (point: POSITION, index: number, component: Component) {\n var { cx, cy } = component.model\n\n var transcoorded = component.transcoordP2S(point.x, point.y)\n\n var theta = Math.atan2(-(transcoorded.y - cy), transcoorded.x - cx)\n\n if (theta > 0) if (theta >= Math.PI / 2) theta = Math.PI / 2\n if (theta < 0) if (theta <= -Math.PI / 2) theta = -Math.PI / 2\n\n var endAngle = -theta + Math.PI / 2\n\n component.set({ endAngle })\n }\n}\n\nexport default class ConveyorJoin extends ConveyorMixin(MCSTransport) {\n get nature() {\n return NATURE\n }\n\n containable(component: Component) {\n return ['Shuttle', 'Port'].includes(component.state.type)\n }\n\n contains(x: number, y: number) {\n var { cx, cy, rx, ry, ratio, startAngle, endAngle } = this.state\n rx = Math.abs(rx)\n ry = Math.abs(ry)\n\n const normx = (x - cx) / (rx * 2 - 0.5)\n const normy = (y - cy) / (ry * 2 - 0.5)\n const ratiox = (x - cx) / ((rx / 100) * ratio * 2 - 0.5)\n const ratioy = (y - cy) / ((ry / 100) * ratio * 2 - 0.5)\n\n if (normx * normx + normy * normy < 0.25 && ratiox * ratiox + ratioy * ratioy > 0.25) {\n const angle = normalizeAngle(Math.atan2(-normy, normx) - Math.PI / 2)\n\n if (angle >= startAngle && angle <= endAngle) {\n return true\n }\n }\n\n return false\n }\n\n render(context: CanvasRenderingContext2D) {\n var { ratio = 50, cx, cy, rx, ry, startAngle = 0, endAngle = Math.PI / 2 } = this.state\n\n context.beginPath()\n\n startAngle -= Math.PI / 2\n endAngle -= Math.PI / 2\n\n /* outer ellipse and inner ellipse */\n context.ellipse(cx, cy, Math.abs(rx), Math.abs(ry), 0, startAngle, endAngle)\n context.ellipse(cx, cy, Math.abs((rx / 100) * ratio), Math.abs((ry / 100) * ratio), 0, endAngle, startAngle, true)\n\n context.lineTo(rx * Math.cos(startAngle) + cx, ry * Math.sin(startAngle) + cy)\n\n this.drawFill(context)\n this.drawStroke(context)\n }\n\n get path() {\n var { cx, cy, rx, ry } = this.state\n\n return [\n {\n x: cx - rx,\n y: cy - ry\n },\n {\n x: cx + rx,\n y: cy - ry\n },\n {\n x: cx + rx,\n y: cy + ry\n },\n {\n x: cx - rx,\n y: cy + ry\n }\n ]\n }\n\n set path(path) {\n var left_top = path[0]\n var right_bottom = path[2]\n\n this.set({\n cx: left_top.x + (right_bottom.x - left_top.x) / 2,\n cy: left_top.y + (right_bottom.y - left_top.y) / 2,\n rx: (right_bottom.x - left_top.x) / 2,\n ry: (right_bottom.y - left_top.y) / 2\n })\n }\n\n get controls(): Control[] {\n var { cx, cy, rx, ry, ratio, startAngle, endAngle } = this.state\n\n var controls = [] as Control[]\n\n controls.push({\n x: cx + ((rx + (rx * ratio) / 100) / 2) * Math.sin(startAngle),\n y: cy - ((ry + (ry * ratio) / 100) / 2) * Math.cos(startAngle),\n handler: antiClockWiseControlHandler\n })\n\n controls.push({\n x: cx + ((rx + (rx * ratio) / 100) / 2) * Math.sin(endAngle),\n y: cy - ((ry + (ry * ratio) / 100) / 2) * Math.cos(endAngle),\n handler: clockwiseControlHandler\n })\n\n const angle = (startAngle + endAngle) / 2\n controls.push({\n x: cx + ((rx * ratio) / 100) * Math.sin(angle),\n y: cy - ((ry * ratio) / 100) * Math.cos(angle),\n handler: controlHandler\n })\n\n return controls\n }\n}\n\nComponent.memoize(ConveyorJoin.prototype, 'controls', false)\n\nComponent.register('ConveyorJoin', ConveyorJoin as any)\n"]}
|
package/dist/conveyor.js
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { Component } from '@hatiolab/things-scene';
|
|
2
|
+
import MCSTransport from './mcs-transport';
|
|
3
|
+
const NATURE = {
|
|
4
|
+
mutable: false,
|
|
5
|
+
resizable: true,
|
|
6
|
+
rotatable: true,
|
|
7
|
+
properties: [
|
|
8
|
+
{
|
|
9
|
+
type: 'select',
|
|
10
|
+
label: 'conveyor-type',
|
|
11
|
+
name: 'conveyorType',
|
|
12
|
+
property: {
|
|
13
|
+
options: ['', 'conveyor', 'rail']
|
|
14
|
+
}
|
|
15
|
+
},
|
|
16
|
+
...MCSTransport.properties
|
|
17
|
+
],
|
|
18
|
+
help: 'scene/component/conveyor'
|
|
19
|
+
};
|
|
20
|
+
export default class Conveyor extends MCSTransport {
|
|
21
|
+
static get nature() {
|
|
22
|
+
return NATURE;
|
|
23
|
+
}
|
|
24
|
+
get auxColor() {
|
|
25
|
+
return '#777';
|
|
26
|
+
}
|
|
27
|
+
containable(component) {
|
|
28
|
+
return ['Shuttle', 'Port'].includes(component.state.type);
|
|
29
|
+
}
|
|
30
|
+
renderConveyor(ctx) {
|
|
31
|
+
const { left, top, width, height } = this.bounds;
|
|
32
|
+
const rollWidth = Math.max(10, Math.min(width, height) / 2);
|
|
33
|
+
ctx.beginPath();
|
|
34
|
+
ctx.fillStyle = this.statusColor;
|
|
35
|
+
ctx.strokeStyle = this.auxColor;
|
|
36
|
+
ctx.lineWidth = 1;
|
|
37
|
+
ctx.translate(left, top);
|
|
38
|
+
ctx.rect(0, 0, width, height);
|
|
39
|
+
ctx.fill();
|
|
40
|
+
ctx.stroke();
|
|
41
|
+
ctx.beginPath();
|
|
42
|
+
ctx.strokeStyle = '#aaa';
|
|
43
|
+
if (width > height) {
|
|
44
|
+
for (let d = 0; d < width; d += rollWidth) {
|
|
45
|
+
ctx.moveTo(d, 0);
|
|
46
|
+
ctx.lineTo(d, height);
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
else {
|
|
50
|
+
for (let d = 0; d < height; d += rollWidth) {
|
|
51
|
+
ctx.moveTo(0, d);
|
|
52
|
+
ctx.lineTo(width, d);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
ctx.stroke();
|
|
56
|
+
ctx.translate(-left, -top);
|
|
57
|
+
}
|
|
58
|
+
renderRtvRail(ctx) {
|
|
59
|
+
const { left, top, width, height } = this.bounds;
|
|
60
|
+
ctx.beginPath();
|
|
61
|
+
ctx.translate(left, top);
|
|
62
|
+
ctx.fillStyle = this.statusColor;
|
|
63
|
+
if (width > height) {
|
|
64
|
+
ctx.fillRect(0, 0, width, (height * 1) / 5);
|
|
65
|
+
ctx.fillRect(0, (height * 4) / 5, width, (height * 1) / 5);
|
|
66
|
+
}
|
|
67
|
+
else {
|
|
68
|
+
ctx.fillRect(0, 0, (width * 1) / 5, height);
|
|
69
|
+
ctx.fillRect((width * 4) / 5, 0, (width * 1) / 5, height);
|
|
70
|
+
}
|
|
71
|
+
ctx.translate(-left, -top);
|
|
72
|
+
}
|
|
73
|
+
render(ctx) {
|
|
74
|
+
const { conveyorType } = this.state;
|
|
75
|
+
if (conveyorType == 'rail') {
|
|
76
|
+
this.renderRtvRail(ctx);
|
|
77
|
+
}
|
|
78
|
+
else {
|
|
79
|
+
this.renderConveyor(ctx);
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
Component.register('Conveyor', Conveyor);
|
|
84
|
+
//# sourceMappingURL=conveyor.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"conveyor.js","sourceRoot":"","sources":["../src/conveyor.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAmB,MAAM,wBAAwB,CAAA;AACnE,OAAO,YAAY,MAAM,iBAAiB,CAAA;AAE1C,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE;QACV;YACE,IAAI,EAAE,QAAQ;YACd,KAAK,EAAE,eAAe;YACtB,IAAI,EAAE,cAAc;YACpB,QAAQ,EAAE;gBACR,OAAO,EAAE,CAAC,EAAE,EAAE,UAAU,EAAE,MAAM,CAAC;aAClC;SACF;QACD,GAAG,YAAY,CAAC,UAAU;KAC3B;IACD,IAAI,EAAE,0BAA0B;CACjC,CAAA;AAED,MAAM,CAAC,OAAO,OAAO,QAAS,SAAQ,YAAY;IAChD,MAAM,KAAK,MAAM;QACf,OAAO,MAAM,CAAA;IACf,CAAC;IAED,IAA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EAAE,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;IAED,MAAM,CAAC,GAA6B;QAClC,MAAM,EAAE,YAAY,EAAE,GAAG,IAAI,CAAC,KAAK,CAAA;QAEnC,IAAI,YAAY,IAAI,MAAM,EAAE;YAC1B,IAAI,CAAC,aAAa,CAAC,GAAG,CAAC,CAAA;SACxB;aAAM;YACL,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,CAAA;SACzB;IACH,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,UAAU,EAAE,QAAQ,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature } from '@hatiolab/things-scene'\nimport MCSTransport from './mcs-transport'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [\n {\n type: 'select',\n label: 'conveyor-type',\n name: 'conveyorType',\n property: {\n options: ['', 'conveyor', 'rail']\n }\n },\n ...MCSTransport.properties\n ],\n help: 'scene/component/conveyor'\n}\n\nexport default class Conveyor extends MCSTransport {\n static get nature() {\n return NATURE\n }\n\n get auxColor() {\n return '#777'\n }\n\n containable(component: Component) {\n return ['Shuttle', 'Port'].includes(component.state.type)\n }\n\n renderConveyor(ctx: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n\n const rollWidth = Math.max(10, Math.min(width, height) / 2)\n\n ctx.beginPath()\n ctx.fillStyle = this.statusColor!\n ctx.strokeStyle = this.auxColor!\n ctx.lineWidth = 1\n\n ctx.translate(left, top)\n ctx.rect(0, 0, width, height)\n ctx.fill()\n ctx.stroke()\n\n ctx.beginPath()\n ctx.strokeStyle = '#aaa'\n\n if (width > height) {\n for (let d = 0; d < width; d += rollWidth) {\n ctx.moveTo(d, 0)\n ctx.lineTo(d, height)\n }\n } else {\n for (let d = 0; d < height; d += rollWidth) {\n ctx.moveTo(0, d)\n ctx.lineTo(width, d)\n }\n }\n\n ctx.stroke()\n\n ctx.translate(-left, -top)\n }\n\n renderRtvRail(ctx: CanvasRenderingContext2D) {\n const { left, top, width, height } = this.bounds\n\n ctx.beginPath()\n\n ctx.translate(left, top)\n\n ctx.fillStyle = this.statusColor!\n\n if (width > height) {\n ctx.fillRect(0, 0, width, (height * 1) / 5)\n ctx.fillRect(0, (height * 4) / 5, width, (height * 1) / 5)\n } else {\n ctx.fillRect(0, 0, (width * 1) / 5, height)\n ctx.fillRect((width * 4) / 5, 0, (width * 1) / 5, height)\n }\n\n ctx.translate(-left, -top)\n }\n\n render(ctx: CanvasRenderingContext2D) {\n const { conveyorType } = this.state\n\n if (conveyorType == 'rail') {\n this.renderRtvRail(ctx)\n } else {\n this.renderConveyor(ctx)\n }\n }\n}\n\nComponent.register('Conveyor', Conveyor)\n"]}
|
package/dist/crane.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import { Component } from '@hatiolab/things-scene';
|
|
2
|
+
import MCSVehicle from './mcs-vehicle';
|
|
3
|
+
const NATURE = {
|
|
4
|
+
mutable: false,
|
|
5
|
+
resizable: true,
|
|
6
|
+
rotatable: true,
|
|
7
|
+
properties: [...MCSVehicle.properties]
|
|
8
|
+
};
|
|
9
|
+
const GAP = 2;
|
|
10
|
+
export default class Crane extends MCSVehicle {
|
|
11
|
+
static get nature() {
|
|
12
|
+
return NATURE;
|
|
13
|
+
}
|
|
14
|
+
get auxColor() {
|
|
15
|
+
return 'black';
|
|
16
|
+
}
|
|
17
|
+
render(ctx) {
|
|
18
|
+
var { left, top, width, height } = this.bounds;
|
|
19
|
+
const { x: cx, y: cy } = this.center;
|
|
20
|
+
const rx = width / 2;
|
|
21
|
+
const ry = height / 2;
|
|
22
|
+
const round = Math.min(rx, ry) * 0.5;
|
|
23
|
+
ctx.translate(left, top);
|
|
24
|
+
ctx.beginPath();
|
|
25
|
+
ctx.strokeStyle = this.auxColor;
|
|
26
|
+
ctx.fillStyle = this.statusColor;
|
|
27
|
+
ctx.lineWidth = 1;
|
|
28
|
+
ctx.lineCap = 'round';
|
|
29
|
+
ctx.setLineDash([]);
|
|
30
|
+
const radius = Math.round(Math.min(width, height) * 0.1);
|
|
31
|
+
ctx.roundRect(1, 0, width - 2, height, radius);
|
|
32
|
+
ctx.roundRect(GAP + 1, GAP, width - (GAP + 1) * 2, height - GAP * 2, radius - 1);
|
|
33
|
+
ctx.fill();
|
|
34
|
+
ctx.stroke();
|
|
35
|
+
ctx.beginPath();
|
|
36
|
+
ctx.arc(cx - left, cy - top, round, 0, Math.PI * 2);
|
|
37
|
+
ctx.stroke();
|
|
38
|
+
ctx.beginPath();
|
|
39
|
+
ctx.roundRect(width / 2 - (round * 2) / 4 - round / 8, height / 2 - (round * 6) / 5, round / 4, (round * 6) / 5, 1);
|
|
40
|
+
ctx.roundRect(width / 2 + (round * 2) / 4 - round / 8, height / 2 - (round * 6) / 5, round / 4, (round * 6) / 5, 1);
|
|
41
|
+
ctx.fill();
|
|
42
|
+
ctx.stroke();
|
|
43
|
+
ctx.beginPath();
|
|
44
|
+
// draw crane bar metapore
|
|
45
|
+
ctx.strokeStyle = 'black';
|
|
46
|
+
ctx.lineWidth = 3;
|
|
47
|
+
ctx.lineCap = 'butt';
|
|
48
|
+
ctx.moveTo(GAP * 3, height / 2);
|
|
49
|
+
ctx.lineTo(width - GAP * 3, height / 2);
|
|
50
|
+
ctx.stroke();
|
|
51
|
+
ctx.translate(-left, -top);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
Component.register('Crane', Crane);
|
|
55
|
+
//# sourceMappingURL=crane.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"crane.js","sourceRoot":"","sources":["../src/crane.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAA+B,MAAM,wBAAwB,CAAA;AAC/E,OAAO,UAAU,MAAM,eAAe,CAAA;AAEtC,MAAM,MAAM,GAAoB;IAC9B,OAAO,EAAE,KAAK;IACd,SAAS,EAAE,IAAI;IACf,SAAS,EAAE,IAAI;IACf,UAAU,EAAE,CAAC,GAAG,UAAU,CAAC,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AAG,CAAC,SAAS,GAAG,CAAC,CAAA;QACjB,GAAG,CAAC,OAAO,GAAG,MAAM,CAAA;QAEpB,GAAG,CAAC,MAAM,CAAC,GAAG,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAA;QAC/B,GAAG,CAAC,MAAM,CAAC,KAAK,GAAG,GAAG,GAAG,CAAC,EAAE,MAAM,GAAG,CAAC,CAAC,CAAA;QAEvC,GAAG,CAAC,MAAM,EAAE,CAAA;QAEZ,GAAG,CAAC,SAAS,CAAC,CAAC,IAAI,EAAE,CAAC,GAAG,CAAC,CAAA;IAC5B,CAAC;CACF;AAED,SAAS,CAAC,QAAQ,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA","sourcesContent":["import { Component, ComponentNature, Properties } from '@hatiolab/things-scene'\nimport MCSVehicle from './mcs-vehicle'\n\nconst NATURE: ComponentNature = {\n mutable: false,\n resizable: true,\n rotatable: true,\n properties: [...MCSVehicle.properties]\n}\n\nconst GAP = 2\n\nexport default class Crane extends MCSVehicle {\n static get nature() {\n return NATURE\n }\n\n get auxColor() {\n return 'black'\n }\n\n render(ctx: CanvasRenderingContext2D) {\n var { left, top, width, height } = this.bounds\n const { x: cx, y: cy } = this.center\n const rx = width / 2\n const ry = height / 2\n\n const round = Math.min(rx, ry) * 0.5\n\n ctx.translate(left, top)\n ctx.beginPath()\n\n ctx.strokeStyle = this.auxColor\n ctx.fillStyle = this.statusColor!\n ctx.lineWidth = 1\n ctx.lineCap = 'round'\n ctx.setLineDash([])\n\n const radius = Math.round(Math.min(width, height) * 0.1)\n ctx.roundRect(1, 0, width - 2, height, radius)\n ctx.roundRect(GAP + 1, GAP, width - (GAP + 1) * 2, height - GAP * 2, radius - 1)\n ctx.fill()\n ctx.stroke()\n\n ctx.beginPath()\n ctx.arc(cx - left, cy - top, round, 0, Math.PI * 2)\n ctx.stroke()\n\n ctx.beginPath()\n ctx.roundRect(width / 2 - (round * 2) / 4 - round / 8, height / 2 - (round * 6) / 5, round / 4, (round * 6) / 5, 1)\n ctx.roundRect(width / 2 + (round * 2) / 4 - round / 8, height / 2 - (round * 6) / 5, round / 4, (round * 6) / 5, 1)\n\n ctx.fill()\n ctx.stroke()\n\n ctx.beginPath()\n\n // draw crane bar metapore\n ctx.strokeStyle = 'black'\n ctx.lineWidth = 3\n ctx.lineCap = 'butt'\n\n ctx.moveTo(GAP * 3, height / 2)\n ctx.lineTo(width - GAP * 3, height / 2)\n\n ctx.stroke()\n\n ctx.translate(-left, -top)\n }\n}\n\nComponent.register('Crane', Crane)\n"]}
|
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
import { SubscriptionClient } from 'subscriptions-transport-ws';
|
|
2
|
+
import { Component, DataSource, RectPath, Shape } from '@hatiolab/things-scene';
|
|
3
|
+
const COMPONENT_IMAGE = new URL('../icons/symbol-data-subscription.png', import.meta.url).href;
|
|
4
|
+
const NATURE = {
|
|
5
|
+
mutable: false,
|
|
6
|
+
resizable: true,
|
|
7
|
+
rotatable: true,
|
|
8
|
+
properties: [
|
|
9
|
+
{
|
|
10
|
+
type: 'string',
|
|
11
|
+
label: 'tag',
|
|
12
|
+
name: 'tag'
|
|
13
|
+
}
|
|
14
|
+
],
|
|
15
|
+
'value-property': 'tag',
|
|
16
|
+
help: 'scene/component/data-subscription'
|
|
17
|
+
};
|
|
18
|
+
export default class DataSubscription extends DataSource(RectPath(Shape)) {
|
|
19
|
+
static get image() {
|
|
20
|
+
if (!DataSubscription._image) {
|
|
21
|
+
DataSubscription._image = new Image();
|
|
22
|
+
DataSubscription._image.src = COMPONENT_IMAGE;
|
|
23
|
+
}
|
|
24
|
+
return DataSubscription._image;
|
|
25
|
+
}
|
|
26
|
+
dispose() {
|
|
27
|
+
if (this.subscription) {
|
|
28
|
+
this.subscription.unsubscribe();
|
|
29
|
+
}
|
|
30
|
+
if (this.client) {
|
|
31
|
+
this.client.unsubscribeAll();
|
|
32
|
+
this.client.close(true);
|
|
33
|
+
}
|
|
34
|
+
super.dispose();
|
|
35
|
+
}
|
|
36
|
+
render(context) {
|
|
37
|
+
var { left, top, width, height } = this.bounds;
|
|
38
|
+
context.beginPath();
|
|
39
|
+
this.drawImage(context, DataSubscription.image, left, top, width, height);
|
|
40
|
+
}
|
|
41
|
+
ready() {
|
|
42
|
+
this._initDataSubscription();
|
|
43
|
+
}
|
|
44
|
+
get nature() {
|
|
45
|
+
return NATURE;
|
|
46
|
+
}
|
|
47
|
+
get tag() {
|
|
48
|
+
return this.state.tag;
|
|
49
|
+
}
|
|
50
|
+
set tag(tag) {
|
|
51
|
+
this.setState('tag', tag);
|
|
52
|
+
}
|
|
53
|
+
_initDataSubscription() {
|
|
54
|
+
if (!this.app.isViewMode)
|
|
55
|
+
return;
|
|
56
|
+
this.requestData();
|
|
57
|
+
}
|
|
58
|
+
async requestData() {
|
|
59
|
+
var { tag } = this.state;
|
|
60
|
+
var self = this;
|
|
61
|
+
var query = `"${tag}"`;
|
|
62
|
+
// var query = `
|
|
63
|
+
// subscription {
|
|
64
|
+
// data(tag: "${tag}") {
|
|
65
|
+
// tag
|
|
66
|
+
// data
|
|
67
|
+
// }
|
|
68
|
+
// }`
|
|
69
|
+
// let wsKey = guid()
|
|
70
|
+
var endpoint = location.origin.replace(/^http/, 'ws') + '/subscriptions';
|
|
71
|
+
this.client = new SubscriptionClient(endpoint, {
|
|
72
|
+
reconnect: true,
|
|
73
|
+
connectionParams: {
|
|
74
|
+
headers: {
|
|
75
|
+
/*
|
|
76
|
+
특정 도메인의 데이타만 받고자 하는 경우에, referer 정보를 제공해서 서버에서 서브도메인 정보를 취득하도록 한다.
|
|
77
|
+
referer: location.href
|
|
78
|
+
또는, 이미 서브도메인 정보를 알고 있다면,
|
|
79
|
+
'x-things-factory-domain': '[subdomain]'
|
|
80
|
+
을 보낼 수 있다.
|
|
81
|
+
관련 정보를 보내지 않는다면, 사용자가 권한을 가진 모든 도메인의 데이타를 수신하게 된다.
|
|
82
|
+
*/
|
|
83
|
+
referer: location.href
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
// null,
|
|
88
|
+
// null
|
|
89
|
+
// wsKey
|
|
90
|
+
);
|
|
91
|
+
this.client.onError(e => {
|
|
92
|
+
var client = this.client;
|
|
93
|
+
// 보드가 실행중이면 재시도, 아니면 재연결 취소
|
|
94
|
+
if (this.disposed) {
|
|
95
|
+
client.reconnect = false;
|
|
96
|
+
this.client.unsubscribeAll();
|
|
97
|
+
this.client.close(true);
|
|
98
|
+
}
|
|
99
|
+
});
|
|
100
|
+
this.client.onConnected(() => {
|
|
101
|
+
// this.subscription = this.client.request({ query }).subscribe({
|
|
102
|
+
// next({ data }) {
|
|
103
|
+
// if (data) {
|
|
104
|
+
// self.data = data.data.data
|
|
105
|
+
// }
|
|
106
|
+
// }
|
|
107
|
+
// })
|
|
108
|
+
// console.log('this.subscription : ', this.subscription)
|
|
109
|
+
});
|
|
110
|
+
this.subscription = this.client.request({ query }).subscribe({
|
|
111
|
+
next({ data }) {
|
|
112
|
+
if (data) {
|
|
113
|
+
self.data = data.data.data;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
});
|
|
117
|
+
// function guid() {
|
|
118
|
+
// function s4() {
|
|
119
|
+
// return (((1 + Math.random()) * 0x10000) | 0).toString(16).substring(1)
|
|
120
|
+
// }
|
|
121
|
+
// return s4() + s4() + '-' + s4() + '-' + s4() + '-' + s4() + '-' + s4() + s4() + s4()
|
|
122
|
+
// }
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
Component.register('data-subscription', DataSubscription);
|
|
126
|
+
//# sourceMappingURL=data-subscription.js.map
|