GenIMD_DPC.h 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193
  1. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  2. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 IMDDPC_EXPORTS
  3. // 符号编译的。在使用此 DLL 的
  4. // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  5. // IMDDPC_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  6. // 符号视为是被导出的。
  7. #pragma once
  8. #ifndef IMDDPC_EXPORTS
  9. #ifdef _WIN64
  10. #ifdef _DEBUG
  11. #pragma comment(lib, "SDCDoseDPCX64D.lib")
  12. #else
  13. #pragma comment(lib, "SDCDoseDPCX64.lib")
  14. #endif
  15. #else
  16. #ifdef _DEBUG
  17. #pragma comment(lib, "SDCDoseDPCD.lib")
  18. #else
  19. #pragma comment(lib, "SDCDoseDPC.lib")
  20. #endif
  21. #endif
  22. #endif
  23. #define PARAM_IN_TYPE
  24. #ifdef IMDDPC_EXPORTS
  25. #define GENDPC_API __declspec(dllexport)
  26. #else
  27. #define GENDPC_API __declspec(dllimport)
  28. #endif
  29. #include "LogicDriver.h"
  30. #include "SerialSCF.h"
  31. //#include "DoseOemDevice.h"
  32. #include "GenIMD_Dose.h"
  33. #include "common_api.h"
  34. //#include "SyncGenOEM.h"
  35. #include "GenIMD_Logical.h"
  36. #include "MACHINE_Logical.h"
  37. #include "diosthread.h"
  38. //#include "afxmt.h"
  39. //extern "C" GENDPC_API DPC* GetDPC();
  40. //extern "C" GENDPC_API void ReleaseDPC(DPC *p);
  41. extern "C" GENDPC_API DriverDPC* GetDriverDPC();
  42. extern "C" GENDPC_API void ReleaseDriverDPC(DriverDPC *p);
  43. // 此类是从 SDCDoseDPC.dll 导出的
  44. class GENDPC_API GenImd_DPC : public LogicDriver
  45. {
  46. std::string *m_pWorkpath;
  47. public:
  48. GenImd_DPC(void);
  49. virtual ~GenImd_DPC(void);
  50. //virtual bool DpcEntry(ResDataObject &Configuration);
  51. //virtual ResDataObject GetConnectionType();
  52. //virtual bool Connect(ResDataObject &Connection);
  53. //virtual bool Probe(ResDataObject &HardwareInfo);
  54. //virtual bool SetWorkPath(const char *pWorkPath);
  55. ////virtual LogicDevice* LoadLogicDevices();
  56. //virtual PVOID LoadLogicDevices();
  57. //virtual void UnloadLogicDevices(/*LogicDevice*/PVOID p);
  58. //virtual bool DisConnect();
  59. //virtual bool OnNotify(HANDLE ExitNotify);
  60. ///////////////////////////////////////////////////////
  61. virtual bool DriverEntry(ResDataObject &Configuration);
  62. virtual bool Driver_Probe(ResDataObject &HardwareInfo);
  63. virtual bool SYSTEM_CALL SetDriverWorkPath(const char * PARAM_IN pWorkPath);
  64. virtual PVOID SYSTEM_CALL LoadDriver();//无根节点
  65. virtual void SYSTEM_CALL UnloadDriver();
  66. //virtual bool OnNotify(HANDLE ExitNotify);
  67. virtual DWORD SYSTEM_CALL OnNotify(HANDLE evtList[], DWORD count);
  68. virtual bool Connect();
  69. virtual void DisConnect();
  70. //给硬件驱动设置Unique工作路径
  71. //如果是同一设备同一连接情况下,硬件多次接入,系统会保证工作路径是一样的.
  72. //连接后,单一硬件相关的数据要保存在此.
  73. virtual bool SYSTEM_CALL SetDeviceWorkPath(const char * PARAM_IN pWorkPath);
  74. RET_STATUS GetDeviceResource(ResDataObject *pDeviceResource);
  75. //逻辑设备树的加载和卸载
  76. virtual PVOID SYSTEM_CALL LoadLogicDevices();
  77. virtual void SYSTEM_CALL UnloadLogicDevices();
  78. virtual bool SYSTEM_CALL OnHeartBeat();
  79. virtual bool Device_Probe(ResDataObject &HardwareInfo);
  80. /////////////////////////////////
  81. int SendCommand(char* strCommand, int nTimeOut = TIMEOUTVALUE); //对指令名称进行打包封装
  82. int SendCommandWithoutAck(char* strCommand, int nTimeOut = TIMEOUTVALUE);
  83. //Device Function
  84. bool ProcessCommand(char* strCommand, int nType = 0);
  85. bool WaitforAK(DWORD nWaitingTime = 500);
  86. struct tagCommandStruct
  87. {
  88. string strCommand;
  89. //0, common commmand, not wait for ack command,
  90. //1 commmand, wait for vck command.,
  91. //2 APR command,
  92. //3, FO command
  93. int nCommmandType;
  94. };
  95. CRITICAL_SECTION g_cs;
  96. HANDLE m_hGenACKEvent;
  97. HANDLE m_hGenCPEvent;
  98. HANDLE m_hGenRX0Event;
  99. HANDLE m_hGenSAEvent;
  100. HANDLE m_hGenRX1Event;
  101. HANDLE m_hGenXR1Event;
  102. string m_strCurrentCommand;
  103. bool m_bReceiveRX1;
  104. bool m_bReceiveRX0;
  105. bool m_bReceiveXR1;
  106. bool m_bWaitforXR1;
  107. bool m_bWaitforRX1;
  108. bool m_bWaitforRX0;
  109. bool m_bSendXR1Failed;
  110. bool m_bInExposurePeriod;
  111. bool m_bIsNAK;
  112. bool m_bWaitAK;
  113. bool m_bStatusFlag;
  114. bool m_bResetting;
  115. bool m_bAPRProcessing;
  116. int m_nCurrentRsubmit;
  117. int m_nAKRsubmit;
  118. int m_nTotalRsubmit;
  119. int m_nTimeoutCounter;
  120. vector <tagCommandStruct> m_strCommondvector;
  121. tagCommandStruct m_IMDCommand;
  122. float m_fProjectionMaxAngle;
  123. void SendNotifytoSubsystem(ResDataObject &resParam);
  124. private:
  125. static PACKET_RET callbackPackageProcess(const char * RecData, DWORD nLength, DWORD& PacketLength);
  126. size_t OnCallback(const char * strPackage, size_t nLength);
  127. string LoadErrorContext(const char* strCode);
  128. ResDataObject m_DeviceConfig; //设备属性
  129. HMODULE m_SCFDllFileHandle;
  130. HMODULE m_LoggerDllFileHandle;
  131. GenIMD_Dose *m_pDoseOEM; //Dose OEM
  132. GenIMD_Logical *m_pSyncGenOEM; //SynGen
  133. CMACHINE_Logical *m_pMachineOEM;
  134. SCF* m_pSCFServer;
  135. typedef SCF* (*GetSCF)();
  136. GetSCF getSCF;
  137. typedef void(*ReleaseSCF)(SCF *p);
  138. ReleaseSCF releaseSCF;
  139. SCFPacket *m_pSendPacket;
  140. SCFPacket *m_pReceivePacket;
  141. DWORD m_wReceiveTime;
  142. };