using DataRWDAL;
|
using HxSocket;
|
using System;
|
using System.Collections.ObjectModel;
|
using System.Linq;
|
using System.Xml;
|
using XCommon.Log;
|
using XCore;
|
using XHandler.Controls.Run.Com;
|
using XHandler.View;
|
using XImagingXhandler.XDAL;
|
|
namespace XHandler.Controls
|
{
|
public class GripTransportControl
|
{
|
#region 变量
|
private string strCurrentCulture = string.Empty;
|
private WellCalc wellCalc = new WellCalc();
|
|
#region BLL
|
private LatticeBll latticeBll = new LatticeBll();
|
private AspirateBll aspirateBll = new AspirateBll();
|
private GripTransportBll gripTransportBll = new GripTransportBll();
|
#endregion
|
|
#region 转运参数
|
private string strMethodName = string.Empty;
|
#endregion
|
|
public RunWnd launchView = null;
|
public HxSocketClient socketTcpListener = null;
|
#endregion
|
|
/// <summary>
|
/// 构造函数
|
/// </summary>
|
public GripTransportControl(string strCurrentCulture)
|
{
|
this.strCurrentCulture = strCurrentCulture;
|
}
|
|
#region 执行抓板放板,返回结果字符串
|
/// <summary>
|
/// 执行抓板放板
|
/// </summary>
|
/// <param name="xmlEnv"></param>
|
/// <param name="methodNode"></param>
|
/// <param name="isSimulator"></param>
|
/// <returns></returns>
|
public bool ExecuteGripTransport(XmlNode xmlEnv, XmlNode methodNode, bool isSimulator)
|
{
|
bool result = true;
|
string methodName = methodNode.SelectSingleNode("name").InnerText;
|
|
if (launchView._cancelSource.IsCancellationRequested)
|
{
|
result = false;
|
return result;
|
}
|
|
try
|
{
|
#region StartLog
|
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
|
|
#region 数据准备
|
MethodGripTransport gripTransportData = gripTransportBll.GenerateMethodGripTransport(methodNode);
|
#endregion
|
|
// From点位耗材信息
|
Labware labwareFrom = LabwareDB.GetLabware(gripTransportData.gripPickLabwareValue);
|
// To点位耗材信息
|
Labware labwareTo = null;
|
ObservableCollection<Labware> piledFromLabwares = LabwareDB.GetPiledlabwareOfALabware(labwareFrom); // 被叠放的盖子
|
|
// 放空板位
|
if ("-1".Equals(gripTransportData.gripPlaceLabwareValue))
|
{
|
labwareTo = labwareFrom;
|
|
// 被抓的耗材位置是顶部,且有盖子:=> labwareTo = 盖子
|
if (piledFromLabwares.Count() > 0 && gripTransportData.gripModelPosValue == 2&& labwareFrom.labware_type_id!="4")
|
{
|
labwareTo = LabwareDB.GetLabware(piledFromLabwares[0].labware_id);
|
}
|
}
|
else
|
{
|
labwareTo = LabwareDB.GetLabware(gripTransportData.gripPlaceLabwareValue);
|
}
|
|
if (labwareFrom == null || labwareTo == null)
|
{
|
return result;
|
}
|
|
|
// 抓板
|
result = ControlCom.ExecuteGripTransportPick(xmlEnv, gripTransportData, labwareFrom, piledFromLabwares, methodName, launchView, isSimulator);
|
if (result)
|
{
|
// 放板
|
result = ControlCom.ExecuteGripTransportPlace(xmlEnv,gripTransportData, labwareFrom, labwareTo, piledFromLabwares, methodName, launchView, isSimulator);
|
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;");
|
}
|
if (result != false)
|
{
|
launchView.GenerateAnimation(xmlEnv, gripTransportData);
|
}
|
}
|
|
|
}
|
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
|
}
|
}
|