using DataEntity.Share;
|
using DriverLib.Engine;
|
using System;
|
using System.Collections.Generic;
|
using System.Data;
|
using System.Linq;
|
using System.Reflection;
|
using System.Windows;
|
using System.Xml;
|
using XCommon;
|
using XCommon.Log;
|
using XCore;
|
using XHandler.Controls.Run.Com;
|
using XHandler.View;
|
using XHandler.View.MethodProperty;
|
using XImaging.Automation.Service.Interface;
|
using XImagingXhandler.XDAL;
|
using static HxEnum.OperationTypeEnum;
|
using DataRWDAL;
|
using NPOI.SS.Formula.Functions;
|
using XHandler.Class;
|
using DataRWDAL.Rack;
|
using System.Configuration;
|
using XHandler.Properties;
|
using XHandler.View.Liquids;
|
using DataEntity;
|
using DriverLibrary;
|
using HxEnum;
|
using XHandler.Class.DataEx;
|
using XCoreBLL;
|
|
namespace XHandler.Controls
|
{
|
public class WaitForControl
|
{
|
string strCurrentCulture = "";
|
public RunWnd launchView = null;
|
WaitForBll waitForBll = new WaitForBll();
|
TimerBll timerBll = new TimerBll();
|
public WaitForControl(string strCurrentCulture)
|
{
|
this.strCurrentCulture = strCurrentCulture;
|
}
|
|
#region 执行等待,返回结果字符串
|
/// <summary>
|
/// 执行等待,返回结果字符串
|
/// </summary>
|
/// <param name="xmlEnv">板位节点信息</param>
|
/// <param name="methodNode">装载方法属性节点对象</param>
|
/// <param name="xmlDocument">完整xml对象</param>
|
/// <param name="isSimulator">false:连接谁;true:仿真</param>
|
/// <returns></returns>
|
public bool ExecuteWaitFor(XmlNode xmlEnv, XmlNode methodNode,XmlDocument xmlDocument,bool isSimulator)
|
{
|
bool result = true;
|
if (launchView._cancelSource.IsCancellationRequested)
|
{
|
result = false;
|
return result;
|
}
|
|
string methodName = methodNode.SelectSingleNode("name").InnerText;
|
try
|
{
|
|
string duringTimeText = methodNode.SelectSingleNode("duringTimeText").InnerText;
|
string duringTimeTextStrIndex = methodNode.SelectSingleNode("duringTimeTextStrIndex").InnerText;
|
bool enableEndWaitfor = (methodNode.SelectSingleNode("enableEndWaitfor").InnerText.ToLower() == "true") ? true : false;
|
MethodWaitFor methodWaitFor = waitForBll.GenerateMethodTimer(methodNode);
|
|
#region Start Log
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strStart.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodName + "】start:");
|
}
|
#endregion
|
|
//数据准备
|
//查找关联的Timer节点
|
XmlNodeList methodListXML = xmlDocument.SelectNodes("root/method");
|
foreach(XmlNode xn in methodListXML)
|
{
|
if (xn.SelectSingleNode("strIndex").InnerText == duringTimeTextStrIndex)
|
{
|
XmlNode timerNodeXML = xn;
|
if (timerNodeXML != null)
|
{
|
MethodTimer methodTimer = timerBll.GenerateMethodTimer(timerNodeXML);
|
if (launchView != null)
|
{
|
HxResult ret = waitForBll.ExecutePause(1, isSimulator);
|
if (ret.Result != ResultType.Success)
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.PauseResource.strPauseError.ToString() + ret.AlarmInfo);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress:pause is failed! error information:" + ret.AlarmInfo);
|
}
|
|
result = false;
|
}
|
else
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.PauseResource.strPauseOk.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress:pause is successful!");
|
}
|
var currentMethodTimer = launchView.methodTimers.SingleOrDefault(x => x.strIndex.Equals(methodTimer.strIndex));
|
if (currentMethodTimer != null&&Convert.ToDouble(currentMethodTimer.duringTime)>0)
|
{
|
methodTimer.duringTime = currentMethodTimer.duringTime;
|
bool b = launchView.ShowDialogForWaitFor(methodTimer, methodWaitFor);
|
|
HxResult ret1 = waitForBll.ExecutePause(2, isSimulator);
|
if (ret1.Result != ResultType.Success)
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.PauseResource.strContinueError.ToString() + ret.AlarmInfo);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress:continue is failed! error information:" + ret1.AlarmInfo);
|
}
|
|
result = false;
|
}
|
else
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.PauseResource.strContinueOk.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress:continue is successful!");
|
}
|
}
|
}
|
else
|
{
|
|
}
|
}
|
}
|
}
|
break;
|
}
|
}
|
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strEnd.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress: complete;");
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strError.ToString() + " 源 " + ex.Source + " 错误信息 " + ex.Message + ";");
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】error:source:" + ex.Source + ";error:" + ex.Message + ";");
|
}
|
|
result = false;
|
}
|
return result;
|
}
|
#endregion
|
}
|
}
|