📄 printer.lst
字号:
C51 COMPILER V7.00 PRINTER 09/14/2006 16:35:55 PAGE 1
C51 COMPILER V7.00, COMPILATION OF MODULE PRINTER
OBJECT MODULE PLACED IN PRINTER.OBJ
COMPILER INVOKED BY: C:\Keil\C51\BIN\C51.EXE PRINTER.C OPTIMIZE(9,SIZE) BROWSE ORDER DEBUG OBJECTEXTEND
stmt level source
1 /***********************************************************
2 * 文件名:PRINTER.C
3 ***********************************************************/
4 #include "REG51STC.H"
5 #include <ABSACC.H>
6 #include "CMD16887.H"
7 #include <INTRINS.H>
8 #include "externxy.h"
9
10 //enum producttype{"Regular","Midgrade","Premium","Diesel","abcdef","x5defee","x6defee","x7defee"};
11 enum producttype{Regular,Midgrade,Premium,Diesel,abcdef,x5defee,x6defee,x7defee};
12 //code producttype product;
13 code uchar oiltypes0[]={"Regular"}; //油品0
14 code uchar oiltypes1[]={"Midgrade"}; //油品1
15 code uchar oiltypes2[]={"Premium"}; //油品2
16 code uchar oiltypes3[]={"Diesel"}; //油品3
17 code uchar oiltypes4[]={"super"}; //油品4
18 code uchar oiltypes5[]={"midgrade"}; //油品5
19 code uchar oiltypes6[]={"premium"}; //油品6
20 code uchar oiltypes7[]={"super"}; //油品7
21 code uchar service_station[]={"ASKAR OIL SERVICE (PVT) LTD"}; //加油站信息
22 /***********************************************************
23 * 功能:读打印机状态,查询busy信号a/b
24 ***********************************************************/
25 void delay_printer(uint useconds,uchar prnidid)
26 { bit tempbit;
27 1 AUXR |=0x02;
28 1 if(prnidid==0) tempbit=p1busy;
29 1 else tempbit=p2busy;
30 1 for(;useconds>0;useconds--)
31 1 {
32 2 WDT_CONTR=0x34;
33 2 printstate=XBYTE[READPRINT]; //读打印机状态
34 2 if (!tempbit) break;
35 2 }
36 1 }
37 /**********************************************
38 * 功能:打印机输出命令及数据a/b
39 ***********************************************/
40 void printer(uchar n,uchar sdata[],uchar prnidid)
41 {
42 1 data uchar i;
43 1 P1STB=1;
44 1 P2STB=1;
45 1 for(i=0;i<n;i++)
46 1 { AUXR &=0xfd;
47 2 bbyte=sdata[i];
48 2 if (bbyte==0x00 && i>3) break;
49 2
50 2
51 2 AUXR |=0x02;
52 2
53 2 if(prnidid==0)
54 2 { delay_printer(20,prnidid);
55 3
C51 COMPILER V7.00 PRINTER 09/14/2006 16:35:55 PAGE 2
56 3 XBYTE[PRINTER1ADD]=bbyte;
57 3 delay_printer(5,prnidid);
58 3 //if (!p1busy)
59 3 {
60 4 P1STB=0;
61 4 _nop_();
62 4 _nop_();
63 4 P1STB=1;
64 4 }
65 3 }
66 2 else
67 2 { delay_printer(20,prnidid);
68 3
69 3 XBYTE[PRINTER2ADD]=bbyte;
70 3 delay_printer(5,prnidid);
71 3 //if (!p2busy)
72 3 {
73 4 P2STB=0;
74 4 _nop_();
75 4 _nop_();
76 4 P2STB=1;
77 4 }
78 3 }
79 2 AUXR &=0xfd;
80 2 }
81 1 AUXR &=0xfd;
82 1 }
83 /**********************************************************
84 * 功能:打印加油票据a/b
85 **********************************************************/
86 void print_proof(uchar gunidid)
87 { uchar prnidid;
88 1 uchar tt[30];
89 1 uchar productnum; //油品
90 1 xdata ulong m;
91 1 uchar i,j;
92 1 bit tempbit;
93 1 if(gunidid==0)
94 1 { productnum=oil_types_a;
95 2 tempbit=p1sel;
96 2 prnidid=pirnt_select_a;
97 2 }
98 1 else
99 1 { productnum=oil_types_b;
100 2 tempbit=p2sel;
101 2 prnidid=pirnt_select_b;
102 2 }
103 1 tempbit=1;
104 1 if(tempbit) //不在线不打印
105 1 { //printer(32,"-------------------------------",prnidid);
106 2 //tt[0]=0x0a;
107 2 //printer(1,&tt[0],prnidid);
108 2 for(i=0;i<30;i++)
109 2 {
110 3 tt[i]=print_format[i+120];
111 3 }
112 2 printer(30,&tt[0],prnidid);
113 2 tt[0]=0x0a;
114 2 printer(1,&tt[0],prnidid);
115 2 for(i=0;i<30;i++)
116 2 {
117 3 tt[i]=print_format[i+90];
C51 COMPILER V7.00 PRINTER 09/14/2006 16:35:55 PAGE 3
118 3 }
119 2 printer(30,&tt[0],prnidid);
120 2 tt[0]=0x0a;
121 2 printer(1,&tt[0],prnidid);
122 2 for(i=0;i<30;i++)
123 2 {
124 3 tt[i]=print_format[i+60];
125 3 }
126 2 printer(30,&tt[0],prnidid);
127 2
128 2 tt[0]=0x0a;
129 2 printer(1,&tt[0],prnidid);
130 2
131 2 tt[0]=0x1b;tt[1]=0x4a;tt[2]=24; //走空行
132 2 printer(3,&tt[0],prnidid);
133 2
134 2 //-------------------------------
135 2 if(gunidid==0){m=gun1.sale;bbyte=dotmode[decimal_a];} //金额
136 2 else {m=gun2.sale;bbyte=dotmode[decimal_b];}
137 2 if(a0) j=6;
138 2 else if(a3) j=5;
139 2 else j=8;
140 2 for(i=7;i>0;i--)
141 2 { if(i==j) {tt[i]=0x2e;i--;}
142 3 tt[i]=m%10+0x30;m/=10;
143 3 }
144 2 tt[0]=m%10+0x30;
145 2 for(i=0;i<j-1;i++)
146 2 {
147 3 if(tt[i]==0x30) tt[i]=0x20;
148 3 else break;
149 3 }
150 2
151 2 printer(11," Total: ",prnidid);
152 2 printer(4,"Rp.",prnidid);
153 2 printer(8,&tt[0],prnidid); //打印金额
154 2
155 2 tt[0]=0x0a;
156 2 printer(1,&tt[0],prnidid);
157 2
158 2 //-----------------------
159 2 if(gunidid==0){m=gun1.liter;bbyte=dotmode[decimal_a];} //升
160 2 else {m=gun2.liter;bbyte=dotmode[decimal_b];}
161 2 if(a4) j=5;
162 2 else if(a1) j=4;
163 2 else j=8;
164 2 for(i=7;i>0;i--)
165 2 { if(i==j) {tt[i]=0x2e;i--;}
166 3 tt[i]=m%10+0x30;m/=10;
167 3 }
168 2 tt[0]=m%10+0x30;
169 2 for(i=0;i<j-1;i++)
170 2 {
171 3 if(tt[i]==0x30) tt[i]=0x20;
172 3 else break;
173 3 }
174 2
175 2 printer(18," Liter: ",prnidid);
176 2 printer(8,&tt[0],prnidid); //打印升
177 2 printer(3," L ",prnidid);
178 2 tt[0]=0x0a;
179 2 printer(1,&tt[0],prnidid);
C51 COMPILER V7.00 PRINTER 09/14/2006 16:35:55 PAGE 4
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -