Skip to content

Commit

Permalink
测试临界点
Browse files Browse the repository at this point in the history
  • Loading branch information
zhangle committed Feb 28, 2023
1 parent 58c712b commit 746818d
Show file tree
Hide file tree
Showing 4 changed files with 376 additions and 162 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
"dev": "nodemon server.js"
},
"nodemonConfig": {
"restartable": "r",
"ignore": [
"node_modules",
"dist"
Expand Down
212 changes: 57 additions & 155 deletions server.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,15 @@ var closeport;
var sendcommand_utf8;
var sendcommand_binary;
var windowsfont;
var usbprintername

var urlencodedParser = bodyParser.urlencoded({ extended: false });
var urlencodedParser = bodyParser.urlencoded({extended: false});
app.use(bodyParser.urlencoded({
extended: true
}));

app.use(express.static('./'));



app.listen(8888, function () {
console.log("Server Start!!");
})
Expand All @@ -41,32 +39,19 @@ app.get('/test_get', function (req, res) {
});


app.post('/', urlencodedParser,function (req, res) {
app.post('/', urlencodedParser, function (req, res) {
printfile();
res.redirect(req.get('referer'));
});

app.post('/128B', urlencodedParser,function (req, res) {
printfile128B();
res.redirect(req.get('referer'));
});
app.post('/128M', urlencodedParser,function (req, res) {
printfile128M();
res.redirect(req.get('referer'));
});
app.post('/128MB', urlencodedParser,function (req, res) {
printfile128MB();
res.redirect(req.get('referer'));
});

try {
openport = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'openport'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -77,8 +62,7 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'about'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -88,8 +72,7 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'sendcommand'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -100,8 +83,7 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'clearbuffer'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -112,8 +94,7 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'printerfont'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -124,21 +105,18 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'barcode'
});
}
catch (error) {
} catch (error) {
console.log(error);
}



try {
printlabel = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'printlabel'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -149,8 +127,7 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'closeport'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -160,8 +137,7 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'sendcommand_utf8'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -171,8 +147,7 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'sendcommand_binary'
});
}
catch (error) {
} catch (error) {
console.log(error);
}

Expand All @@ -182,130 +157,57 @@ try {
typeName: 'TSCSDK.node_driver',
methodName: 'windowsfont'
});
}
catch (error) {
} catch (error) {
console.log(error);
}


function printfile() {
var label_variable = { quantity: '1', copy: '1' };
openport('TSC TE244', true); // ! 打点打印机TSC的名称
sendcommand(`TEXT 10,20,"0",0,12,12,"111111"`, true);
printlabel(label_variable, true);
closeport('', true);
}
function printfile128B() {
let width = 433.154 + 3
var label_variable = { quantity: '1', copy: '1' };
openport('TSC TE244', true); // ! 打点打印机TSC的名称

let alignment = 1
// 30个字符打印效果
// OUT “DPI = “;GETSETTING$(“SYSTEM”,”INFORMATION”,”DPI”)
clearbuffer('', true);
let str = "hello world2"
let str2 = "w"
let fontsize = '14'
let arr = [
`dot$="8"`,
`str$="${str}"`,
`str1$="${str2}"`,
`font$="0"`,
`fontsize=${fontsize}`,
`DPI$=GETSETTING$("SYSTEM","INFORMATION","DPI")`, // 字符串内容
`F=100`,
`G=2`,
`H=F*G`,
`I$=STR$(H)`,
`DPI2=VAL(DPI$)`,
// `IF DPI$+0=203 THEN dot$="11.8"`,
`strWidth=TEXTPIXEL(str1$,font$,fontsize)`,
// `TEXT 10,40,font$,0,fontsize,fontsize,str$`
`TEXT 10,50,\"0\",0,fontsize,fontsize,\"444444444444444\"`,
// `TEXT 10,203,\"0\",0,12,12,str$`,

// `TEXT 50,DPI2,"0",0,12,12,"22222"`,
// `TEXT 50,150,"0",0,12,12,I$`

// `TEXT 10,DPI$,\"0\",0,12,12,str$`,
// `TEXT 10,DPI2$,\"0\",0,12,12,str1$`,

// GETSETTING$ 获取内容位字符串内容
// `TEXT 50,200,\"0\",0,12,12,DPI2$`,

// GETSETTING$ 获取内容位字符串内容
`TEXT 50,200,\"0\",0,12,12,DPI$`,


// 运算符号计算
/*
`TEXT 50,50,"0",0,12,12,F$`,
`TEXT 50,80,"0",0,12,12,G$`,
`TEXT 50,100,"0",0,12,12,H`,
`TEXT 50,150,"0",0,12,12,I$`,
*/


// `TEXT 10,140,\"0\",0,12,12,dot$`,
// `TEXT 10,140,\"0\",0,12,12,DPI2$`,

]
arr.forEach((item, index) => {
sendcommand(item, true);
})
printlabel(label_variable, true);
closeport('', true);
}
function printfile128M() {
let width = 433.154 + 3
var label_variable = { quantity: '1', copy: '1' };
openport('TSC TE244', true); // ! 打点打印机TSC的名称
let alignment = 2
let X= 0
// 30个字符打印效果
clearbuffer('', true);
[
// `str$="WSRM56"`, 3倍大
// `str$="WSRM56789"`, 2倍最小
`str$="WSRM5678901234567890WSRM5678901234567"`,
// `str$="WSRMK-8000WSRMK-8000WSRMK-adsfasd"`,
// `str$="WSRMK-8"`,
`PP=3`,
`LC=${parseInt(X)}`,
`BW=${parseInt(width)}`,
`CW=BARCODEPIXEL(str$,"128M",PP,PP)`,
`IF CW>(BW-50) THEN PP=3`,
`CW=BARCODEPIXEL(str$,"128M",PP,PP)`,
`IF CW>(BW-50) THEN PP=2`,
`CW=BARCODEPIXEL(str$,"128M",PP,PP)`,
`IF CW>(BW-50) THEN PP=1`,
`CW=BARCODEPIXEL(str$,"128M",PP,PP)`,
`RW=BW-CW`,
`SW=RW/2`,
`IF SW>=0 THEN LC=${alignment == 2 ? "LC+SW" : "LC+RW"}`,
`BARCODE LC,0,"128M",74, 2,0,${'PP,PP'},str$`,
'TEXT 0,200,\"0\",0,10,10,\"7423011\"',

].forEach((item, index) => {
sendcommand(item, true);
})
printlabel(label_variable, true);
closeport('', true);
}
function printfile128MB() {
var label_variable = { quantity: '1', copy: '1' };
openport('TSC TE244', true); // ! 打点打印机TSC的名称
var font_variable = {x: '50', y: '50', fonttype: '3', rotation: '0', xmul: '1', ymul: '1', text: 'Font Test'}
var windowsfont_variable = {
x: 50,
y: 250,
fontheight: 64,
rotation: 0,
fontstyle: 0,
fontunderline: 0,
szFaceName: 'Arial',
content: 'Windowsfont Test'
}
var barcode_variable = {
x: '50',
y: '100',
type: '128',
height: '70',
readable: '0',
rotation: '0',
narrow: '3',
wide: '1',
code: '123456'
}
var label_variable = {quantity: '1', copy: '1'};

openport('TSC TE244', true);

clearbuffer('', true);
[
'0123456789123456789',
'ASCDEFGHIJKLMNOPQRS',
'abcdefghijklmnopqrstuvwxyz',
'A-B-C-DHIJKLMNOPQRS',
].forEach((item, index) => {
// sendcommand(`BARCODE 20,${index * 80},"128",74, 0,0,1,2,"${item}"`, true)
sendcommand(`BARCODE 20,${index * 80},"128M",74, 0,0,1,3,"${item}"`, true)
})
sendcommand(`TEXT 0,0,"0",0,12,12,"1234567890-0"`, true);
sendcommand(`TEXT 0,40,"0",0,12,12,"1234567890-1"`, true);
sendcommand(`TEXT 0,80,"0",0,12,12,"1234567890-2"`, true);
sendcommand(`TEXT 0,120,"0",0,12,12,"1234567890-3"`, true);
sendcommand(`TEXT 0,270,"0",0,12,12,"1234567890-4"`, true);
sendcommand(`TEXT 0,180,"0",0,12,12,"1234567890-4"`, true);
sendcommand(`TEXT 0,200,"0",0,12,12,"1234567890-5"`, true);
sendcommand(`TEXT 100,250,"0",0,12,12,"1234567890-6"`, true);
sendcommand(`TEXT 0,280,"0",0,12,12,"1234567890-6.1"`, true);
sendcommand(`TEXT 0,290,"0",0,12,12,"1234567890-6.2"`, true);
printlabel(label_variable, true);

//var selftest_command = 'SELFTEST\r\n';
//var arr = [];
//for (var i = 0; i < selftest_command.length; ++i)
// arr.push(selftest_command.charCodeAt(i));
//var selftest_command_buffer = new Uint8Array(arr);
//sendcommand_binary(selftest_command_buffer, true);

closeport('', true);
}
Loading

0 comments on commit 746818d

Please sign in to comment.