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

📄 pc_comm.c

📁 一款收款机C源代码!因为是几年前的代码了
💻 C
📖 第 1 页 / 共 5 页
字号:
			Do_Waiter_Rpt_Up();
			break;
		#endif /* End VER_RSNT */

	case	ECHO_STATUS:
	case HAND_SHAKE:
		/* Remain */
		break;
	
    #ifdef REST_PLU_FUNC
	case	PLUTAB_UP:
		Do_PLU_relation_tabl_Up();
		break;
    #endif
    
    #ifdef ELEC_SCALE
	case	SCALEPLU_PARA_UP:
		Do_Scale_PLU_Para_Up();
		break;

	case	SCALEPLU_DATA_UP:
		Do_Scale_PLU_Data_Up();
		break;
#endif
		default:							/* The nonexistent command code. */
			Send_Error_Info(NON_EXIST_CMD);
			break;
	}
}


/*****************************************************************************/
/*--------------------------------------------------------------------------*
					PLU parameter down-load.
Note: when changed the bar code, the quantity and the amount must be void.
				This is used for the user's wrong operation.
 *--------------------------------------------------------------------------*/
void Do_PLU_Dwn(void)
{
	byte i;
	int j;
	int idx;
	PLU_STRU *plu_stru;

	if(Data_Len != (2 + COMM_PLU_NUM * sizeof(PLU_STRU)))				/* When the data length is not the demand length */
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	idx = (int)(*((int *)&Data_Area));				/* Get the PLU number */
	if((idx > (Max_Plu_No/* - COMM_PLU_NUM + 1*/)) || (idx <= 0))
				/* The number of PLU commnication in one time is 10 */
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if((idx > Max_Plu_No - COMM_PLU_NUM + 1) || (COMM_PLU_NUM > Max_Plu_No))
	{
		/* Judge the data is zero or not, if not all zero, send an error information, Remain. */
	}
	idx --;

	plu_stru = (PLU_STRU *)(Data_Area + 2);
	for(i = 0, j = idx; (i < COMM_PLU_NUM) && (j < Max_Plu_No); i ++, j ++)
	{
		if((plu_stru[i].Dept_link > Max_Dept_No) || (plu_stru[i].Dept_link == 0))		/* The PLU linked department is error */
		{
			Send_Error_Info(NOT_MATCH_FORMAT);
			return;
		}
        #ifdef REST_PLU_FUNC
		if (plu_stru[i].Attribute.mode > 2)
		{
			Send_Error_Info(NOT_MATCH_FORMAT);
			return;
		}
        #endif
	}
	if(clr_PLU_flag == 0)
	{
		clr_PLU_flag = 1;
		Clr_PLU_Rpt(PTD);
		Clr_PLU_Rpt(DAILY);
	}

	for(i = 0, j = idx; (i < COMM_PLU_NUM) && (j < Max_Plu_No); i ++, j ++)				/* Update the PLUs data */
	{
		#ifdef SCANNER			/* Support the scanner function */
		memcpy(plu[j].barcode, plu_stru[i].Bar_Code, BAR_BUFF_LEN);
		plu[j].barcode[6] &= 0x0F;
        #endif /* End SCANNER */
		plu[j].plink = plu_stru[i].Dept_link;

        #ifdef REST_PLU_FUNC
		plu[j].attr = plu_stru[i].Attribute;
        #endif
		plu[j].price = Bcd2Long(plu_stru[i].Pre_Price, 3);
		memcpy(plu[j].desc, plu_stru[i].Desc, MAX_DESC_LEN_EX+1);
	}

	Send_Succeed_Info();
	#ifdef SCANNER 		/* Support the scanner function */
	signal = 0;
//	Length = 0;				/* When down the PLU's attribute, will first down the PLU index table, so no need used 
//									this flag again */
	#endif /* End SCANNER */
}

#ifdef SCANNER 		/* Support the scanner fuction */
/*-----------------------------------------------------------------------*
					PLU index table down-load.
 *-----------------------------------------------------------------------*/
void Do_PLU_Idx_Dwn(void)
{
	byte i;
	int j;
	int idx;
	int *p;

	if(Data_Len != (2 + COMM_PLU_INDEX_NUM * 2))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	idx = (int)(*((int *)&Data_Area));				/* Get the PLU index number */
	if((idx > (Max_Plu_No/* - COMM_PLU_INDEX_NUM + 1*/)) || (idx <= 0))
				/* The number of PLU commnication in one time is 10 */
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if((idx > Max_Plu_No - COMM_PLU_INDEX_NUM + 1) || (COMM_PLU_INDEX_NUM > Max_Plu_No))
	{
		/* Judge the data is zero or not, if not all zero, send an error information, Remain. */
	}
	idx --;

	p = (int *)(&(Data_Area[2]));
	for(i = 0, j = idx; (i < COMM_PLU_INDEX_NUM) && (j < Max_Plu_No); i ++, j ++)
	{
		if((p[i] > Max_Plu_No) || (p[i] == 0))			/* In the PC side, the index table store the first PLU number of 1, not 0 */
		{
			Send_Error_Info(NOT_MATCH_FORMAT);
			return;
		}
	}
	#ifdef SCANNER				/* Support the scanner function */
	for(i = 0, j = idx; (i < COMM_PLU_INDEX_NUM) && (j < Max_Plu_No); i ++, j ++)
	{
		Sindex[j] = p[i] - 1;			/* In the PC side, the index table store the first PLU number of 1, not 0 */
	}
	signal = 1;
	#endif /* End SCANNER */
	Send_Succeed_Info();
}
#endif /* End SCANNER */

/*-----------------------------------------------------------------------*
					System parameter down-load.
 *-----------------------------------------------------------------------*/
void Do_Sys_Para_Dwn(void)
{
	byte i;
	byte bak_wgt_bar_id;
	byte dept_increase, line_feed_count;
	SYSFLAGDEF Sys_Flag;

	if(Data_Len != SYS_PARA_LEN)
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if(Data_Area[16] != 0x00)			/* The HALO, max is 8 digits, so the fifths BCD byte must be 0 */
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if(((Data_Area[17]>>4)*10+(Data_Area[17]&0x0F)) > MAX_LOGO_NUM)
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	bak_wgt_bar_id = Bcd2dec(Data_Area[18]);
	if(((bak_wgt_bar_id < 20) || (bak_wgt_bar_id > 29)) && (bak_wgt_bar_id != 99))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if((Data_Area[19] < 1) || (Data_Area[19] > 9))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if(Data_Area[20] > 1)
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	dept_increase = Bcd2dec(Data_Area[21]);
	if ((dept_increase < 1) || (dept_increase > 24))	// Judge the increase of dept is right or not
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	line_feed_count = Bcd2dec(Data_Area[26]);
	if (line_feed_count > 9)// Judge the count of line feed is right or not
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	
	Sys_Flag.SF = Data_Area[0];
	if((Sys_Flag.SF1.datefmt == 3) || (Sys_Flag.SF1.xCount_round == 3) || (Sys_Flag.SF1.tax_round == 3))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if(sysflag->sysdots != Sys_Flag.SF1.sysdots)
	{
		if((Chk_Rpt_Clr() == FALSE) || (Rsnt_ChkSale() == NOTOK))
		{
			Send_Error_Info(REPORT_NOT_VOID);
			return;
		}
	}
	Sys_Flag.SF = Data_Area[1];
	#ifdef VER_RSNT			/* Support the restaurant function */
	if((sysflag->clerk_mode != Sys_Flag.SF2.clerk_mode) && (Rsnt_ChkSale() == NOTOK))
	{
		PC_Comm_Exit_Send();
		errorType(ERR_SALE_NO_END);
		Make_Virtual_Key(KD_CLEAR);		/* Exit the communication */
		return;
	}
	#endif /* End VER_RSNT */
	if(sysflag->Tax_System != Sys_Flag.SF2.Tax_System)
	{
		if((Chk_Rpt_Clr() == FALSE) || (Rsnt_ChkSale() == NOTOK))
		{
			Send_Error_Info(REPORT_NOT_VOID);
			return;
		}
	}
	Sys_Flag.SF = Data_Area[2];
	#ifdef VER_RSNT			/* Support the restaurant function */
	#ifdef STOCK 				/* Support the PLU stock function */
	if((sysflag->PLU_Stock_Flag != Sys_Flag.SF3.PLU_Stock_Flag) && (Rsnt_ChkSale() == NOTOK))
	{
		PC_Comm_Exit_Send();
		errorType(ERR_SALE_NO_END);
		Make_Virtual_Key(KD_CLEAR);		/* Exit the communication */
		return;
	}
	#endif /* End STOCK */
	#endif /* End VER_RSNT */
	Sys_Flag.SF = Data_Area[3];
	if((sysflag->Btm_Msg_Flag != Sys_Flag.SF4.Btm_Msg_Flag) && (Rsnt_ChkSale() == NOTOK))
	{
		PC_Comm_Exit_Send();
		errorType(ERR_SALE_NO_END);
		Make_Virtual_Key(KD_CLEAR);		/* Exit the communication */
		return;
	}
	if((sysflag->soft_lock_flag == 0) && (Sys_Flag.SF4.soft_lock_flag == 1))
	{
		if(Get_Scan_Lock() == X_OFF)	/* When no hard control lock, the scan result is equal to the LOCK value */
		{
			errorType(NO_HARD_CTRL_LOCK);
			return;
		}
	}
	Sys_Flag.SF = Data_Area[4];
	if ((Sys_Flag.SF5.kp_font == 0) || (Sys_Flag.SF5.kp_font == 5) || (Sys_Flag.SF5.kp_font == 6) || (Sys_Flag.SF5.kp_font == 7))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	Sys_Flag.SF = Data_Area[5];

	Sys_Flag.SF = Data_Area[0];
	sysflag->datefmt					=		Sys_Flag.SF1.datefmt;
	sysflag->sysdots					=		Sys_Flag.SF1.sysdots;
	sysflag->xCount_round			=		Sys_Flag.SF1.xCount_round;
	sysflag->tax_round				=		Sys_Flag.SF1.tax_round;

	Sys_Flag.SF = Data_Area[1];
	if((sysflag->clerk_mode == 1) && (Sys_Flag.SF2.clerk_mode == 0))		/* When the clerk mode is not equal, clear the report */
	{
		Clr_Clerk_Rpt(DAILY);
		Clr_Clerk_Rpt(PTD);
		currclerk = NUL_VLU;
		sysflag->clerk_mode = Sys_Flag.SF2.clerk_mode;
	}
	else if((sysflag->clerk_mode == 0) && (Sys_Flag.SF2.clerk_mode == 1))
	{
		currclerk = NUL_VLU;
		sysflag->clerk_mode = Sys_Flag.SF2.clerk_mode;
	}
	sysflag->zero_skip				=		Sys_Flag.SF2.zero_skip;
	sysflag->prn_table_detail		=		Sys_Flag.SF2.prn_table_detail;
	sysflag->z_reset_rcpt_no		=		Sys_Flag.SF2.z_reset_rcpt_no;
	sysflag->Tax_System			=		Sys_Flag.SF2.Tax_System;
	sysflag->tax_shift_mode			=		Sys_Flag.SF2.tax_shift_mode;
	sysflag->Prn_Bar_Flag			=		Sys_Flag.SF2.Prn_Bar_Flag;
	sysflag->check_clerk				=		Sys_Flag.SF2.check_clerk;

	Sys_Flag.SF = Data_Area[2];
	sysflag->Subt_PressPrn					=		Sys_Flag.SF3.Subt_PressPrn;
	#ifdef STOCK		/* Support the PLU stock function */
	sysflag->PLU_Stock_Flag			=		Sys_Flag.SF3.PLU_Stock_Flag;
	#endif /* End STOCK */
	sysflag->BackLight				=		Sys_Flag.SF3.BackLight;
	LCD_Back_Set();
	sysflag->NS_switch				=		Sys_Flag.SF3.NS_switch;
	sysflag->RPLDP_flag				=		Sys_Flag.SF3.RPLDP_flag;
	sysflag->dept_shift				=		Sys_Flag.SF3.dept_shift;
	sysflag->Rcpt_prn				=		Sys_Flag.SF3.Rcpt_prn;
	disp_receipt_prn_mode();
	sysflag->fl_wmotor				=		Sys_Flag.SF3.fl_wmotor;

	Sys_Flag.SF = Data_Area[3];
	sysflag->Btm_Msg_Flag			=		Sys_Flag.SF4.Btm_Msg_Flag;
	#ifdef SCANNER		/* Support the SCANNER function */
	sysflag->Input_Bar_Mode			=		Sys_Flag.SF4.Input_Bar_Mode;
	#endif /* End SCANNER */
	if((sysflag->soft_lock_flag == 0) && (Sys_Flag.SF4.soft_lock_flag == 1))
		Modi_Key(2, KD_MODE, 0);
	sysflag->soft_lock_flag 		= 		Sys_Flag.SF4.soft_lock_flag;
	#ifdef AUTO_PER	/* Support the auro percent function */
	sysflag->Auto_Per_Use_Flag		=		Sys_Flag.SF4.Auto_Per_Use_Flag;
	sysflag->Auto_Per_Prn_Flag		=		Sys_Flag.SF4.Auto_Per_Prn_Flag;
	#endif /* End AUTO_PER */
	#ifdef ELEC_JRNL	/* Suport the electronic journal function */
	sysflag->Elec_Jrnl_VAT_Flag	=		Sys_Flag.SF4.Elec_Jrnl_VAT_Flag;
	#endif /* End ELEC_JRNL */
	#ifdef VER_RSNT	/* Support the restaurant function */
	sysflag->Waiter_Must_Flag		=		Sys_Flag.SF4.Waiter_Must_Flag;
	sysflag->Waiter_Sure_Flag		=		Sys_Flag.SF4.Waiter_Sure_Flag;
	#endif /* End VER_RSNT */

	Sys_Flag.SF = Data_Area[4];
	sysflag->Udt_Stock_Mode			=		Sys_Flag.SF5.Udt_Stock_Mode;
	sysflag->zero_trans_flag		=		Sys_Flag.SF5.zero_trans_flag;
	kp_font								=		Sys_Flag.SF5.kp_font;
	sysflag->LogoPosi_Flag			=		Sys_Flag.SF5.LogoPosi_Flag;
	sysflag->PrnAdj_Flag				=		Sys_Flag.SF5.PrnAdj_Flag;
	
	Sys_Flag.SF = Data_Area[5];
	sysflag->Log_Atv_Flag			=		Sys_Flag.SF6.Log_Atv_Flag;
//	sysflag->Compulsory_clerk		=		Sys_Flag.SF6.Compulsory_clerk;
	sysflag->Security					=		Sys_Flag.SF6.Security;
	sysflag->prn_tab_pre_posi		=		Sys_Flag.SF6.prn_tab_pre_posi;

	sysflag->McheNum					=		Bcd2Long(Data_Area+8,2);
	sysflag->RcptNum					=		Bcd2Long(Data_Area+10,2);
	sysflag->HaloNum					=		Bcd2Long(Data_Area+12,4);
	// Data_Area+11		/* This is always 0 */
	sysflag->CurrLogoNo = ((Data_Area[17]>>4)*10+(Data_Area[17]&0x0F));
	sysflag->wgt_bar.id = bak_wgt_bar_id;
	sysflag->wgt_bar.len = Data_Area[19];
	sysflag->wgt_bar.flag = Data_Area[20];
	sysflag->Dept_Shift_Inc =	((Data_Area[21]>>4)*10+(Data_Area[21]&0x0F));
	sysflag->top_cash_ttl	=	Bcd2Long(Data_Area+22,4);
	sysflag->LineFeedCnt		=	((Data_Area[26]>>4)*10+(Data_Area[26]&0x0F));
	Send_Succeed_Info();
}

/*-----------------------------------------------------------------------*
					Clerk parameter down-load.
 *-----------------------------------------------------------------------*/
void Do_Clerk_Dwn(void)
{
	byte i;
	byte j;
	byte idx;
	CLERK_STRU *clerk_stru;

	if(Data_Len != (1 + COMM_CLERK_NUM * sizeof(CLERK_STRU)))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	idx = Data_Area[0];
	if((idx > Max_Clerk_No) || (idx == 0))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	if((idx > Max_Clerk_No - COMM_CLERK_NUM + 1) || (COMM_CLERK_NUM > Max_Clerk_No))
	{
		/* Judge the data is zero or not, if not all zero, send an error information, Remain. */
	}
	idx --;

	clerk_stru = (CLERK_STRU *)(Data_Area+1);
	for(i = 0, j = idx; (i < COMM_CLERK_NUM) && (j < Max_Clerk_No); i ++, j ++)
	{
		if(Bcd2Long(clerk_stru[i].Sec_CODE, 2) == 0)
		{
			Send_Error_Info(NOT_MATCH_FORMAT);
			return;
		}
	}

	for(i = 0, j = idx; (i < COMM_CLERK_NUM) && (j < Max_Clerk_No); i ++, j ++)
	{
		memcpy(clerk[j].desc, clerk_stru[i].Description, MAX_DESC_LEN);
		clerk[j].secret = Bcd2Long(clerk_stru[i].Sec_CODE, 2);
	}
	Send_Succeed_Info();
}

/*-----------------------------------------------------------------------*
					Total description down-load.
 *-----------------------------------------------------------------------*/
void Do_Ttl_Desc_Dwn(void)
{
	byte i;
	char *p;

	if(Data_Len != (MAX_CHECK_NUM+MAX_CHARGE_NUM)*MAX_DESC_LEN)
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}

	p = (char *)(Data_Area);
	for(i = 0; i < MAX_CHECK_NUM; i ++)
	{
		memcpy(charge[i], p, MAX_DESC_LEN);
		p += MAX_DESC_LEN;
	}
	for(i = 0; i < MAX_CHARGE_NUM; i ++)
	{
		memcpy(check[i], p, MAX_DESC_LEN);
		p += MAX_DESC_LEN;
	}
	Send_Succeed_Info();
}

/*-----------------------------------------------------------------------*
					Refund parameter down-load.
 *-----------------------------------------------------------------------*/
void Do_Rfnd_Dwn(void)
{
	long price;

	if(Data_Len != (MAX_DESC_LEN+3+1))
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}
	price = Bcd2Long(Data_Area+MAX_DESC_LEN, 3);
	if(price > MAX_RFND_PRICE)
	{
		Send_Error_Info(NOT_MATCH_FORMAT);
		return;
	}

⌨️ 快捷键说明

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