PlatformInteraction.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. #pragma once
  2. //平台层的交互接口
  3. #include <string>
  4. #include <Windows.h>
  5. using namespace std;
  6. #ifdef _WIN64
  7. #ifdef _DEBUG
  8. #define CDPC_DLL_NANE "ContainerDPCX64D.dll"
  9. #else
  10. #define CDPC_DLL_NANE "ContainerDPCX64.dll"
  11. #endif
  12. #else
  13. #ifdef _DEBUG
  14. #define CDPC_DLL_NANE "ContainerDPCD.dll"
  15. #else
  16. #define CDPC_DLL_NANE "ContainerDPC.dll"
  17. #endif
  18. #endif
  19. //typedef _declspec(dllimport) CDInterface* (_cdecl* GetCDInterface)();
  20. typedef _declspec(dllimport) void (*DeviceLogFunc) (int LogLevel, string Context, string DevicePath);
  21. typedef _declspec(dllimport) void (*DIOSSystemLogFunc) (int cmd, string Code, string Context, string DevicePath);
  22. typedef _declspec(dllimport) void (*DIOSNotifyCallBackEntryFunc)(int cmdType, string keyType, string Context, string DevicePath);
  23. typedef _declspec(dllimport) void (*RawDataNotifyCallBackEntryFunc)(int cmdType, string keyType, string Context, string Head, char* pRawData, int DataLength, string DevicePath);
  24. typedef _declspec(dllimport) void (*NotifyCallBackSetBlockSizeFunc)(string QueName, unsigned int BlockSize, unsigned int FulBlockCount, unsigned int PrevBlockSize, unsigned int PrevBlockCount);
  25. class PlatformInterface {
  26. PlatformInterface() {
  27. };
  28. static HMODULE CheckAndLoad()
  29. {
  30. static HMODULE __hModule = NULL;
  31. if(__hModule == 0)
  32. __hModule = LoadLibrary(CDPC_DLL_NANE);
  33. if (__hModule == NULL)
  34. return NULL;
  35. return __hModule;
  36. //GetCDInterface func = 0;
  37. //func = (GetCDInterface)GetProcAddress(hCDI, "GetCDI");
  38. }
  39. public:
  40. virtual ~PlatformInterface() {};
  41. static void DeviceLog(int LogLevel, string Context, string DevicePath)
  42. {
  43. static DeviceLogFunc func = 0;
  44. if (func == 0)
  45. func = (DeviceLogFunc)GetProcAddress(CheckAndLoad(), "DeviceLog");
  46. if (func != 0)
  47. func(LogLevel, Context, DevicePath);
  48. }
  49. static void DIOSSystemLog(int cmd, string Code, string Context, string DevicePath)
  50. {
  51. static DIOSSystemLogFunc func = 0;
  52. if (func == 0)
  53. func = (DIOSSystemLogFunc)GetProcAddress(CheckAndLoad(), "DIOSSystemLog");
  54. if (func != 0)
  55. func(cmd, Code, Context, DevicePath);
  56. }
  57. static void DIOSNotifyCallBackEntry(int cmdType, string keyType, string Context, string DevicePath)
  58. {
  59. static DIOSNotifyCallBackEntryFunc func = 0;
  60. if (func == 0)
  61. func = (DIOSNotifyCallBackEntryFunc)GetProcAddress(CheckAndLoad(), "DIOSNotifyCallBackEntry");
  62. if (func != 0)
  63. func(cmdType, keyType, Context, DevicePath);
  64. }
  65. static void RawDataNotifyCallBackEntry(int cmdType, string keyType, string Context, string Head, char* pRawData, int DataLength, string DevicePath)
  66. {
  67. static RawDataNotifyCallBackEntryFunc func = 0;
  68. if (func == 0)
  69. func = (RawDataNotifyCallBackEntryFunc)GetProcAddress(CheckAndLoad(), "RawDataNotifyCallBackEntry");
  70. if (func != 0)
  71. func(cmdType, keyType, Context, Head, pRawData, DataLength, DevicePath);
  72. }
  73. static void NotifyCallBackSetBlockSize(string QueName, unsigned int BlockSize, unsigned int FulBlockCount, unsigned int PrevBlockSize, unsigned int PrevBlockCount)
  74. {
  75. static NotifyCallBackSetBlockSizeFunc func = 0;
  76. if (func == 0)
  77. func = (NotifyCallBackSetBlockSizeFunc)GetProcAddress(CheckAndLoad(), "NotifyCallBackSetBlockSize");
  78. if (func != 0)
  79. func(QueName, BlockSize, FulBlockCount, PrevBlockSize, PrevBlockCount);
  80. }
  81. /// <summary>
  82. ///
  83. /// </summary>
  84. /// <param name="pImageData"></param>
  85. /// <param name="nWidth"></param>
  86. /// <param name="nHeight"></param>
  87. /// <param name="nFrameNum"></param>
  88. /// <param name="nDepth"></param>
  89. /// <param name="pPraamData"></param>
  90. /// <param name="ParamLen"></param>
  91. /// <param name="pOutput"></param>
  92. /// <param name="nOutputLen"></param>
  93. /// <param name="szParamDesc"></param>
  94. /// <param name="nPramNum"></param>
  95. /// <param name="szOutPutDesc"></param>
  96. /// <param name="nOutPutParamNum"></param>
  97. /// <returns> </returns>
  98. /// <summary>
  99. /// 算法描述,必须声明输出参数的最大长度,由调用者预先分配
  100. /// </summary>
  101. /// <param name="pImageData">图像数据,BYTE指针,可以自行转成WORD/DOWRD指针</param>
  102. /// <param name="nWidth">图像宽度</param>
  103. /// <param name="nHeigh">图像高度</param>
  104. /// <param name="nDepth">图像像素深度bit</param>
  105. /// <param name="nFrameNum">图像帧数</param>
  106. /// <param name="pPraamData">附加参数结构指针</param>
  107. /// <param name="ParamLen">附加参数结构长度</param>
  108. /// <param name="pOutput">输出参数结构指针</param>
  109. /// <param name="nOutputLen">输出参数结构长度</param>
  110. /// <param name="szParamDesc">输入参数描述</param>
  111. /// <param name="nPramNum">输入参数数量</param>
  112. /// <param name="szOutPutDesc">输出参数描述</param>
  113. /// <param name="nOutPutParamNum">输出参数数量</param>
  114. /// <returns>>=0成功,<0 错误码, >0和小于0 的解释由算法定义</returns>
  115. static int ImageProcess(BYTE* pImageData, int nWidth, int nHeigh, int nDepth, int nFrameNum,
  116. void* pPraamData, int ParamLen, void* pOutput, int nOutputLen,
  117. char szParamDesc[][16], int nPramNum, char szOutPutDesc[][16], int nOutPutParamNum)
  118. {
  119. }
  120. };