@danidoble/webserial 4.4.0-beta.1 → 4.4.0-beta.3
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/boardroid.cjs +1 -1
- package/dist/boardroid.js +106 -101
- package/dist/hopper.cjs +2 -2
- package/dist/hopper.js +66 -51
- package/dist/jofemar.cjs +1 -1
- package/dist/jofemar.js +62 -144
- package/dist/kernel-C1HLYiV1.cjs +1 -0
- package/dist/kernel-C8ISUhzV.cjs +1 -0
- package/dist/kernel-CQcZ_OiG.js +831 -0
- package/dist/{kernel-505KqpPU.js → kernel-DkC7Kj3m.js} +151 -125
- package/dist/kernel-DtXV8d8B.js +831 -0
- package/dist/kernel-DyNuXvtW.cjs +1 -0
- package/dist/kernel-aqBCxtkj.js +831 -0
- package/dist/kernel-pO_elWba.cjs +1 -0
- package/dist/kernel.cjs +2 -2
- package/dist/kernel.d.ts +14 -0
- package/dist/kernel.d.ts.map +1 -0
- package/dist/kernel.js +3 -4
- package/dist/locker.cjs +1 -1
- package/dist/locker.js +33 -26
- package/dist/main.d.ts +28 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/pinpad.cjs +15 -20
- package/dist/pinpad.js +1405 -1259
- package/dist/pinpax.cjs +4 -4
- package/dist/pinpax.js +68 -68
- package/dist/{relay-CsdB0FSa.js → relay-DP8PLsDP.js} +2 -2
- package/dist/{relay-DGFymXOw.cjs → relay-E3NCcSjS.cjs} +1 -1
- package/dist/relay.cjs +1 -1
- package/dist/relay.js +11 -29
- package/dist/serial/boardroid.d.ts +206 -0
- package/dist/serial/boardroid.d.ts.map +1 -0
- package/dist/serial/hopper.d.ts +85 -0
- package/dist/serial/hopper.d.ts.map +1 -0
- package/dist/serial/jofemar.d.ts +218 -0
- package/dist/serial/jofemar.d.ts.map +1 -0
- package/dist/serial/kernel.d.ts +137 -0
- package/dist/serial/kernel.d.ts.map +1 -0
- package/dist/serial/locker.d.ts +33 -0
- package/dist/serial/locker.d.ts.map +1 -0
- package/dist/serial/pinpad.d.ts +263 -0
- package/dist/serial/pinpad.d.ts.map +1 -0
- package/dist/serial/pinpax.d.ts +60 -0
- package/dist/serial/pinpax.d.ts.map +1 -0
- package/dist/serial/relay.d.ts +13 -0
- package/dist/serial/relay.d.ts.map +1 -0
- package/dist/utils/devices.d.ts +26 -0
- package/dist/utils/devices.d.ts.map +1 -0
- package/dist/utils/dispatcher.d.ts +17 -0
- package/dist/utils/dispatcher.d.ts.map +1 -0
- package/dist/utils/emulator.d.ts +80 -0
- package/dist/utils/emulator.d.ts.map +1 -0
- package/dist/utils/utils.d.ts +7 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/{webserial-core-C0ZbaNYy.js → webserial-core-CH2Xov2y.js} +943 -933
- package/dist/webserial-core-Cj_EZjAU.cjs +4 -0
- package/dist/webserial-core-D3luFguv.js +3325 -0
- package/dist/webserial-core-YjdXyVOx.cjs +4 -0
- package/dist/webserial.cjs +2 -2
- package/dist/webserial.js +19 -19
- package/package.json +17 -14
- package/dist/kernel-Dq3Fv1y8.cjs +0 -1
- package/dist/webserial-core-B7vfLzGH.cjs +0 -4
package/dist/jofemar.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import { K as C, w as u, g as
|
|
2
|
-
import { o as i } from "./relay-
|
|
3
|
-
|
|
4
|
-
class b extends C {
|
|
1
|
+
import { K as C, D as f, w as u, g as y } from "./kernel-DtXV8d8B.js";
|
|
2
|
+
import { o as i } from "./relay-DP8PLsDP.js";
|
|
3
|
+
class w extends C {
|
|
5
4
|
__device = {
|
|
6
5
|
type: "esplus",
|
|
7
6
|
support_cart: !1,
|
|
@@ -29,20 +28,20 @@ class b extends C {
|
|
|
29
28
|
};
|
|
30
29
|
constructor({
|
|
31
30
|
filters: t = null,
|
|
32
|
-
config_port: e
|
|
31
|
+
config_port: e,
|
|
33
32
|
no_device: n = 1,
|
|
34
|
-
|
|
33
|
+
device_listen_on_channel: r = 1,
|
|
35
34
|
type: a = "esplus",
|
|
36
35
|
support_cart: o = !0,
|
|
37
36
|
socket: c = !1
|
|
38
37
|
} = {}) {
|
|
39
|
-
if (super({ filters: t, config_port: e, no_device: n,
|
|
38
|
+
if (super({ filters: t, config_port: e, no_device: n, device_listen_on_channel: r, socket: c }), this.__internal__.device.type = "jofemar", f.getCustom(this.typeDevice, n))
|
|
40
39
|
throw new Error(`Device ${this.typeDevice} ${n} already exists`);
|
|
41
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 = {
|
|
42
41
|
locking_time: 60,
|
|
43
42
|
locking_interval: 0,
|
|
44
43
|
need_reset: !1
|
|
45
|
-
}, this.deviceType = a, this.supportCart = o, this.#h(),
|
|
44
|
+
}, this.deviceType = a, this.supportCart = o, this.#h(), f.add(this), this.#l();
|
|
46
45
|
}
|
|
47
46
|
set startChannelVerification(t) {
|
|
48
47
|
const e = parseInt(t);
|
|
@@ -119,21 +118,19 @@ class b extends C {
|
|
|
119
118
|
return i.connection({ channel: t });
|
|
120
119
|
}
|
|
121
120
|
async #s() {
|
|
122
|
-
if (this.__internal__.dispense.elevator.locking_interval)
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
#d(t, e) {
|
|
136
|
-
return e.name = "ok", e.description = "The last command was executed successfully", e.no_code = 1, this.dispatch("command-executed", e), e;
|
|
121
|
+
if (!this.__internal__.dispense.elevator.locking_interval)
|
|
122
|
+
return this.__internal__.dispense.elevator.need_reset && (this.__internal__.dispense.elevator.need_reset = !1, await this.resetWaitingProductRemovedError(), await u(500)), this.__internal__.dispense.status = "elevator-locked", this.__internal__.dispense.elevator.locking_time = 60, new Promise((t) => {
|
|
123
|
+
this.__internal__.dispense.elevator.locking_interval = setInterval(() => {
|
|
124
|
+
this.dispatch("dispensing:withdrawal", {
|
|
125
|
+
elevator: !0,
|
|
126
|
+
seconds: this.__internal__.dispense.elevator.locking_time,
|
|
127
|
+
description: "Please recall products from the elevator"
|
|
128
|
+
}), this.__internal__.dispense.elevator.locking_time -= 1, this.__internal__.dispense.elevator.locking_time <= 0 && (clearInterval(this.__internal__.dispense.elevator.locking_interval), this.__internal__.dispense.elevator.locking_interval = 0, t(!0));
|
|
129
|
+
}, 1e3);
|
|
130
|
+
});
|
|
131
|
+
}
|
|
132
|
+
#d(t) {
|
|
133
|
+
return t.name = "ok", t.description = "The last command was executed successfully", t.no_code = 1, this.dispatch("command-executed", t), t;
|
|
137
134
|
}
|
|
138
135
|
#p(t, e) {
|
|
139
136
|
e.additional = {
|
|
@@ -158,8 +155,8 @@ class b extends C {
|
|
|
158
155
|
42: "B",
|
|
159
156
|
43: "C",
|
|
160
157
|
44: "D"
|
|
161
|
-
};
|
|
162
|
-
return e.additional.ascii = n[
|
|
158
|
+
}, r = t.toString().toLowerCase();
|
|
159
|
+
return e.additional.ascii = n[r] ?? 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;
|
|
163
160
|
}
|
|
164
161
|
#u(t, e) {
|
|
165
162
|
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;
|
|
@@ -217,7 +214,7 @@ class b extends C {
|
|
|
217
214
|
64: "Product detector didn't change during its verification test"
|
|
218
215
|
};
|
|
219
216
|
for (const a of n)
|
|
220
|
-
r[a] && (e.additional.faults.push(r[a]), e.additional.no_faults++);
|
|
217
|
+
r[a] && e.additional.faults && typeof e.additional.no_faults < "u" && (e.additional.faults.push(r[a] || "Unknown fault"), e.additional.no_faults++);
|
|
221
218
|
}
|
|
222
219
|
return this.dispatch("machine:faults", e.additional), e;
|
|
223
220
|
}
|
|
@@ -273,7 +270,7 @@ class b extends C {
|
|
|
273
270
|
channel: h,
|
|
274
271
|
selection: h - 109,
|
|
275
272
|
ascii: n,
|
|
276
|
-
meaning: l[n]
|
|
273
|
+
meaning: l[n] || "Unknown"
|
|
277
274
|
};
|
|
278
275
|
} else if (r.length === 13) {
|
|
279
276
|
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), _ = {
|
|
@@ -300,7 +297,7 @@ class b extends C {
|
|
|
300
297
|
hex: r,
|
|
301
298
|
formatted: p.toLocaleString(),
|
|
302
299
|
ascii: n,
|
|
303
|
-
meaning: _[n]
|
|
300
|
+
meaning: _[n] || "Unknown"
|
|
304
301
|
};
|
|
305
302
|
}
|
|
306
303
|
}
|
|
@@ -312,9 +309,9 @@ class b extends C {
|
|
|
312
309
|
31: "English",
|
|
313
310
|
32: "French"
|
|
314
311
|
};
|
|
315
|
-
return e.no_code = 42, e.name = "Language", e.description = `The language is ${n[t]
|
|
312
|
+
return e.no_code = 42, e.name = "Language", e.description = `The language is ${n[t] || "unknown"}`, e.additional = {
|
|
316
313
|
hex: t,
|
|
317
|
-
language: n[t]
|
|
314
|
+
language: n[t] || "unknown"
|
|
318
315
|
}, this.dispatch("check:language", e.additional), e;
|
|
319
316
|
}
|
|
320
317
|
#k(t, e) {
|
|
@@ -437,8 +434,8 @@ class b extends C {
|
|
|
437
434
|
}, 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;
|
|
438
435
|
}
|
|
439
436
|
#B(t, e, n = 128) {
|
|
440
|
-
if (t[1] && (e.additional.machine.hex = t[1], e.additional.machine.dec = this.hexToDec(t[1]) - n), !(t[1] && t[2]))
|
|
441
|
-
e = this.#d(
|
|
437
|
+
if (t[1] && (e.additional.machine || (e.additional.machine = { hex: null, dec: null }), e.additional.machine.hex = t[1], e.additional.machine.dec = this.hexToDec(t[1]) - n), !(t[1] && t[2]))
|
|
438
|
+
e = this.#d(e);
|
|
442
439
|
else
|
|
443
440
|
switch (t[2]) {
|
|
444
441
|
case "54":
|
|
@@ -526,20 +523,16 @@ class b extends C {
|
|
|
526
523
|
#a() {
|
|
527
524
|
this.__internal__.dispense.dispensing && (this.__internal__.dispense.status = "elevator-locked");
|
|
528
525
|
}
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
*/
|
|
534
|
-
#t({ type: t = null, severity: e = "low" } = {}) {
|
|
526
|
+
#t({
|
|
527
|
+
type: t = null,
|
|
528
|
+
severity: e = "low"
|
|
529
|
+
} = {}) {
|
|
535
530
|
this.dispatch("jofemar:warning", { type: t, severity: e });
|
|
536
531
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
*/
|
|
542
|
-
#i({ type: t = null, severity: e = "high" } = {}) {
|
|
532
|
+
#i({
|
|
533
|
+
type: t = null,
|
|
534
|
+
severity: e = "high"
|
|
535
|
+
} = {}) {
|
|
543
536
|
this.dispatch("jofemar:error", { type: t, severity: e });
|
|
544
537
|
}
|
|
545
538
|
#W(t, e) {
|
|
@@ -657,6 +650,8 @@ class b extends C {
|
|
|
657
650
|
return e;
|
|
658
651
|
}
|
|
659
652
|
serialMessage(t) {
|
|
653
|
+
t = this.fixHexArray(t);
|
|
654
|
+
const e = 128;
|
|
660
655
|
let n = {
|
|
661
656
|
code: t,
|
|
662
657
|
name: null,
|
|
@@ -672,7 +667,7 @@ class b extends C {
|
|
|
672
667
|
};
|
|
673
668
|
switch (t[0]) {
|
|
674
669
|
case "02":
|
|
675
|
-
n = this.#B(t, n,
|
|
670
|
+
n = this.#B(t, n, e);
|
|
676
671
|
break;
|
|
677
672
|
case "06":
|
|
678
673
|
n = this.#W(t, n);
|
|
@@ -689,12 +684,6 @@ class b extends C {
|
|
|
689
684
|
productRemovedContinueDispensing() {
|
|
690
685
|
this.__internal__.dispense.elevator.locking_interval && (this.__internal__.dispense.elevator.locking_time = 0);
|
|
691
686
|
}
|
|
692
|
-
/**
|
|
693
|
-
* Dispense a product from the machine
|
|
694
|
-
* @param {null|number|string} selection
|
|
695
|
-
* @param {boolean} cart
|
|
696
|
-
* @return {Promise<unknown>}
|
|
697
|
-
*/
|
|
698
687
|
async dispense({ selection: t = 1, cart: e = !1 } = {}) {
|
|
699
688
|
const n = i.dispense({ selection: t, cart: e, machineChannel: this.listenOnChannel }), r = n[5], a = n[6];
|
|
700
689
|
this.__internal__.dispense.backup_dispense = {
|
|
@@ -706,24 +695,22 @@ class b extends C {
|
|
|
706
695
|
let o;
|
|
707
696
|
do
|
|
708
697
|
o = await this.internalDispense(n), this.#F(), o.error === "elevator-locked" ? await this.#s() : o.error === "no-response" && await u(1e3);
|
|
709
|
-
while (["elevator-locked", "no-response"].includes(o.error));
|
|
698
|
+
while (["elevator-locked", "no-response"].includes(o.error || ""));
|
|
710
699
|
return this.__internal__.dispense.backup_dispense = {}, o;
|
|
711
700
|
}
|
|
712
701
|
#F() {
|
|
713
702
|
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;
|
|
714
703
|
}
|
|
715
704
|
#q() {
|
|
716
|
-
this.__internal__.dispense.timeout && clearTimeout(this.__internal__.dispense.timeout), this.__internal__.dispense.interval && clearInterval(this.__internal__.dispense.interval)
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
t.__internal__.dispense.interval = setInterval(() => {
|
|
720
|
-
t.status().then(() => {
|
|
705
|
+
this.__internal__.dispense.timeout && clearTimeout(this.__internal__.dispense.timeout), this.__internal__.dispense.interval && clearInterval(this.__internal__.dispense.interval), this.__internal__.dispense.timeout = setTimeout(() => {
|
|
706
|
+
this.__internal__.dispense.interval = setInterval(() => {
|
|
707
|
+
this.status().then(() => {
|
|
721
708
|
});
|
|
722
|
-
},
|
|
723
|
-
},
|
|
709
|
+
}, this.__internal__.dispense.interval_time);
|
|
710
|
+
}, this.__internal__.dispense.timeout_time);
|
|
724
711
|
}
|
|
725
712
|
internalClearSensing() {
|
|
726
|
-
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.
|
|
713
|
+
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.action !== "status"));
|
|
727
714
|
}
|
|
728
715
|
async endDispense() {
|
|
729
716
|
const t = i.endCartDispense({ machineChannel: this.listenOnChannel });
|
|
@@ -755,7 +742,7 @@ class b extends C {
|
|
|
755
742
|
});
|
|
756
743
|
}
|
|
757
744
|
#o() {
|
|
758
|
-
const t = this.__device.type === "iceplus" ?
|
|
745
|
+
const t = this.__device.type === "iceplus" ? y(40) : y(25), e = /* @__PURE__ */ new Date(), n = 1e3 * t + e.getTime(), r = new Date(n);
|
|
759
746
|
this.dispatch("reset:errors", {
|
|
760
747
|
description: "Resetting machine errors",
|
|
761
748
|
duration: t,
|
|
@@ -764,7 +751,7 @@ class b extends C {
|
|
|
764
751
|
});
|
|
765
752
|
}
|
|
766
753
|
async resetAllErrors() {
|
|
767
|
-
return await this.
|
|
754
|
+
return await this.resetWaitingProductRemovedError(), await u(200), await this.resetSoldOutErrors(), await u(400), await this.resetMachineErrors();
|
|
768
755
|
}
|
|
769
756
|
async status() {
|
|
770
757
|
return await this.appendToQueue(i.status({ machineChannel: this.listenOnChannel }), "status");
|
|
@@ -794,7 +781,9 @@ class b extends C {
|
|
|
794
781
|
"program"
|
|
795
782
|
);
|
|
796
783
|
}
|
|
797
|
-
async programDisplayLanguage({
|
|
784
|
+
async programDisplayLanguage({
|
|
785
|
+
language: t = "spanish"
|
|
786
|
+
} = {}) {
|
|
798
787
|
return await this.appendToQueue(
|
|
799
788
|
i.programDisplayLanguage({
|
|
800
789
|
machineChannel: this.listenOnChannel,
|
|
@@ -829,11 +818,6 @@ class b extends C {
|
|
|
829
818
|
"program"
|
|
830
819
|
);
|
|
831
820
|
}
|
|
832
|
-
/**
|
|
833
|
-
* Program the machine to work with a specific temperature
|
|
834
|
-
* @param {number|string} degrees
|
|
835
|
-
* @return {Promise<void>}
|
|
836
|
-
*/
|
|
837
821
|
async programWorkingTemperature({ degrees: t = 0.5 } = {}) {
|
|
838
822
|
return await this.appendToQueue(
|
|
839
823
|
i.programWorkingTemperature({
|
|
@@ -844,10 +828,6 @@ class b extends C {
|
|
|
844
828
|
"program"
|
|
845
829
|
);
|
|
846
830
|
}
|
|
847
|
-
/**
|
|
848
|
-
* @param {number|string} tray
|
|
849
|
-
* @return {Promise<void>}
|
|
850
|
-
*/
|
|
851
831
|
async programIsolationTray({ tray: t = 0 } = {}) {
|
|
852
832
|
return await this.appendToQueue(
|
|
853
833
|
i.programIsolationTray({
|
|
@@ -857,10 +837,6 @@ class b extends C {
|
|
|
857
837
|
"program"
|
|
858
838
|
);
|
|
859
839
|
}
|
|
860
|
-
/**
|
|
861
|
-
* @param {number|string} seconds
|
|
862
|
-
* @return {Promise<*>}
|
|
863
|
-
*/
|
|
864
840
|
async programTimeToStandbyAfterCollect({ seconds: t = 15 } = {}) {
|
|
865
841
|
return await this.appendToQueue(
|
|
866
842
|
i.programTimeToStandbyAfterCollect({
|
|
@@ -870,10 +846,6 @@ class b extends C {
|
|
|
870
846
|
"program"
|
|
871
847
|
);
|
|
872
848
|
}
|
|
873
|
-
/**
|
|
874
|
-
* @param {number|string} seconds
|
|
875
|
-
* @return {Promise<*>}
|
|
876
|
-
*/
|
|
877
849
|
async programTimeToStandbyWithoutCollect({ minutes: t = 1 } = {}) {
|
|
878
850
|
return await this.appendToQueue(
|
|
879
851
|
i.programTimeToStandbyWithoutCollect({
|
|
@@ -883,7 +855,9 @@ class b extends C {
|
|
|
883
855
|
"program"
|
|
884
856
|
);
|
|
885
857
|
}
|
|
886
|
-
async programElevatorSpeed({
|
|
858
|
+
async programElevatorSpeed({
|
|
859
|
+
speed: t = "high"
|
|
860
|
+
} = {}) {
|
|
887
861
|
return await this.appendToQueue(
|
|
888
862
|
i.programElevatorSpeed({
|
|
889
863
|
machineChannel: this.listenOnChannel,
|
|
@@ -907,10 +881,6 @@ class b extends C {
|
|
|
907
881
|
async programDisableTemperatureExpiration() {
|
|
908
882
|
return await this.programTemperatureExpiration({ enable: !1 });
|
|
909
883
|
}
|
|
910
|
-
/**
|
|
911
|
-
* @param {number|string} address
|
|
912
|
-
* @return {Promise<*>}
|
|
913
|
-
*/
|
|
914
884
|
async programMachineAddress({ address: t = 1 } = {}) {
|
|
915
885
|
return await this.appendToQueue(
|
|
916
886
|
i.programMachineAddress({
|
|
@@ -920,10 +890,6 @@ class b extends C {
|
|
|
920
890
|
"program"
|
|
921
891
|
);
|
|
922
892
|
}
|
|
923
|
-
/**
|
|
924
|
-
* @param {number|string} degrees
|
|
925
|
-
* @return {Promise<*>}
|
|
926
|
-
*/
|
|
927
893
|
async programTemperatureBeforeExpiration({ degrees: t = 0.5 } = {}) {
|
|
928
894
|
return await this.appendToQueue(
|
|
929
895
|
i.programTemperatureBeforeExpiration({
|
|
@@ -933,10 +899,6 @@ class b extends C {
|
|
|
933
899
|
"program"
|
|
934
900
|
);
|
|
935
901
|
}
|
|
936
|
-
/**
|
|
937
|
-
* @param {number|string} minutes
|
|
938
|
-
* @return {Promise<*>}
|
|
939
|
-
*/
|
|
940
902
|
async programTimeBeforeExpirationByTemperature({ minutes: t = 1 } = {}) {
|
|
941
903
|
return await this.appendToQueue(
|
|
942
904
|
i.programTimeBeforeExpirationByTemperature({
|
|
@@ -946,7 +908,9 @@ class b extends C {
|
|
|
946
908
|
"program"
|
|
947
909
|
);
|
|
948
910
|
}
|
|
949
|
-
async programTemperatureScale({
|
|
911
|
+
async programTemperatureScale({
|
|
912
|
+
scale: t = "celsius"
|
|
913
|
+
} = {}) {
|
|
950
914
|
return await this.appendToQueue(
|
|
951
915
|
i.programTemperatureScale({
|
|
952
916
|
machineChannel: this.listenOnChannel,
|
|
@@ -955,11 +919,6 @@ class b extends C {
|
|
|
955
919
|
"program"
|
|
956
920
|
);
|
|
957
921
|
}
|
|
958
|
-
/**
|
|
959
|
-
* @param {number|string} selection
|
|
960
|
-
* @param {number|string} voltage
|
|
961
|
-
* @return {Promise<void>}
|
|
962
|
-
*/
|
|
963
922
|
async programVoltageEngine({ selection: t = 1, voltage: e = 5 } = {}) {
|
|
964
923
|
return await this.appendToQueue(
|
|
965
924
|
i.programVoltageEngine({
|
|
@@ -970,11 +929,6 @@ class b extends C {
|
|
|
970
929
|
"voltage-engine"
|
|
971
930
|
);
|
|
972
931
|
}
|
|
973
|
-
/**
|
|
974
|
-
* @param {number|string} selection
|
|
975
|
-
* @param {boolean} enable
|
|
976
|
-
* @return {Promise<void>}
|
|
977
|
-
*/
|
|
978
932
|
async programPushOverProducts({ selection: t = 1, enable: e = !0 } = {}) {
|
|
979
933
|
return await this.appendToQueue(
|
|
980
934
|
i.programPushOverProducts({
|
|
@@ -985,11 +939,6 @@ class b extends C {
|
|
|
985
939
|
"push-over-products"
|
|
986
940
|
);
|
|
987
941
|
}
|
|
988
|
-
/**
|
|
989
|
-
* @param {number|string} selection
|
|
990
|
-
* @param {number|string} seconds
|
|
991
|
-
* @return {Promise<void>}
|
|
992
|
-
*/
|
|
993
942
|
async programChannelRunningAfterDispense({ selection: t = 1, seconds: e = 0 } = {}) {
|
|
994
943
|
return await this.appendToQueue(
|
|
995
944
|
i.programChannelRunningAfterDispense({
|
|
@@ -1000,7 +949,7 @@ class b extends C {
|
|
|
1000
949
|
"channel-running-after-dispense"
|
|
1001
950
|
);
|
|
1002
951
|
}
|
|
1003
|
-
async checkData(t, e =
|
|
952
|
+
async checkData(t, e = 255) {
|
|
1004
953
|
return await this.appendToQueue(
|
|
1005
954
|
i.checkData({
|
|
1006
955
|
machineChannel: this.listenOnChannel,
|
|
@@ -1106,10 +1055,6 @@ class b extends C {
|
|
|
1106
1055
|
"check-data"
|
|
1107
1056
|
);
|
|
1108
1057
|
}
|
|
1109
|
-
/**
|
|
1110
|
-
* @param {number|string} selection
|
|
1111
|
-
* @return {Promise<*>}
|
|
1112
|
-
*/
|
|
1113
1058
|
async getVoltageEngine({ selection: t = 1 } = {}) {
|
|
1114
1059
|
return await this.appendToQueue(
|
|
1115
1060
|
i.getVoltageEngine({
|
|
@@ -1119,10 +1064,6 @@ class b extends C {
|
|
|
1119
1064
|
"check-data"
|
|
1120
1065
|
);
|
|
1121
1066
|
}
|
|
1122
|
-
/**
|
|
1123
|
-
* @param {number|string} selection
|
|
1124
|
-
* @return {Promise<*>}
|
|
1125
|
-
*/
|
|
1126
1067
|
async getChannelPresence({ selection: t = 1 } = {}) {
|
|
1127
1068
|
return await this.appendToQueue(
|
|
1128
1069
|
i.getChannelPresence({
|
|
@@ -1132,10 +1073,6 @@ class b extends C {
|
|
|
1132
1073
|
"check-data"
|
|
1133
1074
|
);
|
|
1134
1075
|
}
|
|
1135
|
-
/**
|
|
1136
|
-
* @param {number|string} selection
|
|
1137
|
-
* @return {Promise<*>}
|
|
1138
|
-
*/
|
|
1139
1076
|
async getPushOverProducts({ selection: t = 1 } = {}) {
|
|
1140
1077
|
return await this.appendToQueue(
|
|
1141
1078
|
i.getPushOverProducts({
|
|
@@ -1145,10 +1082,6 @@ class b extends C {
|
|
|
1145
1082
|
"check-data"
|
|
1146
1083
|
);
|
|
1147
1084
|
}
|
|
1148
|
-
/**
|
|
1149
|
-
* @param {number|string} selection
|
|
1150
|
-
* @return {Promise<*>}
|
|
1151
|
-
*/
|
|
1152
1085
|
async getChannelRunningAfterDispense({ selection: t = 1 } = {}) {
|
|
1153
1086
|
return await this.appendToQueue(
|
|
1154
1087
|
i.getChannelRunningAfterDispense({
|
|
@@ -1167,11 +1100,6 @@ class b extends C {
|
|
|
1167
1100
|
"display"
|
|
1168
1101
|
);
|
|
1169
1102
|
}
|
|
1170
|
-
/**
|
|
1171
|
-
* @param {string} message
|
|
1172
|
-
* @param {number|string} seconds
|
|
1173
|
-
* @return {Promise<void>}
|
|
1174
|
-
*/
|
|
1175
1103
|
async setDisplayMessageTemporarily({ message: t = "", seconds: e = 1 }) {
|
|
1176
1104
|
return this.appendToQueue(
|
|
1177
1105
|
i.setDisplayMessageTemporarily({
|
|
@@ -1182,10 +1110,6 @@ class b extends C {
|
|
|
1182
1110
|
"display"
|
|
1183
1111
|
);
|
|
1184
1112
|
}
|
|
1185
|
-
/**
|
|
1186
|
-
* @param {string} message
|
|
1187
|
-
* @return {Promise<void>}
|
|
1188
|
-
*/
|
|
1189
1113
|
async setDisplayMessageUnlimited({ message: t = "" }) {
|
|
1190
1114
|
return await this.appendToQueue(
|
|
1191
1115
|
i.setDisplayMessageUnlimited({
|
|
@@ -1204,11 +1128,6 @@ class b extends C {
|
|
|
1204
1128
|
"clock"
|
|
1205
1129
|
);
|
|
1206
1130
|
}
|
|
1207
|
-
/**
|
|
1208
|
-
* @param {null|string} event
|
|
1209
|
-
* @param {boolean} enable
|
|
1210
|
-
* @return {Promise<void>}
|
|
1211
|
-
*/
|
|
1212
1131
|
async eventsConfig({ event: t = null, enable: e = !0 } = {}) {
|
|
1213
1132
|
return await this.appendToQueue(
|
|
1214
1133
|
i.eventsConfig({
|
|
@@ -1237,10 +1156,9 @@ class b extends C {
|
|
|
1237
1156
|
"events-config"
|
|
1238
1157
|
);
|
|
1239
1158
|
}
|
|
1240
|
-
async sendCustomCode({ code: t = [] } = {}) {
|
|
1159
|
+
async sendCustomCode({ code: t = [] } = { code: [] }) {
|
|
1241
1160
|
return await this.appendToQueue(
|
|
1242
1161
|
i.sendCustomCode({
|
|
1243
|
-
machineChannel: this.listenOnChannel,
|
|
1244
1162
|
code: t
|
|
1245
1163
|
}),
|
|
1246
1164
|
"custom"
|
|
@@ -1253,12 +1171,12 @@ class b extends C {
|
|
|
1253
1171
|
for (let n = t; n <= e; n++)
|
|
1254
1172
|
this.__device.channels.verification.current = n, await this.getChannelPresence({ selection: n });
|
|
1255
1173
|
return new Promise((n) => {
|
|
1256
|
-
|
|
1174
|
+
const r = setInterval(() => {
|
|
1257
1175
|
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));
|
|
1258
1176
|
}, 500);
|
|
1259
1177
|
});
|
|
1260
1178
|
}
|
|
1261
1179
|
}
|
|
1262
1180
|
export {
|
|
1263
|
-
|
|
1181
|
+
w as Jofemar
|
|
1264
1182
|
};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=require("./webserial-core-YjdXyVOx.cjs");function u(o=100){return new Promise(n=>setTimeout(()=>n(),o))}function b(){return"serial"in navigator}function g(){return"geolocation"in navigator}function k(){return"crypto"in window}function y(o=1){return o*1e3}function w(o){return o==null||o===""}class e{static enable=!1;static instance=null;static#i=null;static#r=1;static#d(){if(e.enable===!1)throw new Error("Emulator is disabled");return e.enable}static#o(n){return e.instance=n,e.#i=n.typeDevice,e.#r=n.deviceNumber,!0}static#n(n=null){return!e.#d()||n===null&&e.instance===null?!1:(e.instance===null&&n!==null&&e.#o(n),!0)}static#l(){if(e.#i!=="locker")throw new Error("This function is only available for Locker devices");return!0}static#s(){if(e.#i!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0}static#t(){if(e.#i!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0}static#c(){if(e.#i==="locker")throw new Error("This function is not available for Locker devices");return!0}static#e(n){e.instance!==null&&e.instance.__emulate({code:n})}static status(n=null){if(!e.#n(n))return!1;let t=[];switch(e.#i){case"locker":t=["0","8"];break;case"boardroid":t=["2",(5+e.#r).toString(16).toUpperCase()];break;case"jofemar":t=["6"];break;default:return!1}e.#e(t)}static dispensed(n=null){if(!e.#n(n))return!1;let t=[];switch(e.#i){case"locker":t=["0","7","4","4","4"];break;case"boardroid":t=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","30"];break;default:return!1}e.#e(t)}static notDispensed(n=null){if(!e.#n(n))return!1;let t=[];switch(e.#i){case"locker":t=["0","7","5","5","5"];break;case"boardroid":t=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":t=["6","34"];break;default:return!1}e.#e(t)}static gateInactive(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","7","5","5","5"])}static gateConfigured(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","6"])}static keyPressed(n=null){if(!e.#n(n)||!e.#t())return!1;const t=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],s=(128+e.#r).toString(16),i=Math.floor(Math.random()*15);e.#e(["2",s,"54",t[i]])}static doorOpened(n=null){if(!e.#n(n)||!this.#c())return!1;let t=[];const s=(128+e.#r).toString(16);switch(e.#i){case"boardroid":t=["2","D8","dc"];break;case"jofemar":t=["2",s,"50","4F"];break}e.#e(t)}static doorClosed(n=null){if(!e.#n(n)||!this.#c())return!1;let t=[];const s=(128+e.#r).toString(16);switch(e.#i){case"boardroid":t=["2","D8","db"];break;case"jofemar":t=["2",s,"50","43"];break}e.#e(t)}static channelDisconnected(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","43","43","FD"])}static channelConnected(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","43","43","FC"])}static channelEmpty(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","43","43","FF"])}static workingTemperature(n=null){if(!e.#n(n)||!e.#t())return!1;const t=(128+e.#r).toString(16);e.#e(["2",t,"43","54","16"])}static currentTemperature(n=null){if(!e.#n(n)||!e.#c())return!1;let t=[];const s=(128+e.#r).toString(16);switch(e.#i){case"boardroid":t=["2","D9","44","30"];break;case"jofemar":t=["2",s,"43","74","2B","30","39","2E","31","7F","43"];break}e.#e(t)}static ready(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","30"])}static busy(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","31"])}static invalidTray(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","32"])}static invalidChannel(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","33"])}static emptyChannel(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","34"])}static elevatorJam(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","35"])}static elevatorMalfunction(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","36"])}static phototransistorFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","37"])}static allChannelsEmpty(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","38"])}static productDetectorFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","39"])}static displayDisconnected(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","41"])}static productUnderElevator(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","42"])}static elevatorSettingAlarm(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","43"])}static buttonPanelFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","44"])}static errorWritingEeprom(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","45"])}static errorControlTemperature(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","46"])}static thermometerDisconnected(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","47"])}static thermometerMisconfigured(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","48"])}static thermometerFailure(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","49"])}static errorExtractorConsumption(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4A"])}static channelSearchError(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4B"])}static productExitMouthSearchError(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4C"])}static elevatorInteriorLocked(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4D"])}static productDetectorVerifierError(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4E"])}static waitingForProductRecall(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4F"])}static productExpiredByTemperature(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","50"])}static faultyAutomaticDoor(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","51"])}static rejectLever(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","A0","1"])}static resetCoinPurse(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","A0","2"])}static#f(n,t=null){let s=n[Math.floor(Math.random()*5)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"0.5":s=n[1];break;case"1":s=n[2];break;case"2":s=n[3];break;case"5":s=n[4];break;case"10":s=n[5];break}return s}static coinInsertedBox(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["40","41","42","43","44","45"],i=e.#f(s,t);e.#e(["2","A0",i])}static coinInsertedTube(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["50","51","52","53","54","55"],i=e.#f(s,t);e.#e(["2","A0",i])}static#a(n,t=null){let s=n[Math.floor(Math.random()*4)];if(t!==null&&!isNaN(parseFloat(t)))switch(t.toString()){case"20":s=n[0];break;case"50":s=n[1];break;case"100":s=n[2];break;case"200":s=n[3];break;case"500":s=n[4];break}return s}static banknoteInsertedStacker(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["80","81","82","83","84"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteInsertedEscrow(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["90","91","92","93","94"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteEjected(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["A0","A1","A2","A3","A4"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteInsertedRecycler(n=null,t=null){if(!e.#n(n)||!e.#s())return!1;const s=["B0","B1","B2","B3","B4"],i=e.#a(s,t);e.#e(["2","B0",i])}static banknoteTaken(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","B0","2a"])}static coinPurseEnabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D0","1"])}static coinPurseDisabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D0","0"])}static billPurseDisabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D1","0","0"])}static billPurseEnabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D1","1","1"])}static readTubes(n=null){if(!e.#n(n)||!e.#s())return!1;const t=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[s,i,a,c,l,f]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)]];e.#e(["2","D2",s,i,a,c,l,f])}static readBillPurse(n=null,t=null){if(!e.#n(n)||!e.#s()||e.instance===null)return!1;const s=e.instance,i=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(s.__banknote_purse.recycler.ict){const a=i[Math.floor(Math.random()*31)];let c="0",l="0",f="0",d="0",h="0";if(t!==null&&!isNaN(parseInt(t)))switch(t.toString()){case"20":c=a;break;case"50":l=a;break;case"100":f=a;break;case"200":d=a;break;case"500":h=a;break}else switch(s.__banknote_purse.recycler.banknote){case 0:c=a;break;case 1:l=a;break;case 2:f=a;break;case 3:d=a;break;case 4:h=a;break}e.#e(["2","D3",c,l,f,d,h,"0"])}else{const[a,c,l,f,d,h]=[i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*2)],i[Math.floor(Math.random())],i[Math.floor(Math.random())]];e.#e(["2","D3",a,c,l,f,d,h])}}static banknoteAccepted(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D4","1"])}static banknoteRejected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D4","0"])}static banknotesDispensed(n=null){if(!e.#n(n)||!e.#s()||e.instance===null)return!1;const t=e.instance,s=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(t.__banknote_purse.recycler.ict){const i=s[Math.floor(Math.random()*30)];let a="0",c="0",l="0",f="0",d="0";switch(t.__banknote_purse.recycler.banknote){case 0:a=i;break;case 1:c=i;break;case 2:l=i;break;case 3:f=i;break;case 4:d=i;break}e.#e(["2","D5",a,c,l,f,d,"0"])}else{const[i,a,c,l,f,d]=[s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*2)],s[Math.floor(Math.random())],s[Math.floor(Math.random())]];e.#e(["2","D5",i,a,c,l,f,d])}}static coinsDispensed(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","D6"])}static relayOn(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DA","1"])}static relayOff(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DA","0"])}static nayaxEnabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","1"])}static nayaxDisabled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","3"])}static nayaxCancelRequest(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","4"])}static nayaxSellApproved(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","5"])}static nayaxSellDenied(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","6"])}static nayaxEndSession(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","7"])}static nayaxCancelled(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","8"])}static nayaxDispensed(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","A","0"])}static nayaxNotDispensed(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["2","DD","A","1"])}static fullTray(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["6","4F"])}static setConnection(n=null){if(!e.#n(n)||e.instance===null)return!1;e.instance.__internal__.serial.connected=!0}}class r extends p.a{constructor(){super(),r.registerType("boardroid"),r.registerType("hopper"),r.registerType("jofemar"),r.registerType("locker"),r.registerType("pinpad"),r.registerType("pinpax"),r.registerType("relay")}static addCustom(n,t){r.registerType(n),r.add(t)}static getCustomByUuid(n,t){return r.get(n,t)}static getJofemarByUuid(n){return r.get("jofemar",n)}static getLockerByUuid(n){return r.get("locker",n)}static getRelayByUuid(n){return r.get("relay",n)}static getBoardroidByUuid(n){return r.get("boardroid",n)}static getPinPadByUuid(n){return r.get("pinpad",n)}static getPinPaxByUuid(n){return r.get("pinpax",n)}static getHopperByUuid(n){return r.get("hopper",n)}static getJofemar(n=1){return r.getByNumber("jofemar",n)}static getBoardroid(n=1){return r.getByNumber("boardroid",n)}static getLocker(n=1){return r.getByNumber("locker",n)}static getRelay(n=1){return r.getByNumber("relay",n)}static getPinPad(n=1){return r.getByNumber("pinpad",n)}static getPinPax(n=1){return r.getByNumber("pinpax",n)}static getHopper(n=1){return r.getByNumber("hopper",n)}}r.instance=new r;class M extends p.ut{constructor(n={}){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,t){await super.timeout(n,t),t==="dispense"&&(this.__internal__.dispense.status="no-response")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){return this.__internal__.dispense.must_response&&(await u(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response")?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"}):(this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{}),new Promise(n=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(this.__internal__.dispense.status){case null:this.internalDispensingProcess()===!1&&(this.internalClearSensing(),this.dispatch("not-dispensed",{reason:"timeout"}),n({status:!1,error:"timeout"}));break;case!0:this.internalClearSensing(),this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),n({status:!0,error:null});break;case!1:this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-stock"}),n({status:!1,error:null});break;case"elevator-locked":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"elevator-locked"}),n({status:!1,error:"elevator-locked"});break;case"no-response":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),n({status:!1,error:"no-response"});break}},this.__internal__.time.sense)}))}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(this.__internal__.dispense.dispensing=!0,!e.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw this.__internal__.dispense.dispensing=!1,new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(t=>{const s=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(s),await this.appendToQueue(n,"dispense");const i=await this.internalDispenseStatus();t(i)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),r.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const t=[];for(const s in n.code)t.push(n.code[s].toString().padStart(2,"0").toLowerCase());this.serialMessage(t)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}fixHexArray(n){return n.map(t=>typeof t=="string"?t.padStart(2,"0").toLowerCase():t.toString(16).padStart(2,"0").toLowerCase())}}exports.Devices=r;exports.Emulator=e;exports.Kernel=M;exports.getSeconds=y;exports.isEmpty=w;exports.supportCrypto=k;exports.supportGeolocation=g;exports.supportWebSerial=b;exports.wait=u;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"use strict";const p=require("./webserial-core-Cj_EZjAU.cjs");function u(o=100){return new Promise(n=>setTimeout(()=>n(),o))}function b(){return"serial"in navigator}function g(){return"geolocation"in navigator}function k(){return"crypto"in window}function y(o=1){return o*1e3}function w(o){return o==null||o===""}class e{static enable=!1;static instance=null;static#i=null;static#r=1;static#d(){if(e.enable===!1)throw new Error("Emulator is disabled");return e.enable}static#o(n){return e.instance=n,e.#i=n.typeDevice,e.#r=n.deviceNumber,!0}static#n(n=null){return!e.#d()||n===null&&e.instance===null?!1:(e.instance===null&&n!==null&&e.#o(n),!0)}static#l(){if(e.#i!=="locker")throw new Error("This function is only available for Locker devices");return!0}static#t(){if(e.#i!=="boardroid")throw new Error("This function is only available for Boardroid devices");return!0}static#s(){if(e.#i!=="jofemar")throw new Error("This function is only available for Jofemar devices");return!0}static#c(){if(e.#i==="locker")throw new Error("This function is not available for Locker devices");return!0}static#e(n){e.instance!==null&&e.instance.__emulate({code:n})}static status(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#i){case"locker":s=["0","8"];break;case"boardroid":s=["2",(5+e.#r).toString(16).toUpperCase()];break;case"jofemar":s=["6"];break;default:return!1}e.#e(s)}static dispensed(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#i){case"locker":s=["0","7","4","4","4"];break;case"boardroid":s=["2","D7","A","0","0","0","0","0","0","0","0","0","F2"];break;case"jofemar":s=["6","30"];break;default:return!1}e.#e(s)}static notDispensed(n=null){if(!e.#n(n))return!1;let s=[];switch(e.#i){case"locker":s=["0","7","5","5","5"];break;case"boardroid":s=["2","D7","A","0","0","1","0","0","0","0","0","0","F2"];break;case"jofemar":s=["6","34"];break;default:return!1}e.#e(s)}static gateInactive(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","7","5","5","5"])}static gateConfigured(n=null){if(!e.#n(n)||!this.#l())return!1;this.#e(["0","6"])}static keyPressed(n=null){if(!e.#n(n)||!e.#s())return!1;const s=["30","31","32","33","34","35","36","37","38","39","2A","23","41","42","43","44"],t=(128+e.#r).toString(16),i=Math.floor(Math.random()*15);e.#e(["2",t,"54",s[i]])}static doorOpened(n=null){if(!e.#n(n)||!this.#c())return!1;let s=[];const t=(128+e.#r).toString(16);switch(e.#i){case"boardroid":s=["2","D8","dc"];break;case"jofemar":s=["2",t,"50","4F"];break}e.#e(s)}static doorClosed(n=null){if(!e.#n(n)||!this.#c())return!1;let s=[];const t=(128+e.#r).toString(16);switch(e.#i){case"boardroid":s=["2","D8","db"];break;case"jofemar":s=["2",t,"50","43"];break}e.#e(s)}static channelDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FD"])}static channelConnected(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FC"])}static channelEmpty(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","43","43","FF"])}static workingTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;const s=(128+e.#r).toString(16);e.#e(["2",s,"43","54","16"])}static currentTemperature(n=null){if(!e.#n(n)||!e.#c())return!1;let s=[];const t=(128+e.#r).toString(16);switch(e.#i){case"boardroid":s=["2","D9","44","30"];break;case"jofemar":s=["2",t,"43","74","2B","30","39","2E","31","7F","43"];break}e.#e(s)}static ready(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","30"])}static busy(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","31"])}static invalidTray(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","32"])}static invalidChannel(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","33"])}static emptyChannel(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","34"])}static elevatorJam(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","35"])}static elevatorMalfunction(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","36"])}static phototransistorFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","37"])}static allChannelsEmpty(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","38"])}static productDetectorFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","39"])}static displayDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","41"])}static productUnderElevator(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","42"])}static elevatorSettingAlarm(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","43"])}static buttonPanelFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","44"])}static errorWritingEeprom(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","45"])}static errorControlTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","46"])}static thermometerDisconnected(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","47"])}static thermometerMisconfigured(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","48"])}static thermometerFailure(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","49"])}static errorExtractorConsumption(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4A"])}static channelSearchError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4B"])}static productExitMouthSearchError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4C"])}static elevatorInteriorLocked(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4D"])}static productDetectorVerifierError(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4E"])}static waitingForProductRecall(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4F"])}static productExpiredByTemperature(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","50"])}static faultyAutomaticDoor(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","51"])}static rejectLever(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","A0","1"])}static resetCoinPurse(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","A0","2"])}static#f(n,s=null){let t=n[Math.floor(Math.random()*5)];if(s!==null&&!isNaN(parseFloat(s)))switch(s.toString()){case"0.5":t=n[1];break;case"1":t=n[2];break;case"2":t=n[3];break;case"5":t=n[4];break;case"10":t=n[5];break}return t}static coinInsertedBox(n=null,s=null){if(!e.#n(n)||!e.#t())return!1;const t=["40","41","42","43","44","45"],i=e.#f(t,s);e.#e(["2","A0",i])}static coinInsertedTube(n=null,s=null){if(!e.#n(n)||!e.#t())return!1;const t=["50","51","52","53","54","55"],i=e.#f(t,s);e.#e(["2","A0",i])}static#a(n,s=null){let t=n[Math.floor(Math.random()*4)];if(s!==null&&!isNaN(parseFloat(s)))switch(s.toString()){case"20":t=n[0];break;case"50":t=n[1];break;case"100":t=n[2];break;case"200":t=n[3];break;case"500":t=n[4];break}return t}static banknoteInsertedStacker(n=null,s=null){if(!e.#n(n)||!e.#t())return!1;const t=["80","81","82","83","84"],i=e.#a(t,s);e.#e(["2","B0",i])}static banknoteInsertedEscrow(n=null,s=null){if(!e.#n(n)||!e.#t())return!1;const t=["90","91","92","93","94"],i=e.#a(t,s);e.#e(["2","B0",i])}static banknoteEjected(n=null,s=null){if(!e.#n(n)||!e.#t())return!1;const t=["A0","A1","A2","A3","A4"],i=e.#a(t,s);e.#e(["2","B0",i])}static banknoteInsertedRecycler(n=null,s=null){if(!e.#n(n)||!e.#t())return!1;const t=["B0","B1","B2","B3","B4"],i=e.#a(t,s);e.#e(["2","B0",i])}static banknoteTaken(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","B0","2a"])}static coinPurseEnabled(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","D0","1"])}static coinPurseDisabled(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","D0","0"])}static billPurseDisabled(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","D1","0","0"])}static billPurseEnabled(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","D1","1","1"])}static readTubes(n=null){if(!e.#n(n)||!e.#t())return!1;const s=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c","1d","1e","1f"],[t,i,a,c,l,f]=[s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)],s[Math.floor(Math.random()*30)]];e.#e(["2","D2",t,i,a,c,l,f])}static readBillPurse(n=null,s=null){if(!e.#n(n)||!e.#t()||e.instance===null)return!1;const t=e.instance,i=["0","1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(t.__banknote_purse.recycler.ict){const a=i[Math.floor(Math.random()*31)];let c="0",l="0",f="0",d="0",h="0";if(s!==null&&!isNaN(parseInt(s)))switch(s.toString()){case"20":c=a;break;case"50":l=a;break;case"100":f=a;break;case"200":d=a;break;case"500":h=a;break}else switch(t.__banknote_purse.recycler.banknote){case 0:c=a;break;case 1:l=a;break;case 2:f=a;break;case 3:d=a;break;case 4:h=a;break}e.#e(["2","D3",c,l,f,d,h,"0"])}else{const[a,c,l,f,d,h]=[i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*30)],i[Math.floor(Math.random()*2)],i[Math.floor(Math.random())],i[Math.floor(Math.random())]];e.#e(["2","D3",a,c,l,f,d,h])}}static banknoteAccepted(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","D4","1"])}static banknoteRejected(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","D4","0"])}static banknotesDispensed(n=null){if(!e.#n(n)||!e.#t()||e.instance===null)return!1;const s=e.instance,t=["1","2","3","4","5","6","7","8","9","a","b","c","d","e","f","10","11","12","13","14","15","16","17","18","19","1a","1b","1c"];if(s.__banknote_purse.recycler.ict){const i=t[Math.floor(Math.random()*30)];let a="0",c="0",l="0",f="0",d="0";switch(s.__banknote_purse.recycler.banknote){case 0:a=i;break;case 1:c=i;break;case 2:l=i;break;case 3:f=i;break;case 4:d=i;break}e.#e(["2","D5",a,c,l,f,d,"0"])}else{const[i,a,c,l,f,d]=[t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*30)],t[Math.floor(Math.random()*2)],t[Math.floor(Math.random())],t[Math.floor(Math.random())]];e.#e(["2","D5",i,a,c,l,f,d])}}static coinsDispensed(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","D6"])}static relayOn(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DA","1"])}static relayOff(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DA","0"])}static nayaxEnabled(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","1"])}static nayaxDisabled(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","0"])}static nayaxPreCreditAuthorized(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","3"])}static nayaxCancelRequest(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","4"])}static nayaxSellApproved(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","5"])}static nayaxSellDenied(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","6"])}static nayaxEndSession(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","7"])}static nayaxCancelled(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","8"])}static nayaxDispensed(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","A","0"])}static nayaxNotDispensed(n=null){if(!e.#n(n)||!e.#t())return!1;e.#e(["2","DD","A","1"])}static fullTray(n=null){if(!e.#n(n)||!e.#s())return!1;e.#e(["6","4F"])}static setConnection(n=null){if(!e.#n(n)||e.instance===null)return!1;e.instance.__internal__.serial.connected=!0}}class r extends p.a{constructor(){super();const n={relay:[],locker:[],jofemar:[],boardroid:[],pinpad:[],pinpax:[],hopper:[]};r.devices={...structuredClone(p.a.devices),...n}}addCustom(n,s){r.registerType(n),r.add(s)}getCustomByUuid(n,s){return r.get(n,s)}getJofemarByUuid(n){return r.get("jofemar",n)}getLockerByUuid(n){return r.get("locker",n)}getRelayByUuid(n){return r.get("relay",n)}getBoardroidByUuid(n){return r.get("boardroid",n)}getPinPadByUuid(n){return r.get("pinpad",n)}getPinPaxByUuid(n){return r.get("pinpax",n)}getHopperByUuid(n){return r.get("hopper",n)}getJofemar(n=1){return r.getByNumber("jofemar",n)}getBoardroid(n=1){return r.getByNumber("boardroid",n)}getLocker(n=1){return r.getByNumber("locker",n)}getRelay(n=1){return r.getByNumber("relay",n)}getPinPad(n=1){return r.getByNumber("pinpad",n)}getPinPax(n=1){return r.getByNumber("pinpax",n)}getHopper(n=1){return r.getByNumber("hopper",n)}}r.instance||(r.instance=new r);class D extends p.ut{constructor(n={}){super(n),this.__internal__=structuredClone(this.__internal__),this.getResponseAsArrayHex(),this.__internal__.device.door_open=!1,this.__internal__.time.response_engines=2e3,this.__internal__.time.sense=100,this.__internal__.interval.waiting_sense=0,this.__internal__.dispense={must_response:!1,dispensing:!1,status:null,counter:0,limit_counter:20,custom_limit_counter:null,backup_dispense:{}}}get isDoorOpen(){return this.__internal__.device.door_open}get isDispensing(){return this.__internal__.interval.waiting_sense||this.__internal__.dispense.dispensing}async timeout(n,s){await super.timeout(n,s),s==="dispense"&&(this.__internal__.dispense.status="no-response")}internalClearSensing(){this.__internal__.interval.waiting_sense&&clearInterval(this.__internal__.interval.waiting_sense),this.__internal__.interval.waiting_sense=0,this.__internal__.dispense.status=null,this.__internal__.dispense.counter=0,this.__internal__.dispense.dispensing=!1}internalDispensingProcess(){let n=this.__internal__.dispense.limit_counter;return this.__internal__.dispense.custom_limit_counter&&(n=this.__internal__.dispense.custom_limit_counter),n+=Math.ceil(n*.6),this.__internal__.dispense.counter>=n?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.__internal__.dispense.dispensing=!1,!1):(this.__internal__.dispense.counter=parseFloat((.1+this.__internal__.dispense.counter).toFixed(1)),this.__internal__.dispense.counter%1===0&&this.dispatch("dispensing",{status:this.__internal__.dispense.status,counter:this.__internal__.dispense.counter,limit:n}),null)}async internalDispenseStatus(){return this.__internal__.dispense.must_response&&(await u(this.__internal__.time.response_engines+10),this.__internal__.dispense.status==="no-response")?(this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),{status:!1,error:"no-response"}):(this.__internal__.dispense.status=null,this.__internal__.dispense.dispensing=!0,this.dispatch("internal:dispense:running",{}),new Promise(n=>{this.__internal__.interval.waiting_sense=setInterval(()=>{switch(this.__internal__.dispense.status){case null:this.internalDispensingProcess()===!1&&(this.internalClearSensing(),this.dispatch("not-dispensed",{reason:"timeout"}),n({status:!1,error:"timeout"}));break;case!0:this.internalClearSensing(),this.__internal__.dispense.status=!0,this.dispatch("dispensed",{}),n({status:!0,error:null});break;case!1:this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-stock"}),n({status:!1,error:null});break;case"elevator-locked":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"elevator-locked"}),n({status:!1,error:"elevator-locked"});break;case"no-response":this.internalClearSensing(),this.__internal__.dispense.status=!1,this.dispatch("not-dispensed",{reason:"no-response"}),n({status:!1,error:"no-response"});break}},this.__internal__.time.sense)}))}async internalDispense(n){if(this.isDispensing)throw new Error("Another dispensing process is running");if(this.__internal__.dispense.dispensing=!0,!e.enable&&!this.__internal__.serial.connected&&(await this.serialConnect(),!this.__internal__.serial.connected))throw this.__internal__.dispense.dispensing=!1,new Error("Serial device not connected");return this.__internal__.serial.queue.length===0?(await this.appendToQueue(n,"dispense"),await this.internalDispenseStatus()):new Promise(s=>{const t=setInterval(async()=>{if(this.__internal__.serial.queue.length>0)return;clearInterval(t),await this.appendToQueue(n,"dispense");const i=await this.internalDispenseStatus();s(i)},100)})}__emulate(n){if(typeof n.code!="object"){console.error("Invalid data to make an emulation");return}this.__internal__.serial.connected||(this.__internal__.serial.connected=!0,this.dispatch("serial:connected"),r.instance.dispatch("change"),this.__internal__.interval.reconnection&&(clearInterval(this.__internal__.interval.reconnection),this.__internal__.interval.reconnection=0)),this.__internal__.timeout.until_response&&(clearTimeout(this.__internal__.timeout.until_response),this.__internal__.timeout.until_response=0);const s=[];for(const t in n.code)s.push(n.code[t].toString().padStart(2,"0").toLowerCase());this.serialMessage(s)}set listenOnPort(n){this.listenOnChannel=n}get listenOnPort(){return this.__internal__.device.listen_on_port??1}fixHexArray(n){return n.map(s=>typeof s=="string"?s.padStart(2,"0").toLowerCase():s.toString(16).padStart(2,"0").toLowerCase())}}exports.Devices=r;exports.Emulator=e;exports.Kernel=D;exports.getSeconds=y;exports.isEmpty=w;exports.supportCrypto=k;exports.supportGeolocation=g;exports.supportWebSerial=b;exports.wait=u;
|