@kosdev-code/kos-dispense-sdk 2.0.11 → 2.0.15
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/dispense-registration-manager-6NDXduUb.cjs +2 -0
- package/dispense-registration-manager-6NDXduUb.cjs.map +1 -0
- package/dispense-registration-manager-CSjwKonf.js +1904 -0
- package/dispense-registration-manager-CSjwKonf.js.map +1 -0
- package/{extension-utils-CMoNCoHG.js → extension-utils-BBJG9cnM.js} +53 -49
- package/{extension-utils-CMoNCoHG.js.map → extension-utils-BBJG9cnM.js.map} +1 -1
- package/extension-utils-DYqo5NBO.cjs +2 -0
- package/{extension-utils-BMU452cN.cjs.map → extension-utils-DYqo5NBO.cjs.map} +1 -1
- package/index.cjs +1 -1
- package/index.d.ts +1 -0
- package/index.d.ts.map +1 -1
- package/index.js +91 -86
- package/models/models/generic-pour/generic-pour-model.d.ts +51 -0
- package/models/models/generic-pour/generic-pour-model.d.ts.map +1 -0
- package/models/models/generic-pour/generic-pour-registration.d.ts +87 -0
- package/models/models/generic-pour/generic-pour-registration.d.ts.map +1 -0
- package/models/models/generic-pour/index.d.ts +5 -0
- package/models/models/generic-pour/index.d.ts.map +1 -0
- package/models/models/generic-pour/services/generic-pour-services.d.ts +16 -0
- package/models/models/generic-pour/services/generic-pour-services.d.ts.map +1 -0
- package/models/models/generic-pour/services/index.d.ts +2 -0
- package/models/models/generic-pour/services/index.d.ts.map +1 -0
- package/models/models/generic-pour/types/index.d.ts +4 -0
- package/models/models/index.d.ts +1 -0
- package/models/models/index.d.ts.map +1 -1
- package/models.cjs +1 -1
- package/models.js +18 -16
- package/package.json +3 -3
- package/pump-provider-B2FPLQDA.cjs +2 -0
- package/pump-provider-B2FPLQDA.cjs.map +1 -0
- package/pump-provider-BN6_xdlt.js +1073 -0
- package/pump-provider-BN6_xdlt.js.map +1 -0
- package/ui/hooks/generic-pour/index.d.ts +3 -0
- package/ui/hooks/generic-pour/index.d.ts.map +1 -0
- package/ui/hooks/generic-pour/use-generic-pour.d.ts +14 -0
- package/ui/hooks/generic-pour/use-generic-pour.d.ts.map +1 -0
- package/ui/hooks/generic-pour/with-generic-pour.d.ts +13 -0
- package/ui/hooks/generic-pour/with-generic-pour.d.ts.map +1 -0
- package/ui/hooks/index.d.ts +2 -0
- package/ui/hooks/index.d.ts.map +1 -1
- package/ui/hooks/pour/index.d.ts +2 -0
- package/ui/hooks/pour/index.d.ts.map +1 -0
- package/ui/hooks/pour/use-pour.d.ts +49 -0
- package/ui/hooks/pour/use-pour.d.ts.map +1 -0
- package/ui/hooks/utils/pour-strategy/hold-to-pour-strategy.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/pour-strategy.d.ts +10 -2
- package/ui/hooks/utils/pour-strategy/pour-strategy.d.ts.map +1 -1
- package/ui/hooks/utils/pour-strategy/tap-to-pour-strategy.d.ts.map +1 -1
- package/ui.cjs +1 -1
- package/ui.js +42 -39
- package/dispense-registration-manager-BtVe7yFS.js +0 -1770
- package/dispense-registration-manager-BtVe7yFS.js.map +0 -1
- package/dispense-registration-manager-CcV-anPv.cjs +0 -2
- package/dispense-registration-manager-CcV-anPv.cjs.map +0 -1
- package/extension-utils-BMU452cN.cjs +0 -2
- package/pump-provider-3XH9JScg.js +0 -1016
- package/pump-provider-3XH9JScg.js.map +0 -1
- package/pump-provider-CyLiBpMN.cjs +0 -2
- package/pump-provider-CyLiBpMN.cjs.map +0 -1
|
@@ -0,0 +1,1904 @@
|
|
|
1
|
+
var lt = Object.defineProperty;
|
|
2
|
+
var ct = (e, t, r) => t in e ? lt(e, t, { enumerable: !0, configurable: !0, writable: !0, value: r }) : e[t] = r;
|
|
3
|
+
var o = (e, t, r) => (ct(e, typeof t != "symbol" ? t + "" : t, r), r);
|
|
4
|
+
import { kosModel as I, isKosModel as v, Kos as b, resolveServiceUrl as C, ServiceFactory as S, KosLog as m, KosModelContainer as R, KosExtensionUtils as N, kosChild as _, FetchError as pt, ExtensionManager as g, EXTENSION_TROUBLE_MAPPER as _e, EXTENSION_TROUBLE_DATA_MAPPER as W, getKosModelSync as z, kosDependency as ce, TroubleContainer as ze, troubleByTypeReducer as Le, kosAction as y, kosTopicHandler as Q, DependencyLifecycle as xe, getKosModel as Ae, FutureManager as pe, kosFuture as ue, FutureHandler as Be, isKosDataModel as ut, ChildModels as gt, KosFeatureFlags as ht, kosParentAware as yt, createPropKey as It, MultipleFutureHandler as ft, arraysEqual as mt, getAllKosCompanionModels as O, EventBus as E, KosContextManager as Pt, destroyKosModel as vt, SingletonKosModelRegistrationFactory as bt, KosModelRegistrationFactory as _t, KosModelRegistry as Mt, RegistrationManager as M, registerCoreModels as Ot, registerLegacyModel as Et } from "@kosdev-code/kos-ui-sdk";
|
|
5
|
+
import "react";
|
|
6
|
+
var u = /* @__PURE__ */ ((e) => (e.IngredientLoader = "kos.ingredient.loader", e.IngredientMapper = "kos.ingredient.mapper", e.IngredientIndex = "kos.ingredient.index", e.IngredientTypeMapper = "kos.ingredient.type.mapper", e.HolderTypeMapper = "kos.holder.type.mapper", e.HolderMapper = "kos.holder.mapper", e.HolderIndex = "kos.holder.index", e.HolderIngredientMapper = "kos.holder.ingredient.mapper", e.AvailabilityMapper = "kos.availability.mapper", e.AvailabilityLoader = "kos.availability.loader", e.SelectedPourableMapper = "kos.selected.pourable.mapper", e.AssemblyMapper = "kos.assembly.mapper", e.BoardMapper = "kos.board.mapper", e.BoardIndex = "kos.board.index", e.PumpIndex = "kos.pump.index", e))(u || {}), T = /* @__PURE__ */ ((e) => (e.Nozzle = "nozzle-model", e.Availability = "availability-model", e.Holder = "holder-model", e.HolderContainer = "holder-container-model", e.IngredientContainer = "ingredient-container-model", e.Ingredient = "ingredient-model", e.Pump = "pump-model", e.PumpContainer = "pump-container-model", e))(T || {}), wt = Object.defineProperty, $t = Object.getOwnPropertyDescriptor, Ct = (e, t, r, n) => {
|
|
7
|
+
for (var i = n > 1 ? void 0 : n ? $t(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
8
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
9
|
+
return n && i && wt(t, r, i), i;
|
|
10
|
+
};
|
|
11
|
+
const j = "ingredient-model";
|
|
12
|
+
let me = class {
|
|
13
|
+
constructor(e, {
|
|
14
|
+
name: t,
|
|
15
|
+
type: r,
|
|
16
|
+
data: n,
|
|
17
|
+
ingredientId: i,
|
|
18
|
+
...s
|
|
19
|
+
}) {
|
|
20
|
+
o(this, "id");
|
|
21
|
+
o(this, "ingredientId");
|
|
22
|
+
o(this, "name");
|
|
23
|
+
o(this, "type");
|
|
24
|
+
o(this, "data");
|
|
25
|
+
this.id = e, this.ingredientId = i, this.name = t, this.type = r, this.data = n, Object.assign(this, s);
|
|
26
|
+
}
|
|
27
|
+
updateModel({
|
|
28
|
+
name: e,
|
|
29
|
+
type: t,
|
|
30
|
+
data: r,
|
|
31
|
+
ingredientId: n,
|
|
32
|
+
...i
|
|
33
|
+
}) {
|
|
34
|
+
this.name = e, this.type = t, this.ingredientId = n, this.data = r, Object.assign(this, i);
|
|
35
|
+
}
|
|
36
|
+
// -------------------LIFECYCLE----------------------------
|
|
37
|
+
// -------------------ENTITY----------------------------
|
|
38
|
+
};
|
|
39
|
+
me = Ct([
|
|
40
|
+
I(j)
|
|
41
|
+
], me);
|
|
42
|
+
const Ue = {
|
|
43
|
+
registration: {
|
|
44
|
+
[j]: {
|
|
45
|
+
class: me,
|
|
46
|
+
singleton: !1
|
|
47
|
+
}
|
|
48
|
+
},
|
|
49
|
+
type: j,
|
|
50
|
+
predicate: v(j),
|
|
51
|
+
factory: b.Factory.create(j)
|
|
52
|
+
}, { URL: je } = C("INGREDIENT_SERVICE"), { getOne: St } = S.build({
|
|
53
|
+
basePath: `${je}/api/ext/dispense/ingredients`
|
|
54
|
+
}), Rt = async () => await St({
|
|
55
|
+
urlOverride: `${je}/api/ext/dispense/ingredients`
|
|
56
|
+
});
|
|
57
|
+
var Tt = Object.defineProperty, Dt = Object.getOwnPropertyDescriptor, Ge = (e, t, r, n) => {
|
|
58
|
+
for (var i = n > 1 ? void 0 : n ? Dt(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
59
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
60
|
+
return n && i && Tt(t, r, i), i;
|
|
61
|
+
};
|
|
62
|
+
const G = "ingredient-container-model", Nt = m.createLogger({ name: "ingredient-container-model" });
|
|
63
|
+
let ne = class {
|
|
64
|
+
constructor(e, t) {
|
|
65
|
+
o(this, "id");
|
|
66
|
+
o(this, "ingredients");
|
|
67
|
+
this.id = e, this.ingredients = new R({
|
|
68
|
+
indexMap: {
|
|
69
|
+
ingredientType: "type"
|
|
70
|
+
},
|
|
71
|
+
extensionId: u.IngredientIndex,
|
|
72
|
+
parentId: e
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
updateModel() {
|
|
76
|
+
}
|
|
77
|
+
// -------------------LIFECYCLE----------------------------
|
|
78
|
+
getIngredientsByType(e) {
|
|
79
|
+
return this.ingredients.getIndexByKey("ingredientType", e);
|
|
80
|
+
}
|
|
81
|
+
async load(e) {
|
|
82
|
+
var i;
|
|
83
|
+
Nt.debug(`loading ingredient container ${this.id}`);
|
|
84
|
+
const t = await Rt();
|
|
85
|
+
if ((t == null ? void 0 : t.status) !== 200)
|
|
86
|
+
throw new Error("Failed to load ingredients");
|
|
87
|
+
const r = await N.executeLoaderExtension({
|
|
88
|
+
context: e,
|
|
89
|
+
extension: u.IngredientLoader
|
|
90
|
+
}), n = (t == null ? void 0 : t.data) ?? {};
|
|
91
|
+
for (const s of Object.keys(n))
|
|
92
|
+
for (const a of ((i = t == null ? void 0 : t.data) == null ? void 0 : i[s]) || []) {
|
|
93
|
+
const c = await N.executeDataMapperExtension({
|
|
94
|
+
extension: u.IngredientMapper,
|
|
95
|
+
data: a,
|
|
96
|
+
contextData: r
|
|
97
|
+
}), l = await N.executePropertyMapperExtension({
|
|
98
|
+
extension: u.IngredientTypeMapper,
|
|
99
|
+
data: a,
|
|
100
|
+
contextData: r
|
|
101
|
+
}), p = {
|
|
102
|
+
...a,
|
|
103
|
+
type: l || a.type,
|
|
104
|
+
...c,
|
|
105
|
+
data: c
|
|
106
|
+
}, h = Ue.factory(a.id)(
|
|
107
|
+
p
|
|
108
|
+
);
|
|
109
|
+
this.ingredients.addModel(h);
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
// -------------------ENTITY----------------------------
|
|
113
|
+
};
|
|
114
|
+
Ge([
|
|
115
|
+
_
|
|
116
|
+
], ne.prototype, "ingredients", 2);
|
|
117
|
+
ne = Ge([
|
|
118
|
+
I(G)
|
|
119
|
+
], ne);
|
|
120
|
+
const He = {
|
|
121
|
+
registration: {
|
|
122
|
+
[G]: {
|
|
123
|
+
class: ne,
|
|
124
|
+
singleton: !0
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
type: G,
|
|
128
|
+
predicate: v(G),
|
|
129
|
+
factory: b.Singleton.create(G)
|
|
130
|
+
}, { URL: ge } = C("HOLDER_SERVICE"), { getAll: zt, postModel: Fe, deleteModel: Lt } = S.build({
|
|
131
|
+
basePath: `${ge}/api/kos/holders`
|
|
132
|
+
}), xt = m.createLogger({
|
|
133
|
+
name: "holder-service",
|
|
134
|
+
group: "Services"
|
|
135
|
+
}), ii = async () => await zt({}), At = async (e, t) => {
|
|
136
|
+
if (!e || !t)
|
|
137
|
+
throw new Error("Missing holderPath or ingredientId");
|
|
138
|
+
return await Fe({
|
|
139
|
+
model: { holderPath: e, ingredientId: t },
|
|
140
|
+
urlOverride: `${ge}/api/ext/dispense/assignments`
|
|
141
|
+
});
|
|
142
|
+
}, Bt = async (e) => {
|
|
143
|
+
if (!e)
|
|
144
|
+
throw new Error("Missing holderPath");
|
|
145
|
+
return await Lt({
|
|
146
|
+
id: e,
|
|
147
|
+
urlOverride: `${ge}/api/ext/dispense/assignments/${e}`
|
|
148
|
+
});
|
|
149
|
+
}, Ut = async (e) => {
|
|
150
|
+
if (!e)
|
|
151
|
+
throw new Error("Missing holderPath");
|
|
152
|
+
return xt.debug(
|
|
153
|
+
`sending POST request to /api/ext/dispense/pumpEvents/replaceLine/${e}`
|
|
154
|
+
), await Fe({
|
|
155
|
+
model: {},
|
|
156
|
+
urlOverride: `${ge}/api/ext/dispense/pumpEvents/replaceLine/${e}`
|
|
157
|
+
});
|
|
158
|
+
}, { URL: se } = C("ASSIGNMENT_SERVICE"), { getAll: jt, postModel: Ke, deleteModel: Gt } = S.build({
|
|
159
|
+
destinationAddress: "",
|
|
160
|
+
basePath: `${se}/api/ext/dispense/assignments`
|
|
161
|
+
}), ae = window.kosUseFos, ni = async () => await jt({ fos: ae }), Ht = async (e, t) => {
|
|
162
|
+
var i, s, a, c;
|
|
163
|
+
const r = JSON.stringify(t), n = `${se}/api/ext/dispense/assignments`;
|
|
164
|
+
try {
|
|
165
|
+
const l = await Ke({
|
|
166
|
+
model: { holderPath: e, factoryJson: r },
|
|
167
|
+
urlOverride: n
|
|
168
|
+
});
|
|
169
|
+
return (l == null ? void 0 : l.status) === 200 && ((i = l == null ? void 0 : l.data) != null && i.error) ? [l.data.error || "unknownError", l.data] : [void 0, l == null ? void 0 : l.data];
|
|
170
|
+
} catch (l) {
|
|
171
|
+
if (l instanceof pt)
|
|
172
|
+
return [
|
|
173
|
+
((a = (s = l.payload) == null ? void 0 : s.data) == null ? void 0 : a.error) || "unknownError",
|
|
174
|
+
(c = l.payload) == null ? void 0 : c.data
|
|
175
|
+
];
|
|
176
|
+
}
|
|
177
|
+
return ["unknownError", void 0];
|
|
178
|
+
}, si = async (e) => {
|
|
179
|
+
const t = ae ? `${se}/api/ingredients/assignments/${e.holderPath}` : `${se}/api/ext/dispense/assignments`;
|
|
180
|
+
return await Ke({
|
|
181
|
+
model: { ...e, fuelGauge: 680 },
|
|
182
|
+
fos: ae,
|
|
183
|
+
urlOverride: t
|
|
184
|
+
});
|
|
185
|
+
}, ai = async (e) => await Gt({ id: e, fos: ae });
|
|
186
|
+
var Ft = Object.defineProperty, Kt = Object.getOwnPropertyDescriptor, he = (e, t, r, n) => {
|
|
187
|
+
for (var i = n > 1 ? void 0 : n ? Kt(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
188
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
189
|
+
return n && i && Ft(t, r, i), i;
|
|
190
|
+
};
|
|
191
|
+
const H = T.Holder, Re = m.createLogger({ name: "holder-model" });
|
|
192
|
+
g[_e].register(
|
|
193
|
+
"holder",
|
|
194
|
+
async (e) => {
|
|
195
|
+
const t = [];
|
|
196
|
+
return t.push(...e.data.holderPaths), t;
|
|
197
|
+
}
|
|
198
|
+
);
|
|
199
|
+
g[W].register(
|
|
200
|
+
"pump",
|
|
201
|
+
async (e) => {
|
|
202
|
+
if (e.data.pumpPath) {
|
|
203
|
+
const { model: t } = z(
|
|
204
|
+
e.data.pumpPath
|
|
205
|
+
);
|
|
206
|
+
if (t) {
|
|
207
|
+
const r = t.ingredientId ? z(t.ingredientId).model : void 0;
|
|
208
|
+
return {
|
|
209
|
+
ingredientId: t.ingredientId,
|
|
210
|
+
ingredientName: (r == null ? void 0 : r.displayName) ?? ((r == null ? void 0 : r.name) || ""),
|
|
211
|
+
childPumpName: t.name
|
|
212
|
+
};
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
return {};
|
|
216
|
+
}
|
|
217
|
+
);
|
|
218
|
+
g[W].register(
|
|
219
|
+
"holder",
|
|
220
|
+
async (e) => e.data.holderNames.length > 0 ? {
|
|
221
|
+
holderName: e.data.holderNames[0] || ""
|
|
222
|
+
} : {}
|
|
223
|
+
);
|
|
224
|
+
g[W].register(
|
|
225
|
+
"container",
|
|
226
|
+
async (e) => {
|
|
227
|
+
if (e.data.ingredients.length > 0) {
|
|
228
|
+
const t = e.data.ingredients[0], { model: r } = z(t);
|
|
229
|
+
return {
|
|
230
|
+
ingredientName: (r == null ? void 0 : r.displayName) ?? ((r == null ? void 0 : r.name) || ""),
|
|
231
|
+
ingredients: e.data.ingredients ? e.data.ingredients : [],
|
|
232
|
+
unknonwnIngredientId: e.data.unknonwnIngredientId ?? ""
|
|
233
|
+
};
|
|
234
|
+
}
|
|
235
|
+
return {};
|
|
236
|
+
}
|
|
237
|
+
);
|
|
238
|
+
class Vt extends Error {
|
|
239
|
+
constructor(r, n) {
|
|
240
|
+
super(n);
|
|
241
|
+
o(this, "type");
|
|
242
|
+
this.name = "AssignmentError", this.type = r;
|
|
243
|
+
}
|
|
244
|
+
}
|
|
245
|
+
let L = class {
|
|
246
|
+
constructor(e, {
|
|
247
|
+
path: t,
|
|
248
|
+
name: r,
|
|
249
|
+
ingredientSource: n,
|
|
250
|
+
ingredientId: i,
|
|
251
|
+
ingredientType: s,
|
|
252
|
+
slice: a,
|
|
253
|
+
group: c,
|
|
254
|
+
data: l,
|
|
255
|
+
enjoyByDate: p
|
|
256
|
+
}, h) {
|
|
257
|
+
o(this, "id");
|
|
258
|
+
o(this, "path");
|
|
259
|
+
o(this, "name");
|
|
260
|
+
o(this, "ingredientId");
|
|
261
|
+
o(this, "ingredientType");
|
|
262
|
+
o(this, "ingredientSource");
|
|
263
|
+
o(this, "group");
|
|
264
|
+
o(this, "slice");
|
|
265
|
+
o(this, "logger");
|
|
266
|
+
o(this, "data");
|
|
267
|
+
o(this, "enjoyByDate");
|
|
268
|
+
o(this, "pumps");
|
|
269
|
+
o(this, "ingredientContainer");
|
|
270
|
+
o(this, "troubleContainer");
|
|
271
|
+
this.id = e, this.path = t, this.name = r, this.ingredientType = s, this.ingredientSource = n, this.ingredientId = i, this.group = c, this.slice = a, this.enjoyByDate = p, this.data = l, this.pumps = new R({
|
|
272
|
+
parentId: e,
|
|
273
|
+
sortKey: "path"
|
|
274
|
+
}), this.logger = h.logger;
|
|
275
|
+
}
|
|
276
|
+
updateModel({
|
|
277
|
+
path: e,
|
|
278
|
+
name: t,
|
|
279
|
+
ingredientSource: r,
|
|
280
|
+
ingredientId: n,
|
|
281
|
+
ingredientType: i,
|
|
282
|
+
group: s,
|
|
283
|
+
slice: a,
|
|
284
|
+
enjoyByDate: c,
|
|
285
|
+
data: l
|
|
286
|
+
}) {
|
|
287
|
+
this.path = e, this.name = t, this.ingredientId = n, this.ingredientType = i, this.ingredientSource = r, this.enjoyByDate = c, this.slice = a, this.group = s, this.data = l;
|
|
288
|
+
}
|
|
289
|
+
get hasEnjoyByDate() {
|
|
290
|
+
return !!this.enjoyByDate && !this.unassigned;
|
|
291
|
+
}
|
|
292
|
+
get hasEnjoyByWarning() {
|
|
293
|
+
var e;
|
|
294
|
+
return ((e = this.troublesByType.EnjoyByTrouble) == null ? void 0 : e.length) > 0;
|
|
295
|
+
}
|
|
296
|
+
get nozzlePaths() {
|
|
297
|
+
return this.pumps.data.map((e) => e.nozzlePath);
|
|
298
|
+
}
|
|
299
|
+
async cancelPour() {
|
|
300
|
+
await Promise.all(
|
|
301
|
+
this.pumps.data.filter((e) => e.isPouring).map((e) => e.cancelPour())
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
get canPour() {
|
|
305
|
+
return !this.shouldDefer && this.pumps.data.every((e) => e.canPour);
|
|
306
|
+
}
|
|
307
|
+
get isPouring() {
|
|
308
|
+
const e = this.pumps.data.some((t) => t.isPouring);
|
|
309
|
+
return this.logger.debug(`isPouring: ${!!e}`), e;
|
|
310
|
+
}
|
|
311
|
+
async performIntent(e) {
|
|
312
|
+
const t = typeof e == "string" ? e : e.intent, r = typeof e == "string" ? void 0 : e.pumpPath, n = r ? this.pumps.getModel(r) : this.pumps.data[0];
|
|
313
|
+
return n == null ? void 0 : n.performIntent({ intent: t });
|
|
314
|
+
}
|
|
315
|
+
get pourState() {
|
|
316
|
+
return this.pumps.data.reduce((t, r) => r.pouringState ? r.pouringState : t, "");
|
|
317
|
+
}
|
|
318
|
+
get nozzlePath() {
|
|
319
|
+
var e;
|
|
320
|
+
return (e = this.pumps.data[0]) == null ? void 0 : e.nozzlePath;
|
|
321
|
+
}
|
|
322
|
+
get pumpPaths() {
|
|
323
|
+
return this.pumps.data.map((e) => e.id);
|
|
324
|
+
}
|
|
325
|
+
get sortedPumps() {
|
|
326
|
+
return this.pumps.data.sort((e, t) => e.virtual && !t.virtual ? -1 : !e.virtual && t.virtual ? 1 : e.name.localeCompare(t.name));
|
|
327
|
+
}
|
|
328
|
+
get ingredient() {
|
|
329
|
+
var t;
|
|
330
|
+
return this.ingredientId ? (t = this.ingredientContainer) == null ? void 0 : t.ingredients.getModel(
|
|
331
|
+
this.ingredientId
|
|
332
|
+
) : void 0;
|
|
333
|
+
}
|
|
334
|
+
get ingredientName() {
|
|
335
|
+
return this.ingredient ? this.ingredient.displayName ?? this.ingredient.name : this.ingredientId ? "unknown" : "";
|
|
336
|
+
}
|
|
337
|
+
get previousIngredient() {
|
|
338
|
+
var t;
|
|
339
|
+
return this.prevIngredientId ? (t = this.ingredientContainer) == null ? void 0 : t.ingredients.getModel(
|
|
340
|
+
this.prevIngredientId
|
|
341
|
+
) : void 0;
|
|
342
|
+
}
|
|
343
|
+
get previousIngredientName() {
|
|
344
|
+
return this.previousIngredient ? this.previousIngredient.displayName ?? this.previousIngredient.name : this.prevIngredientId ? "unknown" : "";
|
|
345
|
+
}
|
|
346
|
+
get troubles() {
|
|
347
|
+
return this.troubleContainer.troubles.getIndexByKey("byIface", this.path).sort((e, t) => t.rank - e.rank);
|
|
348
|
+
}
|
|
349
|
+
get troubleStatus() {
|
|
350
|
+
return "";
|
|
351
|
+
}
|
|
352
|
+
get troublesByType() {
|
|
353
|
+
return this.troubles.reduce(
|
|
354
|
+
Le,
|
|
355
|
+
{}
|
|
356
|
+
);
|
|
357
|
+
}
|
|
358
|
+
get prevIngredientId() {
|
|
359
|
+
var e, t;
|
|
360
|
+
return (t = (e = this.pumps.data) == null ? void 0 : e[0]) == null ? void 0 : t.prevIngredientId;
|
|
361
|
+
}
|
|
362
|
+
get unassigned() {
|
|
363
|
+
return (!this.ingredientId || this.ingredientId === "0") && (!this.prevIngredientId || this.prevIngredientId === "0");
|
|
364
|
+
}
|
|
365
|
+
get removed() {
|
|
366
|
+
return (!this.ingredientId || this.ingredientId === "0") && this.prevIngredientId !== void 0 && this.prevIngredientId !== "0";
|
|
367
|
+
}
|
|
368
|
+
get maxVolume() {
|
|
369
|
+
return this.slice.maxVolMl ?? 0;
|
|
370
|
+
}
|
|
371
|
+
get remainingVolume() {
|
|
372
|
+
return this.slice.currentVolMl ?? 0;
|
|
373
|
+
}
|
|
374
|
+
get hasMaxVolume() {
|
|
375
|
+
return this.slice.maxVolMl !== void 0;
|
|
376
|
+
}
|
|
377
|
+
get hasRemainingVolume() {
|
|
378
|
+
return this.slice.currentVolMl !== void 0;
|
|
379
|
+
}
|
|
380
|
+
get fillPercent() {
|
|
381
|
+
return this.remainingVolume <= 0 ? 0 : Math.floor((this.remainingVolume || 1) / (this.maxVolume || 1) * 100);
|
|
382
|
+
}
|
|
383
|
+
get hasFuelGuage() {
|
|
384
|
+
return this.hasMaxVolume && this.hasRemainingVolume;
|
|
385
|
+
}
|
|
386
|
+
updateIngredient(e) {
|
|
387
|
+
this.ingredientId !== e && y(() => {
|
|
388
|
+
this.ingredientId = e;
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
async resolveIntentVolume(e) {
|
|
392
|
+
const t = this.pumps.data[0];
|
|
393
|
+
return t ? t.resolveIntentVolume(e) : { volume: -1 };
|
|
394
|
+
}
|
|
395
|
+
async overrideRfidCode(e) {
|
|
396
|
+
if (!e)
|
|
397
|
+
throw new Error("Invalid override");
|
|
398
|
+
try {
|
|
399
|
+
const [t, r] = await Ht(this.path, e);
|
|
400
|
+
if (t)
|
|
401
|
+
throw new Vt(
|
|
402
|
+
t,
|
|
403
|
+
`Failed to perform rfid override on holder ${this.id}`
|
|
404
|
+
);
|
|
405
|
+
return y(() => {
|
|
406
|
+
this.ingredientId = r == null ? void 0 : r.ingredientId;
|
|
407
|
+
}), r;
|
|
408
|
+
} catch (t) {
|
|
409
|
+
throw Re.error(`Failed to perform rfid override on holder ${this.id}`, t), t;
|
|
410
|
+
}
|
|
411
|
+
}
|
|
412
|
+
async assignIngredient(e) {
|
|
413
|
+
try {
|
|
414
|
+
e ? await At(this.path, e) : await Bt(this.path), y(() => {
|
|
415
|
+
this.ingredientId = e;
|
|
416
|
+
});
|
|
417
|
+
} catch (t) {
|
|
418
|
+
throw Re.error(`Failed to perform assign ingredient to holder ${this.id}`, t), t;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
get shouldDefer() {
|
|
422
|
+
return this.troubles.some((e) => e.shouldDefer);
|
|
423
|
+
}
|
|
424
|
+
async replaceLine() {
|
|
425
|
+
await Ut(this.path);
|
|
426
|
+
}
|
|
427
|
+
// -------------------LIFECYCLE----------------------------
|
|
428
|
+
// ----------------------------------
|
|
429
|
+
// UNCOMMENT FOR TESTING FUEL GAUGE
|
|
430
|
+
// ----------------------------------
|
|
431
|
+
// async load() {
|
|
432
|
+
// const random = Math.max(1000, Math.floor(Math.random() * 5000));
|
|
433
|
+
// this.slice.maxVolMl = 1000;
|
|
434
|
+
// setInterval(() => {
|
|
435
|
+
// kosAction(() => {
|
|
436
|
+
// if (this.remainingVolume < -100) {
|
|
437
|
+
// this.slice.maxVolMl = 1000;
|
|
438
|
+
// this.slice.currentVolMl = this.maxVolume;
|
|
439
|
+
// } else {
|
|
440
|
+
// this.slice.currentVolMl = this.remainingVolume - 50;
|
|
441
|
+
// }
|
|
442
|
+
// });
|
|
443
|
+
// }, random);
|
|
444
|
+
// }
|
|
445
|
+
// -------------------ENTITY----------------------------
|
|
446
|
+
};
|
|
447
|
+
he([
|
|
448
|
+
_
|
|
449
|
+
], L.prototype, "pumps", 2);
|
|
450
|
+
he([
|
|
451
|
+
ce({ modelType: He.type })
|
|
452
|
+
], L.prototype, "ingredientContainer", 2);
|
|
453
|
+
he([
|
|
454
|
+
ce({ modelType: ze.type })
|
|
455
|
+
], L.prototype, "troubleContainer", 2);
|
|
456
|
+
L = he([
|
|
457
|
+
I(H)
|
|
458
|
+
], L);
|
|
459
|
+
const Ve = {
|
|
460
|
+
registration: {
|
|
461
|
+
[H]: {
|
|
462
|
+
class: L,
|
|
463
|
+
singleton: !1
|
|
464
|
+
}
|
|
465
|
+
},
|
|
466
|
+
type: H,
|
|
467
|
+
predicate: v(H),
|
|
468
|
+
factory: b.Factory.create(H)
|
|
469
|
+
}, Yt = async (e, t) => {
|
|
470
|
+
var Se;
|
|
471
|
+
const r = g.propertyMapper.executeMapper(
|
|
472
|
+
u.HolderIngredientMapper,
|
|
473
|
+
t
|
|
474
|
+
), n = g.propertyMapper.executeMapper(
|
|
475
|
+
u.HolderTypeMapper,
|
|
476
|
+
t
|
|
477
|
+
) || t.ingType, i = await N.executeDataMapperExtension({
|
|
478
|
+
extension: u.HolderMapper,
|
|
479
|
+
data: t,
|
|
480
|
+
contextData: {}
|
|
481
|
+
}), { name: s, path: a, ingredientId: c, ingType: l, ingSource: p, slice: h, ...U } = t, f = { ...U, ...i }, D = h || { pos: 0 }, re = {
|
|
482
|
+
name: s,
|
|
483
|
+
path: a,
|
|
484
|
+
ingredientId: r || c,
|
|
485
|
+
ingredientType: n || l,
|
|
486
|
+
ingredientSource: p,
|
|
487
|
+
enjoyByDate: (Se = t.container) != null && Se.enjoyByDate ? new Date(t.container.enjoyByDate) : void 0,
|
|
488
|
+
slice: D,
|
|
489
|
+
group: e,
|
|
490
|
+
data: f
|
|
491
|
+
};
|
|
492
|
+
return Ve.factory(t.path)(re);
|
|
493
|
+
}, { URL: kt } = C("ASSEMBLY_SERVICE"), { getOne: Zt } = S.build({
|
|
494
|
+
basePath: `${kt}/api/kos/device/assemblies`
|
|
495
|
+
}), Jt = m.createLogger({
|
|
496
|
+
name: "assembly-service",
|
|
497
|
+
group: "Services"
|
|
498
|
+
}), Ye = async () => (Jt.debug("sending GET for assembly"), await Zt({}));
|
|
499
|
+
var Xt = Object.defineProperty, qt = Object.getOwnPropertyDescriptor, ye = (e, t, r, n) => {
|
|
500
|
+
for (var i = n > 1 ? void 0 : n ? qt(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
501
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
502
|
+
return n && i && Xt(t, r, i), i;
|
|
503
|
+
};
|
|
504
|
+
const F = "board-container-model", ke = "/kos/hardware/board/linked", Ze = "/kos/hardware/board/unlinked";
|
|
505
|
+
let x = class {
|
|
506
|
+
constructor(e, t, r) {
|
|
507
|
+
o(this, "id");
|
|
508
|
+
o(this, "logger");
|
|
509
|
+
o(this, "models");
|
|
510
|
+
this.id = e, this.logger = r.logger, this.models = new R({
|
|
511
|
+
parentId: e,
|
|
512
|
+
extensionId: u.BoardIndex
|
|
513
|
+
});
|
|
514
|
+
}
|
|
515
|
+
get boardList() {
|
|
516
|
+
return this.models.data;
|
|
517
|
+
}
|
|
518
|
+
updateModel() {
|
|
519
|
+
}
|
|
520
|
+
addModel(e) {
|
|
521
|
+
this.models.addModel(e);
|
|
522
|
+
}
|
|
523
|
+
removeModel(e) {
|
|
524
|
+
this.models.removeModel(e);
|
|
525
|
+
}
|
|
526
|
+
updateBoard(e) {
|
|
527
|
+
const t = e.path, r = this.models.getModel(t);
|
|
528
|
+
if (!r) {
|
|
529
|
+
this.logger.warn(`board ${t} not found`);
|
|
530
|
+
return;
|
|
531
|
+
}
|
|
532
|
+
r.updateModel(e);
|
|
533
|
+
}
|
|
534
|
+
handleBoardLinkEvent(e) {
|
|
535
|
+
this.logger.debug(`handling ${ke} event ${e}`), e ? this.updateBoard(e) : this.logger.debug("- boardLinkEvent is undefined");
|
|
536
|
+
}
|
|
537
|
+
handleBoardUnlinkEvent(e) {
|
|
538
|
+
this.logger.debug(
|
|
539
|
+
`handling ${Ze} event ${e}`
|
|
540
|
+
), e ? this.updateBoard(e) : this.logger.debug("- boardLinkEvent is undefined");
|
|
541
|
+
}
|
|
542
|
+
};
|
|
543
|
+
ye([
|
|
544
|
+
_
|
|
545
|
+
], x.prototype, "models", 2);
|
|
546
|
+
ye([
|
|
547
|
+
Q({
|
|
548
|
+
lifecycle: xe.INIT,
|
|
549
|
+
topic: ke,
|
|
550
|
+
websocket: !0
|
|
551
|
+
})
|
|
552
|
+
], x.prototype, "handleBoardLinkEvent", 1);
|
|
553
|
+
ye([
|
|
554
|
+
Q({
|
|
555
|
+
lifecycle: xe.INIT,
|
|
556
|
+
topic: Ze,
|
|
557
|
+
websocket: !0
|
|
558
|
+
})
|
|
559
|
+
], x.prototype, "handleBoardUnlinkEvent", 1);
|
|
560
|
+
x = ye([
|
|
561
|
+
I(F)
|
|
562
|
+
], x);
|
|
563
|
+
const Wt = async (e) => {
|
|
564
|
+
const t = e.data.boardPath, { model: r } = z(t);
|
|
565
|
+
return {
|
|
566
|
+
boardName: (r == null ? void 0 : r.name) || ""
|
|
567
|
+
};
|
|
568
|
+
};
|
|
569
|
+
var Qt = Object.defineProperty, er = Object.getOwnPropertyDescriptor, Je = (e, t, r, n) => {
|
|
570
|
+
for (var i = n > 1 ? void 0 : n ? er(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
571
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
572
|
+
return n && i && Qt(t, r, i), i;
|
|
573
|
+
};
|
|
574
|
+
const K = T.PumpContainer;
|
|
575
|
+
var Xe = /* @__PURE__ */ ((e) => (e.byBoard = "byBoard", e.byType = "byType", e.byNozzle = "byNozzle", e))(Xe || {});
|
|
576
|
+
let oe = class {
|
|
577
|
+
constructor(e, t) {
|
|
578
|
+
o(this, "id");
|
|
579
|
+
o(this, "pumps");
|
|
580
|
+
this.id = e, this.pumps = new R({
|
|
581
|
+
indexMap: {
|
|
582
|
+
byNozzle: (r) => r.nozzlePaths,
|
|
583
|
+
byBoard: (r) => r.boardPath,
|
|
584
|
+
byType: "type"
|
|
585
|
+
},
|
|
586
|
+
parentId: e,
|
|
587
|
+
extensionId: u.PumpIndex
|
|
588
|
+
});
|
|
589
|
+
}
|
|
590
|
+
/**
|
|
591
|
+
* The collection of pump models.
|
|
592
|
+
*/
|
|
593
|
+
get pumpModels() {
|
|
594
|
+
return this.pumps.data;
|
|
595
|
+
}
|
|
596
|
+
/**
|
|
597
|
+
* The collection of pump paths.
|
|
598
|
+
*/
|
|
599
|
+
get pumpPaths() {
|
|
600
|
+
return this.pumpModels.map((e) => e.path);
|
|
601
|
+
}
|
|
602
|
+
addModel(e) {
|
|
603
|
+
this.pumps.addModel(e);
|
|
604
|
+
}
|
|
605
|
+
removeModel(e) {
|
|
606
|
+
this.pumps.removeModel(e);
|
|
607
|
+
}
|
|
608
|
+
getModel(e) {
|
|
609
|
+
return this.pumps.getModel(e);
|
|
610
|
+
}
|
|
611
|
+
get models() {
|
|
612
|
+
return this.pumps;
|
|
613
|
+
}
|
|
614
|
+
get data() {
|
|
615
|
+
return this.pumps.data;
|
|
616
|
+
}
|
|
617
|
+
updateModel() {
|
|
618
|
+
}
|
|
619
|
+
// -------------------LIFECYCLE----------------------------
|
|
620
|
+
async load() {
|
|
621
|
+
}
|
|
622
|
+
// -------------------ENTITY----------------------------
|
|
623
|
+
};
|
|
624
|
+
Je([
|
|
625
|
+
_
|
|
626
|
+
], oe.prototype, "pumps", 2);
|
|
627
|
+
oe = Je([
|
|
628
|
+
I(K)
|
|
629
|
+
], oe);
|
|
630
|
+
const Me = {
|
|
631
|
+
registration: {
|
|
632
|
+
[K]: {
|
|
633
|
+
class: oe,
|
|
634
|
+
singleton: !0
|
|
635
|
+
}
|
|
636
|
+
},
|
|
637
|
+
type: K,
|
|
638
|
+
predicate: v(K),
|
|
639
|
+
factory: b.Singleton.create(
|
|
640
|
+
K
|
|
641
|
+
)
|
|
642
|
+
}, qe = async (e) => {
|
|
643
|
+
const t = [], { model: r } = await Ae(e);
|
|
644
|
+
return r && (t.push(r.boardPath), t.push(r.nozzlePath), t.push(r.holderPath)), t;
|
|
645
|
+
}, tr = async (e) => {
|
|
646
|
+
const t = [], r = e.data.pumpPath;
|
|
647
|
+
t.push(r);
|
|
648
|
+
const n = await qe(r);
|
|
649
|
+
return [...t, ...n];
|
|
650
|
+
}, rr = async (e) => {
|
|
651
|
+
const t = [], r = e.data.boardPath;
|
|
652
|
+
t.push(e.data.boardPath);
|
|
653
|
+
const n = await Ae(
|
|
654
|
+
Me.type
|
|
655
|
+
);
|
|
656
|
+
if (n != null && n.model) {
|
|
657
|
+
const s = n.model.models.getIndexByKey(
|
|
658
|
+
Xe.byBoard,
|
|
659
|
+
r
|
|
660
|
+
).map(
|
|
661
|
+
(c) => qe(c.path)
|
|
662
|
+
);
|
|
663
|
+
(await Promise.allSettled(s)).forEach((c) => {
|
|
664
|
+
c.status === "fulfilled" && c.value.forEach((l) => t.push(l));
|
|
665
|
+
});
|
|
666
|
+
}
|
|
667
|
+
return Array.from(new Set(t));
|
|
668
|
+
};
|
|
669
|
+
var ir = Object.defineProperty, nr = Object.getOwnPropertyDescriptor, sr = (e, t, r, n) => {
|
|
670
|
+
for (var i = n > 1 ? void 0 : n ? nr(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
671
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
672
|
+
return n && i && ir(t, r, i), i;
|
|
673
|
+
};
|
|
674
|
+
const V = "board-model", Te = (e, t) => {
|
|
675
|
+
const { type: r, name: n, path: i, linked: s, instanceId: a, link: c, ...l } = e;
|
|
676
|
+
t.type = r, t.name = n, t.path = i, t.linked = s, t.link = Object.freeze(c), t.instanceId = a, Object.assign(t, l);
|
|
677
|
+
};
|
|
678
|
+
g[_e].register(
|
|
679
|
+
"board",
|
|
680
|
+
rr
|
|
681
|
+
);
|
|
682
|
+
g[W].register(
|
|
683
|
+
"board",
|
|
684
|
+
Wt
|
|
685
|
+
);
|
|
686
|
+
let Pe = class {
|
|
687
|
+
constructor(e, t, r) {
|
|
688
|
+
o(this, "id");
|
|
689
|
+
o(this, "type");
|
|
690
|
+
o(this, "name");
|
|
691
|
+
o(this, "path");
|
|
692
|
+
o(this, "linked");
|
|
693
|
+
o(this, "instanceId");
|
|
694
|
+
o(this, "logger");
|
|
695
|
+
this.id = e, this.logger = r.logger, Te(t, this);
|
|
696
|
+
}
|
|
697
|
+
updateModel(e) {
|
|
698
|
+
Te(e, this);
|
|
699
|
+
}
|
|
700
|
+
// -------------------LIFECYCLE----------------------------
|
|
701
|
+
async init() {
|
|
702
|
+
this.logger.debug(`initializing board ${this.id}`);
|
|
703
|
+
}
|
|
704
|
+
async load() {
|
|
705
|
+
this.logger.debug(`loading board ${this.id}`);
|
|
706
|
+
}
|
|
707
|
+
};
|
|
708
|
+
Pe = sr([
|
|
709
|
+
I(V)
|
|
710
|
+
], Pe);
|
|
711
|
+
const We = {
|
|
712
|
+
registration: {
|
|
713
|
+
[V]: {
|
|
714
|
+
class: Pe,
|
|
715
|
+
singleton: !1
|
|
716
|
+
}
|
|
717
|
+
},
|
|
718
|
+
type: V,
|
|
719
|
+
predicate: v(V),
|
|
720
|
+
factory: b.Factory.create(V)
|
|
721
|
+
}, Qe = {
|
|
722
|
+
registration: {
|
|
723
|
+
[F]: {
|
|
724
|
+
class: x,
|
|
725
|
+
singleton: !0
|
|
726
|
+
},
|
|
727
|
+
...We.registration
|
|
728
|
+
},
|
|
729
|
+
type: F,
|
|
730
|
+
predicate: v(F),
|
|
731
|
+
factory: b.Singleton.create(
|
|
732
|
+
F
|
|
733
|
+
)
|
|
734
|
+
};
|
|
735
|
+
var ar = Object.defineProperty, or = Object.getOwnPropertyDescriptor, Ie = (e, t, r, n) => {
|
|
736
|
+
for (var i = n > 1 ? void 0 : n ? or(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
737
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
738
|
+
return n && i && ar(t, r, i), i;
|
|
739
|
+
};
|
|
740
|
+
const Y = T.HolderContainer, dr = "/kos/insertion/insert/start", lr = "/kos/insertion/insert/complete", cr = "/kos/insertion/insert/update", pr = "/kos/insertion/remove", ur = "/kos/pumpEvent/replaceLine", gr = "/kos/handle/*";
|
|
741
|
+
let A = class {
|
|
742
|
+
constructor(e, t, r) {
|
|
743
|
+
o(this, "id");
|
|
744
|
+
o(this, "holders");
|
|
745
|
+
o(this, "logger");
|
|
746
|
+
this.id = e, this.holders = new R({
|
|
747
|
+
indexMap: {
|
|
748
|
+
nozzle: (n) => n.nozzlePaths,
|
|
749
|
+
group: "group"
|
|
750
|
+
},
|
|
751
|
+
parentId: e,
|
|
752
|
+
extensionId: u.HolderIndex
|
|
753
|
+
}), this.logger = r.logger;
|
|
754
|
+
}
|
|
755
|
+
updateModel() {
|
|
756
|
+
}
|
|
757
|
+
handleHolderEvents(e) {
|
|
758
|
+
var r, n, i;
|
|
759
|
+
m.ifDebug(
|
|
760
|
+
() => this.logger.debug("Received holder change event", JSON.stringify(e))
|
|
761
|
+
);
|
|
762
|
+
const t = this.holders.getModel(e.path);
|
|
763
|
+
t && (this.logger.info(
|
|
764
|
+
`Received change event for holder ${t.path}. Updating fuel gauge data.`
|
|
765
|
+
), t.slice.currentVolMl = (r = e.slice) == null ? void 0 : r.currentVolMl, t.slice.maxVolMl = (n = e.slice) == null ? void 0 : n.maxVolMl, (i = e == null ? void 0 : e.container) != null && i.enjoyByDate ? t.enjoyByDate = new Date(e.container.enjoyByDate) : t.enjoyByDate = void 0);
|
|
766
|
+
}
|
|
767
|
+
handleInsertion(e) {
|
|
768
|
+
m.ifDebug(
|
|
769
|
+
() => this.logger.debug("Received insertion event", JSON.stringify(e))
|
|
770
|
+
), (Array.isArray(e) ? e : [e]).forEach((r) => {
|
|
771
|
+
y(() => {
|
|
772
|
+
var s, a, c;
|
|
773
|
+
const n = r.ingredientId, i = this.holders.getModel(r.path);
|
|
774
|
+
i && (this.logger.info(
|
|
775
|
+
`Received insertion event for holder ${i.path}`
|
|
776
|
+
), i.updateIngredient(n), i.slice.currentVolMl = (s = r.slice) == null ? void 0 : s.currentVolMl, i.slice.maxVolMl = (a = r.slice) == null ? void 0 : a.maxVolMl, (c = r == null ? void 0 : r.container) != null && c.enjoyByDate ? i.enjoyByDate = new Date(r.container.enjoyByDate) : i.enjoyByDate = void 0, r.pumps.forEach((l) => {
|
|
777
|
+
y(() => {
|
|
778
|
+
const p = i.pumps.getModel(l.path);
|
|
779
|
+
p && (p.ingredientId = l.ingredientId, p.inserted = l.inserted, p.prevIngredientId = l.prevIngredientId);
|
|
780
|
+
});
|
|
781
|
+
}));
|
|
782
|
+
});
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
// -------------------ENTITY----------------------------
|
|
786
|
+
};
|
|
787
|
+
Ie([
|
|
788
|
+
_
|
|
789
|
+
], A.prototype, "holders", 2);
|
|
790
|
+
Ie([
|
|
791
|
+
Q({
|
|
792
|
+
topic: gr,
|
|
793
|
+
websocket: !0,
|
|
794
|
+
condition: (e, t) => t.holders.getModel(e.path) !== void 0
|
|
795
|
+
})
|
|
796
|
+
], A.prototype, "handleHolderEvents", 1);
|
|
797
|
+
Ie([
|
|
798
|
+
Q({
|
|
799
|
+
topic: [
|
|
800
|
+
dr,
|
|
801
|
+
lr,
|
|
802
|
+
cr,
|
|
803
|
+
pr,
|
|
804
|
+
ur
|
|
805
|
+
],
|
|
806
|
+
websocket: !0
|
|
807
|
+
})
|
|
808
|
+
], A.prototype, "handleInsertion", 1);
|
|
809
|
+
A = Ie([
|
|
810
|
+
I(Y)
|
|
811
|
+
], A);
|
|
812
|
+
const et = {
|
|
813
|
+
registration: {
|
|
814
|
+
[Y]: {
|
|
815
|
+
class: A,
|
|
816
|
+
singleton: !0
|
|
817
|
+
}
|
|
818
|
+
},
|
|
819
|
+
type: Y,
|
|
820
|
+
predicate: v(Y),
|
|
821
|
+
factory: b.Singleton.create(
|
|
822
|
+
Y
|
|
823
|
+
)
|
|
824
|
+
}, hr = m.createLogger({ name: "board-utils" }), yr = async (e) => {
|
|
825
|
+
const t = await N.executeDataMapperExtension({
|
|
826
|
+
extension: u.BoardMapper,
|
|
827
|
+
data: e,
|
|
828
|
+
contextData: {}
|
|
829
|
+
}), { type: r, name: n, path: i, linked: s, instanceId: a, ...c } = e, l = { ...c, ...t }, p = {
|
|
830
|
+
type: r,
|
|
831
|
+
name: n,
|
|
832
|
+
path: i,
|
|
833
|
+
linked: s,
|
|
834
|
+
instanceId: a,
|
|
835
|
+
...l
|
|
836
|
+
}, h = We.factory(e.path)(p);
|
|
837
|
+
return h.updateModel(p), h;
|
|
838
|
+
}, Ir = (e) => async (t) => {
|
|
839
|
+
hr.debug(`adding board ${t.name}`);
|
|
840
|
+
const r = await yr(t);
|
|
841
|
+
e.addModel(r);
|
|
842
|
+
};
|
|
843
|
+
var d = /* @__PURE__ */ ((e) => (e.IDLE = "IDLE", e.POURING = "POURING", e.POUR_STARTING = "POUR_STARTING", e.POUR_CANCELING = "POUR_CANCELING", e.POUR_CANCELED = "POUR_CANCELED", e.POUR_COMPLETE = "POUR_COMPLETE", e))(d || {});
|
|
844
|
+
const { URL: Oe } = C("PUMP_SERVICE"), { postModel: fr, getOne: mr } = S.build({
|
|
845
|
+
basePath: `${Oe}/api/kos/holders`
|
|
846
|
+
});
|
|
847
|
+
m.createLogger({
|
|
848
|
+
name: "pump-service",
|
|
849
|
+
group: "Services"
|
|
850
|
+
});
|
|
851
|
+
const Pr = async ({
|
|
852
|
+
intent: e,
|
|
853
|
+
pumpId: t,
|
|
854
|
+
tracker: r
|
|
855
|
+
}) => {
|
|
856
|
+
const n = `${Oe}/api/ext/dispense/nozzle/nozzle/pipeline/ingredient/pour/${t}/${e}`, i = await fr({ model: {}, urlOverride: n, tracker: r });
|
|
857
|
+
return i != null && i.data && pe.initiateFuture(i.data), i;
|
|
858
|
+
}, vr = async (e, t) => {
|
|
859
|
+
const r = `${Oe}/api/ext/dispense/nozzle/nozzle/pipeline/ingredient/intent/${e}/${t}/volume`, n = await mr({ urlOverride: r });
|
|
860
|
+
return n != null && n.data ? n.data : { volume: -1 };
|
|
861
|
+
};
|
|
862
|
+
var br = Object.defineProperty, _r = Object.getOwnPropertyDescriptor, Ee = (e, t, r, n) => {
|
|
863
|
+
for (var i = n > 1 ? void 0 : n ? _r(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
864
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
865
|
+
return n && i && br(t, r, i), i;
|
|
866
|
+
};
|
|
867
|
+
const k = T.Pump;
|
|
868
|
+
g[_e].register(
|
|
869
|
+
"pump",
|
|
870
|
+
tr
|
|
871
|
+
);
|
|
872
|
+
let q = class {
|
|
873
|
+
constructor(e, t) {
|
|
874
|
+
o(this, "id");
|
|
875
|
+
o(this, "inserted");
|
|
876
|
+
o(this, "type");
|
|
877
|
+
o(this, "virtual");
|
|
878
|
+
o(this, "ingredientId");
|
|
879
|
+
o(this, "holderPath");
|
|
880
|
+
o(this, "boardPath");
|
|
881
|
+
o(this, "nozzlePath");
|
|
882
|
+
o(this, "childPump");
|
|
883
|
+
o(this, "name");
|
|
884
|
+
o(this, "path");
|
|
885
|
+
o(this, "prevIngredientId");
|
|
886
|
+
o(this, "troubleContainer");
|
|
887
|
+
o(this, "futureHandler");
|
|
888
|
+
o(this, "currentState", d.IDLE);
|
|
889
|
+
this.id = e;
|
|
890
|
+
const {
|
|
891
|
+
inserted: r,
|
|
892
|
+
holderPath: n,
|
|
893
|
+
boardPath: i,
|
|
894
|
+
nozzlePath: s,
|
|
895
|
+
name: a,
|
|
896
|
+
path: c,
|
|
897
|
+
childPump: l,
|
|
898
|
+
virtual: p,
|
|
899
|
+
prevIngredientId: h,
|
|
900
|
+
...U
|
|
901
|
+
} = t;
|
|
902
|
+
this.inserted = r, this.type = t.type, this.ingredientId = t.ingredientId, this.holderPath = n, this.boardPath = i, this.nozzlePath = s, this.name = a, this.path = c, this.childPump = !!l, this.virtual = !!p, this.prevIngredientId = h, Object.assign(this, U), this.futureHandler = new Be(this);
|
|
903
|
+
}
|
|
904
|
+
updateModel(e) {
|
|
905
|
+
const {
|
|
906
|
+
inserted: t,
|
|
907
|
+
holderPath: r,
|
|
908
|
+
boardPath: n,
|
|
909
|
+
nozzlePath: i,
|
|
910
|
+
childPump: s,
|
|
911
|
+
name: a,
|
|
912
|
+
path: c,
|
|
913
|
+
...l
|
|
914
|
+
} = e;
|
|
915
|
+
this.inserted = t, this.type = e.type, this.ingredientId = e.ingredientId, this.holderPath = r, this.boardPath = n, this.nozzlePath = i, this.childPump = this.childPump ? this.childPump : !!s, this.name = a, this.path = c, this.prevIngredientId = e.prevIngredientId, Object.assign(this, l);
|
|
916
|
+
}
|
|
917
|
+
// -------------------LIFECYCLE----------------------------
|
|
918
|
+
get troubles() {
|
|
919
|
+
return this.troubleContainer.troubles.getIndexByKey("byIface", this.path).sort((e, t) => t.rank - e.rank);
|
|
920
|
+
}
|
|
921
|
+
get troubleStatus() {
|
|
922
|
+
return "";
|
|
923
|
+
}
|
|
924
|
+
get troublesByType() {
|
|
925
|
+
return this.troubles.reduce(
|
|
926
|
+
Le,
|
|
927
|
+
{}
|
|
928
|
+
);
|
|
929
|
+
}
|
|
930
|
+
get pouringState() {
|
|
931
|
+
var e;
|
|
932
|
+
return ((e = this.future) == null ? void 0 : e.endState) || "";
|
|
933
|
+
}
|
|
934
|
+
get isPouring() {
|
|
935
|
+
var e;
|
|
936
|
+
return !!(this.future && !((e = this.future) != null && e.endState)) || this.currentState === d.POUR_STARTING || this.currentState === d.POURING;
|
|
937
|
+
}
|
|
938
|
+
get canPour() {
|
|
939
|
+
return !!this.ingredientId && !this.isPouring;
|
|
940
|
+
}
|
|
941
|
+
onFutureUpdate(e) {
|
|
942
|
+
e.endState && y(() => {
|
|
943
|
+
this.currentState = d.IDLE;
|
|
944
|
+
});
|
|
945
|
+
}
|
|
946
|
+
async cancelPour() {
|
|
947
|
+
var e;
|
|
948
|
+
this.currentState === d.POURING || this.currentState === d.POUR_STARTING ? (this.currentState = d.POUR_CANCELING, await ((e = this.future) == null ? void 0 : e.cancelFuture()), y(() => {
|
|
949
|
+
this.currentState = d.IDLE;
|
|
950
|
+
})) : m.warn(`Cannot cancel pour in state ${this.currentState}`);
|
|
951
|
+
}
|
|
952
|
+
get future() {
|
|
953
|
+
return this.futureHandler.future;
|
|
954
|
+
}
|
|
955
|
+
async resolveIntentVolume(e) {
|
|
956
|
+
return await vr(this.path, e);
|
|
957
|
+
}
|
|
958
|
+
async performIntent(e, t) {
|
|
959
|
+
const r = typeof e == "string" ? e : e.intent;
|
|
960
|
+
if (!r)
|
|
961
|
+
throw new Error("No intent provided");
|
|
962
|
+
try {
|
|
963
|
+
if (this.currentState === d.IDLE) {
|
|
964
|
+
if (this.currentState = d.POUR_STARTING, !t)
|
|
965
|
+
throw new Error("No tracker provided");
|
|
966
|
+
const n = await Pr({
|
|
967
|
+
tracker: t,
|
|
968
|
+
intent: r,
|
|
969
|
+
pumpId: this.path
|
|
970
|
+
});
|
|
971
|
+
return this.currentState === d.POUR_STARTING && y(() => {
|
|
972
|
+
this.currentState = d.POURING;
|
|
973
|
+
}), n == null ? void 0 : n.data;
|
|
974
|
+
} else
|
|
975
|
+
throw new Error(`Cannot pour in state ${this.currentState}`);
|
|
976
|
+
} catch (n) {
|
|
977
|
+
throw m.error(n), this.currentState = d.IDLE, n;
|
|
978
|
+
}
|
|
979
|
+
}
|
|
980
|
+
// -------------------ENTITY----------------------------
|
|
981
|
+
};
|
|
982
|
+
Ee([
|
|
983
|
+
ce({ modelType: ze.type })
|
|
984
|
+
], q.prototype, "troubleContainer", 2);
|
|
985
|
+
Ee([
|
|
986
|
+
ue()
|
|
987
|
+
], q.prototype, "performIntent", 1);
|
|
988
|
+
q = Ee([
|
|
989
|
+
I(k)
|
|
990
|
+
], q);
|
|
991
|
+
const tt = {
|
|
992
|
+
registration: {
|
|
993
|
+
[k]: {
|
|
994
|
+
class: q,
|
|
995
|
+
singleton: !1
|
|
996
|
+
}
|
|
997
|
+
},
|
|
998
|
+
type: k,
|
|
999
|
+
predicate: v(k),
|
|
1000
|
+
factory: b.Factory.create(k)
|
|
1001
|
+
}, Mr = m.createLogger({ name: "pump-utils" }), Or = (e, t) => {
|
|
1002
|
+
const r = (t.pumps ?? []).length > 1, n = {
|
|
1003
|
+
boardPath: t.boardPath,
|
|
1004
|
+
holderPath: t.holderPath,
|
|
1005
|
+
ingredientId: t.ingredientId,
|
|
1006
|
+
childPump: !!t.childPump,
|
|
1007
|
+
virtual: r,
|
|
1008
|
+
inserted: t.inserted,
|
|
1009
|
+
name: t.name,
|
|
1010
|
+
path: t.path,
|
|
1011
|
+
type: t.type,
|
|
1012
|
+
nozzlePath: e,
|
|
1013
|
+
prevIngredientId: t.prevIngredientId
|
|
1014
|
+
}, i = tt.factory(t.path)(n);
|
|
1015
|
+
return i.updateModel(n), i;
|
|
1016
|
+
}, rt = (e) => (t) => (r) => (n) => {
|
|
1017
|
+
var c;
|
|
1018
|
+
Mr.debug(`adding pump ${n.name}`);
|
|
1019
|
+
const i = Or(r.path, n);
|
|
1020
|
+
e.addModel(i);
|
|
1021
|
+
const s = i.holderPath, a = t.holders.getModel(s);
|
|
1022
|
+
a == null || a.pumps.addModel(i), a != null && a.nozzlePaths.includes(r.path) || a == null || a.nozzlePaths.push(r.path), (c = n == null ? void 0 : n.pumps) == null || c.forEach((l) => {
|
|
1023
|
+
const p = i.holderPath, h = {
|
|
1024
|
+
...l,
|
|
1025
|
+
childPump: !0,
|
|
1026
|
+
holderPath: p,
|
|
1027
|
+
ingredientId: i.ingredientId
|
|
1028
|
+
};
|
|
1029
|
+
rt(e)(t)(r)(h);
|
|
1030
|
+
});
|
|
1031
|
+
};
|
|
1032
|
+
var Er = Object.defineProperty, wr = Object.getOwnPropertyDescriptor, ee = (e, t, r, n) => {
|
|
1033
|
+
for (var i = n > 1 ? void 0 : n ? wr(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
1034
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
1035
|
+
return n && i && Er(t, r, i), i;
|
|
1036
|
+
};
|
|
1037
|
+
const Z = "assembly-model", $r = "assembly-data";
|
|
1038
|
+
let w = class {
|
|
1039
|
+
constructor(e, t, r) {
|
|
1040
|
+
o(this, "id");
|
|
1041
|
+
o(this, "_nozzlePaths", /* @__PURE__ */ new Set());
|
|
1042
|
+
o(this, "troubleContainer");
|
|
1043
|
+
o(this, "holderContainer");
|
|
1044
|
+
o(this, "boardContainer");
|
|
1045
|
+
o(this, "pumpContainer");
|
|
1046
|
+
o(this, "logger");
|
|
1047
|
+
this.id = e, this.holderContainer = et.factory({}), this.boardContainer = Qe.factory({}), this.pumpContainer = Me.factory({}), this.logger = r.logger;
|
|
1048
|
+
}
|
|
1049
|
+
updateModel(e) {
|
|
1050
|
+
}
|
|
1051
|
+
get allHolders() {
|
|
1052
|
+
return this.holderContainer.holders.data;
|
|
1053
|
+
}
|
|
1054
|
+
get holderGroups() {
|
|
1055
|
+
return this.holderContainer.holders.getIndexKeys("group");
|
|
1056
|
+
}
|
|
1057
|
+
get nozzlePaths() {
|
|
1058
|
+
return Array.from(this._nozzlePaths);
|
|
1059
|
+
}
|
|
1060
|
+
getHoldersByGroup(e) {
|
|
1061
|
+
return this.holderContainer.holders.getIndexByKey("group", e);
|
|
1062
|
+
}
|
|
1063
|
+
getHoldersByNozzle(e) {
|
|
1064
|
+
return this.holderContainer.holders.getIndexByKey("nozzle", e);
|
|
1065
|
+
}
|
|
1066
|
+
/**
|
|
1067
|
+
* Returns a map of the pumps associated with each nozzle
|
|
1068
|
+
*
|
|
1069
|
+
* Can be used in conjunction with the nozzlePaths to get the pumps associated with each nozzle
|
|
1070
|
+
* @returns Record<string, PumpModel[]>
|
|
1071
|
+
*/
|
|
1072
|
+
get pumpsByNozzle() {
|
|
1073
|
+
return this.pumpContainer.models.idx.byNozzle;
|
|
1074
|
+
}
|
|
1075
|
+
/**
|
|
1076
|
+
* Returns a list of all fo the pumps paths across the entire assembly.
|
|
1077
|
+
*/
|
|
1078
|
+
get pumpPaths() {
|
|
1079
|
+
return this.pumpContainer.models.data.map((e) => e.path);
|
|
1080
|
+
}
|
|
1081
|
+
get boards() {
|
|
1082
|
+
return this.boardContainer.boardList;
|
|
1083
|
+
}
|
|
1084
|
+
// -------------------LIFECYCLE----------------------------
|
|
1085
|
+
async init() {
|
|
1086
|
+
this.logger.debug(`initializing assembly ${this.id}`);
|
|
1087
|
+
}
|
|
1088
|
+
async ready() {
|
|
1089
|
+
var e;
|
|
1090
|
+
(e = this.troubleContainer) == null || e.troubles.increment();
|
|
1091
|
+
}
|
|
1092
|
+
async load(e) {
|
|
1093
|
+
this.logger.debug(`loading assembly ${this.id}`);
|
|
1094
|
+
const t = await Ye();
|
|
1095
|
+
if ((t == null ? void 0 : t.status) === 200) {
|
|
1096
|
+
const r = await N.executeDataMapperExtension({
|
|
1097
|
+
extension: u.AssemblyMapper,
|
|
1098
|
+
data: t.data,
|
|
1099
|
+
contextData: {}
|
|
1100
|
+
});
|
|
1101
|
+
e.set($r, r), Object.assign(this, r), Object.entries(r).forEach(([n, i]) => {
|
|
1102
|
+
ut(i) && (this.logger.debug(`adding child model ${n} from extension data`), this[gt][n] = !0);
|
|
1103
|
+
});
|
|
1104
|
+
for await (const n of t.data.assemblies) {
|
|
1105
|
+
const {
|
|
1106
|
+
boards: i,
|
|
1107
|
+
holders: s,
|
|
1108
|
+
nozzles: a,
|
|
1109
|
+
core: c,
|
|
1110
|
+
name: l,
|
|
1111
|
+
path: p,
|
|
1112
|
+
...h
|
|
1113
|
+
} = n;
|
|
1114
|
+
this.logger.debug(`adding assembly ${l}`), Object.keys(h).forEach((f) => {
|
|
1115
|
+
ht.enableFeature(f);
|
|
1116
|
+
});
|
|
1117
|
+
for await (const f of i)
|
|
1118
|
+
this.logger.debug(`adding board ${f.name}`), await Ir(this.boardContainer)(f);
|
|
1119
|
+
for await (const [f, D] of Object.entries(s))
|
|
1120
|
+
for await (const re of D) {
|
|
1121
|
+
this.logger.debug(`adding holder ${re.name}`);
|
|
1122
|
+
const Ce = await Yt(f, re);
|
|
1123
|
+
this.holderContainer.holders.addModel(Ce);
|
|
1124
|
+
}
|
|
1125
|
+
const U = rt(this.pumpContainer)(
|
|
1126
|
+
this.holderContainer
|
|
1127
|
+
);
|
|
1128
|
+
a.forEach((f) => {
|
|
1129
|
+
this._nozzlePaths.add(f.path);
|
|
1130
|
+
const D = U(f);
|
|
1131
|
+
f.pumps.forEach(D);
|
|
1132
|
+
});
|
|
1133
|
+
}
|
|
1134
|
+
}
|
|
1135
|
+
}
|
|
1136
|
+
};
|
|
1137
|
+
ee([
|
|
1138
|
+
ce({
|
|
1139
|
+
modelType: "trouble-container-model"
|
|
1140
|
+
})
|
|
1141
|
+
], w.prototype, "troubleContainer", 2);
|
|
1142
|
+
ee([
|
|
1143
|
+
_
|
|
1144
|
+
], w.prototype, "holderContainer", 2);
|
|
1145
|
+
ee([
|
|
1146
|
+
_
|
|
1147
|
+
], w.prototype, "boardContainer", 2);
|
|
1148
|
+
ee([
|
|
1149
|
+
_
|
|
1150
|
+
], w.prototype, "pumpContainer", 2);
|
|
1151
|
+
w = ee([
|
|
1152
|
+
I(Z)
|
|
1153
|
+
], w);
|
|
1154
|
+
const it = {
|
|
1155
|
+
registration: {
|
|
1156
|
+
[Z]: {
|
|
1157
|
+
class: w,
|
|
1158
|
+
singleton: !0
|
|
1159
|
+
}
|
|
1160
|
+
},
|
|
1161
|
+
type: Z,
|
|
1162
|
+
predicate: v(Z),
|
|
1163
|
+
factory: b.Singleton.create(Z)
|
|
1164
|
+
};
|
|
1165
|
+
var Cr = Object.defineProperty, Sr = Object.getOwnPropertyDescriptor, Rr = (e, t, r, n) => {
|
|
1166
|
+
for (var i = n > 1 ? void 0 : n ? Sr(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
1167
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
1168
|
+
return n && i && Cr(t, r, i), i;
|
|
1169
|
+
};
|
|
1170
|
+
const J = T.Availability;
|
|
1171
|
+
let ve = class {
|
|
1172
|
+
constructor(e, t, r) {
|
|
1173
|
+
o(this, "id");
|
|
1174
|
+
o(this, "data");
|
|
1175
|
+
o(this, "available");
|
|
1176
|
+
o(this, "visible");
|
|
1177
|
+
o(this, "groupId");
|
|
1178
|
+
o(this, "rawId");
|
|
1179
|
+
o(this, "altId");
|
|
1180
|
+
o(this, "type");
|
|
1181
|
+
o(this, "note");
|
|
1182
|
+
o(this, "taggedIds");
|
|
1183
|
+
o(this, "parentId");
|
|
1184
|
+
o(this, "logger");
|
|
1185
|
+
this.id = e, this.taggedIds = t.taggedIds || [], this.logger = r.logger, this.available = t.available, this.visible = t.visible, this.groupId = t.groupId, this.rawId = t.rawId, this.altId = t.altId, this.type = t.type, this.parentId = t.kosParentId, this.data = t.data, this.note = t.note;
|
|
1186
|
+
}
|
|
1187
|
+
updateModel(e) {
|
|
1188
|
+
this.taggedIds = e.taggedIds || [], this.available = e.available, this.visible = e.visible, this.groupId = e.groupId, this.rawId = e.rawId, this.altId = e.altId, this.type = e.type, this.data = e.data;
|
|
1189
|
+
}
|
|
1190
|
+
updateAvailability(e) {
|
|
1191
|
+
this.available = e;
|
|
1192
|
+
}
|
|
1193
|
+
// -------------------LIFECYCLE----------------------------
|
|
1194
|
+
// -------------------ENTITY----------------------------
|
|
1195
|
+
};
|
|
1196
|
+
ve = Rr([
|
|
1197
|
+
yt(),
|
|
1198
|
+
I(J)
|
|
1199
|
+
], ve);
|
|
1200
|
+
const be = {
|
|
1201
|
+
registration: {
|
|
1202
|
+
[J]: {
|
|
1203
|
+
class: ve,
|
|
1204
|
+
singleton: !1
|
|
1205
|
+
}
|
|
1206
|
+
},
|
|
1207
|
+
type: J,
|
|
1208
|
+
predicate: v(J),
|
|
1209
|
+
factory: b.Factory.create(
|
|
1210
|
+
J
|
|
1211
|
+
)
|
|
1212
|
+
}, { URL: B } = C("NOZZLE_SERVICE"), { postModel: we, deleteModel: Tr, getOne: Dr } = S.build({
|
|
1213
|
+
basePath: `${B}/api/nozzle`
|
|
1214
|
+
}), Nr = async (e, t) => {
|
|
1215
|
+
const r = await we({
|
|
1216
|
+
model: {},
|
|
1217
|
+
urlOverride: `${B}/api/ext/dispense/nozzle/${e}/pipeline/beverage/pour`,
|
|
1218
|
+
ordered: !0,
|
|
1219
|
+
tracker: t
|
|
1220
|
+
});
|
|
1221
|
+
return r != null && r.data && pe.initiateFuture(r.data), r;
|
|
1222
|
+
}, zr = async (e, t, r) => {
|
|
1223
|
+
const n = await we({
|
|
1224
|
+
model: {},
|
|
1225
|
+
urlOverride: `${B}/api/ext/dispense/nozzle/${t}/pipeline/beverage/fixed/${e}`,
|
|
1226
|
+
ordered: !0,
|
|
1227
|
+
tracker: r
|
|
1228
|
+
});
|
|
1229
|
+
return n != null && n.data && pe.initiateFuture(n.data), n;
|
|
1230
|
+
}, Lr = async (e) => await Dr({
|
|
1231
|
+
urlOverride: `${B}${e}/pipeline/beverage/availability`
|
|
1232
|
+
}), xr = async (e, t) => await we({
|
|
1233
|
+
model: t,
|
|
1234
|
+
urlOverride: `${B}/api/ext/dispense/nozzle/${e}/pipeline/beverage/select`
|
|
1235
|
+
}), Ar = async (e) => await Tr({
|
|
1236
|
+
id: e,
|
|
1237
|
+
urlOverride: `${B}/api/ext/dispense/nozzle/${e}/pipeline/beverage/select`
|
|
1238
|
+
});
|
|
1239
|
+
var Br = Object.defineProperty, Ur = Object.getOwnPropertyDescriptor, te = (e, t, r, n) => {
|
|
1240
|
+
for (var i = n > 1 ? void 0 : n ? Ur(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
1241
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
1242
|
+
return n && i && Br(t, r, i), i;
|
|
1243
|
+
};
|
|
1244
|
+
const X = T.Nozzle, jr = It(
|
|
1245
|
+
"beverageTopicPrefix"
|
|
1246
|
+
), ie = (e) => e.onPourStart !== void 0 && e.onPourCancel !== void 0 && e.onPourProgress !== void 0, De = "/kos/nozzle/pour/started", Gr = "/kos/nozzle/pour/progress", Hr = "/kos/nozzle/pour/cancel";
|
|
1247
|
+
let $ = class {
|
|
1248
|
+
constructor(e, t, r) {
|
|
1249
|
+
/** the unique identifier for this nozzle.*/
|
|
1250
|
+
o(this, "id");
|
|
1251
|
+
o(this, "path");
|
|
1252
|
+
o(this, "logger");
|
|
1253
|
+
o(this, "name");
|
|
1254
|
+
o(this, "_selectedBeverage");
|
|
1255
|
+
o(this, "_selectedBrand");
|
|
1256
|
+
o(this, "_additionalItems");
|
|
1257
|
+
o(this, "_availabilityItems");
|
|
1258
|
+
o(this, "futureHandler");
|
|
1259
|
+
o(this, "currentState", d.IDLE);
|
|
1260
|
+
o(this, "beverageTopicPrefix");
|
|
1261
|
+
o(this, "topicPrefix");
|
|
1262
|
+
o(this, "urlPrefix");
|
|
1263
|
+
this.id = e, this.path = t.path, this.name = t.name, this.beverageTopicPrefix = t.beverageTopicPrefix, this.topicPrefix = t.topicPrefix, this.urlPrefix = t.urlPrefix, this._selectedBeverage = void 0, this._selectedBrand = void 0, this._additionalItems = [], this.futureHandler = new ft(this), this._availabilityItems = new R({
|
|
1264
|
+
indexMap: {
|
|
1265
|
+
byGroup: "groupId",
|
|
1266
|
+
byParent: "parentId"
|
|
1267
|
+
},
|
|
1268
|
+
parentId: e
|
|
1269
|
+
}), this.logger = r.logger;
|
|
1270
|
+
}
|
|
1271
|
+
/**
|
|
1272
|
+
* The availability nodes that can be dispensed from this nozzle.
|
|
1273
|
+
* This is a subset of the availability for the entire dispenser
|
|
1274
|
+
* and is determined by the nodes associated with a nozzle.
|
|
1275
|
+
*/
|
|
1276
|
+
get beverages() {
|
|
1277
|
+
return this._availabilityItems.getIndexByKey("byGroup", "beverages");
|
|
1278
|
+
}
|
|
1279
|
+
/**
|
|
1280
|
+
* The availability nodes that have been grouped into the "brands" group.
|
|
1281
|
+
*
|
|
1282
|
+
*/
|
|
1283
|
+
get brands() {
|
|
1284
|
+
return this._availabilityItems.getIndexByKey("byGroup", "brands");
|
|
1285
|
+
}
|
|
1286
|
+
get visibleBrands() {
|
|
1287
|
+
return this.brands.filter((e) => e.visible);
|
|
1288
|
+
}
|
|
1289
|
+
get visibleBeverages() {
|
|
1290
|
+
return this.beverages.filter((e) => e.visible);
|
|
1291
|
+
}
|
|
1292
|
+
/**
|
|
1293
|
+
* A derived value that indicates if the nozzle is currently pouring a beverage.
|
|
1294
|
+
* @readonly
|
|
1295
|
+
*/
|
|
1296
|
+
get isPouring() {
|
|
1297
|
+
var e;
|
|
1298
|
+
return !!(this.futureHandler.getFuture() && !((e = this.futureHandler.getFuture()) != null && e.endState)) || this.currentState === d.POUR_STARTING || this.currentState === d.POURING || this.currentState === d.POUR_CANCELING;
|
|
1299
|
+
}
|
|
1300
|
+
/**
|
|
1301
|
+
* A derived value that indicates if the nozzle is currently available to pour a beverage.
|
|
1302
|
+
*
|
|
1303
|
+
* This will generally be determined by whether there is a currently selected pourable AND
|
|
1304
|
+
* the nozzle is not currently pouring.
|
|
1305
|
+
*
|
|
1306
|
+
* The value is observable and will change when the selected pourable changes or the nozzle
|
|
1307
|
+
* starts or stops pouring.
|
|
1308
|
+
* @readonly
|
|
1309
|
+
* */
|
|
1310
|
+
get canPour() {
|
|
1311
|
+
return !!this._selectedBeverage && this._selectedBeverage.available && this.currentState === d.IDLE;
|
|
1312
|
+
}
|
|
1313
|
+
/**
|
|
1314
|
+
* The selected pourable for this nozzle. Its shape is determined by the results of the
|
|
1315
|
+
* {@link ExtensionType.SelectedPourableMapper} extension.
|
|
1316
|
+
* @readonly
|
|
1317
|
+
*
|
|
1318
|
+
* */
|
|
1319
|
+
get selectedPourable() {
|
|
1320
|
+
return {
|
|
1321
|
+
beverage: this._selectedBeverage,
|
|
1322
|
+
additional: this._additionalItems
|
|
1323
|
+
};
|
|
1324
|
+
}
|
|
1325
|
+
get future() {
|
|
1326
|
+
return this.futureHandler.getFuture();
|
|
1327
|
+
}
|
|
1328
|
+
get pourProgress() {
|
|
1329
|
+
var e;
|
|
1330
|
+
return ((e = this.future) == null ? void 0 : e.progress) ?? 0;
|
|
1331
|
+
}
|
|
1332
|
+
updateModel() {
|
|
1333
|
+
}
|
|
1334
|
+
// -------------------LIFECYCLE----------------------------
|
|
1335
|
+
setSelectedBrand(e) {
|
|
1336
|
+
this._selectedBrand = e, this._selectedBeverage = void 0;
|
|
1337
|
+
}
|
|
1338
|
+
get selectedBrand() {
|
|
1339
|
+
return this._selectedBrand;
|
|
1340
|
+
}
|
|
1341
|
+
/**
|
|
1342
|
+
* Set the values used to determine the selected pourable for this nozzle.
|
|
1343
|
+
*
|
|
1344
|
+
* @param pourable The pourable to set.
|
|
1345
|
+
* @param pourable.beverage The beverage selected.
|
|
1346
|
+
* @param pourable.additional The additional items such as flavors or other items that could be incorporated
|
|
1347
|
+
* into the pourable.
|
|
1348
|
+
* */
|
|
1349
|
+
async setSelectedPourable({
|
|
1350
|
+
beverage: e,
|
|
1351
|
+
additional: t,
|
|
1352
|
+
context: r
|
|
1353
|
+
}) {
|
|
1354
|
+
if (!e) {
|
|
1355
|
+
const c = await Ar(this.name);
|
|
1356
|
+
if ((c == null ? void 0 : c.status) !== 200)
|
|
1357
|
+
throw new Error("Failed to clear pourable");
|
|
1358
|
+
this._selectedBeverage = void 0;
|
|
1359
|
+
return;
|
|
1360
|
+
}
|
|
1361
|
+
if (e === this._selectedBeverage && mt(this._additionalItems, t)) {
|
|
1362
|
+
this.logger.info("No change in selected pourable");
|
|
1363
|
+
return;
|
|
1364
|
+
}
|
|
1365
|
+
this._selectedBeverage = e, this._additionalItems = t;
|
|
1366
|
+
let n = await g.dataMapper.executeMapper(
|
|
1367
|
+
u.SelectedPourableMapper,
|
|
1368
|
+
{
|
|
1369
|
+
beverage: e,
|
|
1370
|
+
additional: t,
|
|
1371
|
+
context: r
|
|
1372
|
+
}
|
|
1373
|
+
);
|
|
1374
|
+
const i = {
|
|
1375
|
+
bevId: e.rawId
|
|
1376
|
+
};
|
|
1377
|
+
(!n || Object.keys(n).length === 0) && (this.logger.info(
|
|
1378
|
+
`No selected pourable mapper defined, using the default payload ${i}`
|
|
1379
|
+
), n = i);
|
|
1380
|
+
const s = n ?? i, a = await xr(this.name, s);
|
|
1381
|
+
if ((a == null ? void 0 : a.status) !== 200)
|
|
1382
|
+
throw new Error("Failed to select pourable");
|
|
1383
|
+
}
|
|
1384
|
+
/**
|
|
1385
|
+
* Utility method that will return the availability nodes that belong to the specified
|
|
1386
|
+
* group as defined in the dispenser beverage graph. For example, a dispenser
|
|
1387
|
+
* implementation may group availability nodes by Brand, Beverage, or Flavors
|
|
1388
|
+
*
|
|
1389
|
+
* @param groupId The group to filter by.
|
|
1390
|
+
* @returns The availability nodes that are available to be dispensed from this nozzle
|
|
1391
|
+
* and are in the specified group.
|
|
1392
|
+
* */
|
|
1393
|
+
getGroupAvailabilityItems(e) {
|
|
1394
|
+
return this._availabilityItems.getIndexByKey(
|
|
1395
|
+
"byGroup",
|
|
1396
|
+
e
|
|
1397
|
+
);
|
|
1398
|
+
}
|
|
1399
|
+
/**
|
|
1400
|
+
* Utility method that will return the availability nodes that are tagged with the specified parent id.
|
|
1401
|
+
*
|
|
1402
|
+
* This is useful when brandsets use the taggedIds property to associate nodes with a parent node. For example,
|
|
1403
|
+
* when organizing a brandset into brands and beverages, the brand nodes will be tagged with the beverage nodes.
|
|
1404
|
+
*
|
|
1405
|
+
* @param parentId - The parent id to filter by.
|
|
1406
|
+
* @returns the availability nodes that are tagged with the specified parent id.
|
|
1407
|
+
*/
|
|
1408
|
+
getAvailabilityByParent(e) {
|
|
1409
|
+
return this._availabilityItems.getIndexByKey(
|
|
1410
|
+
"byParent",
|
|
1411
|
+
e
|
|
1412
|
+
);
|
|
1413
|
+
}
|
|
1414
|
+
updateIfCurrent(e, t) {
|
|
1415
|
+
this.currentState === e && y(() => {
|
|
1416
|
+
this.currentState = t;
|
|
1417
|
+
});
|
|
1418
|
+
}
|
|
1419
|
+
onFutureUpdate(e) {
|
|
1420
|
+
O(this).forEach((r) => {
|
|
1421
|
+
ie(r) && r.onPourProgress(e);
|
|
1422
|
+
});
|
|
1423
|
+
const t = {
|
|
1424
|
+
nozzleId: this.id,
|
|
1425
|
+
progress: e.progress,
|
|
1426
|
+
status: e.status,
|
|
1427
|
+
clientData: e.clientData,
|
|
1428
|
+
futureId: e.futureId,
|
|
1429
|
+
remainingTimeMs: e.remainingTimeMs,
|
|
1430
|
+
endState: e.endState,
|
|
1431
|
+
reason: e.reason,
|
|
1432
|
+
timeRemaining: e.timeRemaining
|
|
1433
|
+
};
|
|
1434
|
+
E.publish(Gr, t);
|
|
1435
|
+
}
|
|
1436
|
+
async pour(e) {
|
|
1437
|
+
try {
|
|
1438
|
+
if (this.currentState === d.IDLE) {
|
|
1439
|
+
if (this.updateIfCurrent(d.IDLE, d.POUR_STARTING), !e)
|
|
1440
|
+
throw new Error("No tracker provided");
|
|
1441
|
+
const t = await Nr(this.name, e);
|
|
1442
|
+
this.updateIfCurrent(d.POUR_STARTING, d.POURING), O(this).forEach((n) => {
|
|
1443
|
+
var i;
|
|
1444
|
+
ie(n) && ((i = n.onPourStart) == null || i.call(n));
|
|
1445
|
+
});
|
|
1446
|
+
const r = {
|
|
1447
|
+
nozzleId: this.id,
|
|
1448
|
+
type: "free"
|
|
1449
|
+
};
|
|
1450
|
+
return E.publish(De, r), t;
|
|
1451
|
+
} else
|
|
1452
|
+
throw new Error(`Cannot pour in state ${this.currentState}`);
|
|
1453
|
+
} catch (t) {
|
|
1454
|
+
throw this.logger.error(t), this.currentState = d.IDLE, t;
|
|
1455
|
+
}
|
|
1456
|
+
}
|
|
1457
|
+
async fixedPour(e, t) {
|
|
1458
|
+
try {
|
|
1459
|
+
if (this.currentState === d.IDLE) {
|
|
1460
|
+
if (this.currentState = d.POUR_STARTING, !t)
|
|
1461
|
+
throw new Error("No tracker provided");
|
|
1462
|
+
const r = await zr(e, this.name, t);
|
|
1463
|
+
this.currentState === d.POUR_STARTING && y(() => {
|
|
1464
|
+
this.currentState = d.POURING;
|
|
1465
|
+
}), O(this).forEach((i) => {
|
|
1466
|
+
var s;
|
|
1467
|
+
ie(i) && ((s = i.onPourStart) == null || s.call(i));
|
|
1468
|
+
});
|
|
1469
|
+
const n = {
|
|
1470
|
+
nozzleId: this.id,
|
|
1471
|
+
type: "fixed"
|
|
1472
|
+
};
|
|
1473
|
+
return E.publish(De, n), r;
|
|
1474
|
+
} else
|
|
1475
|
+
throw new Error(`Cannot pour in state ${this.currentState}`);
|
|
1476
|
+
} catch (r) {
|
|
1477
|
+
throw this.logger.error(r), this.currentState = d.IDLE, r;
|
|
1478
|
+
}
|
|
1479
|
+
}
|
|
1480
|
+
/**
|
|
1481
|
+
* An action that will cancel a pour for this nozzle.
|
|
1482
|
+
* */
|
|
1483
|
+
async cancelPour() {
|
|
1484
|
+
var e;
|
|
1485
|
+
if (this.currentState === d.POURING || this.currentState === d.POUR_STARTING) {
|
|
1486
|
+
this.currentState = d.POUR_CANCELING, await ((e = this.futureHandler.getFuture()) == null ? void 0 : e.cancelFuture()), y(() => {
|
|
1487
|
+
this.currentState = d.IDLE;
|
|
1488
|
+
}), O(this).forEach((r) => {
|
|
1489
|
+
var n;
|
|
1490
|
+
ie(r) && ((n = r.onPourCancel) == null || n.call(r));
|
|
1491
|
+
});
|
|
1492
|
+
const t = {
|
|
1493
|
+
nozzleId: this.id
|
|
1494
|
+
};
|
|
1495
|
+
E.publish(Hr, t);
|
|
1496
|
+
} else
|
|
1497
|
+
this.logger.warn(`Cannot cancel pour in state ${this.currentState}`);
|
|
1498
|
+
}
|
|
1499
|
+
updateGroupMembers() {
|
|
1500
|
+
this._availabilityItems.data.forEach((e) => {
|
|
1501
|
+
(e.taggedIds || []).forEach((r) => {
|
|
1502
|
+
const n = this._availabilityItems.data.find(
|
|
1503
|
+
(i) => i.rawId === r
|
|
1504
|
+
);
|
|
1505
|
+
n && n.parentId !== e.id && (n.parentId = e.id, this._availabilityItems.updateModel(n));
|
|
1506
|
+
});
|
|
1507
|
+
});
|
|
1508
|
+
}
|
|
1509
|
+
/** @internal */
|
|
1510
|
+
async load(e) {
|
|
1511
|
+
var n, i;
|
|
1512
|
+
this.logger.debug(`loading nozzle ${this.id}`);
|
|
1513
|
+
const t = await Lr(this.urlPrefix);
|
|
1514
|
+
if ((t == null ? void 0 : t.status) !== 200)
|
|
1515
|
+
throw new Error("Failed to load nozzle availability");
|
|
1516
|
+
const r = await g.loader.executeLoader(
|
|
1517
|
+
u.AvailabilityLoader,
|
|
1518
|
+
{}
|
|
1519
|
+
);
|
|
1520
|
+
e == null || e.set(u.AvailabilityLoader, r), e == null || e.set($e.type, this);
|
|
1521
|
+
for (const s of Object.keys((n = t.data) == null ? void 0 : n.groups) || [])
|
|
1522
|
+
for (const a of ((i = t.data) == null ? void 0 : i.groups[s]) || []) {
|
|
1523
|
+
const c = await g.dataMapper.executeMapper(
|
|
1524
|
+
u.AvailabilityMapper,
|
|
1525
|
+
{ ...a, groupId: s },
|
|
1526
|
+
r
|
|
1527
|
+
), l = {
|
|
1528
|
+
...a,
|
|
1529
|
+
note: a.note ?? void 0,
|
|
1530
|
+
kosParentId: this.id,
|
|
1531
|
+
rawId: a.id,
|
|
1532
|
+
groupId: s,
|
|
1533
|
+
data: c
|
|
1534
|
+
}, p = be.factory(
|
|
1535
|
+
`${this.id}-${s}-${a.id}`
|
|
1536
|
+
)(l);
|
|
1537
|
+
this._availabilityItems.addModel(p);
|
|
1538
|
+
}
|
|
1539
|
+
this.updateGroupMembers();
|
|
1540
|
+
}
|
|
1541
|
+
async updateAvailability(e) {
|
|
1542
|
+
const t = Pt.getContext(this.id), r = (t == null ? void 0 : t.get(u.AvailabilityLoader)) || {};
|
|
1543
|
+
if (e.rebuild)
|
|
1544
|
+
for (const n of Object.keys(e == null ? void 0 : e.groups) || []) {
|
|
1545
|
+
this._availabilityItems.getIndexByKey("group", n).filter(
|
|
1546
|
+
(s) => !e.groups[n].find(
|
|
1547
|
+
(a) => `${this.id}-${n}-${a.id}` === s.id
|
|
1548
|
+
)
|
|
1549
|
+
).forEach((s) => {
|
|
1550
|
+
this._availabilityItems.removeModel(s.id), vt(s);
|
|
1551
|
+
});
|
|
1552
|
+
for (const s of (e == null ? void 0 : e.groups[n]) || []) {
|
|
1553
|
+
const a = await g.dataMapper.executeMapper(
|
|
1554
|
+
u.AvailabilityMapper,
|
|
1555
|
+
{ ...s, groupId: n },
|
|
1556
|
+
r
|
|
1557
|
+
), c = {
|
|
1558
|
+
...s,
|
|
1559
|
+
note: s.note ?? void 0,
|
|
1560
|
+
kosParentId: this.id,
|
|
1561
|
+
groupId: n,
|
|
1562
|
+
rawId: s.id,
|
|
1563
|
+
data: a,
|
|
1564
|
+
taggedIds: s.taggedIds
|
|
1565
|
+
}, l = this._availabilityItems.getModel(
|
|
1566
|
+
`${this.id}-${n}-${s.id}`
|
|
1567
|
+
);
|
|
1568
|
+
if (l)
|
|
1569
|
+
l.updateModel(c);
|
|
1570
|
+
else {
|
|
1571
|
+
const p = be.factory(
|
|
1572
|
+
`${this.id}-${n}-${s.id}`
|
|
1573
|
+
)(c);
|
|
1574
|
+
this._availabilityItems.addModel(p);
|
|
1575
|
+
}
|
|
1576
|
+
}
|
|
1577
|
+
}
|
|
1578
|
+
else
|
|
1579
|
+
for (const n of Object.keys(e == null ? void 0 : e.groups) || [])
|
|
1580
|
+
for (const i of (e == null ? void 0 : e.groups[n]) || []) {
|
|
1581
|
+
const s = await g.dataMapper.executeMapper(
|
|
1582
|
+
u.AvailabilityMapper,
|
|
1583
|
+
{ ...i, groupId: n },
|
|
1584
|
+
r
|
|
1585
|
+
), a = {
|
|
1586
|
+
...i,
|
|
1587
|
+
note: i.note ?? void 0,
|
|
1588
|
+
kosParentId: this.id,
|
|
1589
|
+
groupId: n,
|
|
1590
|
+
rawId: i.id,
|
|
1591
|
+
data: s,
|
|
1592
|
+
type: i.type,
|
|
1593
|
+
taggedIds: i.taggedIds
|
|
1594
|
+
}, c = this._availabilityItems.getModel(
|
|
1595
|
+
`${this.id}-${n}-${i.id}`
|
|
1596
|
+
);
|
|
1597
|
+
c && c.updateModel(a);
|
|
1598
|
+
}
|
|
1599
|
+
this.updateGroupMembers();
|
|
1600
|
+
}
|
|
1601
|
+
// -------------------ENTITY----------------------------
|
|
1602
|
+
};
|
|
1603
|
+
te([
|
|
1604
|
+
_
|
|
1605
|
+
], $.prototype, "_availabilityItems", 2);
|
|
1606
|
+
te([
|
|
1607
|
+
ue()
|
|
1608
|
+
], $.prototype, "pour", 1);
|
|
1609
|
+
te([
|
|
1610
|
+
ue()
|
|
1611
|
+
], $.prototype, "fixedPour", 1);
|
|
1612
|
+
te([
|
|
1613
|
+
Q({
|
|
1614
|
+
topic: `${jr}/availability`,
|
|
1615
|
+
websocket: !0
|
|
1616
|
+
})
|
|
1617
|
+
], $.prototype, "updateAvailability", 1);
|
|
1618
|
+
$ = te([
|
|
1619
|
+
I(X)
|
|
1620
|
+
], $);
|
|
1621
|
+
const $e = {
|
|
1622
|
+
registration: {
|
|
1623
|
+
[X]: {
|
|
1624
|
+
class: $,
|
|
1625
|
+
singleton: !1
|
|
1626
|
+
}
|
|
1627
|
+
},
|
|
1628
|
+
type: X,
|
|
1629
|
+
predicate: v(X),
|
|
1630
|
+
factory: b.Factory.create(X)
|
|
1631
|
+
};
|
|
1632
|
+
var Fr = Object.defineProperty, Kr = Object.getOwnPropertyDescriptor, nt = (e, t, r, n) => {
|
|
1633
|
+
for (var i = n > 1 ? void 0 : n ? Kr(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
1634
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
1635
|
+
return n && i && Fr(t, r, i), i;
|
|
1636
|
+
};
|
|
1637
|
+
const st = "device-assembly-model";
|
|
1638
|
+
let de = class {
|
|
1639
|
+
constructor(e, t, r) {
|
|
1640
|
+
o(this, "id");
|
|
1641
|
+
o(this, "deviceNozzles");
|
|
1642
|
+
o(this, "logger");
|
|
1643
|
+
this.id = e, this.logger = r.logger, this.deviceNozzles = new R();
|
|
1644
|
+
}
|
|
1645
|
+
// -------------------LIFECYCLE----------------------------
|
|
1646
|
+
async init() {
|
|
1647
|
+
this.logger.debug(`initializing device-assembly ${this.id}`);
|
|
1648
|
+
}
|
|
1649
|
+
getNozzle(e) {
|
|
1650
|
+
return this.deviceNozzles.getModel(e);
|
|
1651
|
+
}
|
|
1652
|
+
get nozzlePaths() {
|
|
1653
|
+
return this.deviceNozzles.data.map((e) => e.path);
|
|
1654
|
+
}
|
|
1655
|
+
async load() {
|
|
1656
|
+
this.logger.debug(`loading device-assembly ${this.id}`);
|
|
1657
|
+
const e = await Ye();
|
|
1658
|
+
(e == null ? void 0 : e.status) === 200 && e.data.assemblies.map((r) => r.nozzles).flat().forEach((r) => {
|
|
1659
|
+
var a;
|
|
1660
|
+
const n = r.path, i = ((a = r.pipelines.find((c) => c.name === "beverage")) == null ? void 0 : a.topicPrefix) || "", s = $e.factory(n)({
|
|
1661
|
+
path: r.path,
|
|
1662
|
+
name: r.name,
|
|
1663
|
+
urlPrefix: r.urlPrefix,
|
|
1664
|
+
topicPrefix: r.topicPrefix,
|
|
1665
|
+
beverageTopicPrefix: i
|
|
1666
|
+
});
|
|
1667
|
+
this.deviceNozzles.addModel(s);
|
|
1668
|
+
});
|
|
1669
|
+
}
|
|
1670
|
+
};
|
|
1671
|
+
nt([
|
|
1672
|
+
_
|
|
1673
|
+
], de.prototype, "deviceNozzles", 2);
|
|
1674
|
+
de = nt([
|
|
1675
|
+
I(st)
|
|
1676
|
+
], de);
|
|
1677
|
+
const Vr = new bt({
|
|
1678
|
+
class: de,
|
|
1679
|
+
type: st
|
|
1680
|
+
}), { URL: at } = C("GENERIC_POUR_SERVICE"), { postModel: Yr } = S.build({
|
|
1681
|
+
basePath: `${at}/api/nozzle`
|
|
1682
|
+
}), kr = async (e, t) => {
|
|
1683
|
+
const r = await Yr({
|
|
1684
|
+
model: {},
|
|
1685
|
+
urlOverride: `${at}${e}`,
|
|
1686
|
+
ordered: !0,
|
|
1687
|
+
tracker: t
|
|
1688
|
+
});
|
|
1689
|
+
return r != null && r.data && pe.initiateFuture(r.data), r;
|
|
1690
|
+
};
|
|
1691
|
+
var Zr = Object.defineProperty, Jr = Object.getOwnPropertyDescriptor, ot = (e, t, r, n) => {
|
|
1692
|
+
for (var i = n > 1 ? void 0 : n ? Jr(t, r) : t, s = e.length - 1, a; s >= 0; s--)
|
|
1693
|
+
(a = e[s]) && (i = (n ? a(t, r, i) : a(i)) || i);
|
|
1694
|
+
return n && i && Zr(t, r, i), i;
|
|
1695
|
+
};
|
|
1696
|
+
const dt = "generic-pour-model", Xr = "/kos/generic/pour/started", qr = "/kos/generic/pour/progress", Wr = "/kos/generic/pour/cancel", fe = (e) => e.onPourStart !== void 0 && e.onPourCancel !== void 0 && e.onPourProgress !== void 0;
|
|
1697
|
+
let le = class {
|
|
1698
|
+
constructor(e, t, r) {
|
|
1699
|
+
o(this, "id");
|
|
1700
|
+
o(this, "currentState", d.IDLE);
|
|
1701
|
+
o(this, "servicePath");
|
|
1702
|
+
o(this, "pourType");
|
|
1703
|
+
o(this, "logger");
|
|
1704
|
+
o(this, "futureHandler");
|
|
1705
|
+
this.id = e, this.logger = r.logger, this.futureHandler = new Be(this), this.servicePath = t.servicePath, this.pourType = t.pourType || "free";
|
|
1706
|
+
}
|
|
1707
|
+
async pour(e) {
|
|
1708
|
+
try {
|
|
1709
|
+
if (this.currentState === d.IDLE) {
|
|
1710
|
+
if (this.updateIfCurrent(d.IDLE, d.POUR_STARTING), !e)
|
|
1711
|
+
throw new Error("No tracker provided");
|
|
1712
|
+
const t = await kr(this.servicePath, e);
|
|
1713
|
+
this.updateIfCurrent(d.POUR_STARTING, d.POURING), O(this).forEach((n) => {
|
|
1714
|
+
var i;
|
|
1715
|
+
fe(n) && ((i = n.onPourStart) == null || i.call(n));
|
|
1716
|
+
});
|
|
1717
|
+
const r = {
|
|
1718
|
+
pourTarget: this.id,
|
|
1719
|
+
type: this.pourType
|
|
1720
|
+
};
|
|
1721
|
+
return E.publish(Xr, r), t;
|
|
1722
|
+
} else
|
|
1723
|
+
throw new Error(`Cannot pour in state ${this.currentState}`);
|
|
1724
|
+
} catch (t) {
|
|
1725
|
+
throw this.logger.error(t), this.currentState = d.IDLE, t;
|
|
1726
|
+
}
|
|
1727
|
+
}
|
|
1728
|
+
async cancelPour() {
|
|
1729
|
+
var e;
|
|
1730
|
+
if (this.currentState === d.POURING || this.currentState === d.POUR_STARTING) {
|
|
1731
|
+
this.currentState = d.POUR_CANCELING, await ((e = this.futureHandler.getFuture()) == null ? void 0 : e.cancelFuture()), y(() => {
|
|
1732
|
+
this.currentState = d.IDLE;
|
|
1733
|
+
}), O(this).forEach((r) => {
|
|
1734
|
+
var n;
|
|
1735
|
+
fe(r) && ((n = r.onPourCancel) == null || n.call(r));
|
|
1736
|
+
});
|
|
1737
|
+
const t = {
|
|
1738
|
+
pourTarget: this.id
|
|
1739
|
+
};
|
|
1740
|
+
E.publish(Wr, t);
|
|
1741
|
+
} else
|
|
1742
|
+
this.logger.warn(`Cannot cancel pour in state ${this.currentState}`);
|
|
1743
|
+
}
|
|
1744
|
+
updateIfCurrent(e, t) {
|
|
1745
|
+
this.currentState === e && y(() => {
|
|
1746
|
+
this.currentState = t;
|
|
1747
|
+
});
|
|
1748
|
+
}
|
|
1749
|
+
/**
|
|
1750
|
+
* A derived value that indicates if the nozzle is currently pouring a beverage.
|
|
1751
|
+
* @readonly
|
|
1752
|
+
*/
|
|
1753
|
+
get isPouring() {
|
|
1754
|
+
var e;
|
|
1755
|
+
return !!(this.futureHandler.getFuture() && !((e = this.futureHandler.getFuture()) != null && e.endState)) || this.currentState === d.POUR_STARTING || this.currentState === d.POURING || this.currentState === d.POUR_CANCELING;
|
|
1756
|
+
}
|
|
1757
|
+
/**
|
|
1758
|
+
* A derived value that indicates if the pour target is currently available to pour a beverage.
|
|
1759
|
+
*
|
|
1760
|
+
* Generally this means that the pour target is currently idle and not in the process of pouring, initiating a pour, or canceling a pour.
|
|
1761
|
+
* The value is observable and will change when the selected pourable changes or the pour target
|
|
1762
|
+
* starts or stops pouring.
|
|
1763
|
+
* @readonly
|
|
1764
|
+
* */
|
|
1765
|
+
get canPour() {
|
|
1766
|
+
return this.currentState === d.IDLE;
|
|
1767
|
+
}
|
|
1768
|
+
get future() {
|
|
1769
|
+
return this.futureHandler.getFuture();
|
|
1770
|
+
}
|
|
1771
|
+
get pourProgress() {
|
|
1772
|
+
var e;
|
|
1773
|
+
return ((e = this.future) == null ? void 0 : e.progress) ?? 0;
|
|
1774
|
+
}
|
|
1775
|
+
updateServicePath(e, t) {
|
|
1776
|
+
e !== this.servicePath && (this.isPouring && t && this.cancelPour(), this.servicePath = e);
|
|
1777
|
+
}
|
|
1778
|
+
onFutureUpdate(e) {
|
|
1779
|
+
O(this).forEach((r) => {
|
|
1780
|
+
fe(r) && r.onPourProgress(e);
|
|
1781
|
+
});
|
|
1782
|
+
const t = {
|
|
1783
|
+
pourTarget: this.id,
|
|
1784
|
+
progress: e.progress,
|
|
1785
|
+
status: e.status,
|
|
1786
|
+
clientData: e.clientData,
|
|
1787
|
+
futureId: e.futureId,
|
|
1788
|
+
remainingTimeMs: e.remainingTimeMs,
|
|
1789
|
+
endState: e.endState,
|
|
1790
|
+
reason: e.reason,
|
|
1791
|
+
timeRemaining: e.timeRemaining
|
|
1792
|
+
};
|
|
1793
|
+
E.publish(qr, t);
|
|
1794
|
+
}
|
|
1795
|
+
// -------------------LIFECYCLE----------------------------
|
|
1796
|
+
async init() {
|
|
1797
|
+
this.logger.debug(`initializing generic-pour ${this.id}`);
|
|
1798
|
+
}
|
|
1799
|
+
async load() {
|
|
1800
|
+
this.logger.debug(`loading generic-pour ${this.id}`);
|
|
1801
|
+
}
|
|
1802
|
+
};
|
|
1803
|
+
ot([
|
|
1804
|
+
ue()
|
|
1805
|
+
], le.prototype, "pour", 1);
|
|
1806
|
+
le = ot([
|
|
1807
|
+
I(dt)
|
|
1808
|
+
], le);
|
|
1809
|
+
const oi = new _t({
|
|
1810
|
+
class: le,
|
|
1811
|
+
type: dt
|
|
1812
|
+
}), Ne = {
|
|
1813
|
+
...He.registration,
|
|
1814
|
+
...Ue.registration,
|
|
1815
|
+
...et.registration,
|
|
1816
|
+
...Ve.registration,
|
|
1817
|
+
...$e.registration,
|
|
1818
|
+
...tt.registration,
|
|
1819
|
+
...Me.registration,
|
|
1820
|
+
...be.registration,
|
|
1821
|
+
...it.registration,
|
|
1822
|
+
...Qe.registration
|
|
1823
|
+
}, Qr = (e) => () => (Ot(e)(), Vr.register(), Object.keys(Ne).forEach((t) => {
|
|
1824
|
+
const r = Ne[t];
|
|
1825
|
+
Et(e)(t, r);
|
|
1826
|
+
}), g[W].register(
|
|
1827
|
+
"FirmwareUpdateInProgressTrouble",
|
|
1828
|
+
async (t) => {
|
|
1829
|
+
var r;
|
|
1830
|
+
if ((r = t.data) != null && r.deviceId) {
|
|
1831
|
+
const { model: n } = z(
|
|
1832
|
+
it.type
|
|
1833
|
+
);
|
|
1834
|
+
if (n) {
|
|
1835
|
+
const i = n.boards.find(
|
|
1836
|
+
(s) => s.id === t.data.deviceId
|
|
1837
|
+
) ? z(t.data.deviceId).model : void 0;
|
|
1838
|
+
return {
|
|
1839
|
+
devices: i ? i.name : ""
|
|
1840
|
+
};
|
|
1841
|
+
}
|
|
1842
|
+
}
|
|
1843
|
+
return {};
|
|
1844
|
+
}
|
|
1845
|
+
), {
|
|
1846
|
+
preload: M.model.preloadModel(e),
|
|
1847
|
+
model: M.model.register(e),
|
|
1848
|
+
companion: M.companion.register(e),
|
|
1849
|
+
legacy: M.model.registerLegacyModel(e)
|
|
1850
|
+
}), P = {
|
|
1851
|
+
...Mt
|
|
1852
|
+
};
|
|
1853
|
+
P.dispense = {
|
|
1854
|
+
models: Qr(P)
|
|
1855
|
+
};
|
|
1856
|
+
P.preload = M.model.preloadModel(P);
|
|
1857
|
+
P.model = M.model.register(P);
|
|
1858
|
+
P.companion = M.companion.register(P);
|
|
1859
|
+
P.legacy = M.model.registerLegacyModel(P);
|
|
1860
|
+
const di = P;
|
|
1861
|
+
export {
|
|
1862
|
+
it as A,
|
|
1863
|
+
x as B,
|
|
1864
|
+
zr as C,
|
|
1865
|
+
T as D,
|
|
1866
|
+
u as E,
|
|
1867
|
+
Nr as F,
|
|
1868
|
+
oi as G,
|
|
1869
|
+
Ve as H,
|
|
1870
|
+
Ue as I,
|
|
1871
|
+
xr as J,
|
|
1872
|
+
di as K,
|
|
1873
|
+
kr as L,
|
|
1874
|
+
$e as N,
|
|
1875
|
+
tt as P,
|
|
1876
|
+
ke as T,
|
|
1877
|
+
be as a,
|
|
1878
|
+
Ze as b,
|
|
1879
|
+
Qe as c,
|
|
1880
|
+
We as d,
|
|
1881
|
+
Vr as e,
|
|
1882
|
+
et as f,
|
|
1883
|
+
He as g,
|
|
1884
|
+
Me as h,
|
|
1885
|
+
Xe as i,
|
|
1886
|
+
d as j,
|
|
1887
|
+
Ne as k,
|
|
1888
|
+
Rt as l,
|
|
1889
|
+
si as m,
|
|
1890
|
+
At as n,
|
|
1891
|
+
ai as o,
|
|
1892
|
+
ni as p,
|
|
1893
|
+
ii as q,
|
|
1894
|
+
Qr as r,
|
|
1895
|
+
Ut as s,
|
|
1896
|
+
Ht as t,
|
|
1897
|
+
Bt as u,
|
|
1898
|
+
Ye as v,
|
|
1899
|
+
vr as w,
|
|
1900
|
+
Pr as x,
|
|
1901
|
+
Ar as y,
|
|
1902
|
+
Lr as z
|
|
1903
|
+
};
|
|
1904
|
+
//# sourceMappingURL=dispense-registration-manager-CSjwKonf.js.map
|