Exemple #1
0
/******************************************************************************
 函数名称:Power_Down
 功能描述:休眠手持机
 参数名称:	输入/输出?	类型		描述
 输入		
 
 返  回  值:
 
 作      者	:于福勇/刘及华
 日      期:2012-11-27

 修改历史:
		日期		修改人		修改描述
		------		---------	-------------
******************************************************************************/
void System_reset(void)
{
//  uint uisleep_delay;   //可提升为全局变量
//  EA_ucSetStopFlag(EM_ENABLE_STOP);  //两秒后进入睡眠状态;
	lcddisperr("系统正在重启...");
//  uisleep_delay = 2;
	Close_GPRS_Module();
//  EA_vSetSaveResTime(uisleep_delay);
	EA_vSystemManage (EM_RESET);
	
	//(void)EA_uiInkey(0);
}
Exemple #2
0
/******************************************************************************
 函数名称:Power_Down
 功能描述:休眠手持机
 参数名称:	输入/输出?	类型		描述
 输入		
 
 返  回  值:
 
 作      者	:于福勇/刘及华
 日      期:2012-11-27

 修改历史:
		日期		修改人		修改描述
		------		---------	-------------
******************************************************************************/
void Power_Down(void)
{
//  uint uisleep_delay;   //可提升为全局变量
//  EA_ucSetStopFlag(EM_ENABLE_STOP);  //两秒后进入睡眠状态;
	lcddisperr("系统正在关机...");
//  uisleep_delay = 2;
	Close_GPRS_Module();
//  EA_vSetSaveResTime(uisleep_delay);
	EA_vSystemManage (EM_SHUTDOWN);
	
//  (void)EA_uiInkey(0);
}
Exemple #3
0
uchar TA_BT_ucSetBTPINCodeMode(uchar ucMode)
{
	uchar ucRet = 0, ucCmd = 0, ucData = 0;

	if (0x00 == ucMode)	//	SPP 无需PIN配对
	{
		ucCmd = EM_BT_PARE_MODE;
		ucData = EM_BT_PARE_SSP_JUST;
	}
	else
	{
		ucCmd = EM_BT_PARE_MODE;
		ucData = EM_BT_PARE_FIXED;
	}

	ucRet = EA_ucSetBTParamConfig(ucCmd, &ucData);
	if (EM_SUCCESS != ucRet)
	{
		ucCmd = 20;
		EA_vCls();
		TA_vDisplayLine(DISP_LINE_M1, DISP_POS_MID, "设置蓝牙配对模式错%02X", ucRet);
		while (ucCmd--)
		{
			EA_vLCDLightOff();
			EA_vDelayMs(500);
			EA_vLCDLightOn();
			EA_vDelayMs(500);
			EA_vBeepMs(500);
			TA_vDisplayLine(DISP_LINE_M2, DISP_POS_MID, "请联系厂商客服!");
			EA_uiInkey(3);
		}
		EA_uiInkey(30);
		EA_vSystemManage(EM_SHUTDOWN);
	}

	return ucRet;
}
Exemple #4
0
int dlm_main(char *CMDBUF , int *nCmdLen)
{
    char szGetBuffer[30],szTmpBuf[30];
	char szBuffer[100];

 //   char cWaitRet;
    uint uiKey , uiRet,nRet;
 //   uchar ucRetVal;
//    uchar ucFd;
    uchar ucRet;

    int nScreen = 0;
    char cMenuTime;
 //   uint uiCount;
    uint uiOption;
	uint puiConfigInfo;
//  uchar i,  ucIfExist, ucStatus; 

    const char *pcModuleName = MODULE_FILE_NAME;
//    const char *pcCommModuleName = "applib";
    DevHandle phPinpad;
//    DevHandle hVoiceHandle;
#ifdef EPT_A9L
//	uint_64 llCnt = 0;
//	char szData[100];
#endif

#ifdef EMVIC
	EA_EMV_vInit();
#endif
    //设备句柄清空 
    gbPrintHandle = EM_NULL;
	//清空所有全局设备句柄,add by zhuchentao 060831
	gbhdlMagCard = EM_NULL;;	//磁卡模块 
	gbhdlUserCard = EM_NULL;
	gbhdlMasterCard = EM_NULL;
	gbhdlSAM1Card = EM_NULL;
	gbhdlSAM2Card = EM_NULL;
	gbhdlSAM3Card = EM_NULL;
	gbhdlSAM4Card = EM_NULL;
	gbMifCardHandle = EM_NULL;
#ifdef EMVIC 
	gbhdlPINPAD = EM_NULL;   
	gbhdlRS232 = EM_NULL;
	gbMifCardHandle = EM_NULL; 
#endif
	cRunState = 1;
    CommInfo.gbHdl = EM_NULL;
    memset(&iso, 0, sizeof(ISODataStru));
    memset(&iso1, 0, sizeof(ISODataStru));
    memset(&printiso, 0, sizeof(ISODataStru));
    memset(&upiso, 0, sizeof(ISODataStru));
	gbcECDefault = 0;
#ifndef EPT_A9L
#ifdef EPT_M3
	if (EA_uiLoadAndExecuteModule("LibRFReader.dlm", "") != EM_SUCCESS)
#endif
#ifdef EPT56X0
	if (EA_uiLoadAndExecuteModule("LibRFReader", "") != EM_SUCCESS)
#endif
    {
    	
        PubDisplay(3, "载入LibRFReader.dlm失败");
        PubDisplay(4, "请下载LibRFReader.dlm文件");
		PubuiInkey(0);
		return EXCEPTION;
    }
#endif
	EA_vCls();
	PubucLoadAllMfVar((char*)MODULE_FILE_NAME, &FV, sizeof(FV));

// #ifdef EPT56X0
// 	EA_ucSetStopFlag(EM_DISABLE_STOP);
// #endif
// #ifdef EPT_A9L
// 	EA_ucSetStopFlag(EM_DISABLE_STOP);
// #endif
// 银商允许修改参数标志,提交程序的时候分别2种情况编译提交 
//	setup.c 中还有一个地方要设置,勿忘!!!
#ifdef TMS
   		     cSetupModifyFlag = 0;// TMS服务器版 不允许修改参数
#else
  			 cSetupModifyFlag = 1;// 下载版 允许修改参数
#endif

#ifndef EPT5610
	EA_vSetLCDLightTimer(60);
#endif
    EA_vCls();
    if (PubucFirstRunPara(pcModuleName, "parafile") == EM_SUCCESS)
    {
		PubGetPinpadPara();// 先读取参数文件中密码键盘标签
              FV.gbnParaFirstFlag = YES;
		WRITE_nVAR(FV.gbnParaFirstFlag);
    }
	PubUsePinpadInside(FV.Other.SetPinpadType);
// 	PubUsePinpadInside(1);
    PubGetPrinterType(&iPrinterType); 
    PubGetPinpadType(&iPinpadType);
    while ((ucRet = PubOpenDevice("PINPAD", EM_io_IPP, &phPinpad)) != EM_SUCCESS)
    {
		PubGetPosType();
		if (FV.gbnPosTypeFlag == YES)
		{
			FV.Other.SetPinpadType = 1;
			PubUsePinpadInside(1);
			WRITE_nVAR(FV.Other.SetPinpadType);
		}
		else
		{
	        PubDisplayInv(2, "打开密码键盘错");
	        PubDisplay(3, "请接入密码键盘");
	        PubDisplay(4, "[%d][%02x][%d]", ucRet, ucRet,FV.gbnPosTypeFlag);
	        EA_vBeepMs(50);
			uiRet = PubuiInkey(1);
	        if (uiRet == EM_key_FUNC1)
			{
				PubSetUsePinpadType();
			}
			if (uiRet == EM_key_FUNC9||EM_key_CANCEL)
			{
				return EM_ERROR;
			}
		}
    }
    while ((PubGetPinpadVer(phPinpad ,&iPinpadVer)) == 3)
    {
        PubDisplayInv(2, "请接好密码键盘");
        EA_vBeepMs(50);
        PubuiInkey(1);
    }
#ifndef EPT5610
    //20070914  by wei 将安全级别设置成默认级别
	if ( iPinpadVer == 2 )  
	{
		EA_pci_ucGetSecureConfig(phPinpad, EM_NULL, &puiConfigInfo);
		if ( puiConfigInfo != EM_pin_DEFAULTCONFIG)
		{
			EA_pci_ucSetSecureConfig(phPinpad, EM_NULL, EM_pin_DEFAULTCONFIG);
		}
	}
#endif
    EA_ucCloseDevice(&phPinpad);

    nFirstSetupFlag = NO;

    if (PubucFirstRunProg(pcModuleName) == EM_SUCCESS)
	{
        FV.gbnFirstFlag = YES;
		WRITE_nVAR(FV.gbnFirstFlag);
	}

    // 注册headcommon 
/*
    if (PubLoadAndExecuteModule(pcCommModuleName, "F0506") != EM_SUCCESS)
    {
        EA_vCls();
        PubDisplay(3, "装载公共模块失败!");   
        //因为PubDisplay是在applib中的,注册applib失败也就无法使用PubDisplay函数,只能用EA_vDisplay函数
        PubuiInkey(0);
        return EXCEPTION;
    }

*/
    // 导入def8583.h中的8583包定义
    if (PubImport8583(YlIso8583Def) == EXCEPTION)
    {
        EA_vCls();
        PubDisplay(3, "8583包导入出错");
        PubDisplay(4, "请检查程序重新下装");
        PubuiInkey(0);
        return EXCEPTION;
    }
    // 导入结束 
	PubGetMifsType(&iMifsType);	//增加POS模块判断/必须放在initcomm之前,initcomm可能会影响底层的判断

    if (FV.gbnFirstFlag == YES)
    {
		PubGetPosType();
		PubSetupFirst();
#ifdef EMVIC
   		setup_first ();
#endif   		
		WRITE_nVAR(FV); //这里把setupfirst里面的内容统一写入一次
		nFirstSetupFlag = YES;
		FV.gbnFirstFlag = NO;
		WRITE_nVAR(FV.gbnFirstFlag);

		FV.gbnParaFirstFlag = YES;
		WRITE_nVAR(FV.gbnParaFirstFlag);

		if (FV.gbnParaFirstFlag == YES)
		{
		PubReadPara() ;
		}
		FV.gbnParaFirstFlag = NO;
		WRITE_nVAR(FV.gbnParaFirstFlag);
    }
    if (FV.gbnParaFirstFlag == YES)
    {
        PubReadPara();
    }
    if (nFirstSetupFlag == YES)
    {
		PubInitGlobal();
        PubSetup(10);
        nFirstSetupFlag = NO;
    }
	else
	{    
		PubInitGlobal();
	}
#ifdef TMS
	//读取主控应用参数
	ProReadBasePara();
#endif
	// by wei 每次进入应用不需要重新操作员签到 modify by baijz 20110723 BCTC要求每次开机操作员签到
     BUFCLR(szGetBuffer);
//      VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer));
//      if (szGetBuffer[0] == LOGON)
//          PubSetPoscfgcPosState(NO_LOGON);

	EA_vCls();
	PubKeyOn();

#ifdef BZ       /*标准版*/
	PubDisplayInv( 1, "中国银联"); 
#endif
#ifdef Largevalue   /*大额支付*/	
       PubDisplayInv( 1, "中国银联-大额"); 
#endif
#ifdef NMLS   /*内蒙移动零售*/
	PubDisplayInv( 1, "内蒙移动零售"); 
#endif
#ifdef NMJF   /*内蒙移动缴费*/
	PubDisplayInv( 1, "内蒙移动缴费"); 
#endif 
	PubDisplayCen(2, "CUP2.0");
	PubDisplayCen(3, "自检...");
	szGetCmdFlag = 0 ;
	szCMDChangeAppFlag = 0 ;
    //ucRet = EA_ucOpenDevice("PINPAD",EM_io_IPP, &phPinpad);
    while ((ucRet = PubOpenDevice("PINPAD", EM_io_IPP, &phPinpad)) != EM_SUCCESS)
	{
        PubDisplayInv(2, "打开密码键盘错");
        PubDisplay(3, "[%d][%02x]", ucRet, ucRet);
        EA_vBeepMs(50);
        PubuiInkey(1);
	}
    while ((ucRet = PubResetPinpad(phPinpad)) != EM_SUCCESS)
	{
        PubDisplayInv(2, "请接好密码键盘");
        PubDisplay(3, "[%d][%02x]", ucRet, ucRet);
        EA_vBeepMs(50);
        PubuiInkey(1);
	}
	// 为多应用,怕其他应用使用和银联相同的mackey workkey的ID号,这里重新load一次。
	PubucSelectKey(phPinpad, EM_pin_MASTERKEY, FV.bank.nMKeyIndex);
	if(FV.Other.gbMacKeyLen)
		PubucLoadKey(phPinpad,EM_pin_DEFAULTMODE ,EM_pin_MACKEY, 0, FV.Other.gbMacKeyLen, FV.Other.gbszMacKey);
	if(FV.Other.gbWorkKeyLen)
		PubucLoadKey(phPinpad, EM_pin_DEFAULTMODE ,EM_pin_WORKKEY, 0, FV.Other.gbWorkKeyLen, FV.Other.gbszWorkKey);
    EA_ucCloseDevice(&phPinpad);
    if (PubuiInkeyMs(500) == EM_key_CANCEL)
        PubLogin();
  
	PubGetMifsType(&iMifsType);	//增加POS模块判断/必须放在initcomm之前,initcomm可能会影响底层的判断
    PubInitComm(&CommInfo, AUTOCHECK);
    BUFCLR(szGetBuffer);
    VERIFY_NORMAL(PubGetPoscfgcBatchState(szGetBuffer));

    if (szGetBuffer[0] == YES)
    {
        EA_vCls();
        PubDisplayInv(2, "请先结算再作交易");
        PubuiInkey(1);
    }
	//打开MISPOS的通讯接口 
#ifdef EPT_A9L
	
	ucRet = EA_ucOpenDevice(FV.Other.gbcMISPort,0, &gbhdCMDRS232);
	if (ucRet != EM_SUCCESS)
	{
		ucRet = EA_ucOpenDevice("COM3",0, &gbhdCMDRS232);
		if (ucRet == EM_SUCCESS)
		{
			memcpy(FV.Other.gbcMISPort,"COM3",4);
			WRITE_nVAR(FV.Other.gbcMISPort);
		}
	}
	if (ucRet != EM_SUCCESS)
	{
		 EA_vCls();
		 PubDisplay(1,"请先设置COMPOS 端口");
		 EA_vBeepMs(1000);
		 PubuiInkey(0);
		return ProFuncBankszComPos();
		/*memcpy(FV.Other.gbcMISPort,"COM2",4);
		WRITE_nVAR(FV.Other.gbcMISPort);
		EA_vCls();
		PubDisplay(1,"无法打开通信端口!");
		PubDisplay(2,"请重启设备");
		EA_vBeepMs(1000);
		PubuiInkey(2);
		return EXCEPTION;*/
	}
	else
	{
		ucRet = EA_ucInitRS232(gbhdCMDRS232,FV.gbRSInfo.ucBps,EM_232_NOPAR ,EM_232_8DBS);
		//ucRet = EA_ucCloseDevice(&gbhdCMDRS232);
		//gbhdCMDRS232 = EM_NULL;
	}
#endif

	if ( nCmdLen != NULL && CMDBUF != NULL)
	{
		CMDBUFLen = *nCmdLen;
		if (CMDBUFLen >0 )
		{				      
			memset(szCMDBuffer , 0 , sizeof(szCMDBuffer));
			memcpy(szCMDBuffer , CMDBUF , CMDBUFLen);			
			memset(&TlvSendValue,0,sizeof(struct TLVVALUE));
			CMDProcess(szCMDBuffer, (char*)&TlvSendValue, &gbctlvflag);
			szGetCmdFlag = 15;
		}
	}

    BUFCLR(szGetBuffer);
	BUFCLR(gbPosTags);
	gbTags = 0; 


	      gbnDisplayTime = 0;
#ifdef EMVIC
	PubSetExeReader(1);
#endif
    while (1)
    {
		PubDispIcon();//显示一下5650电池电量和信号
#ifdef TMS
		if (ProJudgeBaseDlaVer() == EM_SUCCESS)
		{
			ProGetBaseDialFix();
			ucRet = PubReturnUpdate() ;
			if (ucRet != EM_ERROR)
			{
				PubDelAllBit(&iso);
				close_all_dev();
				return ucRet;
			}
			if (PubCheckRunState() == EM_SUCCESS)
			{
				PubDelAllBit(&iso);
				close_all_dev();
				return EM_ERROR;
			}
		}
#endif
	memset(&gbTrkInfo, 0, sizeof(struct TrackInfo));
	memset(&gbCardinfo, 0, sizeof(struct CardConfig));
//	PubDisplay(4 , "%d  %d  %d   %d",EM_VOC_LEVEL0,EM_VOC_LEVEL1,EM_VOC_LEVEL2,EM_VOC_LEVEL3);
//	PubuiInkey(60);
//    FV.Other.POSSTATFLAG = 6;//chenjs20060915 ls add for test TMS 
//	EA_ucAudioSetVolume(FV.Other.ucNewVolume);
//	EA_ucAudioPlay("qing.wav");
//	EA_ucAudioPlay("shuaka.wav");
	

	
#if 0
    ucRet = EA_ucOpenDevice("EVOICE", 0, &hVoiceHandle); //打开外置语音设备

    if(ucRet != EM_SUCCESS)
    {
        EA_vDisplays(2,1, "Test Open Err:%02x", ucRet);
        EA_uiInkey(0);
        return EM_ERROR;
    }
    else
    {
        EA_vDisplays(2,1, "Open OK");
        EA_uiInkey(2);
    }
    ucRet = EA_ucIfVoiceExist(hVoiceHandle, &ucIfExist);
    if(ucRet != EM_SUCCESS)
    {
        EA_vDisplays(2,1, "Test IfExist Err:%02x", ucRet);
        EA_ucCloseDevice(&hVoiceHandle);
        EA_uiInkey(0);
        return EM_ERROR;
    }
    else
    {
         if(ucIfExist == 1) //If Exist
        {
            for(i = 0; i < 8; i++)
            {
                ucRet = EA_ucPlayVoice(hVoiceHandle, i);
                if(ucRet != EM_SUCCESS)
                {
                    EA_vDisplays(2,1, "Test play%d Err:%02x",i, ucRet);
                    EA_uiInkey(0);
                }
                else
                {
                    EA_vDisplays(2,1, "Test play%d OK", i);
                }
                do
                {
                    EA_ucGetPlayStatus(hVoiceHandle, &ucStatus);
                }while(ucStatus == EM_VOICE_PLAYING);
            }
        }
        else
        {
            EA_vDisplays(2,1, "No voice module exists");
            EA_uiInkey(0);
        }
        EA_ucCloseDevice(&hVoiceHandle);
    }
#endif	
#if 0		
        switch (FV.Other.POSSTATFLAG)
        {
        case 0:
            break;
        case 1:
			if (ProCheckPOSSTATFLAG()!= NORMAL)
			{
				break;
			}
            EA_vCls();
            PubDisplay(1, "系统要求下载参数");
            PubDisplay(2, "请按确认键继续");
			PubuiInkey(0);  
            if ( PubDownPara() == NORMAL) 
			{
				ACK(4,"00");
			}
			else
			{
				NAK_info(4,"XX","交易失败");
			}
            continue;
        case 2:
			if (ProCheckPOSSTATFLAG()!= NORMAL)
			{
				break;
			}
            EA_vCls();
            PubDisplay(1, "系统要求上传状态");
            PubDisplay(2, "请按确认键继续");
            PubuiInkey(0);
            if (PubUploadState() == NORMAL) 
			{
				ACK(4,"00");
			}
			else
			{
				NAK_info(4,"XX","交易失败");
			}
            continue;
        case 3:
			if (ProCheckPOSSTATFLAG()!= NORMAL)
			{
				break;
			}
            EA_vCls();
            PubDisplay(1, "系统要求重新签到");
            PubDisplay(2, "请按确认键继续");
            PubuiInkey(0);
            if (PubBankLogin() == NORMAL)
			{
				ACK(4,"00");
			}
			else
			{
				NAK_info(4,"XX","交易失败");
			}
            continue;

#ifdef EMVIC
        case 4:
			if (ProCheckPOSSTATFLAG()!= NORMAL)
			{
				break;
			}
            EA_vCls();
            PubDisplay(1, "系统要求公钥下载");
            PubDisplay(2, "请按确认键继续");
            PubuiInkey(0);
            //if(PubYlConnect(&CommInfo)!=NORMAL)
			//    continue;
	    	if (PubQueryPubilcKey () == 1)
			{
			    PubDownPubilcKey ();
			}
			ACK(4, "00");
		    //PubDialOff (&CommInfo);
			continue;     
        case 5:
			if (ProCheckPOSSTATFLAG()!= NORMAL)
			{
				break;
			}
            EA_vCls();
            PubDisplay(1, "系统要求更新参数");
            PubDisplay(2, "请按确认键继续");
            PubuiInkey(0);
	        if(PubYlConnect(&CommInfo)!=NORMAL)
			    continue;
//add by baijz 20110906 下载过程断电,需要删除EMV参数文件,否则会重复下载
			EA_ucPFDel (FEmvPara);
			EA_ucPFCreate (FEmvPara, (sizeof (struct EMVPARA)));
//add end 
		    PubDownEmvPara ();
		    PubDialOff (&CommInfo);
            continue;
#endif

#ifdef TMS
		case 6:
			if (ProCheckPOSSTATFLAG()!= NORMAL)
			{
				break;
			}
			EA_vCls();
            PubDisplay(1, "要求下载TMS参数");
            PubDisplay(2, "请按确认键继续");
            PubuiInkey(60);
	        TmsDownPara();
			continue;
#endif
			
			case 7:
			if (ProCheckPOSSTATFLAG()!= NORMAL)
			{
				break;
			}
			EA_vCls();
            PubDisplay(1, "要求下载卡BIN黑名单");
            PubDisplay(2, "请按确认键继续");
            PubuiInkey(60);
	        PubDownCardBin();
			continue;
			//JP add
        default:
            break;
        }
		FV.Other.POSSTATFLAG = 0;//chenjs20070104 add防止不小心死循环
		CheckPOSSTATFLAGTimes = 0;

		WRITE_nVAR(FV.Other.POSSTATFLAG);

#endif
        EA_ucGetDateTime(&datetime);
        sprintf(szTmpBuf , "%04d%02d%02d", datetime.usYear, datetime.ucMonth, datetime.ucDay);
        PubDialOff(&CommInfo);
        // 判断打印是否完成 
        PubJudePrintFinish(1);


//		 如果隔日了,就要求POS的操作员签到。
		if(memcmp( szTmpBuf , FV.Other.gbLoginDate, 8 ))
			PubSetPoscfgcPosState(NO_LOGON);

        BUFCLR(szGetBuffer);
        VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer));
           
/*        if (szGetBuffer[0] == NO_LOGON)
        {
#ifdef TMS
			EA_vCls();
			PubDisplayInv(1,"银联EMV应用");
			PubDisplayCen(3,"按任意键签到");
			PubDisplayCen(4,"按取消键切换应用");
			uiRet = PubuiInkey(10);
			if (uiRet == EM_key_FUNC9|| uiRet == EM_key_CANCEL)
			{
				EA_vCls();
                PubDisplayCen(2, "应用切换");
                PubuiInkeyMs(500);
                PubDelAllBit(&iso);
				close_all_dev();
				EA_vCls();
                return EM_ERROR;
			}
#endif
            if (PubLogin() != NORMAL)
                continue;
        }
*/	
        

//   20060119
//for test dudj
/*
PubDisplay(3, "是否联机签到?");
 if (PubuiInkey(2)!=EM_key_ENTER)
	sprintf( FV.Other.gbLoginDate , "%s", szTmpBuf);
PubDisplay(3, "");
*/
		// 测试的时候打开。发布的封掉
 		/*sprintf( FV.Other.gbLoginDate , "%s", szTmpBuf);
        if(memcmp( szTmpBuf , FV.Other.gbLoginDate, 8 ))
        {
                if (PubBankLogin() != NORMAL)
                {
                    PubSetPoscfgcPosState(NO_LOGON);
                }
                else
                {
			        EA_ucGetDateTime(&datetime);
					sprintf(szTmpBuf , "%04d%02d%02d", datetime.usYear, datetime.ucMonth, datetime.ucDay);
                    sprintf( FV.Other.gbLoginDate , "%s", szTmpBuf);
					WRITE_nVAR(FV.Other.gbLoginDate);
                }
			    continue;
        }*/           
        
        BUFCLR(szGetBuffer);
        VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer));

        if (szGetBuffer[0] == LOCK)
        {
            PubLock();
            continue;
        }
        PubGetPoscfgcMenuTime(&cMenuTime);
	    PubGetTermCapSet();     //add by chenjis 20130311

        while (1)
        {
			if (szCMDChangeAppFlag == 2)//强制切换到应用2
			{
				PubDelAllBit(&iso);
				close_all_dev();
				return 2;
			}
// 			PubSetExeReader(0);
			gbcECDefault = 0;
			PubDispIcon();
#ifdef TMS
			if (ProJudgeBaseDlaVer() == EM_SUCCESS)
			{		
				// for 主控应用更新,添加一个新返回值2
				ucRet = PubReturnUpdate() ;
				if (ucRet != EM_ERROR)
				{
					PubDelAllBit(&iso);
					close_all_dev();
					return ucRet;
				}
				if (PubCheckRunState() == EM_SUCCESS)
				{
					PubDelAllBit(&iso);
					close_all_dev();
					return EM_ERROR;
				}

			}
#endif
            PubSetPoscfgcSettleEnd(1);  /*设置结算未结束标志 */
            EA_vCls();
            nScreen = 0 ;
            //chenjs20060725 add down
            memset(&gbTrkInfo, 0, sizeof(struct TrackInfo));
            memset(&gbCardinfo, 0, sizeof(struct CardConfig));
            gbTrkInfo.cDoneFlag = 0;
			PubSetBankcMacChk(MAC_ECB);
#ifdef EMVIC          
            //ecash   by wei
			gblTranAmt = 0l;
			BUFCLR(gbszTermData);
			gbszTermData[0] = FV.EmvStru.gbcMSD;//loyes
#endif
			strcpy(gbszErrCode, "");

	        while (1)
	        {
				gbnComposFlag =1;
         		gbnSettleFlag=0;
				if (szCMDChangeAppFlag == 2)//强制切换到应用2
				{
					PubDelAllBit(&iso);
					close_all_dev();
					return 2;
				}
	            PubSetPoscfgcSettleEnd(1);  /*设置结算未结束标志 */
	            //EA_vCls();
	            nScreen = 0 ;
	            //chenjs20060725 add down
	            memset(&gbTrkInfo, 0, sizeof(struct TrackInfo));
	            memset(&gbCardinfo, 0, sizeof(struct CardConfig));
	            gbTrkInfo.cDoneFlag = 0;
				if (CMDCONT.Type == CMD_NONE) // CMD_NONE表示无命令			
				{
					nRet = GetCMD();
					if (szCMDChangeAppFlag == 15)
					{
						PubDelAllBit(&iso);
						close_all_dev();
						EA_ucCloseDevice(&gbhdCMDRS232);
						memcpy(CMDBUF , szCMDBuffer , CMDBUFLen);
						CMDBUF[CMDBUFLen] = 0 ;
						*nCmdLen = CMDBUFLen;
						return 15;
					}
					if (nRet != NORMAL)
					{
					
						//PubDisdoter();
	 					PubDispLogo();
						if( EA_ucKBHit_ped() == EM_key_HIT )
						{
						      uiKey = PubuiInkeyMs(500);
#ifdef BZ  /*标准版*/
						  if (uiKey == ENTER)
#endif
#ifdef Largevalue   /*大额支付*/
						   if (uiKey == ENTER)
#endif
#ifdef NMLS   /*内蒙移动零售*/
						   if (uiKey == EM_key_F1)     /*应内蒙银商要求F1进入查询菜单wujianyuan modify 20130712*/
#endif
#ifdef NMJF   /*内蒙移动缴费*/
						   if (uiKey == EM_key_F1)    /*应内蒙银商要求F1进入查询菜单wujianyuan modify 20130712*/
#endif 
						     {
							EA_vCls();
							PubDisplay(2, "请输入安全密码:");
							BUFCLR(szGetBuffer);
							PubGetSAFEPWD(szGetBuffer, sizeof(szGetBuffer));
							PubKeyOff();
							
							BUFCLR(szBuffer);
							if (PubGetNStr(3, BIGFONT, szBuffer, 6) == NORMAL &&
								memcmp(szGetBuffer, szBuffer, 6) == 0)
							{
								PubKeyOn();	
								EA_ucCloseDevice(&gbhdCMDRS232);
								gbhdCMDRS232 = EM_NULL;
								PubSetupNew();
								 EA_vCls();
							}	
							 EA_vCls();
							PubKeyOn();					
						
							}
							if(uiKey==EM_key_9)
							{
							if (PubuiInkey(1) == '5')
							if (PubuiInkey(1) == '9')
							{
		                                      EA_vSystemManage(EM_RESET);//add by wujy  20111020 实现重启
							}
							}
							if (uiKey == EM_key_FUNC9)  //多应用切换
							{
								EA_ucCloseDevice(&gbhdCMDRS232);
								gbhdCMDRS232 = EM_NULL;
								PubDelAllBit(&iso);
								close_all_dev();
								EA_vCls();
								return EM_SUCCESS;				
							}
							if (uiKey == EM_key_FUNC)
							{

								gbnComposFlag =0;
								memset(&TlvSendValue,0,sizeof(struct TLVVALUE));
								PubGetBankszTerminal(TlvSendValue.szTerminal, 8);
								PubGetBankszCust(TlvSendValue.szCust, 15);
						        BUFCLR(szGetBuffer);
						        VERIFY_NORMAL(PubGetPoscfgcPosState(szGetBuffer));

						        if (szGetBuffer[0] == NO_LOGON)
						        {
					            	if(PubLogin()!=NORMAL)
					        		{
										EA_vCls();
					        			continue;
									}
								
					        	}
						        BUFCLR(szGetBuffer);
						        VERIFY_NORMAL(PubGetPoscfgcLoginState(szGetBuffer));

						        if (szGetBuffer[0] == NO_LOGON)
					        	{
									VERIFY_NORMAL(PubSetPoscfgcPosState(NO_LOGON));
									if(PubBankLogin()== NORMAL)
									{
										VERIFY_NORMAL(PubSetPoscfgcPosState(LOGON));
						        		       VERIFY_NORMAL(PubSetPoscfgcLoginState(LOGON));
										EA_ucGetDateTime(&datetime);
										BUFCLR(FV.Other.gbLoginDate);
										sprintf(FV.Other.gbLoginDate , "%04d%02d%02d", datetime.usYear, datetime.ucMonth, datetime.ucDay);
										WRITE_nVAR(FV.Other.gbLoginDate);
									}
									else
					        		      {
										PubDialOff (&CommInfo);
										EA_vCls();
										continue;
									}
					        	}
								EA_vCls();
								PubDisplay (1, "1.消  费   2.撤  销");
								PubDisplay (2, "3.退  货   4.预授权");
								PubDisplay (3, "5.离  线   6.打  印");
								PubDisplay (4, "7.管  理   8.其  它");

								uiKey = PubuiInkey((char) cMenuTime);
								if(uiKey>='1'&&uiKey<='8')
									uiOption=uiKey-'0';
								else
								{
									EA_vCls();
									continue;
								}
								
								PubUpYLDataOld();

						              PubProcessOld(uiOption);
								EA_vCls();
								continue;				
							}						
						}
						continue;
					}
				}
				
				if (CMDCONT.Type != CMD_NONE)
				{
				break;
				}
				
	        }      

	         if (PubProcess(CMDCONT.Type) != CMD_INTERRUPT)
	         {
	 	     ClearCMD();
	         }
	         EA_vLCDLightOff();
	    }
	    return EM_SUCCESS;
	}
}