-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathserver02.js
204 lines (165 loc) · 4.16 KB
/
server02.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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
'use strict';
var edge = require('edge-js');
var express = require('express');
var bodyParser = require('body-parser');
const util = require('util');
var app = express();
var about;
var openport;
var sendcommand;
var clearbuffer;
var printerfont;
var barcode;
var printlabel;
var closeport;
var sendcommand_utf8;
var sendcommand_binary;
var windowsfont;
var urlencodedParser = bodyParser.urlencoded({ extended: false });
app.use(bodyParser.urlencoded({
extended: true
}));
app.use(express.static('./'));
app.listen(8888, function () {
console.log("Server Start!!");
})
app.get('/test_get', function (req, res) {
console.log('GET Function Test!!');
});
app.post('/', urlencodedParser,function (req, res) {
printfile();
res.redirect(req.get('referer'));
});
try {
openport = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'openport'
});
}
catch (error) {
console.log(error);
}
try {
about = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'about'
});
}
catch (error) {
console.log(error);
}
try {
sendcommand = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'sendcommand'
});
}
catch (error) {
console.log(error);
}
try {
clearbuffer = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'clearbuffer'
});
}
catch (error) {
console.log(error);
}
try {
printerfont = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'printerfont'
});
}
catch (error) {
console.log(error);
}
try {
barcode = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'barcode'
});
}
catch (error) {
console.log(error);
}
try {
printlabel = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'printlabel'
});
}
catch (error) {
console.log(error);
}
try {
closeport = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'closeport'
});
}
catch (error) {
console.log(error);
}
try {
sendcommand_utf8 = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'sendcommand_utf8'
});
}
catch (error) {
console.log(error);
}
try {
sendcommand_binary = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'sendcommand_binary'
});
}
catch (error) {
console.log(error);
}
try {
windowsfont = edge.func({
assemblyFile: 'tsclibnet.dll',
typeName: 'TSCSDK.node_driver',
methodName: 'windowsfont'
});
}
catch (error) {
console.log(error);
}
function printfile()
{
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);
// printerfont(font_variable, true);
// barcode(barcode_variable, true);
// windowsfont(windowsfont_variable, true);
// sendcommand('CODEPAGE UTF-8', true);
// sendcommand('TEXT 250,50,\"0\",0,10,10,\"Text Test!!\"', true);
sendcommand('TEXT 50,50,\"ARIAL.TTF\",0,12,12,\"Text222 Test!!\"', 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);
}