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.

63 lines
1.5 KiB
C

/******************************************************************************
Copyright(C):2015~2018 hzleaper
FileName:$FILE_BASE$.$FILE_EXT$
Author:zhikun wu
Email:zk.wu@hzleaper.com
Tools:vs2010 pc on company
Created:$DATE$
History:$DAY$:$MONTH$:$YEAR$ $HOUR$:$MINUTE$
*******************************************************************************/
#include "zdefines.h"
#include <QtCore\qlibrary.h>
enum tpemIoType {
TP_IO_ADLINK = 1,
};
class IIoInterface
{
public:
IIoInterface() {}
virtual ~IIoInterface() {}
virtual int IIint() = 0;
virtual int IFree() = 0;
virtual int IReadI(qint32& state) = 0;
virtual int IReadO(qint32& state) = 0;
virtual int IWriteO(qint32& state) = 0;
};
#define TP_IOCTRL_DLL "tpIoCtrl"
class QLoadIoCtrl : public QLibrary
{
public:
typedef IIoInterface*(*func_io_create)(int);
typedef void(*func_io_delete)(IIoInterface*);
QLoadIoCtrl(const QString& path)
#ifdef _DEBUG
: QLibrary(path + TP_IOCTRL_DLL + "d")
#else
: QLibrary(path + TP_IOCTRL_DLL)
#endif
{
_ioCreate = (func_io_create)resolve("tp_io_create");
_ioDelete = (func_io_delete)resolve("tp_io_delete");
}
~QLoadIoCtrl(){}
IIoInterface* Create(int type) {
if (NULL == _ioCreate) {
return NULL;
}
return _ioCreate(type);
}
void Delete(IIoInterface* pio) {
if (NULL != _ioDelete) {
_ioDelete(pio);
}
}
private:
func_io_create _ioCreate;
func_io_delete _ioDelete;
};