using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using XHandler.View;
|
using XCore;
|
using XImagingXhandler.XDAL;
|
using DriverLib;
|
using DriverLib.Engine;
|
using System.Xml;
|
using System.Windows.Threading;
|
using DriverLibrary;
|
using System.Windows;
|
using XCommon.Log;
|
using System.Reflection;
|
using XHandler.View.MethodProperty;
|
using static HxEnum.OperationTypeEnum;
|
|
namespace XHandler.Controls
|
{
|
public class HomeControl
|
{
|
string strCurrentCulture = "";
|
LatticeBll latticeBll = new LatticeBll();
|
HomeBll homeBll = new HomeBll();
|
public RunWnd launchView = null;
|
|
public HomeControl(string strCurrentCulture)
|
{
|
this.strCurrentCulture= strCurrentCulture;
|
}
|
|
#region 复位
|
/// <summary>
|
/// 复位
|
/// </summary>
|
/// <param name="labwareNode">装载吸头的板位节点对象</param>
|
/// <param name="methodNode">装载方法属性节点对象</param>
|
/// <param name="channelNums">已选的通道数量</param>
|
/// <param name="isSimulator">0:连接谁;1:仿真</param>
|
/// <param name="dtsTips">本次使用前的吸头列表</param>
|
/// <param name="dteTips">使用过的吸头列表</param>
|
/// <returns></returns>
|
public bool ExecuteHome(XmlNode methodNode, float xAxisVal, float yAxisVal, float zAxisVal, bool isSimulator)
|
{
|
bool result = true;
|
if (launchView._cancelSource.IsCancellationRequested)
|
{
|
result = false;
|
return result;
|
}
|
if(strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】"+Properties.MachineRunResource.strStart.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】start:");
|
}
|
|
// 状态2 初始化 黄蓝绿交替闪
|
HxResult ret = CommonBll.StatusLamp(2, isSimulator);
|
|
HomeMParam homeMParam = new HomeMParam();
|
homeMParam.xAxisVal = xAxisVal;
|
homeMParam.yAxisVal = yAxisVal;
|
homeMParam.zAxisVal = zAxisVal;
|
|
launchView.SetWaitOne();//暂停
|
ret = homeBll.ExecuteHome(homeMParam, isSimulator);
|
|
if (ret.Result != ResultType.Success)
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】"+ Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strHomeFail.ToString() + ret.AlarmInfo);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress: home is fail! error information:" + ret.AlarmInfo);
|
}
|
|
OperateDialog plsConfirmOper = null;
|
if (!launchView.isRemotingOper)
|
{
|
System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
|
{
|
plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.MachineRunResource.strGoHomeFailWhatToDo : "The action of go home was fail! What do you want to do?");
|
plsConfirmOper.ShowDialog();
|
}));
|
}
|
else
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1048", 5, Properties.MachineRunResource.strGoHomeFailWhatToDo, 2);
|
plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.MachineRunResource.strGoHomeFailWhatToDo : "The action of go home was fail! What do you want to do?");
|
plsConfirmOper.ShowDialog();
|
}
|
|
if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试
|
{
|
return ExecuteHome(methodNode, xAxisVal, yAxisVal, zAxisVal, isSimulator);
|
}
|
else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) // 终止
|
{
|
if (launchView.isRemotingOper)
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1049", 5, Properties.MachineRunResource.strHomeFailWasStoped, 2);
|
}
|
result = false;
|
return result;
|
}
|
else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过
|
{
|
result = true;
|
return result;
|
}
|
}
|
else
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strHomeSuccess.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress:home is success!");
|
}
|
}
|
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strEnd.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress: complete;");
|
}
|
return result;
|
}
|
#endregion
|
}
|
}
|