using XHandler.View.Liquids;
|
using DataEntity;
|
using DriverLibrary;
|
using HxEnum;
|
using XHandler.Class.DataEx;
|
using XCoreBLL;
|
using XHandler.View;
|
using DriverLib.Engine;
|
using System.Xml;
|
using System;
|
using XCommon.Log;
|
using XImagingXhandler.XDAL;
|
|
namespace XHandler.Controls.Run
|
{
|
public class TimerControl
|
{
|
string strCurrentCulture = "";
|
public RunWnd launchView = null;
|
WaitForBll waitForBll = new WaitForBll();
|
TimerBll timerBll = new TimerBll();
|
public TimerControl(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 ExecuteTimer(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 strIndex = methodNode.SelectSingleNode("strIndex").InnerText;//定时器节点Id
|
double duringTime = Convert.ToDouble(methodNode.SelectSingleNode("duringTime").InnerText);
|
MethodTimer methodTimer = timerBll.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
|
|
if (launchView != null)
|
{
|
launchView.methodTimers.Add(methodTimer);
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + methodTimer.duringTime+" s" );
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + methodTimer.duringTime + " s");
|
}
|
}
|
}
|
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
|
}
|
}
|