#pragma once#include <iostream>#include <Windows.h>classCardManager{public:enumDATA_T{PUBLISHER,CARD_ID,USER_NAME,};private:constshortPUBLISHER_ADDR=0x30;constshortPUBLISHER_LEN=0x10;constshortCARD_ID_ADDR=PUBLISHER_ADDR+PUBLISHER_LEN;constshortCARD_ID_LEN=0x10;constshortUSER_NAME_ADDR=CARD_ID_ADDR+CARD_ID_LEN;constshortUSER_NAME_LEN=0x10;constshortBALANCE_ADDR=USER_NAME_ADDR+USER_NAME_LEN;constshortBALANCE_LEN=0x04;//sizeof(float)constshortBALANCE_BUF_ADDR=BALANCE_ADDR+BALANCE_LEN;constshortBALANCE_BUF_LEN=BALANCE_LEN;HANDLEm_icdev;boolm_passwdChecked;void(*noPasswdFunc)(void);void(*notInitFunc)(void);inlineboolpassWordConfirm(){if(noPasswdFunc&&!m_passwdChecked){noPasswdFunc();}returnm_passwdChecked;}inlineboolinitConfirm(){if(notInitFunc&&!m_icdev){notInitFunc();}returnm_icdev!=0;}boolwriteBalance(floatnum);boolwriteInfo(DATA_Tinfo_type,conststd::string&data);floatgetBuffer();boolwriteBuffer(floatbalance);staticunsignedchar*float2bytes(floatnum);staticfloatbytes2float(unsignedchar*bytes);public:CardManager();virtual~CardManager();inlineboolisInited(){returnm_icdev!=0;}inlinevoidsetNoPasswdCallBack(void(*callBack)(void)){noPasswdFunc=callBack;}inlinevoidsetNotInitCallBack(void(*callback)(void)){notInitFunc=callback;}/* return 0 for ok 1 for init device error 2 for no card */intinit(intport,longbaud);booldisConnect();intgetInfo(DATA_Tdata_type,std::string&out);boolcheckPassWd(constunsignedchar*key);/* return 0 for ok */intrelease(floatinitialBalance);/* return 0 for ok */intconsume(floatcosts);floatgetBalance();intcharge(floatamount);};