ST_MSTMsg.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302
  1. using OTSCLRINTERFACE;
  2. using OTSDataType;
  3. using OTSModelSharp;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Drawing;
  7. using static OTSDataType.otsdataconst;
  8. namespace OTSMeasureApp._1_OTSMeasure.Measure._3_MeasureFlow
  9. {
  10. public enum ENUM_MSG_TYPE
  11. {
  12. MTHREADSTATUS = 1001,
  13. MSAMPLESTATUS = 1002,
  14. MSAMPLERESULT = 1003
  15. };
  16. public enum MSAMPLE_RET
  17. {
  18. BSE_DATA = 0,
  19. REMOVEBG_DATA=1,
  20. FIELD_DATA = 2,
  21. START_MSR_FIELD = 3
  22. };
  23. public struct SMSR_COMPLETE_DATA
  24. {
  25. public OTS_MSR_THREAD_STATUS MsrStatus;
  26. public string csMsrStartTime;
  27. public int iMsrCompleteSampleCount;
  28. public int iMsrCompleteFieldCount;
  29. public int iParticleCount;
  30. public TimeSpan MsrUsedTime;
  31. public string csMsrEndTime;
  32. };
  33. public struct STMThreadStatus
  34. {
  35. public OTS_MSR_THREAD_STATUS iMsrStatu; //OTS_MSR_THREAD_STATUS
  36. public string csMsrStartTime; //MSR_START_TIME
  37. public string csMsrEndTime; //MSR_END_TIME
  38. public SMSR_COMPLETE_DATA SMsrCompleteData;
  39. };
  40. public struct STMSampleStatus
  41. {
  42. public OTS_MSR_SAMPLE_STATUS iMsrSampleStatu; //OTS_MSR_SAMPLE_STATUS
  43. public string cSampleName;
  44. public string csSampleMsrStartTime;
  45. public List<PointF> BCompleteFieldList;
  46. };
  47. public struct STMSampleResultData
  48. {
  49. public MSAMPLE_RET iRetDataType; //ENUM_MEASURE_SAMPLE_RESULT
  50. public struct RBSEDATA
  51. {
  52. public int fieldId;
  53. public System.Drawing.Point pos;
  54. public int iBSEDataHeight;
  55. public int iBSEDataWidth;
  56. public byte[] lpBSEData;
  57. public Bitmap coloredImg;
  58. };
  59. public struct SAMPLEFIELDDATA
  60. {
  61. public System.Drawing.Point FieldPos;
  62. public int iMeasureFieldCount;
  63. public int iCompleteFieldCount;
  64. public int iSParticleCount; // Field particle count
  65. public TimeSpan TUsedTime;
  66. };
  67. public struct StartToMsrField
  68. {
  69. public System.Drawing.Point FieldPos;
  70. };
  71. public RBSEDATA BSEData;
  72. public SAMPLEFIELDDATA SFieldData;
  73. public StartToMsrField SMsrField;
  74. };
  75. public class ST_MSTMsg
  76. {
  77. private COTSSample m_sample;
  78. private CMsrThreadStatus m_msrStatus;
  79. private CMsrSampleStatus m_sampleStatus;
  80. private COTSField m_curFld;
  81. public ENUM_MSG_TYPE iMsgType;
  82. public STMThreadStatus STMThreadStu;
  83. public STMSampleStatus STMSampleStu;
  84. public STMSampleResultData STMSampleRetData;
  85. public ST_MSTMsg(CMsrThreadStatus measurestatus)
  86. {
  87. m_msrStatus = measurestatus;
  88. }
  89. public ST_MSTMsg(COTSSample sample)
  90. {
  91. m_sample = sample;
  92. m_sampleStatus = sample.GetMsrStatus();
  93. }
  94. public ST_MSTMsg(COTSSample sample,COTSField curfld)
  95. {
  96. m_sample = sample;
  97. m_sampleStatus = sample.GetMsrStatus();
  98. m_curFld = curfld;
  99. }
  100. internal void InitThreadOverMsg()
  101. {
  102. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  103. STMThreadStu.iMsrStatu = m_msrStatus.GetStatus();
  104. DateTime timeEnd = m_msrStatus.GetEndTime();
  105. STMThreadStu.csMsrEndTime = timeEnd.ToString("yyyy-MM-dd HH:mm:ss");
  106. }
  107. public void InitThreadStartMsg()
  108. {
  109. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  110. DateTime timeStart = m_msrStatus.GetStartTime();
  111. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.INPROCESS;
  112. STMThreadStu.csMsrStartTime = timeStart.ToShortDateString();
  113. }
  114. internal void InitThreadPausedMsg()
  115. {
  116. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  117. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
  118. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.PAUSED;
  119. STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  120. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
  121. }
  122. internal void InitThreadStoppedMsg()
  123. {
  124. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  125. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.STOPPED;
  126. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
  127. STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  128. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.STOPPED;
  129. }
  130. internal void InitThreadFailedMsg()
  131. {
  132. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  133. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.FAILED;
  134. }
  135. internal void InitThreadSucceedMsg()
  136. {
  137. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  138. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
  139. }
  140. internal void InitSampleStartMsg()
  141. {
  142. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  143. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.INPROCESS;
  144. this.STMSampleStu.cSampleName = m_sample.GetName();
  145. }
  146. internal void InitSamplePausedMsg()
  147. {
  148. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  149. //this.STMThreadStu.iMsrStatu = m_sample.GetMsrStatus().GetStatus();
  150. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.PAUSED;
  151. this.STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  152. }
  153. internal void InitSampleCompleteMsg()
  154. {
  155. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  156. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
  157. this.STMSampleStu.cSampleName = m_sample.GetName(); ;
  158. }
  159. internal void InitFieldStartMsg()
  160. {
  161. var poiFieldCentre = m_curFld.GetOTSPosition();
  162. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  163. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
  164. this.STMSampleRetData.SMsrField.FieldPos = new Point((int)poiFieldCentre.X, (int)poiFieldCentre.Y);
  165. }
  166. internal void InitFieldBSEImageMsg()
  167. {
  168. var poiFieldCentre = m_curFld.GetOTSPosition();
  169. var pBSEImg = m_curFld.GetBSEImage();
  170. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  171. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  172. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  173. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  174. this.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
  175. this.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
  176. byte[] pImgData = pBSEImg.GetImageDataPtr();
  177. this.STMSampleRetData.BSEData.lpBSEData = pImgData;
  178. }
  179. internal void InitFieldBSEAnalysisPartsDataMsg()
  180. {
  181. var poiFieldCentre = m_curFld.GetOTSPosition();
  182. var pImg = m_curFld.GetAnalysisParticleBlackColoredImage();
  183. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  184. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
  185. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  186. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  187. this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
  188. this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
  189. //byte[] pImgData = pBSEImg.GetImageDataPtr();
  190. this.STMSampleRetData.BSEData.coloredImg = pImg;
  191. }
  192. internal void InitFieldSTDColoredPartsDataMsg()
  193. {
  194. var poiFieldCentre = m_curFld.GetOTSPosition();
  195. var pImg = m_curFld.GetAnalysisParticleSTDColoredImage();
  196. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  197. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
  198. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  199. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  200. this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
  201. this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
  202. //byte[] pImgData = pBSEImg.GetImageDataPtr();
  203. this.STMSampleRetData.BSEData.coloredImg = pImg;
  204. }
  205. internal void InitFieldDataMsg()
  206. {
  207. var pStatus = m_sample.GetMsrStatus();
  208. iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  209. STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
  210. STMSampleRetData.SFieldData.iCompleteFieldCount = pStatus.GetCompletedFields();
  211. STMSampleRetData.SFieldData.iMeasureFieldCount = m_sample.GetFieldsData().Count;
  212. STMSampleRetData.SFieldData.iSParticleCount = (int)m_curFld.GetListAnalysisParticles().Count;
  213. STMSampleRetData.SFieldData.FieldPos.X = Convert.ToInt32(m_curFld.GetOTSPosition().X);
  214. STMSampleRetData.SFieldData.FieldPos.Y = Convert.ToInt32(m_curFld.GetOTSPosition().Y);
  215. }
  216. internal void InitHolePreThreadInProcessMsg()
  217. {
  218. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  219. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.INPROCESS;
  220. }
  221. internal void InitHolePreThreadStoppedMsg()
  222. {
  223. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  224. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
  225. }
  226. internal void InitHolePreThreadFailedMsg()
  227. {
  228. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  229. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.FAILED;
  230. }
  231. internal void InitHolePreThreadSucceedMsg()
  232. {
  233. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  234. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
  235. }
  236. internal void InitHolePreBSEDataMsg(CBSEImgClr pBSEIamge,Point poiFieldCenter)
  237. {
  238. var poiFieldCentre = poiFieldCenter;
  239. var pBSEImg = pBSEIamge;
  240. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  241. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  242. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  243. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  244. this.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
  245. this.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
  246. byte[] pImgData = pBSEImg.GetImageDataPtr();
  247. this.STMSampleRetData.BSEData.lpBSEData = pImgData;
  248. }
  249. internal void InitHolePreSampleEndMsg()
  250. {
  251. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  252. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.COMPLETED;
  253. }
  254. }
  255. }