ST_MSTMsg.cs 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  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()
  86. {
  87. }
  88. public ST_MSTMsg(CMsrThreadStatus measurestatus)
  89. {
  90. m_msrStatus = measurestatus;
  91. }
  92. public ST_MSTMsg(COTSSample sample)
  93. {
  94. m_sample = sample;
  95. m_sampleStatus = sample.GetMsrStatus();
  96. }
  97. public ST_MSTMsg(COTSSample sample,COTSField curfld)
  98. {
  99. m_sample = sample;
  100. m_sampleStatus = sample.GetMsrStatus();
  101. m_curFld = curfld;
  102. }
  103. internal void InitThreadOverMsg()
  104. {
  105. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  106. STMThreadStu.iMsrStatu = m_msrStatus.GetStatus();
  107. DateTime timeEnd = m_msrStatus.GetEndTime();
  108. STMThreadStu.csMsrEndTime = timeEnd.ToString("yyyy-MM-dd HH:mm:ss");
  109. }
  110. public void InitThreadStartMsg()
  111. {
  112. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  113. DateTime timeStart = m_msrStatus.GetStartTime();
  114. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.INPROCESS;
  115. STMThreadStu.csMsrStartTime = timeStart.ToShortDateString();
  116. }
  117. internal void InitThreadPausedMsg()
  118. {
  119. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  120. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
  121. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.PAUSED;
  122. STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  123. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
  124. }
  125. internal void InitThreadStoppedMsg()
  126. {
  127. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  128. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.STOPPED;
  129. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
  130. STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  131. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.STOPPED;
  132. }
  133. internal void InitThreadFailedMsg()
  134. {
  135. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  136. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.FAILED;
  137. }
  138. internal void InitThreadSucceedMsg()
  139. {
  140. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  141. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
  142. }
  143. internal void InitSampleStartMsg()
  144. {
  145. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  146. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.INPROCESS;
  147. this.STMSampleStu.cSampleName = m_sample.GetName();
  148. }
  149. internal void InitSamplePausedMsg()
  150. {
  151. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  152. //this.STMThreadStu.iMsrStatu = m_sample.GetMsrStatus().GetStatus();
  153. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.PAUSED;
  154. this.STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  155. }
  156. internal void InitSampleCompleteMsg()
  157. {
  158. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  159. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
  160. this.STMSampleStu.cSampleName = m_sample.GetName(); ;
  161. }
  162. internal void InitFieldStartMsg()
  163. {
  164. var poiFieldCentre = m_curFld.GetOTSPosition();
  165. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  166. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
  167. this.STMSampleRetData.SMsrField.FieldPos = new Point((int)poiFieldCentre.X, (int)poiFieldCentre.Y);
  168. }
  169. internal void InitFieldBSEImageMsg()
  170. {
  171. var poiFieldCentre = m_curFld.GetOTSPosition();
  172. var pBSEImg = m_curFld.GetBSEImage();
  173. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  174. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  175. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  176. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  177. this.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
  178. this.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
  179. byte[] pImgData = pBSEImg.GetImageDataPtr();
  180. this.STMSampleRetData.BSEData.lpBSEData = pImgData;
  181. }
  182. internal void InitFieldBSEAnalysisPartsDataMsg()
  183. {
  184. var poiFieldCentre = m_curFld.GetOTSPosition();
  185. var pImg = m_curFld.GetAnalysisParticleBlackColoredImage();
  186. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  187. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
  188. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  189. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  190. this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
  191. this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
  192. //byte[] pImgData = pBSEImg.GetImageDataPtr();
  193. this.STMSampleRetData.BSEData.coloredImg = pImg;
  194. }
  195. internal void InitFieldSTDColoredPartsDataMsg()
  196. {
  197. var poiFieldCentre = m_curFld.GetOTSPosition();
  198. var pImg = m_curFld.GetAnalysisParticleSTDColoredImage();
  199. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  200. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
  201. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  202. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  203. this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
  204. this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
  205. //byte[] pImgData = pBSEImg.GetImageDataPtr();
  206. this.STMSampleRetData.BSEData.coloredImg = pImg;
  207. }
  208. internal void InitFieldDataMsg()
  209. {
  210. var pStatus = m_sample.GetMsrStatus();
  211. iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  212. STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
  213. STMSampleRetData.SFieldData.iCompleteFieldCount = pStatus.GetCompletedFields();
  214. STMSampleRetData.SFieldData.iMeasureFieldCount = m_sample.GetFieldsData().Count;
  215. STMSampleRetData.SFieldData.iSParticleCount = (int)m_curFld.GetListAnalysisParticles().Count;
  216. STMSampleRetData.SFieldData.FieldPos.X = Convert.ToInt32(m_curFld.GetOTSPosition().X);
  217. STMSampleRetData.SFieldData.FieldPos.Y = Convert.ToInt32(m_curFld.GetOTSPosition().Y);
  218. }
  219. internal void InitHolePreThreadInProcessMsg()
  220. {
  221. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  222. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.INPROCESS;
  223. }
  224. internal void InitHolePreThreadStoppedMsg()
  225. {
  226. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  227. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
  228. }
  229. internal void InitHolePreThreadFailedMsg()
  230. {
  231. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  232. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.FAILED;
  233. }
  234. internal void InitHolePreThreadSucceedMsg()
  235. {
  236. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  237. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.SUCCESSED;
  238. }
  239. internal void InitHolePreBSEDataMsg(CBSEImgClr pBSEIamge,Point poiFieldCenter)
  240. {
  241. var poiFieldCentre = poiFieldCenter;
  242. var pBSEImg = pBSEIamge;
  243. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  244. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  245. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  246. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  247. this.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
  248. this.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
  249. byte[] pImgData = pBSEImg.GetImageDataPtr();
  250. this.STMSampleRetData.BSEData.lpBSEData = pImgData;
  251. }
  252. internal void InitHolePreSampleEndMsg()
  253. {
  254. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  255. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.COMPLETED;
  256. }
  257. }
  258. }