id_card_reader.h
2.26 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#ifndef ETRADECLIENT_HARDWARE_ID_CARD_READER_H_INCLUDED
#define ETRADECLIENT_HARDWARE_ID_CARD_READER_H_INCLUDED
/*
密码机信息:
生产厂商:广州江南科友科技股份有限公司
型号:(未知)
*/
#include <string>
struct IDCardInfo
{
std::wstring name;
std::wstring gender;
std::wstring nation;
std::wstring birth_date;
std::wstring address;
std::wstring id_code;
std::wstring depart;
std::wstring start_date;
std::wstring end_date;
std::wstring portrait_img_path;
};
class IDCardReader
{
typedef int(__stdcall *InitCommFunc)(int port);
typedef int(__stdcall *CloseCommFunc)();
typedef int(__stdcall *AuthenticateFunc)();
typedef int(__stdcall *ReadContentFunc)(int active);
typedef int(__stdcall *ReadContentFieldFunc)(char* name, int* len);
public:
/*This function may throw exception if the card reader library cannot be loaded!*/
IDCardReader();
~IDCardReader();
bool Connect() const;
void Disconnect() const;
bool VerifyCard() const;
IDCardInfo ReadCard() const;
//新中新电子身份证读卡器接口 add by liuye 2017.10.24
bool SynConnect();
bool SynFindCard();
IDCardInfo SynReadCard();
bool SynDisConnect();
//
private:
void Init(); // Load library to initialize all the function object.
bool DoConnect(int port_min, int port_max) const;
void GetCardField(ReadContentFieldFunc fn, std::wstring& field) const;
void GetPortraitPath(std::wstring& portrait_path) const;
InitCommFunc m_init_comm_fn; // Function object to init the communitation with ID card reader.
CloseCommFunc m_close_comm_fn; // Function object to close the communitation with ID card reader.
AuthenticateFunc m_auth_fn; // Function object to authentication of the ID card reader.
ReadContentFunc m_read_content_fn; // Function object to read the content from the ID card reader.
ReadContentFieldFunc m_get_name_fn;
ReadContentFieldFunc m_get_gender_fn;
ReadContentFieldFunc m_get_nation_fn;
ReadContentFieldFunc m_get_birthday_fn;
ReadContentFieldFunc m_get_addr_fn;
ReadContentFieldFunc m_get_id_code_fn;
ReadContentFieldFunc m_get_dept_fn;
ReadContentFieldFunc m_get_start_date_fn;
ReadContentFieldFunc m_get_end_data_fn;
int m_iPort;
static const std::string ID_CARD_READER_HARDWARE_INFO; // Currently this field is not used.
};
#endif // ETRADECLIENT_HARDWARE_ID_CARD_READER_H_INCLUDED