@danidoble/webserial 4.3.3 → 4.3.5

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