forked from farafonov-alexey/node-atol-wrapper
-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.js
65 lines (62 loc) · 1.83 KB
/
index.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
const w = require('./bindings');
const fptr = new w.Fptr10();
console.log(fptr);
fptr.create();
const settings = fptr.getSettings();
console.log('getSettings', settings);
settings.Port = 0; // ComPort communication
// settings.ComFile = '/dev/ttyACM0'; //ComPort name
settings.ComFile = 'COM4'; // ComPort name
settings.BaudRate = 115200;
console.log('setSettings', fptr.setSettings(settings));
console.log('isOpened', fptr.isOpened());
console.log('open', fptr.open());
console.log('isOpened', fptr.isOpened());
console.log('getData', fptr.processJson({type: 'getDeviceStatus'}));
console.log('findLastDocument', fptr.findLastDocument());
// try {
// console.log('fnReport', fptr.fnReport(1));
// } catch (e) {
// console.log('error', e.message, 'code', e.code, 'descr', e.description);
// }
// console.log('openShift', fptr.processJson({
// type: 'openShift',
//
// operator: {
// name: 'Иванов',
// vatin: '123654789507'
// },
//
// postItems: [
// {
// type: 'text',
// text: 'ОТКРЫТА НОВАЯ СМЕНА',
// alignment: 'center',
// doubleWidth: true
// }
// ]
// }));
// console.log('closeShift', fptr.processJson({
// type: 'closeShift',
// operator: {
// name: 'Иванов',
// vatin: '123654789507'
// }
// }));
fptr.processJsonAsync(
{type: 'reportX', operator: {name: 'Иванов', vatin: '123654789507'}},
(err, result) => {
if (err) {
throw err;
} else {
console.log('reportX', result);
fptr.processJsonAsync({type: 'getDeviceStatus'}, (err, result) => {
if (err) {
throw err;
} else {
console.log('getDeviceStatus', result);
console.log('close', fptr.close());
}
})
}
});