-
Notifications
You must be signed in to change notification settings - Fork 0
/
Command.java
154 lines (114 loc) · 4.77 KB
/
Command.java
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
package printer;
public class Command
{
private static final byte ESC = 0x1B;
private static final byte FS = 0x1C;
private static final byte GS = 0x1D;
private static final byte US = 0x1F;
private static final byte DLE = 0x10;
private static final byte DC4 = 0x14;
private static final byte DC1 = 0x11;
private static final byte SP = 0x20;
private static final byte NL = 0x0A;
private static final byte FF = 0x0C;
public static final byte PIECE = (byte) 0xFF;
public static final byte NUL = (byte) 0x00;
//打印机初始化
public static byte[] ESC_Init = new byte[] { ESC, '@' };
/**
* 打印命令
*/
//打印并换行
public static byte[] LF = new byte[] { NL };
//打印并走纸
public static byte[] ESC_J = new byte[] { ESC, 'J', 0x00 };
public static byte[] ESC_d = new byte[] { ESC, 'd', 0x00 };
//打印自检页
public static byte[] US_vt_eot = new byte[] { US, DC1, 0x04 };
//蜂鸣指令
public static byte[] ESC_B_m_n = new byte[] { ESC, 'B', 0x00, 0x00 };
//切刀指令
public static byte[] GS_V_n = new byte[] { GS, 'V', 0x00 };
public static byte[] GS_V_m_n = new byte[] { GS, 'V', 'B', 0x00 };
public static byte[] GS_i = new byte[] { ESC, 'i' };
public static byte[] GS_m = new byte[] { ESC, 'm' };
/**
* 字符设置命令
*/
//设置字符右间距
public static byte[] ESC_SP = new byte[] { ESC, SP, 0x00 };
//设置字符打印字体格式
public static byte[] ESC_ExclamationMark = new byte[] { ESC, '!', 0x00 };
//设置字体倍高倍宽
public static byte[] GS_ExclamationMark = new byte[] { GS, '!', 0x00 };
//设置反显打印
public static byte[] GS_B = new byte[] { GS, 'B', 0x00 };
//取消/选择90度旋转打印
public static byte[] ESC_V = new byte[] { ESC, 'V', 0x00 };
//选择字体字型(主要是ASCII码)
public static byte[] ESC_M = new byte[] { ESC, 'M', 0x00 };
//选择/取消加粗指令
public static byte[] ESC_G = new byte[] { ESC, 'G', 0x00 };
public static byte[] ESC_E = new byte[] { ESC, 'E', 0x00 };
//选择/取消倒置打印模式
public static byte[] ESC_LeftBrace = new byte[] { ESC, '{', 0x00 };
//设置下划线点高度(字符)
public static byte[] ESC_Minus = new byte[] { ESC, 45, 0x00 };
//字符模式
public static byte[] FS_dot = new byte[] { FS, 46 };
//汉字模式
public static byte[] FS_and = new byte[] { FS, '&' };
//设置汉字打印模式
public static byte[] FS_ExclamationMark = new byte[] { FS, '!', 0x00 };
//设置下划线点高度(汉字)
public static byte[] FS_Minus = new byte[] { FS, 45, 0x00 };
//设置汉字左右间距
public static byte[] FS_S = new byte[] { FS, 'S', 0x00, 0x00 };
//选择字符代码页
public static byte[] ESC_t = new byte[] { ESC, 't', 0x00 };
/**
* 格式设置指令
*/
//设置默认行间距
public static byte[] ESC_Two = new byte[] { ESC, 50 };
//设置行间距
public static byte[] ESC_Three = new byte[] { ESC, 51, 0x00 };
//设置对齐模式
public static byte[] ESC_Align = new byte[] { ESC, 'a', 0x00 };
//设置左边距
public static byte[] GS_LeftSp = new byte[] { GS, 'L', 0x00, 0x00 };
//设置绝对打印位置
//将当前位置设置到距离行首(nL + nH x 256)处。
//如果设置位置在指定打印区域外,该命令被忽略
public static byte[] ESC_Relative = new byte[] { ESC, '$', 0x00, 0x00 };
//设置相对打印位置
public static byte[] ESC_Absolute = new byte[] { ESC, 92, 0x00, 0x00 };
//设置打印区域宽度
public static byte[] GS_W = new byte[] { GS, 'W', 0x00, 0x00 };
/**
* 状态指令
*/
//实时状态传送指令
public static byte[] DLE_eot = new byte[] { DLE, 0x04, 0x00 };
//实时弹钱箱指令
public static byte[] DLE_DC4 = new byte[] { DLE, DC4, 0x00, 0x00, 0x00 };
//标准弹钱箱指令
public static byte[] ESC_p = new byte[] { ESC, 'F', 0x00, 0x00, 0x00 };
/**
* 条码设置指令
*/
//选择HRI打印方式
public static byte[] GS_H = new byte[] { GS, 'H', 0x00 };
//设置条码高度
public static byte[] GS_h = new byte[] { GS, 'h', (byte) 0xa2 };
//设置条码宽度
public static byte[] GS_w = new byte[] { GS, 'w', 0x00 };
//设置HRI字符字体字型
public static byte[] GS_f = new byte[] { GS, 'f', 0x00 };
//条码左偏移指令
public static byte[] GS_x = new byte[] { GS, 'x', 0x00 };
//打印条码指令
public static byte[] GS_k = new byte[] { GS, 'k', 'A', FF };
//二维码相关指令
public static byte[] GS_k_m_v_r_nL_nH = new byte[] { ESC, 'Z', 0x03, 0x03, 0x08, 0x00, 0x00 };
}