forked from lamassu/genmega-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbau.js
91 lines (76 loc) · 2.8 KB
/
bau.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
const genmega = require('./build/Release/genmega.node')
exports.BAUOpen = function BAUOpen(serialPortName) {
const { iRet, data } = genmega.BAUOpenV2(serialPortName);
console.log('BAU Firmware Version: ', data);
if(iRet < 0) console.error('BAU OPEN: ', iRet);
return { iRet };
}
exports.BAUClose = function BAUClose() {
genmega.BAUCloseV2();
}
exports.BAUReset = function BAUReset() {
const { iRet } = genmega.BAUResetV2();
if(iRet < 0) console.error('BAU RESET: ', iRet);
return { iRet };
}
exports.BAUGetLastError = function BAUGetLastError() {
const { data } = genmega.BAUGetLastErrorV2();
return { data };
}
exports.BAUStatus = function BAUStatus() {
const result = {};
const { iRet, data } = genmega.BAUStatusV2();
if(iRet < 0) console.error(`BAU STATUS: ${iRet}`);
if(data === "") console.log(`BAU STATUS EMPTY!`)
const values = data.split("")
result.bLineStatus = values[0];
result.bIdling = values[1];
result.bAccepting = values[2];
result.bEscrow = values[3];
result.bStacking = values[4];
result.bReturning = values[5];
result.bJammed = values[6];
result.bStackerFull = values[7];
result.bCassetteAttached = values[8];
result.bPaused = values[9];
result.bCalibration = values[10];
result.bFailure = values[11];
result.bPushNoPush = values[12];
result.bFlashDownload = values[13];
return { iRet, result };
}
exports.BAUSetCapabilities = function BAUSetCapabilities(escrow_enabled) {
const { iRet } = genmega.BAUSetCapabilitiesV2(escrow_enabled)
if(iRet < 0) console.error(`BAU SET CAPABILITIES: ${iRet}`);
return { iRet }
}
exports.BAUSetEnableDenom = function BAUSetEnableDenom(denominationData) {
const { iRet } = genmega.BAUSetEnableDenomV2(denominationData);
if(iRet < 0) console.error(`BAU SET ENABLE DENOM: ${iRet}`);
return { iRet };
}
exports.BAUCancel = function BAUCancel() {
const { iRet, data } = genmega.BAUCancelV2();
if(iRet < 0) console.error(`BAU CANCEL BILL: ${iRet}`);
return { iRet, data };
}
exports.BAUAcceptBill = function BAUAcceptBill(mode) {
const { iRet, data } = genmega.BAUAcceptBillV2(mode);
if(iRet < 0) console.error(`BAU ACCEPT BILL: ${iRet}`);
return { iRet, data }
}
exports.BAUReject = function BAUReject() {
const { iRet } = genmega.BAUReturnBillV2();
if(iRet < 0) console.error(`BAU RETURN BILL: ${iRet}`);
return { iRet };
}
exports.BAUStack = function BAUStack() {
const { iRet } = genmega.BAUStackBillV2();
if(iRet < 0) console.error(`BAU STACK BILL: ${iRet}`);
return { iRet };
}
exports.BAUGetSupportCurrency = function BAUGetSupportCurrency() {
const { iRet, data } = genmega.BAUGetSupportCurrencyV2();
if(iRet < 0) console.error(`BAU GET SUPPORT CURRENCY: ${iRet}`);
return { iRet, data };
}