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

📄 tool.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
	{
		prn_Power_Dwn_Info();
   	GetMainMode();
   	if(MainMode != REGISTER)
   	{
			/* This case will not occur when use the soft control lock */
   		if(sysflag->soft_lock_flag == 1)
   			CurrMode = MainMode = REGISTER;
      	bellcnt = 0xFF;
      	while ( GetMainMode() != REGISTER );
      	Clr_Key_Buff();
			bellcnt = 0x00;
   	}
   	return;
   }
	#ifdef VER_RSNT		/* Support the restaurant function */
	/* When some tables transaction is not end, and all is suspended, print the information also */
	if(work_mode == RSNT)
	{
		if(Rsnt_ChkSale() == NOTOK)
		{
//			prn_Power_Dwn_Info();
		}
	}
	#endif /* End VER_RSNT */
}


/*-----------------------------------------------------------------------------*
 *                The free function key get key input function.
 *-----------------------------------------------------------------------------*/
byte FFkey_GetIn(void)
{
   char key,keybak;

   numcnt = 0;
   while (TRUE)
   {
      if ( numcnt > NUMLIMIT )
      {
         errorType(ERR_DIGIT_ILLEGAL);
         return (NG);
      }

      key = GetKey();
      if(numcnt == 0)
      {
         memset( In_Buff, ' ',MAX_LCD_NUM);
         In_Buff[0] = 0xFF;
//			Clr_Dsp_Data();
      }

      switch (key)
      {
         case CTRL_LOCK_CHG :						/* Control lock changed */
            InCmd = KD_NULL;
            return (OK);

         #ifdef SCANNER			/* Support the scanner function */
         case SPLU:
         	break;
         #endif /* End SCANNER */

         default :
            keybak=key;
            key = Isdigit(key, digit_code_table);
//            if( (key >= (unsigned char)0) && (key <= (unsigned char)9) )
				if(key != 0xFF)			/* Is the digit key */
            {
               if(numcnt == 0)
               	Clr_Dsp_Data();
               In_Buff[numcnt++]= key;
               TransDis(numcnt);
            }
            else                                /* do for command */
            {
               lastincmd=InCmd;                 /** this place will change **/
               InCmd = keybak;
               if (numcnt)
               {
                  In_Buff[numcnt] = 0xFF;
                  asc2long();
               }
               else
                  lnum = 0L;
               return (OK);
            } /* end else */
      }/* end switch */
   }/* end while */
   return (OK);
}


/*-------------------------------------------------------------------------------------*
 *                Clear the department shift display in the LCD.
 *-------------------------------------------------------------------------------------*/
void Clr_DPSF_Disp(void)
{
//	disp_Char_Str("   ",0);    /* Display the character string to the LCD, can clear the pervious display */
	VFDSetPeriod(0,CLR);
	VFDSetPeriod(1,CLR);
	VFDSetPeriod(2,CLR);
}


/*-------------------------------------------------------------------------------------*
 *                      Get the PCASH number.
 *-------------------------------------------------------------------------------------*/
byte get_PCASH(void)
{
   byte tmp;
   
	if(InCmd == KD_PCASH1)
      tmp = 0;
   else if(InCmd == KD_PCASH2)
      tmp = 1;
   else if(InCmd == KD_PCASH3)
      tmp = 2;
   else //(InCmd == KD_PCASH4)
      tmp = 3;
      
   return (tmp);
}


#ifdef FCE_FUNC		/* Support the FCE function */
/*-------------------------------------------------------------------------------------*
 *                      Get the PCASH number.
 *-------------------------------------------------------------------------------------*/
byte getFCE(void)
{
	byte tmp;

	if(InCmd == KD_FCE1)
		tmp = 0;
	else if(InCmd == KD_FCE2)
		tmp = 1;
	else if(InCmd == KD_FCE3)
		tmp = 2;
	else if(InCmd == KD_FCE4)
		tmp = 3;
	else // InCmd == KD_FCE
	{
		if(numcnt)			/* Has input the digit */
			tmp = lnum - 1;
		else					/* Not input the digit */
			tmp = 0;
	}
	return (tmp);
}
#endif /* End FCE_FUNC */


/*--------------------------------------------------------------*
 *			Adjust the print Quantity data:
 *					Quantity:			Print format:
 *						12.345					12.345Q
 *						12.340					 12.34Q
 *						12.300					  12.3Q
 *						12.000						 12Q
 *						12.003					12.003Q
 *						 0.000						  0Q	// This case may be appear in the individual report
 *
 *			Store the adjust long number to 'adj_num'.
 *			Store teh adjust dots to 'adj_dots'.
 *--------------------------------------------------------------*/
void Qty_Adjust(long num)
{
	byte i;

	if(num == 0)			/* If the adjust is 0, print 0Q, this case may appear in the individual report */
	{
		adj_dots = 0;
		adj_num = 0;
		return;
	}

	adj_dots = 3;
	for(i = 0; i < 3; i ++)
	{
		if((num != 0) && (num % 10) == 0)
		{
			num /= 10;
			adj_dots --;
		}
		else
			break;
	}

	adj_num = num;
}


/*-----------------------------------------------------------------*
 *			Check the input DEC key is legal or illegal.
 *-----------------------------------------------------------------*/
byte en_dec_chk(word key)
{
	if((CurrMode == REGISTER) || (CurrMode == TRAINING))
	{
		if((key == KD_XTIME) || (key == KD_PER1) || (key == KD_PER2) 
					|| (key == KD_PER3) || (key == KD_CLEAR))
			return (OK);
		else
			return (NG);
	}
	else if(CurrMode == PROGRAM)
	{
		if((Prog_en_dec_input_flag == 1) || (key == KD_CLEAR) || (key == KD_CASH))
									/* In program mode, the CASH key used for the cancel operation */
			return (OK);
		else
			return (NG);
	}
	else if((CurrMode == XREPORT) || (CurrMode == ZREPORT))
	{
		if(key == KD_CLEAR)
			return (OK);
		else
			return (NG);
	}
	else
		return (NG);
}


static CHR day_of_month[MONTH]=
{
   31,28,31,30,31,30,31,31,30,31,30,31
};

/*******************************************************
 * Check if it is a leap year                          *
 * Argument: year----the year to be checked            *
 * Return:   TRUE  ---- it is a leap year              *
 *           FALSE --- it is not a leap year           *
 *******************************************************/
CHR leapyear(CHR year)
{
   WORD testyear;
   
   testyear = 2000 + year;

   if( (testyear%4) ==0)
   {
      if( (testyear%100)==0)
      {
         if( (testyear%400) ==0)
            return(TRUE);
         else
            return(FALSE);
      }
      else
         return(TRUE);
   }
   else
      return(FALSE);
}

/*******************************************************
 * Simply check whether it's a valid date.             *
 * NG     ---- Invalid date.                           *
 * OK    ---- Valid date.                              *
 ******************************************************/
CHR IsDay( byte year, byte month, byte day )
{
   if(year > 99)
   	return (NG);
   if((month == 0) || ( month > 12 ))
   	return (NG);
   if(day == 0)
   	return ( NG ); 

   if(leapyear(year) == TRUE)
      day_of_month[1] = 29;
   else  
      day_of_month[1] = 28;

   if(day > day_of_month[month-1])
      return(NG);
   else
      return(OK);
}


/*--------------------------------------------------*
			Clear the status flag.
 *--------------------------------------------------*/
void Clr_Staus_Flag(void)
{
 	Void_flag=0;
 	RM_flag = 0;
 	Mul_flag = 0;
 	pluenflag = 0;

	ra_flag = 0;
	po_flag = 0;
}


#ifdef VER_RSNT
/*--------------------------------------------------------------------*
					Check the restaurant sale is end or not.
						OK: 		The restaurant sale is not end.
						NOTOK: 	The restaurant sale is end.
 *--------------------------------------------------------------------*/
byte Rsnt_ChkSale(void)
{
	byte i;

	for(i = 0; i < Max_Table_No; i ++)
	{
		if(table[i].status == 1)
		{
			return (NOTOK);
		}
	}
	return (OK);
}


/*-----------------------------------------------------------------------*
		From the table's logical number, get the table's physical number
 *-----------------------------------------------------------------------*/
byte Get_Table(long num, int *pidx)
{
	byte i;

//	if((num <= 0) || (num > MAX_TABLE_LOGI_NO))
//		return (NG);
	for(i = 0; i < Real_Table_No; i ++)
	{
		if(num == table[i].Logi_No)
		{
			*pidx = i;
			return (OK);
		}
	}
//	if(i == Max_Table_No)
		return (NG);
}
#endif /* End VER_RSNT */

#ifdef SCANNER			/* Support the scanner function */
/*-----------------------------------------------------------*
			Check enable the long number input legal or not
 *-----------------------------------------------------------*/
byte en_longnum_chk(word key)
{
	if(key == KD_CLEAR)
		return (OK);
	if(dec_flag)
		return (NG);
	if((key == KD_PLU))
		return (OK);
	if((CurrMode == PROGRAM) && ((key == KD_SUBTTL)||key == KD_SURE||key == KD_ENTER) && (ProgBar == 1 ))
		return (OK);
	return (NG);
}
#endif /* End SCANNER */


/*-----------------------------------------------------------------------*
				Check the key pressed or the control lock changed.
 *-----------------------------------------------------------------------*/
byte Chk_KeyPrs_LockChg(byte flag)
{
	if(Key_Poll_Chk() == TRUE)
	{
		if(flag == 1)
			Clr_Key_Buff();
		return (NOTOK);
	}
	GetMainMode();
	if(MainMode != CurrMode)
		return (NOTOK);
	return (OK);
}


#define	MAX_BUF_LEN1			23
/************************************************************************/
void DLongPrnFmt(DoubleLong dl, byte Location, byte Direction, byte Adj_Len)
{
	byte len;
	char tmp_str[MAX_BUF_LEN1];			/* The temporary string, store the ASCII format data */

	if(Location > MAX_PRN_LEN)
		return;
	DLong2Asc(&dl, tmp_str, Adj_Len);
	len = strlen(tmp_str);
	if(Direction == RIGHTFLUSH)
	{
		if(len > Location)
			memcpy(prn_Buf+1, tmp_str, Location);
		else
			memcpy(prn_Buf+Location-len+1, tmp_str, len);
	}
	else if(Direction == LEFTFLUSH)
	{
		if(len > MAX_PRN_LEN - Location + 1)
			memcpy(prn_Buf+Location, tmp_str, MAX_PRN_LEN-Location+1);
		else
			memcpy(prn_Buf+Location, tmp_str, len);
	}
}
#undef	MAX_BUF_LEN1			/* Release the define */

#if 0
#if KB == KB_59N24
/*----------------------------------------------------------------------*
					When press the 1,3,7,9 key at one time,
				doint initial the 
 *----------------------------------------------------------------------*/
void Chk_Init(void)
{
	byte i, k = 0;
	word cnt;
	word temp[MAX_KEY_SCAN_CNTR];
	word k_digit2;
	word ctrl_lock;		// The control lock.

	extern	const char keyScanCode[];
	const word key_comp_data_P_MODE[MAX_KEY_SCAN_CNTR] = 
	{	// P mode, 1, 3, 7, 9 key
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0A, 0x0A, 0x0A, 0x0A
	};
	const word key_comp_data_LOCK_MODE[MAX_KEY_SCAN_CNTR] = 
	{	// LOCK mode, 1, 3, 7, 9 key
		0, 0, 0, 0, 0, 0, 0, 0, 0, 0x0A, 0x0A, 0x0A, 0
	};
	const word key_comp_data_R_MODE[MAX_KEY_SCAN_CNTR] = 
	{	// R mode, 1, 3, 7, 9 key
		0, 0, 0, 0, 0,

⌨️ 快捷键说明

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