📄 tool.c
字号:
/*
* Module: TOOL.C
* Modified by: X.C.Zheng WeiHua
* Modified on: Date: 03-8-11 14:03
* Copyright(c) WeiHua Tech Ltd.
*/
#include "ecrsys.h"
#include "ftype.h"
#include "sysdata.h"
#include "data.h"
#include "string.h"
#include "stdlib.h"
#include "ctype.h"
#include "mathes.h"
#include "keydef.h"
#include "lcd2.h"
#include "disp.h"
extern volatile byte SpluKeyIn;
/** 0 1 2 3 4 5 6 7 8 9 **/
//const char deptab[MAX_DEPT_KEY_CNTR] =
// { KD_DP1 ,KD_DP2 ,KD_DP3, KD_DP4, KD_DP5 , KD_DP6 };
const char deptab[MAX_REL_DEPT_CNT] = {
KD_DP1, KD_DP2, KD_DP3, KD_DP4, KD_DP5, KD_DP6, KD_DP7, KD_DP8,
KD_DP9, KD_DP10, KD_DP11, KD_DP12, KD_DP13, KD_DP14, KD_DP15, KD_DP16,
KD_DP17, KD_DP18, KD_DP19, KD_DP20, KD_DP21, KD_DP22, KD_DP23, KD_DP24,
/* KD_DP25, KD_DP26, KD_DP27, KD_DP28, KD_DP29, KD_DP30, KD_DP31, KD_DP32, KD_DP33,
KD_DP34, KD_DP35, KD_DP36, KD_DP37, KD_DP38, KD_DP39, KD_DP40, KD_DP41, KD_DP42,
KD_DP43, KD_DP44, KD_DP45, KD_DP46, KD_DP47, KD_DP48, KD_DP49, KD_DP50,
*/
};
#ifdef REST_PLU_FUNC
const char menutab[MAX_MENU_KEY_CNTR] = {
KD_MENU01,KD_MENU02,KD_MENU03,KD_MENU04,KD_MENU05,
KD_MENU06,KD_MENU07,KD_MENU08,KD_MENU09,KD_MENU10
};
#endif
/*-----------------------------------------------------------------------------------------
* Get the Really key code with the physical key scanning code.
*
*----------------------------------------------------------------------------------------*/
word Rcode(word ch)
{
word key;
if (ch < TS_LOGI_OFFSET)
{
key = key_logi_get(key_logic, ch, MAX_KEY_CNT);
key = FF_Key_Get(key);
}
else {
key = ts_get_logi(ch); // The touch screen key logical from 1 to LCD_LAYOUT_MAX_KEY
key = TS_Key_Get(key);
}
return (key);
}
/******************************************************************************/
void InitTrans(void)
{
memset((void*)&tmpvars,0,sizeof(Inter_Var));
TnsBf_Len = 0; /* Clear the transaction buffer */
SndTnsBf_Len = 0; /* Clear the second transaction buffer */
NewTrans = 0;
Cash_flag = 0;
RM_flag = 0;
Mul_flag = 0;
Void_flag = 0;
pluenflag = 0;
Subt_Prn_Flag = 0;
Subt_Press_Flag = 0;
memset(TaxFlag, 0, MAX_TAX_NUM);
// Tax1Flag = Tax2Flag = Tax3Flag = 0;
#ifdef AUTO_PER /* Support the department auto percent function */
Auto_Per_Flag = 0;
#endif /* End AUTO_PER */
store_head_step = 0;
#ifdef REST_PLU_FUNC
do_menu_flag=0;
#endif
table_awake_len = 0;
#if 0
Rst_Tl_Sub();
Rst_Lcd_Text();
#endif
}
/******************************************************************************/
/* display 'E' and wait for clear, then clear display */
void error(void)
{
errorMsg(Disp_Err_Normal);
return;
}
/******************************************************************************
* display massage and wait for clear, then clear display
******************************************************************************/
void errorMsg(char *str)
{
if(pass_flag == 1)
return;
if(MainMode == X_OFF) /* LOCK mode, return */
return;
if ( ((MainMode == REGISTER)||(MainMode == TRAINING)) && (currclerk == NUL_VLU)
&& (sysflag->clerk_mode)/* || (MainMode == ZREPORT && z_scrt_flag) */)
return;
#ifdef VER_RSNT /* Support the restaurant function */
if(waiter_input_flag)
return;
#endif /* End VER_RSNT */
if (!Lcd_Err_Flag) {
Lcd_Err_Flag = 1;
Lcd_Err_Type(0, str); /* The normal error type */
}
Clr_Period();
Disp_Spec_Period(); /* Dispaly the special period */
VFDDisplay(str, CLEARD, LEFT); /* Display the error information */
bellcnt = 0xFE;
while (!Lcd_Chk_Sure_Key());
// bellcnt = 29;
InCmd=KD_CLEAR; /* Press the CLEAR key */
LCD_Back_Set();
// bellcnt = 0; /* If a key press, the bellcnt has changed */
// if((CurrMode == REGISTER)||(CurrMode == TRAINING))
/* Can not do this judge, for the control lock is changed
but the flag must be cleared */
{
if(!sysflag->tax_shift_mode)
Clr_Tax_Flag();
Clr_Staus_Flag();
}
Disp_Mode();
Clr_Dsp_Data();
RightDisp(0L,sysflag->sysdots); /* Display the zero to the LCD, indicate it has clear the error */
Lcd_Tl_Input_Disp(TL_INPUT_CLEAR, 0);
if (chk_res_last_disp()) {
dis_res_last_disp();
Lcm_Disp_Last_Line(LCM_LINE_2);
}
if (Lcd_Err_Flag) {
Lcd_Err_Flag = 0;
Lcd_Res_Pop_Text();
}
}
/*----------------------------------------------------------------------------
* Check whether the input key is digit key.
* return : 0 - 9 digits key index.
* : 0xff Not the digits key
*---------------------------------------------------------------------------*/
byte Isdigit(word key_code, const word *str)
{
char i;
for ( i = 0; i < MAX_DIGIT_NUM ; i ++ )
{
if ( key_code == str[i] )
break;
}
if ( i >= MAX_DIGIT_NUM )
i = 0xFF;
return(i);
}
/******************************************************************************
* Get tenkey input.
*
* return the long data which input by user.
*
* The input number can store in the input buffer 'In_Buff'(BCD code), also this function
* can changed it to the long data stored in variable 'lnum'.
*******************************************************************************/
byte GetIn(void)
{
byte i;
byte Mode;
byte max_dec_len; /* The max length of fractional section */
word key,keybak;
numcnt = 0;
dec_flag = 0;
dec_cnt = 0;
if((sysflag->dept_shift)&&(DeptShiftFlag != 0)) /* Active or not the function of it. */
{
DeptShiftFlag=0; /* Clear the department shift counter */
}
else if((sysflag->DPLU_shift)&&(DPLUShiftFlag != 0))
{
DPLUShiftFlag=0; /* Clear the department shift counter */
Lcd_Shift_Exchange(KD_DPLUSF);
}
// DeptShiftFlag=0; /* Clear the department shift counter */
#ifdef SCANNER /* Support the scanner function */
BarInFlag = 0;
#endif /* End SCANNER */
mode_disp_flag = 0;
if(en_long_dec_input_flag == 1)
max_dec_len = long_dec_input_len;
else
max_dec_len = 3;
/* do keyin circle */
while (TRUE)
{
#ifndef SCANNER
if ((numcnt > NUMLIMIT) || (dec_cnt > max_dec_len)) /* Check the last input is legal or not */
#else /* Else SCANNER */
if((numcnt > MAX_INPUT_LEN) || (dec_cnt > max_dec_len))
#endif /* End SCANNER */
{
Clr_DPSF_Disp();
errorType(ERR_DIGIT_ILLEGAL);
return (NG);
}
key = GetKey();
if(key == KD_NULL)
continue;
if( key == KD_RCPT_ON )
{
if((NewTrans) || (Flag_Prgm_Head) || (Idvul_Head_Prn_Flag == PRINTD) || (CurrMode == X_OFF))
{
errorType(ERR_PRN_NOT_END);
return (NG);
}
sysflag->Rcpt_prn = !sysflag->Rcpt_prn;
disp_receipt_prn_mode();
continue;
}
if( key == KD_FEED )
{
Key_Feed();
continue;
}
if( numcnt==0 )
{
if(((CurrMode == REGISTER)||(CurrMode == TRAINING)) && ((currclerk != NUL_VLU)
|| (sysflag->clerk_mode == 0)) && (sysflag->sysdots != 0) && (!waiter_input_flag))
/* In the transaction mode, set the period If the decimal position is 0, not to display it */
{
if( (InCmd == KD_AMOUNT) /*|| (InCmd == KD_XTIME) */)
VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1,CLR); /* Clear the period when the price has inputed */
else
VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1,SET); /* Set the period when the price has't inputed */
}
#if 0
if (disp_report_flag) {
if ( (CurrMode == XREPORT) && (CurrMode == ZREPORT) ) {
//Lcm_Disp_Clr(LCM_LINE_2);
Disp_Mode(); // 在报表里面输入时,由于第一行的关系,所以在这里必须清除。
}
}
#endif
}
if(((CurrMode == REGISTER)||(CurrMode == TRAINING))&& ((key == KD_RM)
|| (key == KD_TAXSFT1) || (key == KD_TAXSFT2) ||(key == KD_TAXSFT3) || (key == KD_TAXSFT4) || (key == KD_TAX_EMP))) /* In the sale mode */
{
if(pass_flag == 1)
continue;
if( !(((sysflag->clerk_mode == 1) && (currclerk == NUL_VLU)) && (waiter_input_flag)) )
/* If currclerk is null and in the register
mode, indicate the program is in wait the clerk password input .
*/
{
if((InCmd == KD_XTIME) && ((CurrMode == REGISTER) || (CurrMode == TRAINING)) && (numcnt == 0))
VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1,CLR); /* Clear the period when the price has inputed */
if(mode_disp_flag)
{
mode_disp_flag = 0;
Clr_Dsp_Data();
RightDisp(0, sysflag->sysdots);
}
if(key == KD_RM) /* Return Merchandise key */
Do_RM();
else if(key == KD_TAX_EMP) /* Tax Excemp key */
Do_STAXEMP();
else // key == KD_TAXSFT1,2 /* Tax Shift key */
Do_STAXSFT(key);
}
continue;
}
switch (key)
{
case KD_MODE:
case KD_F1:
if(sysflag->soft_lock_flag != 1)
{
Clr_DPSF_Disp();
errorType(ERR_KEY_ILLEGAL);
return (NG);
}
if(numcnt == 0)
{
Disp_Mode(); /* Dispaly the current mode */
mode_disp_flag = 1;
break;
}
if(numcnt != 1)
{
Clr_DPSF_Disp();
errorType(ERR_MODE);
return (NG);
}
if(In_Buff[0] == 0)
Mode = X_OFF;
else if(In_Buff[0] == 1)
Mode = REGISTER;
else if(In_Buff[0] == 2)
Mode = XREPORT;
else if(In_Buff[0] == 3)
Mode = ZREPORT;
else if(In_Buff[0] == 4)
Mode = PROGRAM;
else
{
Clr_DPSF_Disp();
errorType(ERR_MODE);
return (NG);
}
if(Mode != CurrMode)
{
if((CurrMode == REGISTER) || (CurrMode == TRAINING)) /* Sale check */
{
if(NewTrans) /* The transaction not end, error */
{
Clr_DPSF_Disp();
errorType(ERR_SALE_NO_END);
return (NG);
}
}
else if(CurrMode == PROGRAM) /* Program check */
{
if(progflag)
{
Clr_DPSF_Disp();
errorType(ERR_PROGRAM_NO_END);
return (NG);
}
}
Clr_DPSF_Disp();
currmodeInt = Mode;
Lcd_Tl_Input_Disp(TL_INPUT_INPUTED, 0);
return (OK);
}
else
{
Clr_DPSF_Disp();
return (NG);
}
break;
case KD_PAGE_UP:
case KD_PAGE_DOWN:
case KD_UP:
case KD_DOWN:
if((CurrMode == PROGRAM)||((CurrMode == XREPORT||CurrMode == ZREPORT)&&(Rpt_Disp_Roll_flag == 0)))
{
lastincmd = InCmd;
InCmd = key;
return OK;
}
else
Lcd_Roll(key); /* Roll the text screen */
break;
case KD_DEC : /* Is dot, set dot flag */
if(dec_flag == 1)
{
Clr_DPSF_Disp();
errorType(ERR_DEC_PRESS);
return (NG);
}
else
{
dec_flag = 1;
if(numcnt == 0)
In_Buff[numcnt++] = 0;
TransDis(numcnt);
}
break;
case KD_0:
if(dec_flag)
dec_cnt ++;
In_Buff[numcnt++] = 0;
TransDis(numcnt);
break;
case KD_D0 : /* For '00' key in */
if(dec_flag)
dec_cnt += 2;
In_Buff[numcnt++] = 0;
TransDis(numcnt);
In_Buff[numcnt++] = 0;
TransDis(numcnt);
break;
case KD_T0: /* For '000' key in */
if(dec_flag)
dec_cnt += 3;
In_Buff[numcnt++] = 0;
TransDis(numcnt);
In_Buff[numcnt++] = 0;
TransDis(numcnt);
In_Buff[numcnt++] = 0;
TransDis(numcnt);
break;
case KD_DPSF:
lastincmd = InCmd; /** this place will change **/
InCmd = KD_DPSF;
return OK;
case KD_DPLUSF:
if(MainMode == X_OFF) /* Lock mode */
break;
if(pass_flag == 1)
break;
if((InCmd == KD_XTIME) && ((CurrMode == REGISTER) || (CurrMode == TRAINING)) && (numcnt == 0))
VFDSetPeriod(MAX_LCD_NUM - sysflag->sysdots - 1,CLR); /* Clear the period when the price has inputed */
if((key == KD_DPSF)&&(!sysflag->dept_shift))
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -