123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360 |
- using System;
- using System.Collections.Generic;
- using OTSCLRINTERFACE;
- using System.Drawing;
- using OTSDataType;
- using OTSModelSharp;
- using OTSModelSharp.ServiceInterface;
- namespace OTSMeasureApp
- {
- public class SEMDATAFieldManage
- {
- #region 全部变量声明
- //连接状态
- public bool ConnectionState = false;
- // 判断是否是模拟状态 FASE: 不是在模拟环境下 True: 在模拟环境下
- public bool IsSimulationStatus = false;
- //获取当前电镜的ID号
- //int SemType = 0;
- //获取XML 路径
- static string xmlFilePath = System.Configuration.ConfigurationManager.ConnectionStrings["XMLFilePath"].ConnectionString;
- //日志路径
- static string LogPath = System.Configuration.ConfigurationManager.ConnectionStrings["LogPath"].ConnectionString;
- //电镜设置对象
- SemController cSemfun = null;
- ScanController cScanfun = null;
- EDSController cEDSfun = null;
- //主窗体对象
- COTSMeasureParam m_ProjData;
- //CFieldPositionMgr cFieldMgrClr;
- NLog.Logger log ;
- #endregion
- #region 构造方法
-
- public SEMDATAFieldManage(COTSMeasureParam a_DataMgr)
- {
- log = NLog.LogManager.GetCurrentClassLogger();
- //获取主窗体对象
- if (m_ProjData == null)
- {
- m_ProjData = a_DataMgr;
- }
- }
- /// <summary>
- /// 初始化其他参数
- /// </summary>
- public bool InitAndConnection()
- {
- try
- {
- //控制类对象初始化
- if (cSemfun == null)
- {
- cSemfun = SemController.GetSEMController();
- }
- if (cScanfun == null)
- {
- cScanfun = ScanController.GetScanController();
- }
- if (cEDSfun == null)
- {
- cEDSfun = EDSController.GetEDSController();
- }
-
- return cSemfun.Connect();
- }
- catch (Exception ex)
- {
- log.Error("SEMDATAFieldManage_InitAndConntion:--Error:" + ex.ToString() + "");
- return false;
- }
- }
- #endregion
-
- #region 获取放大倍数
- private double GetGMagnification()
- {
- try
- {
- double a_dMagnification = 0;
- //获取放大倍数
- bool result = cSemfun.GetMagnification(ref a_dMagnification);
- if (result)
- {
- //赋值 显示
- return a_dMagnification;
- }
- else
- {
- //配置结果提示
- return 0;
- }
- }
- catch (Exception)
- {
- return 0;
- }
- }
- #endregion
- #region 获取工作距离
- private double GetSemWorkingDistance()
- {
- try
- {
- double a_WorkingDistance = 0;
- //获取工作距离
- bool result = cSemfun.GetWorkingDistance(ref a_WorkingDistance);
- if (result)
- {
- //赋值 显示
- return a_WorkingDistance;
- }
- else
- {
- //配置结果提示
- return 0;
- }
- }
- catch (Exception ex)
- {
- log.Error("SEMDATAFieldManage_GetSemWorkingDistance--错误日志:" + ex.ToString() + "");
- return 0;
- }
- }
- #endregion
- #region 设置放大倍数
- private bool SetGMagnification(double a_dMagnification)
- {
- try
- {
- //获取放大倍数
- bool result = cSemfun.SetMagnification(a_dMagnification);
- return result;
- }
- catch (Exception ex)
- {
- log.Error("SEMDATAFieldManage_SetSemWorkingDistance--错误日志:" + ex.ToString() + "");
- return false;
- }
- }
- #endregion
- #region 设置工作距离
- private bool SetSemWorkingDistance(double a_WorkingDistance)
- {
- try
- {
- bool result = cSemfun.SetWorkingDistance(a_WorkingDistance);
- return result;
- }
- catch (Exception ex)
- {
- log.Error("SEMDATAFieldManage_SetSemWorkingDistance--错误日志:" + ex.ToString() + "");
- return false;
- }
- }
- #endregion
- #region 获取单点Xray与元素信息
- /// <summary>
- /// 获取单点Xray与元素信息
- /// </summary>
- /// <param name="a_Milliseconds">采集时间</param>
- /// <param name="a_BSEX">鼠标在BSE图中X轴</param>
- /// <param name="a_BSEY">鼠标在BSE图中Y轴</param>
- /// <param name="a_ElementXrayData">Xray数组</param>
- /// <param name="a_nElementNum">元素数量</param>
- /// <param name="a_strElementName">元素名称</param>
- /// <returns></returns>
- public bool GetXRayAndElementInfo(uint a_Milliseconds, int a_BSEX, int a_BSEY, ref int[] a_ElementXrayData, ref ValueType a_nElementNum, ref string a_strElementName)
- {
- //获取Xray与元素信息
- return false;// cfun.GetEDSControl().GetXRayByPoints(a_Milliseconds, a_BSEX, a_BSEY, ref a_ElementXrayData, ref a_nElementNum, ref a_strElementName);
- }
- #endregion
- #region 获取电镜参数 放大倍数与工作距离
- public List<double> GetSEMMagAndWDParameter()
- {
- List<double> semParameter = new List<double>();
- //放大倍数
- double magnification = GetGMagnification();
- //工作距离
- double semWorkingDistance = GetSemWorkingDistance();
- //添加 放大倍数、工作距离
- semParameter.Add(magnification);
- semParameter.Add(semWorkingDistance);
- return semParameter;
- }
- #endregion
- #region 设置电镜 放大倍数与工作距离
- /// <summary>
- /// 设置电镜 放大倍数
- /// </summary>
- /// <param name="a_dMagnification"></param>
- /// <param name="a_WorkingDistance"></param>
- /// <returns></returns>
- public bool SetSEMMagnificationParameter(double a_dMagnification)
- {
- return SetGMagnification(a_dMagnification);
- }
- /// <summary>
- /// 设置电镜 工作距离
- /// </summary>
- /// <param name="a_WorkingDistance"></param>
- /// <returns></returns>
- public bool SetSEMWorkingDistanceParameter(double a_WorkingDistance)
- {
- return SetSemWorkingDistance(a_WorkingDistance);
- }
- #endregion
- #region 驱动SEM到当前位置
- public bool SetSEMCurrentLocation( Point mousePoint, List<ARectangleGDIObject> m_RectangleGDIObjects, StageDrawingData oTSSampleStageData, int IsWidth, int Width, int Height)
- {
- try
- {
- ARectangleGDIObject RectangleGDIObject = null;
- //循环判断是否鼠标在样品范围中
- foreach (ARectangleGDIObject item in m_RectangleGDIObjects)
- {
- if (item.Region.Contains(mousePoint))
- {
- //获取在范围中的样品
- RectangleGDIObject = item;
- break;
- }
- }
- //判断是否鼠标在样品台范围中
- Point OTSLocation = new Point();
- if (RectangleGDIObject != null)
- {
- //鼠标在样品台中移动获取坐标
- OTSLocation = OTSSamplespaceGraphicsPanelFun.GetMouseLocationInRectangleGDIObject(mousePoint, m_RectangleGDIObjects[0], oTSSampleStageData, IsWidth, m_RectangleGDIObjects[0].Region.Width, m_RectangleGDIObjects[0].Region.Height);
- Point SEMPoint =m_ProjData.ChangeOTSToSemCoord(OTSLocation);
- //调用C++ controller中的方法
- //移动至当前位置
- bool result = cSemfun.MoveSEMToPoint(SEMPoint.X, SEMPoint.Y);
- if (result)
- {
- return result;
- }
- }
- return false;
- }
- catch (Exception)
- {
- return false;
- }
- }
- #endregion
- #region 驱动SEM到中心位置
- public bool DriveSEMToLocation(Point mousePoint, List<ARectangleGDIObject> m_RectangleGDIObjects, List<ARectangleGDIObject> m_SingleGDIObjects, StageDrawingData oTSSampleStageData, int IsWidth, int Width, int Height)
- {
- try
- {
- ARectangleGDIObject RectangleGDIObject = null;
- //循环判断是否鼠标在样品范围中
- foreach (ARectangleGDIObject item in m_RectangleGDIObjects)
- {
- if (item.Region.Contains(mousePoint))
- {
- //获取在范围中的样品台对象
- RectangleGDIObject = item;
- break;
- }
- }
- //判断是否鼠标在样品台范围中
- Point OTSLocation = new Point();
- if (RectangleGDIObject != null)
- {
- //鼠标在样品台中移动获取坐标
- OTSLocation = OTSSamplespaceGraphicsPanelFun.GetMouseLocationInRectangleGDIObject(mousePoint, RectangleGDIObject, oTSSampleStageData, IsWidth, RectangleGDIObject.Region.Width, RectangleGDIObject.Region.Height);
- Point SEMPoint = m_ProjData.ChangeOTSToSemCoord(OTSLocation);
- //循环single中所有对象 进行位置匹配
- for (int i = 0; i < m_SingleGDIObjects.Count; i++)
- {
- if (m_SingleGDIObjects[i].Region.Contains(mousePoint))
- {
- //获取帧图左上坐标
- Point LT = new Point((int)m_SingleGDIObjects[i].RegionF.Left, (int)m_SingleGDIObjects[i].RegionF.Top);
- Point lTLocation = OTSSamplespaceGraphicsPanelFun.GetMouseLocationInRectangleGDIObject(LT, RectangleGDIObject, oTSSampleStageData, IsWidth, RectangleGDIObject.Region.Width, RectangleGDIObject.Region.Height);
- lTLocation = m_ProjData.ChangeOTSToSemCoord(lTLocation);
- //获取帧图右下坐标
- Point RB = new Point((int)m_SingleGDIObjects[i].RegionF.Right, (int)m_SingleGDIObjects[i].RegionF.Bottom);
- Point rbLocation = OTSSamplespaceGraphicsPanelFun.GetMouseLocationInRectangleGDIObject(RB, RectangleGDIObject, oTSSampleStageData, IsWidth, RectangleGDIObject.Region.Width, RectangleGDIObject.Region.Height);
- rbLocation = m_ProjData.ChangeOTSToSemCoord(rbLocation);
- int diffX = Math.Abs(rbLocation.X - lTLocation.X) / 2;
- int diffY = Math.Abs(rbLocation.Y - lTLocation.Y) / 2;
- //移动至帧图中心位置
- int moveCenterX = lTLocation.X - diffX;
- int moveCenterY = lTLocation.Y + diffY;
- bool result = cSemfun.MoveSEMToPoint(moveCenterX, moveCenterY);
- if (result)
- {
- return result;
- }
- }
- }
- }
- return false;
- }
- catch (Exception)
- {
- return false;
- }
- }
- #endregion
- #region 获取SEM位置
- public bool GetSemLocation(ref List<double> SemLocation)
- {
- //获取SEM位置 a_dPositionX:X轴 a_dPositionY:Z轴 a_dPositionR:角度
- double a_dPositionX = 0;
- double a_dPositionY = 0;
- double a_dPositionR = 0;
- if (cSemfun != null)
- {
- if (cSemfun.GetSemPositionXY(ref a_dPositionX, ref a_dPositionY, ref a_dPositionR))
- {
- SemLocation.Add(a_dPositionX);
- SemLocation.Add(a_dPositionY);
- SemLocation.Add(a_dPositionR);
- return true;
- }
- }
- return false;
- }
- #endregion
- }
- }
|