@operato/ops-contract 0.9.48 → 0.9.50
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/README.md +12 -5
- package/dist/asset-acceptance.d.ts +27 -0
- package/dist/asset-acceptance.js +33 -0
- package/dist/capability.d.ts +1 -1
- package/dist/capability.js +16 -1
- package/dist/contract.d.ts +61 -3
- package/dist/contract.js +59 -4
- package/dist/domain-catalog.d.ts +9 -2
- package/dist/domain-catalog.js +36 -4
- package/dist/energy-ingest.js +4 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.js +5 -0
- package/dist/intralogistics-profile.d.ts +114 -0
- package/dist/intralogistics-profile.js +149 -0
- package/dist/operational-ingest.d.ts +4 -2
- package/dist/operational-ingest.js +78 -4
- package/dist/route-network.d.ts +84 -0
- package/dist/route-network.js +132 -0
- package/dist/transport-policy.d.ts +79 -0
- package/dist/transport-policy.js +68 -0
- package/dist/travel.d.ts +83 -0
- package/dist/travel.js +32 -0
- package/dist/yms-profile.d.ts +1 -1
- package/dist/yms-profile.js +1 -1
- package/dist-cjs/index.cjs +2392 -1889
- package/package.json +1 -1
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/*
|
|
2
|
+
* **Intralogistics vocabulary** - transport control inside a plant or warehouse (operato-application ADR-0266 decision 8 ④).
|
|
3
|
+
*
|
|
4
|
+
* Not a new twin area (ADR-0266 decision 5): transport crosses wms, mes and yms (warehouse to line, dock to warehouse), and a fact
|
|
5
|
+
* goes to the area its location declares (ADR-0081). This file names the words those facts use, the way the wms and yms profiles
|
|
6
|
+
* do, so the transport control product and the twin spell them once.
|
|
7
|
+
*
|
|
8
|
+
* Semiconductor MCS words map onto existing axes: a carrier is an asset (GS1 GRAI), a port is a location whose parent is its
|
|
9
|
+
* machine's location, a transport command is an order and a transport job is a task.
|
|
10
|
+
*
|
|
11
|
+
* The types here are not entries of `DOMAIN_CATALOG`. That catalogue gives every equipment type one owning area and every logistics
|
|
12
|
+
* location type `storable`; guided equipment works in several areas, and a waypoint holds nothing. How a host resolves these types
|
|
13
|
+
* next to an area's own is the kernel stage's decision (ADR-0266 §5 stage 6) - `intralogisticsTypeOf` answers for this list.
|
|
14
|
+
*/
|
|
15
|
+
/**
|
|
16
|
+
* CBV steps for a carrier moving between ports. All three are CBV's own (ref.gs1.org/cbv) - checked by the CBV bizStep test.
|
|
17
|
+
*
|
|
18
|
+
* The transport control product speaks only of the carrier (GRAI). Stock moving in or out is the warehouse's and the plant's to say
|
|
19
|
+
* (ADR-0266 decision 9) - items in the carrier follow through `carriedBy`.
|
|
20
|
+
*/
|
|
21
|
+
export const ILG_BIZSTEP = {
|
|
22
|
+
/** The carrier left a port. */
|
|
23
|
+
departing: 'urn:epcglobal:cbv:bizstep:departing',
|
|
24
|
+
/** The carrier reached a port. */
|
|
25
|
+
arriving: 'urn:epcglobal:cbv:bizstep:arriving',
|
|
26
|
+
/** The carrier is on its way. */
|
|
27
|
+
transporting: 'urn:epcglobal:cbv:bizstep:transporting'
|
|
28
|
+
};
|
|
29
|
+
/** Location types of the route network. */
|
|
30
|
+
export const ILG_LOCATION_TYPES = ['waypoint', 'port', 'charger', 'parking'];
|
|
31
|
+
/**
|
|
32
|
+
* ISA-95 level of each location type.
|
|
33
|
+
*
|
|
34
|
+
* · `port` - one carrier stays there for a while: `StorageUnit`.
|
|
35
|
+
* · `waypoint` - neither storage nor work, a point passed through. The standard's escape is `Other`; writing `StorageUnit` would
|
|
36
|
+
* make a roll-up count waypoints as storage and the occupancy rate false (the same judgement as the yard's `gate`).
|
|
37
|
+
* · `charger` · `parking` - equipment stands there, not goods: `Other`.
|
|
38
|
+
*/
|
|
39
|
+
const ILG_LOCATION_LEVEL = {
|
|
40
|
+
waypoint: 'Other',
|
|
41
|
+
port: 'StorageUnit',
|
|
42
|
+
charger: 'Other',
|
|
43
|
+
parking: 'Other'
|
|
44
|
+
};
|
|
45
|
+
/**
|
|
46
|
+
* Only the port holds goods (`storable`). A waypoint, a charger and a parking spot declare no capability of their own: a charger's
|
|
47
|
+
* metering belongs to the energy twin's segment that shares its location id.
|
|
48
|
+
*/
|
|
49
|
+
const ILG_LOCATION_CAPABILITIES = {
|
|
50
|
+
waypoint: [],
|
|
51
|
+
port: ['storable'],
|
|
52
|
+
charger: [],
|
|
53
|
+
parking: []
|
|
54
|
+
};
|
|
55
|
+
export const ILG_TYPES = [
|
|
56
|
+
...ILG_LOCATION_TYPES.map((k) => ({
|
|
57
|
+
key: k, role: 'location', label: `twin.type.${k}`, standardClass: { epcis: 'bizLocation' }, identity: { scheme: 'gs1:SGLN' },
|
|
58
|
+
level: ILG_LOCATION_LEVEL[k], capabilities: ILG_LOCATION_CAPABILITIES[k]
|
|
59
|
+
})),
|
|
60
|
+
/* A forklift under transport control keeps the wms `forklift` type and adds `guided` in the site's own declaration. */
|
|
61
|
+
{ key: 'amr', role: 'equipment', label: 'twin.type.amr', standardClass: { epcis: 'object', iso55000: 'Asset' }, identity: { scheme: 'gs1:GIAI' }, capabilities: ['mobile', 'guided', 'operable', 'energyStoring'] },
|
|
62
|
+
{ key: 'agv', role: 'equipment', label: 'twin.type.agv', standardClass: { epcis: 'object', iso55000: 'Asset' }, identity: { scheme: 'gs1:GIAI' }, capabilities: ['mobile', 'guided', 'operable', 'energyStoring'] }
|
|
63
|
+
];
|
|
64
|
+
/** This list's entry for a type key, or `undefined`. */
|
|
65
|
+
export function intralogisticsTypeOf(key) {
|
|
66
|
+
return ILG_TYPES.find(t => t.key === key);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Whether equipment of this type travels the route network under transport control (`guided`). The app and the kernel read the
|
|
70
|
+
* same answer from the vocabulary.
|
|
71
|
+
*/
|
|
72
|
+
export function isGuidedType(key) {
|
|
73
|
+
return intralogisticsTypeOf(key)?.capabilities.includes('guided') ?? false;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Equipment property ids transport simulation reads (`ResourceProperty.id` on equipment or its class). The standards name no such
|
|
77
|
+
* parameters, so they are named here, once - like `OP_PARAM` - and the fact that we named them is not hidden
|
|
78
|
+
* (design/plans/transport-execution-wiring.md W2). Each is a percentage of full charge, so its unit is UN/CEFACT `P1` (percent);
|
|
79
|
+
* a value without that unit is not read - a physical quantity without a unit cannot be used.
|
|
80
|
+
*
|
|
81
|
+
* Absent properties mean the battery is not modelled for that machine: charge stays unknown rather than starting at a made-up
|
|
82
|
+
* level or draining at a made-up rate.
|
|
83
|
+
*/
|
|
84
|
+
export const ILG_EQUIPMENT_PROPERTY = {
|
|
85
|
+
/** State of charge when the simulation starts, percent (`P1`). */
|
|
86
|
+
charge: 'charge',
|
|
87
|
+
/** Charge used per metre travelled, percentage points (`P1`). */
|
|
88
|
+
chargeUsePerMetre: 'chargeUsePerMetre',
|
|
89
|
+
/** Charge gained per minute on a charger, percentage points (`P1`). */
|
|
90
|
+
chargeGainPerMinute: 'chargeGainPerMinute'
|
|
91
|
+
};
|
|
92
|
+
/**
|
|
93
|
+
* Equipment property ids that name a machine to its robot link (operato-application ADR-0266 decision 10, operato-intralogic design §14,
|
|
94
|
+
* 2026-12-04). VDA 5050 addresses a vehicle by manufacturer and serial number - its topics are
|
|
95
|
+
* `<interface>/<majorVersion>/<manufacturer>/<serialNumber>/<topic>` - and these are the two values, as text, without a unit.
|
|
96
|
+
* A machine without both is outside the robot link: people report its travel by hand.
|
|
97
|
+
*/
|
|
98
|
+
export const ILG_ROBOT_IDENTITY_PROPERTY = {
|
|
99
|
+
manufacturer: 'manufacturer',
|
|
100
|
+
serialNumber: 'serialNumber'
|
|
101
|
+
};
|
|
102
|
+
/** UN/CEFACT common code for percent - the unit of every `ILG_EQUIPMENT_PROPERTY`. */
|
|
103
|
+
export const PERCENT_UOM = 'P1';
|
|
104
|
+
/** A transport command (MCS) - `OrderState.kind`. */
|
|
105
|
+
export const ILG_ORDER_KIND = {
|
|
106
|
+
transport: 'transport'
|
|
107
|
+
};
|
|
108
|
+
/**
|
|
109
|
+
* Transport jobs (MCS) - `TaskState.kind`.
|
|
110
|
+
*
|
|
111
|
+
* · `transport-leg` - one leg, port to port. A command can split into several legs (a stop on the way, an alternate destination).
|
|
112
|
+
* · `charge` - occupies a charger. Charging takes a place, so it is a task.
|
|
113
|
+
* · `park` - to a parking spot.
|
|
114
|
+
*/
|
|
115
|
+
export const ILG_TASK_KIND = {
|
|
116
|
+
leg: 'transport-leg',
|
|
117
|
+
charge: 'charge',
|
|
118
|
+
park: 'park'
|
|
119
|
+
};
|
|
120
|
+
/**
|
|
121
|
+
* Why a transport command failed. Closed: a reason the receiver does not know cannot be shown or counted. Values are refusal codes
|
|
122
|
+
* (kebab-case); wording is the presentation layer's.
|
|
123
|
+
*/
|
|
124
|
+
export const TRANSPORT_FAILURE_REASON = [
|
|
125
|
+
'no-route',
|
|
126
|
+
'destination-unavailable',
|
|
127
|
+
'carrier-not-found',
|
|
128
|
+
/** The carrier identified at pick-up is not the one the command named. */
|
|
129
|
+
'carrier-mismatch',
|
|
130
|
+
'cancelled-by-source',
|
|
131
|
+
'equipment-fault'
|
|
132
|
+
];
|
|
133
|
+
export function isTransportFailureReason(v) {
|
|
134
|
+
return typeof v === 'string' && TRANSPORT_FAILURE_REASON.includes(v);
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
137
|
+
* Operational attention kinds the transport control product raises - `<product>.<code>` (`operational-attention.ts`).
|
|
138
|
+
* Keys and values only; no sentences (the kernel's rule for attentions).
|
|
139
|
+
*/
|
|
140
|
+
export const ILG_ATTENTION_KIND = {
|
|
141
|
+
deadlock: 'intralogic.traffic-deadlock',
|
|
142
|
+
blocked: 'intralogic.traffic-blocked',
|
|
143
|
+
lowCharge: 'intralogic.low-charge',
|
|
144
|
+
linkLost: 'intralogic.link-lost',
|
|
145
|
+
noRoute: 'intralogic.no-route',
|
|
146
|
+
rerouted: 'intralogic.rerouted',
|
|
147
|
+
carrierUnidentified: 'intralogic.carrier-unidentified',
|
|
148
|
+
carrierDuplicate: 'intralogic.carrier-duplicate'
|
|
149
|
+
};
|
|
@@ -4,7 +4,7 @@ import type { IngestResult } from './face2-adapter.ts';
|
|
|
4
4
|
* 주석의 수가 union 보다 오래 살아 읽는 사람이 여섯에서 멈췄다). 리듀서가 다루는 것과 같은 목록이다(주목 확인은 우리 안의
|
|
5
5
|
* 행위라 제외).
|
|
6
6
|
*/
|
|
7
|
-
export type OperationalKind = 'task' | 'equipment' | 'equipment-period' | 'person' | 'asset' | 'order' | 'quality' | 'test' | 'disposition' | 'material-lot' | 'observation' | 'complete';
|
|
7
|
+
export type OperationalKind = 'task' | 'equipment' | 'equipment-period' | 'person' | 'asset' | 'order' | 'quality' | 'test' | 'disposition' | 'material-lot' | 'observation' | 'complete' | 'travel-passed' | 'travel-reservation' | 'travel-link' | 'travel-pose';
|
|
8
8
|
/**
|
|
9
9
|
* 정규 운영 레코드 — **델타의 필드 이름 + 시각(`at`)**.
|
|
10
10
|
*
|
|
@@ -51,11 +51,13 @@ export interface ObjectShape {
|
|
|
51
51
|
/** 0 보다 커야 하는 수 — 「모른다」는 **비워서** 말한다(0 으로 말하지 않는다). */
|
|
52
52
|
positive?: readonly string[];
|
|
53
53
|
}
|
|
54
|
+
/** 이 레코드가 운행 사실인가 — 설비 에너지 판정이 묻는다(`isEnergyEquipmentRecord`, 두 판정은 배타). */
|
|
55
|
+
export declare function isTravelRecord(record: unknown): boolean;
|
|
54
56
|
/**
|
|
55
57
|
* 이 레코드가 어느 운영 사실인가 — **라우팅 판정을 한 곳에 둔다**(소비처가 각자 짐작하지 않게).
|
|
56
58
|
*
|
|
57
59
|
* EPCIS·에너지와 겹치지 않게 본다: `epc`·`meterId` 가 있으면 그쪽 어휘이고, `equipmentId` 는 설비
|
|
58
|
-
* **에너지** 상태의 이름이다(운영 설비는 `moverId`). 품질은 설비와 정체 필드를 공유하므로 `good` 으로
|
|
60
|
+
* **에너지** 상태의 이름이다(운영 설비는 `moverId`) — 운행 사실 넷만 그 이름을 쓴다(위 `travel-*`). 품질은 설비와 정체 필드를 공유하므로 `good` 으로
|
|
59
61
|
* 가른다 — 둘 다 아니면 어느 쪽인지 모르는 것이고, 모르면 받지 않는다.
|
|
60
62
|
*
|
|
61
63
|
* ── 순서가 뜻을 갖는다: **주체와 참조는 다르다** ────────────────────────────
|
|
@@ -36,6 +36,7 @@
|
|
|
36
36
|
*/
|
|
37
37
|
import { OP_EVENT, TASK_STATUS, BASIS_UNKNOWN, EQUIPMENT_STATUS, PERSON_STATUS, ASSET_STATUS, DISPOSITION_DECISION, MATERIAL_ACTUAL_USE, MATERIAL_LOT_USE, isTestSpecificationBasis, isRecipeExecutionBasis, isMaterialExecutionBasis } from "./contract.js";
|
|
38
38
|
import { isWorkShiftExecutionBasis } from "./work-shift-basis.js";
|
|
39
|
+
import { TRAVEL_LINK_JUDGED_BY, TRAVEL_LINK_STATE } from "./travel.js";
|
|
39
40
|
/**
|
|
40
41
|
* 객체 한 줄이 선언된 안쪽 모양을 지키나 — **선언하지 않은 자리는 보지 않는다.**
|
|
41
42
|
*
|
|
@@ -231,7 +232,12 @@ const SPECS = {
|
|
|
231
232
|
*/
|
|
232
233
|
recipeKey: 'string', recipeBasis: 'object', materialBasis: 'object[]',
|
|
233
234
|
/* 근거 칸이 빈 까닭 — 닫힌 낱말이다(§`BASIS_UNKNOWN`). 투입이 근거 장치보다 먼저였던 오더도 이행은 사실이다. */
|
|
234
|
-
basisUnknown: 'string'
|
|
235
|
+
basisUnknown: 'string',
|
|
236
|
+
/*
|
|
237
|
+
* 실패 · 취소로 닫힌 까닭 — 열린 낱말이다(도메인이 소유한다. 구내 반송은 `TRANSPORT_FAILURE_REASON`). 2026-12-04: 반송 지시가
|
|
238
|
+
* 실패로 닫힐 때(`ORDER_TERMINAL_STATUS` 의 `failed`) 그 사유가 오더에 실린다 — 그 작업은 `cancelled` 로 가서 사유를 들 곳이 없다.
|
|
239
|
+
*/
|
|
240
|
+
reasonCode: 'string'
|
|
235
241
|
},
|
|
236
242
|
/* 상태·종류는 도메인이 소유한다 — 닫지 않는다. 근거가 빈 까닭은 커널이 읽으므로 닫는다. */
|
|
237
243
|
enums: { basisUnknown: BASIS_UNKNOWN },
|
|
@@ -441,13 +447,77 @@ const SPECS = {
|
|
|
441
447
|
effectiveTime: 'string', effectiveEndTime: 'string', recordTime: 'string',
|
|
442
448
|
source: 'string', derived: 'boolean'
|
|
443
449
|
}
|
|
450
|
+
},
|
|
451
|
+
/*
|
|
452
|
+
* ── 경로망 위의 운행 (2026-12-04, operato-application ADR-0266 결정 8 ②, `travel.ts`) ─────────────────────────────────────
|
|
453
|
+
*
|
|
454
|
+
* 구내 반송 제품이 보내는 넷. 사건 이름 · 데이터 모양은 이미 있었고(`OP_EVENT.travel*`, 커널의 접기도 섰다) 들어올 문만 없었다 —
|
|
455
|
+
* 그래서 이 표에 선다(고칠 자리가 셋인 까닭, 위 `match` 의 머리말).
|
|
456
|
+
*
|
|
457
|
+
* 장비를 `equipmentId` 로 부른다(`travel.ts` 의 결정 — 옛 와이어 이름이 아니다). 그 이름은 설비 **에너지** 상태의 것이기도 해서,
|
|
458
|
+
* 갈래는 **함께 오는 칸**으로 가른다: 지난 자리(`location`) · 잡은 구간(`connectionIds`) · 통신(`link`) · 위치(`pose`). 에너지 문은
|
|
459
|
+
* 이 넷을 밀어낸다(`isEnergyEquipmentRecord` — 판정끼리 배타). 이 갈래들은 다른 어떤 갈래보다 먼저 본다 — 정체 칸이 다른 갈래와
|
|
460
|
+
* 겹치지 않으므로 순서는 넷 사이의 것이다.
|
|
461
|
+
*/
|
|
462
|
+
'travel-passed': {
|
|
463
|
+
eventType: OP_EVENT.travelPassed,
|
|
464
|
+
match: ['equipmentId', 'location'],
|
|
465
|
+
matchOrder: 5,
|
|
466
|
+
identity: 'equipmentId',
|
|
467
|
+
required: ['equipmentId', 'location'],
|
|
468
|
+
fields: { equipmentId: 'string', location: 'string', heading: 'number', recordTime: 'string' }
|
|
469
|
+
},
|
|
470
|
+
'travel-reservation': {
|
|
471
|
+
eventType: OP_EVENT.travelReservation,
|
|
472
|
+
match: ['equipmentId', 'connectionIds'],
|
|
473
|
+
matchOrder: 5,
|
|
474
|
+
identity: 'equipmentId',
|
|
475
|
+
/* 빈 목록은 「전부 놓았다」는 말이다 — 비어 있어도 받는다(아래 `ingest` 의 빈 값 규칙은 배열을 비었다고 보지 않는다). */
|
|
476
|
+
required: ['equipmentId', 'connectionIds'],
|
|
477
|
+
fields: { equipmentId: 'string', connectionIds: 'string[]', recordTime: 'string' }
|
|
478
|
+
},
|
|
479
|
+
'travel-link': {
|
|
480
|
+
eventType: OP_EVENT.travelLink,
|
|
481
|
+
match: ['equipmentId', 'link'],
|
|
482
|
+
matchOrder: 5,
|
|
483
|
+
identity: 'equipmentId',
|
|
484
|
+
required: ['equipmentId', 'link'],
|
|
485
|
+
fields: { equipmentId: 'string', link: 'object', recordTime: 'string' },
|
|
486
|
+
shapes: {
|
|
487
|
+
link: {
|
|
488
|
+
required: ['state', 'lastSeenAt', 'judgedBy'],
|
|
489
|
+
fields: { lastSeenAt: 'string', lastLocation: 'string' },
|
|
490
|
+
enums: { state: TRAVEL_LINK_STATE, judgedBy: TRAVEL_LINK_JUDGED_BY }
|
|
491
|
+
}
|
|
492
|
+
}
|
|
493
|
+
},
|
|
494
|
+
'travel-pose': {
|
|
495
|
+
eventType: OP_EVENT.travelPose,
|
|
496
|
+
match: ['equipmentId', 'pose'],
|
|
497
|
+
matchOrder: 5,
|
|
498
|
+
identity: 'equipmentId',
|
|
499
|
+
required: ['equipmentId', 'pose'],
|
|
500
|
+
fields: { equipmentId: 'string', pose: 'object', recordTime: 'string' },
|
|
501
|
+
shapes: {
|
|
502
|
+
pose: {
|
|
503
|
+
required: ['x', 'y', 'theta', 'networkVersion', 'at'],
|
|
504
|
+
fields: { x: 'number', y: 'number', theta: 'number', networkVersion: 'string', at: 'string', deviationM: 'number' }
|
|
505
|
+
}
|
|
506
|
+
}
|
|
444
507
|
}
|
|
445
508
|
};
|
|
509
|
+
/** 운행 사실의 갈래 — 정체 칸이 `equipmentId` 인 것들. 에너지 문이 이것으로 밀어낸다. */
|
|
510
|
+
const TRAVEL_KINDS = Object.keys(SPECS).filter(kind => SPECS[kind].identity === 'equipmentId');
|
|
511
|
+
/** 이 레코드가 운행 사실인가 — 설비 에너지 판정이 묻는다(`isEnergyEquipmentRecord`, 두 판정은 배타). */
|
|
512
|
+
export function isTravelRecord(record) {
|
|
513
|
+
const kind = operationalKindOf(record);
|
|
514
|
+
return kind !== undefined && TRAVEL_KINDS.includes(kind);
|
|
515
|
+
}
|
|
446
516
|
/**
|
|
447
517
|
* 이 레코드가 어느 운영 사실인가 — **라우팅 판정을 한 곳에 둔다**(소비처가 각자 짐작하지 않게).
|
|
448
518
|
*
|
|
449
519
|
* EPCIS·에너지와 겹치지 않게 본다: `epc`·`meterId` 가 있으면 그쪽 어휘이고, `equipmentId` 는 설비
|
|
450
|
-
* **에너지** 상태의 이름이다(운영 설비는 `moverId`). 품질은 설비와 정체 필드를 공유하므로 `good` 으로
|
|
520
|
+
* **에너지** 상태의 이름이다(운영 설비는 `moverId`) — 운행 사실 넷만 그 이름을 쓴다(위 `travel-*`). 품질은 설비와 정체 필드를 공유하므로 `good` 으로
|
|
451
521
|
* 가른다 — 둘 다 아니면 어느 쪽인지 모르는 것이고, 모르면 받지 않는다.
|
|
452
522
|
*
|
|
453
523
|
* ── 순서가 뜻을 갖는다: **주체와 참조는 다르다** ────────────────────────────
|
|
@@ -462,10 +532,12 @@ export function operationalKindOf(record) {
|
|
|
462
532
|
const r = record;
|
|
463
533
|
/*
|
|
464
534
|
* EPCIS·에너지와 겹치지 않게 본다: `epc`·`meterId` 가 있으면 그쪽 어휘이고, `equipmentId` 는 설비
|
|
465
|
-
* **에너지** 상태의 이름이다(운영 설비는 `moverId`)
|
|
535
|
+
* **에너지** 상태의 이름이다(운영 설비는 `moverId`) — 운행 사실 넷만 그 이름을 쓴다.
|
|
466
536
|
*/
|
|
467
|
-
if (r.epc !== undefined || r.meterId !== undefined
|
|
537
|
+
if (r.epc !== undefined || r.meterId !== undefined)
|
|
468
538
|
return undefined;
|
|
539
|
+
/* `equipmentId` 를 실었으면 운행 사실만 본다 — 그 밖의 갈래에서 그 이름은 에너지 어휘다. */
|
|
540
|
+
const travelOnly = r.equipmentId !== undefined;
|
|
469
541
|
/* 문자열은 비어 있으면 없는 것으로 본다 — 공백만 실은 필드는 말한 것이 아니다. */
|
|
470
542
|
const present = (k) => {
|
|
471
543
|
const v = r[k];
|
|
@@ -475,6 +547,8 @@ export function operationalKindOf(record) {
|
|
|
475
547
|
};
|
|
476
548
|
for (const kind of MATCH_ORDER) {
|
|
477
549
|
const spec = SPECS[kind];
|
|
550
|
+
if (travelOnly !== (spec.identity === 'equipmentId'))
|
|
551
|
+
continue;
|
|
478
552
|
const fields = spec.match ?? [spec.identity];
|
|
479
553
|
if (fields.every(present))
|
|
480
554
|
return kind;
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import type { EffectivePeriod, ISOTime, RefusalParams, ResourceClassDef, ResourceProperty } from './contract.ts';
|
|
2
|
+
/** A path from one location to another. VDA 5050 `edge`. */
|
|
3
|
+
export interface LocationConnection extends EffectivePeriod {
|
|
4
|
+
id: string;
|
|
5
|
+
/** `locations.id` (or a referenced location of another lens). */
|
|
6
|
+
from: string;
|
|
7
|
+
to: string;
|
|
8
|
+
/** `one-way` = from -> to only. */
|
|
9
|
+
direction: ConnectionDirection;
|
|
10
|
+
/** Metres, > 0. The basis of travel time. Never computed from coordinates here. */
|
|
11
|
+
lengthM: number;
|
|
12
|
+
/** Metres per second, > 0. Absent = the equipment's own speed. */
|
|
13
|
+
maxSpeedMps?: number;
|
|
14
|
+
/** How many machines may be on this connection at once. Absent = 1 (exclusive). */
|
|
15
|
+
capacity?: number;
|
|
16
|
+
/** Equipment classes allowed to pass. Absent = no restriction. */
|
|
17
|
+
equipmentClassIds?: string[];
|
|
18
|
+
properties?: ResourceProperty[];
|
|
19
|
+
}
|
|
20
|
+
export declare const CONNECTION_DIRECTION: readonly ["one-way", "two-way"];
|
|
21
|
+
export type ConnectionDirection = (typeof CONNECTION_DIRECTION)[number];
|
|
22
|
+
/** An ordered list of connections - "this equipment goes this way". */
|
|
23
|
+
export interface FixedRoute extends EffectivePeriod {
|
|
24
|
+
id: string;
|
|
25
|
+
/** In travel order; each must start where the previous one ended. */
|
|
26
|
+
connectionIds: string[];
|
|
27
|
+
/** Equipment bound to this route. Absent = advisory for all. */
|
|
28
|
+
equipmentClassIds?: string[];
|
|
29
|
+
binding: FixedRouteBinding;
|
|
30
|
+
}
|
|
31
|
+
export declare const FIXED_ROUTE_BINDING: readonly ["mandatory", "preferred"];
|
|
32
|
+
export type FixedRouteBinding = (typeof FIXED_ROUTE_BINDING)[number];
|
|
33
|
+
/** One published edition of the network. A published edition is never edited; a change is a new version. */
|
|
34
|
+
export interface RouteNetworkEdition {
|
|
35
|
+
id: string;
|
|
36
|
+
version: string;
|
|
37
|
+
publishedAt: ISOTime;
|
|
38
|
+
publishedBy?: string;
|
|
39
|
+
}
|
|
40
|
+
/** Default capacity of a connection when none is declared. */
|
|
41
|
+
export declare const DEFAULT_CONNECTION_CAPACITY = 1;
|
|
42
|
+
export declare const ROUTE_NETWORK_ISSUE: {
|
|
43
|
+
readonly connectionDangling: "route-connection-dangling";
|
|
44
|
+
readonly connectionSelf: "route-connection-self";
|
|
45
|
+
readonly connectionLength: "route-connection-length";
|
|
46
|
+
readonly connectionSpeed: "route-connection-speed";
|
|
47
|
+
readonly connectionCapacity: "route-connection-capacity";
|
|
48
|
+
readonly connectionDirection: "route-connection-direction";
|
|
49
|
+
readonly connectionDuplicate: "route-connection-duplicate";
|
|
50
|
+
readonly connectionUnknownClass: "route-connection-unknown-class";
|
|
51
|
+
readonly fixedEmpty: "route-fixed-empty";
|
|
52
|
+
readonly fixedUnknownConnection: "route-fixed-unknown-connection";
|
|
53
|
+
readonly fixedBroken: "route-fixed-broken";
|
|
54
|
+
readonly fixedClass: "route-fixed-class";
|
|
55
|
+
readonly fixedBinding: "route-fixed-binding";
|
|
56
|
+
readonly duplicateId: "route-duplicate-id";
|
|
57
|
+
};
|
|
58
|
+
export type RouteNetworkIssueCode = (typeof ROUTE_NETWORK_ISSUE)[keyof typeof ROUTE_NETWORK_ISSUE];
|
|
59
|
+
export interface RouteNetworkIssue {
|
|
60
|
+
code: RouteNetworkIssueCode;
|
|
61
|
+
/** The connection or fixed route the issue is about. */
|
|
62
|
+
subject: string;
|
|
63
|
+
params: RefusalParams;
|
|
64
|
+
}
|
|
65
|
+
export interface RouteNetworkInput {
|
|
66
|
+
locations?: readonly {
|
|
67
|
+
id: string;
|
|
68
|
+
}[];
|
|
69
|
+
referencedLocations?: readonly {
|
|
70
|
+
id: string;
|
|
71
|
+
}[];
|
|
72
|
+
connections?: readonly LocationConnection[];
|
|
73
|
+
fixedRoutes?: readonly FixedRoute[];
|
|
74
|
+
equipmentClasses?: readonly ResourceClassDef[];
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Checks the structure of a route network. Returns every issue found (empty = structurally sound).
|
|
78
|
+
*
|
|
79
|
+
* Not checked here: whether a port can be reached, dead ends, deadlock risk. Those need graph search and belong to the deciders
|
|
80
|
+
* (the app's rules, the kernel's execution policy).
|
|
81
|
+
*/
|
|
82
|
+
export declare function validateRouteNetwork(def: RouteNetworkInput): RouteNetworkIssue[];
|
|
83
|
+
/** Whether equipment of these classes may pass this connection (class closure included). */
|
|
84
|
+
export declare function connectionAdmits(c: LocationConnection, equipmentClassIds: readonly string[], classes?: readonly ResourceClassDef[]): boolean;
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import { classClosure } from "./contract.js";
|
|
2
|
+
export const CONNECTION_DIRECTION = ['one-way', 'two-way'];
|
|
3
|
+
export const FIXED_ROUTE_BINDING = ['mandatory', 'preferred'];
|
|
4
|
+
/** Default capacity of a connection when none is declared. */
|
|
5
|
+
export const DEFAULT_CONNECTION_CAPACITY = 1;
|
|
6
|
+
export const ROUTE_NETWORK_ISSUE = {
|
|
7
|
+
connectionDangling: 'route-connection-dangling',
|
|
8
|
+
connectionSelf: 'route-connection-self',
|
|
9
|
+
connectionLength: 'route-connection-length',
|
|
10
|
+
connectionSpeed: 'route-connection-speed',
|
|
11
|
+
connectionCapacity: 'route-connection-capacity',
|
|
12
|
+
connectionDirection: 'route-connection-direction',
|
|
13
|
+
connectionDuplicate: 'route-connection-duplicate',
|
|
14
|
+
connectionUnknownClass: 'route-connection-unknown-class',
|
|
15
|
+
fixedEmpty: 'route-fixed-empty',
|
|
16
|
+
fixedUnknownConnection: 'route-fixed-unknown-connection',
|
|
17
|
+
fixedBroken: 'route-fixed-broken',
|
|
18
|
+
fixedClass: 'route-fixed-class',
|
|
19
|
+
fixedBinding: 'route-fixed-binding',
|
|
20
|
+
duplicateId: 'route-duplicate-id'
|
|
21
|
+
};
|
|
22
|
+
const positiveNumber = (v) => typeof v === 'number' && Number.isFinite(v) && v > 0;
|
|
23
|
+
/** The two ends a connection can be entered from, in its allowed directions. */
|
|
24
|
+
function traversals(c) {
|
|
25
|
+
return c.direction === 'two-way' ? [{ from: c.from, to: c.to }, { from: c.to, to: c.from }] : [{ from: c.from, to: c.to }];
|
|
26
|
+
}
|
|
27
|
+
/**
|
|
28
|
+
* Whether equipment of `classIds` may pass `c`. A connection without a class list admits everyone; with one, the equipment's class
|
|
29
|
+
* closure (base classes included) must meet it - an `amr-small` derived from `amr` passes an `amr` connection.
|
|
30
|
+
*/
|
|
31
|
+
function admits(c, classIds, classes) {
|
|
32
|
+
if (!c.equipmentClassIds || c.equipmentClassIds.length === 0)
|
|
33
|
+
return true;
|
|
34
|
+
const allowed = new Set(c.equipmentClassIds);
|
|
35
|
+
return classIds.every(id => [...classClosure([id], classes)].some(k => allowed.has(k)));
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Checks the structure of a route network. Returns every issue found (empty = structurally sound).
|
|
39
|
+
*
|
|
40
|
+
* Not checked here: whether a port can be reached, dead ends, deadlock risk. Those need graph search and belong to the deciders
|
|
41
|
+
* (the app's rules, the kernel's execution policy).
|
|
42
|
+
*/
|
|
43
|
+
export function validateRouteNetwork(def) {
|
|
44
|
+
const issues = [];
|
|
45
|
+
const places = new Set([...(def.locations ?? []), ...(def.referencedLocations ?? [])].map(l => l.id));
|
|
46
|
+
const connections = def.connections ?? [];
|
|
47
|
+
const classIds = new Set((def.equipmentClasses ?? []).map(c => c.id));
|
|
48
|
+
const byId = new Map();
|
|
49
|
+
const seenEnds = new Set();
|
|
50
|
+
for (const c of connections) {
|
|
51
|
+
if (byId.has(c.id))
|
|
52
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.duplicateId, subject: c.id, params: { kind: 'connection' } });
|
|
53
|
+
byId.set(c.id, c);
|
|
54
|
+
for (const end of [c.from, c.to]) {
|
|
55
|
+
if (!places.has(end))
|
|
56
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDangling, subject: c.id, params: { location: end } });
|
|
57
|
+
}
|
|
58
|
+
if (c.from === c.to)
|
|
59
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionSelf, subject: c.id, params: { location: c.from } });
|
|
60
|
+
if (!CONNECTION_DIRECTION.includes(c.direction)) {
|
|
61
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDirection, subject: c.id, params: { direction: String(c.direction) } });
|
|
62
|
+
}
|
|
63
|
+
if (!positiveNumber(c.lengthM))
|
|
64
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionLength, subject: c.id, params: { lengthM: String(c.lengthM) } });
|
|
65
|
+
if (c.maxSpeedMps !== undefined && !positiveNumber(c.maxSpeedMps)) {
|
|
66
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionSpeed, subject: c.id, params: { maxSpeedMps: String(c.maxSpeedMps) } });
|
|
67
|
+
}
|
|
68
|
+
if (c.capacity !== undefined && !(Number.isInteger(c.capacity) && c.capacity >= 1)) {
|
|
69
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionCapacity, subject: c.id, params: { capacity: String(c.capacity) } });
|
|
70
|
+
}
|
|
71
|
+
/* A class list may only name declared classes - but only when the twin declares classes at all. A twin without class
|
|
72
|
+
definitions still names classes by id (classClosure takes the ids as they are), so absence of definitions is not an error. */
|
|
73
|
+
if (classIds.size > 0) {
|
|
74
|
+
for (const id of c.equipmentClassIds ?? []) {
|
|
75
|
+
if (!classIds.has(id))
|
|
76
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionUnknownClass, subject: c.id, params: { equipmentClassId: id } });
|
|
77
|
+
}
|
|
78
|
+
}
|
|
79
|
+
/* Two connections over the same ends in the same direction are one path declared twice; a reader would not know which
|
|
80
|
+
length or speed holds. A one-way pair in opposite directions is two paths, not a duplicate. */
|
|
81
|
+
for (const t of traversals(c)) {
|
|
82
|
+
const key = `${t.from}\u0000${t.to}`;
|
|
83
|
+
if (seenEnds.has(key))
|
|
84
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.connectionDuplicate, subject: c.id, params: { from: t.from, to: t.to } });
|
|
85
|
+
seenEnds.add(key);
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
const routeIds = new Set();
|
|
89
|
+
for (const r of def.fixedRoutes ?? []) {
|
|
90
|
+
if (routeIds.has(r.id))
|
|
91
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.duplicateId, subject: r.id, params: { kind: 'fixed-route' } });
|
|
92
|
+
routeIds.add(r.id);
|
|
93
|
+
if (!FIXED_ROUTE_BINDING.includes(r.binding)) {
|
|
94
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedBinding, subject: r.id, params: { binding: String(r.binding) } });
|
|
95
|
+
}
|
|
96
|
+
if (!r.connectionIds || r.connectionIds.length === 0) {
|
|
97
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedEmpty, subject: r.id, params: {} });
|
|
98
|
+
continue;
|
|
99
|
+
}
|
|
100
|
+
const legs = [];
|
|
101
|
+
for (const id of r.connectionIds) {
|
|
102
|
+
const c = byId.get(id);
|
|
103
|
+
if (!c)
|
|
104
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedUnknownConnection, subject: r.id, params: { connection: id } });
|
|
105
|
+
else
|
|
106
|
+
legs.push(c);
|
|
107
|
+
}
|
|
108
|
+
if (legs.length !== r.connectionIds.length)
|
|
109
|
+
continue;
|
|
110
|
+
/* Walk the route: the first leg may be entered from either end it allows; every later leg must be entered where the
|
|
111
|
+
previous one left off, in a direction it allows. */
|
|
112
|
+
let at = new Set(traversals(legs[0]).map(t => t.to));
|
|
113
|
+
for (let i = 1; i < legs.length; i++) {
|
|
114
|
+
const next = new Set(traversals(legs[i]).filter(t => at.has(t.from)).map(t => t.to));
|
|
115
|
+
if (next.size === 0) {
|
|
116
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedBroken, subject: r.id, params: { after: legs[i - 1].id, connection: legs[i].id } });
|
|
117
|
+
break;
|
|
118
|
+
}
|
|
119
|
+
at = next;
|
|
120
|
+
}
|
|
121
|
+
for (const classId of r.equipmentClassIds ?? []) {
|
|
122
|
+
const blocked = legs.find(c => !admits(c, [classId], def.equipmentClasses));
|
|
123
|
+
if (blocked)
|
|
124
|
+
issues.push({ code: ROUTE_NETWORK_ISSUE.fixedClass, subject: r.id, params: { equipmentClassId: classId, connection: blocked.id } });
|
|
125
|
+
}
|
|
126
|
+
}
|
|
127
|
+
return issues;
|
|
128
|
+
}
|
|
129
|
+
/** Whether equipment of these classes may pass this connection (class closure included). */
|
|
130
|
+
export function connectionAdmits(c, equipmentClassIds, classes) {
|
|
131
|
+
return admits(c, equipmentClassIds, classes);
|
|
132
|
+
}
|
|
@@ -0,0 +1,79 @@
|
|
|
1
|
+
import type { RefusalParams } from './contract.ts';
|
|
2
|
+
export type PolicyParams = Record<string, number | string | boolean>;
|
|
3
|
+
/** Which machine takes which job. */
|
|
4
|
+
export declare const DISPATCH_RULE: {
|
|
5
|
+
/** The first available machine in the kernel's own order - what its assignment does today. */
|
|
6
|
+
readonly firstIdle: "firstIdle";
|
|
7
|
+
/** The machine that reaches the pick-up soonest; ties by id. */
|
|
8
|
+
readonly minEta: "minEta";
|
|
9
|
+
};
|
|
10
|
+
export type DispatchRuleName = (typeof DISPATCH_RULE)[keyof typeof DISPATCH_RULE];
|
|
11
|
+
/** Which way it goes. */
|
|
12
|
+
export declare const ROUTING_RULE: {
|
|
13
|
+
/** Least travel time, reservations not considered. Connection time = length / effective speed. */
|
|
14
|
+
readonly shortestTime: "shortestTime";
|
|
15
|
+
/** Least arrival time over time windows: a connection held past its capacity is waited for or avoided. */
|
|
16
|
+
readonly timeWindow: "timeWindow";
|
|
17
|
+
};
|
|
18
|
+
export type RoutingRuleName = (typeof ROUTING_RULE)[keyof typeof ROUTING_RULE];
|
|
19
|
+
export interface TransportPolicySet {
|
|
20
|
+
id: string;
|
|
21
|
+
/** A published set is never edited; a change is a new version. */
|
|
22
|
+
version: string;
|
|
23
|
+
/** Which machine takes which job. */
|
|
24
|
+
dispatch: {
|
|
25
|
+
rule: DispatchRuleName;
|
|
26
|
+
params?: PolicyParams;
|
|
27
|
+
};
|
|
28
|
+
/** Which way it goes. */
|
|
29
|
+
routing: {
|
|
30
|
+
rule: RoutingRuleName;
|
|
31
|
+
params?: PolicyParams;
|
|
32
|
+
};
|
|
33
|
+
traffic: {
|
|
34
|
+
/** How far ahead connections are reserved, seconds. */
|
|
35
|
+
horizonS?: number;
|
|
36
|
+
/** What a machine does when its next connection is taken. */
|
|
37
|
+
onConflict: TrafficConflictAction;
|
|
38
|
+
};
|
|
39
|
+
charging: {
|
|
40
|
+
/** Go charge below this state of charge, percent. */
|
|
41
|
+
lowSoc: number;
|
|
42
|
+
/** Charge up to this, percent. */
|
|
43
|
+
targetSoc: number;
|
|
44
|
+
/** Charge while idle even above `lowSoc`. */
|
|
45
|
+
opportunistic?: boolean;
|
|
46
|
+
/** Time-of-use periods to avoid - period ids of the ops-master tariff (`tariff.ts`). */
|
|
47
|
+
avoidTariffPeriodIds?: string[];
|
|
48
|
+
};
|
|
49
|
+
/** Where to go instead when a destination is unavailable (equipment down, port full). In order of preference. */
|
|
50
|
+
alternates?: TransportAlternate[];
|
|
51
|
+
}
|
|
52
|
+
export declare const TRAFFIC_CONFLICT_ACTION: readonly ["wait", "replan", "yield"];
|
|
53
|
+
export type TrafficConflictAction = (typeof TRAFFIC_CONFLICT_ACTION)[number];
|
|
54
|
+
export interface TransportAlternate {
|
|
55
|
+
/** `locations.id` */
|
|
56
|
+
destination: string;
|
|
57
|
+
alternatives: string[];
|
|
58
|
+
}
|
|
59
|
+
export declare const TRANSPORT_POLICY_ISSUE: {
|
|
60
|
+
readonly ruleMissing: "policy-rule-missing";
|
|
61
|
+
readonly ruleUnknown: "policy-rule-unknown";
|
|
62
|
+
readonly conflictAction: "policy-conflict-action";
|
|
63
|
+
readonly horizon: "policy-horizon";
|
|
64
|
+
readonly soc: "policy-soc";
|
|
65
|
+
readonly alternateUnknown: "policy-alternate-unknown";
|
|
66
|
+
readonly alternateSelf: "policy-alternate-self";
|
|
67
|
+
readonly alternateDuplicate: "policy-alternate-duplicate";
|
|
68
|
+
};
|
|
69
|
+
export type TransportPolicyIssueCode = (typeof TRANSPORT_POLICY_ISSUE)[keyof typeof TRANSPORT_POLICY_ISSUE];
|
|
70
|
+
export interface TransportPolicyIssue {
|
|
71
|
+
code: TransportPolicyIssueCode;
|
|
72
|
+
params: RefusalParams;
|
|
73
|
+
}
|
|
74
|
+
/**
|
|
75
|
+
* Checks the shape of a policy set, rule names included (closed lists).
|
|
76
|
+
*
|
|
77
|
+
* `locationIds`, when given, are the places alternates may name; without it, alternates are not checked against places.
|
|
78
|
+
*/
|
|
79
|
+
export declare function validateTransportPolicy(policy: TransportPolicySet, locationIds?: ReadonlySet<string>): TransportPolicyIssue[];
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
/** Which machine takes which job. */
|
|
2
|
+
export const DISPATCH_RULE = {
|
|
3
|
+
/** The first available machine in the kernel's own order - what its assignment does today. */
|
|
4
|
+
firstIdle: 'firstIdle',
|
|
5
|
+
/** The machine that reaches the pick-up soonest; ties by id. */
|
|
6
|
+
minEta: 'minEta'
|
|
7
|
+
};
|
|
8
|
+
/** Which way it goes. */
|
|
9
|
+
export const ROUTING_RULE = {
|
|
10
|
+
/** Least travel time, reservations not considered. Connection time = length / effective speed. */
|
|
11
|
+
shortestTime: 'shortestTime',
|
|
12
|
+
/** Least arrival time over time windows: a connection held past its capacity is waited for or avoided. */
|
|
13
|
+
timeWindow: 'timeWindow'
|
|
14
|
+
};
|
|
15
|
+
export const TRAFFIC_CONFLICT_ACTION = ['wait', 'replan', 'yield'];
|
|
16
|
+
export const TRANSPORT_POLICY_ISSUE = {
|
|
17
|
+
ruleMissing: 'policy-rule-missing',
|
|
18
|
+
ruleUnknown: 'policy-rule-unknown',
|
|
19
|
+
conflictAction: 'policy-conflict-action',
|
|
20
|
+
horizon: 'policy-horizon',
|
|
21
|
+
soc: 'policy-soc',
|
|
22
|
+
alternateUnknown: 'policy-alternate-unknown',
|
|
23
|
+
alternateSelf: 'policy-alternate-self',
|
|
24
|
+
alternateDuplicate: 'policy-alternate-duplicate'
|
|
25
|
+
};
|
|
26
|
+
const isPercent = (v) => typeof v === 'number' && Number.isFinite(v) && v >= 0 && v <= 100;
|
|
27
|
+
/**
|
|
28
|
+
* Checks the shape of a policy set, rule names included (closed lists).
|
|
29
|
+
*
|
|
30
|
+
* `locationIds`, when given, are the places alternates may name; without it, alternates are not checked against places.
|
|
31
|
+
*/
|
|
32
|
+
export function validateTransportPolicy(policy, locationIds) {
|
|
33
|
+
const issues = [];
|
|
34
|
+
const known = { dispatch: Object.values(DISPATCH_RULE), routing: Object.values(ROUTING_RULE) };
|
|
35
|
+
for (const part of ['dispatch', 'routing']) {
|
|
36
|
+
const rule = policy[part]?.rule;
|
|
37
|
+
if (typeof rule !== 'string' || rule.trim() === '')
|
|
38
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleMissing, params: { part } });
|
|
39
|
+
else if (!known[part].includes(rule))
|
|
40
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.ruleUnknown, params: { part, rule } });
|
|
41
|
+
}
|
|
42
|
+
if (!TRAFFIC_CONFLICT_ACTION.includes(policy.traffic?.onConflict)) {
|
|
43
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.conflictAction, params: { onConflict: String(policy.traffic?.onConflict) } });
|
|
44
|
+
}
|
|
45
|
+
const horizon = policy.traffic?.horizonS;
|
|
46
|
+
if (horizon !== undefined && !(typeof horizon === 'number' && Number.isFinite(horizon) && horizon > 0)) {
|
|
47
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.horizon, params: { horizonS: String(horizon) } });
|
|
48
|
+
}
|
|
49
|
+
const { lowSoc, targetSoc } = policy.charging ?? {};
|
|
50
|
+
if (!isPercent(lowSoc) || !isPercent(targetSoc) || lowSoc >= targetSoc) {
|
|
51
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.soc, params: { lowSoc: String(lowSoc), targetSoc: String(targetSoc) } });
|
|
52
|
+
}
|
|
53
|
+
const seen = new Set();
|
|
54
|
+
for (const a of policy.alternates ?? []) {
|
|
55
|
+
if (seen.has(a.destination))
|
|
56
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateDuplicate, params: { destination: a.destination } });
|
|
57
|
+
seen.add(a.destination);
|
|
58
|
+
if (a.alternatives.includes(a.destination))
|
|
59
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateSelf, params: { destination: a.destination } });
|
|
60
|
+
if (locationIds) {
|
|
61
|
+
for (const id of [a.destination, ...a.alternatives]) {
|
|
62
|
+
if (!locationIds.has(id))
|
|
63
|
+
issues.push({ code: TRANSPORT_POLICY_ISSUE.alternateUnknown, params: { location: id } });
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
return issues;
|
|
68
|
+
}
|