@danidoble/webserial 4.4.0-beta.2 → 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 +99 -95
- package/dist/hopper.cjs +2 -2
- package/dist/hopper.js +66 -51
- package/dist/jofemar.cjs +1 -1
- package/dist/jofemar.js +57 -141
- 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-CXM5xoJD.js → kernel-DkC7Kj3m.js} +147 -124
- 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 +32 -26
- package/dist/main.d.ts +28 -0
- package/dist/main.d.ts.map +1 -0
- package/dist/pinpad.cjs +14 -14
- package/dist/pinpad.js +816 -791
- package/dist/pinpax.cjs +4 -4
- package/dist/pinpax.js +54 -54
- package/dist/relay.cjs +1 -1
- package/dist/relay.js +11 -18
- 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-CH2Xov2y.js +3325 -0
- package/dist/webserial-core-Cj_EZjAU.cjs +4 -0
- package/dist/webserial.cjs +2 -2
- package/dist/webserial.js +16 -16
- package/package.json +10 -7
- package/dist/kernel-Dizfdw3M.cjs +0 -1
package/dist/hopper.cjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const
|
|
2
|
-
`,
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const s=require("./webserial-core-YjdXyVOx.cjs");class d extends s.ut{__hoppers__={levels:[{id:1,currency:10,key:"Hopper 1",name:"10 Pesos",amount:0,capacity:1e3},{id:2,currency:5,key:"Hopper 2",name:"5 Pesos",amount:0,capacity:1e3},{id:3,currency:2,key:"Hopper 3",name:"2 Pesos",amount:0,capacity:1e3},{id:4,currency:1,key:"Hopper 4",name:"1 Peso",amount:0,capacity:1e3}],balance:0,current:null};constructor({filters:e=null,config_port:t={baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:r=1,socket:n=!1}={filters:null,config_port:{baudRate:115200,dataBits:8,stopBits:1,parity:"none",bufferSize:32768,flowControl:"none"},no_device:1,socket:!1}){if(super({filters:e,config_port:t,no_device:r,socket:n}),this.__internal__.device.type="hopper",s.a.getCustom(this.typeDevice,r))throw new Error(`Device ${this.typeDevice} ${r} already exists`);this.__internal__.time.response_connection=7e3,this.__internal__.time.response_general=7e3,this.__internal__.serial.delay_first_connection=500,this.__internal__.serial.response.replacer="",this.__internal__.serial.response.limiter=`\r
|
|
2
|
+
`,s.a.add(this),this.#s()}#s(){const e=["levels","hopper:updated","dispense-change","balance:updated","validator:status","change:1x1"];for(const t of e)this.serialRegisterAvailableListener(t)}get balance(){return this.__hoppers__.balance}get currentHopper(){return this.__hoppers__.current}get levels(){return this.__hoppers__.levels}setMaxCapacity({hopper:e=1,capacity:t=1e3}={hopper:1,capacity:1e3}){return this.#r(e),this.__hoppers__.levels[e-1].capacity=t,this}setHopperName({hopper:e=1,name:t=""}={hopper:1,name:""}){if(this.#r(e),typeof t!="string"||t.length===0)throw new TypeError("Name must be a non-empty string");return this.__hoppers__.levels[e-1].name=t,this}setHopperKey({hopper:e=1,key:t=""}={hopper:1,key:""}){if(this.#r(e),typeof t!="string"||t.length===0)throw new TypeError("Key must be a non-empty string");return this.__hoppers__.levels[e-1].key=t,this}setHopperCurrency({hopper:e=1,currency:t=1}={hopper:1,currency:1}){if(this.#r(e),typeof t!="number"||t<=0)throw new RangeError("Currency must be a positive number");return this.__hoppers__.levels[e-1].currency=t,this}#n(e){e.error=!0,e.ascii.includes("ffffff")?(e.name="SINTAX",e.description="Error de Sintaxis",e.no_code=400):e.ascii.includes("ffaaaa")?(e.name="LOWLEVEL",e.description="Bajo nivel de monedas en Hopper (99)",e.no_code=401):e.ascii.includes("ffbbbb")?(e.name="TIMEOUT_DISPENSE",e.description="Error de dispensado, timeout",e.no_code=402):(e.name="UNKNOWN_ERROR",e.description="Unknown error occurred",e.no_code=999),this.dispatch("serial:message",e)}#i(e){if(this.lastAction==="status")e.name="STATUS",e.description="Hoppers status",e.no_code=1,this.__hoppers__.levels[0].amount=this.#t(e.code[9],e.code[10]),this.__hoppers__.levels[1].amount=this.#t(e.code[7],e.code[8]),this.__hoppers__.levels[2].amount=this.#t(e.code[5],e.code[6]),this.__hoppers__.levels[3].amount=this.#t(e.code[3],e.code[4]),e.data=this.__hoppers__.levels,this.dispatch("levels",e.data);else if(this.lastAction==="readHopper"){e.name="READ_HOPPER",e.description=`Hopper ${this.__hoppers__.current} level`,e.no_code=2;const t=(this.__hoppers__.current||1)-1;this.__hoppers__.levels[t].amount=this.#t(e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current,this.dispatch("hopper:updated",this.__hoppers__.levels[t])}else if(this.lastAction==="writeHopper"){e.name="WRITE_HOPPER",e.description="Hopper "+this.__hoppers__.current+" write",e.no_code=3,this.__hoppers__.levels[(this.__hoppers__.current||1)-1].amount=this.#t(e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current;const t=(this.__hoppers__.current||1)-1;this.dispatch("hopper:updated",this.__hoppers__.levels[t])}else if(this.lastAction==="dispenseHopper"){e.name="DISPENSEHOPPER",e.description="Hopper "+this.__hoppers__.current+" dispense",e.no_code=4,this.__hoppers__.levels[(this.__hoppers__.current||1)-1].amount=this.#t(e.code[9],e.code[10]),e.data=this.__hoppers__.levels,e.hopperId=this.__hoppers__.current;const t=(this.__hoppers__.current||0)-1;this.dispatch("hopper:updated",this.__hoppers__.levels[t])}else this.lastAction==="dispenseChange"?(e.name="DISPENSE_CHANGE",e.description="Change dispensed",e.no_code=5,e.data=this.#t(e.code[9],e.code[10]),this.dispatch("dispense-change",{amount:e.data})):this.lastAction==="readBalance"?(e.name="READ_BALANCE",e.description="Read Balance",e.no_code=6,this.__hoppers__.balance=this.#t(e.code[9],e.code[10]),e.data=this.__hoppers__.balance,this.dispatch("balance:updated",{balance:e.data})):this.lastAction==="clearBalance"?(e.name="CLEAR_BALANCE",e.description="Clared hoppers balance",e.no_code=7,this.__hoppers__.balance=this.#t(e.code[9],e.code[10]),e.data=this.__hoppers__.balance,this.dispatch("balance:updated",{balance:e.data})):this.lastAction==="configValidator"?(e.code[2]===1?(e.name="ENABLE_VALIDATOR",e.description="Validator enabled",e.no_code=8,this.dispatch("validator:status",{enabled:!0})):(e.name="DISABLE_VALIDATOR",e.description="Validator disabled",e.no_code=9,this.dispatch("validator:status",{enabled:!1})),e.no_code=400,e.data=e.code[2]===1?"enabled":"disabled"):this.lastAction?.includes("change1x1Hopper")&&(e.code[2]===1?(e.name="CHANGE_1X1_HOPPER_1",e.description="Change 1x1 Hopper 1",e.no_code=10):e.code[2]===2?(e.name="CHANGE_1X1_HOPPER_2",e.description="Change 1x1 Hopper 2",e.no_code=11):e.code[2]===3?(e.name="CHANGE_1X1_HOPPER_3",e.description="Change 1x1 Hopper 3",e.no_code=12):e.code[2]===4?(e.name="CHANGE_1X1_HOPPER_4",e.description="Change 1x1 Hopper 4",e.no_code=13):(e.name="CHANGE_1X1_HOPPER_UNKNOWN",e.description="Change 1x1 Hopper Unknown",e.no_code=14),this.dispatch("change:1x1",{hopperId:e.code[2]}));this.dispatch("serial:message",e)}serialMessage(e){const t=e,r=this.parseUint8ArrayToString(t),i={ascii:this.asciiToHex(r),code:t,name:"",description:"",request:this.lastAction,no_code:0,error:!1,data:null};if(t.length===3){this.#n(i);return}const p=Array.from(t);if(t.length!==13){const c=this.#p({array:p,chunkSize:13});for(const o of c){const a=this.parseUint8ArrayToString(new Uint8Array(o)),h=this.asciiToHex(a),_=this.stringToArrayHex(a);i.code=o,i.hex=_,i.ascii=h,o.length!==13?this.#n(i):this.#i(i)}return}this.#i(i)}#t(e,t){return(e<<8|t)<<16>>16}#r(e){if(typeof e!="number"||e<1||e>4)throw new RangeError("Hopper ID must be a number between 1 and 4");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Hopper ID must be an integer")}#o(e){if(typeof e!="number"||e<-32768||e>32767)throw new RangeError("Quantity must be a number between -32768 and 32767");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Quantity must be an integer")}#a(e){this.#o(e);const t=e&65535,r=t>>8&255,n=t&255;return[r,n]}#p({array:e,chunkSize:t=13}={array:[],chunkSize:13}){if(!Array.isArray(e))throw new TypeError("Expected an array");if(typeof t!="number"||t<=0)throw new RangeError("Chunk size must be a positive number");const r=[];for(let n=0;n<e.length;n+=t)r.push(e.slice(n,n+t));return r}#e(e){e.length<11&&(e=[...e,...Array(11-e.length).fill(0)]);const r=e.slice(1,11).reduce((n,i)=>{if(typeof i!="number")throw new TypeError("Array must contain only numbers");return n+i},0)&255;return e[11]=r,e[12]=15,e}serialSetConnectionConstant(){return[10,0,0,0,0,0,0,0,0,0,0,0,15]}async sendConnect(){const e=this.#e([10]);return await this.appendToQueue(e,"connect")}async requestStatus(){const e=this.#e([10,10,11,12]);return await this.appendToQueue(e,"status")}async readBalance(){const e=this.#e([10,192,1]);return await this.appendToQueue(e,"readBalance")}async clearBalance(){const e=this.#e([10,192,2]);return await this.appendToQueue(e,"clearBalance")}async forceInvalid(){const e="0A000F00".match(/.{1,2}/g);return await this.appendToQueue(e,"ForceInvalid")}async readHopper({hopper:e=1}={hopper:1}){this.#r(e),this.__hoppers__.current=e;const t=this.#e([10,e,e]);return await this.appendToQueue(t,"readHopper")}async writeHopper({hopper:e=1,quantity:t=0}={hopper:1,quantity:0}){this.#r(e),this.#o(t),this.__hoppers__.current=e;const[r,n]=this.#a(t),i=this.#e([10,240,e,0,0,0,0,0,0,r,n]);return await this.appendToQueue(i,"writeHopper")}async dispenseHopper({hopper:e=1}={hopper:1}){this.#r(e),this.__hoppers__.current=e;const t=this.#e([10,2,e]);return await this.appendToQueue(t,"dispenseHopper")}async dispenseChange({change:e=0}={change:0}){if(typeof e!="number"||e<0||e>32767)throw new RangeError("Change must be a number between 0 and 32767");if(typeof e!="number"||!Number.isInteger(e))throw new TypeError("Change must be an integer");const t=e&255,r=e>>8&255,n=this.#e([10,204,170,0,0,0,0,0,0,r,t]);return await this.appendToQueue(n,"dispenseChange")}async configValidator({enable:e=!1}={enable:!1}){if(typeof e!="boolean")throw new TypeError("Enable must be a boolean");const t=this.#e([10,176,e?1:0]);return await this.appendToQueue(t,"configValidator")}async disableValidator(){return await this.configValidator({enable:!1})}async enableValidator(){return await this.configValidator({enable:!0})}async change1x1({hopper:e=1}={hopper:1}){this.#r(e),this.__hoppers__.current=e;const t=this.#e([10,224,e]);return await this.appendToQueue(t,"change1x1Hopper-"+e)}async sendCustomCode({code:e=[]}={code:[]}){if(!Array.isArray(e)||!e.every(r=>typeof r=="number"&&r>=0&&r<=255))throw new TypeError("Code must be an array of numbers between 0 and 255");const t=this.#e(e);await this.appendToQueue(t,"custom")}}exports.Hopper=d;
|
package/dist/hopper.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { u as
|
|
2
|
-
class
|
|
1
|
+
import { u as d, a } from "./webserial-core-D3luFguv.js";
|
|
2
|
+
class f extends d {
|
|
3
3
|
__hoppers__ = {
|
|
4
4
|
levels: [
|
|
5
5
|
{ id: 1, currency: 10, key: "Hopper 1", name: "10 Pesos", amount: 0, capacity: 1e3 },
|
|
@@ -20,8 +20,8 @@ class d extends _ {
|
|
|
20
20
|
bufferSize: 32768,
|
|
21
21
|
flowControl: "none"
|
|
22
22
|
},
|
|
23
|
-
no_device:
|
|
24
|
-
socket:
|
|
23
|
+
no_device: r = 1,
|
|
24
|
+
socket: n = !1
|
|
25
25
|
} = {
|
|
26
26
|
filters: null,
|
|
27
27
|
config_port: {
|
|
@@ -35,12 +35,12 @@ class d extends _ {
|
|
|
35
35
|
no_device: 1,
|
|
36
36
|
socket: !1
|
|
37
37
|
}) {
|
|
38
|
-
if (super({ filters: e, config_port: t, no_device:
|
|
39
|
-
throw new Error(`Device ${this.typeDevice} ${
|
|
38
|
+
if (super({ filters: e, config_port: t, no_device: r, socket: n }), this.__internal__.device.type = "hopper", a.getCustom(this.typeDevice, r))
|
|
39
|
+
throw new Error(`Device ${this.typeDevice} ${r} already exists`);
|
|
40
40
|
this.__internal__.time.response_connection = 7e3, this.__internal__.time.response_general = 7e3, this.__internal__.serial.delay_first_connection = 500, this.__internal__.serial.response.replacer = "", this.__internal__.serial.response.limiter = `\r
|
|
41
|
-
`,
|
|
41
|
+
`, a.add(this), this.#s();
|
|
42
42
|
}
|
|
43
|
-
#
|
|
43
|
+
#s() {
|
|
44
44
|
const e = ["levels", "hopper:updated", "dispense-change", "balance:updated", "validator:status", "change:1x1"];
|
|
45
45
|
for (const t of e)
|
|
46
46
|
this.serialRegisterAvailableListener(t);
|
|
@@ -54,20 +54,20 @@ class d extends _ {
|
|
|
54
54
|
get levels() {
|
|
55
55
|
return this.__hoppers__.levels;
|
|
56
56
|
}
|
|
57
|
-
setMaxCapacity({ hopper: e =
|
|
57
|
+
setMaxCapacity({ hopper: e = 1, capacity: t = 1e3 } = { hopper: 1, capacity: 1e3 }) {
|
|
58
58
|
return this.#r(e), this.__hoppers__.levels[e - 1].capacity = t, this;
|
|
59
59
|
}
|
|
60
|
-
setHopperName({ hopper: e =
|
|
60
|
+
setHopperName({ hopper: e = 1, name: t = "" } = { hopper: 1, name: "" }) {
|
|
61
61
|
if (this.#r(e), typeof t != "string" || t.length === 0)
|
|
62
62
|
throw new TypeError("Name must be a non-empty string");
|
|
63
63
|
return this.__hoppers__.levels[e - 1].name = t, this;
|
|
64
64
|
}
|
|
65
|
-
setHopperKey({ hopper: e =
|
|
65
|
+
setHopperKey({ hopper: e = 1, key: t = "" } = { hopper: 1, key: "" }) {
|
|
66
66
|
if (this.#r(e), typeof t != "string" || t.length === 0)
|
|
67
67
|
throw new TypeError("Key must be a non-empty string");
|
|
68
68
|
return this.__hoppers__.levels[e - 1].key = t, this;
|
|
69
69
|
}
|
|
70
|
-
setHopperCurrency({ hopper: e =
|
|
70
|
+
setHopperCurrency({ hopper: e = 1, currency: t = 1 } = { hopper: 1, currency: 1 }) {
|
|
71
71
|
if (this.#r(e), typeof t != "number" || t <= 0)
|
|
72
72
|
throw new RangeError("Currency must be a positive number");
|
|
73
73
|
return this.__hoppers__.levels[e - 1].currency = t, this;
|
|
@@ -80,30 +80,34 @@ class d extends _ {
|
|
|
80
80
|
e.name = "STATUS", e.description = "Hoppers status", e.no_code = 1, this.__hoppers__.levels[0].amount = this.#t(e.code[9], e.code[10]), this.__hoppers__.levels[1].amount = this.#t(e.code[7], e.code[8]), this.__hoppers__.levels[2].amount = this.#t(e.code[5], e.code[6]), this.__hoppers__.levels[3].amount = this.#t(e.code[3], e.code[4]), e.data = this.__hoppers__.levels, this.dispatch("levels", e.data);
|
|
81
81
|
else if (this.lastAction === "readHopper") {
|
|
82
82
|
e.name = "READ_HOPPER", e.description = `Hopper ${this.__hoppers__.current} level`, e.no_code = 2;
|
|
83
|
-
const t = this.__hoppers__.current - 1;
|
|
83
|
+
const t = (this.__hoppers__.current || 1) - 1;
|
|
84
84
|
this.__hoppers__.levels[t].amount = this.#t(e.code[9], e.code[10]), e.data = this.__hoppers__.levels, e.hopperId = this.__hoppers__.current, this.dispatch("hopper:updated", this.__hoppers__.levels[t]);
|
|
85
85
|
} else if (this.lastAction === "writeHopper") {
|
|
86
|
-
e.name = "WRITE_HOPPER", e.description = "Hopper " + this.__hoppers__.current + " write", e.no_code = 3, this.__hoppers__.levels[this.__hoppers__.current - 1].amount = this.#t(
|
|
86
|
+
e.name = "WRITE_HOPPER", e.description = "Hopper " + this.__hoppers__.current + " write", e.no_code = 3, this.__hoppers__.levels[(this.__hoppers__.current || 1) - 1].amount = this.#t(
|
|
87
|
+
// @ts-expect-error index position on uint8array is number
|
|
87
88
|
e.code[9],
|
|
89
|
+
// @ts-expect-error index position on uint8array is number
|
|
88
90
|
e.code[10]
|
|
89
91
|
), e.data = this.__hoppers__.levels, e.hopperId = this.__hoppers__.current;
|
|
90
|
-
const t = this.__hoppers__.current - 1;
|
|
92
|
+
const t = (this.__hoppers__.current || 1) - 1;
|
|
91
93
|
this.dispatch("hopper:updated", this.__hoppers__.levels[t]);
|
|
92
94
|
} else if (this.lastAction === "dispenseHopper") {
|
|
93
|
-
e.name = "DISPENSEHOPPER", e.description = "Hopper " + this.__hoppers__.current + " dispense", e.no_code = 4, this.__hoppers__.levels[this.__hoppers__.current - 1].amount = this.#t(
|
|
95
|
+
e.name = "DISPENSEHOPPER", e.description = "Hopper " + this.__hoppers__.current + " dispense", e.no_code = 4, this.__hoppers__.levels[(this.__hoppers__.current || 1) - 1].amount = this.#t(
|
|
96
|
+
// @ts-expect-error index position on uint8array is number
|
|
94
97
|
e.code[9],
|
|
98
|
+
// @ts-expect-error index position on uint8array is number
|
|
95
99
|
e.code[10]
|
|
96
100
|
), e.data = this.__hoppers__.levels, e.hopperId = this.__hoppers__.current;
|
|
97
|
-
const t = this.__hoppers__.current - 1;
|
|
101
|
+
const t = (this.__hoppers__.current || 0) - 1;
|
|
98
102
|
this.dispatch("hopper:updated", this.__hoppers__.levels[t]);
|
|
99
|
-
} else this.lastAction === "dispenseChange" ? (e.name = "DISPENSE_CHANGE", e.description = "Change dispensed", e.no_code = 5, e.data = this.#t(e.code[9], e.code[10]), this.dispatch("dispense-change", { amount: e.data })) : this.lastAction === "readBalance" ? (e.name = "READ_BALANCE", e.description = "Read Balance", e.no_code = 6, this.__hoppers__.balance = this.#t(e.code[9], e.code[10]), e.data = this.__hoppers__.balance, this.dispatch("balance:updated", { balance: e.data })) : this.lastAction === "clearBalance" ? (e.name = "CLEAR_BALANCE", e.description = "Clared hoppers balance", e.no_code = 7, this.__hoppers__.balance = this.#t(e.code[9], e.code[10]), e.data = this.__hoppers__.balance, this.dispatch("balance:updated", { balance: e.data })) : this.lastAction === "configValidator" ? (e.code[2] === 1 ? (e.name = "ENABLE_VALIDATOR", e.description = "Validator enabled", e.no_code = 8, this.dispatch("validator:status", { enabled: !0 })) : (e.name = "DISABLE_VALIDATOR", e.description = "Validator disabled", e.no_code = 9, this.dispatch("validator:status", { enabled: !1 })), e.no_code = 400, e.data = e.code[2] === 1 ? "enabled" : "disabled") : this.lastAction
|
|
103
|
+
} else this.lastAction === "dispenseChange" ? (e.name = "DISPENSE_CHANGE", e.description = "Change dispensed", e.no_code = 5, e.data = this.#t(e.code[9], e.code[10]), this.dispatch("dispense-change", { amount: e.data })) : this.lastAction === "readBalance" ? (e.name = "READ_BALANCE", e.description = "Read Balance", e.no_code = 6, this.__hoppers__.balance = this.#t(e.code[9], e.code[10]), e.data = this.__hoppers__.balance, this.dispatch("balance:updated", { balance: e.data })) : this.lastAction === "clearBalance" ? (e.name = "CLEAR_BALANCE", e.description = "Clared hoppers balance", e.no_code = 7, this.__hoppers__.balance = this.#t(e.code[9], e.code[10]), e.data = this.__hoppers__.balance, this.dispatch("balance:updated", { balance: e.data })) : this.lastAction === "configValidator" ? (e.code[2] === 1 ? (e.name = "ENABLE_VALIDATOR", e.description = "Validator enabled", e.no_code = 8, this.dispatch("validator:status", { enabled: !0 })) : (e.name = "DISABLE_VALIDATOR", e.description = "Validator disabled", e.no_code = 9, this.dispatch("validator:status", { enabled: !1 })), e.no_code = 400, e.data = e.code[2] === 1 ? "enabled" : "disabled") : this.lastAction?.includes("change1x1Hopper") && (e.code[2] === 1 ? (e.name = "CHANGE_1X1_HOPPER_1", e.description = "Change 1x1 Hopper 1", e.no_code = 10) : e.code[2] === 2 ? (e.name = "CHANGE_1X1_HOPPER_2", e.description = "Change 1x1 Hopper 2", e.no_code = 11) : e.code[2] === 3 ? (e.name = "CHANGE_1X1_HOPPER_3", e.description = "Change 1x1 Hopper 3", e.no_code = 12) : e.code[2] === 4 ? (e.name = "CHANGE_1X1_HOPPER_4", e.description = "Change 1x1 Hopper 4", e.no_code = 13) : (e.name = "CHANGE_1X1_HOPPER_UNKNOWN", e.description = "Change 1x1 Hopper Unknown", e.no_code = 14), this.dispatch("change:1x1", { hopperId: e.code[2] }));
|
|
100
104
|
this.dispatch("serial:message", e);
|
|
101
105
|
}
|
|
102
106
|
serialMessage(e) {
|
|
103
|
-
const t = this.parseUint8ArrayToString(
|
|
107
|
+
const t = e, r = this.parseUint8ArrayToString(t), i = {
|
|
104
108
|
//hex,
|
|
105
|
-
ascii: this.asciiToHex(
|
|
106
|
-
code:
|
|
109
|
+
ascii: this.asciiToHex(r),
|
|
110
|
+
code: t,
|
|
107
111
|
name: "",
|
|
108
112
|
description: "",
|
|
109
113
|
request: this.lastAction,
|
|
@@ -111,19 +115,20 @@ class d extends _ {
|
|
|
111
115
|
error: !1,
|
|
112
116
|
data: null
|
|
113
117
|
};
|
|
114
|
-
if (
|
|
115
|
-
this.#n(
|
|
118
|
+
if (t.length === 3) {
|
|
119
|
+
this.#n(i);
|
|
116
120
|
return;
|
|
117
121
|
}
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
122
|
+
const p = Array.from(t);
|
|
123
|
+
if (t.length !== 13) {
|
|
124
|
+
const c = this.#p({ array: p, chunkSize: 13 });
|
|
125
|
+
for (const o of c) {
|
|
126
|
+
const s = this.parseUint8ArrayToString(new Uint8Array(o)), h = this.asciiToHex(s), _ = this.stringToArrayHex(s);
|
|
127
|
+
i.code = o, i.hex = _, i.ascii = h, o.length !== 13 ? this.#n(i) : this.#i(i);
|
|
123
128
|
}
|
|
124
129
|
return;
|
|
125
130
|
}
|
|
126
|
-
this.#i(
|
|
131
|
+
this.#i(i);
|
|
127
132
|
}
|
|
128
133
|
#t(e, t) {
|
|
129
134
|
return (e << 8 | t) << 16 >> 16;
|
|
@@ -140,29 +145,35 @@ class d extends _ {
|
|
|
140
145
|
if (typeof e != "number" || !Number.isInteger(e))
|
|
141
146
|
throw new TypeError("Quantity must be an integer");
|
|
142
147
|
}
|
|
143
|
-
#
|
|
148
|
+
#a(e) {
|
|
144
149
|
this.#o(e);
|
|
145
|
-
const t = e & 65535,
|
|
146
|
-
return [
|
|
150
|
+
const t = e & 65535, r = t >> 8 & 255, n = t & 255;
|
|
151
|
+
return [r, n];
|
|
147
152
|
}
|
|
148
|
-
#
|
|
153
|
+
#p({
|
|
154
|
+
array: e,
|
|
155
|
+
chunkSize: t = 13
|
|
156
|
+
} = {
|
|
157
|
+
array: [],
|
|
158
|
+
chunkSize: 13
|
|
159
|
+
}) {
|
|
149
160
|
if (!Array.isArray(e))
|
|
150
161
|
throw new TypeError("Expected an array");
|
|
151
162
|
if (typeof t != "number" || t <= 0)
|
|
152
163
|
throw new RangeError("Chunk size must be a positive number");
|
|
153
|
-
const
|
|
154
|
-
for (let
|
|
155
|
-
|
|
156
|
-
return
|
|
164
|
+
const r = [];
|
|
165
|
+
for (let n = 0; n < e.length; n += t)
|
|
166
|
+
r.push(e.slice(n, n + t));
|
|
167
|
+
return r;
|
|
157
168
|
}
|
|
158
169
|
#e(e) {
|
|
159
170
|
e.length < 11 && (e = [...e, ...Array(11 - e.length).fill(0)]);
|
|
160
|
-
const
|
|
171
|
+
const r = e.slice(1, 11).reduce((n, i) => {
|
|
161
172
|
if (typeof i != "number")
|
|
162
173
|
throw new TypeError("Array must contain only numbers");
|
|
163
|
-
return
|
|
174
|
+
return n + i;
|
|
164
175
|
}, 0) & 255;
|
|
165
|
-
return e[11] =
|
|
176
|
+
return e[11] = r, e[12] = 15, e;
|
|
166
177
|
}
|
|
167
178
|
serialSetConnectionConstant() {
|
|
168
179
|
return [10, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 15];
|
|
@@ -187,17 +198,17 @@ class d extends _ {
|
|
|
187
198
|
const e = "0A000F00".match(/.{1,2}/g);
|
|
188
199
|
return await this.appendToQueue(e, "ForceInvalid");
|
|
189
200
|
}
|
|
190
|
-
async readHopper({ hopper: e =
|
|
201
|
+
async readHopper({ hopper: e = 1 } = { hopper: 1 }) {
|
|
191
202
|
this.#r(e), this.__hoppers__.current = e;
|
|
192
203
|
const t = this.#e([10, e, e]);
|
|
193
204
|
return await this.appendToQueue(t, "readHopper");
|
|
194
205
|
}
|
|
195
|
-
async writeHopper({ hopper: e =
|
|
206
|
+
async writeHopper({ hopper: e = 1, quantity: t = 0 } = { hopper: 1, quantity: 0 }) {
|
|
196
207
|
this.#r(e), this.#o(t), this.__hoppers__.current = e;
|
|
197
|
-
const [
|
|
208
|
+
const [r, n] = this.#a(t), i = this.#e([10, 240, e, 0, 0, 0, 0, 0, 0, r, n]);
|
|
198
209
|
return await this.appendToQueue(i, "writeHopper");
|
|
199
210
|
}
|
|
200
|
-
async dispenseHopper({ hopper: e =
|
|
211
|
+
async dispenseHopper({ hopper: e = 1 } = { hopper: 1 }) {
|
|
201
212
|
this.#r(e), this.__hoppers__.current = e;
|
|
202
213
|
const t = this.#e([10, 2, e]);
|
|
203
214
|
return await this.appendToQueue(t, "dispenseHopper");
|
|
@@ -207,10 +218,12 @@ class d extends _ {
|
|
|
207
218
|
throw new RangeError("Change must be a number between 0 and 32767");
|
|
208
219
|
if (typeof e != "number" || !Number.isInteger(e))
|
|
209
220
|
throw new TypeError("Change must be an integer");
|
|
210
|
-
const t = e & 255,
|
|
211
|
-
return await this.appendToQueue(
|
|
221
|
+
const t = e & 255, r = e >> 8 & 255, n = this.#e([10, 204, 170, 0, 0, 0, 0, 0, 0, r, t]);
|
|
222
|
+
return await this.appendToQueue(n, "dispenseChange");
|
|
212
223
|
}
|
|
213
|
-
async configValidator({
|
|
224
|
+
async configValidator({
|
|
225
|
+
enable: e = !1
|
|
226
|
+
} = { enable: !1 }) {
|
|
214
227
|
if (typeof e != "boolean")
|
|
215
228
|
throw new TypeError("Enable must be a boolean");
|
|
216
229
|
const t = this.#e([10, 176, e ? 1 : 0]);
|
|
@@ -222,18 +235,20 @@ class d extends _ {
|
|
|
222
235
|
async enableValidator() {
|
|
223
236
|
return await this.configValidator({ enable: !0 });
|
|
224
237
|
}
|
|
225
|
-
async change1x1({ hopper: e =
|
|
238
|
+
async change1x1({ hopper: e = 1 } = { hopper: 1 }) {
|
|
226
239
|
this.#r(e), this.__hoppers__.current = e;
|
|
227
240
|
const t = this.#e([10, 224, e]);
|
|
228
241
|
return await this.appendToQueue(t, "change1x1Hopper-" + e);
|
|
229
242
|
}
|
|
230
|
-
async sendCustomCode({
|
|
231
|
-
|
|
243
|
+
async sendCustomCode({
|
|
244
|
+
code: e = []
|
|
245
|
+
} = { code: [] }) {
|
|
246
|
+
if (!Array.isArray(e) || !e.every((r) => typeof r == "number" && r >= 0 && r <= 255))
|
|
232
247
|
throw new TypeError("Code must be an array of numbers between 0 and 255");
|
|
233
248
|
const t = this.#e(e);
|
|
234
249
|
await this.appendToQueue(t, "custom");
|
|
235
250
|
}
|
|
236
251
|
}
|
|
237
252
|
export {
|
|
238
|
-
|
|
253
|
+
f as Hopper
|
|
239
254
|
};
|
package/dist/jofemar.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const l=require("./kernel-Dizfdw3M.cjs"),i=require("./relay-E3NCcSjS.cjs"),f=require("./webserial-core-YjdXyVOx.cjs");class v extends l.Kernel{__device={type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}};constructor({filters:t=null,config_port:e=null,no_device:n=1,device_listen_on_port:r=1,type:a="esplus",support_cart:o=!0,socket:c=!1}={}){if(super({filters:t,config_port:e,no_device:n,device_listen_on_port:r,socket:c}),this.__internal__.device.type="jofemar",f.a.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);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={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=a,this.supportCart=o,this.#h(),f.a.add(this),this.#l()}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnChannel(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set listenOnPort(t){this.listenOnChannel=t}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}#h(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)}#l(){this.on("internal:dispense:running",this.#q.bind(this))}serialSetConnectionConstant(t=1){return i.o.connection({channel:t})}async#s(){if(this.__internal__.dispense.elevator.locking_interval)return;this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await l.wait(500));const t=this;return this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(e=>{t.__internal__.dispense.elevator.locking_interval=setInterval(()=>{t.dispatch("dispensing:withdrawal",{elevator:!0,seconds:t.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),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))},1e3)})}#d(t,e){return e.name="ok",e.description="The last command was executed successfully",e.no_code=1,this.dispatch("command-executed",e),e}#p(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const n={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"};return e.additional.ascii=n[t]??null,e.name="Key pressed",e.description=`The key ${e.additional.ascii} was pressed`,e.no_code=2,this.dispatch("keyboard:pressed",e.additional),e}#u(t,e){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}#_(t,e){e.no_code=404;let n=t[5]??null;return n&&this.listenOnChannel>1&&(n=this.hexToDec(n)-this.listenOnChannel+1,n=this.decToHex(n)),n&&(n==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):n==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e}#f(t,e){e.no_code=39,e.name="Program version";const n=t.slice(4,12),r=n.map(a=>String.fromCharCode(this.hexToDec(a))).join("");return e.additional={version:r,hex:n},e.description=`The program version is ${r}`,this.dispatch("program:version",e.additional),e}#y(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const n=t.slice(4,-3);if(n.length>1&&n[0]!=="30"){e.description="Machine has faults";const r={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const a of n)r[a]&&(e.additional.faults.push(r[a]),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e}#v(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const n=t.slice(4,-3),r=n.map(_=>String.fromCharCode(this.hexToDec(_))).join(""),[a,o]=r.split(" "),[c,h]=a.split(":"),[s,d,p]=o.split("-"),u=new Date(2e3+parseInt(p),parseInt(d)-1,parseInt(s),parseInt(c),parseInt(h));return e.additional={day:s,month:d,year:p,hours:c,minutes:h,formatted:r,date:u,hex:n},this.dispatch("clock:registers",e.additional),e}#C(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const n=String.fromCharCode(this.hexToDec(t[4]));if(n!=="0"){const r=t.slice(5,-3);if(n==="T"&&r.length===4){const a=String.fromCharCode(this.hexToDec(r[0])),o=String.fromCharCode(this.hexToDec(r[1])),c=String.fromCharCode(this.hexToDec(r[3]));e.additional={ascii:n,type:"DU.d",dozens:a,units:o,decimals:c,time:parseFloat(`${a}${o}.${c}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(n)&&r.length===3){const a=String.fromCharCode(this.hexToDec(r[0])),o=String.fromCharCode(this.hexToDec(r[1])),c=String.fromCharCode(this.hexToDec(r[2])),h=parseInt(`${a}${o}${c}`),s={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:a,dozens:o,decimals:c,channel:h,selection:h-109,ascii:n,meaning:s[n]??"Unknown"}}else if(r.length===13){const a=r.map(y=>String.fromCharCode(this.hexToDec(y))).join(""),o=parseInt(a.slice(0,2)),c=parseInt(a.slice(2,4)),h=parseInt(a.slice(4,6)),s=parseInt(a.slice(7,9)),d=parseInt(a.slice(9,11))-1,p=2e3+parseInt(a.slice(11,13)),u=new Date(p,d,s,o,c,h),_={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:u,hex:r,formatted:u.toLocaleString(),ascii:n,meaning:_[n]??"Unknown"}}}return this.dispatch("machine:activity",e.additional),e}#T(t,e){const n={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${n[t]??"unknown"}`,e.additional={hex:t,language:n[t]??"unknown"},this.dispatch("check:language",e.additional),e}#k(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e}#m(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const n=this.hexToDec(t)-139;return e.additional={hex:t,tray:n},this.dispatch("check:isolation-tray",e.additional),e}#w(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const n=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:n},this.dispatch("check:engine-voltage",e.additional),e}#b(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const n=t==="30";return e.additional={hex:t,push:n},this.dispatch("check:push-over",e.additional),e}#x(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const n=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:n},this.dispatch("check:extractor-after-dispense",e.additional),e}#E(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const n=this.hexToDec(t)-128;return e.additional={hex:t,seconds:n},this.dispatch("check:standby-after-collect",e.additional),e}#D(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:standby-without-collect",e.additional),e}#O(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const n=t==="30"?"low":"high";return e.additional={hex:t,speed:n},this.dispatch("check:elevator-speed",e.additional),e}#M(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const n=t==="31";return e.additional={hex:t,enabled:n},this.dispatch("check:expiration-by-temperature",e.additional),e}#I(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const n=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:n},this.dispatch("check:temperature-before-expiration",e.additional),e}#S(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:expiration-after",e.additional),e}#P(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const n=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:n},this.dispatch("check:temperature-scale",e.additional),e}#Q(t,e){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}#g(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e}#A(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},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}#B(t,e,n=128){if(t[1]&&(e.additional.machine.hex=t[1],e.additional.machine.dec=this.hexToDec(t[1])-n),!(t[1]&&t[2]))e=this.#d(t,e);else switch(t[2]){case"54":e.request="--automatic",e=this.#p(t[3],e);break;case"50":e.request="--automatic",e=this.#u(t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=this.#C(t,e);break;case"43":e.request="channel-status",e=this.#_(t,e);break;case"50":e=this.#f(t,e);break;case"53":e=this.#y(t,e);break;case"54":e.request="working-temperature",e=this.#g(t[4],e);break;case"72":e=this.#v(t,e);break;case"74":e.request="current-temperature",e=this.#A(t,e);break;case"49":e=this.#T(t[4],e);break;case"5a":e=this.#k(t[4],e);break;case"42":e=this.#m(t[4],e);break;case"47":e=this.#w(t[4],e);break;case"4e":e=this.#Q(t,e);break;case"4f":e=this.#b(t[4],e);break;case"45":e=this.#x(t[4],e);break;case"46":e=this.#E(t[4],e);break;case"48":e=this.#D(t[4],e);break;case"76":e=this.#O(t[4],e);break;case"63":e=this.#M(t[4],e);break;case"65":e=this.#I(t[4],e);break;case"66":e=this.#S(t[4],e);break;case"67":e=this.#P(t[4],e);break}break}return e}#n(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)}#e(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)}#a(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")}#t({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})}#i({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})}#W(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,this.#n();break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,this.#e(),this.#t({type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,this.#e(),this.#t({type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,this.#e(),this.#t({type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,this.#e(),this.#i({type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,this.#e(),this.#i({type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,this.#e(),this.#i({type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,this.#e(),this.#i({type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,this.#a(),this.#t({type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,this.#n(),this.#t({type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,this.#e(),this.#t({type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,this.#n(),this.#t({type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,this.#e(),this.#i({type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,this.#e(),this.#i({type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,this.#n(),this.#t({type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,this.#n(),this.#t({type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,this.#n(),this.#t({type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,this.#n(),this.#t({type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,this.#e(),this.#i({type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,this.#e(),this.#t({type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,this.#e(),this.#i({type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,this.#a(),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),this.#i({type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,this.#e(),this.#i({type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,this.#a();break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,this.#n(),this.#t({type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,this.#n(),this.#t({type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,this.#n(),this.#t({type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,this.#n(),this.#t({type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&this.#e();return e}serialMessage(t){t=this.fixHexArray(t);const e=128;let n={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":n=this.#B(t,n,e);break;case"06":n=this.#W(t,n);break;case"15":n.name="Checksum error",n.description="The calculated checksum does not match the received checksum",n.no_code=38,this.#e();break;default:n.name="unknown",n.description="The message received is unknown",n.no_code=404;break}this.dispatch("serial:message",n)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){const n=i.o.dispense({selection:t,cart:e,machineChannel:this.listenOnChannel}),r=n[5],a=n[6];this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:a,tray:r};let o;do o=await this.internalDispense(n),this.#F(),o.error==="elevator-locked"?await this.#s():o.error==="no-response"&&await l.wait(1e3);while(["elevator-locked","no-response"].includes(o.error));return this.__internal__.dispense.backup_dispense={},o}#F(){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}#q(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval);const t=this;t.__internal__.dispense.timeout=setTimeout(()=>{t.__internal__.dispense.interval=setInterval(()=>{t.status().then(()=>{})},t.__internal__.dispense.interval_time)},t.__internal__.dispense.timeout_time)}internalClearSensing(){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"))}async endDispense(){const t=i.o.endCartDispense({machineChannel:this.listenOnChannel});return await this.internalDispense(t)}async collect(){return await this.appendToQueue(i.o.collect({machineChannel:this.listenOnChannel}),"collect")}async#r(t){return await this.appendToQueue(i.o.reset({machineChannel:this.listenOnChannel,type:t}),"reset")}async resetSoldOutErrors(){return await this.#r("soldOut")}async resetWaitingProductRemovedError(){return await this.#r("waiting")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(this.#o(),await this.#r("machine")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await this.#r("machine"),this.#o(),t(!0))},100)})}#o(){const t=this.__device.type==="iceplus"?l.getSeconds(40):l.getSeconds(25),e=new Date,n=1e3*t+e.getTime(),r=new Date(n);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:r})}async resetAllErrors(){return await this.resetWaitingProductRemovedError(),await l.wait(200),await this.resetSoldOutErrors(),await l.wait(400),await this.resetMachineErrors()}async status(){return await this.appendToQueue(i.o.status({machineChannel:this.listenOnChannel}),"status")}async#c(t){return await this.appendToQueue(i.o.lights({machineChannel:this.listenOnChannel,type:t}),"lights")}async lightsOn(){return await this.#c("on")}async lightsOff(){return await this.#c("off")}async program(t,e){return await this.appendToQueue(i.o.program({machineChannel:this.listenOnChannel,param1:t,param2:e}),"program")}async programDisplayLanguage({language:t="spanish"}={}){return await this.appendToQueue(i.o.programDisplayLanguage({machineChannel:this.listenOnChannel,language:t}),"program")}async programBeeper({enable:t=!0}={}){return await this.appendToQueue(i.o.programBeeper({machineChannel:this.listenOnChannel,enable:t}),"program")}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.appendToQueue(i.o.programDisableWorkingTemperature({machineChannel:this.listenOnChannel}),"program")}async programDisableThermometer(){return await this.appendToQueue(i.o.programDisableThermometer({machineChannel:this.listenOnChannel}),"program")}async programWorkingTemperature({degrees:t=.5}={}){return await this.appendToQueue(i.o.programWorkingTemperature({machineChannel:this.listenOnChannel,degrees:t,machineType:this.__device.type}),"program")}async programIsolationTray({tray:t=0}={}){return await this.appendToQueue(i.o.programIsolationTray({machineChannel:this.listenOnChannel,tray:t}),"program")}async programTimeToStandbyAfterCollect({seconds:t=15}={}){return await this.appendToQueue(i.o.programTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel,seconds:t}),"program")}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){return await this.appendToQueue(i.o.programTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programElevatorSpeed({speed:t="high"}={}){return await this.appendToQueue(i.o.programElevatorSpeed({machineChannel:this.listenOnChannel,speed:t}),"program")}async programTemperatureExpiration({enable:t=!1}={}){return await this.appendToQueue(i.o.programTemperatureExpiration({machineChannel:this.listenOnChannel,enable:t}),"program")}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){return await this.appendToQueue(i.o.programMachineAddress({machineChannel:this.listenOnChannel,address:t}),"program")}async programTemperatureBeforeExpiration({degrees:t=.5}={}){return await this.appendToQueue(i.o.programTemperatureBeforeExpiration({machineChannel:this.listenOnChannel,degrees:t}),"program")}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){return await this.appendToQueue(i.o.programTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programTemperatureScale({scale:t="celsius"}={}){return await this.appendToQueue(i.o.programTemperatureScale({machineChannel:this.listenOnChannel,scale:t}),"program")}async programVoltageEngine({selection:t=1,voltage:e=5}={}){return await this.appendToQueue(i.o.programVoltageEngine({machineChannel:this.listenOnChannel,selection:t,voltage:e}),"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){return await this.appendToQueue(i.o.programPushOverProducts({machineChannel:this.listenOnChannel,selection:t,enable:e}),"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){return await this.appendToQueue(i.o.programChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t,seconds:e}),"channel-running-after-dispense")}async checkData(t,e="FF"){return await this.appendToQueue(i.o.checkData({machineChannel:this.listenOnChannel,type:t,aux:e}),"check-data")}async getDisplayLanguage(){return await this.appendToQueue(i.o.getDisplayLanguage({machineChannel:this.listenOnChannel}),"check-data")}async getBeeper(){return await this.appendToQueue(i.o.getBeeper({machineChannel:this.listenOnChannel}),"check-data")}async getWorkingTemperature(){return await this.appendToQueue(i.o.getWorkingTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getIsolationTray(){return await this.appendToQueue(i.o.getIsolationTray({machineChannel:this.listenOnChannel}),"check-data")}async getProgramVersion(){return await this.appendToQueue(i.o.getProgramVersion({machineChannel:this.listenOnChannel}),"check-data")}async getFaults(){return await this.appendToQueue(i.o.getFaults({machineChannel:this.listenOnChannel}),"check-data")}async getMachineId(){return await this.appendToQueue(i.o.getMachineId({machineChannel:this.listenOnChannel}),"check-data")}async getCurrentTemperature(){return await this.appendToQueue(i.o.getCurrentTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyAfterCollect(){return await this.appendToQueue(i.o.getTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyWithoutCollect(){return await this.appendToQueue(i.o.getTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel}),"check-data")}async getElevatorSpeed(){return await this.appendToQueue(i.o.getElevatorSpeed({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureExpiration(){return await this.appendToQueue(i.o.getTemperatureExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureBeforeExpiration(){return await this.appendToQueue(i.o.getTemperatureBeforeExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTimeBeforeExpirationByTemperature(){return await this.appendToQueue(i.o.getTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureScale(){return await this.appendToQueue(i.o.getTemperatureScale({machineChannel:this.listenOnChannel}),"check-data")}async getClockRegisters(){return await this.appendToQueue(i.o.getClockRegisters({machineChannel:this.listenOnChannel}),"check-data")}async getMachineActivity(){return await this.appendToQueue(i.o.getMachineActivity({machineChannel:this.listenOnChannel}),"check-data")}async getVoltageEngine({selection:t=1}={}){return await this.appendToQueue(i.o.getVoltageEngine({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelPresence({selection:t=1}={}){return await this.appendToQueue(i.o.getChannelPresence({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getPushOverProducts({selection:t=1}={}){return await this.appendToQueue(i.o.getPushOverProducts({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelRunningAfterDispense({selection:t=1}={}){return await this.appendToQueue(i.o.getChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async setDisplayStandbyMessage({message:t=""}={}){return await this.appendToQueue(i.o.setDisplayStandbyMessage({machineChannel:this.listenOnChannel,message:t}),"display")}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){return this.appendToQueue(i.o.setDisplayMessageTemporarily({machineChannel:this.listenOnChannel,message:t,seconds:e}),"display")}async setDisplayMessageUnlimited({message:t=""}){return await this.appendToQueue(i.o.setDisplayMessageUnlimited({machineChannel:this.listenOnChannel,message:t}),"display")}async programClock({date:t=new Date}={}){return await this.appendToQueue(i.o.programClock({machineChannel:this.listenOnChannel,date:t}),"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){return await this.appendToQueue(i.o.eventsConfig({machineChannel:this.listenOnChannel,event:t,enable:e}),"events-config")}async eventEnable({event:t=null}={}){return await this.appendToQueue(i.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async eventDisable({event:t=null}={}){return await this.appendToQueue(i.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async sendCustomCode({code:t=[]}={}){return await this.appendToQueue(i.o.sendCustomCode({machineChannel:this.listenOnChannel,code:t}),"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let n=t;n<=e;n++)this.__device.channels.verification.current=n,await this.getChannelPresence({selection:n});return new Promise(n=>{let r=setInterval(()=>{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))},500)})}}exports.Jofemar=v;
|
|
1
|
+
"use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const h=require("./kernel-C1HLYiV1.cjs"),i=require("./relay-E3NCcSjS.cjs");class y extends h.Kernel{__device={type:"esplus",support_cart:!1,withdraw:{in_process:!1,seconds:60,interval:0},cart:{in_process:!1},channels:{verification:{clear(){this.running=!1,this.current=1,this.channels=[]},running:!1,start:1,end:80,current:1,channels:[]}}};constructor({filters:t=null,config_port:e,no_device:n=1,device_listen_on_channel:r=1,type:a="esplus",support_cart:o=!0,socket:c=!1}={}){if(super({filters:t,config_port:e,no_device:n,device_listen_on_channel:r,socket:c}),this.__internal__.device.type="jofemar",h.Devices.getCustom(this.typeDevice,n))throw new Error(`Device ${this.typeDevice} ${n} already exists`);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={locking_time:60,locking_interval:0,need_reset:!1},this.deviceType=a,this.supportCart=o,this.#h(),h.Devices.add(this),this.#l()}set startChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid start channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid start channel verification, valid range is 1 to 126");this.__device.channels.verification.start=e}set endChannelVerification(t){const e=parseInt(t);if(isNaN(e))throw new Error("Invalid end channel verification, must be a number");if(e<1||e>126)throw new Error("Invalid end channel verification, valid range is 1 to 126");this.__device.channels.verification.end=e}set listenOnChannel(t){if(t=parseInt(t),isNaN(t)||t<1||t>31)throw new Error("Invalid port number, valid range is 1 to 31");this.__internal__.device.listen_on_port=t,this.__internal__.serial.bytes_connection=this.serialSetConnectionConstant(t),this.__internal__.device.hex_number=(128+t).toString(16)}set listenOnPort(t){this.listenOnChannel=t}set deviceType(t){if(typeof t!="string")throw new Error("Invalid device type, must be a string");this.__device.type=t}set supportCart(t){if(typeof t!="boolean")throw new Error("Invalid support cart, must be a boolean");this.__device.support_cart=t}#h(){const t=["dispensing:withdrawal","command-executed","keyboard:pressed","door:event","program:version","machine:faults","clock:registers","machine:activity","check:language","check:beeper","check:isolation-tray","check:engine-voltage","check:push-over","check:extractor-after-dispense","check:standby-after-collect","check:standby-without-collect","check:elevator-speed","check:expiration-by-temperature","check:temperature-before-expiration","check:expiration-after","check:temperature-scale","check:machine-id","temperature:working","temperature:current","jofemar:warning","jofemar:error","serial:message","reset:errors","channels","channel:status","machine:status"];for(const e of t)this.serialRegisterAvailableListener(e)}#l(){this.on("internal:dispense:running",this.#q.bind(this))}serialSetConnectionConstant(t=1){return i.o.connection({channel:t})}async#s(){if(!this.__internal__.dispense.elevator.locking_interval)return this.__internal__.dispense.elevator.need_reset&&(this.__internal__.dispense.elevator.need_reset=!1,await this.resetWaitingProductRemovedError(),await h.wait(500)),this.__internal__.dispense.status="elevator-locked",this.__internal__.dispense.elevator.locking_time=60,new Promise(t=>{this.__internal__.dispense.elevator.locking_interval=setInterval(()=>{this.dispatch("dispensing:withdrawal",{elevator:!0,seconds:this.__internal__.dispense.elevator.locking_time,description:"Please recall products from the elevator"}),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))},1e3)})}#d(t){return t.name="ok",t.description="The last command was executed successfully",t.no_code=1,this.dispatch("command-executed",t),t}#p(t,e){e.additional={hex:t,dec:this.hexToDec(t),ascii:null};const n={30:"0",31:"1",32:"2",33:"3",34:"4",35:"5",36:"6",37:"7",38:"8",39:"9","2a":"*",23:"#",41:"A",42:"B",43:"C",44:"D"},r=t.toString().toLowerCase();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}#u(t,e){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}#_(t,e){e.no_code=404;let n=t[5]??null;return n&&this.listenOnChannel>1&&(n=this.hexToDec(n)-this.listenOnChannel+1,n=this.decToHex(n)),n&&(n==="FD"?(e.no_code=4,e.name="channel disconnected",e.description="The channel is disconnected",e.additional={active:!1}):n==="FC"?(e.no_code=5,e.name="channel connected",e.description="The channel is connected",e.additional={active:!0}):(e.no_code=6,e.name="channel sold out",e.description="The channel is empty",e.additional={active:!0}),this.__device.channels.verification.running&&(this.__device.channels.verification.channels.push({selection:this.__device.channels.verification.current,active:e.additional.active}),e.additional.selection=this.__device.channels.verification.current),this.dispatch("channel:status",e.additional)),e}#f(t,e){e.no_code=39,e.name="Program version";const n=t.slice(4,12),r=n.map(a=>String.fromCharCode(this.hexToDec(a))).join("");return e.additional={version:r,hex:n},e.description=`The program version is ${r}`,this.dispatch("program:version",e.additional),e}#y(t,e){e.no_code=39,e.name="Machine faults",e.description="No faults detected",e.additional={no_faults:0,faults:[]};const n=t.slice(4,-3);if(n.length>1&&n[0]!=="30"){e.description="Machine has faults";const r={31:"Busy",32:"Invalid tray",33:"Invalid channel",34:"Empty channel",35:"Jam in elevator engine",36:"Malfunction in the elevator belt or product detector",37:"Failure in one of the photo transistors in the cabinet",38:"No channels detected",39:"Product detector fault",41:"Machine display is disconnected",42:"Product alarm under elevator",43:"Error when elevator approaching to a position",44:"Fault in keyboard",45:"Eeprom writing error",46:"Fault communicating with temperature control",47:"The thermometer is disconnected",48:"Thermometer programming lost",49:"Thermometer faulty","4a":"Channels power consumption detector faulty","4b":"Elevator does not find channel or tray","4c":"Elevator does not find delivery product position","4d":"Interior of elevator blocked","4e":"Error in tester of product detector","4f":"Waiting for product to be removed",50:"Product expired by temperature reasons",51:"Automatic door faulty",59:"Product is expired","5a":"Product is expired",61:"Product is expired",62:"Product is expired",63:"Product is expired",64:"Product detector didn't change during its verification test"};for(const a of n)r[a]&&e.additional.faults&&typeof e.additional.no_faults<"u"&&(e.additional.faults.push(r[a]||"Unknown fault"),e.additional.no_faults++)}return this.dispatch("machine:faults",e.additional),e}#v(t,e){e.no_code=40,e.name="Clock registers",e.description="Clock registers";const n=t.slice(4,-3),r=n.map(_=>String.fromCharCode(this.hexToDec(_))).join(""),[a,o]=r.split(" "),[c,l]=a.split(":"),[s,d,p]=o.split("-"),u=new Date(2e3+parseInt(p),parseInt(d)-1,parseInt(s),parseInt(c),parseInt(l));return e.additional={day:s,month:d,year:p,hours:c,minutes:l,formatted:r,date:u,hex:n},this.dispatch("clock:registers",e.additional),e}#C(t,e){e.no_code=41,e.name="Machine activity",e.description="Events from read machine activity";const n=String.fromCharCode(this.hexToDec(t[4]));if(n!=="0"){const r=t.slice(5,-3);if(n==="T"&&r.length===4){const a=String.fromCharCode(this.hexToDec(r[0])),o=String.fromCharCode(this.hexToDec(r[1])),c=String.fromCharCode(this.hexToDec(r[3]));e.additional={ascii:n,type:"DU.d",dozens:a,units:o,decimals:c,time:parseFloat(`${a}${o}.${c}`),meaning:"Extraction time (in seconds)"}}else if(["B","D","E","F","G"].includes(n)&&r.length===3){const a=String.fromCharCode(this.hexToDec(r[0])),o=String.fromCharCode(this.hexToDec(r[1])),c=String.fromCharCode(this.hexToDec(r[2])),l=parseInt(`${a}${o}${c}`),s={B:"Error on going to tray channel",D:"Error on product detector",E:"Extraction of channel ok",F:"Error on engine intensity detection",G:"Error on product exit door"};e.additional={type:"HDU",hundreds:a,dozens:o,decimals:c,channel:l,selection:l-109,ascii:n,meaning:s[n]||"Unknown"}}else if(r.length===13){const a=r.map(f=>String.fromCharCode(this.hexToDec(f))).join(""),o=parseInt(a.slice(0,2)),c=parseInt(a.slice(2,4)),l=parseInt(a.slice(4,6)),s=parseInt(a.slice(7,9)),d=parseInt(a.slice(9,11))-1,p=2e3+parseInt(a.slice(11,13)),u=new Date(p,d,s,o,c,l),_={A:"Attempt to close product exit door",C:"Closing of exterior door",H:"Error on opening of product exit door",I:"New attempt to arrive at product exit position after an error on first attempt",J:"Power on cooling unit",K:"Power off cooling unit",L:"Start of defrosting",M:"End of defrosting",O:"Opening of exterior door",R:"Memory reset",S:"Error on going to product exit position",Y:"Power on machine",Z:"Power off machine",c:"Closing of inner door",e:"New attempt to extract from channel due no product detection when elevator arrived to product exit position",o:"Opening of inner door"};e.additional={type:"hhmmssWddMMAA",date:u,hex:r,formatted:u.toLocaleString(),ascii:n,meaning:_[n]||"Unknown"}}}return this.dispatch("machine:activity",e.additional),e}#T(t,e){const n={30:"Spanish",31:"English",32:"French"};return e.no_code=42,e.name="Language",e.description=`The language is ${n[t]||"unknown"}`,e.additional={hex:t,language:n[t]||"unknown"},this.dispatch("check:language",e.additional),e}#k(t,e){return e.no_code=43,e.name="Beeper",e.description=`The beeper is ${t==="30"?"on":"off"}`,e.additional={hex:t,beeper:t==="30"},this.dispatch("check:beeper",e.additional),e}#m(t,e){e.no_code=44,e.name="Isolation tray",e.description="Isolation tray";const n=this.hexToDec(t)-139;return e.additional={hex:t,tray:n},this.dispatch("check:isolation-tray",e.additional),e}#w(t,e){e.no_code=45,e.name="Engine voltage",e.description="Engine voltage";const n=(this.hexToDec(t)-128)/2+5;return e.additional={hex:t,voltage:n},this.dispatch("check:engine-voltage",e.additional),e}#b(t,e){e.no_code=46,e.name="Push over",e.description="Push over";const n=t==="30";return e.additional={hex:t,push:n},this.dispatch("check:push-over",e.additional),e}#x(t,e){e.no_code=47,e.name="Extractor after dispense",e.description="Extractor after dispense";const n=(this.hexToDec(t)-128)/10;return e.additional={hex:t,seconds:n},this.dispatch("check:extractor-after-dispense",e.additional),e}#E(t,e){e.no_code=48,e.name="Standby after collect",e.description="Time to standby after collect product";const n=this.hexToDec(t)-128;return e.additional={hex:t,seconds:n},this.dispatch("check:standby-after-collect",e.additional),e}#D(t,e){e.no_code=49,e.name="Standby without collect",e.description="Time to standby when product delivery is not collected";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:standby-without-collect",e.additional),e}#O(t,e){e.no_code=50,e.name="Elevator speed",e.description="Elevator speed";const n=t==="30"?"low":"high";return e.additional={hex:t,speed:n},this.dispatch("check:elevator-speed",e.additional),e}#M(t,e){e.no_code=51,e.name="Temperature expiration",e.description="Temperature expiration";const n=t==="31";return e.additional={hex:t,enabled:n},this.dispatch("check:expiration-by-temperature",e.additional),e}#I(t,e){e.no_code=52,e.name="Temperature before expiration",e.description="Temperature before expiration";const n=(this.hexToDec(t)-128)/2;return e.additional={hex:t,temperature:n},this.dispatch("check:temperature-before-expiration",e.additional),e}#S(t,e){e.no_code=53,e.name="Time before expiration",e.description="Time before expiration";const n=this.hexToDec(t)-128;return e.additional={hex:t,minutes:n},this.dispatch("check:expiration-after",e.additional),e}#P(t,e){e.no_code=54,e.name="Temperature scale",e.description="Temperature scale";const n=t==="43"?"Celsius":"Fahrenheit";return e.additional={hex:t,scale:n},this.dispatch("check:temperature-scale",e.additional),e}#Q(t,e){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}#g(t,e){return e.no_code=7,e.name="working temperature",e.description=`The working temperature is ${t}`,e.additional={hex:t,temperature:{traditional:(this.hexToDec(t)-this.hexToDec("80"))/2,ice_plus:(this.hexToDec(t)-this.hexToDec("80"))/2-25.5}},this.dispatch("temperature:working",e.additional),e}#A(t,e){return e.no_code=8,e.name="current temperature",e.additional={sign:null,tens:null,units:null,decimals:null,type_degrees:null,formatted:null,decimal_point:t[7]==="2e"?".":null,degrees:t[9]==="7f"?"°":null,error:null},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}#B(t,e,n=128){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]))e=this.#d(e);else switch(t[2]){case"54":e.request="--automatic",e=this.#p(t[3],e);break;case"50":e.request="--automatic",e=this.#u(t[3],e);break;case"43":switch(e.request="check-data",t[3]){case"41":e=this.#C(t,e);break;case"43":e.request="channel-status",e=this.#_(t,e);break;case"50":e=this.#f(t,e);break;case"53":e=this.#y(t,e);break;case"54":e.request="working-temperature",e=this.#g(t[4],e);break;case"72":e=this.#v(t,e);break;case"74":e.request="current-temperature",e=this.#A(t,e);break;case"49":e=this.#T(t[4],e);break;case"5a":e=this.#k(t[4],e);break;case"42":e=this.#m(t[4],e);break;case"47":e=this.#w(t[4],e);break;case"4e":e=this.#Q(t,e);break;case"4f":e=this.#b(t[4],e);break;case"45":e=this.#x(t[4],e);break;case"46":e=this.#E(t[4],e);break;case"48":e=this.#D(t[4],e);break;case"76":e=this.#O(t[4],e);break;case"63":e=this.#M(t[4],e);break;case"65":e=this.#I(t[4],e);break;case"66":e=this.#S(t[4],e);break;case"67":e=this.#P(t[4],e);break}break}return e}#n(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!0)}#e(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status=!1)}#a(){this.__internal__.dispense.dispensing&&(this.__internal__.dispense.status="elevator-locked")}#t({type:t=null,severity:e="low"}={}){this.dispatch("jofemar:warning",{type:t,severity:e})}#i({type:t=null,severity:e="high"}={}){this.dispatch("jofemar:error",{type:t,severity:e})}#W(t,e){if(e.request="status",t[1]&&!t[2]){switch(t[1]){case"30":e.name="Machine ready",e.description="The machine is ready for instructions",e.no_code=9,this.#n();break;case"31":e.name="Machine busy",e.description="The machine is busy right now",e.no_code=10;break;case"32":e.name="Invalid tray",e.description="The tray requested is invalid",e.no_code=11,this.#e(),this.#t({type:"invalid-tray"});break;case"33":e.name="Invalid channel",e.description="The channel requested is invalid",e.no_code=12,this.#e(),this.#t({type:"invalid-channel"});break;case"34":e.name="Empty channel",e.description="The channel requested is empty",e.no_code=13,this.#e(),this.#t({type:"empty-channel"});break;case"35":e.name="Jam",e.description="Jam in elevator engine",e.no_code=14,this.#e(),this.#i({type:"jam"});break;case"36":e.name="Malfunction",e.description="Malfunction in the elevator belt or product detector",e.no_code=15,this.#e(),this.#i({type:"malfunction"});break;case"37":e.name="Photo transistors",e.description="Failure in one of the photo transistors in the cabinet",e.no_code=16,this.#e(),this.#i({type:"photo-transistors"});break;case"38":e.name="Without channels",e.description="No channels detected",e.no_code=17,this.#e(),this.#i({type:"without-channels"});break;case"39":e.name="Product detector fault",e.description="Product detector fault",e.no_code=18,this.#a(),this.#t({type:"fault-product-detector"});break;case"41":e.name="Fault in 485 BUS",e.description="Machine display is disconnected",e.no_code=19,this.#n(),this.#t({type:"display-disconnected"});break;case"42":e.name="Product under elevator",e.description="Product alarm under elevator",e.no_code=20,this.#e(),this.#t({type:"product-under-elevator"});break;case"43":e.name="Error when elevator approaching to a position",e.description="Error when elevator approaching to a position",e.no_code=21,this.#n(),this.#t({type:"error-approaching-position",severity:"high"});break;case"44":e.name="Fault in keyboard",e.description="Fault in keyboard",e.no_code=22,this.#e(),this.#i({type:"fault-keyboard"});break;case"45":e.name="Eeprom writing error",e.description="Eeprom writing error",e.no_code=23,this.#e(),this.#i({type:"eeprom-writing-error",severity:"critical"});break;case"46":e.name="Fault communicating with temperature control",e.description="Fault communicating with temperature control",e.no_code=24,this.#n(),this.#t({type:"fault-temperature-control"});break;case"47":e.name="Thermometer disconnected",e.description="The thermometer is disconnected",e.no_code=25,this.#n(),this.#t({type:"thermometer-disconnected"});break;case"48":e.name="Thermometer programming lost",e.description="Thermometer programming lost",e.no_code=26,this.#n(),this.#t({type:"thermometer-programming-lost"});break;case"49":e.name="Thermometer faulty",e.description="Thermometer faulty",e.no_code=27,this.#n(),this.#t({type:"thermometer-faulty"});break;case"4a":e.name="Channels power consumption detector faulty",e.description="Channels power consumption detector faulty",e.no_code=28,this.#e(),this.#i({type:"channels-power-consumption-detector-faulty",severity:"critical"});break;case"4b":e.name="Elevator does not find channel or tray",e.description="Elevator does not find channel or tray",e.no_code=29,this.#e(),this.#t({type:"elevator-not-find-channel-tray"});break;case"4c":e.name="Elevator does not find delivery product position",e.description="Elevator does not find delivery product position",e.no_code=30,this.#e(),this.#i({type:"elevator-not-find-delivery-position"});break;case"4d":e.name="Interior of elevator blocked",e.description="Interior of elevator blocked",e.no_code=31,this.#a(),this.__internal__.dispense.elevator.need_reset||(this.__internal__.dispense.elevator.need_reset=!0),this.#i({type:"interior-elevator-blocked",severity:"low"});break;case"4e":e.name="Error in tester of product detector",e.description="Error in tester of product detector",e.no_code=32,this.#e(),this.#i({type:"error-tester-product-detector"});break;case"4f":e.name="Waiting for product to be removed",e.description="Waiting for product to be removed",e.no_code=33,this.#a();break;case"50":e.name="Product expired by temperature reasons",e.description="Product expired by temperature reasons",e.no_code=34,this.#n(),this.#t({type:"product-expired-temperature"});break;case"51":e.name="Automatic door faulty",e.description="Automatic door faulty",e.no_code=35,this.#n(),this.#t({type:"automatic-door-faulty"});break;case"59":case"5a":case"61":case"62":case"63":switch(e.name="Product is expired",e.description="Product is expired",e.additional={nsf_alarm:1},t[1]){case"5a":e.additional.nsf_alarm=2;break;case"61":e.additional.nsf_alarm=3;break;case"62":e.additional.nsf_alarm=4;break;case"63":e.additional.nsf_alarm=5;break}e.no_code=36,this.#n(),this.#t({type:"product-expired"});break;case"64":e.name="Product detector didn't change during its verification test",e.description="Product detector didn't change during its verification test",e.no_code=37,this.#n(),this.#t({type:"automatic-door-faulty"});break}this.dispatch("machine:status",e)}else e.name="executed",e.description="The last command was executed successfully",e.no_code=8,!t[1]&&this.__internal__.dispense.dispensing&&this.#e();return e}serialMessage(t){t=this.fixHexArray(t);const e=128;let n={code:t,name:null,description:null,request:"unknown",no_code:0,additional:{machine:{hex:null,dec:null}}};switch(t[0]){case"02":n=this.#B(t,n,e);break;case"06":n=this.#W(t,n);break;case"15":n.name="Checksum error",n.description="The calculated checksum does not match the received checksum",n.no_code=38,this.#e();break;default:n.name="unknown",n.description="The message received is unknown",n.no_code=404;break}this.dispatch("serial:message",n)}productRemovedContinueDispensing(){this.__internal__.dispense.elevator.locking_interval&&(this.__internal__.dispense.elevator.locking_time=0)}async dispense({selection:t=1,cart:e=!1}={}){const n=i.o.dispense({selection:t,cart:e,machineChannel:this.listenOnChannel}),r=n[5],a=n[6];this.__internal__.dispense.backup_dispense={selection:t,cart:e,channel:a,tray:r};let o;do o=await this.internalDispense(n),this.#F(),o.error==="elevator-locked"?await this.#s():o.error==="no-response"&&await h.wait(1e3);while(["elevator-locked","no-response"].includes(o.error||""));return this.__internal__.dispense.backup_dispense={},o}#F(){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}#q(){this.__internal__.dispense.timeout&&clearTimeout(this.__internal__.dispense.timeout),this.__internal__.dispense.interval&&clearInterval(this.__internal__.dispense.interval),this.__internal__.dispense.timeout=setTimeout(()=>{this.__internal__.dispense.interval=setInterval(()=>{this.status().then(()=>{})},this.__internal__.dispense.interval_time)},this.__internal__.dispense.timeout_time)}internalClearSensing(){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"))}async endDispense(){const t=i.o.endCartDispense({machineChannel:this.listenOnChannel});return await this.internalDispense(t)}async collect(){return await this.appendToQueue(i.o.collect({machineChannel:this.listenOnChannel}),"collect")}async#r(t){return await this.appendToQueue(i.o.reset({machineChannel:this.listenOnChannel,type:t}),"reset")}async resetSoldOutErrors(){return await this.#r("soldOut")}async resetWaitingProductRemovedError(){return await this.#r("waiting")}async resetMachineErrors(){return this.__internal__.serial.queue.length===0?(this.#o(),await this.#r("machine")):new Promise(t=>{const e=setInterval(async()=>{this.__internal__.serial.queue.length>0||(clearInterval(e),await this.#r("machine"),this.#o(),t(!0))},100)})}#o(){const t=this.__device.type==="iceplus"?h.getSeconds(40):h.getSeconds(25),e=new Date,n=1e3*t+e.getTime(),r=new Date(n);this.dispatch("reset:errors",{description:"Resetting machine errors",duration:t,started_at:e,finished_at:r})}async resetAllErrors(){return await this.resetWaitingProductRemovedError(),await h.wait(200),await this.resetSoldOutErrors(),await h.wait(400),await this.resetMachineErrors()}async status(){return await this.appendToQueue(i.o.status({machineChannel:this.listenOnChannel}),"status")}async#c(t){return await this.appendToQueue(i.o.lights({machineChannel:this.listenOnChannel,type:t}),"lights")}async lightsOn(){return await this.#c("on")}async lightsOff(){return await this.#c("off")}async program(t,e){return await this.appendToQueue(i.o.program({machineChannel:this.listenOnChannel,param1:t,param2:e}),"program")}async programDisplayLanguage({language:t="spanish"}={}){return await this.appendToQueue(i.o.programDisplayLanguage({machineChannel:this.listenOnChannel,language:t}),"program")}async programBeeper({enable:t=!0}={}){return await this.appendToQueue(i.o.programBeeper({machineChannel:this.listenOnChannel,enable:t}),"program")}async programDisableWorkingTemperature(){if(this.__device.type==="iceplus")throw new Error("IcePlus does not support disable working temperature");return await this.appendToQueue(i.o.programDisableWorkingTemperature({machineChannel:this.listenOnChannel}),"program")}async programDisableThermometer(){return await this.appendToQueue(i.o.programDisableThermometer({machineChannel:this.listenOnChannel}),"program")}async programWorkingTemperature({degrees:t=.5}={}){return await this.appendToQueue(i.o.programWorkingTemperature({machineChannel:this.listenOnChannel,degrees:t,machineType:this.__device.type}),"program")}async programIsolationTray({tray:t=0}={}){return await this.appendToQueue(i.o.programIsolationTray({machineChannel:this.listenOnChannel,tray:t}),"program")}async programTimeToStandbyAfterCollect({seconds:t=15}={}){return await this.appendToQueue(i.o.programTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel,seconds:t}),"program")}async programTimeToStandbyWithoutCollect({minutes:t=1}={}){return await this.appendToQueue(i.o.programTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programElevatorSpeed({speed:t="high"}={}){return await this.appendToQueue(i.o.programElevatorSpeed({machineChannel:this.listenOnChannel,speed:t}),"program")}async programTemperatureExpiration({enable:t=!1}={}){return await this.appendToQueue(i.o.programTemperatureExpiration({machineChannel:this.listenOnChannel,enable:t}),"program")}async programEnableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!0})}async programDisableTemperatureExpiration(){return await this.programTemperatureExpiration({enable:!1})}async programMachineAddress({address:t=1}={}){return await this.appendToQueue(i.o.programMachineAddress({machineChannel:this.listenOnChannel,address:t}),"program")}async programTemperatureBeforeExpiration({degrees:t=.5}={}){return await this.appendToQueue(i.o.programTemperatureBeforeExpiration({machineChannel:this.listenOnChannel,degrees:t}),"program")}async programTimeBeforeExpirationByTemperature({minutes:t=1}={}){return await this.appendToQueue(i.o.programTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel,minutes:t}),"program")}async programTemperatureScale({scale:t="celsius"}={}){return await this.appendToQueue(i.o.programTemperatureScale({machineChannel:this.listenOnChannel,scale:t}),"program")}async programVoltageEngine({selection:t=1,voltage:e=5}={}){return await this.appendToQueue(i.o.programVoltageEngine({machineChannel:this.listenOnChannel,selection:t,voltage:e}),"voltage-engine")}async programPushOverProducts({selection:t=1,enable:e=!0}={}){return await this.appendToQueue(i.o.programPushOverProducts({machineChannel:this.listenOnChannel,selection:t,enable:e}),"push-over-products")}async programChannelRunningAfterDispense({selection:t=1,seconds:e=0}={}){return await this.appendToQueue(i.o.programChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t,seconds:e}),"channel-running-after-dispense")}async checkData(t,e=255){return await this.appendToQueue(i.o.checkData({machineChannel:this.listenOnChannel,type:t,aux:e}),"check-data")}async getDisplayLanguage(){return await this.appendToQueue(i.o.getDisplayLanguage({machineChannel:this.listenOnChannel}),"check-data")}async getBeeper(){return await this.appendToQueue(i.o.getBeeper({machineChannel:this.listenOnChannel}),"check-data")}async getWorkingTemperature(){return await this.appendToQueue(i.o.getWorkingTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getIsolationTray(){return await this.appendToQueue(i.o.getIsolationTray({machineChannel:this.listenOnChannel}),"check-data")}async getProgramVersion(){return await this.appendToQueue(i.o.getProgramVersion({machineChannel:this.listenOnChannel}),"check-data")}async getFaults(){return await this.appendToQueue(i.o.getFaults({machineChannel:this.listenOnChannel}),"check-data")}async getMachineId(){return await this.appendToQueue(i.o.getMachineId({machineChannel:this.listenOnChannel}),"check-data")}async getCurrentTemperature(){return await this.appendToQueue(i.o.getCurrentTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyAfterCollect(){return await this.appendToQueue(i.o.getTimeToStandbyAfterCollect({machineChannel:this.listenOnChannel}),"check-data")}async getTimeToStandbyWithoutCollect(){return await this.appendToQueue(i.o.getTimeToStandbyWithoutCollect({machineChannel:this.listenOnChannel}),"check-data")}async getElevatorSpeed(){return await this.appendToQueue(i.o.getElevatorSpeed({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureExpiration(){return await this.appendToQueue(i.o.getTemperatureExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureBeforeExpiration(){return await this.appendToQueue(i.o.getTemperatureBeforeExpiration({machineChannel:this.listenOnChannel}),"check-data")}async getTimeBeforeExpirationByTemperature(){return await this.appendToQueue(i.o.getTimeBeforeExpirationByTemperature({machineChannel:this.listenOnChannel}),"check-data")}async getTemperatureScale(){return await this.appendToQueue(i.o.getTemperatureScale({machineChannel:this.listenOnChannel}),"check-data")}async getClockRegisters(){return await this.appendToQueue(i.o.getClockRegisters({machineChannel:this.listenOnChannel}),"check-data")}async getMachineActivity(){return await this.appendToQueue(i.o.getMachineActivity({machineChannel:this.listenOnChannel}),"check-data")}async getVoltageEngine({selection:t=1}={}){return await this.appendToQueue(i.o.getVoltageEngine({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelPresence({selection:t=1}={}){return await this.appendToQueue(i.o.getChannelPresence({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getPushOverProducts({selection:t=1}={}){return await this.appendToQueue(i.o.getPushOverProducts({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async getChannelRunningAfterDispense({selection:t=1}={}){return await this.appendToQueue(i.o.getChannelRunningAfterDispense({machineChannel:this.listenOnChannel,selection:t}),"check-data")}async setDisplayStandbyMessage({message:t=""}={}){return await this.appendToQueue(i.o.setDisplayStandbyMessage({machineChannel:this.listenOnChannel,message:t}),"display")}async setDisplayMessageTemporarily({message:t="",seconds:e=1}){return this.appendToQueue(i.o.setDisplayMessageTemporarily({machineChannel:this.listenOnChannel,message:t,seconds:e}),"display")}async setDisplayMessageUnlimited({message:t=""}){return await this.appendToQueue(i.o.setDisplayMessageUnlimited({machineChannel:this.listenOnChannel,message:t}),"display")}async programClock({date:t=new Date}={}){return await this.appendToQueue(i.o.programClock({machineChannel:this.listenOnChannel,date:t}),"clock")}async eventsConfig({event:t=null,enable:e=!0}={}){return await this.appendToQueue(i.o.eventsConfig({machineChannel:this.listenOnChannel,event:t,enable:e}),"events-config")}async eventEnable({event:t=null}={}){return await this.appendToQueue(i.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async eventDisable({event:t=null}={}){return await this.appendToQueue(i.o.eventEnable({machineChannel:this.listenOnChannel,event:t}),"events-config")}async sendCustomCode({code:t=[]}={code:[]}){return await this.appendToQueue(i.o.sendCustomCode({code:t}),"custom")}async assignChannels(){const t=this.__device.channels.verification.start,e=this.__device.channels.verification.end;if(t>e)throw new Error("Invalid range, start must be less than end");this.__device.channels.verification.clear(),this.__device.channels.verification.running=!0;for(let n=t;n<=e;n++)this.__device.channels.verification.current=n,await this.getChannelPresence({selection:n});return new Promise(n=>{const r=setInterval(()=>{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))},500)})}}exports.Jofemar=y;
|