MFC实例

 

#pragma once
#include "afxwin.h"
#include "resource.h"
#include <paxnet/PclEmvCommand.h>
#include "CdiglogPublic.h"

#include <thread>
#include <mutex>


// CDiglog_SHOW 对话框
using namespace pax;
//using namespace std;

class CDiglog_SHOW : public CDialog, public CdiglogPublic
{
	DECLARE_DYNAMIC(CDiglog_SHOW)

public:
	CDiglog_SHOW(CWnd* pParent = NULL);   // 标准构造函数
	virtual ~CDiglog_SHOW();
	virtual BOOL OnInitDialog();

// 对话框数据
	enum { IDD = IDD_SHOW };

protected:
	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV 支持

	DECLARE_MESSAGE_MAP()
public:

	afx_msg void OnBnClickedButtonNew();
	afx_msg void OnBnClickedButtonLine();
	afx_msg void OnBnClickedButtonTotal();
	bool getNotify();
	void setNotify();
	int IsAciMod();
	void OnBnClickedButton();
	static void setDialog(CDialog *pThis);
	static CDialog * getDialog();
	void AddAndShowRFTimes(int itimes);
	void AddAndShowICTimes(int itimes);
	void AddAndShowWICTimes(int itimes);

	static std::mutex m_ContactRecy;
	static std::mutex m_ContactLessRecy;
	static std::mutex m_WicRecy;
	
	static std::mutex m_ICCardMutex;
  	static std::mutex m_RFCardMutex;
	static std::mutex m_WicMutex;
//	static std::mutex m_Recy;
	static CDialog *m_pThisDialog;
	
private:
	int ranDom();
	void clearBox();
	bool SetEMVData(std::vector<pax::EMV_TLV> &emv_datas);
	std::string getAmountStr();
	void ContactTrans();
	void ContactlessTrans();
	void WicClaimService();

	CString BootOpenDialog();
	//void OnBnClickedSelectFile();
	void ChangeConfigItem(std::string strTYPE, std::string strCMDName);

	bool GetRecy();
	void ContactTransRecycle();
	void ContactlessTransRecycle();
	void WicClaimServiceRecycle();
	void EndIC();
	void EndRF();
	void EndWIC();
	static UINT ICThreadProc(LPVOID pParam);
	static UINT RFThreadProc(LPVOID pParam);
	static UINT WICThreadProc(LPVOID pParam);
	static void setFlag(bool val);
	
	double m_dAmountOk;
	double m_dSubTotal;
	double m_dTax;
	int m_iButtonLineTimes;
	int m_iAciMode;
	bool m_bICCard;
	bool m_bRFCard;

	bool m_bIsAciMod;
    bool m_bNotify;
	
	bool m_bRecyContanct;
	bool m_bRecyContanctLess;
	//bool m_bRecyWic;
	
	CEdit m_total;
	CListBox m_listBox;
	CEdit m_fileEdt;
	CEdit m_RFEditTimes;
	CEdit m_ICEditTimes;
	CEdit m_WICEditTimes;
	//CComboBox m_comBox;

	bool m_bContactRecy;
	bool m_bContactlessRecy;
	bool m_bWicRecy;

	CWinThread*m_IcThread;
	CWinThread*m_RFThread;
	CWinThread*m_WICThread;
	
	static bool m_bFlag;

	int m_iCout;
	//int m_iInterval;
	int m_iRFTimes;
	int m_iICTimes;
	int m_iWICTimes;
	bool m_bApproved;
public:
	void CDiglog_SHOW::setCommandRequest(pax::PclCommand* command);
	void DoContactTrans();
	void DoContactlessTrans();
	void DoWicClaimService();
	bool getApproved();
public:
	afx_msg void OnLbnSelchangeList1();
	afx_msg void OnEnChangeEditsend2();
	afx_msg void OnEnChangeEditrecv2();
	//afx_msg void OnBnClickedAppro();
	afx_msg void OnEnChangeTotal();
	//afx_msg void OnBnClickedInvalidPin();
	//afx_msg void OnBnClickedDeclined();
	afx_msg void OnBnClickedButtonClear();
	afx_msg void OnEnChangeEditrecv();
	afx_msg void OnEnChangeEditsend();
	afx_msg void OnBnClickedAci();
	afx_msg void OnBnClickedStandard();
	afx_msg void OnBnClickedHeb();
	afx_msg void OnBnClickedButtonClear2();
	afx_msg void OnBnClickedButtonOpen();
//	afx_msg void OnEnChangeConfig();
	afx_msg void OnBnClickedRecy();
	afx_msg void OnBnClickedRecy2();
	afx_msg void OnBnClickedBegin();
	afx_msg void OnBnClickedEnd();
	afx_msg void OnBnClickedDecl();
	afx_msg void OnBnClickedApproved();
};
#include "stdafx.h"
#include "Diglog_SHOW.h"
#include "resource.h"
#include "afxdialogex.h"
#include "EcrSimulatorDlg.h"
#include <paxnet/PclListBoxRemoveItemCommand.h>
#include <paxnet/PclSetVariableCommand.h>
//#include <paxnet/PclDisplayFormCommand.h>
#include <paxnet/PclListBoxInsertItemCommand.h>
#include <paxnet/PclEmvBeginContactTxnCommand.h>
#include <paxnet/PclEmvBeginContactlessTxnCommand.h>
#include <paxnet/PclRequestMessage.h>
#include <paxnet/PclResponseMessage.h>
#include <paxnet/PclResult.h>

#include <paxnet\PclEmvDetectICCardCommand.h>
#include <paxnet\PclEmvBeginContactTxnCommand.h>
#include <paxnet\PclEmvContinueContactTxnCommand.h>
#include <paxnet\PclEmvEndContactTxnCommand.h>
#include <paxnet\PclEmvBeginContactlessTxnCommand.h>
#include <paxnet\PclEmvEndContactlessTxnCommand.h>
#include <paxnet\PclEmvRemoveContactCardCommand.h>
#include <paxnet\PclEmvSetContactTLVDataCommand.h>
#include <paxnet\PclEmvSetContactlessTLVDataCommand.h>
#include <paxnet\PclEmvGetContactTLVDataCommand.h>
#include <paxnet\PclEmvGetContactlessTLVDataCommand.h>
#include <paxnet\PclEmvReleaseContactlessServiceCommand.h>
#include <paxnet\PclDisplayFormCommand.h>
#include <paxnet\PclSetFormPackageCommand.h>
#include <paxnet\PclGetPackageListCommand.h>
#include <paxnet\PclGetVariableListCommand.h>
#include <paxnet\PclSetVariableCommand.h>
#include <paxnet\PclGetFormListCommand.h>
#include <paxnet\DataBuffer.h>
#include <paxnet\PclDownloadResult.h>
#include <paxnet\PclResponseMessage.h>
#include <paxnet\PclGetFileCommand.h>
#include <paxnet\PclEmvGetAppListContactTxnCommand.h>
#include <paxnet\PclEmvSelectAppContactTxnCommand.h>


#include <fstream>
#include <iostream>
#include <sstream>
#include <string>
#include<iostream>
#include<ctime>
#include<cstdlib>
#include<paxnet\PclWicClaimServiceCommand.h>

#define WM_THREAD_STOP 0x0427



using namespace std; 
using namespace pax;

static const uint16_t REMOVE_ALL_ITEMS = 0xFFFF;
std::mutex CDiglog_SHOW::m_ICCardMutex;
std::mutex CDiglog_SHOW::m_RFCardMutex;
std::mutex CDiglog_SHOW::m_WicMutex;
std::mutex CDiglog_SHOW::m_ContactRecy;
std::mutex CDiglog_SHOW::m_ContactLessRecy;
std::mutex CDiglog_SHOW::m_WicRecy;
CDialog *CDiglog_SHOW::m_pThisDialog = NULL;

int g_iIntervalRF=2;
int g_iIntervalIC=2;
int g_iIntervalWIC=2;


int g_iTimes= 0;

bool CDiglog_SHOW::m_bFlag = true;

IMPLEMENT_DYNAMIC(CDiglog_SHOW, CDialog)


CDiglog_SHOW::CDiglog_SHOW(CWnd* pParent /*=NULL*/)
: CDialog(CDiglog_SHOW::IDD, pParent),
 CdiglogPublic(),
 m_iButtonLineTimes(0),
 m_dAmountOk(0),
 m_dSubTotal(0),
 m_dTax(0),
 m_bICCard(false),
 m_iAciMode(0),
 m_bRFCard(false),
 m_bIsAciMod(false),
 m_bNotify(false),
 m_bRecyContanct(false),
 m_bRecyContanctLess(false),
 //m_bRecyWic(false),
 m_bContactRecy(true),
 m_bContactlessRecy(true),
 m_bWicRecy(true),
 m_iCout(0),
 //m_iInterval(0),
 m_iRFTimes(0),
 m_iICTimes(0),
 m_iWICTimes(0),
 m_bApproved(false)//,
 {

}


CDiglog_SHOW::~CDiglog_SHOW(){

}
void CDiglog_SHOW::DoDataExchange(CDataExchange* pDX){
	CDialog::DoDataExchange(pDX);
	DDX_Control(pDX, IDC_LIST1, m_listBox);
	DDX_Control(pDX, IDC_TOTAL, m_total);
//	DDX_Control(pDX, IDC_BUTTON_OPEN, m_IOpenBtn);
	DDX_Control(pDX, IDC_CONFIG, m_fileEdt);
	DDX_Control(pDX, IDC_RFTIMES, m_RFEditTimes);
	DDX_Control(pDX, IDC_ICTIMES, m_ICEditTimes);
	DDX_Control(pDX, IDC_WICTIMES, m_WICEditTimes);
	
}


BEGIN_MESSAGE_MAP(CDiglog_SHOW, CDialog)
	ON_BN_CLICKED(IDC_BUTTON_NEW, &CDiglog_SHOW::OnBnClickedButtonNew)
	ON_BN_CLICKED(IDC_BUTTON_LINE, &CDiglog_SHOW::OnBnClickedButtonLine)
	ON_BN_CLICKED(IDC_BUTTON_TOTAL, &CDiglog_SHOW::OnBnClickedButtonTotal)
	ON_LBN_SELCHANGE(IDC_LIST1, &CDiglog_SHOW::OnLbnSelchangeList1)
//	ON_BN_CLICKED(IDC_APPRO, &CDiglog_SHOW::OnBnClickedAppro)
	ON_EN_CHANGE(IDC_TOTAL, &CDiglog_SHOW::OnEnChangeTotal)
	//ON_BN_CLICKED(IDC_INVALID_PIN, &CDiglog_SHOW::OnBnClickedInvalidPin)
	//ON_BN_CLICKED(IDC_DECLINED, &CDiglog_SHOW::OnBnClickedDeclined)
	ON_BN_CLICKED(IDC_BUTTON_CLEAR, &CDiglog_SHOW::OnBnClickedButtonClear)
	ON_EN_CHANGE(IDC_EDITRECV, &CDiglog_SHOW::OnEnChangeEditrecv)
	ON_EN_CHANGE(IDC_EDITSEND, &CDiglog_SHOW::OnEnChangeEditsend)
	ON_BN_CLICKED(IDC_ACI, &CDiglog_SHOW::OnBnClickedAci)
	ON_BN_CLICKED(IDC_STANDARD, &CDiglog_SHOW::OnBnClickedStandard)
	ON_BN_CLICKED(IDC_HEB, &CDiglog_SHOW::OnBnClickedHeb)
	ON_BN_CLICKED(IDC_BUTTON_OPEN, &CDiglog_SHOW::OnBnClickedButtonOpen)
//	ON_EN_CHANGE(IDC_CONFIG, &CDiglog_SHOW::OnEnChangeConfig)
	//ON_BN_CLICKED(IDC_RECY, &CDiglog_SHOW::OnBnClickedRecy)
//	ON_BN_CLICKED(IDC_RECY2, &CDiglog_SHOW::OnBnClickedRecy2)
	ON_BN_CLICKED(IDC_BEGIN, &CDiglog_SHOW::OnBnClickedBegin)
	ON_BN_CLICKED(IDC_END, &CDiglog_SHOW::OnBnClickedEnd)
	ON_BN_CLICKED(IDC_APPROVED, &CDiglog_SHOW::OnBnClickedApproved)
	ON_BN_CLICKED(IDC_DECL, &CDiglog_SHOW::OnBnClickedDecl)
END_MESSAGE_MAP()

BOOL CDiglog_SHOW::OnInitDialog()
{
	CDialog::OnInitDialog();
	CButton* radio=(CButton*)GetDlgItem(IDC_STANDARD);
	
	radio->SetCheck(1);

	radio=(CButton*)GetDlgItem(IDC_DECL);
	
	radio->SetCheck(1);
	
	//HICON hIcon = AfxGetApp()->LoadIcon(IDI_IOPEN); 
	//m_IOpenBtn.SetIcon(hIcon);
	//m_fileEdt.SetWindowText(m_filePath.c_str());
	//m_fileEdt.UpdateData(false);
	
	//设置显示最大字符数
	((CEdit*)GetDlgItem(IDC_EDITRECV))->SetLimitText(65535);
	((CEdit*)GetDlgItem(IDC_EDITSEND))->SetLimitText(65535);

	CButton *pEndBtn = (CButton*)this->GetDlgItem(IDC_END);
	pEndBtn->EnableWindow(false);
	m_RFEditTimes.EnableWindow(false);
	m_ICEditTimes.EnableWindow(false);
	m_WICEditTimes.EnableWindow(false);

	return TRUE;
}


int CDiglog_SHOW:: ranDom(){
	srand((unsigned)time(NULL));
	return rand()%100;
}
void CDiglog_SHOW::clearBox(){
	m_dAmountOk = 0,
	m_dSubTotal = 0,
	m_dTax = 0;
	m_iButtonLineTimes = 0;
	m_listBox.ResetContent();
	
}
void CDiglog_SHOW::OnBnClickedButtonNew()
{
	// TODO:  在此添加控件通知处理程序代码
	// TODO:  在此添加控件通知处理程序代码
	clearBox();
	SetDlgItemText(IDC_TOTAL, "");
	
	pax::PclRequestMessage request;

	// source
	auto sourceAddress = "ECR";
	request.setSourceAddress(sourceAddress);

	// destination
	auto destAddress = "TERMINAL";
	request.setDestAddress(destAddress);

	//command
	pax::PclListBoxRemoveItemCommand Command;
	Command.setListControlId("LIST.ITEM");
	Command.addListItemId(REMOVE_ALL_ITEMS);
	Command.setSequenceNo(1);
	Command.addToMessage(request);
	sendRequest(request);

	// SetVariable STR.SUBTOTAL<FS>$0.00<RS>STR.TAX<FS>$0.00<RS>STR.AMOUNTOK<FS>$0.00<RS>STR.AMOUNTDUE<FS>$0.00<RS>STR.LANE_CLOSED<FS>Welcome
	//<RS>STR.PRESENT_CARD<FS>Welcome to ACI Worldwide<RS>BOOL.MSRENABLE<FS>false
	pax::PclSetVariableCommand setVarCMD;
	setVarCMD.setSequenceNo(2);
	setVarCMD.addVariable( "STR.SUBTOTAL", "$0.00");
	setVarCMD.addVariable( "STR.TAX", "$0.00");
	setVarCMD.addVariable( "STR.AMOUNTOK", "$0.00");
	setVarCMD.addVariable( "STR.AMOUNTDUE", "$0.00");
	setVarCMD.addVariable( "STR.LANE_CLOSED", "Welcome");
	setVarCMD.addVariable( "STR.PRESENT_CARD", "Welcome to ACI Worldwide");
	setVarCMD.addVariable( "BOOL.MSRENABLE", "false");
	
	setVarCMD.addToMessage(request);
	sendRequest(request);

	//DisplayForm LaneClosedScreen
	pax::PclDisplayFormCommand displayCMD;
	displayCMD.setFormName("LaneClosedScreen");
	displayCMD.setSequenceNo(3);
	displayCMD.addToMessage(request);
	sendRequest(request);
	return;
}

void CDiglog_SHOW::ChangeConfigItem(std::string strTYPE, std::string strCMDName){
	CString buffer;
	GetPrivateProfileStringA(strTYPE.c_str(), strCMDName.c_str(), "", buffer.GetBuffer(MAX_SIZE), MAX_SIZE, strConfigFile.c_str());
	std::string str_datas = buffer.GetBuffer();
	std::string strAmount = std::to_string(m_dAmountOk);
	std::vector<std::string> data = split( strAmount, ".");
	std::string s1 = data[0]+ data[1].substr(0,2);
	str_datas.replace(20-s1.size(), s1.size(), s1);
	WritePrivateProfileString(strTYPE.c_str(), strCMDName.c_str(), str_datas.c_str(), strConfigFile.c_str());
}
void CDiglog_SHOW::OnBnClickedButtonLine()
{ 
	// TODO:  在此添加控件通知处理程序代码
	std::string item;
	CString strData ;
	auto ranDomData = 0;
	
	m_iButtonLineTimes++;
	pax::PclRequestMessage request;
	
	// source
	auto sourceAddress = "ECR";
	request.setSourceAddress(sourceAddress);

	// destination
	auto destAddress = "TERMINAL";
	request.setDestAddress(destAddress);
	
	//1. pax::PclListBoxInsertItemCommand * command
	pax::PclListBoxInsertItemCommand command;

	command.setListControlId("LIST.ITEM");

	command.setSequenceNo(0);
	
	auto plistItem = std::shared_ptr< pax::PclListBoxInsertItemCommand::ListItem >( new pax::PclListBoxInsertItemCommand::ListItem );
	plistItem->referenceId = 1;
    plistItem->position = pax::PclListBoxInsertItemCommand::END;
    plistItem->itemId = m_iButtonLineTimes;

	ranDomData = ranDom();
	m_dSubTotal += ranDomData;
	//m_dTax = m_dSubTotal*0.05;
	m_dTax = ranDomData*0.05;
	//m_dAmountOk = m_dSubTotal +m_dTax;
	m_dAmountOk += ranDomData +m_dTax;
	ranDomData += m_dTax;//for show

	item =" Line Item "
		+ std::to_string(m_iButtonLineTimes)
		+ " ................................................Amount:"
		+ std::to_string(ranDomData)+"$"
		+ "................Tax:"
		+std::to_string(m_dTax).substr(0,4)+"$";
			
    plistItem->text =item; //"Line Item times ............ $value" 文本加上数

	command.addListItem( plistItem);

	command.addToMessage(request);

	sendRequest(request);
	
	m_listBox.InsertString(m_listBox.GetCount(),item.c_str());
	m_listBox.SetCurSel(m_listBox.GetCount()-1);

    //chage 9f02
    ChangeConfigItem("Contact", "BEGIN");
    ChangeConfigItem("Contact", "GETAPPLIST");
	ChangeConfigItem("Contact", "CONTINUE");
	ChangeConfigItem("Contactless", "BEGIN");
	
	//2: SET_VARIABLE
	pax::PclSetVariableCommand setVarCMD;
  	//setVarCMD.setSequenceNo(m_iButtonLineTimes);
  	setVarCMD.setSequenceNo(2);
	setVarCMD.addVariable( "STR.AMOUNTOK", std::to_string(m_dAmountOk));
	setVarCMD.addVariable( "STR.SUBTOTAL", std::to_string(m_dSubTotal));
	setVarCMD.addVariable( "STR.TAX", to_string(m_dTax));
	setVarCMD.addToMessage(request);

	sendRequest(request);
}
std::string CDiglog_SHOW::getAmountStr(){
	std::string strInteger = "";
	std::string strDecimal ="";
	std::string strAmount="";
	int iBits = 0;
	std::stringstream ssFields(std::to_string(m_dAmountOk));
	std::getline( ssFields, strInteger, '.');
	std::getline( ssFields, strDecimal, '.');
	iBits = strInteger.size()+2;
	for(int i=0; i<12-iBits; i++)strAmount+="0";
	strAmount+= strInteger+strDecimal.substr(0,2);
	return strAmount;
}
bool CDiglog_SHOW::SetEMVData(std::vector<pax::EMV_TLV> &emv_datas){
	pax::EMV_TLV emv_dataItem;
	std::string strInteger = "";
	std::string strDecimal ="";
	
	//0x9F02
	emv_dataItem.strTag = "9F02";
	emv_dataItem.strData = getAmountStr();//设置金额
	emv_dataItem.strKer ="0";
	emv_datas.push_back(emv_dataItem);

	//0x9F03
	emv_dataItem.strTag = "9F03";
	emv_dataItem.strData = "000000000000";
	emv_dataItem.strKer ="0";
	emv_datas.push_back(emv_dataItem);

	//0x9c
	emv_dataItem.strTag = "9C";
	emv_dataItem.strData = "00";
	emv_dataItem.strKer ="0";
	emv_datas.push_back(emv_dataItem);

	//0x9A
	emv_dataItem.strTag = "9A";
	emv_dataItem.strData = "180523";
	emv_dataItem.strKer ="0";
	emv_datas.push_back(emv_dataItem);

	//0x9F21
	emv_dataItem.strTag = "9F21";
	emv_dataItem.strData = "113000";
	emv_dataItem.strKer ="0";
	emv_datas.push_back(emv_dataItem);
	return true;
}

/*
void CDiglog_SHOW::OnBnClickedButtonTotal()
{
	// TODO:  在此添加控件通知处理程序代码
	//m_total = std::to_string(m_dAmountOk );
	//UpdateData(false);
	
	std::string strAmount = std::to_string(m_dAmountOk);
	strAmount ="$" + strAmount;
	m_total.SetWindowText(strAmount.c_str());
	m_total.UpdateData(false);

	pax::PclRequestMessage request;

	// source
	auto sourceAddress = "ECR";
	request.setSourceAddress(sourceAddress);

	// destination
	auto destAddress = "TERMINAL";
	request.setDestAddress(destAddress);

	//非接接触式轮询剪卡,再交易
	//1:PclEmvBeginContactlessTxnCommand ,设置EMV的tag值
	pax::PclEmvBeginContactlessTxnCommand beginclessCMD;
	std::vector<pax::EMV_TLV> emv_datas;
	if (!SetEMVData(emv_datas))
	return;
	beginclessCMD.addEMVTLVData(std::make_shared<std::vector<pax::EMV_TLV>>(emv_datas));
	beginclessCMD.setSequenceNo(0);
	beginclessCMD.addToMessage(request);
	sendRequest(request);
	
	//2: DISPLAY_FORM: SwipeScreen
	pax::PclDisplayFormCommand displayCMD;
	displayCMD.setFormName("SwipeScreen");
	displayCMD.setSequenceNo(1);
	displayCMD.addToMessage(request);
	sendRequest(request);

	//3: SET_VARIABLE: STR.SWIPE = Please Swipe or Insert Card
	pax::PclSetVariableCommand setVarCMD;
	setVarCMD.setSequenceNo(2);
	setVarCMD.addVariable( " STR.SWIPE", "Please Swipe or Insert Card");
	setVarCMD.addToMessage(request);
	sendRequest(request);

}
*/
	
void CDiglog_SHOW::setCommandRequest(pax::PclCommand* command){
	pax::PclRequestMessage request;

	// source
	auto sourceAddress = "ECR";
	request.setSourceAddress(sourceAddress);

	// destination
	auto destAddress = "TERMINAL";
	request.setDestAddress(destAddress);

	command->addToMessage(request);
	sendRequest(request);

}
int CDiglog_SHOW::IsAciMod(){

	return m_iAciMode;
}
bool CDiglog_SHOW::getNotify(){
	return m_bNotify;
}
void CDiglog_SHOW::setNotify(){
	m_bNotify = false;
}


void CDiglog_SHOW::DoContactlessTrans(){
	CDiglog_SHOW:: m_RFCardMutex.lock();
	if(bBeginSuccsess != true){
		pax::PclEmvBeginContactlessTxnCommand beginclessCMD;
		std::vector<pax::EMV_TLV> emv_datas;
		GetINIEmvData("Contactless","BEGIN", emv_datas);
		beginclessCMD.addEMVTLVData(std::make_shared<std::vector<pax::EMV_TLV>>(emv_datas));
		beginclessCMD.setSequenceNo(0);
		setCommandRequest(&beginclessCMD);
	}
	CDiglog_SHOW:: m_RFCardMutex.unlock();
	return;
}
void CDiglog_SHOW::DoContactTrans(){
	CDiglog_SHOW:: m_ICCardMutex.lock();
	if(bDetectSuccess != true){
		pax::PclEmvDetectICCardCommand detectICCMD;
		detectICCMD.setSequenceNo(0);
		setCommandRequest(&detectICCMD);
	}
	CDiglog_SHOW:: m_ICCardMutex.unlock();
	return;
}
void CDiglog_SHOW::DoWicClaimService(){
	CDiglog_SHOW::m_WicMutex.lock();
	if(bWicSuccess == false){
		pax::PclWicClaimServiceCommand CMD;
		std::vector<pax::EMV_TLV> emv_datas;
		GetINIEmvData("WIC","ClaimService", emv_datas);
		pax::EMV_TLV tlv = emv_datas.front();
		std::string str = tlv.strData;
		pax::DataBuffer dataTLV(1024);
		dataTLV.insertData(str.c_str(), str.size());
		CMD.setWICKeyIndex(dataTLV);
		CMD.setSequenceNo(0);
		setCommandRequest(&CMD);
	}
	CDiglog_SHOW::m_WicMutex.unlock();
}
//bool CDiglog_SHOW::GetContactRecy(){
	//CDiglog_SHOW::m_Recy.lock();
	//return m_bRecyling;
	//CDiglog_SHOW::m_Recy.unlock();
//}

void CDiglog_SHOW::ContactTrans(){
	DoContactTrans();
	return;
}

void CDiglog_SHOW::ContactlessTrans(){
	DoContactlessTrans();
	return;
}
	
void CDiglog_SHOW::WicClaimService(){
	DoWicClaimService();
	return;
}

void CDiglog_SHOW::OnBnClickedButtonTotal()
{
	// TODO:  在此添加控件通知处理程序代码
	//m_total = std::to_string(m_dAmountOk );
	//UpdateData(false);
	
	std::string strAmount = std::to_string(m_dAmountOk);
	std::vector<std::string> data = split( strAmount, ".");
	std::string str = data[0]
			    + "."
				+ data[1].substr(0,2)
				+ "$";
	
	m_total.SetWindowText(str.c_str());
	m_total.UpdateData(false);


	m_bNotify = true;
	if(m_iAciMode == 2){
		std::thread wicThread(&CDiglog_SHOW::WicClaimService, this);
		wicThread.detach();
	}else{
		std::thread detectRFCardthread(&CDiglog_SHOW::ContactlessTrans,this);
		detectRFCardthread.detach();
		std::thread detectICCardthread(&CDiglog_SHOW::ContactTrans,this);
		detectICCardthread.detach();
	}
	CButton *pBtnEnd = (CButton*)this->GetDlgItem(IDC_END);
	CButton *pBtnBegin = (CButton*)this->GetDlgItem(IDC_BEGIN);
	m_iCout++;
	if(m_iCout%2 !=0){
		pBtnBegin->EnableWindow(false);
		pBtnEnd->EnableWindow(false);
	}else{
		pBtnBegin->EnableWindow(true);
		pBtnEnd->EnableWindow(true);
	}
}
void CDiglog_SHOW::OnBnClickedButton()
{
	while(1){	
		_sleep(3*1000);
	}

}



bool CDiglog_SHOW::getApproved(){
return m_bApproved;
}


void CDiglog_SHOW::OnLbnSelchangeList1()
{
	// TODO:  在此添加控件通知处理程序代码

	  

}


void CDiglog_SHOW::OnEnChangeEditsend2()
{
	// TODO:  如果该控件是 RICHEDIT 控件,它将不
	// 发送此通知,除非重写 CDialog::OnInitDialog()
	// 函数并调用 CRichEditCtrl().SetEventMask(),
	// 同时将 ENM_CHANGE 标志“或”运算到掩码中。

	// TODO:  在此添加控件通知处理程序代码
}


void CDiglog_SHOW::OnEnChangeEditrecv2()
{
	// TODO:  如果该控件是 RICHEDIT 控件,它将不
	// 发送此通知,除非重写 CDialog::OnInitDialog()
	// 函数并调用 CRichEditCtrl().SetEventMask(),
	// 同时将 ENM_CHANGE 标志“或”运算到掩码中。

	// TODO:  在此添加控件通知处理程序代码
}




void CDiglog_SHOW::OnEnChangeTotal()
{
	// TODO:  如果该控件是 RICHEDIT 控件,它将不
	// 发送此通知,除非重写 __super::OnInitDialog()
	// 函数并调用 CRichEditCtrl().SetEventMask(),
	// 同时将 ENM_CHANGE 标志“或”运算到掩码中。

	// TODO:  在此添加控件通知处理程序代码
}



void CDiglog_SHOW::OnBnClickedButtonClear()
{
	// TODO:  在此添加控件通知处理程序代码
	SetDlgItemText(IDC_EDITSEND, "");
	SetDlgItemText(IDC_EDITRECV, "");
	strDataRecv = "";
	strDataSend = "";
}


void CDiglog_SHOW::OnEnChangeEditrecv()
{
	// TODO:  如果该控件是 RICHEDIT 控件,它将不
	// 发送此通知,除非重写 __super::OnInitDialog()
	// 函数并调用 CRichEditCtrl().SetEventMask(),
	// 同时将 ENM_CHANGE 标志“或”运算到掩码中。

	// TODO:  在此添加控件通知处理程序代码
}


void CDiglog_SHOW::OnEnChangeEditsend()
{
	// TODO:  如果该控件是 RICHEDIT 控件,它将不
	// 发送此通知,除非重写 __super::OnInitDialog()
	// 函数并调用 CRichEditCtrl().SetEventMask(),
	// 同时将 ENM_CHANGE 标志“或”运算到掩码中。

	// TODO:  在此添加控件通知处理程序代码
}


void CDiglog_SHOW::OnBnClickedAci()
{
	// TODO:  在此添加控件通知处理程序代码
	m_iAciMode = 1;
}


void CDiglog_SHOW::OnBnClickedStandard()
{
	// TODO:  在此添加控件通知处理程序代码
	m_iAciMode = 0;
}


void CDiglog_SHOW::OnBnClickedHeb()
{
	// TODO:  在此添加控件通知处理程序代码
	m_iAciMode = 2;
}


void CDiglog_SHOW::OnBnClickedButtonOpen()
{
	// TODO:  在此添加控件通知处理程序代码
#if 0
	char szPath[500];     //存放选择的目录路径 
    CString str;

    ZeroMemory(szPath, sizeof(szPath));   

    BROWSEINFO bi;   
    bi.hwndOwner = NULL;   
    bi.pidlRoot = NULL;   
    bi.pszDisplayName = szPath;   
    bi.lpszTitle = "请选择需要打包的目录:";   
    //bi.ulFlags = 0;
	bi.ulFlags=BIF_NEWDIALOGSTYLE;//调整子窗口的大小
    bi.lpfn = NULL;   
    bi.lParam = 0;   
    bi.iImage = 0;  
	
    //弹出选择目录对话框
    LPITEMIDLIST lp = SHBrowseForFolder(&bi);   

    if(lp && SHGetPathFromIDList(lp, szPath))   
    {
        str.Format("选择的目录为 %s",  szPath);
        AfxMessageBox(str); 
        
    }
    else   
        AfxMessageBox("无效的目录,请重新选择");   
#endif
	std::thread thread1(&CDiglog_SHOW::BootOpenDialog, this);
	thread1.detach();
	//BootOpenDialog(); 

}


CString CDiglog_SHOW::BootOpenDialog()   //返回选择的文件名称
{
    CString strFile = _T("");
    CFileDialog dlgFile(TRUE, NULL, NULL, OFN_HIDEREADONLY, _T("Describe Files (*.ini)|*.ini|All Files (*.*)|*.*||"), NULL);
    if (dlgFile.DoModal()){
        strFile = dlgFile.GetPathName();
    }
	m_fileEdt.UpdateData(TRUE);
	m_fileEdt.SetWindowText(strFile);
	m_fileEdt.UpdateData(FALSE);
	//m_filePath = strFile.GetBuffer();
	strConfigFile = strFile.GetBuffer();
    return strFile;
}
//void CDiglog_SHOW::OnBnClickedSelectFile(){
//	while(1){
//	m_fileEdt.SetWindowText(m_filePath.c_str());
//	m_fileEdt.UpdateData(false);}
//}




//void CDiglog_SHOW::OnEnChangeConfig()
//{
	// TODO:  如果该控件是 RICHEDIT 控件,它将不
	// 发送此通知,除非重写 __super::OnInitDialog()
	// 函数并调用 CRichEditCtrl().SetEventMask(),
	// 同时将 ENM_CHANGE 标志“或”运算到掩码中。

	// TODO:  在此添加控件通知处理程序代码
//}


void CDiglog_SHOW::ContactTransRecycle(){
	
	while(1){
		//CDiglog_SHOW::m_ContactRecy.lock();
		if (!m_bContactRecy) break;
		//CDiglog_SHOW::m_ContactRecy.unlock();
		DoContactTrans();
		_sleep(2*1000);
	}
	//_sleep(500);
}
void CDiglog_SHOW::ContactlessTransRecycle(){

	while(1){
		//CDiglog_SHOW::m_ContactLessRecy.lock();
		if(!m_bContactlessRecy)break;
		//CDiglog_SHOW::m_ContactLessRecy.unlock();
		DoContactlessTrans();
		_sleep(2*1000);
	}
	//_sleep(500);
}
void CDiglog_SHOW::WicClaimServiceRecycle(){
	//CDiglog_SHOW::m_WicRecy.lock();
	while(1){
		if(!m_bWicRecy) break;
		DoWicClaimService();
		_sleep(2*1000);
	}
	//CDiglog_SHOW::m_WicRecy.unlock();
	//_sleep(500);
}
 void CDiglog_SHOW::EndIC(){
	CDiglog_SHOW::m_ContactRecy.lock();
	m_bContactRecy = false;
	CDiglog_SHOW::m_ContactRecy.unlock();
}
 void CDiglog_SHOW::EndRF(){
	
	CDiglog_SHOW::m_ContactLessRecy.lock();
	m_bContactlessRecy = false;
	CDiglog_SHOW::m_ContactLessRecy.unlock();
}
 void CDiglog_SHOW::EndWIC(){
	CDiglog_SHOW::m_WicRecy.lock();
	//while(m_bWicRecy){
		m_bWicRecy = false;
	//}
	CDiglog_SHOW::m_WicRecy.unlock();
}



void CDiglog_SHOW::OnBnClickedBegin(){
	// TODO:  在此添加控件通知处理程序代码
		// TODO:  在此添加控件通知处理程序代码
	CEdit *pEditInterval = (CEdit*)this->GetDlgItem(IDC_INTERVAL);
	CString strInterval;
	pEditInterval->GetWindowText(strInterval);
	std::string str=strInterval.GetBuffer();
	int itimes = atoi(str.c_str());
	if(itimes != 0 && itimes >= 1){
		g_iIntervalRF = itimes;
		g_iIntervalIC =itimes;
 		g_iIntervalWIC =itimes;
	}
	m_iRFTimes=0;
	std::string strRF= std::to_string(m_iRFTimes);
	m_RFEditTimes.SetWindowText(strRF.c_str());
	m_RFEditTimes.UpdateData(false);

	m_iICTimes=0;
	std::string strIC = std::to_string(m_iICTimes);
	m_ICEditTimes.SetWindowText(strIC.c_str());
	m_ICEditTimes.UpdateData(false);

	m_iWICTimes=0;
	std::string strWIC= std::to_string(m_iWICTimes);
	m_WICEditTimes.SetWindowText(strWIC.c_str());
	m_WICEditTimes.UpdateData(false);
	
	if(m_iAciMode == 2){
		m_WICThread= AfxBeginThread((AFX_THREADPROC)WICThreadProc, NULL);
	}else{
		m_RFThread = AfxBeginThread((AFX_THREADPROC)RFThreadProc, NULL);
		m_IcThread = AfxBeginThread((AFX_THREADPROC)ICThreadProc, NULL);
	}
	CButton *pEndBtn = (CButton*)this->GetDlgItem(IDC_BEGIN);
	pEndBtn->EnableWindow(false);
	pEndBtn = (CButton*)this->GetDlgItem(IDC_END);
	pEndBtn->EnableWindow(true);
	pEndBtn = (CButton*)this->GetDlgItem(IDC_BUTTON_TOTAL);
	pEndBtn->EnableWindow(false);
}

void CDiglog_SHOW::AddAndShowRFTimes(int itimes){
	m_iRFTimes += itimes;
	//m_RFEditTimes.EnableWindow(true);
	std::string str = std::to_string(m_iRFTimes);
	m_RFEditTimes.SetWindowText(str.c_str());
	m_RFEditTimes.UpdateData(false);
}
void CDiglog_SHOW::AddAndShowICTimes(int itimes){
	m_iICTimes += itimes;
	//m_RFEditTimes.EnableWindow(true);
	std::string str= std::to_string(m_iICTimes);
	m_ICEditTimes.SetWindowText(str.c_str());
	m_ICEditTimes.UpdateData(false);
}
void CDiglog_SHOW::AddAndShowWICTimes(int itimes){
	m_iWICTimes += itimes;
	//m_RFEditTimes.EnableWindow(true);
	std::string str= std::to_string(m_iWICTimes);
	m_WICEditTimes.SetWindowText(str.c_str());
	m_WICEditTimes.UpdateData(false);
}



void CDiglog_SHOW::OnBnClickedEnd(){
	// TODO:  在此添加控件通知处理程序代码
	
	// TODO:  在此添加控件通知处理程序代码
	if(m_iAciMode == 2){
		m_WICThread->PostThreadMessage(WM_THREAD_STOP, NULL, NULL);
	}else{
		m_IcThread->PostThreadMessage(WM_THREAD_STOP, NULL, NULL);
		m_RFThread->PostThreadMessage(WM_THREAD_STOP, NULL, NULL);
	}
	CButton *pEndBtn = (CButton*)this->GetDlgItem(IDC_BEGIN);
	pEndBtn->EnableWindow(true);
	pEndBtn = (CButton*)this->GetDlgItem(IDC_BUTTON_TOTAL);
	pEndBtn->EnableWindow(true);
	
	//std::string strRF= std::to_string(m_iRFTimes);
	//m_RFEditTimes.SetWindowText(strRF.c_str());
	//m_RFEditTimes.UpdateData(false);
	//m_RFEditTimes.EnableWindow(false);
}
void CDiglog_SHOW::setFlag(bool val){
	m_bFlag = val;
}


#if 0
	while(1){
		CEcrSimulatorDlg * pDialog = (CEcrSimulatorDlg *)CDiglog_SHOW::getDialog();
		CDiglog_SHOW* pObj = pDialog->getShow();
		pObj->DoContactTrans();
		_sleep(2*1000);
	}
#endif

UINT CDiglog_SHOW::RFThreadProc(LPVOID pParam){
	while(1){
			MSG msg;
			while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){  
				
				if(msg.message == WM_THREAD_STOP){
					return 0;
				}else{
					DispatchMessage(&msg);
				}	
			}
			CEcrSimulatorDlg * pDialog = (CEcrSimulatorDlg *)CDiglog_SHOW::getDialog();
			CDiglog_SHOW* pObj = pDialog->getShow();
			pObj->DoContactlessTrans();
			_sleep(g_iIntervalRF*1000);
		}
		return 0;
}
UINT CDiglog_SHOW::ICThreadProc(LPVOID pParam){
	while(1){
		MSG msg;
		while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){  
			
			if(msg.message == WM_THREAD_STOP){
				return 0;
			}else{
				DispatchMessage(&msg);
			}   
		}
	    CEcrSimulatorDlg * pDialog = (CEcrSimulatorDlg *)CDiglog_SHOW::getDialog();
		CDiglog_SHOW* pObj = pDialog->getShow();
		pObj->DoContactTrans();
		_sleep(g_iIntervalIC*1000);
	}
	return 0;
}
UINT CDiglog_SHOW::WICThreadProc(LPVOID pParam){
	while(1){
		MSG msg;
		while(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){  
			
			if(msg.message == WM_THREAD_STOP){
				return 0;
			}else{
				DispatchMessage(&msg);
			}   
		}
	    CEcrSimulatorDlg * pDialog = (CEcrSimulatorDlg *)CDiglog_SHOW::getDialog();
		CDiglog_SHOW* pObj = pDialog->getShow();
		pObj->DoWicClaimService();
		_sleep(g_iIntervalWIC*1000);
	}
	return 0;
}


void CDiglog_SHOW::setDialog(CDialog *pThis){
	m_pThisDialog = pThis;
}
CDialog * CDiglog_SHOW::getDialog(){
	return m_pThisDialog;
}


void CDiglog_SHOW::OnBnClickedApproved()
{
	// TODO:  在此添加控件通知处理程序代码
	m_bApproved = true;
}


void CDiglog_SHOW::OnBnClickedDecl()
{
	// TODO:  在此添加控件通知处理程序代码
	m_bApproved =false;
}

 

版权声明:本文为cindywry原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://blog.csdn.net/cindywry/article/details/87531132

智能推荐

Python学习练习6----列表、字典的运用2

range 用法参见http://blog.csdn.net/chiclewu/article/details/50592368 直接在 在线编程工具中练习: https://www.tutorialspoint.com/execute_python_online.php 代码如下,增加range、列表的len()、字典的items()函数,for 函数也有了新变化 练习2: 2的运行结果,注意p...

PoolThreadCache

缓存构成   PoolThreadCache的缓存由三部分构成:tiny、small 和 normal。 tiny   缓存数据大小区间为[16B, 496B]数据,数组长度为32,根据数据大小计算索引的办法:数据大小除以16,如下代码所示: small   缓存数据大小区间为[512B, 4KB]数据,数组长度为4,根据数据大小计算索引的办法:数据大小除以512,然后log2得到指数,如下代码所...

Intellij IDEA 搭建Spring Boot项目(一)

Intellij IDEA 搭建Spring Boot项目 标签(空格分隔): SpringBoot JAVA后台 第一步 选择File –> New –> Project –>Spring Initialer –> 点击Next  第二步 自己修改 Group 和 Artif...

CentOS学习之路1-wget下载安装配置

参考1: https://blog.csdn.net/zhaoyanjun6/article/details/79108129 参考2: http://www.souvc.com/?p=1569 CentOS学习之路1-wget下载安装配置 1.wget的安装与基本使用 安装wget yum 安装软件 默认安装保存在/var/cache/yum ,用于所有用户使用。 帮助命令 基本用法 例子:下载...

深入浅出Spring的IOC容器,对Spring的IOC容器源码进行深入理解

文章目录 DispatcherServlet整体继承图 入口:DispatcherServlet.init() HttpServletBean.init() FrameworkServlet.initServletBean() 首先大家,去看Spring的源码入口,第一个就是DispatcherServlet DispatcherServlet整体继承图 入口:DispatcherServlet....

猜你喜欢

laravel框架的课堂知识点概总

1. MVC 1.1 概念理解 MVC全名是Model View Controller,是模型(model)-视图(view)-控制器(controller)的缩写,一种软件设计典范,用一种业务逻辑、数据、界面显示分离的方法组织代码,将业务逻辑聚集到一个部件里面,在改进和个性化定制界面及用户交互的同时,不需要重新编写业务逻辑 MVC 是一种使用 MVC(Model View Controller ...

Unity人物角色动画系统学习总结

使用动画系统控制人物行走、转向、翻墙、滑行、拾取木头 混合树用来混合多个动画 MatchTarget用来匹配翻墙贴合墙上的某一点,人物以此为支点翻墙跳跃 IK动画类似于MatchTarget,控制两只手上的两个点来指定手的旋转和位置,使得拾取木头时更逼真 创建AnimatorController: 首先创建一个混合树,然后双击 可以看到该混合树有五种状态机,分别是Idle、WalkForward、...

Composer 安装 ThinkPHP6 问题

Composer 安装 ThinkPHP6 问题 先说说问题 一.运行环境要求 二.配置 参考: ThinkPHP6.0完全开发手册 先说说问题 执行ThinkPHP6的安装命令 遇到问题汇总如下: 看提示是要更新版本,执行命令更新。 更新之后,再次安装ThinkPHP,之后遇到如下问题。 尝试了很多方法,依然不能解决。其中包括使用https://packagist.phpcomposer.com...

Spring Boot 整合JDBC

今天主要讲解一下SpringBoot如何整合JDBC,没啥理论好说的,直接上代码,看项目整体结构 看一下对应的pom.xml 定义User.java 定义数据源配置,这里使用druid,所以需要写一个配置类 上面指定druid的属性配置,和用户登录的账号信息以及对应的过滤规则: 下面定义数据访问接口和对应的实现: 数据访问层很简单,直接注入JdbcTemplate模板即可,下面再看对应的servi...

html鼠标悬停显示样式

1.显示小手:     在style中添加cursor:pointer 实现鼠标悬停变成小手样式     实例:         其他参数: cursor语法: cursor : auto | crosshair | default | hand | move | help | wait | tex...