@danidoble/webserial 4.2.2 → 4.2.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,1107 @@
1
+ var vt = Object.defineProperty;
2
+ var F = (p) => {
3
+ throw TypeError(p);
4
+ };
5
+ var yt = (p, h, e) => h in p ? vt(p, h, { enumerable: !0, configurable: !0, writable: !0, value: e }) : p[h] = e;
6
+ var N = (p, h, e) => yt(p, typeof h != "symbol" ? h + "" : h, e), wt = (p, h, e) => h.has(p) || F("Cannot " + e);
7
+ var P = (p, h, e) => h.has(p) ? F("Cannot add the same private member more than once") : h instanceof WeakSet ? h.add(p) : h.set(p, e);
8
+ var n = (p, h, e) => (wt(p, h, "access private method"), e);
9
+ import { K as kt, _ as A, w as T, g as B } from "./kernel-BFXQSiNz.js";
10
+ var i, $, W, g, u, E, q, O, j, R, J, L, U, H, V, K, G, z, Q, Y, Z, X, tt, et, it, nt, rt, at, ot, ct, st, ht, _, l, m, d, f, lt, dt, pt, ut, w, S, M, D, I, _t;
11
+ class Tt extends kt {
12
+ constructor({
13
+ filters: e = null,
14
+ config_port: t = null,
15
+ no_device: r = 1,
16
+ device_listen_on_port: a = 1,
17
+ type: o = "esplus",
18
+ support_cart: c = !0
19
+ } = {}) {
20
+ super({ filters: e, config_port: t, no_device: r, device_listen_on_port: a });
21
+ P(this, i);
22
+ N(this, "__device", {
23
+ type: "esplus",
24
+ support_cart: !1,
25
+ withdraw: {
26
+ in_process: !1,
27
+ seconds: 60,
28
+ interval: 0
29
+ },
30
+ // waiting for user withdraw products
31
+ cart: {
32
+ in_process: !1
33
+ },
34
+ channels: {
35
+ verification: {
36
+ clear() {
37
+ this.running = !1, this.current = 1, this.channels = [];
38
+ },
39
+ running: !1,
40
+ start: 1,
41
+ end: 80,
42
+ current: 1,
43
+ channels: []
44
+ }
45
+ }
46
+ });
47
+ if (this.__internal__.device.type = "jofemar", A.getCustom(this.typeDevice, r))
48
+ throw new Error(`Device ${this.typeDevice} ${r} already exists`);
49
+ this.__internal__.dispense.must_response = !0, this.__internal__.time.response_general = 800, this.__internal__.time.response_engines = 800, this.__internal__.dispense.limit_counter = 40, this.__internal__.dispense.timeout = 0, this.__internal__.dispense.timeout_time = 4e3, this.__internal__.dispense.interval = 0, this.__internal__.dispense.interval_time = 1e3, this.__internal__.device.hex_number = (128 + this.listenOnChannel).toString(16), this.__internal__.device.door_open = !1, this.__internal__.dispense.elevator = {
50
+ locking_time: 60,
51
+ locking_interval: 0,
52
+ need_reset: !1
53
+ }, this.deviceType = o, this.supportCart = c, n(this, i, $).call(this), n(this, i, g).call(this), n(this, i, W).call(this);
54
+ }
55
+ set startChannelVerification(e) {
56
+ const t = parseInt(e);
57
+ if (isNaN(t)) throw new Error("Invalid start channel verification, must be a number");
58
+ if (t < 1 || t > 126) throw new Error("Invalid start channel verification, valid range is 1 to 126");
59
+ this.__device.channels.verification.start = t;
60
+ }
61
+ set endChannelVerification(e) {
62
+ const t = parseInt(e);
63
+ if (isNaN(t)) throw new Error("Invalid end channel verification, must be a number");
64
+ if (t < 1 || t > 126) throw new Error("Invalid end channel verification, valid range is 1 to 126");
65
+ this.__device.channels.verification.end = t;
66
+ }
67
+ set listenOnChannel(e) {
68
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 31) throw new Error("Invalid port number, valid range is 1 to 31");
69
+ this.__internal__.device.listen_on_port = e, this.__internal__.serial.bytes_connection = this.serialSetConnectionConstant(e), this.__internal__.device.hex_number = (128 + e).toString(16);
70
+ }
71
+ /**
72
+ * @deperecated
73
+ * @param {string|number} channel
74
+ */
75
+ set listenOnPort(e) {
76
+ this.listenOnChannel = e;
77
+ }
78
+ set deviceType(e) {
79
+ if (typeof e != "string") throw new Error("Invalid device type, must be a string");
80
+ this.__device.type = e;
81
+ }
82
+ set supportCart(e) {
83
+ if (typeof e != "boolean") throw new Error("Invalid support cart, must be a boolean");
84
+ this.__device.support_cart = e;
85
+ }
86
+ serialJofemarMakeBytes(e) {
87
+ let t = this.hexToDec(this.sumHex(e)), r = this.calcCheckSums(t.toString());
88
+ for (let a = 0; a < 2; a++)
89
+ e.push(this.hexMaker(r[a]));
90
+ return e.push("03"), this.add0x(e);
91
+ }
92
+ calcCheckSums(e) {
93
+ e = this.add0x([this.decToHex(parseInt(e).toString())]);
94
+ let t = [];
95
+ return t.push((e & 255 | 240).toString(16).toUpperCase()), t.push((e & 255 | 15).toString(16).toUpperCase()), t;
96
+ }
97
+ serialSetConnectionConstant(e = 1) {
98
+ let t = ["02", "30", "30", (128 + e).toString(16), "53", "FF", "FF"], r = [];
99
+ return t.forEach((a) => {
100
+ r.push(this.hexMaker(a));
101
+ }), this.serialJofemarMakeBytes(r);
102
+ }
103
+ serialMessage(e) {
104
+ let r = {
105
+ code: e,
106
+ name: null,
107
+ description: null,
108
+ request: "unknown",
109
+ no_code: 0,
110
+ additional: {
111
+ machine: {
112
+ hex: null,
113
+ dec: null
114
+ }
115
+ }
116
+ };
117
+ switch (e[0]) {
118
+ case "02":
119
+ r = n(this, i, ht).call(this, e, r, 128);
120
+ break;
121
+ case "06":
122
+ r = n(this, i, lt).call(this, e, r);
123
+ break;
124
+ case "15":
125
+ r.name = "Checksum error", r.description = "The calculated checksum does not match the received checksum", r.no_code = 38, n(this, i, l).call(this);
126
+ break;
127
+ default:
128
+ r.name = "unknown", r.description = "The message received is unknown", r.no_code = 404;
129
+ break;
130
+ }
131
+ this.dispatch("serial:message", r);
132
+ }
133
+ productRemovedContinueDispensing() {
134
+ this.__internal__.dispense.elevator.locking_interval && (this.__internal__.dispense.elevator.locking_time = 0);
135
+ }
136
+ /**
137
+ * Dispense a product from the machine
138
+ * @param {null|number|string} selection
139
+ * @param {boolean} cart
140
+ * @return {Promise<unknown>}
141
+ */
142
+ async dispense({ selection: e = 1, cart: t = !1 } = {}) {
143
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 130) throw new Error("Invalid selection");
144
+ const { channel: r, tray: a } = n(this, i, dt).call(this, e);
145
+ this.__internal__.dispense.backup_dispense = {
146
+ selection: e,
147
+ cart: t,
148
+ channel: r,
149
+ tray: a
150
+ };
151
+ let c = ["02", "30", "30", this.__internal__.device.hex_number, "56", a, r];
152
+ t && (c[4] = "4D"), c = n(this, i, E).call(this, c);
153
+ let s;
154
+ do
155
+ s = await this.internalDispense(c), n(this, i, pt).call(this), s.error === "elevator-locked" ? await n(this, i, q).call(this) : s.error === "no-response" && await T(1e3);
156
+ while (["elevator-locked", "no-response"].includes(s.error));
157
+ return this.__internal__.dispense.backup_dispense = {}, s;
158
+ }
159
+ internalClearSensing() {
160
+ super.internalClearSensing(), this.__internal__.dispense.timeout && clearTimeout(this.__internal__.dispense.timeout), this.__internal__.dispense.interval && clearInterval(this.__internal__.dispense.interval), this.__internal__.serial.queue.length > 0 && (this.__internal__.serial.queue = this.__internal__.serial.queue.filter((e) => e.type !== "status"));
161
+ }
162
+ async endDispense() {
163
+ let t = ["02", "30", "30", this.__internal__.device.hex_number, "4D", "80", "80"];
164
+ return t = n(this, i, E).call(this, t), await this.internalDispense(t);
165
+ }
166
+ async collect() {
167
+ const e = ["02", "30", "30", "81", "4E", "FF", "FF"];
168
+ return await n(this, i, u).call(this, e, "collect");
169
+ }
170
+ async resetSoldOutErrors() {
171
+ return await n(this, i, w).call(this, "80");
172
+ }
173
+ async resetWaitingProductRemovedError() {
174
+ return await n(this, i, w).call(this, "81");
175
+ }
176
+ async resetMachineErrors() {
177
+ return this.__internal__.serial.queue.length === 0 ? (n(this, i, S).call(this), await n(this, i, w).call(this, "FF")) : new Promise((e) => {
178
+ const t = setInterval(async () => {
179
+ this.__internal__.serial.queue.length > 0 || (clearInterval(t), await n(this, i, w).call(this, "FF"), n(this, i, S).call(this), e(!0));
180
+ }, 100);
181
+ });
182
+ }
183
+ async resetAllErrors() {
184
+ return await this.resetSoldOutErrors(), await T(100), await this.resetWaitingProductRemovedError(), await T(100), await this.resetMachineErrors();
185
+ }
186
+ async status() {
187
+ const e = ["02", "30", "30", "81", "53", "FF", "FF"];
188
+ return await n(this, i, u).call(this, e, "status");
189
+ }
190
+ async lightsOn() {
191
+ return await n(this, i, M).call(this, "81");
192
+ }
193
+ async lightsOff() {
194
+ return await n(this, i, M).call(this, "80");
195
+ }
196
+ async program(e, t) {
197
+ const r = ["02", "30", "30", "81", "50", e, t];
198
+ return await n(this, i, u).call(this, r, "program");
199
+ }
200
+ async programDisplayLanguage({ language: e = "spanish" } = {}) {
201
+ const t = { spanish: "30", english: "31", french: "32" };
202
+ if (!t[e]) throw new Error("Invalid language");
203
+ return await this.program("49", t[e]);
204
+ }
205
+ async programBeeper({ enable: e = !0 } = {}) {
206
+ const t = e ? "31" : "30";
207
+ return await this.program("5A", t);
208
+ }
209
+ async programDisableWorkingTemperature() {
210
+ if (this.__device.type === "iceplus") throw new Error("IcePlus does not support disable working temperature");
211
+ return await this.program("54", "80");
212
+ }
213
+ async programDisableThermometer() {
214
+ return await this.programDisableWorkingTemperature();
215
+ }
216
+ /**
217
+ * Program the machine to work with a specific temperature
218
+ * @param {number|string} degrees
219
+ * @return {Promise<void>}
220
+ */
221
+ async programWorkingTemperature({ degrees: e = 0.5 } = {}) {
222
+ e = parseFloat(e);
223
+ const t = this.__device.type === "iceplus" ? 6.5 : 32, r = this.__device.type === "iceplus" ? -25 : 0.5;
224
+ if (isNaN(e) || e < r || e > t || e % 0.5 !== 0)
225
+ throw new Error("Invalid degrees, must be a multiple of 0.5 and between 0.5 and 32");
226
+ let a = e * 2 + 128;
227
+ return this.__device.type === "iceplus" && (a += 51), a = Math.ceil(a), await this.program("54", a.toString(16));
228
+ }
229
+ /**
230
+ * @param {number|string} tray
231
+ * @return {Promise<void>}
232
+ */
233
+ async programIsolationTray({ tray: e = 0 } = {}) {
234
+ if (e = parseInt(e), isNaN(e) || e < 0 || e > 12) throw new Error("Invalid tray, valid range is 0 to 12");
235
+ const t = e === 0 ? "80" : (e + 139).toString(16);
236
+ return this.program("42", t);
237
+ }
238
+ /**
239
+ * @param {number|string} seconds
240
+ * @return {Promise<*>}
241
+ */
242
+ async programTimeToStandbyAfterCollect({ seconds: e = 15 } = {}) {
243
+ if (e = parseInt(e), isNaN(e) || e < 15 || e > 120) throw new Error("Invalid seconds, valid range is 15 to 120");
244
+ const t = (128 + e).toString(16);
245
+ return await this.program("46", t);
246
+ }
247
+ /**
248
+ * @param {number|string} seconds
249
+ * @return {Promise<*>}
250
+ */
251
+ async programTimeToStandbyWithoutCollect({ minutes: e = 1 } = {}) {
252
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 10) throw new Error("Invalid minutes, valid range is 1 to 10");
253
+ const t = (128 + e).toString(16);
254
+ return await this.program("48", t);
255
+ }
256
+ async programElevatorSpeed({ speed: e = "high" } = {}) {
257
+ const t = { high: "31", low: "30" };
258
+ if (!t[e]) throw new Error("Invalid speed, valid speeds are 'high' and 'low'");
259
+ return await this.program("76", t[e]);
260
+ }
261
+ async programTemperatureExpiration({ enable: e = !1 } = {}) {
262
+ const t = e ? "31" : "30";
263
+ return await this.program("63", t);
264
+ }
265
+ async programEnableTemperatureExpiration() {
266
+ return await this.programTemperatureExpiration({ enable: !0 });
267
+ }
268
+ async programDisableTemperatureExpiration() {
269
+ return await this.programTemperatureExpiration({ enable: !1 });
270
+ }
271
+ /**
272
+ * @param {number|string} address
273
+ * @return {Promise<*>}
274
+ */
275
+ async programMachineAddress({ address: e = 1 } = {}) {
276
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 31) throw new Error("Invalid address, valid range is 1 to 31");
277
+ const t = (128 + e).toString(16);
278
+ return await this.program("64", t);
279
+ }
280
+ /**
281
+ * @param {number|string} degrees
282
+ * @return {Promise<*>}
283
+ */
284
+ async programTemperatureBeforeExpiration({ degrees: e = 0.5 } = {}) {
285
+ if (e = parseFloat(e), isNaN(e) || e < 0.5 || e > 30 || e % 0.5 !== 0)
286
+ throw new Error("Invalid degrees, must be a multiple of 0.5 and valid range is 0.5 to 30");
287
+ const t = (128 + e * 2).toString(16);
288
+ return await this.program("65", t);
289
+ }
290
+ /**
291
+ * @param {number|string} minutes
292
+ * @return {Promise<*>}
293
+ */
294
+ async programTimeBeforeExpirationByTemperature({ minutes: e = 1 } = {}) {
295
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 120) throw new Error("Invalid minutes, valid range is 1 to 120");
296
+ const t = (128 + e).toString(16);
297
+ return await this.program("66", t);
298
+ }
299
+ async programTemperatureScale({ scale: e = "c" } = {}) {
300
+ const t = { c: "43", f: "46" };
301
+ if (!t[e]) throw new Error("Invalid scale, valid scales are 'c' for celsius and 'f' for fahrenheit");
302
+ return await this.program("67", t[e]);
303
+ }
304
+ /**
305
+ * @param {number|string} selection
306
+ * @param {number|string} voltage
307
+ * @return {Promise<void>}
308
+ */
309
+ async programVoltageEngine({ selection: e = 1, voltage: t = 5 } = {}) {
310
+ if (t = parseFloat(t), e = parseInt(e), isNaN(e) || e < 1 || e > this.__device.channels.verification.end)
311
+ throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);
312
+ if (isNaN(t) || t < 5 || t > 9.5 || t % 0.5 !== 0)
313
+ throw new Error("Invalid voltage, valid range is 5 to 9.5");
314
+ const r = 109 + e, o = (128 + (t - 5) * 2).toString(16), c = ["02", "30", "30", "81", "47", r, o];
315
+ return await n(this, i, u).call(this, c, "voltage-engine");
316
+ }
317
+ /**
318
+ * @param {number|string} selection
319
+ * @param {boolean} enable
320
+ * @return {Promise<void>}
321
+ */
322
+ async programPushOverProducts({ selection: e = 1, enable: t = !0 } = {}) {
323
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > this.__device.channels.verification.end)
324
+ throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);
325
+ const o = ["02", "30", "30", "81", "4F", 109 + e, t ? "31" : "30"];
326
+ return await n(this, i, u).call(this, o, "push-over-products");
327
+ }
328
+ /**
329
+ * @param {number|string} selection
330
+ * @param {number|string} seconds
331
+ * @return {Promise<void>}
332
+ */
333
+ async programChannelRunningAfterDispense({ selection: e = 1, seconds: t = 0 } = {}) {
334
+ if (e = parseInt(e), t = parseFloat(t), isNaN(e) || e < 1 || e > this.__device.channels.verification.end)
335
+ throw new Error(`Invalid selection, valid range is 1 to ${this.__device.channels.verification.end}`);
336
+ if (isNaN(t) || t < 0 || t > 10 || t % 0.1 !== 0)
337
+ throw new Error("Invalid seconds, valid range is 0.0 to 10.0 with a step of 0.1");
338
+ const r = 109 + e;
339
+ t = t.toFixed(1);
340
+ const a = 128 + t * 10, o = ["02", "30", "30", "81", "45", r, a];
341
+ return await n(this, i, u).call(this, o, "channel-running-after-dispense");
342
+ }
343
+ async checkData(e, t = "FF") {
344
+ const r = ["02", "30", "30", "81", "43", e, t];
345
+ return await n(this, i, u).call(this, r, "check-data");
346
+ }
347
+ async getDisplayLanguage() {
348
+ return await this.checkData("49");
349
+ }
350
+ async getBeeper() {
351
+ return await this.checkData("5A");
352
+ }
353
+ async getWorkingTemperature() {
354
+ return await this.checkData("54");
355
+ }
356
+ async getIsolationTray() {
357
+ return await this.checkData("42");
358
+ }
359
+ async getProgramVersion() {
360
+ return await this.checkData("50");
361
+ }
362
+ async getFaults() {
363
+ return await this.checkData("53");
364
+ }
365
+ async getMachineId() {
366
+ return await this.checkData("4E");
367
+ }
368
+ async getCurrentTemperature() {
369
+ return await this.checkData("74");
370
+ }
371
+ async getTimeToStandbyAfterCollect() {
372
+ return await this.checkData("46");
373
+ }
374
+ async getTimeToStandbyWithoutCollect() {
375
+ return await this.checkData("48");
376
+ }
377
+ async getElevatorSpeed() {
378
+ return await this.checkData("76");
379
+ }
380
+ async getTemperatureExpiration() {
381
+ return await this.checkData("63");
382
+ }
383
+ async getTemperatureBeforeExpiration() {
384
+ return await this.checkData("65");
385
+ }
386
+ async getTimeBeforeExpirationByTemperature() {
387
+ return await this.checkData("66");
388
+ }
389
+ async getTemperatureScale() {
390
+ return await this.checkData("67");
391
+ }
392
+ async getClockRegisters() {
393
+ return await this.checkData("72");
394
+ }
395
+ async getMachineActivity() {
396
+ return await this.checkData("41");
397
+ }
398
+ /**
399
+ * @param {number|string} selection
400
+ * @return {Promise<*>}
401
+ */
402
+ async getVoltageEngine({ selection: e = 1 } = {}) {
403
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 126)
404
+ throw new Error("Invalid selection, valid range is 1 to 126");
405
+ const t = (109 + e).toString(16);
406
+ return await this.checkData("47", t);
407
+ }
408
+ /**
409
+ * @param {number|string} selection
410
+ * @return {Promise<*>}
411
+ */
412
+ async getChannelPresence({ selection: e = 1 } = {}) {
413
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 126)
414
+ throw new Error("Invalid selection, valid range is 1 to 126");
415
+ const t = (109 + e).toString(16);
416
+ return await this.checkData("43", t);
417
+ }
418
+ /**
419
+ * @param {number|string} selection
420
+ * @return {Promise<*>}
421
+ */
422
+ async getPushOverProducts({ selection: e = 1 } = {}) {
423
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 126)
424
+ throw new Error("Invalid selection, valid range is 1 to 126");
425
+ const t = (109 + e).toString(16);
426
+ return await this.checkData("4F", t);
427
+ }
428
+ /**
429
+ * @param {number|string} selection
430
+ * @return {Promise<*>}
431
+ */
432
+ async getChannelRunningAfterDispense({ selection: e = 1 } = {}) {
433
+ if (e = parseInt(e), isNaN(e) || e < 1 || e > 126)
434
+ throw new Error("Invalid selection, valid range is 1 to 126");
435
+ const t = (109 + e).toString(16);
436
+ return await this.checkData("45", t);
437
+ }
438
+ async setDisplayStandbyMessage({ message: e = "" } = {}) {
439
+ e = e.substring(0, 32);
440
+ const t = n(this, i, I).call(this, e);
441
+ return await n(this, i, D).call(this, "80", t);
442
+ }
443
+ /**
444
+ * @param {string} message
445
+ * @param {number|string} seconds
446
+ * @return {Promise<void>}
447
+ */
448
+ async setDisplayMessageTemporarily({ message: e = "", seconds: t = 1 }) {
449
+ if (e = e.substring(0, 32), t = parseInt(t), isNaN(t) || t < 1 || t > 125) throw new Error("Invalid seconds, valid range is 1 to 125");
450
+ const r = n(this, i, I).call(this, e), a = (128 + t).toString(16);
451
+ return await n(this, i, D).call(this, a, r);
452
+ }
453
+ /**
454
+ * @param {string} message
455
+ * @return {Promise<void>}
456
+ */
457
+ async setDisplayMessageUnlimited({ message: e = "" }) {
458
+ e = e.substring(0, 32);
459
+ const t = n(this, i, I).call(this, e);
460
+ return await n(this, i, D).call(this, "FF", t);
461
+ }
462
+ async programClock({ date: e = /* @__PURE__ */ new Date() } = {}) {
463
+ if (!(e instanceof Date)) throw new Error("Invalid date, must be an instance of Date");
464
+ const t = ["02", "30", "30", "81", "72", ...n(this, i, _t).call(this, e)];
465
+ return await n(this, i, u).call(this, t, "clock");
466
+ }
467
+ /**
468
+ * @param {null|string} event
469
+ * @param {boolean} enable
470
+ * @return {Promise<void>}
471
+ */
472
+ async eventsConfig({ event: e = null, enable: t = !0 } = {}) {
473
+ if (e === null) throw new Error("Invalid event");
474
+ const a = ["02", "30", "30", "81", "41", e, t ? "31" : "30"];
475
+ return await n(this, i, u).call(this, a, "events-config");
476
+ }
477
+ async eventEnable({ event: e = null } = {}) {
478
+ if (e === null) throw new Error("Invalid event");
479
+ const t = parseInt(e, 16);
480
+ if (isNaN(t) || t < 38 || t > 100) throw new Error("Invalid event");
481
+ return await this.eventsConfig({ event: e, enable: !0 });
482
+ }
483
+ async eventDisable({ event: e = null } = {}) {
484
+ if (e === null) throw new Error("Invalid event");
485
+ const t = parseInt(e, 16);
486
+ if (isNaN(t) || t < 38 || t > 100) throw new Error("Invalid event");
487
+ return await this.eventsConfig({ event: e, enable: !1 });
488
+ }
489
+ async sendCustomCode({ code: e = [] } = {}) {
490
+ if (e.length < 5) throw new Error("Invalid code, minimum length is 5");
491
+ return await n(this, i, u).call(this, e, "custom");
492
+ }
493
+ async assignChannels() {
494
+ const e = this.__device.channels.verification.start, t = this.__device.channels.verification.end;
495
+ if (e > t) throw new Error("Invalid range, start must be less than end");
496
+ this.__device.channels.verification.clear(), this.__device.channels.verification.running = !0;
497
+ for (let r = e; r <= t; r++)
498
+ this.__device.channels.verification.current = r, await this.getChannelPresence({ selection: r });
499
+ return new Promise((r) => {
500
+ let a = setInterval(() => {
501
+ this.__device.channels.verification.channels.length === t - e + 1 && (clearInterval(a), this.dispatch("channels", { channels: this.__device.channels.verification.channels }), this.__device.channels.verification.clear(), r(!0));
502
+ }, 500);
503
+ });
504
+ }
505
+ }
506
+ i = new WeakSet(), $ = function() {
507
+ const e = [
508
+ "dispensing:withdrawal",
509
+ "command-executed",
510
+ "keyboard:pressed",
511
+ "door:event",
512
+ "program:version",
513
+ "machine:faults",
514
+ "clock:registers",
515
+ "machine:activity",
516
+ "check:language",
517
+ "check:beeper",
518
+ "check:isolation-tray",
519
+ "check:engine-voltage",
520
+ "check:push-over",
521
+ "check:extractor-after-dispense",
522
+ "check:standby-after-collect",
523
+ "check:standby-without-collect",
524
+ "check:elevator-speed",
525
+ "check:expiration-by-temperature",
526
+ "check:temperature-before-expiration",
527
+ "check:expiration-after",
528
+ "check:temperature-scale",
529
+ "check:machine-id",
530
+ "temperature:working",
531
+ "temperature:current",
532
+ "jofemar:warning",
533
+ "jofemar:error",
534
+ "serial:message",
535
+ "reset:errors",
536
+ "channels",
537
+ "channel:status",
538
+ "machine:status"
539
+ ];
540
+ for (const t of e)
541
+ this.serialRegisterAvailableListener(t);
542
+ }, W = function() {
543
+ this.on("internal:dispense:running", n(this, i, ut).bind(this));
544
+ }, g = function() {
545
+ A.add(this);
546
+ }, u = function(e, t) {
547
+ return e[3] = this.__internal__.device.hex_number, this.appendToQueue(n(this, i, E).call(this, e), t);
548
+ }, E = function(e) {
549
+ let t = this.hexToDec(this.sumHex(e)), r = this.calcCheckSums(t.toString());
550
+ for (let a = 0; a < 2; a++)
551
+ e.push(this.hexMaker(r[a]));
552
+ return e.push("03"), e;
553
+ }, q = async function() {
554
+ if (this.__internal__.dispense.elevator.locking_interval) return;
555
+ this.__internal__.dispense.elevator.need_reset && (this.__internal__.dispense.elevator.need_reset = !1, await this.resetWaitingProductRemovedError(), await T(500));
556
+ const e = this;
557
+ return this.__internal__.dispense.status = "elevator-locked", this.__internal__.dispense.elevator.locking_time = 60, new Promise((t) => {
558
+ e.__internal__.dispense.elevator.locking_interval = setInterval(() => {
559
+ e.dispatch("dispensing:withdrawal", {
560
+ elevator: !0,
561
+ seconds: e.__internal__.dispense.elevator.locking_time,
562
+ description: "Please recall products from the elevator"
563
+ }), e.__internal__.dispense.elevator.locking_time -= 1, e.__internal__.dispense.elevator.locking_time <= 0 && (clearInterval(e.__internal__.dispense.elevator.locking_interval), e.__internal__.dispense.elevator.locking_interval = 0, t(!0));
564
+ }, 1e3);
565
+ });
566
+ }, O = function(e, t) {
567
+ return t.name = "ok", t.description = "The last command was executed successfully", t.no_code = 1, this.dispatch("command-executed", t), t;
568
+ }, j = function(e, t) {
569
+ t.additional = {
570
+ hex: e,
571
+ dec: this.hexToDec(e),
572
+ ascii: null
573
+ };
574
+ const r = {
575
+ 30: "0",
576
+ 31: "1",
577
+ 32: "2",
578
+ 33: "3",
579
+ 34: "4",
580
+ 35: "5",
581
+ 36: "6",
582
+ 37: "7",
583
+ 38: "8",
584
+ 39: "9",
585
+ "2a": "*",
586
+ 23: "#",
587
+ 41: "A",
588
+ 42: "B",
589
+ 43: "C",
590
+ 44: "D"
591
+ };
592
+ return t.additional.ascii = r[e] ?? null, t.name = "Key pressed", t.description = `The key ${t.additional.ascii} was pressed`, t.no_code = 2, this.dispatch("keyboard:pressed", t.additional), t;
593
+ }, R = function(e, t) {
594
+ return t.additional = { open: !1 }, t.no_code = 3, e === "4f" ? (t.name = "door open", t.description = "The door was opened", t.additional.open = !0, this.__internal__.device.door_open = !0, this.dispatch("door:event", t.additional)) : e === "43" ? (t.name = "door close", t.description = "The door was closed", t.additional.open = !1, this.__internal__.device.door_open = !1, this.dispatch("door:event", t.additional)) : (t.name = "door event", t.description = "The door event received is unknown", this.dispatch("door:event", { open: t.additional.open, message: t })), t;
595
+ }, J = function(e, t) {
596
+ t.no_code = 404;
597
+ let r = e[5] ?? null;
598
+ return r && this.listenOnChannel > 1 && (r = this.hexToDec(r) - this.listenOnChannel + 1, r = this.decToHex(r)), r && (r === "FD" ? (t.no_code = 4, t.name = "channel disconnected", t.description = "The channel is disconnected", t.additional = { active: !1 }) : r === "FC" ? (t.no_code = 5, t.name = "channel connected", t.description = "The channel is connected", t.additional = { active: !0 }) : (t.no_code = 6, t.name = "channel sold out", t.description = "The channel is empty", t.additional = { active: !0 }), this.__device.channels.verification.running && (this.__device.channels.verification.channels.push({
599
+ selection: this.__device.channels.verification.current,
600
+ active: t.additional.active
601
+ }), t.additional.selection = this.__device.channels.verification.current), this.dispatch("channel:status", t.additional)), t;
602
+ }, L = function(e, t) {
603
+ t.no_code = 39, t.name = "Program version";
604
+ const r = e.slice(4, 12), a = r.map((o) => String.fromCharCode(this.hexToDec(o))).join("");
605
+ return t.additional = { version: a, hex: r }, t.description = `The program version is ${a}`, this.dispatch("program:version", t.additional), t;
606
+ }, U = function(e, t) {
607
+ t.no_code = 39, t.name = "Machine faults", t.description = "No faults detected", t.additional = { no_faults: 0, faults: [] };
608
+ const r = e.slice(4, -3);
609
+ if (r.length > 1 && r[0] !== "30") {
610
+ t.description = "Machine has faults";
611
+ const a = {
612
+ 31: "Busy",
613
+ 32: "Invalid tray",
614
+ 33: "Invalid channel",
615
+ 34: "Empty channel",
616
+ 35: "Jam in elevator engine",
617
+ 36: "Malfunction in the elevator belt or product detector",
618
+ 37: "Failure in one of the photo transistors in the cabinet",
619
+ 38: "No channels detected",
620
+ 39: "Product detector fault",
621
+ 41: "Machine display is disconnected",
622
+ 42: "Product alarm under elevator",
623
+ 43: "Error when elevator approaching to a position",
624
+ 44: "Fault in keyboard",
625
+ 45: "Eeprom writing error",
626
+ 46: "Fault communicating with temperature control",
627
+ 47: "The thermometer is disconnected",
628
+ 48: "Thermometer programming lost",
629
+ 49: "Thermometer faulty",
630
+ "4a": "Channels power consumption detector faulty",
631
+ "4b": "Elevator does not find channel or tray",
632
+ "4c": "Elevator does not find delivery product position",
633
+ "4d": "Interior of elevator blocked",
634
+ "4e": "Error in tester of product detector",
635
+ "4f": "Waiting for product to be removed",
636
+ 50: "Product expired by temperature reasons",
637
+ 51: "Automatic door faulty",
638
+ 59: "Product is expired",
639
+ "5a": "Product is expired",
640
+ 61: "Product is expired",
641
+ 62: "Product is expired",
642
+ 63: "Product is expired",
643
+ 64: "Product detector didn't change during its verification test"
644
+ };
645
+ for (const o of r)
646
+ a[o] && (t.additional.faults.push(a[o]), t.additional.no_faults++);
647
+ }
648
+ return this.dispatch("machine:faults", t.additional), t;
649
+ }, H = function(e, t) {
650
+ t.no_code = 40, t.name = "Clock registers", t.description = "Clock registers";
651
+ const r = e.slice(4, -3), a = r.map((C) => String.fromCharCode(this.hexToDec(C))).join(""), [o, c] = a.split(" "), [s, v] = o.split(":"), [y, k, b] = c.split("-"), x = new Date(
652
+ 2e3 + parseInt(b),
653
+ parseInt(k) - 1,
654
+ parseInt(y),
655
+ parseInt(s),
656
+ parseInt(v)
657
+ );
658
+ return t.additional = {
659
+ day: y,
660
+ month: k,
661
+ year: b,
662
+ hours: s,
663
+ minutes: v,
664
+ formatted: a,
665
+ date: x,
666
+ hex: r
667
+ }, this.dispatch("clock:registers", t.additional), t;
668
+ }, V = function(e, t) {
669
+ t.no_code = 41, t.name = "Machine activity", t.description = "Events from read machine activity";
670
+ const r = String.fromCharCode(this.hexToDec(e[4]));
671
+ if (r !== "0") {
672
+ const a = e.slice(5, -3);
673
+ if (r === "T" && a.length === 4) {
674
+ const o = String.fromCharCode(this.hexToDec(a[0])), c = String.fromCharCode(this.hexToDec(a[1])), s = String.fromCharCode(this.hexToDec(a[3]));
675
+ t.additional = {
676
+ ascii: r,
677
+ type: "DU.d",
678
+ dozens: o,
679
+ units: c,
680
+ decimals: s,
681
+ time: parseFloat(`${o}${c}.${s}`),
682
+ meaning: "Extraction time (in seconds)"
683
+ };
684
+ } else if (["B", "D", "E", "F", "G"].includes(r) && a.length === 3) {
685
+ const o = String.fromCharCode(this.hexToDec(a[0])), c = String.fromCharCode(this.hexToDec(a[1])), s = String.fromCharCode(this.hexToDec(a[2])), v = parseInt(`${o}${c}${s}`), y = {
686
+ B: "Error on going to tray channel",
687
+ D: "Error on product detector",
688
+ E: "Extraction of channel ok",
689
+ F: "Error on engine intensity detection",
690
+ G: "Error on product exit door"
691
+ };
692
+ t.additional = {
693
+ type: "HDU",
694
+ hundreds: o,
695
+ dozens: c,
696
+ decimals: s,
697
+ channel: v,
698
+ selection: v - 109,
699
+ ascii: r,
700
+ meaning: y[r] ?? "Unknown"
701
+ };
702
+ } else if (a.length === 13) {
703
+ const o = a.map((ft) => String.fromCharCode(this.hexToDec(ft))).join(""), c = parseInt(o.slice(0, 2)), s = parseInt(o.slice(2, 4)), v = parseInt(o.slice(4, 6)), y = parseInt(o.slice(7, 9)), k = parseInt(o.slice(9, 11)) - 1, b = 2e3 + parseInt(o.slice(11, 13)), x = new Date(b, k, y, c, s, v), C = {
704
+ A: "Attempt to close product exit door",
705
+ C: "Closing of exterior door",
706
+ H: "Error on opening of product exit door",
707
+ I: "New attempt to arrive at product exit position after an error on first attempt",
708
+ J: "Power on cooling unit",
709
+ K: "Power off cooling unit",
710
+ L: "Start of defrosting",
711
+ M: "End of defrosting",
712
+ O: "Opening of exterior door",
713
+ R: "Memory reset",
714
+ S: "Error on going to product exit position",
715
+ Y: "Power on machine",
716
+ Z: "Power off machine",
717
+ c: "Closing of inner door",
718
+ e: "New attempt to extract from channel due no product detection when elevator arrived to product exit position",
719
+ o: "Opening of inner door"
720
+ };
721
+ t.additional = {
722
+ type: "hhmmssWddMMAA",
723
+ date: x,
724
+ hex: a,
725
+ formatted: x.toLocaleString(),
726
+ ascii: r,
727
+ meaning: C[r] ?? "Unknown"
728
+ };
729
+ }
730
+ }
731
+ return this.dispatch("machine:activity", t.additional), t;
732
+ }, K = function(e, t) {
733
+ const r = {
734
+ 30: "Spanish",
735
+ 31: "English",
736
+ 32: "French"
737
+ };
738
+ return t.no_code = 42, t.name = "Language", t.description = `The language is ${r[e] ?? "unknown"}`, t.additional = {
739
+ hex: e,
740
+ language: r[e] ?? "unknown"
741
+ }, this.dispatch("check:language", t.additional), t;
742
+ }, G = function(e, t) {
743
+ return t.no_code = 43, t.name = "Beeper", t.description = `The beeper is ${e === "30" ? "on" : "off"}`, t.additional = {
744
+ hex: e,
745
+ beeper: e === "30"
746
+ }, this.dispatch("check:beeper", t.additional), t;
747
+ }, z = function(e, t) {
748
+ t.no_code = 44, t.name = "Isolation tray", t.description = "Isolation tray";
749
+ const r = this.hexToDec(e) - 139;
750
+ return t.additional = {
751
+ hex: e,
752
+ tray: r
753
+ }, this.dispatch("check:isolation-tray", t.additional), t;
754
+ }, Q = function(e, t) {
755
+ t.no_code = 45, t.name = "Engine voltage", t.description = "Engine voltage";
756
+ const r = (this.hexToDec(e) - 128) / 2 + 5;
757
+ return t.additional = {
758
+ hex: e,
759
+ voltage: r
760
+ }, this.dispatch("check:engine-voltage", t.additional), t;
761
+ }, Y = function(e, t) {
762
+ t.no_code = 46, t.name = "Push over", t.description = "Push over";
763
+ const r = e === "30";
764
+ return t.additional = {
765
+ hex: e,
766
+ push: r
767
+ }, this.dispatch("check:push-over", t.additional), t;
768
+ }, Z = function(e, t) {
769
+ t.no_code = 47, t.name = "Extractor after dispense", t.description = "Extractor after dispense";
770
+ const r = (this.hexToDec(e) - 128) / 10;
771
+ return t.additional = {
772
+ hex: e,
773
+ seconds: r
774
+ }, this.dispatch("check:extractor-after-dispense", t.additional), t;
775
+ }, X = function(e, t) {
776
+ t.no_code = 48, t.name = "Standby after collect", t.description = "Time to standby after collect product";
777
+ const r = this.hexToDec(e) - 128;
778
+ return t.additional = {
779
+ hex: e,
780
+ seconds: r
781
+ }, this.dispatch("check:standby-after-collect", t.additional), t;
782
+ }, tt = function(e, t) {
783
+ t.no_code = 49, t.name = "Standby without collect", t.description = "Time to standby when product delivery is not collected";
784
+ const r = this.hexToDec(e) - 128;
785
+ return t.additional = {
786
+ hex: e,
787
+ minutes: r
788
+ }, this.dispatch("check:standby-without-collect", t.additional), t;
789
+ }, et = function(e, t) {
790
+ t.no_code = 50, t.name = "Elevator speed", t.description = "Elevator speed";
791
+ const r = e === "30" ? "low" : "high";
792
+ return t.additional = {
793
+ hex: e,
794
+ speed: r
795
+ }, this.dispatch("check:elevator-speed", t.additional), t;
796
+ }, it = function(e, t) {
797
+ t.no_code = 51, t.name = "Temperature expiration", t.description = "Temperature expiration";
798
+ const r = e === "31";
799
+ return t.additional = {
800
+ hex: e,
801
+ enabled: r
802
+ }, this.dispatch("check:expiration-by-temperature", t.additional), t;
803
+ }, nt = function(e, t) {
804
+ t.no_code = 52, t.name = "Temperature before expiration", t.description = "Temperature before expiration";
805
+ const r = (this.hexToDec(e) - 128) / 2;
806
+ return t.additional = {
807
+ hex: e,
808
+ temperature: r
809
+ }, this.dispatch("check:temperature-before-expiration", t.additional), t;
810
+ }, rt = function(e, t) {
811
+ t.no_code = 53, t.name = "Time before expiration", t.description = "Time before expiration";
812
+ const r = this.hexToDec(e) - 128;
813
+ return t.additional = {
814
+ hex: e,
815
+ minutes: r
816
+ }, this.dispatch("check:expiration-after", t.additional), t;
817
+ }, at = function(e, t) {
818
+ t.no_code = 54, t.name = "Temperature scale", t.description = "Temperature scale";
819
+ const r = e === "43" ? "Celsius" : "Fahrenheit";
820
+ return t.additional = {
821
+ hex: e,
822
+ scale: r
823
+ }, this.dispatch("check:temperature-scale", t.additional), t;
824
+ }, ot = function(e, t) {
825
+ return t.no_code = 54, t.name = "Machine ID", t.description = "Machine ID", t.additional = { hex: e[4], full_hex: e }, this.dispatch("check:machine-id", t.additional), t;
826
+ }, ct = function(e, t) {
827
+ return t.no_code = 7, t.name = "working temperature", t.description = `The working temperature is ${e}`, t.additional = {
828
+ hex: e,
829
+ temperature: {
830
+ traditional: (this.hexToDec(e) - this.hexToDec("80")) / 2,
831
+ ice_plus: (this.hexToDec(e) - this.hexToDec("80")) / 2 - 25.5
832
+ }
833
+ }, this.dispatch("temperature:working", t.additional), t;
834
+ }, st = function(e, t) {
835
+ return t.no_code = 8, t.name = "current temperature", t.additional = {
836
+ sign: null,
837
+ tens: null,
838
+ units: null,
839
+ decimals: null,
840
+ type_degrees: null,
841
+ formatted: null,
842
+ decimal_point: e[7] === "2e" ? "." : null,
843
+ degrees: e[9] === "7f" ? "°" : null,
844
+ error: null
845
+ }, e[4] === "2b" ? t.additional.sign = e[4] = "+" : ["2e", "2d"].includes(e[4]) ? t.additional.sign = e[4] = "-" : e[4] === "20" && (t.additional.error = "Error in thermometer"), this.hexToDec(e[5]) >= 48 && this.hexToDec(e[5]) <= 57 ? t.additional.tens = this.hexToDec(e[5]) - 48 : e[5] === "2a" && (t.additional.error = "Error in thermometer"), this.hexToDec(e[6]) >= 48 && this.hexToDec(e[6]) <= 57 ? t.additional.units = this.hexToDec(e[6]) - 48 : e[6] === "2a" && (t.additional.error = "Error in thermometer"), this.hexToDec(e[8]) >= 48 && this.hexToDec(e[8]) <= 57 ? t.additional.decimals = this.hexToDec(e[8]) - 48 : e[8] === "2a" && (t.additional.error = "Error in thermometer"), e[10] === "43" ? t.additional.type_degrees = "C" : e[10] === "46" && (t.additional.type_degrees = "F"), t.additional.error === "Error in thermometer" ? (t.additional.formatted = "Error in thermometer", t.description = "The current temperature cannot be read because there is an error in the thermometer") : (t.additional.formatted = (t.additional.sign ?? "") + (t.additional.tens ?? "") + (t.additional.units ?? "") + (t.additional.decimal_point ?? "") + (t.additional.decimals ?? "") + (t.additional.degrees ?? "") + (t.additional.type_degrees ?? ""), t.description = `The current temperature is ${t.additional.formatted}`), this.dispatch("temperature:current", t.additional), t;
846
+ }, ht = function(e, t, r = 128) {
847
+ if (e[1] && (t.additional.machine.hex = e[1], t.additional.machine.dec = this.hexToDec(e[1]) - r), !(e[1] && e[2]))
848
+ t = n(this, i, O).call(this, e, t);
849
+ else
850
+ switch (e[2]) {
851
+ case "54":
852
+ t.request = "--automatic", t = n(this, i, j).call(this, e[3], t);
853
+ break;
854
+ case "50":
855
+ t.request = "--automatic", t = n(this, i, R).call(this, e[3], t);
856
+ break;
857
+ case "43":
858
+ switch (t.request = "check-data", e[3]) {
859
+ case "41":
860
+ t = n(this, i, V).call(this, e, t);
861
+ break;
862
+ case "43":
863
+ t.request = "channel-status", t = n(this, i, J).call(this, e, t);
864
+ break;
865
+ case "50":
866
+ t = n(this, i, L).call(this, e, t);
867
+ break;
868
+ case "53":
869
+ t = n(this, i, U).call(this, e, t);
870
+ break;
871
+ case "54":
872
+ t.request = "working-temperature", t = n(this, i, ct).call(this, e[4], t);
873
+ break;
874
+ case "72":
875
+ t = n(this, i, H).call(this, e, t);
876
+ break;
877
+ case "74":
878
+ t.request = "current-temperature", t = n(this, i, st).call(this, e, t);
879
+ break;
880
+ case "49":
881
+ t = n(this, i, K).call(this, e[4], t);
882
+ break;
883
+ case "5a":
884
+ t = n(this, i, G).call(this, e[4], t);
885
+ break;
886
+ case "42":
887
+ t = n(this, i, z).call(this, e[4], t);
888
+ break;
889
+ case "47":
890
+ t = n(this, i, Q).call(this, e[4], t);
891
+ break;
892
+ case "4e":
893
+ t = n(this, i, ot).call(this, e, t);
894
+ break;
895
+ case "4f":
896
+ t = n(this, i, Y).call(this, e[4], t);
897
+ break;
898
+ case "45":
899
+ t = n(this, i, Z).call(this, e[4], t);
900
+ break;
901
+ case "46":
902
+ t = n(this, i, X).call(this, e[4], t);
903
+ break;
904
+ case "48":
905
+ t = n(this, i, tt).call(this, e[4], t);
906
+ break;
907
+ case "76":
908
+ t = n(this, i, et).call(this, e[4], t);
909
+ break;
910
+ case "63":
911
+ t = n(this, i, it).call(this, e[4], t);
912
+ break;
913
+ case "65":
914
+ t = n(this, i, nt).call(this, e[4], t);
915
+ break;
916
+ case "66":
917
+ t = n(this, i, rt).call(this, e[4], t);
918
+ break;
919
+ case "67":
920
+ t = n(this, i, at).call(this, e[4], t);
921
+ break;
922
+ }
923
+ break;
924
+ }
925
+ return t;
926
+ }, _ = function() {
927
+ this.__internal__.dispense.dispensing && (this.__internal__.dispense.status = !0);
928
+ }, l = function() {
929
+ this.__internal__.dispense.dispensing && (this.__internal__.dispense.status = !1);
930
+ }, m = function() {
931
+ this.__internal__.dispense.dispensing && (this.__internal__.dispense.status = "elevator-locked");
932
+ }, /**
933
+ * Dispatch a warning message
934
+ * @param {null|string} type
935
+ * @param {string} severity
936
+ */
937
+ d = function({ type: e = null, severity: t = "low" } = {}) {
938
+ this.dispatch("jofemar:warning", { type: e, severity: t });
939
+ }, /**
940
+ * Dispatch an error message
941
+ * @param {null|string} type
942
+ * @param {string} severity
943
+ */
944
+ f = function({ type: e = null, severity: t = "high" } = {}) {
945
+ this.dispatch("jofemar:error", { type: e, severity: t });
946
+ }, lt = function(e, t) {
947
+ if (t.request = "status", e[1] && !e[2]) {
948
+ switch (e[1]) {
949
+ case "30":
950
+ t.name = "Machine ready", t.description = "The machine is ready for instructions", t.no_code = 9, n(this, i, _).call(this);
951
+ break;
952
+ case "31":
953
+ t.name = "Machine busy", t.description = "The machine is busy right now", t.no_code = 10;
954
+ break;
955
+ case "32":
956
+ t.name = "Invalid tray", t.description = "The tray requested is invalid", t.no_code = 11, n(this, i, l).call(this), n(this, i, d).call(this, { type: "invalid-tray" });
957
+ break;
958
+ case "33":
959
+ t.name = "Invalid channel", t.description = "The channel requested is invalid", t.no_code = 12, n(this, i, l).call(this), n(this, i, d).call(this, { type: "invalid-channel" });
960
+ break;
961
+ case "34":
962
+ t.name = "Empty channel", t.description = "The channel requested is empty", t.no_code = 13, n(this, i, l).call(this), n(this, i, d).call(this, { type: "empty-channel" });
963
+ break;
964
+ case "35":
965
+ t.name = "Jam", t.description = "Jam in elevator engine", t.no_code = 14, n(this, i, l).call(this), n(this, i, f).call(this, { type: "jam" });
966
+ break;
967
+ case "36":
968
+ t.name = "Malfunction", t.description = "Malfunction in the elevator belt or product detector", t.no_code = 15, n(this, i, l).call(this), n(this, i, f).call(this, { type: "malfunction" });
969
+ break;
970
+ case "37":
971
+ t.name = "Photo transistors", t.description = "Failure in one of the photo transistors in the cabinet", t.no_code = 16, n(this, i, l).call(this), n(this, i, f).call(this, { type: "photo-transistors" });
972
+ break;
973
+ case "38":
974
+ t.name = "Without channels", t.description = "No channels detected", t.no_code = 17, n(this, i, l).call(this), n(this, i, f).call(this, { type: "without-channels" });
975
+ break;
976
+ case "39":
977
+ t.name = "Product detector fault", t.description = "Product detector fault", t.no_code = 18, n(this, i, m).call(this), n(this, i, d).call(this, { type: "fault-product-detector" });
978
+ break;
979
+ case "41":
980
+ t.name = "Fault in 485 BUS", t.description = "Machine display is disconnected", t.no_code = 19, n(this, i, _).call(this), n(this, i, d).call(this, { type: "display-disconnected" });
981
+ break;
982
+ case "42":
983
+ t.name = "Product under elevator", t.description = "Product alarm under elevator", t.no_code = 20, n(this, i, l).call(this), n(this, i, d).call(this, { type: "product-under-elevator" });
984
+ break;
985
+ case "43":
986
+ t.name = "Error when elevator approaching to a position", t.description = "Error when elevator approaching to a position", t.no_code = 21, n(this, i, _).call(this), n(this, i, d).call(this, { type: "error-approaching-position", severity: "high" });
987
+ break;
988
+ case "44":
989
+ t.name = "Fault in keyboard", t.description = "Fault in keyboard", t.no_code = 22, n(this, i, l).call(this), n(this, i, f).call(this, { type: "fault-keyboard" });
990
+ break;
991
+ case "45":
992
+ t.name = "Eeprom writing error", t.description = "Eeprom writing error", t.no_code = 23, n(this, i, l).call(this), n(this, i, f).call(this, { type: "eeprom-writing-error", severity: "critical" });
993
+ break;
994
+ case "46":
995
+ t.name = "Fault communicating with temperature control", t.description = "Fault communicating with temperature control", t.no_code = 24, n(this, i, _).call(this), n(this, i, d).call(this, { type: "fault-temperature-control" });
996
+ break;
997
+ case "47":
998
+ t.name = "Thermometer disconnected", t.description = "The thermometer is disconnected", t.no_code = 25, n(this, i, _).call(this), n(this, i, d).call(this, { type: "thermometer-disconnected" });
999
+ break;
1000
+ case "48":
1001
+ t.name = "Thermometer programming lost", t.description = "Thermometer programming lost", t.no_code = 26, n(this, i, _).call(this), n(this, i, d).call(this, { type: "thermometer-programming-lost" });
1002
+ break;
1003
+ case "49":
1004
+ t.name = "Thermometer faulty", t.description = "Thermometer faulty", t.no_code = 27, n(this, i, _).call(this), n(this, i, d).call(this, { type: "thermometer-faulty" });
1005
+ break;
1006
+ case "4a":
1007
+ t.name = "Channels power consumption detector faulty", t.description = "Channels power consumption detector faulty", t.no_code = 28, n(this, i, l).call(this), n(this, i, f).call(this, { type: "channels-power-consumption-detector-faulty", severity: "critical" });
1008
+ break;
1009
+ case "4b":
1010
+ t.name = "Elevator does not find channel or tray", t.description = "Elevator does not find channel or tray", t.no_code = 29, n(this, i, l).call(this), n(this, i, d).call(this, { type: "elevator-not-find-channel-tray" });
1011
+ break;
1012
+ case "4c":
1013
+ t.name = "Elevator does not find delivery product position", t.description = "Elevator does not find delivery product position", t.no_code = 30, n(this, i, l).call(this), n(this, i, f).call(this, { type: "elevator-not-find-delivery-position" });
1014
+ break;
1015
+ case "4d":
1016
+ t.name = "Interior of elevator blocked", t.description = "Interior of elevator blocked", t.no_code = 31, n(this, i, m).call(this), this.__internal__.dispense.elevator.need_reset || (this.__internal__.dispense.elevator.need_reset = !0), n(this, i, f).call(this, { type: "interior-elevator-blocked", severity: "low" });
1017
+ break;
1018
+ case "4e":
1019
+ t.name = "Error in tester of product detector", t.description = "Error in tester of product detector", t.no_code = 32, n(this, i, l).call(this), n(this, i, f).call(this, { type: "error-tester-product-detector" });
1020
+ break;
1021
+ case "4f":
1022
+ t.name = "Waiting for product to be removed", t.description = "Waiting for product to be removed", t.no_code = 33, n(this, i, m).call(this);
1023
+ break;
1024
+ case "50":
1025
+ t.name = "Product expired by temperature reasons", t.description = "Product expired by temperature reasons", t.no_code = 34, n(this, i, _).call(this), n(this, i, d).call(this, { type: "product-expired-temperature" });
1026
+ break;
1027
+ case "51":
1028
+ t.name = "Automatic door faulty", t.description = "Automatic door faulty", t.no_code = 35, n(this, i, _).call(this), n(this, i, d).call(this, { type: "automatic-door-faulty" });
1029
+ break;
1030
+ case "59":
1031
+ case "5a":
1032
+ case "61":
1033
+ case "62":
1034
+ case "63":
1035
+ switch (t.name = "Product is expired", t.description = "Product is expired", t.additional = { nsf_alarm: 1 }, e[1]) {
1036
+ case "5a":
1037
+ t.additional.nsf_alarm = 2;
1038
+ break;
1039
+ case "61":
1040
+ t.additional.nsf_alarm = 3;
1041
+ break;
1042
+ case "62":
1043
+ t.additional.nsf_alarm = 4;
1044
+ break;
1045
+ case "63":
1046
+ t.additional.nsf_alarm = 5;
1047
+ break;
1048
+ }
1049
+ t.no_code = 36, n(this, i, _).call(this), n(this, i, d).call(this, { type: "product-expired" });
1050
+ break;
1051
+ case "64":
1052
+ t.name = "Product detector didn't change during its verification test", t.description = "Product detector didn't change during its verification test", t.no_code = 37, n(this, i, _).call(this), n(this, i, d).call(this, { type: "automatic-door-faulty" });
1053
+ break;
1054
+ }
1055
+ this.dispatch("machine:status", t);
1056
+ } else
1057
+ t.name = "executed", t.description = "The last command was executed successfully", t.no_code = 8, !e[1] && this.__internal__.dispense.dispensing && n(this, i, l).call(this);
1058
+ return t;
1059
+ }, dt = function(e) {
1060
+ if (e = parseInt(e) + 109, e = e.toString(), e.length !== 3)
1061
+ throw new Error("Invalid selection");
1062
+ const t = (parseInt(e.substring(0, 2)) + 128).toString(16).padStart(2, "0");
1063
+ return { channel: (parseInt(e.substring(2, 3)) + 128).toString(16).padStart(2, "0"), tray: t };
1064
+ }, pt = function() {
1065
+ this.__internal__.dispense.timeout && clearTimeout(this.__internal__.dispense.timeout), this.__internal__.dispense.interval && clearInterval(this.__internal__.dispense.interval), this.__internal__.dispense.timeout = 0, this.__internal__.dispense.interval = 0;
1066
+ }, ut = function() {
1067
+ this.__internal__.dispense.timeout && clearTimeout(this.__internal__.dispense.timeout), this.__internal__.dispense.interval && clearInterval(this.__internal__.dispense.interval);
1068
+ const e = this;
1069
+ e.__internal__.dispense.timeout = setTimeout(() => {
1070
+ e.__internal__.dispense.interval = setInterval(() => {
1071
+ e.status().then(() => {
1072
+ });
1073
+ }, e.__internal__.dispense.interval_time);
1074
+ }, e.__internal__.dispense.timeout_time);
1075
+ }, w = async function(e) {
1076
+ const t = ["02", "30", "30", "81", "52", e, "FF"];
1077
+ return await n(this, i, u).call(this, t, "reset");
1078
+ }, S = function() {
1079
+ const e = this.__device.type === "iceplus" ? B(40) : B(25), t = /* @__PURE__ */ new Date(), r = 1e3 * e + t.getTime(), a = new Date(r);
1080
+ this.dispatch("reset:errors", {
1081
+ description: "Resetting machine errors",
1082
+ duration: e,
1083
+ started_at: t,
1084
+ finished_at: a
1085
+ });
1086
+ }, M = async function(e) {
1087
+ const t = ["02", "30", "30", "81", "4C", e, "FF"];
1088
+ return await n(this, i, u).call(this, t, "lights");
1089
+ }, D = async function(e = "80", t = []) {
1090
+ const r = ["02", "30", "30", "81", "44", e, ...t];
1091
+ return await n(this, i, u).call(this, r, "display");
1092
+ }, I = function(e = "") {
1093
+ e = e.padEnd(32, " ");
1094
+ const t = [];
1095
+ for (let r = 0; r < 32; r++)
1096
+ t.push(e.charCodeAt(r).toString(16));
1097
+ return t;
1098
+ }, _t = function(e) {
1099
+ if (!(e instanceof Date)) throw new Error("Invalid date, must be an instance of Date");
1100
+ const t = e.getHours().toString().padStart(2, "0"), r = e.getMinutes().toString().padStart(2, "0"), a = e.getDate().toString().padStart(2, "0"), o = (e.getMonth() + 1).toString().padStart(2, "0"), c = e.getFullYear().toString().substring(2, 4), s = `${t}:${r} ${a}-${o}-${c}`, v = [];
1101
+ for (let y = 0; y < 14; y++)
1102
+ v.push(s.charCodeAt(y).toString(16));
1103
+ return v;
1104
+ };
1105
+ export {
1106
+ Tt as Jofemar
1107
+ };