@fmsim/machine 3.0.0-beta.2 → 3.0.0-beta.4
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/features/vehicle-travel.js +73 -0
- package/dist/features/vehicle-travel.js.map +1 -0
- package/dist/mcs-carrier-holder.js +4 -3
- package/dist/mcs-carrier-holder.js.map +1 -1
- package/dist/mcs-vehicle.js +6 -60
- package/dist/mcs-vehicle.js.map +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/jest.config.js +1 -1
- package/package.json +3 -3
- package/src/features/vehicle-travel.ts +82 -0
- package/src/mcs-carrier-holder.ts +6 -3
- package/src/mcs-vehicle.ts +7 -71
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/** The node a vehicle's data names: a `Node` of the board with that id and node machine. */
|
|
2
|
+
function findNode(vehicle, nodeId, nodeMachine) {
|
|
3
|
+
var _a, _b, _c;
|
|
4
|
+
if (!nodeId || !nodeMachine) {
|
|
5
|
+
return null;
|
|
6
|
+
}
|
|
7
|
+
const nodes = (((_b = (_a = vehicle.root).findAllById) === null || _b === void 0 ? void 0 : _b.call(_a, nodeId)) || []).filter((node) => node.state.type == 'Node');
|
|
8
|
+
return (_c = nodes.find((node) => node.nodeMachine === nodeMachine)) !== null && _c !== void 0 ? _c : null;
|
|
9
|
+
}
|
|
10
|
+
/**
|
|
11
|
+
* A vehicle's travel between the nodes of the board (`fmsim.Vehicle`, ADR-0167 decision 18): it goes to the centre of
|
|
12
|
+
* the Node its NODEID and NODEMACHINE name, turned the way it came, or -- the board's vehicle animation on -- it is drawn
|
|
13
|
+
* on the way (waypoint). One mixin worn by fmsim's own AGV and OHT and by a figure alike. A figure's front need not be
|
|
14
|
+
* its travel's: `vehicleHeading` (degrees) turns it, 0 for fmsim's own.
|
|
15
|
+
*/
|
|
16
|
+
export function VehicleTravel(Base) {
|
|
17
|
+
return class extends Base {
|
|
18
|
+
constructor() {
|
|
19
|
+
super(...arguments);
|
|
20
|
+
this._lastWaypoint = null;
|
|
21
|
+
}
|
|
22
|
+
/** The angle, in radians, the vehicle's front makes with the way it travels. */
|
|
23
|
+
get travelHeading() {
|
|
24
|
+
var _a;
|
|
25
|
+
return ((Number((_a = this.state) === null || _a === void 0 ? void 0 : _a.vehicleHeading) || 0) * Math.PI) / 180;
|
|
26
|
+
}
|
|
27
|
+
onchangeData(after, before) {
|
|
28
|
+
super.onchangeData(after, before);
|
|
29
|
+
const { NODEID: beforeNodeId, NODEMACHINE: beforeNodeMachine } = before.data || {};
|
|
30
|
+
const { NODEID: NodeId, NODEMACHINE: NodeMachine } = after.data || {};
|
|
31
|
+
if (NodeId === undefined ||
|
|
32
|
+
NodeMachine === undefined ||
|
|
33
|
+
(beforeNodeId === NodeId && beforeNodeMachine === NodeMachine) ||
|
|
34
|
+
(this._lastWaypoint && this._lastWaypoint.NodeId === NodeId && this._lastWaypoint.NodeMachine === NodeMachine)) {
|
|
35
|
+
return; // not changed
|
|
36
|
+
}
|
|
37
|
+
const afterNode = findNode(this, NodeId, NodeMachine);
|
|
38
|
+
if (!afterNode) {
|
|
39
|
+
// 보드는 전체 노드의 부분 뷰 — 모든 노드를 그리지 않는다. 위치 NODEID 가 이 보드에
|
|
40
|
+
// 없는 노드를 가리키는 건 오류가 아니라 정상(그 노드는 이 보드에 미표시)이므로,
|
|
41
|
+
// 경고 없이 조용히 배치를 생략한다. (데이터 갱신마다 도는 hot path — 거짓 경보 방지.)
|
|
42
|
+
return;
|
|
43
|
+
}
|
|
44
|
+
const beforeNode = this._lastWaypoint ? findNode(this, this._lastWaypoint.NodeId, this._lastWaypoint.NodeMachine) : afterNode;
|
|
45
|
+
// 실제 존재하는 노드 중 가장 최근에 이동한 노드
|
|
46
|
+
this._lastWaypoint = { NodeId, NodeMachine };
|
|
47
|
+
if (this.root.vehicleAnimation) {
|
|
48
|
+
;
|
|
49
|
+
this.trigger('waypoint', {
|
|
50
|
+
from: beforeNode || afterNode,
|
|
51
|
+
to: afterNode,
|
|
52
|
+
duration: 5000
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
else if (beforeNode) {
|
|
56
|
+
const fromCenter = beforeNode.center;
|
|
57
|
+
const toCenter = afterNode.center;
|
|
58
|
+
const { x: startX, y: startY } = beforeNode.transcoordS2T(fromCenter.x, fromCenter.y);
|
|
59
|
+
const { x: endX, y: endY } = afterNode.transcoordS2T(toCenter.x, toCenter.y);
|
|
60
|
+
const theta = Math.atan2(endY - startY, endX - startX) + Math.PI / 2;
|
|
61
|
+
this.location = { x: endX, y: endY };
|
|
62
|
+
this.setState('rotation', theta + this.travelHeading);
|
|
63
|
+
}
|
|
64
|
+
else {
|
|
65
|
+
// beforeNode 없음: afterNode 위치로 즉시 이동
|
|
66
|
+
const toCenter = afterNode.center;
|
|
67
|
+
const { x, y } = afterNode.transcoordS2T(toCenter.x, toCenter.y);
|
|
68
|
+
this.location = { x, y };
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=vehicle-travel.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"vehicle-travel.js","sourceRoot":"","sources":["../../src/features/vehicle-travel.ts"],"names":[],"mappings":"AAEA,4FAA4F;AAC5F,SAAS,QAAQ,CAAC,OAAY,EAAE,MAAc,EAAE,WAAmB;;IACjE,IAAI,CAAC,MAAM,IAAI,CAAC,WAAW,EAAE,CAAC;QAC5B,OAAO,IAAI,CAAA;IACb,CAAC;IAED,MAAM,KAAK,GAAG,CAAC,CAAA,MAAA,MAAA,OAAO,CAAC,IAAI,EAAC,WAAW,mDAAG,MAAM,CAAC,KAAI,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,IAAS,EAAE,EAAE,CAAC,IAAI,CAAC,KAAK,CAAC,IAAI,IAAI,MAAM,CAAW,CAAA;IAEnH,OAAO,MAAA,KAAK,CAAC,IAAI,CAAC,CAAC,IAAU,EAAE,EAAE,CAAC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AA;YACjE,CAAC;iBAAM,CAAC;gBACN,qCAAqC;gBACrC,MAAM,QAAQ,GAAG,SAAS,CAAC,MAAM,CAAA;gBACjC,MAAM,EAAE,CAAC,EAAE,CAAC,EAAE,GAAG,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CAAC,CAC/D;gBAAC,IAAY,CAAC,QAAQ,GAAG,EAAE,CAAC,EAAE,CAAC,EAAE,CAAA;YACpC,CAAC;QACH,CAAC;KACF,CAAA;AACH,CAAC","sourcesContent":["import type Node from '../node'\n\n/** The node a vehicle's data names: a `Node` of the board with that id and node machine. */\nfunction findNode(vehicle: any, nodeId: string, nodeMachine: string): Node | null {\n if (!nodeId || !nodeMachine) {\n return null\n }\n\n const nodes = (vehicle.root.findAllById?.(nodeId) || []).filter((node: any) => node.state.type == 'Node') as Node[]\n\n return nodes.find((node: Node) => node.nodeMachine === nodeMachine) ?? null\n}\n\n/**\n * A vehicle's travel between the nodes of the board (`fmsim.Vehicle`, ADR-0167 decision 18): it goes to the centre of\n * the Node its NODEID and NODEMACHINE name, turned the way it came, or -- the board's vehicle animation on -- it is drawn\n * on the way (waypoint). One mixin worn by fmsim's own AGV and OHT and by a figure alike. A figure's front need not be\n * its travel's: `vehicleHeading` (degrees) turns it, 0 for fmsim's own.\n */\nexport function VehicleTravel<T extends new (...args: any[]) => any>(Base: T) {\n return class extends Base {\n _lastWaypoint: { NodeId: string; NodeMachine: string } | null = null\n\n /** The angle, in radians, the vehicle's front makes with the way it travels. */\n get travelHeading(): number {\n return ((Number((this as any).state?.vehicleHeading) || 0) * Math.PI) / 180\n }\n\n onchangeData(after: Record<string, any>, before: Record<string, any>): void {\n super.onchangeData(after, before)\n\n const { NODEID: beforeNodeId, NODEMACHINE: beforeNodeMachine } = before.data || {}\n const { NODEID: NodeId, NODEMACHINE: NodeMachine } = after.data || {}\n\n if (\n NodeId === undefined ||\n NodeMachine === undefined ||\n (beforeNodeId === NodeId && beforeNodeMachine === NodeMachine) ||\n (this._lastWaypoint && this._lastWaypoint.NodeId === NodeId && this._lastWaypoint.NodeMachine === NodeMachine)\n ) {\n return // not changed\n }\n\n const afterNode = findNode(this, NodeId, NodeMachine)\n if (!afterNode) {\n // 보드는 전체 노드의 부분 뷰 — 모든 노드를 그리지 않는다. 위치 NODEID 가 이 보드에\n // 없는 노드를 가리키는 건 오류가 아니라 정상(그 노드는 이 보드에 미표시)이므로,\n // 경고 없이 조용히 배치를 생략한다. (데이터 갱신마다 도는 hot path — 거짓 경보 방지.)\n return\n }\n\n const beforeNode = this._lastWaypoint ? findNode(this, this._lastWaypoint.NodeId, this._lastWaypoint.NodeMachine) : afterNode\n\n // 실제 존재하는 노드 중 가장 최근에 이동한 노드\n this._lastWaypoint = { NodeId, NodeMachine }\n\n if ((this as any).root.vehicleAnimation) {\n ;(this as any).trigger('waypoint', {\n from: beforeNode || afterNode,\n to: afterNode,\n duration: 5000\n })\n } else if (beforeNode) {\n const fromCenter = beforeNode.center\n const toCenter = afterNode.center\n\n const { x: startX, y: startY } = beforeNode.transcoordS2T(fromCenter.x, fromCenter.y)\n const { x: endX, y: endY } = afterNode.transcoordS2T(toCenter.x, toCenter.y)\n\n const theta = Math.atan2(endY - startY, endX - startX) + Math.PI / 2\n\n ;(this as any).location = { x: endX, y: endY }\n ;(this as any).setState('rotation', theta + this.travelHeading)\n } else {\n // beforeNode 없음: afterNode 위치로 즉시 이동\n const toCenter = afterNode.center\n const { x, y } = afterNode.transcoordS2T(toCenter.x, toCenter.y)\n ;(this as any).location = { x, y }\n }\n }\n }\n}\n"]}
|
|
@@ -185,10 +185,11 @@ export function CarrierHolder(Base) {
|
|
|
185
185
|
/**
|
|
186
186
|
* Where a holder's carriers rest, in coordinates above the holder's bottom, and whether they stand on it or hang from
|
|
187
187
|
* it: on the transport surface by default (fmsim v2). A Port, Shelf or Shuttle holds them at its bottom; an OHT hangs
|
|
188
|
-
* them below.
|
|
188
|
+
* them below. A figure holder says it by its `carrierMount` (ADR-0167 decision 18).
|
|
189
189
|
*/
|
|
190
190
|
get carrierRest() {
|
|
191
|
-
|
|
191
|
+
var _a;
|
|
192
|
+
return ((_a = this.state) === null || _a === void 0 ? void 0 : _a.carrierMount) === 'HANG' ? { height: 0, mount: 'HANG' } : { height: 30, mount: 'ON' };
|
|
192
193
|
}
|
|
193
194
|
/** The pile, and the exception area beside the holder's +X edge. Frames in mm on the holder's own anchor (its bottom) */
|
|
194
195
|
outsideSlots() {
|
|
@@ -297,5 +298,5 @@ function colourAndEffect(legend) {
|
|
|
297
298
|
}));
|
|
298
299
|
}
|
|
299
300
|
registerFigureLegendResolver(carrierHolderLegend);
|
|
300
|
-
registerFigureCapability(Object.assign(Object.assign({}, CARRIER_HOLDER), { properties:
|
|
301
|
+
registerFigureCapability(Object.assign(Object.assign({}, CARRIER_HOLDER), { properties: carrierHolderProperties({ legends: themesColorMap, animations: themesAnimationMap, mount: true }) }), base => CarrierHolder(base));
|
|
301
302
|
//# sourceMappingURL=mcs-carrier-holder.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcs-carrier-holder.js","sourceRoot":"","sources":["../src/mcs-carrier-holder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,eAAe,EACf,wBAAwB,EACxB,4BAA4B,EAE7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAoC,MAAM,wBAAwB,CAAA;AACxF,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpF,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,EAAE,cAAc,EAAE,MAAM,sBAAsB,CAAA;AAErD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,CAAC,IAAI,EAAE,GAAG,CAAC,EAAE,EAAE;QACzC,IAAI,KAAK,GAAG,GAAG,CAAA;QACf,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;YAC9D,IAAI,CAAC;gBACH,KAAK,GAAG,KAAK,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;YAC5B,CAAC;YAAC,WAAM,CAAC;gBACP,OAAO,CAAC,IAAI,EAAE,GAAG,CAAC,CAAA;YACpB,CAAC;QACH,CAAC;QACD,IAAI,CAAC,KAAK,IAAI,OAAO,KAAK,KAAK,QAAQ;YAAE,OAAO,CAAC,IAAI,EAAE,KAAK,CAAC,CAAA;QAC7D,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,GAAG,KAA8C,CAAA;QACxE,OAAO,CAAC,IAAI,kCAAO,CAAC,KAAK,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,GAAK,CAAC,MAAM,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAG,CAAA;IAC3G,CAAC,CAAC,CACH,CAAA;AACH,CAAC;AAED,4BAA4B,CAAC,mBAAmB,CAAC,CAAA;AACjD,wBAAwB,iCAAM,cAAc,KAAE,UAAU,EAAE,yBAAkC,KAAI,IAAI,CAAC,EAAE,CAAC,aAAa,CAAC,IAAI,CAAU,CAAC,CAAA","sourcesContent":["import { themesColorMap, themesAnimationMap } from '@fmsim/api'\nimport JSON5 from 'json5'\nimport {\n Capacity,\n Holdable,\n ItemsDataBinding,\n Model,\n TRANSFER_SLOT_KEY,\n figureLegendSourcesChanged,\n itemTypeEntryOf,\n itemTypeTableOf,\n registerFigureCapability,\n registerFigureLegendResolver,\n type ItemType\n} from '@hatiolab/things-scene'\nimport { HOLDER_ANCHOR, type ItemDims, type ResolvedSlot } from '@hatiolab/figure-model'\nimport { CARRIER_HOLDER, carrierHolderProperties } from '@fmsim/figure-capabilities'\nimport MCSUnit from './mcs-unit.js'\nimport { incomingFromV2 } from './utils/load-address'\n\n/**\n * A holder's slots outside its layout (common item contract 3.4): every carrier of a holder without a layout stands in\n * one pile, and a carrier whose address is unknown or wrong stands in the exception area beside the holder.\n */\nexport const PILE_SLOT = 'pile'\nexport const EXCEPTION_SLOT = 'exception'\n\n/** Where the exception area starts, past the holder's +X edge: a gap of this much of the holder's width */\nconst EXCEPTION_GAP_RATIO = 0.1\n\n/** A carrier shown in a pile is this much of its holder's plan, and half its smaller side high (fmsim v2) */\nconst PILE_PLAN_RATIO = 0.8\nconst PILE_HEIGHT_RATIO = 0.5\n\n/** The record of one carrier the holder's data names: its id, the slot it stands in, what it is told */\nexport interface CarrierRecord {\n slotId: string\n itemId: string\n itemState: { data: Record<string, any>; showText: boolean }\n}\n\n/** The properties a carrier holder adds, offering the legends this board has (ADR-0167 decision 11, 미결 1) */\nexport const CARRIER_HOLDER_PROPERTIES = carrierHolderProperties({ legends: themesColorMap, animations: themesAnimationMap })\n\n/**\n * A holder of MCS carriers, as a mixin over what holds things (`fmsim.CarrierHolder`). What it holds is the common item\n * contract's: carriers are its items (`_items`), found by their CARRIERNAME in the root (itemById), made, moved between\n * holders and let go by the one reconcile by id. MCS's part is here: reading the holder data into one record per\n * carrier, looking its CARRIERTYPE up in the domain's carrier type table (ADR-0155, theme carrier-types), and how a\n * carrier -- whose size MCS does not say -- is shown.\n */\nexport function CarrierHolder<T extends new (...args: any[]) => any>(Base: T) {\n return class extends Base {\n /** Whatever wears this is a carrier holder: the legend resolver finds it up a carrier's parents. */\n get isCarrierHolder(): true {\n return true\n }\n\n /** The records the reconcile took last, as JSON: the same again is not reconciled */\n _carrierRecordsTaken?: string\n\n get showOverflow() {\n return true\n }\n\n get hierarchy() {\n return {\n ...super.hierarchy,\n components: []\n }\n }\n\n // ── items: the holder data is the holder's, the records are worked out from it ─────────────\n\n _itemsFromData(): boolean {\n return false\n }\n\n _keyedById(): boolean {\n return true\n }\n\n /** A carrier the data moves here from another holder travels for two seconds */\n itemMoveAnimation() {\n return { duration: 2000, ease: 'inout' }\n }\n\n _createItemFromRecord(record: CarrierRecord): any {\n const { width, height } = (this as any).state\n return Model.compile(\n { id: record.itemId, type: 'Carrier', left: 0, top: 0, width, height, ...record.itemState },\n (this as any).root?.app\n )\n }\n\n /**\n * One record per carrier the data names, bottom first: MULTICARRIERS in order, then the representative. Without a\n * layout they all stand in the pile. A carrier is told its own keys and whether to show its text.\n */\n carrierRecords(data: Record<string, any> | undefined): CarrierRecord[] {\n return incomingFromV2(data).map(c => ({\n slotId: PILE_SLOT,\n itemId: c.name,\n itemState: this.carrierStateOf(c.record, c.record === data)\n }))\n }\n\n /** What a carrier is told: its own keys (the representative's are picked out of the holder data), and its text */\n carrierStateOf(record: Record<string, any>, representative: boolean): CarrierRecord['itemState'] {\n let data: Record<string, any> = { ...record }\n if (representative) {\n data = { CARRIERNAME: record.CARRIERNAME }\n for (const k of ['CARRIERTYPE', 'EMPTYTYPE', 'CARRIERSTATUS']) if (k in record) data[k] = record[k]\n }\n return { data, showText: !!(this as any).getState('showCarrierText') }\n }\n\n /**\n * The carrier 2D draws (fmsim v2, a rule of position): the top of the data's stack -- MULTICARRIERS bottom first, the\n * holder's own CARRIERNAME last -- when the holder holds it, else the last it holds.\n */\n get topCarrier(): any {\n const items: any[] = (this as any)._items\n const names = incomingFromV2((this as any).data).map(c => c.name)\n for (let i = names.length - 1; i >= 0; i--) {\n const held = items.find(c => c.state.id === names[i])\n if (held) return held\n }\n return items[items.length - 1]\n }\n\n /** The holder's carriers made to be what its data says now. Records the same as last time change nothing */\n syncCarriers(data: Record<string, any> | undefined) {\n const records = this.carrierRecords(data)\n const taken = JSON.stringify(records)\n if (taken === this._carrierRecordsTaken) return\n this._carrierRecordsTaken = taken\n ;(this as any)._reconcileItems(records)\n }\n\n async ready() {\n await super.ready()\n this.syncCarriers((this as any).data)\n }\n\n onchange(after: Record<string, any>, before: Record<string, any>): void {\n super.onchange(after, before)\n /* Its size moves its bottom and changes the size a pile shows carriers at: they take its plan, made and seated again. */\n if ('width' in after || 'height' in after || 'depth' in after) {\n const { width, height } = (this as any).state\n for (const carrier of (this as any)._items) if (width && height) carrier.set({ width, height })\n this._carriersSeatedAgain()\n }\n /* 이 홀더의 Carrier 들이 물려받는 범례가 바뀌었다: 그 피규어들이 범례를 다시 고른다 (ADR-0166 결정 12) */\n if ('carrierLegendName' in after || 'carrierAnimationName' in after) figureLegendSourcesChanged(this)\n if ('showCarrierText' in after || 'slotLayout' in after) {\n this._carrierRecordsTaken = undefined\n this.syncCarriers((this as any).data)\n if ('slotLayout' in after) this._carriersSeatedAgain()\n }\n }\n\n onchangeData(after: Record<string, any>, before: Record<string, any>): void {\n this.syncCarriers(after.data || {})\n super.onchangeData(after, before)\n }\n\n // ── the domain's item types ────────────────────────────────────────────────\n\n /**\n * A carrier's type (ADR-0155): the code it says (its CARRIERTYPE, trimmed and upper-cased -- doc 01, 6.8), in the\n * domain's carrier type table the scene was given when it opened. None when the table does not have it, or the scene\n * was given none.\n */\n carrierItemType(carrier: any): ItemType | null {\n const table = itemTypeTableOf(this)\n return (table && itemTypeEntryOf(table, carrier)) || null\n }\n\n /** A carrier's item type: its code, when the domain's table has it; else null */\n itemTypeOf(carrier: any): string | null {\n return this.carrierItemType(carrier)?.code ?? null\n }\n\n /**\n * A carrier's size in mm, as judged: none. MCS data does not say a carrier's size and a carrier type has none\n * (ADR-0155 amendment 1 C); a carrier is shown at the size of the place it stands in (itemShownDimsOf).\n */\n itemDimsOf(_carrier: any): ItemDims | null {\n return null\n }\n\n /**\n * The size a carrier of unknown size is shown at, in mm (for showing only, never judged). In the pile, most of the\n * holder's plan and half its smaller side high; elsewhere the box filling its slot, its height shared by the stack.\n */\n itemShownDimsOf(_carrier: any, slot: ResolvedSlot, slotId: string): ItemDims | null {\n /* Elsewhere outside the layout, a holder that keeps carriers there says (the exception area: LoadLayoutHolder). */\n if (slotId === PILE_SLOT) {\n const k = (this as any).mmPerSceneUnit\n const { width = 0, height = 0 } = (this as any).state\n const w = Math.abs(width) * PILE_PLAN_RATIO\n const d = Math.abs(height) * PILE_PLAN_RATIO\n return w > 0 && d > 0 ? { width: w * k, depth: d * k, height: Math.min(w, d) * PILE_HEIGHT_RATIO * k } : null\n }\n const layers = Number.isFinite(slot.stackLimit) && slot.stackLimit > 0 ? slot.stackLimit : 1\n return Number.isFinite(slot.allowed.width)\n ? { width: slot.allowed.width, depth: slot.allowed.depth, height: slot.allowed.height / layers }\n : null\n }\n\n /** A carrier's size as it is shown, in mm: its own, or the size its slot shows an unknown one at (its seat's) */\n carrierShownDimsOf(carrier: any): ItemDims | null {\n return (this as any).itemSeatOf(carrier)?.dims ?? null\n }\n\n /** Every carrier made again at the size it is shown at, and every slot seated again */\n _carriersSeatedAgain() {\n const items: any[] = (this as any)._items\n for (const carrier of items) carrier._realObject?.update?.()\n const slots = new Set(items.map(c => c[TRANSFER_SLOT_KEY]))\n for (const slotId of slots) (this as any)._reseatSlot(slotId)\n }\n\n // ── where carriers stand ──────────────────────────────────────────────────\n\n /**\n * Where a holder's carriers rest, in coordinates above the holder's bottom, and whether they stand on it or hang from\n * it: on the transport surface by default (fmsim v2). A Port, Shelf or Shuttle holds them at its bottom; an OHT hangs\n * them below.\n */\n get carrierRest(): { height: number; mount: 'ON' | 'HANG' } {\n return { height: 30, mount: 'ON' }\n }\n\n /** The pile, and the exception area beside the holder's +X edge. Frames in mm on the holder's own anchor (its bottom) */\n outsideSlots() {\n const k = (this as any).mmPerSceneUnit\n const { width = 0 } = (this as any).state\n const w = Math.abs(width)\n const rest = this.carrierRest\n return [\n {\n id: PILE_SLOT,\n anchorId: HOLDER_ANCHOR,\n frame: { position: { x: 0, y: rest.height * k, z: 0 }, rotation: 0 },\n mount: rest.mount\n },\n {\n id: EXCEPTION_SLOT,\n anchorId: HOLDER_ANCHOR,\n frame: {\n position: { x: (w / 2 + w * EXCEPTION_GAP_RATIO) * k + this.exceptionHalfWidth, y: 0, z: 0 },\n rotation: 0\n }\n }\n ]\n }\n\n /** Half the width of a carrier in the exception area, in mm: its edge stands past the gap */\n get exceptionHalfWidth(): number {\n return 0\n }\n\n /**\n * The holder's own anchor is its bottom's centre: a node on the frame at its 3D's origin (the box centre), half its\n * 3D's depth down, turned and moved with it. Others by the layer below.\n */\n anchorObject3D(anchorId: string): any {\n const frame = super.anchorObject3D(anchorId)\n if (anchorId !== HOLDER_ANCHOR || !frame) return frame\n let node = frame.userData.carrierAnchor\n if (!node || node.parent !== frame) {\n node = new frame.constructor()\n node.name = 'carrier-anchor'\n frame.add(node)\n frame.userData.carrierAnchor = node\n }\n node.position.set(0, -(Number((this as any)._realObject?.effectiveDepth) || 0) / 2, 0)\n return node\n }\n }\n}\n\n/* The mixins of things-scene are typed loosely: the holder is still an MCSUnit. */\ninterface MCSCarrierHolder extends MCSUnit {}\n\n/** fmsim's own carrier holder: an MCS unit that holds things, wearing `fmsim.CarrierHolder`. */\nclass MCSCarrierHolder extends CarrierHolder(ItemsDataBinding(Holdable(Capacity(MCSUnit as any)))) {\n static get properties(): any {\n return [...MCSUnit.properties, ...CARRIER_HOLDER_PROPERTIES]\n }\n}\n\nexport default MCSCarrierHolder\n\n/*\n The legend a carrier figure shows its tables by (ADR-0166 7, 12; ADR-0167 11): the nearest carrier holder up its\n parents that chose one for the role -- carrier-legend its carrier legend, carrier-animation its carrier animation --\n then the board root's same choice; none chosen, no answer (the figure's own table, fmsim's default). Colour and effect\n only: a carrier figure's thickness is its own fixed table (ADR-0167 12).\n*/\nconst ROLE_PROPERTY: Record<string, string> = {\n 'carrier-legend': 'carrierLegendName',\n 'carrier-animation': 'carrierAnimationName'\n}\n\nexport function carrierHolderLegend({ component, role }: { component: any; role: string }): unknown {\n const property = ROLE_PROPERTY[role]\n if (!property) return undefined\n let name: unknown\n for (let at = component?.parent; at && !name; at = at.parent) if (at.isCarrierHolder) name = at.state?.[property]\n name ||= component?.root?.rootModel?.state?.[property]\n if (typeof name !== 'string' || !name) return undefined\n let legend = component?.root?.style?.[name]\n if (typeof legend === 'string') {\n try {\n legend = JSON5.parse(legend)\n } catch {\n return undefined\n }\n }\n return legend && typeof legend === 'object' ? colourAndEffect(legend) : undefined\n}\n\n/** A legend as a figure takes it from fmsim: each entry's colour and effect; a colour alone stays the colour; an entry's JSON5 text read. */\nfunction colourAndEffect(legend: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(legend).map(([code, raw]) => {\n let entry = raw\n if (typeof entry === 'string' && entry.trim().startsWith('{')) {\n try {\n entry = JSON5.parse(entry)\n } catch {\n return [code, raw]\n }\n }\n if (!entry || typeof entry !== 'object') return [code, entry]\n const { color, effect } = entry as { color?: unknown; effect?: unknown }\n return [code, { ...(color !== undefined ? { color } : {}), ...(effect !== undefined ? { effect } : {}) }]\n })\n )\n}\n\nregisterFigureLegendResolver(carrierHolderLegend)\nregisterFigureCapability({ ...CARRIER_HOLDER, properties: CARRIER_HOLDER_PROPERTIES as never }, base => CarrierHolder(base) as never)\n"]}
|
|
1
|
+
{"version":3,"file":"mcs-carrier-holder.js","sourceRoot":"","sources":["../src/mcs-carrier-holder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,kBAAkB,EAAE,MAAM,YAAY,CAAA;AAC/D,OAAO,KAAK,MAAM,OAAO,CAAA;AACzB,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,gBAAgB,EAChB,KAAK,EACL,iBAAiB,EACjB,0BAA0B,EAC1B,eAAe,EACf,eAAe,EACf,wBAAwB,EACxB,4BAA4B,EAE7B,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,aAAa,EAAoC,MAAM,wBAAwB,CAAA;AACxF,OAAO,EAAE,cAAc,EAAE,uBAAuB,EAAE,MAAM,4BAA4B,CAAA;AACpF,OAAO,OAAO,MAAM,eAAe,CAAA;AACnC,OAAO,E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AU,CACrC,CAAA","sourcesContent":["import { themesColorMap, themesAnimationMap } from '@fmsim/api'\nimport JSON5 from 'json5'\nimport {\n Capacity,\n Holdable,\n ItemsDataBinding,\n Model,\n TRANSFER_SLOT_KEY,\n figureLegendSourcesChanged,\n itemTypeEntryOf,\n itemTypeTableOf,\n registerFigureCapability,\n registerFigureLegendResolver,\n type ItemType\n} from '@hatiolab/things-scene'\nimport { HOLDER_ANCHOR, type ItemDims, type ResolvedSlot } from '@hatiolab/figure-model'\nimport { CARRIER_HOLDER, carrierHolderProperties } from '@fmsim/figure-capabilities'\nimport MCSUnit from './mcs-unit.js'\nimport { incomingFromV2 } from './utils/load-address'\n\n/**\n * A holder's slots outside its layout (common item contract 3.4): every carrier of a holder without a layout stands in\n * one pile, and a carrier whose address is unknown or wrong stands in the exception area beside the holder.\n */\nexport const PILE_SLOT = 'pile'\nexport const EXCEPTION_SLOT = 'exception'\n\n/** Where the exception area starts, past the holder's +X edge: a gap of this much of the holder's width */\nconst EXCEPTION_GAP_RATIO = 0.1\n\n/** A carrier shown in a pile is this much of its holder's plan, and half its smaller side high (fmsim v2) */\nconst PILE_PLAN_RATIO = 0.8\nconst PILE_HEIGHT_RATIO = 0.5\n\n/** The record of one carrier the holder's data names: its id, the slot it stands in, what it is told */\nexport interface CarrierRecord {\n slotId: string\n itemId: string\n itemState: { data: Record<string, any>; showText: boolean }\n}\n\n/** The properties a carrier holder adds, offering the legends this board has (ADR-0167 decision 11, 미결 1) */\nexport const CARRIER_HOLDER_PROPERTIES = carrierHolderProperties({ legends: themesColorMap, animations: themesAnimationMap })\n\n/**\n * A holder of MCS carriers, as a mixin over what holds things (`fmsim.CarrierHolder`). What it holds is the common item\n * contract's: carriers are its items (`_items`), found by their CARRIERNAME in the root (itemById), made, moved between\n * holders and let go by the one reconcile by id. MCS's part is here: reading the holder data into one record per\n * carrier, looking its CARRIERTYPE up in the domain's carrier type table (ADR-0155, theme carrier-types), and how a\n * carrier -- whose size MCS does not say -- is shown.\n */\nexport function CarrierHolder<T extends new (...args: any[]) => any>(Base: T) {\n return class extends Base {\n /** Whatever wears this is a carrier holder: the legend resolver finds it up a carrier's parents. */\n get isCarrierHolder(): true {\n return true\n }\n\n /** The records the reconcile took last, as JSON: the same again is not reconciled */\n _carrierRecordsTaken?: string\n\n get showOverflow() {\n return true\n }\n\n get hierarchy() {\n return {\n ...super.hierarchy,\n components: []\n }\n }\n\n // ── items: the holder data is the holder's, the records are worked out from it ─────────────\n\n _itemsFromData(): boolean {\n return false\n }\n\n _keyedById(): boolean {\n return true\n }\n\n /** A carrier the data moves here from another holder travels for two seconds */\n itemMoveAnimation() {\n return { duration: 2000, ease: 'inout' }\n }\n\n _createItemFromRecord(record: CarrierRecord): any {\n const { width, height } = (this as any).state\n return Model.compile(\n { id: record.itemId, type: 'Carrier', left: 0, top: 0, width, height, ...record.itemState },\n (this as any).root?.app\n )\n }\n\n /**\n * One record per carrier the data names, bottom first: MULTICARRIERS in order, then the representative. Without a\n * layout they all stand in the pile. A carrier is told its own keys and whether to show its text.\n */\n carrierRecords(data: Record<string, any> | undefined): CarrierRecord[] {\n return incomingFromV2(data).map(c => ({\n slotId: PILE_SLOT,\n itemId: c.name,\n itemState: this.carrierStateOf(c.record, c.record === data)\n }))\n }\n\n /** What a carrier is told: its own keys (the representative's are picked out of the holder data), and its text */\n carrierStateOf(record: Record<string, any>, representative: boolean): CarrierRecord['itemState'] {\n let data: Record<string, any> = { ...record }\n if (representative) {\n data = { CARRIERNAME: record.CARRIERNAME }\n for (const k of ['CARRIERTYPE', 'EMPTYTYPE', 'CARRIERSTATUS']) if (k in record) data[k] = record[k]\n }\n return { data, showText: !!(this as any).getState('showCarrierText') }\n }\n\n /**\n * The carrier 2D draws (fmsim v2, a rule of position): the top of the data's stack -- MULTICARRIERS bottom first, the\n * holder's own CARRIERNAME last -- when the holder holds it, else the last it holds.\n */\n get topCarrier(): any {\n const items: any[] = (this as any)._items\n const names = incomingFromV2((this as any).data).map(c => c.name)\n for (let i = names.length - 1; i >= 0; i--) {\n const held = items.find(c => c.state.id === names[i])\n if (held) return held\n }\n return items[items.length - 1]\n }\n\n /** The holder's carriers made to be what its data says now. Records the same as last time change nothing */\n syncCarriers(data: Record<string, any> | undefined) {\n const records = this.carrierRecords(data)\n const taken = JSON.stringify(records)\n if (taken === this._carrierRecordsTaken) return\n this._carrierRecordsTaken = taken\n ;(this as any)._reconcileItems(records)\n }\n\n async ready() {\n await super.ready()\n this.syncCarriers((this as any).data)\n }\n\n onchange(after: Record<string, any>, before: Record<string, any>): void {\n super.onchange(after, before)\n /* Its size moves its bottom and changes the size a pile shows carriers at: they take its plan, made and seated again. */\n if ('width' in after || 'height' in after || 'depth' in after) {\n const { width, height } = (this as any).state\n for (const carrier of (this as any)._items) if (width && height) carrier.set({ width, height })\n this._carriersSeatedAgain()\n }\n /* 이 홀더의 Carrier 들이 물려받는 범례가 바뀌었다: 그 피규어들이 범례를 다시 고른다 (ADR-0166 결정 12) */\n if ('carrierLegendName' in after || 'carrierAnimationName' in after) figureLegendSourcesChanged(this)\n if ('showCarrierText' in after || 'slotLayout' in after) {\n this._carrierRecordsTaken = undefined\n this.syncCarriers((this as any).data)\n if ('slotLayout' in after) this._carriersSeatedAgain()\n }\n }\n\n onchangeData(after: Record<string, any>, before: Record<string, any>): void {\n this.syncCarriers(after.data || {})\n super.onchangeData(after, before)\n }\n\n // ── the domain's item types ────────────────────────────────────────────────\n\n /**\n * A carrier's type (ADR-0155): the code it says (its CARRIERTYPE, trimmed and upper-cased -- doc 01, 6.8), in the\n * domain's carrier type table the scene was given when it opened. None when the table does not have it, or the scene\n * was given none.\n */\n carrierItemType(carrier: any): ItemType | null {\n const table = itemTypeTableOf(this)\n return (table && itemTypeEntryOf(table, carrier)) || null\n }\n\n /** A carrier's item type: its code, when the domain's table has it; else null */\n itemTypeOf(carrier: any): string | null {\n return this.carrierItemType(carrier)?.code ?? null\n }\n\n /**\n * A carrier's size in mm, as judged: none. MCS data does not say a carrier's size and a carrier type has none\n * (ADR-0155 amendment 1 C); a carrier is shown at the size of the place it stands in (itemShownDimsOf).\n */\n itemDimsOf(_carrier: any): ItemDims | null {\n return null\n }\n\n /**\n * The size a carrier of unknown size is shown at, in mm (for showing only, never judged). In the pile, most of the\n * holder's plan and half its smaller side high; elsewhere the box filling its slot, its height shared by the stack.\n */\n itemShownDimsOf(_carrier: any, slot: ResolvedSlot, slotId: string): ItemDims | null {\n /* Elsewhere outside the layout, a holder that keeps carriers there says (the exception area: LoadLayoutHolder). */\n if (slotId === PILE_SLOT) {\n const k = (this as any).mmPerSceneUnit\n const { width = 0, height = 0 } = (this as any).state\n const w = Math.abs(width) * PILE_PLAN_RATIO\n const d = Math.abs(height) * PILE_PLAN_RATIO\n return w > 0 && d > 0 ? { width: w * k, depth: d * k, height: Math.min(w, d) * PILE_HEIGHT_RATIO * k } : null\n }\n const layers = Number.isFinite(slot.stackLimit) && slot.stackLimit > 0 ? slot.stackLimit : 1\n return Number.isFinite(slot.allowed.width)\n ? { width: slot.allowed.width, depth: slot.allowed.depth, height: slot.allowed.height / layers }\n : null\n }\n\n /** A carrier's size as it is shown, in mm: its own, or the size its slot shows an unknown one at (its seat's) */\n carrierShownDimsOf(carrier: any): ItemDims | null {\n return (this as any).itemSeatOf(carrier)?.dims ?? null\n }\n\n /** Every carrier made again at the size it is shown at, and every slot seated again */\n _carriersSeatedAgain() {\n const items: any[] = (this as any)._items\n for (const carrier of items) carrier._realObject?.update?.()\n const slots = new Set(items.map(c => c[TRANSFER_SLOT_KEY]))\n for (const slotId of slots) (this as any)._reseatSlot(slotId)\n }\n\n // ── where carriers stand ──────────────────────────────────────────────────\n\n /**\n * Where a holder's carriers rest, in coordinates above the holder's bottom, and whether they stand on it or hang from\n * it: on the transport surface by default (fmsim v2). A Port, Shelf or Shuttle holds them at its bottom; an OHT hangs\n * them below. A figure holder says it by its `carrierMount` (ADR-0167 decision 18).\n */\n get carrierRest(): { height: number; mount: 'ON' | 'HANG' } {\n return (this as any).state?.carrierMount === 'HANG' ? { height: 0, mount: 'HANG' } : { height: 30, mount: 'ON' }\n }\n\n /** The pile, and the exception area beside the holder's +X edge. Frames in mm on the holder's own anchor (its bottom) */\n outsideSlots() {\n const k = (this as any).mmPerSceneUnit\n const { width = 0 } = (this as any).state\n const w = Math.abs(width)\n const rest = this.carrierRest\n return [\n {\n id: PILE_SLOT,\n anchorId: HOLDER_ANCHOR,\n frame: { position: { x: 0, y: rest.height * k, z: 0 }, rotation: 0 },\n mount: rest.mount\n },\n {\n id: EXCEPTION_SLOT,\n anchorId: HOLDER_ANCHOR,\n frame: {\n position: { x: (w / 2 + w * EXCEPTION_GAP_RATIO) * k + this.exceptionHalfWidth, y: 0, z: 0 },\n rotation: 0\n }\n }\n ]\n }\n\n /** Half the width of a carrier in the exception area, in mm: its edge stands past the gap */\n get exceptionHalfWidth(): number {\n return 0\n }\n\n /**\n * The holder's own anchor is its bottom's centre: a node on the frame at its 3D's origin (the box centre), half its\n * 3D's depth down, turned and moved with it. Others by the layer below.\n */\n anchorObject3D(anchorId: string): any {\n const frame = super.anchorObject3D(anchorId)\n if (anchorId !== HOLDER_ANCHOR || !frame) return frame\n let node = frame.userData.carrierAnchor\n if (!node || node.parent !== frame) {\n node = new frame.constructor()\n node.name = 'carrier-anchor'\n frame.add(node)\n frame.userData.carrierAnchor = node\n }\n node.position.set(0, -(Number((this as any)._realObject?.effectiveDepth) || 0) / 2, 0)\n return node\n }\n }\n}\n\n/* The mixins of things-scene are typed loosely: the holder is still an MCSUnit. */\ninterface MCSCarrierHolder extends MCSUnit {}\n\n/** fmsim's own carrier holder: an MCS unit that holds things, wearing `fmsim.CarrierHolder`. */\nclass MCSCarrierHolder extends CarrierHolder(ItemsDataBinding(Holdable(Capacity(MCSUnit as any)))) {\n static get properties(): any {\n return [...MCSUnit.properties, ...CARRIER_HOLDER_PROPERTIES]\n }\n}\n\nexport default MCSCarrierHolder\n\n/*\n The legend a carrier figure shows its tables by (ADR-0166 7, 12; ADR-0167 11): the nearest carrier holder up its\n parents that chose one for the role -- carrier-legend its carrier legend, carrier-animation its carrier animation --\n then the board root's same choice; none chosen, no answer (the figure's own table, fmsim's default). Colour and effect\n only: a carrier figure's thickness is its own fixed table (ADR-0167 12).\n*/\nconst ROLE_PROPERTY: Record<string, string> = {\n 'carrier-legend': 'carrierLegendName',\n 'carrier-animation': 'carrierAnimationName'\n}\n\nexport function carrierHolderLegend({ component, role }: { component: any; role: string }): unknown {\n const property = ROLE_PROPERTY[role]\n if (!property) return undefined\n let name: unknown\n for (let at = component?.parent; at && !name; at = at.parent) if (at.isCarrierHolder) name = at.state?.[property]\n name ||= component?.root?.rootModel?.state?.[property]\n if (typeof name !== 'string' || !name) return undefined\n let legend = component?.root?.style?.[name]\n if (typeof legend === 'string') {\n try {\n legend = JSON5.parse(legend)\n } catch {\n return undefined\n }\n }\n return legend && typeof legend === 'object' ? colourAndEffect(legend) : undefined\n}\n\n/** A legend as a figure takes it from fmsim: each entry's colour and effect; a colour alone stays the colour; an entry's JSON5 text read. */\nfunction colourAndEffect(legend: Record<string, unknown>): Record<string, unknown> {\n return Object.fromEntries(\n Object.entries(legend).map(([code, raw]) => {\n let entry = raw\n if (typeof entry === 'string' && entry.trim().startsWith('{')) {\n try {\n entry = JSON5.parse(entry)\n } catch {\n return [code, raw]\n }\n }\n if (!entry || typeof entry !== 'object') return [code, entry]\n const { color, effect } = entry as { color?: unknown; effect?: unknown }\n return [code, { ...(color !== undefined ? { color } : {}), ...(effect !== undefined ? { effect } : {}) }]\n })\n )\n}\n\nregisterFigureLegendResolver(carrierHolderLegend)\nregisterFigureCapability(\n { ...CARRIER_HOLDER, properties: carrierHolderProperties({ legends: themesColorMap, animations: themesAnimationMap, mount: true }) as never },\n base => CarrierHolder(base) as never\n)\n"]}
|
package/dist/mcs-vehicle.js
CHANGED
|
@@ -1,24 +1,13 @@
|
|
|
1
|
+
import { registerFigureCapability } from '@hatiolab/things-scene';
|
|
2
|
+
import { VEHICLE } from '@fmsim/figure-capabilities';
|
|
1
3
|
import { LEGEND_VEHICLE } from './features/mcs-status-default';
|
|
4
|
+
import { VehicleTravel } from './features/vehicle-travel';
|
|
2
5
|
import MCSCarrierHolder from './mcs-carrier-holder';
|
|
3
6
|
const DIRECTION_GAP = 3;
|
|
4
|
-
function findNode(vehicle, nodeId, nodeMachine) {
|
|
5
|
-
var _a, _b;
|
|
6
|
-
if (!nodeId || !nodeMachine) {
|
|
7
|
-
return null;
|
|
8
|
-
}
|
|
9
|
-
const nodes = (((_b = (_a = vehicle.root).findAllById) === null || _b === void 0 ? void 0 : _b.call(_a, nodeId)) || []).filter(node => node.state.type == 'Node');
|
|
10
|
-
return nodes.find((node) => {
|
|
11
|
-
return node.nodeMachine === nodeMachine;
|
|
12
|
-
});
|
|
13
|
-
}
|
|
14
7
|
/**
|
|
15
8
|
* MCS용 Unit > Transport들의 공통 속성을 정의한 오브젝트
|
|
16
9
|
*/
|
|
17
|
-
export default class MCSVehicle extends MCSCarrierHolder {
|
|
18
|
-
constructor() {
|
|
19
|
-
super(...arguments);
|
|
20
|
-
this.lastWaypoint = null;
|
|
21
|
-
}
|
|
10
|
+
export default class MCSVehicle extends VehicleTravel(MCSCarrierHolder) {
|
|
22
11
|
static get properties() {
|
|
23
12
|
return [
|
|
24
13
|
...MCSCarrierHolder.properties,
|
|
@@ -80,50 +69,7 @@ export default class MCSVehicle extends MCSCarrierHolder {
|
|
|
80
69
|
super.postrender(ctx);
|
|
81
70
|
// this.renderDirection(ctx)
|
|
82
71
|
}
|
|
83
|
-
onchangeData(after, before) {
|
|
84
|
-
super.onchangeData(after, before);
|
|
85
|
-
const { NODEID: beforeNodeId, NODEMACHINE: beforeNodeMachine } = before.data || {};
|
|
86
|
-
const { NODEID: NodeId, NODEMACHINE: NodeMachine } = after.data || {};
|
|
87
|
-
if (NodeId === undefined ||
|
|
88
|
-
NodeMachine === undefined ||
|
|
89
|
-
(beforeNodeId === NodeId && beforeNodeMachine === NodeMachine) ||
|
|
90
|
-
(this.lastWaypoint && this.lastWaypoint.NodeId === NodeId && this.lastWaypoint.NodeMachine === NodeMachine)) {
|
|
91
|
-
return; // not changed
|
|
92
|
-
}
|
|
93
|
-
const afterNode = findNode(this, NodeId, NodeMachine);
|
|
94
|
-
if (!afterNode) {
|
|
95
|
-
// 보드는 전체 노드의 부분 뷰 — 모든 노드를 그리지 않는다. 위치 NODEID 가 이 보드에
|
|
96
|
-
// 없는 노드를 가리키는 건 오류가 아니라 정상(그 노드는 이 보드에 미표시)이므로,
|
|
97
|
-
// 경고 없이 조용히 배치를 생략한다. (데이터 갱신마다 도는 hot path — 거짓 경보 방지.)
|
|
98
|
-
return;
|
|
99
|
-
}
|
|
100
|
-
const beforeNode = this.lastWaypoint
|
|
101
|
-
? findNode(this, this.lastWaypoint.NodeId, this.lastWaypoint.NodeMachine)
|
|
102
|
-
: afterNode;
|
|
103
|
-
// 실제 존재하는 노드 중 가장 최근에 이동한 노드
|
|
104
|
-
this.lastWaypoint = { NodeId, NodeMachine };
|
|
105
|
-
if (this.root.vehicleAnimation) {
|
|
106
|
-
this.trigger('waypoint', {
|
|
107
|
-
from: beforeNode || afterNode,
|
|
108
|
-
to: afterNode,
|
|
109
|
-
duration: 5000
|
|
110
|
-
});
|
|
111
|
-
}
|
|
112
|
-
else if (beforeNode) {
|
|
113
|
-
const fromCenter = beforeNode.center;
|
|
114
|
-
const toCenter = afterNode.center;
|
|
115
|
-
const { x: startX, y: startY } = beforeNode.transcoordS2T(fromCenter.x, fromCenter.y);
|
|
116
|
-
const { x: endX, y: endY } = afterNode.transcoordS2T(toCenter.x, toCenter.y);
|
|
117
|
-
const theta = Math.atan2(endY - startY, endX - startX) + Math.PI / 2;
|
|
118
|
-
this.location = { x: endX, y: endY };
|
|
119
|
-
this.setState('rotation', theta);
|
|
120
|
-
}
|
|
121
|
-
else {
|
|
122
|
-
// beforeNode 없음: afterNode 위치로 즉시 이동
|
|
123
|
-
const toCenter = afterNode.center;
|
|
124
|
-
const { x, y } = afterNode.transcoordS2T(toCenter.x, toCenter.y);
|
|
125
|
-
this.location = { x, y };
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
72
|
}
|
|
73
|
+
/* fmsim.Vehicle (ADR-0167 18): a figure travels between nodes by the same mixin as fmsim's own AGV and OHT */
|
|
74
|
+
registerFigureCapability(VEHICLE, base => VehicleTravel(base));
|
|
129
75
|
//# sourceMappingURL=mcs-vehicle.js.map
|
package/dist/mcs-vehicle.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcs-vehicle.js","sourceRoot":"","sources":["../src/mcs-vehicle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"mcs-vehicle.js","sourceRoot":"","sources":["../src/mcs-vehicle.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAA;AACjE,OAAO,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAA;AACpD,OAAO,EAAE,cAAc,EAAU,MAAM,+BAA+B,CAAA;AACtE,OAAO,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAA;AACzD,OAAO,gBAAgB,MAAM,sBAAsB,CAAA;AAEnD,MAAM,aAAa,GAAG,CAAC,CAAA;AAEvB;;GAEG;AACH,MAAM,CAAC,OAAO,OAAO,UAAW,SAAQ,aAAa,CAAC,gBAAgB,CAAC;IACrE,MAAM,KAAK,UAAU;QACnB,OAAO;YACL,GAAG,gBAAgB,CAAC,UAAU;YAC9B;gBACE,IAAI,EAAE,QAAQ;gBACd,KAAK,EAAE,WAAW;gBAClB,IAAI,EAAE,WAAW;gBACjB,QAAQ,EAAE;oBACR,OAAO,EAAE,CAAC,EAAE,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC;iBAC7C;aACF;SACF,CAAA;IACH,CAAC;IAED,iBAAiB;QACf,OAAO,cAAc,CAAA;IACvB,CAAC;IAED,eAAe,CAAC,GAA6B;QAC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port { LEGEND_VEHICLE, Legend } from './features/mcs-status-default'\nimport { VehicleTravel } from './features/vehicle-travel'\nimport MCSCarrierHolder from './mcs-carrier-holder'\n\nconst DIRECTION_GAP = 3\n\n/**\n * MCS용 Unit > Transport들의 공통 속성을 정의한 오브젝트\n */\nexport default class MCSVehicle extends VehicleTravel(MCSCarrierHolder) {\n static get properties(): any {\n return [\n ...MCSCarrierHolder.properties,\n {\n type: 'select',\n label: 'direction',\n name: 'direction',\n property: {\n options: ['', 'up', 'down', 'left', 'right']\n }\n }\n ]\n }\n\n getLegendFallback(): Legend {\n return LEGEND_VEHICLE\n }\n\n renderDirection(ctx: CanvasRenderingContext2D) {\n const { direction } = this.state\n\n if (direction) {\n const { left, top, width, height } = this.state\n\n ctx.beginPath()\n ctx.translate(left, top)\n\n ctx.strokeStyle = 'black'\n ctx.fillStyle = 'black'\n ctx.lineJoin = 'round'\n ctx.lineWidth = 1\n ctx.setLineDash([])\n\n switch (direction) {\n case 'up':\n ctx.moveTo((width * 1) / 3, -DIRECTION_GAP)\n ctx.lineTo(width / 2, -height / 10 - DIRECTION_GAP)\n ctx.lineTo((width * 2) / 3, -DIRECTION_GAP)\n break\n case 'down':\n ctx.moveTo((width * 1) / 3, height + DIRECTION_GAP)\n ctx.lineTo(width / 2, height + height / 10 + DIRECTION_GAP)\n ctx.lineTo((width * 2) / 3, height + DIRECTION_GAP)\n break\n case 'left':\n ctx.moveTo(-DIRECTION_GAP, (height * 1) / 3)\n ctx.lineTo(-width / 10 - 2, height / 2)\n ctx.lineTo(-DIRECTION_GAP, (height * 2) / 3)\n break\n case 'right':\n default:\n ctx.moveTo(DIRECTION_GAP + width, (height * 1) / 3)\n ctx.lineTo(DIRECTION_GAP + width + width / 10, height / 2)\n ctx.lineTo(DIRECTION_GAP + width, (height * 2) / 3)\n break\n }\n\n ctx.translate(-left, -top)\n ctx.closePath()\n\n ctx.fill()\n ctx.stroke()\n }\n }\n\n // Performance aware\n postrender(ctx: CanvasRenderingContext2D): void {\n super.postrender(ctx)\n // this.renderDirection(ctx)\n }\n}\n\n/* fmsim.Vehicle (ADR-0167 18): a figure travels between nodes by the same mixin as fmsim's own AGV and OHT */\nregisterFigureCapability(VEHICLE, base => VehicleTravel(base) as never)\n"]}
|