#ifndef _JY_H #define _JY_H #include "CAN.h" //定义CAN接口卡信息的数据类型。 typedef struct _VCI_BOARD_INFO_JY{ USHORT hw_Version; USHORT fw_Version; USHORT dr_Version; USHORT in_Version; USHORT irq_Num; BYTE can_Num; CHAR str_Serial_Num[8]; CHAR str_hw_Type[16]; char str_GYUsb_Serial[4][4]; } VCI_BOARD_INFO_JY,*PVCI_BOARD_INFO_JY; //共63个字节 //定义CAN信息帧的数据类型。 typedef struct _VCI_CAN_OBJ_JY{ BYTE ID[4]; UINT TimeStamp; BYTE TimeFlag; BYTE SendType;//保留不用 yyd BYTE RemoteFlag;//是否是远程帧 BYTE ExternFlag;//是否是扩展帧 BYTE DataLen; BYTE Data[8]; BYTE Reserved[3]; }VCI_CAN_OBJ_JY,*PVCI_CAN_OBJ_JY; //定义初始化CAN的数据类型 typedef struct _VCI_INIT_CONFIG_JY{ DWORD AccCode; DWORD AccMask; DWORD Reserved; UCHAR Filter; UCHAR kCanBaud; UCHAR Timing0; UCHAR Timing1; UCHAR Mode; UCHAR CanRx_IER;//added by yyd }VCI_INIT_CONFIG_JY,*PVCI_INIT_CONFIG_JY; class CJYWrapper : public CDLLModule { public: DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_OpenDevice, (DWORD DeviceType,DWORD DeviceInd,DWORD Reserved)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_CloseDevice, (DWORD DeviceType,DWORD DeviceInd)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_InitCAN, (DWORD DeviceType, DWORD DeviceInd, DWORD CANInd, PVCI_INIT_CONFIG_JY pInitConfig)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_StartCAN, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_ResetCAN, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_ReadErrInfo, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,PVCI_ERR_INFO pErrInfo)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_ReadCANStatus, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,PVCI_CAN_STATUS pCANStatus)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_WriteBoardInfo, (DWORD DeviceType,DWORD DeviceInd,PVCI_BOARD_INFO_JY pInfo)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_ReadBoardInfo, (DWORD DeviceType,DWORD DeviceInd,PVCI_BOARD_INFO_JY pInfo)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_GetReference, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,DWORD RefType,PVOID pData)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_SetReference, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,DWORD RefType,PVOID pData)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_GetReceiveNum, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_ClearBuffer, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_Transmit, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,PVCI_CAN_OBJ_JY pSend)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_Receive, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd,PVCI_CAN_OBJ_JY pReceive)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_ResumeConfig, (DWORD DeviceType,DWORD DeviceInd,DWORD CANInd)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_FindGyUsbDevice, (PVCI_BOARD_INFO_JY pInfo)) DECLARE_DLL_FUNCTION_3(DWORD, WINAPI, VCI_UsbDeviceReset, (DWORD DeviceType,DWORD DeviceInd,DWORD Reserved)) BEGIN_DLL_INIT() INIT_DLL_FUNCTION_3(VCI_OpenDevice) INIT_DLL_FUNCTION_3(VCI_CloseDevice) INIT_DLL_FUNCTION_3(VCI_InitCAN) INIT_DLL_FUNCTION_3(VCI_StartCAN) INIT_DLL_FUNCTION_3(VCI_ResetCAN) INIT_DLL_FUNCTION_3(VCI_ReadErrInfo) INIT_DLL_FUNCTION_3(VCI_ReadCANStatus) INIT_DLL_FUNCTION_3(VCI_WriteBoardInfo) INIT_DLL_FUNCTION_3(VCI_ReadBoardInfo) INIT_DLL_FUNCTION_3(VCI_GetReference) INIT_DLL_FUNCTION_3(VCI_SetReference) INIT_DLL_FUNCTION_3(VCI_GetReference) INIT_DLL_FUNCTION_3(VCI_ClearBuffer) INIT_DLL_FUNCTION_3(VCI_Transmit) INIT_DLL_FUNCTION_3(VCI_Receive) INIT_DLL_FUNCTION_3(VCI_ResumeConfig) INIT_DLL_FUNCTION_3(VCI_FindGyUsbDevice) INIT_DLL_FUNCTION_3(VCI_UsbDeviceReset) END_DLL_INIT() bool Init(LPCTSTR szPath, UINT nCnt, ...){return false;}// 具体化 }; class CJY : public CCAN { public: CJY(); virtual ~CJY(); BOOL OpenDevice(DWORD devInd); void CloseDevice(DWORD devInd); BOOL InitCAN(DWORD devInd, DWORD CANInd, PVCI_INIT_CONFIG pInitConfig); BOOL StartCAN(DWORD devInd, DWORD CANInd); BOOL ResetCAN(DWORD devInd, DWORD CANInd); void ReadErrInfo(DWORD devInd, DWORD CANInd, PVCI_ERR_INFO pErrInfo); BOOL ReadCANStatus(DWORD devInd, DWORD CANInd, PVCI_CAN_STATUS pCANStatus); BOOL WriteBoardInfo(DWORD devInd, DWORD CANInd, PVCI_BOARD_INFO_JY pInfo); BOOL ReadBoardInfo(DWORD devInd, DWORD CANInd, PVCI_BOARD_INFO_JY pInfo); BOOL GetReference(DWORD devInd, DWORD CANInd, DWORD RefType, PVOID pData); BOOL SetReference(DWORD devInd, DWORD CANInd, DWORD RefType, PVOID pData); BOOL ClearBuffer(DWORD devInd, DWORD CANInd); ULONG GetReceiveNum(DWORD devInd, DWORD CANInd); ULONG Transmit(DWORD devInd, DWORD CANInd, PVCI_CAN_OBJ pSend,ULONG Len); ULONG Receive(DWORD devInd, DWORD CANInd, PVCI_CAN_OBJ pReceive,ULONG Len, INT WaitTime=-1); void ResumeConfig(DWORD devInd, DWORD CANInd); DWORD FindGyUsbDevice(PVCI_BOARD_INFO_JY pInfo); DWORD UsbDeviceReset(DWORD DeviceType,DWORD DeviceInd,DWORD Reserved); BOOL LoadDLL(); protected: VCI_INIT_CONFIG_JY init_config; DWORD m_dwDevType; // 设备类型 DWORD m_dwDevInd; // 设备索引 DWORD m_dwCANInd; // CAN通道索引 CJYWrapper m_wrapper; }; #endif