XraySubSystem.h 8.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296
  1. #pragma once
  2. // 下列 ifdef 块是创建使从 DLL 导出更简单的
  3. // 宏的标准方法。此 DLL 中的所有文件都是用命令行上定义的 XRAYSUBSYSTEM_EXPORTS
  4. // 符号编译的。在使用此 DLL 的
  5. // 任何其他项目上不应定义此符号。这样,源文件中包含此文件的任何其他项目都会将
  6. // XRAYSUBSYSTEM_API 函数视为是从 DLL 导入的,而此 DLL 则将用此宏定义的
  7. // 符号视为是被导出的。
  8. #ifndef XRAYSUBSYSTEM_EXPORTS
  9. #ifdef _WIN64
  10. #ifdef _DEBUG
  11. #pragma comment(lib, "XraySubSystemX64D.lib")
  12. #else
  13. #pragma comment(lib, "XraySubSystemX64.lib")
  14. #endif
  15. #else
  16. #ifdef _DEBUG
  17. #pragma comment(lib, "XraySubSystemD.lib")
  18. #else
  19. #pragma comment(lib, "XraySubSystem.lib")
  20. #endif
  21. #endif
  22. #endif
  23. #ifdef XRAYSUBSYSTEM_EXPORTS
  24. #define XRAYSUBSYSTEM_API __declspec(dllexport)
  25. #define XRAYSUBSYSTEM_C_API extern "C" __declspec(dllexport)
  26. #else
  27. #define XRAYSUBSYSTEM_API __declspec(dllimport)
  28. #define XRAYSUBSYSTEM_C_API extern "C" __declspec(dllimport)
  29. #endif
  30. #include "DiosSMachine.h"
  31. #include "..\..\deliver\include\AsnycAction.h"
  32. #include <map>
  33. using namespace std;
  34. //事件--------------------------
  35. //这些事件的值保留为空
  36. #define DiosEvtSeqReady "ReadySeqEvt"
  37. #define DiosEvtSeqEnd "EndSeqEvt"
  38. #define DiosEvtSeqPost "SeqPostEvt"
  39. #define DiosEvtFramePrep "FramePrepEvt"
  40. #define DiosEvtFrameReady "FrameReadyEvt"
  41. //#define DiosEvtFrameProcess "FrameProcEvt"
  42. #define DiosEvtFrameEnd "FrameEndEvt"
  43. #define DiosEvtSeqExit "ExitSeqEvt"
  44. //Recover相关
  45. #define DiosEvtSeqRecover "SeqRecoverEvt"
  46. #define DiosEvtFrameRecover "FrameRecoverEvt"
  47. //错误事件定义在DiosSMachine.h中
  48. //{"Error":"Frame"} 或 {"Error":"Seq"}
  49. //状态点--------------------------
  50. #define DiosPosSeqPrep "SeqPrep"
  51. #define DiosPosSeqPost "SeqPost"
  52. #define DiosPosSeqEnd "SeqEnd"
  53. #define DiosPosSeqReady "SeqReady"
  54. #define DiosPosFramePrep "FramePrep"
  55. #define DiosPosFrameReady "FrameReady"
  56. #define DiosPosFramePost "FramePost"
  57. #define DiosPosFrameError "FrameError"
  58. #define DiosPosFrameRecover "FrameRecover"
  59. #define DiosPosSeqError "SeqError"
  60. #define DiosPosSeqRecover "SeqRecover"
  61. //子状态机状态点--------------------------
  62. #define DiosSubAcqStateMachine "FrameAcquiring"
  63. #define DiosPosFrameStart "FrameStart"
  64. #define DiosPosFrameAcq "FrameAcq"
  65. #define DiosPosFrameIn "FrameIn"
  66. #define DiosPosFrameOut "FrameOut"
  67. #define DiosPosFrameEnd "FrameEnd"
  68. class XRAYSUBSYSTEM_API XrayAcqSystem : public DiosSubSMachine
  69. {
  70. void InitXrayAcqSystem();
  71. public:
  72. XrayAcqSystem(void);
  73. XrayAcqSystem(const char *pName);
  74. virtual ~XrayAcqSystem();
  75. //Active得根据设备单元的属性,自行调整了
  76. //Actions----------------------------------------------------------------------
  77. //Entry&Exit Action
  78. virtual DIOSSTMRET StateMachineEntry(DWORD timeout);//Begin状态点
  79. virtual DIOSSTMRET StateMachineExit(DWORD timeout);//End状态点
  80. //RoutePos Action
  81. virtual DIOSSTMRET StateMachineAction(const char *pAction, DWORD timeout);
  82. virtual DIOSSTMRET StateMachineGuard(const char *pGuard, DWORD timeout);
  83. //Real Actions
  84. DIOSSTMRET FrameStart(DWORD timeout);
  85. DIOSSTMRET FrameAcq(DWORD timeout);
  86. DIOSSTMRET FrameIn(DWORD timeout);
  87. DIOSSTMRET FrameOut(DWORD timeout);
  88. DIOSSTMRET FrameEnd(DWORD timeout);
  89. //Events----------------------------------------------------------------------
  90. virtual int StateMachineWaitForEvents(
  91. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  92. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  93. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  94. DWORD timeout
  95. );
  96. int WaitFrom_FrameStart(
  97. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  98. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  99. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  100. DWORD timeout
  101. );
  102. int WaitFrom_FrameAcq(
  103. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  104. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  105. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  106. DWORD timeout
  107. );
  108. int WaitFrom_FrameIn(
  109. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  110. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  111. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  112. DWORD timeout
  113. );
  114. int WaitFrom_FrameOut(
  115. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  116. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  117. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  118. DWORD timeout
  119. );
  120. int WaitFrom_FrameEnd(
  121. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  122. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  123. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  124. DWORD timeout
  125. );
  126. };
  127. class XRAYSUBSYSTEM_API XraySubSystem : public DiosSMachine
  128. {
  129. HANDLE m_TransPosHandle;
  130. DiosSubSMachine *m_pAcqStateMachine;
  131. //map<string, vector<string>> m_mapStateList; //map<StateName,vector<Clientworkpath>>
  132. public:
  133. XraySubSystem(void);
  134. virtual ~XraySubSystem();
  135. virtual void StopStateMachine(DWORD timeout);
  136. HANDLE GetMachineNotifyHandle();
  137. //Actions----------------------------------------------------------------------
  138. //Entry&Exit Action
  139. virtual DIOSSTMRET StateMachineEntry(DWORD timeout);//Begin状态点
  140. virtual DIOSSTMRET StateMachineExit(DWORD timeout);//End状态点
  141. //RoutePos Action
  142. virtual DIOSSTMRET StateMachineAction(const char *pAction, DWORD timeout);
  143. virtual DIOSSTMRET StateMachineGuard(const char *pGuard, DWORD timeout);
  144. DIOSSTMRET AddtoStateList(const char *pClientAddress[],int count);
  145. DIOSSTMRET DeltoStateList();
  146. //Real Actions
  147. DIOSSTMRET SeqPrep(DWORD timeout);
  148. DIOSSTMRET SeqPost(DWORD timeout);
  149. DIOSSTMRET SeqReady(DWORD timeout);
  150. DIOSSTMRET SeqEnd(DWORD timeout);
  151. DIOSSTMRET FramePrep(DWORD timeout);
  152. DIOSSTMRET FrameReady(DWORD timeout);
  153. DIOSSTMRET FramePost(DWORD timeout);
  154. DIOSSTMRET FrameError(DWORD timeout);
  155. DIOSSTMRET FrameRecover(DWORD timeout);
  156. DIOSSTMRET SeqError(DWORD timeout);
  157. DIOSSTMRET SeqRecover(DWORD timeout);
  158. //Events----------------------------------------------------------------------
  159. virtual int StateMachineWaitForEvents(
  160. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  161. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  162. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  163. DWORD timeout
  164. );
  165. int WaitFrom_SeqPrep(
  166. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  167. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  168. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  169. DWORD timeout
  170. );
  171. int WaitFrom_SeqPost(
  172. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  173. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  174. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  175. DWORD timeout
  176. );
  177. int WaitFrom_SeqReady(
  178. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  179. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  180. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  181. DWORD timeout
  182. );
  183. int WaitFrom_SeqEnd(
  184. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  185. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  186. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  187. DWORD timeout
  188. );
  189. int WaitFrom_FramePrep(
  190. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  191. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  192. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  193. DWORD timeout
  194. );
  195. int WaitFrom_FrameReady(
  196. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  197. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  198. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  199. DWORD timeout
  200. );
  201. int WaitFrom_FrameAcquiring(
  202. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  203. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  204. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  205. DWORD timeout
  206. );
  207. int WaitFrom_FramePost(
  208. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  209. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  210. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  211. DWORD timeout
  212. );
  213. int WaitFrom_FrameError(
  214. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  215. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  216. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  217. DWORD timeout
  218. );
  219. int WaitFrom_FrameRecover(
  220. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  221. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  222. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  223. DWORD timeout
  224. );
  225. int WaitFrom_SeqError(
  226. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  227. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  228. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  229. DWORD timeout
  230. );
  231. int WaitFrom_SeqRecover(
  232. DiosStMRouteLine *pLocalEvts[], DWORD CountOfLocal,
  233. DiosStMRouteLine *pExternalEvts[], DWORD CountOfExternal,
  234. DiosStMRouteLine *pOutpathEvts[], DWORD CountOfOutpath,
  235. DWORD timeout
  236. );
  237. DWORD Lock(DWORD timeout = INFINITE);
  238. void UnLock();
  239. virtual RET_STATUS SetAction(const char *ActionName, ResDataObject &Req, ResDataObject &Resp);
  240. private:
  241. HANDLE m_hMutex;
  242. };