ST_MSTMsg.cs 10 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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 = OTS_MSR_THREAD_STATUS.FINISHED;
  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.MTHREADSTATUS;
  120. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.PAUSED;
  121. STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  122. }
  123. internal void InitThreadStoppedMsg()
  124. {
  125. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  126. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.STOPPED;
  127. STMThreadStu.csMsrEndTime = DateTime.Now.ToShortDateString();
  128. }
  129. internal void InitsampleFailedMsg()
  130. {
  131. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  132. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.FAILED;
  133. }
  134. internal void InitThreadFinishedMsg()
  135. {
  136. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  137. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.FINISHED;
  138. }
  139. internal void InitSampleStartMsg()
  140. {
  141. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  142. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.START;
  143. this.STMSampleStu.cSampleName = m_sample.GetName();
  144. }
  145. internal void InitSampleCompleteMsg()
  146. {
  147. this.iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  148. this.STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.COMPLETED;
  149. this.STMSampleStu.cSampleName = m_sample.GetName(); ;
  150. }
  151. internal void InitFieldStartMsg()
  152. {
  153. var poiFieldCentre = m_curFld.GetOTSPosition();
  154. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  155. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.START_MSR_FIELD;
  156. this.STMSampleRetData.SMsrField.FieldPos = new Point((int)poiFieldCentre.X, (int)poiFieldCentre.Y);
  157. }
  158. internal void InitFieldBSEImageMsg()
  159. {
  160. var poiFieldCentre = m_curFld.GetOTSPosition();
  161. var pBSEImg = m_curFld.GetBSEImage();
  162. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  163. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  164. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  165. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  166. this.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
  167. this.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
  168. byte[] pImgData = pBSEImg.GetImageDataPtr();
  169. this.STMSampleRetData.BSEData.lpBSEData = pImgData;
  170. }
  171. internal void InitFieldBSEAnalysisPartsDataMsg()
  172. {
  173. var poiFieldCentre = m_curFld.GetOTSPosition();
  174. var pImg = m_curFld.GetAnalysisParticleRandomColoredImage();
  175. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  176. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
  177. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  178. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  179. this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
  180. this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
  181. //byte[] pImgData = pBSEImg.GetImageDataPtr();
  182. this.STMSampleRetData.BSEData.coloredImg = pImg;
  183. }
  184. internal void InitFieldSTDColoredPartsDataMsg()
  185. {
  186. var poiFieldCentre = m_curFld.GetOTSPosition();
  187. var pImg = m_curFld.GetAnalysisParticleSTDColoredImage();
  188. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  189. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.REMOVEBG_DATA;
  190. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  191. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  192. this.STMSampleRetData.BSEData.iBSEDataHeight = pImg.Height;
  193. this.STMSampleRetData.BSEData.iBSEDataWidth = pImg.Width;
  194. //byte[] pImgData = pBSEImg.GetImageDataPtr();
  195. this.STMSampleRetData.BSEData.coloredImg = pImg;
  196. }
  197. internal void InitFieldDataMsg()
  198. {
  199. var pStatus = m_sample.GetMsrStatus();
  200. iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  201. STMSampleRetData.iRetDataType = MSAMPLE_RET.FIELD_DATA;
  202. STMSampleRetData.SFieldData.iCompleteFieldCount = pStatus.GetCompletedFields();
  203. STMSampleRetData.SFieldData.iMeasureFieldCount = m_sample.GetFieldsData().Count;
  204. STMSampleRetData.SFieldData.iSParticleCount = (int)m_curFld.GetListAnalysisParticles().Count;
  205. STMSampleRetData.SFieldData.FieldPos.X = Convert.ToInt32(m_curFld.GetOTSPosition().X);
  206. STMSampleRetData.SFieldData.FieldPos.Y = Convert.ToInt32(m_curFld.GetOTSPosition().Y);
  207. }
  208. internal void InitHolePreThreadInProcessMsg()
  209. {
  210. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  211. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.INPROCESS;
  212. }
  213. internal void InitHolePreThreadStoppedMsg()
  214. {
  215. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  216. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
  217. }
  218. internal void InitHolePreThreadFailedMsg()
  219. {
  220. iMsgType = ENUM_MSG_TYPE.MSAMPLESTATUS;
  221. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.FAILED;
  222. }
  223. internal void InitHolePreThreadSucceedMsg()
  224. {
  225. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  226. STMSampleStu.iMsrSampleStatu = OTS_MSR_SAMPLE_STATUS.STOPPED;
  227. }
  228. internal void InitHolePreBSEDataMsg(CBSEImgClr pBSEIamge,Point poiFieldCenter)
  229. {
  230. var poiFieldCentre = poiFieldCenter;
  231. var pBSEImg = pBSEIamge;
  232. this.iMsgType = ENUM_MSG_TYPE.MSAMPLERESULT;
  233. this.STMSampleRetData.iRetDataType = MSAMPLE_RET.BSE_DATA;
  234. this.STMSampleRetData.BSEData.pos.X = (int)poiFieldCentre.X;
  235. this.STMSampleRetData.BSEData.pos.Y = (int)poiFieldCentre.Y;
  236. this.STMSampleRetData.BSEData.iBSEDataHeight = pBSEImg.GetHeight();
  237. this.STMSampleRetData.BSEData.iBSEDataWidth = pBSEImg.GetWidth();
  238. byte[] pImgData = pBSEImg.GetImageDataPtr();
  239. this.STMSampleRetData.BSEData.lpBSEData = pImgData;
  240. }
  241. internal void InitHolePreSampleEndMsg()
  242. {
  243. iMsgType = ENUM_MSG_TYPE.MTHREADSTATUS;
  244. STMThreadStu.iMsrStatu = OTS_MSR_THREAD_STATUS.FINISHED;
  245. }
  246. }
  247. }