|
|
@@ -1,209 +0,0 @@
|
|
|
-
|
|
|
-using OTSCLRINTERFACE;
|
|
|
-using OTSCommon.DBOperate.Model;
|
|
|
-
|
|
|
-using OTSIncAReportApp.SysMgrTools;
|
|
|
-using OTSModelSharp.ServiceCenter;
|
|
|
-using ServiceInterface;
|
|
|
-using System;
|
|
|
-using System.Collections;
|
|
|
-using System.Collections.Generic;
|
|
|
-using System.Drawing;
|
|
|
-using System.Linq;
|
|
|
-
|
|
|
-namespace OTSIncAReportGrids.OTSIncAReportGridsFuncation
|
|
|
-{
|
|
|
- public class OTSReportGridsFun
|
|
|
- {
|
|
|
- #region 定义变量
|
|
|
- //为了加快颗粒列表抠图的速度,这里保存一个全局变量
|
|
|
- public List<Field> m_list_COTSFieldMgrClr = null;
|
|
|
- //是否已经连接到了电镜
|
|
|
- public bool m_SEMConnectionState = false;
|
|
|
- //连接到电镜的ID号
|
|
|
- public int m_SEM_ID = 0;
|
|
|
- public HardwareController m_cfun = null;
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 构造函数
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 需传入,主窗体对象,与要获取数据窗体的对象
|
|
|
- /// </summary>
|
|
|
- /// <param name="in_frmReportApp"></param>
|
|
|
- /// <param name="form"></param>
|
|
|
- public OTSReportGridsFun()
|
|
|
- {
|
|
|
- m_cfun = HardwareController.GetSemController();// It's better to reinitialize, but it's not good to uninitialize
|
|
|
- }
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 自定义方法封装
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 传入颗粒的tagid和fieldid,来获取该颗粒下对应的xray数据
|
|
|
- /// </summary>
|
|
|
- /// <param name="in_clr_tagid"></param>
|
|
|
- /// <param name="in_clr_fieldid"></param>
|
|
|
- /// <param name="Search_xray"></param>
|
|
|
- /// <param name="Analysis_xray"></param>
|
|
|
- public void GetXrayByParticleTagIDAndFieldID_ForDrawDistrbutionImageAndBSE(int in_clr_tagid, int in_clr_fieldid, out uint[] Search_xray, out uint[] Analysis_xray, out int xray_id, out List<Element> list_celementchemistryclr)
|
|
|
- {
|
|
|
- Search_xray = new uint[2000];
|
|
|
- Analysis_xray = new uint[2000];
|
|
|
- xray_id = 0;
|
|
|
- list_celementchemistryclr = new List<Element>();
|
|
|
-
|
|
|
- //防止为空校验判断
|
|
|
- if (m_list_COTSFieldMgrClr == null)
|
|
|
- return;
|
|
|
- Particle particle = m_list_COTSFieldMgrClr.Find(x => x.FieldID == in_clr_fieldid).ParticleList.Find(x => x.ParticleId == in_clr_tagid);
|
|
|
- if (particle.XrayId > -1)
|
|
|
- {
|
|
|
- for (int i = 0; i < 2000; i++)
|
|
|
- {
|
|
|
- Analysis_xray[i] = BitConverter.ToUInt32(particle.XRayData, i * 4);
|
|
|
- }
|
|
|
-
|
|
|
- Search_xray = Analysis_xray;
|
|
|
- xray_id = particle.XrayId;
|
|
|
- list_celementchemistryclr = particle.ElementList;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 临时创建一个用于组建particle类的小segment类结构
|
|
|
- /// </summary>
|
|
|
- class ShowSegment
|
|
|
- {
|
|
|
- Rectangle m_rect = new Rectangle();
|
|
|
- List<Color> m_list_color = new List<Color>();
|
|
|
-
|
|
|
- public Rectangle Rect
|
|
|
- {
|
|
|
- get { return m_rect; }
|
|
|
- set { m_rect = value; }
|
|
|
- }
|
|
|
-
|
|
|
- public List<Color> List_Color
|
|
|
- {
|
|
|
- get { return m_list_color; }
|
|
|
- set { m_list_color = value; }
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 传入showsegment的list对象列表,返回从该对象列表计算出的外边rect矩形[目前宽度计算错误]
|
|
|
- /// </summary>
|
|
|
- /// <param name="in_list_showsegment"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public Rectangle GetRectByListRectangle(List<ShowSegment> in_list_showsegment)
|
|
|
- {
|
|
|
- int x = 10000, y = 10000;
|
|
|
- int width = 0, height = 0;
|
|
|
- for (int i = 0; i < in_list_showsegment.Count(); i++)
|
|
|
- {
|
|
|
- if (x > in_list_showsegment[i].Rect.X)
|
|
|
- x = in_list_showsegment[i].Rect.X;
|
|
|
- if (y > in_list_showsegment[i].Rect.Y)
|
|
|
- y = in_list_showsegment[i].Rect.Y;
|
|
|
- if (width < in_list_showsegment[i].Rect.X + in_list_showsegment[i].Rect.Width)
|
|
|
- width = in_list_showsegment[i].Rect.X + in_list_showsegment[i].Rect.Width;
|
|
|
- if (height < in_list_showsegment[i].Rect.Height)
|
|
|
- height = in_list_showsegment[i].Rect.Height;
|
|
|
- }
|
|
|
- width = width - x;//计算时已增加了x在里面,计算完成后,再将x的值去掉
|
|
|
-
|
|
|
- //height就是线的数量
|
|
|
- return new Rectangle(x, y, width + 3, in_list_showsegment.Count() + 3);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- #endregion
|
|
|
-
|
|
|
- #region 连接电镜相关
|
|
|
- /// <summary>
|
|
|
- /// 连接电镜,颗粒列表使用
|
|
|
- /// </summary>
|
|
|
- public bool Connection_ForParticlesGrid()
|
|
|
- {
|
|
|
- if (!m_SEMConnectionState)
|
|
|
- {
|
|
|
-
|
|
|
- m_SEMConnectionState = m_cfun.Connect();
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- return m_SEMConnectionState;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 移动电镜到指定的X,Y坐标上,R坐标使用原先的值进行移动
|
|
|
- /// </summary>
|
|
|
- /// <param name="PositionX"></param>
|
|
|
- /// <param name="PositionY"></param>
|
|
|
- public bool MoveSemToPointXY_ForParticlesGrid(double in_PositionX, double in_PositionY)
|
|
|
- {
|
|
|
- bool isSuccess = false;
|
|
|
- //首先获取电镜当前的位置,并记录原R值
|
|
|
- double ls_PositionX = 0;
|
|
|
- double ls_PositionY = 0;
|
|
|
- double ls_PositionR = 0;
|
|
|
-
|
|
|
- if (m_SEMConnectionState)
|
|
|
- {
|
|
|
- isSuccess = m_cfun.GetSemPositionXY(ref ls_PositionX, ref ls_PositionY, ref ls_PositionR);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- if (m_SEMConnectionState)
|
|
|
- {
|
|
|
- isSuccess = m_cfun.MoveSEMToPoint(new Point((int)in_PositionX, (int)in_PositionY), ls_PositionR);
|
|
|
- }
|
|
|
-
|
|
|
- return isSuccess;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// 设置放大倍数
|
|
|
- /// </summary>
|
|
|
- /// <param name="a_dMagnification"></param>
|
|
|
- /// <returns></returns>
|
|
|
- public bool SetMagnification(double a_dMagnification)
|
|
|
- {
|
|
|
- bool isSuccess = false;
|
|
|
- if (m_SEMConnectionState)
|
|
|
- {
|
|
|
- isSuccess = m_cfun.SetMagnification(a_dMagnification);
|
|
|
- }
|
|
|
-
|
|
|
- return isSuccess;
|
|
|
- }
|
|
|
-
|
|
|
- public bool AcquireBSEImage(string sampleName, int width, int height, DwellTimeLevel dwellTime, ref byte[] ImageByte)
|
|
|
- {
|
|
|
- bool isSuccess = false;
|
|
|
- if (m_SEMConnectionState)
|
|
|
- {
|
|
|
- isSuccess = m_cfun.AcquireBSEImage(sampleName, width, height, dwellTime, ref ImageByte);
|
|
|
- }
|
|
|
-
|
|
|
- return isSuccess;
|
|
|
- }
|
|
|
-
|
|
|
- public bool AcquisitionSpectrum(string samplePath, int xrayMode, double new_PixelSize, ref Particle particle, uint a_nXRayAQTime)
|
|
|
- {
|
|
|
- bool isSuccess = false;
|
|
|
- if (m_SEMConnectionState)
|
|
|
- {
|
|
|
- isSuccess = m_cfun.AcquisitionSpectrum(samplePath, xrayMode, new_PixelSize, ref particle, a_nXRayAQTime);
|
|
|
- }
|
|
|
-
|
|
|
- return isSuccess;
|
|
|
- }
|
|
|
-
|
|
|
- #endregion
|
|
|
- }
|
|
|
-}
|