@danidoble/webserial 4.2.4 → 4.2.6

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