hardware_cmd.h 2.33 KB
#ifndef ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED
#define ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED

#include <string>

#include <boost/property_tree/ptree.hpp>

class HardwareCmd
{
	// Return a boost ptree node as a reply data, we don't return reply as "std::string" type because
	// it will cause some trouble when construct a result JSON string if the data is alreay a JSON string.
	// It will add redundant back slash character ("\") in the JSON string.
	typedef boost::property_tree::ptree ReplyData;
public:
	struct Reply
	{
		ReplyData data;
		std::string error_code;
	};

	//卡片安全等级
	enum SecurityLevel
	{
		SL_0 = 0, // 0表示最低级,不替换秘钥,不写入业务信息,不做安全认证
		SL_1, // 等级1需要替换秘钥,写入业务信息,不做安全认证
		SL_2  // 等级2需要替换秘钥,写入业务信息,需要安全认证
	};

	//秘钥加密方式
	enum EncryptType
	{
		ET_PWM = 0, //加密机方式加密
		ET_DES = 1	//des算法加密
	};

	virtual ~HardwareCmd() {}

	/*Exception will be thrown if any error happens.*/
	virtual Reply Execute(const std::string& input) = 0;
};

class ReadPINPadCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

class ReadIDCardCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

class ActivateDILICardCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

class ResetDILICardCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

class ReadDILICardBasicInfoCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

class ReadDILICardServiceInfoCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

class WriteDILICardServiceInfoCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

class ReadBankCardNumCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};

//中央结算特殊需求,一个接口先刷园区卡再刷银行卡
class ReadDILIAndBankCardNumCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};
//

//解密扫码枪数据
class DecodeScannerCmd : public HardwareCmd
{
public:
	virtual Reply Execute(const std::string& input) override;
};
#endif // ETRADECLIENT_HARDWARE_HARDWARE_CMD_H_INCLUDED