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.
mitlib.pub/MITLIB/commdll/RfId.h

66 lines
1.6 KiB
C++

#ifndef _RFID_H_
#define _RFID_H_
#pragma once
#include <memory>
#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 CString &strID) = 0;
virtual bool ReadID(CString *pResult) = 0;
virtual bool TestComm() = 0;
virtual CString GetErrorMessage() const = 0;
};
class COMMDLL_DLLCLASS RfIdBase : public IRfId
{
private:
CIniFile m_hardwareIni;
CommPtr m_pCommPort;
public:
explicit RfIdBase(int index);
virtual ~RfIdBase();
long GetBaudRate();
long GetByteSize();
double GetStopBits();
CString GetParity();
CString GetCommPort();
int GetHead();
int GetUnit();
bool Connect();
bool Disconnect();
bool IsConnected();
bool Send(const CString &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:
explicit RfId(int index);
virtual ~RfId(void);
bool WriteID(const CString &strID);
bool ReadID(CString *pResult);
bool TestComm();
CString GetErrorMessage() const;
};
#pragma warning( pop)
#endif // _RFID_H_