|
@@ -26,7 +26,7 @@ namespace OTSPartA_STDEditor
|
|
|
//数据库操作对象
|
|
|
public SqlLiteClass m_sc = null;
|
|
|
// 电镜设置对象
|
|
|
- COTSControlFunExport m_cfun = null;
|
|
|
+ EDSController m_EDSHardwareMgr = null;
|
|
|
//Xray图谱用户控件
|
|
|
UXrayControl XrayControl = null;
|
|
|
//全局Xray 用于存储当前选择行的Xray信息
|
|
@@ -483,7 +483,7 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
|
|
|
|
|
|
- #region 采集Xray 按钮事件
|
|
|
+ //采集Xray 按钮事件
|
|
|
private void btnCollectXray_Click(object sender, EventArgs e)
|
|
|
{
|
|
|
m_SubMidWindow.m_MainForm.IsModified = true;
|
|
@@ -508,6 +508,7 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
//显示Xray
|
|
|
xrayByteData = IntArrToByteArr(GetCollectXray(strTime));
|
|
|
+ m_EDSHardwareMgr.DisConnect();
|
|
|
int color = Convert.ToInt32(ParseRGB(colorHx16toRGB(m_SubMidWindow.m_MainForm.STDDictionary[STDId].Color)).ToString());
|
|
|
//根据树节点修改对应的Xray信息
|
|
|
UpdateSTDXray(STDId, xrayByteData);
|
|
@@ -519,39 +520,25 @@ namespace OTSPartA_STDEditor
|
|
|
/// <returns></returns>
|
|
|
protected uint[] GetCollectXray(string strTime)
|
|
|
{
|
|
|
- try
|
|
|
+ //控制类对象初始化
|
|
|
+ if (null == m_EDSHardwareMgr)
|
|
|
{
|
|
|
- if (null == m_cfun)
|
|
|
- {
|
|
|
- m_cfun = COTSControlFunExport.GetControllerInstance();
|
|
|
- }
|
|
|
- if (ConnectionSem(connectionEnumType.EDSOnlyPointXRay))
|
|
|
- {
|
|
|
- if (EDSInit())
|
|
|
- {
|
|
|
- int iSize = 2000;
|
|
|
- uint[] iXrayData = new uint[iSize];
|
|
|
- //采集XRay数据
|
|
|
- if (m_cfun.CollectSpectrum(uint.Parse(strTime), ref iXrayData))
|
|
|
- {
|
|
|
- return iXrayData;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return null;
|
|
|
+ m_EDSHardwareMgr = EDSController.GetEDSController();
|
|
|
}
|
|
|
- catch /*(Exception ex)*/
|
|
|
+
|
|
|
+ //1.连接电镜
|
|
|
+ if (m_EDSHardwareMgr.Connect())
|
|
|
{
|
|
|
- return null;
|
|
|
+ int iSize = 2000;
|
|
|
+ uint[] iXrayData = new uint[iSize];
|
|
|
+ //采集XRay数据
|
|
|
+ if (m_EDSHardwareMgr.CollectSpectrum(uint.Parse(strTime), ref iXrayData))
|
|
|
+ {
|
|
|
+ return iXrayData;
|
|
|
+ }
|
|
|
}
|
|
|
- finally
|
|
|
- {
|
|
|
- //EDS过程结束
|
|
|
- //m_cfun.EDSFinishedInstance();
|
|
|
|
|
|
- //关闭连接
|
|
|
- DisConnectSem(connectionEnumType.EDSOnlyPointXRay);
|
|
|
- }
|
|
|
+ return null;
|
|
|
}
|
|
|
private void btnReadXray_Click(object sender, EventArgs e)
|
|
|
{
|
|
@@ -691,93 +678,7 @@ namespace OTSPartA_STDEditor
|
|
|
}
|
|
|
#endregion
|
|
|
|
|
|
- #region 连接与关闭设备
|
|
|
- public bool ConnectionSem(connectionEnumType connectionType)
|
|
|
- {
|
|
|
- //获取连接电镜类型
|
|
|
- string connTypeStr = GetConnectionType(connectionType);
|
|
|
- //连接电镜标识
|
|
|
- bool bDisConnResult = false;
|
|
|
- //判断连接状态
|
|
|
- if (!m_bConnectionState)
|
|
|
- {
|
|
|
- //连接电镜设置
|
|
|
- bDisConnResult = m_cfun.ConncetSem();
|
|
|
- }
|
|
|
- if (bDisConnResult)
|
|
|
- {
|
|
|
- m_bConnectionState = true;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_bConnectionState = false;
|
|
|
- }
|
|
|
- return bDisConnResult;
|
|
|
- }
|
|
|
-
|
|
|
- public bool DisConnectSem(connectionEnumType disConnectType)
|
|
|
- {
|
|
|
- //获取关闭电镜类型
|
|
|
- string connTypeStr = GetConnectionType(disConnectType);
|
|
|
- bool bDisConnResult = false;
|
|
|
- if (m_bConnectionState)
|
|
|
- {
|
|
|
- bDisConnResult = m_cfun.DisconnectSem();
|
|
|
- }
|
|
|
- if (bDisConnResult)
|
|
|
- {
|
|
|
- m_bConnectionState = false;
|
|
|
- }
|
|
|
- else
|
|
|
- {
|
|
|
- m_bConnectionState = true;
|
|
|
- }
|
|
|
- return bDisConnResult;
|
|
|
- }
|
|
|
-
|
|
|
- private string GetConnectionType(connectionEnumType connectionType)
|
|
|
- {
|
|
|
- string connString = string.Empty;
|
|
|
- switch (connectionType)
|
|
|
- {
|
|
|
- //设置单点采集文字内容
|
|
|
- case connectionEnumType.EDSOnlyPointXRay:
|
|
|
- connString = "OnlyPointXRay";
|
|
|
- break;
|
|
|
- //设置多点采集文字内容
|
|
|
- case connectionEnumType.EDSMultiPointXRay:
|
|
|
- connString = "MultiPointXRay";
|
|
|
- break;
|
|
|
- //设置面采集文字内容
|
|
|
- case connectionEnumType.EDSAreaXRay:
|
|
|
- connString = "AreaXRay";
|
|
|
- break;
|
|
|
- //设置图片
|
|
|
- case connectionEnumType.ScanImage:
|
|
|
- connString = "Image";
|
|
|
- break;
|
|
|
- default: break;
|
|
|
- }
|
|
|
- return connString;
|
|
|
- }
|
|
|
-
|
|
|
- /// <summary>
|
|
|
- /// EDS初始化
|
|
|
- /// </summary>
|
|
|
- public bool EDSInit()
|
|
|
- {
|
|
|
- bool bResult = false;
|
|
|
- //线程调用 加载
|
|
|
- bResult = m_cfun.EDSInit();
|
|
|
- return bResult;
|
|
|
- }
|
|
|
- public enum connectionEnumType
|
|
|
- {
|
|
|
- EDSOnlyPointXRay = 0,
|
|
|
- EDSMultiPointXRay = 1,
|
|
|
- EDSAreaXRay = 2,
|
|
|
- ScanImage = 3
|
|
|
- }
|
|
|
+ #region Xray 与 STDDB数据操作
|
|
|
/// <summary>
|
|
|
/// 标准Xray状态
|
|
|
/// </summary>
|
|
@@ -787,7 +688,6 @@ namespace OTSPartA_STDEditor
|
|
|
Modify = 1,
|
|
|
Delete = 2
|
|
|
}
|
|
|
- #endregion
|
|
|
|
|
|
/// <summary>
|
|
|
/// 记录修改后的标准中的Xray信息
|
|
@@ -811,9 +711,7 @@ namespace OTSPartA_STDEditor
|
|
|
public byte[] XrayData { get => xrayData; set => xrayData = value; }
|
|
|
public int InfoState { get => infoState; set => infoState = value; }
|
|
|
}
|
|
|
- #endregion
|
|
|
|
|
|
- #region Xray 与 STDDB数据操作
|
|
|
/// <summary>
|
|
|
/// 绑定数据库中已存在的Xray信息
|
|
|
/// </summary>
|