You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
74 lines
1.6 KiB
C++
74 lines
1.6 KiB
C++
#pragma once
|
|
#include <memory>
|
|
#include <string>
|
|
|
|
#include "Utility.h"
|
|
|
|
#ifdef BUILD_COMMDLL
|
|
#define COMMDLL_DLLCLASS __declspec(dllexport)
|
|
#else
|
|
#define COMMDLL_DLLCLASS __declspec(dllimport)
|
|
#endif
|
|
|
|
class CScanner;
|
|
typedef std::shared_ptr<CScanner> CommPtr;
|
|
|
|
class IRfId
|
|
{
|
|
public:
|
|
virtual ~IRfId()
|
|
{
|
|
}
|
|
|
|
virtual bool WriteID(const std::string &strID) = 0;
|
|
virtual bool ReadID(std::string *pResult) = 0;
|
|
virtual bool TestComm() = 0;
|
|
virtual std::string GetErrorMessage() const = 0;
|
|
};
|
|
|
|
class COMMDLL_DLLCLASS RfIdBase : public IRfId
|
|
{
|
|
private:
|
|
CIniFile m_hardwareIni;
|
|
CommPtr m_pCommPort;
|
|
public:
|
|
// ctor
|
|
explicit RfIdBase(int index);
|
|
virtual ~RfIdBase();
|
|
|
|
// methods
|
|
long GetBaudRate();
|
|
long GetByteSize();
|
|
double GetStopBits();
|
|
std::string GetParity();
|
|
std::string GetCommPort();
|
|
int GetHead();
|
|
int GetUnit();
|
|
bool Connect();
|
|
bool Disconnect();
|
|
bool IsConnected();
|
|
bool Send(const std::string &data);
|
|
virtual void OnReceiveComm(const char *cpcBuffer, int nSize) = 0;
|
|
};
|
|
|
|
#pragma warning( push )
|
|
#pragma warning( disable : 4251 )
|
|
class COMMDLL_DLLCLASS RfId
|
|
{
|
|
private:
|
|
std::unique_ptr<IRfId> m_base;
|
|
|
|
public:
|
|
// ctor
|
|
explicit RfId(int index);
|
|
virtual ~RfId(void);
|
|
|
|
// methods
|
|
bool WriteID(const std::string &strID);
|
|
bool ReadID(std::string *pResult);
|
|
bool TestComm();
|
|
std::string GetErrorMessage() const;
|
|
};
|
|
#pragma warning( pop)
|
|
|