TSC BAR CODE PRINTER DRIVER (Implemented with TSPL)
const Tspl = require("@dudoo/tsc");
let tspl = new Tspl('192.168.81.68', 9100, (state) => {
console.log(state);
switch(state){
case 'connected':
//STATUS---------------
//tspl.send(Tspl.Status.poll());
//TEXT-----------------
let cmdGrpA = [
Tspl.Sys.size({m:40, n:25, unit:'mm'}),
Tspl.Sys.gap({m:3, n:0, unit:'mm'}),
Tspl.Sys.direction({m:1, n:0}),
Tspl.Sys.cls(),
Tspl.Lb.text({x:10, y:10, content:'TSC 標籤機測試範例'}),
Tspl.Lb.text({x:10, y:40, x_multiplication:1, y_multiplication:1, content:'肚肚奶茶 大杯'}),
Tspl.Sys.print({m:1, n:1})
];
tspl.send(cmdGrpA).then(() => {
}).catch((err) => {
console.log(err);
});
//PUTBMP-----------------
let setup = [
Tspl.Sys.size({m:40, n:25, unit:'mm'}),
Tspl.Sys.gap({m:3, n:0, unit:'mm'}),
Tspl.Sys.direction({m:1, n:0})
];
tspl.printImgLabel(setup, './demo.png').then(() => {
tspl.close();
process.exitCode = 1;
process.exit();
}).catch(err => {
console.log(err);
});
//SOUND----------------
let cmdGrpB = [
Tspl.Sys.sound({level:5, interval:200}),
Tspl.Sys.sound({level:3, interval:200}),
Tspl.Sys.sound({level:3, interval:200}),
Tspl.Sys.sound({level:4, interval:200}),
Tspl.Sys.sound({level:2, interval:200}),
Tspl.Sys.sound({level:2, interval:200}),
Tspl.Sys.sound({level:1, interval:200}),
Tspl.Sys.sound({level:2, interval:200}),
Tspl.Sys.sound({level:3, interval:200}),
Tspl.Sys.sound({level:4, interval:200}),
Tspl.Sys.sound({level:5, interval:200})
];
tspl.send(cmdGrpB).then(() => {
tspl.close();
process.exitCode = 1;
process.exit();
}).catch(err => {
console.log(err);
});
//SELFTEST-------
tspl.send(Tspl.Sys.selftest({page:'ETHERNET'}));
break;
}
}, (data) => {
console.log(Tspl.Status.translate(data));
});
tspl.connect();