📄 jbprint.c
字号:
/*****************************************************************************
*
* 文件名:jbPrint.c
*
* 说 明:JJF24-1B打印子程序所有函数定义
*
*****************************************************************************/
// #pragma src
#include <jbPrint.h>
/*****************************************************************************
*
* 函数名: PrintTalkRecord
*
* 说 明: 打印主程序
*
*****************************************************************************/
bool PrintTalkRecord()
{
byte i,j;
byte bFormValue;
//ulint xdata lParaTemp;
fPrnSure=1;
if((bStatusWord==S_OLDLOCKWAIT)||(bStatusWord==S_OLDUNLOCKWAIT)||
(bStatusWord==S_NEWLOCKWAIT)||(bStatusWord==S_NEWUNLOCKWAIT))
cbDelay5MS=100;
else
cbDelay5MS=255;
fDelay5MS=0;
fBusy=1;
// 打印机的情况
i=50;
while(--i!=0){ // 80 ms
j=150;
while(--j!=0){
if(fDelay5MS)
return FALSE;
if(fDelay5MS||(cbDelay5MS==120)){
cbDelay5MS=180;
return FALSE;
}
if(fBusy)
i=50;
}
}
AutoReadPara(72);
if(bParaByte>34)
return FALSE;
else if(bParaByte!=0){
for(i=0;i<60;i++)
aSelfForm[i]=aPrintForm[bParaByte-1][i];
}
cbDelay5MS=180;
fDelay5MS=0;
PrinterInit();
if(bParaByte>=33){ //lmt add 2001.3.13
WritePrintPort(0x1b); //回纸
WritePrintPort(0x6a);
WritePrintPort(200);
WritePrintPort(0x1b); //回纸
WritePrintPort(0x6a);
Page(6);
j=XBYTE[PARA_59];
Page(5);
WritePrintPort(j);
}
Print_CR();
if(bParaByte==0)
uPrint();
else{
for(i=0;i<60;i++){
bFormValue=aSelfForm[i];
if(bFormValue==ERRVALUE){
fPrnSure=FALSE;
break;
}
if(bFormValue==PRNEND){
if(i==0)
fPrnSure=FALSE;
break;
}
switch(bFormValue){
case PRINTF0: //lmt add 2001.3.13
if(((bStatusWord==S_OLDMASTERCALL)||(bStatusWord==S_NEWMASTERCALL))
&&(bParaByte==33)){
//lParaTemp=lTotalTariff;
Print_Fee();
}
else{
for(j=0;j<8;j++)
WritePrintPort(0x20);
}
break;
case PRINTF1: //lmt add 2001.3.13
/*
if((bStatusWord==S_OLDMASTERCALL)||(bStatusWord==S_NEWMASTERCALL)){
//lTotalTariff=0;
//Print_Fee();
PrintSpace(6);
}
else{
*/
for(j=0;j<6;j++)
WritePrintPort(0x20);
//}
break;
case PRINTF2: // lmt add 2001.3.13
/*
if((bStatusWord==S_OLDMASTERCALL)||(bStatusWord==S_NEWMASTERCALL)){
//lTotalTariff=0;
//Print_Fee();
PrintSpace(6);
}
else{
*/
for(j=0;j<6;j++)
WritePrintPort(0x20);
//}
break;
case PRINTFEE: // lmt add 2001.3.13
/*
if(((bStatusWord==S_OLDMASTERCALL)||(bStatusWord==S_NEWMASTERCALL))
&&(bParaByte==33))
lTotalTariff=lParaTemp;
*/
Print_Fee();
break;
case TALKTIME:
PrintTalkTime();
break;
case PASSICODE:
PrintCode(PASSI);
break;
case STARTTIME:
PrintStartTime();
break;
case LOCALCODE:
PrintCode(LOCAL);
break;
case STARTDATE:
PrintDate();
break;
case PRINTNo:
PrintBillNo();
break;
case PRINTCR:
Print_CR();
break;
case FEED:
bFormValue=aSelfForm[++i];
ESC_J(bFormValue);
break;
default:
PrintSpace(bFormValue);
break;
}
if(!fPrnSure)
break;
}
AutoReadPara(73);
ESC_J(bParaByte);
}
if(fPrnSure){
AutoReadPara(74);
if(++iParaWord>9999)
iParaWord=0;
AutoWritePara(74);
}
return fPrnSure;
} // End of PrintTalkRecord()
/*****************************************************************************
*
* 函数明: WritePrintPort()
*
* 说 明: 数据写到打印口
*
*****************************************************************************/
void WritePrintPort(byte bPrintByte)
{
while(fBusy){
if(cbDelay5MS<70){
fPrnSure=FALSE;
return;
}
}
Page(6);
OutBuf|=0x04;
XBYTE[OUT_CE]=OutBuf;
XBYTE[PR_CE]=bPrintByte;
OutBuf&=0xfb;
XBYTE[OUT_CE]=OutBuf;
OutBuf|=0x04;
XBYTE[OUT_CE]=OutBuf;
Page(5);
} // End of WritePrintPort()
/*****************************************************************************
*
* 函数明: PrinterInit
*
* 说 明: 打印机初始化
*
*****************************************************************************/
void PrinterInit()
{
WritePrintPort(0x1B);
WritePrintPort(0x40);
} // End of PrinterInit()
/*****************************************************************************
*
* 函数明: Print_CR
*
* 说 明: 打印回车(打印头回位)
*
*****************************************************************************/
void Print_CR(void)
{
WritePrintPort(0x0D);
} // End of Print_CR()
/*****************************************************************************
*
* 函数名: PrintSpace
*
* 说 明: 打印空格
*
*****************************************************************************/
void PrintSpace(byte bSpaces)
{
byte i;
for(i=0;i<bSpaces;i++)
WritePrintPort(0x20);
} // End of PrintSpace()
/*****************************************************************************
*
* 函数名: ESC_J
*
* 说 明: 垂直进纸
*
*****************************************************************************/
void ESC_J(byte bLength)
{
WritePrintPort(0x1B);
WritePrintPort(0x4A);
WritePrintPort(bLength);
} // End of ESC_J()
/*****************************************************************************
*
* 函数名: PrintBillNo
*
* 说 明: 打印花单流水号
*
*****************************************************************************/
void PrintBillNo()
{
byte i;
GetParaContent(74);
for(i=1;i<5;i++)
WritePrintPort(aServer[i]+0x30);
} // End of PrintBillNo()
/*****************************************************************************
*
* 函数名: PrintDate
*
* 说 明: 打印通话起始日期
*
*****************************************************************************/
void PrintDate()
{
byte i,bByte;
for(i=0;i<4;i++){
bByte=aCallTime[i];
WritePrintPort((bByte>>4)+0x30);
WritePrintPort((bByte&0x0F)+0x30);
if((i==1)||(i==2))
WritePrintPort(0x2D);
}
} // End of PrintDate()
/*****************************************************************************
*
* 函数名: PrintCode
*
*
* 说 明: 打印电话号码:主叫号(本机号)或被叫号
*
*
*****************************************************************************/
byte code aPrn8Num[]={3,4,9,10,13,14,29,30};
void PrintCode(bool fCodeType )
{
byte i,bByte,j;
byte data bLimit;
byte xdata aLocalCode[16];
bLimit=16;
AutoReadPara(72);
if((fCodeType==PASSI)&&(bParaByte>28)) //打印被叫号码
bLimit--;
else{ //打印本机电话号码
if(fWorkMode){
j=8;
AutoReadPara(02);
}
else{
j=4;
AutoReadPara(210);
}
memset(aLocalCode,0x0c,16);
for(i=0;i<j;i++){
bByte=aParaBuf[i];
aLocalCode[2*i]=bByte>>4;
aLocalCode[2*i+1]=bByte&0x0f;
}
}
for(i=0;i<bLimit;i++){
if(fCodeType==PASSI)
bByte=aNumBuf[i];
else
bByte=aLocalCode[i];
if(bByte>0x09)
WritePrintPort(0x20);
else
WritePrintPort(bByte+0x30);
if((i==7)&&(fCodeType==LOCAL)){ //打印本机号码时,有的打印格式只能打印8位号码
for(j=0;j<8;j++){
if(bParaByte==aPrn8Num[j])
return;
}
}
}
} // End of PrintCode()
/*****************************************************************************
*
* 函数名: PrintStartTime
*
* 说 明: 打印通话起始时间
*
*
*****************************************************************************/
void PrintStartTime()
{
byte i,bByte;
AutoReadPara(72);
for(i=4;i<7;i++){
if((i==6)&&
(!fWorkMode)){ //||(bParaByte==0)){
if((bParaByte==0)||(bParaByte==9)||(bParaByte==10)||(bParaByte==30))
return;
PrintSpace(3);
}
else{
if(i!=4)
WritePrintPort(0x3a);
bByte=aCallTime[i];
WritePrintPort((bByte>>4)+0x30);
WritePrintPort((bByte&0x0f)+0x30);
}
}
} // End of PrintStartTime()
/*****************************************************************************
*
* 函数名: PrintTalkTime
*
* 说 明: 打印通话时长
*
*****************************************************************************/
void PrintTalkTime()
{
byte i;
uint iWork0=3600;
uint iWork1;
iWork1=iTotalTime;
for(i=0;i<3;i++){
aServer[0]=iWork1/iWork0;
BINConvBCD(1);
WritePrintPort(aServer[1]+0x30);
WritePrintPort(aServer[2]+0x30);
if(i!=2)
WritePrintPort(0x3A);
iWork1=iWork1%iWork0;
iWork0=iWork0/60;
}
} // End of PrintTalkTime()
/*****************************************************************************
*
* 函数名: Print_Fee
*
* 说 明: 打印通话话费
*
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -