⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 print.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
        prn_Table(currtable - 1, 0);
        Flag_Prgm_Head = 0;
        if(prn_LstSpndAmt_flag == 1)
            Prn_Adj_Ex(Var_Str_LstSpndAmt,(table[currtable - 1].tmpvars).netamt,sysflag->sysdots,RPOSI,DESC_NEW);
        prn_Line('-');
    }
#endif /* End VER_RSNT */

    if(Head_Prn_Flag == 1)
    {
    //	   memcpy(prn_Buf+1, Str_Flush_Head, MAX_PRN_LEN);
        xtr_strcpy(prn_Buf+1, Str_Flush_Head);				/* Modified on 2004-04-07 17:16 */
        prn_Str();
        prn_Line('=');
    }
    Head_Prn_Flag = 1;
    if(prn_tab_pre_flag)
        prn_pre_item_head();
}


/*----------------------------------------------------------------------------*
 *                Print the logo while later can't support it                 *
 *          The parameter dummy may use in select which logo to print         * 
 *----------------------------------------------------------------------------*/
void prn_Logo(void)
{
	prn_Bmp();
   /*          Print the Logo             */
}


/*---------------------------------------------------------------------------------------------------------
*  Printing the current data stored in Prn_Data_Buffer[]
*
*  If the Logo Text not printing, then printing the Logo text ( Note, first store the current printing
*  contents, and then restore it to continue printing )
*
*---------------------------------------------------------------------------------------------------------*/
void  Print_Ex(byte type)
{
   if ( (Flag_Prn_Head == FALSE) && (( CurrMode == REGISTER)||(CurrMode == TRAINING)) )
   {
      Flag_Prn_Head = TRUE;
      prn_Data_Store(0);                     // Store the current printing data.
      if((Logo_Prn_Flag == 1) &&(sysflag->LogoPosi_Flag == HEAD) && (!sysflag->PrnAdj_Flag))
      	prn_Logo();
//    if( CurrMode == REGISTER)
      Receipt_Head_Prn();
      prn_Data_Store(1);                     // restore the data from buffer.

		// Initialize the LCD text.
		Rst_Lcd_Text();
		Lcd_Init_Sale();		/* Initial the sale head */
   }
   if((CurrMode == REGISTER)||(CurrMode == TRAINING))
   {
   	Subt_Press_Flag = 0;
   	if(sysflag->Subt_PressPrn)
   		Subt_Prn_Flag = 0;
   }
   Prn_Str(type);
}


/*-----------------------------------------------------------------------------*
 *             Print the ASCII code to test the printer                        *
 *-----------------------------------------------------------------------------*/
void  prn_Testing(void)
{
   byte a,b,c,d;

   c = 0x20;
   phead = prear = 0;
   Prn_Stat= PRN_IDLE;
   Flag_Key_Feed_Papr = 0;
	prn_Ver();			/* Print the current version */
   
#ifdef THAI_FONT
   for( a = 0x20; a/* <= 0xFF*/ >= 0x20; a++)			/* 0xFF + 1 = 0x00 */
#else
	for( a = 0x20; a < 0x7F; a ++)
#endif	   
   {
      d = c;
      for( b = 1; b < MAX_PRN_LEN + 1; b ++)
      {
         prn_Buf[ b ] = d;
         d ++;
         #ifdef THAI_FONT
         if(d == 0x00)			/* 0xFF + 1 = 0x00 */
         #else
         if(d == 0x7F)
         #endif
            d = 0x20;
      }
      prn_Str();
      c ++;
      if(Chk_KeyPrs_LockChg(1) == NOTOK)
      {
//			memcpy(prn_Buf+1, Str_PrnInt, MAX_PRN_LEN);
			xtr_strcpy(prn_Buf+1, Str_PrnInt);		/* Modified on 2004-04-07 17:15 */
			prn_Str();
			Clr_Key_Buff();
      	break;
      }
   }

   Line_Feed(2);
//   memcpy(prn_Buf+1,Str_Cmpltd,MAX_PRN_LEN);
	xtr_strcpy(prn_Buf+1,Str_Cmpltd);		/* Modified on 2004-04-07 17:15 */
   prn_Str();
   Line_Feed(6);
}


/*-----------------------------------------------------------------------------*
 *             Print the ASCII code to test the printer                        *
 *-----------------------------------------------------------------------------*/
void prn_Testing1(void)
{
	byte i;

	phead = prear = 0;
   Prn_Stat= PRN_IDLE;
   Flag_Key_Feed_Papr = 0;

#ifdef THAI_FONT
	for(i = 0x20; i/* >= 0x20*/ <= 0x95; i ++)
#else
	for(i = 0x20; i < 0x7F; i ++)
#endif /* End THAI_FONT */
	{
		prn_Line(i);
      if(Chk_KeyPrs_LockChg(1) == NOTOK)
      {
//			memcpy(prn_Buf+1, Str_PrnInt, MAX_PRN_LEN);
			xtr_strcpy(prn_Buf+1, Str_PrnInt);		/* Modified on 2004-04-07 17:14 */
			prn_Str();
			Clr_Key_Buff();
      	break;
      }
	}
	Line_Feed(2);
//	memcpy(prn_Buf+1,Str_Cmpltd,MAX_PRN_LEN);
	xtr_strcpy(prn_Buf+1,Str_Cmpltd);		/* Modified on 2004-04-07 17:14 */
	prn_Str();
	Line_Feed(6);
}


/*-----------------------------------------------------------------------------*
 *             Print the ASCII code to test the printer                        *
 *-----------------------------------------------------------------------------*/
void  prn_Testing2(void)
{
	byte i;
   byte a,b;
   byte cnt;

   a = 0x20;
   cnt = 0;
   phead = prear = 0;
   Prn_Stat= PRN_IDLE;
   Flag_Key_Feed_Papr = 0;
	while(TRUE)
   {
      b = a;
      for(i = 1; i < MAX_PRN_LEN + 1; i ++)
      {
         prn_Buf[ i ] = b;
         b ++;
         if(b == 0x7F)
            b = 0x20;
      }
      prn_Str();
      a ++;
      if(a == 0x7F)
      	a = 0x20;

		cnt ++;
		if(cnt == 15)
		{
			cnt = 0;
      	CndtDelay(5000);		/* Condition delay 5 seconds */
      	prn_Str();				/* Print a blank line */
		}
      if(Chk_KeyPrs_LockChg(1) == NOTOK)
      {
//			memcpy(prn_Buf+1, Str_PrnInt, MAX_PRN_LEN);
			xtr_strcpy(prn_Buf+1, Str_PrnInt);			/* Modified on 2004-04-07 17:14 */
			prn_Str();
			Clr_Key_Buff();
      	break;
      }
   }
   Line_Feed(2);
//   memcpy(prn_Buf+1,Str_Cmpltd,MAX_PRN_LEN);
	xtr_strcpy(prn_Buf+1,Str_Cmpltd);	/* Modified on 2004-04-07 17:13 */
   prn_Str();
   Line_Feed(6);
}


/*---------------------------------------------------------------------------------------*
 *                               Print date and time                                     *
 *---------------------------------------------------------------------------------------*/

#ifdef OLD
void prn_Date_Time(byte year, byte month, byte day, byte hour, byte minute)
{
//	memcpy(prn_Buf+1, Str_Date, strlen(Str_Date));
	xtr_strcpy(prn_Buf+1, Str_Date);		/* Modified on 2004-04-07 17:13 */
	if(sysflag->datefmt == 0)				/* American date format, MMDDYY */
	{
		DectoAsc(prn_Buf+7, month);
		prn_Buf[9] = '-';
		DectoAsc(prn_Buf+10, day);
		prn_Buf[12] = '-';
		LongtoAsc(prn_Buf+13, 2000+year, 4);
	}
	else if(sysflag->datefmt == 1)		/* Endlish date format, DDMMYY */
	{
		DectoAsc(prn_Buf+7, day);
		prn_Buf[9] = '-';
		DectoAsc(prn_Buf+10, month);
		prn_Buf[12] = '-';
		LongtoAsc(prn_Buf+13, 2000+year, 4);
	}
	else if(sysflag->datefmt == 2)		/* China date fmt, YYMMDD */
	{
		LongtoAsc(prn_Buf+7, 2000+year, 4);
		prn_Buf[11] = '-';
		DectoAsc(prn_Buf+12, month);
		prn_Buf[14] = '-';
		DectoAsc(prn_Buf+15, day);
	}
	else
		sysflag->datefmt = 1;
//   memcpy(prn_Buf+22,Str_Time,strlen(Str_Time));
	xtr_strcpy(prn_Buf+22, Str_Time);
	DectoAsc(prn_Buf+28, hour);
	prn_Buf[30] = ':';
	DectoAsc(prn_Buf+31, minute);
	prn_Str();
}
/*------------------------------------------------------------------------------------*
 *             Print the clerk number and receipt number in the receipt end.          *
 *------------------------------------------------------------------------------------*/
void prn_Clerk_RcptNum(void)           //Print the clerk number and the recepit number and the machine number.
{
   byte i;
   i = 29;
   if(sysflag->clerk_mode)
   {
		memcpy(prn_Buf+1, clerk[currclerk-1].desc, MAX_DESC_LEN);
   }
   LongPrnFmt(sysflag->RcptNum,0,RPOSI, RIGHTFLUSH);
   prn_Buf[28]  = '#';
   for(;i < PRN_BUF_LEN;i ++)          // If the RcptNum's length smaller than 4, adjust it with zero's ASCII code.
      if(prn_Buf[i] == ' ')
         prn_Buf[i] = '0';
   LongPrnFmt(sysflag->McheNum,0,22, RIGHTFLUSH); // Adjust McheNum's length when smaller than 4.
   for(i=19;i < 22;i ++)
      if(prn_Buf[i] == ' ')
         prn_Buf[i] = '0';
   prn_Buf[0] = NM_FONT_PRN;
   prn_Str();
   sysflag->RcptNum ++;
   if(sysflag->RcptNum == 10000)
      sysflag->RcptNum = 1;
}
#else
void prn_Date_Time(byte year, byte month, byte day, byte hour, byte minute)
{
	if(sysflag->datefmt == 0)				/* American date format, MMDDYY */
	{
		DectoAsc(prn_Buf+1, month);
		prn_Buf[3] = '-';
		DectoAsc(prn_Buf+4, day);
		prn_Buf[6] = '-';
		LongtoAsc(prn_Buf+7, 2000+year, 4);
	}
	else if(sysflag->datefmt == 1)		/* Endlish date format, DDMMYY */
	{
		DectoAsc(prn_Buf+1, day);
		prn_Buf[3] = '-';
		DectoAsc(prn_Buf+4, month);
		prn_Buf[6] = '-';
		LongtoAsc(prn_Buf+7, 2000+year, 4);
	}
	else if(sysflag->datefmt == 2)		/* China date fmt, YYMMDD */
	{
		LongtoAsc(prn_Buf+1, 2000+year, 4);
		prn_Buf[3] = '-';
		DectoAsc(prn_Buf+4, month);
		prn_Buf[6] = '-';
		DectoAsc(prn_Buf+7, day);
	}
	else
		sysflag->datefmt = 1;

	DectoAsc(prn_Buf+20, hour);
	prn_Buf[22] = ':';
	DectoAsc(prn_Buf+23, minute);
	prn_Str();
}


/*------------------------------------------------------------------------------------*
 *             Print the clerk number and receipt number in the receipt end.          *
 *------------------------------------------------------------------------------------*/
void prn_Clerk_RcptNum(void)           //Print the clerk number and the recepit number and the machine number.
{
   if(sysflag->clerk_mode)
   {
		memcpy(prn_Buf+1, clerk[currclerk-1].desc, MAX_DESC_LEN);
   }
   LWordtoAsc(prn_Buf+RPOSI-4, sysflag->RcptNum, 4);
   prn_Buf[RPOSI-5] = '#';
   
   LWordtoAsc(prn_Buf+14, sysflag->McheNum, 4);
   
   prn_Buf[0] = NM_FONT_PRN;
   prn_Str();
   sysflag->RcptNum ++;
   if(sysflag->RcptNum == 10000)
      sysflag->RcptNum = 1;
}
#endif

/*------------------------------------------------------------------------------------*
 *             Print one line give with same character.
 *------------------------------------------------------------------------------------*/
void prn_Line(char chr)
{
	byte i;
	
//	memset(prn_Buf+1,chr,MAX_PRN_LEN);
	for(i = 0; i < MAX_PRN_LEN; i ++)
	{
		if(i%2 == 0)
			prn_Buf[i+1] = chr;
	}
   prn_Str();
}


/*------------------------------------------------------------------------------------*
 *             Print one line give with same character.
 *------------------------------------------------------------------------------------*/
void prn_Full_Line(char chr)
{
	byte i;

	memset(prn_Buf+1,chr,MAX_PRN_LEN);
   prn_Str();
}


/*-----------------------------------------------------------------------------------*
 *    The universal function for print when gived the information and long number
 *    Parameter:  src_str: The information wanted to print in the left.
 *                num:     The long number wanted to print in the right.
 *                dots:    The number of radix point belong to the long number.
 *						mode:		DESC_OLD: Indicate using the old print buffer
 *									DESC_NEW: Indicate using the new print buffer.
 *-----------------------------------------------------------------------------------*/
void Prn_Adj_Ex(char *src_str, long num, byte dots, byte posi, byte mode)
{
    byte len; // 2006-08-29 new add.
    byte len2;
    
	if(((CurrMode == XREPORT) || (CurrMode == ZREPORT)) && (zero_skip_flag == 1))
	{
		if(sysflag->zero_skip)
		{
			if(num == 0)
			{
				clr_Prn_Buf();
				return;
			}
		}
	}
	if(mode == DESC_OLD)
	{
//		memcpy(prn_Buf+1,src_str,strlen(src_str));
        len = strlen(src_str);
        len2 = Cal_Len2(num, dots);
        xtr_strcpy(prn_Buf+1,src_str);		/* Modified on 2004-04-07 17:12 */
        if(len + len2  + 1 > posi)  //prn two line
            print();
        LongPrnFmt(num,dots,posi, RIGHTFLUSH);
 	    print();
	}
	else // mode == DESC_NEW
	{
//		Prn_InsFmtStr(src_str, 1, strlen(src_str)/2, NULL);
		Prn_InsFmtStr(src_str, 1, Get_Spec_Len(src_str), NULL);
		LongPrnFmt_Ex(num, dots, posi, RIGHTFLUSH, NM_FONT_PRN);
		Print_Ex(1);
	}
}


/*-----------------------------------------------------------------------------------*
 *    The universal function for print when gived the information and long number

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -