#ifndef _USBINTERFACE_H_ #define _USBINTERFACE_H_ #include #include #include class USBInterface { /* 定义函数指针 */ /* 设置产品编号,OSCA02是6 */ using SpecifyDevIdx = void(*)(int idx); /* 打开设备,调用前需要先设置产品编号 */ using DeviceOpen = unsigned long(*)(); /* 打开指定ID的设备 */ using DeviceOpenWithID = unsigned long(*)(int ID); /* 关闭设备 */ using DeviceClose = unsigned long(*)(); /* 开始采集数据,传入0x33开始采集 */ using USBCtrlTransSimple = unsigned long(*)(int32_t Request); /* 示波器控制 */ using USBCtrlTrans = unsigned char(*)(unsigned char Request, unsigned short Value, unsigned long outBufSize); /* 读取数据 */ using BufferWR = unsigned char*(*)(int index); /* 设置缓冲区大小 */ using SetInfo = void(*)(double dataNumPerPixar, double CurrentFreq, unsigned char ChannelMask, int ZrroUniInt, unsigned int bufferoffset, unsigned int HWbufferSize); /* 不知道清空什么 */ using ClearBuffer = unsigned long(*)(unsigned char objA , unsigned char objB, unsigned int Num); /* 清空缓冲区遗留的数据 */ using ResetPipe = void(*)(); /* 将数据从示波器的SRAM拷贝到PC内存中 */ using AiReadBulkData = void(*)(unsigned int SampleCount, unsigned int EventNum, unsigned int TimeOut, unsigned char* Buffer, unsigned char Flag, unsigned int First_PacketNum); /* 阻塞等待数据拷贝完成 */ using EventCheck = unsigned long(*)(long Timeout); public: USBInterface(); /* 加载动态库 */ bool loadLib(const QString& libName); /* 指定设备编号 */ void specifyDevId(int idx); /* 打开设备 */ unsigned long devOpen(); /* 打开设备,这个函数用于多个示波器级联时使用的,替代devOpen函数 */ unsigned long devOpenWithID(int ID); /* 关闭设备 */ unsigned long devClose(); /* 开始采集数据命令 */ unsigned long usbCtrlTransSimple(int32_t Request); /* 示波器控制命令 */ unsigned char usbCtrlTrans(unsigned char Request, unsigned short Value); /* 获取缓冲区指针 */ unsigned char* bufferWR(int index); /* 设置缓冲区的大小 */ void setInfo( unsigned int HWbufferSize); /* 目前不知道清空什么 */ unsigned long clearBuffer(unsigned char objA , unsigned char objB, unsigned int Num); /* 清空缓冲区遗留的数据 */ void resetPipe(); /* 将数据从示波器的SRAM拷贝到内存中 */ void readBulkData(unsigned int SampleCount, unsigned int EventNum, unsigned int TimeOut, unsigned char* Buffer); /* 阻塞等待数据拷贝完成 */ unsigned long eventCheck(long Timeout); private: QLibrary m_lib; SpecifyDevIdx m_specifyDevID = nullptr; DeviceOpen m_devOpen = nullptr; DeviceOpenWithID m_devOpenWithID = nullptr; DeviceClose m_devClose = nullptr; USBCtrlTransSimple m_usbCtrlTransSimple = nullptr; USBCtrlTrans m_usbCtrlTrans = nullptr; BufferWR m_bufferWR = nullptr; SetInfo m_setInfo = nullptr; ClearBuffer m_clearBuffer = nullptr; ResetPipe m_resetPipe = nullptr; AiReadBulkData m_aiReadBulkData = nullptr; EventCheck m_eventCheck = nullptr; }; #endif /* USBINTERFACE_H_ */