using DriverLib.Engine;
|
using System;
|
using System.Collections.Generic;
|
using System.Configuration;
|
using System.Data;
|
using System.Linq;
|
using System.Reflection;
|
using System.Runtime.Remoting.Channels;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Xml;
|
using XCore;
|
using XImagingXhandler.XDAL;
|
using XHandler.View.MethodProperty;
|
using XHandler.View;
|
using XHandler.Class.DataEx;
|
using HxSocket;
|
using DataEntity.Share;
|
using XCommon.Log;
|
using XHandler.Controls.Run.Com;
|
using static HxEnum.OperationTypeEnum;
|
using MySqlX.XDevAPI.Common;
|
using SqlSugar;
|
using XImaging.Automation.Service.Interface;
|
using DataRWDAL;
|
using DataEntity;
|
using System.Runtime.Remoting.Metadata.W3cXsd2001;
|
|
namespace XHandler.Controls
|
{
|
public class UnloadTipsControl
|
{
|
string strCurrentCulture = "";
|
WellCalc wellCalc = new WellCalc();
|
LatticeBll latticeBll = new LatticeBll();
|
UnloadTipsBll unloadTipsBll = new UnloadTipsBll();
|
public RunWnd launchView = null;
|
public HxSocketClient socketTcpClientToRemote = null;
|
|
public UnloadTipsControl(string strCurrentCulture)
|
{
|
this.strCurrentCulture = strCurrentCulture;
|
}
|
|
#region 执行卸载吸头,返回结果字符串
|
/// <summary>
|
/// 执行卸载吸头,返回结果字符串
|
/// </summary>
|
/// <param name="platformNodeList"></param>
|
/// <param name="methodNode">装载方法属性节点对象</param>
|
/// <param name="isSimulator">0:连接谁;1:仿真</param>
|
/// <returns></returns>
|
public bool ExecuteUnloadTips(XmlNodeList platformNodeList, XmlNode methodNode, bool isSimulator)
|
{
|
bool result = true;
|
|
if (launchView._cancelSource.IsCancellationRequested)
|
{
|
result = false;
|
return result;
|
}
|
|
try
|
{
|
#region Start Log
|
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:");
|
}
|
#endregion
|
|
#region 数据准备
|
string channelNums = methodNode.SelectSingleNode("channels").InnerText;
|
string armName = methodNode.SelectSingleNode("arm/text").InnerText;
|
string armId = methodNode.SelectSingleNode("arm/value").InnerText;
|
string latticeid = methodNode.SelectSingleNode("position/value").InnerText;
|
string latticenum = methodNode.SelectSingleNode("position/text").InnerText;
|
bool isputToSource = methodNode.SelectSingleNode("isputToSource").InnerText.ToLower() == "true" ? true : false;
|
#endregion
|
|
#region 数据验证
|
if (channelNums == "")
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler:【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strWithoutChannel.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler:Channel wasn't set, please check!");
|
}
|
if (launchView.isRemotingOper)
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1019", 5, Properties.MachineRunResource.strWithoutChannel, 2);
|
}
|
result = false;
|
return result;
|
}
|
#endregion
|
|
DataTable dt = null;
|
List<TipsTable> dtTipBase = new List<TipsTable>();
|
Lattice lattice = new Lattice();
|
TabletopTemplate tabletopTemplate = TabletopTemplateDB.GetCurrentAppTabletopTemplateCollectionFromdb(); //增加台面模板判断
|
if (tabletopTemplate == null)
|
{
|
lattice = LatticeDB.GetLatticeDataByIdFromdb(latticenum, Convert.ToInt32(armId), Shared.SoftwareInformation.software_device_number); // 卸载位
|
}
|
else
|
{
|
string armid = methodNode.SelectSingleNode("arm/value").InnerText;
|
lattice = LatticeDB.GetLatticeDataByLatticeNumAndTempIdFromdb(latticenum, Convert.ToInt32(armid), Shared.SoftwareInformation.software_device_number, tabletopTemplate.tabletopid);
|
}
|
//Lattice lattice = LatticeDB.GetLatticeDataByIdFromdb(latticenum, Convert.ToInt32(armId), Shared.SoftwareInformation.software_device_number); // 卸载位
|
if (isputToSource) // 原孔位放置
|
{
|
//查询板位上是否有空闲的耗材孔
|
foreach (XmlNode x in platformNodeList)
|
{
|
if (launchView.currentWellLatticeId != string.Empty)
|
{
|
string a = x.ChildNodes[0].InnerText;
|
|
|
int latticeId = 0;
|
if (tabletopTemplate == null)
|
{
|
a = ControlCom.GetLatticeId(Convert.ToInt32(a)).ToString();
|
}
|
else
|
{
|
string latticeNumber = "P" + a;
|
a = LatticeDB.GetLatticeDataByLatticeNumAndTempIdFromdb(latticeNumber, Convert.ToInt32(Shared.DeviceArmList.SingleOrDefault(t => t.arm_type.Equals(1)).device_arm_id), Shared.SoftwareInformation.software_device_number, tabletopTemplate.tabletopid).lattice_id;
|
}
|
|
if (a == launchView.currentWellLatticeId)
|
{
|
lattice = LatticeDB.GetLatticeDataByIdFromdb(launchView.currentWellLatticeId);
|
|
if (!string.IsNullOrEmpty(launchView.currentInValidWell))
|
{
|
XmlNodeList xmlNodeList = x.SelectNodes("labware");
|
Labware labware = LabwareDB.GetLabware(xmlNodeList[xmlNodeList.Count-1].ChildNodes[0].InnerText);
|
|
string t1 = launchView.currentInValidWell;
|
string p = lattice.lattice_id;
|
string[] tWells = t1.Split(',');
|
for (int i = 0; i < tWells.Length; i++)
|
{
|
TipsTable t = new TipsTable();
|
t.labware_id = labware.labware_id;
|
t.lattice_id = p;
|
t.wellname = tWells[i];
|
t.axis_b_X = 0.0f;
|
t.axis_b_Y = 0.0f;
|
t.axis_b_Z = 0.0f;
|
t.well_top_shape = 0;
|
t.axis_b_r = 0.0f;
|
t.isUsed = 0;
|
t.lattice_num = lattice.lattice_num;
|
dtTipBase.Add(t);
|
}
|
|
List<Lattice> lattices = new List<Lattice>();
|
lattices.Add(lattice);
|
dt = ControlCom.GenerateCurrentTablayoutWellCoordinate(labware, lattices);
|
}
|
else
|
{
|
result = false;
|
return result;
|
}
|
break;
|
}
|
else
|
{
|
continue;
|
}
|
}
|
}
|
|
List<TipsTable> dtsTips = new List<TipsTable>();
|
|
if(dt==null)
|
{
|
result = false;
|
return result;
|
}
|
// dt 转化为实体类对象集合
|
for (int i = 0; i < dt.Rows.Count; i++)
|
{
|
//去除未被选中的孔位(即非可用枪头孔位)
|
var a = dtTipBase.FirstOrDefault(x => x.labware_id.Equals(dt.Rows[i]["labware_id"].ToString()) &&
|
x.lattice_id.Equals(dt.Rows[i]["lattice_id"].ToString()) &&
|
x.lattice_num.Equals(dt.Rows[i]["lattice_num"].ToString()) &&
|
x.wellname.Equals(dt.Rows[i]["wellname"].ToString()));
|
if (a != null)
|
{
|
TipsTable tipsTable = new TipsTable();
|
tipsTable.labware_id = dt.Rows[i]["labware_id"].ToString();
|
tipsTable.lattice_id = dt.Rows[i]["lattice_id"].ToString();
|
tipsTable.wellname = dt.Rows[i]["wellname"].ToString();
|
tipsTable.axis_b_X = (float)Convert.ToDouble(dt.Rows[i]["axis_b_X"].ToString());
|
tipsTable.axis_b_Y = (float)Convert.ToDouble(dt.Rows[i]["axis_b_Y"].ToString());
|
tipsTable.axis_b_Z = (float)Convert.ToDouble(dt.Rows[i]["axis_b_Z"].ToString());
|
tipsTable.well_top_shape = Convert.ToInt32(dt.Rows[i]["well_top_shape"].ToString());
|
tipsTable.axis_b_r = (float)Convert.ToDouble(dt.Rows[i]["axis_b_r"].ToString());
|
tipsTable.isUsed = Convert.ToInt32(dt.Rows[i]["isUsed"].ToString());
|
tipsTable.lattice_num = dt.Rows[i]["lattice_num"].ToString();
|
dtsTips.Add(tipsTable);
|
}
|
}
|
|
// 通道号
|
string[] strCh = channelNums.Split(',');
|
UnloadTipsMParam unloadTipsMParam = new UnloadTipsMParam();
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
|
TipsTable tipsTableSource = dtsTips.FirstOrDefault(t => t.lattice_num.Equals(lattice.lattice_num));
|
|
string strWell = launchView.currentInValidWell;
|
unloadTipsMParam.xAxisVal = (float)tipsTableSource.axis_b_X;
|
unloadTipsMParam.yAxisVal = (float)tipsTableSource.axis_b_Y;
|
unloadTipsMParam.zAxisVal = (float)tipsTableSource.axis_b_Z - 10f;
|
unloadTipsMParam.armId = Convert.ToInt32(armId);
|
|
launchView.SetWaitOne(); // 暂停
|
HxResult ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, isSimulator);
|
|
#region 错误处理
|
result = DoError(platformNodeList, methodNode, isSimulator, ret, tipsTableSource, strWell, latticenum);
|
#endregion
|
}
|
else//选定垃圾桶板位退枪头
|
{
|
if (!string.IsNullOrEmpty(latticenum))
|
{
|
//判断是否是垃圾桶板位
|
if (lattice.is_trash == 1)
|
{
|
if (Shared.ChannelCount == 1)
|
{
|
UnloadTipsMParam unloadTipsMParam = new UnloadTipsMParam();
|
unloadTipsMParam.xAxisVal = (float)lattice.lattice_X+ (float)lattice.lattice_length/2f;
|
unloadTipsMParam.yAxisVal = (float)lattice.lattice_Y + (float)lattice.lattice_width / 2f;
|
unloadTipsMParam.zAxisVal = (float)lattice.lattice_Z - ControlCom.CurrentLengthOfTip - 50 - (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
|
unloadTipsMParam.armId = Convert.ToInt32(methodNode.SelectSingleNode("arm/value").InnerText);
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
|
launchView.SetWaitOne();//暂停
|
HxResult ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, isSimulator);
|
|
#region 错误处理
|
result = DoError(platformNodeList, methodNode, isSimulator, ret, null, string.Empty, latticenum);
|
#endregion
|
}
|
else if (Shared.ChannelCount > 1&&!Shared.ChannelCount.Equals(96))
|
{
|
UnloadTipsMParamSH unloadTipsMParam = new UnloadTipsMParamSH();
|
unloadTipsMParam.yAxisVal = (float)lattice.lattice_Y + 30f;
|
float[] f = new float[channelNums.Split(',').Length];
|
for (int i = 0; i < f.Length; i++)
|
{
|
f[i] = (float)lattice.lattice_Z-ControlCom.CurrentLengthOfTip-50- (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
}
|
|
unloadTipsMParam.channelCount = f.Length;
|
int[] c = new int[channelNums.Split(',').Length];
|
string[] cn = channelNums.Split(',');
|
for (int j = 0; j < c.Length; j++)
|
{
|
c[j] = Convert.ToInt32(cn[j]);
|
}
|
|
unloadTipsMParam.channelId = c;
|
unloadTipsMParam.zAxisVal = f;
|
|
unloadTipsMParam.yChannelGapVal = 9;
|
unloadTipsMParam.armId = Convert.ToInt32(methodNode.SelectSingleNode("arm/value").InnerText);
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
|
launchView.SetWaitOne();//暂停
|
HxResult ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, isSimulator);
|
|
#region 错误处理
|
result = DoError(platformNodeList, methodNode, isSimulator, ret, null, string.Empty, latticenum);
|
#endregion
|
}
|
else if (Shared.ChannelCount.Equals(96))
|
{
|
UnloadTipsMParam unloadTipsMParam = new UnloadTipsMParam();
|
unloadTipsMParam.xAxisVal = (float)lattice.lattice_X;
|
unloadTipsMParam.yAxisVal = (float)lattice.lattice_Y+13;
|
unloadTipsMParam.zAxisVal = (float)lattice.lattice_Z-80;
|
|
unloadTipsMParam.armId = Convert.ToInt32(methodNode.SelectSingleNode("arm/value").InnerText);
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
|
launchView.SetWaitOne();//暂停
|
HxResult ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, isSimulator);
|
|
#region 错误处理
|
result = DoError(platformNodeList, methodNode, isSimulator, ret, null, string.Empty, latticenum);
|
#endregion
|
}
|
}
|
else
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.RunUnloadTipsResource.strUnloadTipTargetWrong);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】Target lattice isn't trash, please task will stop!");
|
}
|
if (launchView.isRemotingOper)
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1019", 5, Properties.RunUnloadTipsResource.strWithoutLattice, 2);
|
}
|
result = false;
|
return result;
|
}
|
}
|
else
|
{
|
result = ExecuteUnloadTipsInToTrash(platformNodeList, methodNode, isSimulator);
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strError.ToString() + " 源 " + ex.Source + " 错误信息 " + ex.Message + ";");
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】error:source:" + ex.Source + ";error:" + ex.Message + ";");
|
}
|
if (launchView.isRemotingOper)
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1001", 5, "error:source:" + ex.Source + ";error:" + ex.Message + ";", 2);
|
}
|
result = false;
|
}
|
|
|
return result;
|
}
|
|
private bool DoError(XmlNodeList labwareNode, XmlNode methodNode, bool isSimulator, HxResult ret, TipsTable tipsTableSource, string strWell, string latticenum)
|
{
|
bool result = true;
|
|
if (ret.Result != ResultType.Success)
|
{
|
#region 错误处理
|
OperateDialog plsConfirmOper = null;
|
if (!launchView.isRemotingOper)
|
{
|
System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
|
{
|
plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunUnloadTipsResource.strFailWhatToDo : "unloadtips are fail! What do you want to do?");
|
plsConfirmOper.ShowDialog();
|
}));
|
}
|
else
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1043", 5, Properties.RunUnloadTipsResource.strFailWhatToDo, 2);
|
plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunUnloadTipsResource.strFailWhatToDo : "unloadtips are fail! What do you want to do?");
|
plsConfirmOper.ShowDialog();
|
}
|
|
if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试
|
{
|
result = ExecuteUnloadTips(labwareNode, methodNode, isSimulator);
|
return result;
|
}
|
else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) // 终止
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress + Properties.RunUnloadTipsResource.strUnLoadTipWasStopped);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress:unload tip was stopped!");
|
}
|
if (launchView.isRemotingOper)
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1044", 5, Properties.RunUnloadTipsResource.strUnLoadTipWasStopped, 2);
|
}
|
result = false;
|
return result;
|
}
|
else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过
|
{
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress + Properties.RunUnloadTipsResource.strUnLoadTipWasSkipped);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress:unload tip was skipped!");
|
}
|
}
|
#endregion
|
}
|
else
|
{
|
if (tipsTableSource != null)
|
{
|
launchView.UpdateLabwaretipsPutIntoSrc(tipsTableSource, strWell);
|
}
|
launchView.currentIsLoadingTips = false;
|
ControlCom.CurrentLengthOfTip = 0f;
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress + Properties.RunUnloadTipsResource.strUnloadTipSuccess + "卸载到板位 " + latticenum);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress:unload tips are success from " + latticenum + " lattice!");
|
}
|
}
|
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strEnd);
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】complete;");
|
}
|
|
return result;
|
}
|
#endregion
|
|
#region 执行卸载吸头到垃圾桶板位,返回结果字符串
|
/// <summary>
|
/// 执行卸载吸头到垃圾桶板位,返回结果字符串
|
/// </summary>
|
/// <param name="platformNodeList"></param>
|
/// <param name="methodNode">装载方法属性节点对象</param>
|
/// <param name="isSimulator">0:连接谁;1:仿真</param>
|
/// <returns></returns>
|
public bool ExecuteUnloadTipsInToTrash(XmlNodeList platformNodeList, XmlNode methodNode, bool isSimulator)
|
{
|
bool result = true;
|
try
|
{
|
if (launchView._cancelSource.IsCancellationRequested)
|
{
|
result = false;
|
return result;
|
}
|
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【卸载枪头】" + Properties.MachineRunResource.strStart.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【unloadtip method】start:");
|
}
|
|
#region 数据准备
|
string channelNums = methodNode.SelectSingleNode("channels").InnerText;
|
string armName = methodNode.SelectSingleNode("arm/text").InnerText;
|
string armId = methodNode.SelectSingleNode("arm/value").InnerText;
|
#endregion
|
|
#region 数据验证
|
if (channelNums == "")
|
{
|
//MethodMsg methodMsg = new MethodMsg(Guid.NewGuid().ToString(), "ID202_Choice_machine", 5, "", "ExecuteUnloadTipsInToTrash", "1019",
|
// "卸载枪头方法未指定卸载的通道,卸载枪头方法终止运行。", 6, 0);
|
//if (socketTcpClientToRemote != null)
|
//{
|
// socketTcpClientToRemote.sendmessageError(socketTcpClientToRemote.CreateSendMsgContent(methodMsg, false), launchView.isRemotingOper);
|
//}
|
if (strCurrentCulture.Equals("zh-CN"))
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler:【卸载枪头】" + Properties.MachineRunResource.strWithoutChannel.ToString());
|
}
|
else
|
{
|
launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler:Channel wasn't set, please check!");
|
}
|
if (launchView.isRemotingOper)
|
{
|
launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1019", 5, Properties.MachineRunResource.strWithoutChannel, 2);
|
}
|
result = false;
|
return result;
|
}
|
#endregion
|
|
List<Lattice> lattice = LatticeDB.GetTrashLatticeDataByIdFromdb(armId, Shared.SoftwareInformation.software_device_number); // 获取当前垃圾桶台面板位信息
|
|
Random random = new Random();
|
int i = random.Next(0, lattice.Count);
|
|
launchView.SetWaitOne();//暂停
|
if (Shared.ChannelCount == 1)
|
{
|
UnloadTipsMParam unloadTipsMParam = new UnloadTipsMParam();
|
//unloadTipsMParam.xAxisVal = (float)lattice[i].lattice_X;
|
//unloadTipsMParam.yAxisVal = (float)lattice[i].lattice_Y;
|
//unloadTipsMParam.zAxisVal = (float)lattice[i].lattice_Z;
|
unloadTipsMParam.xAxisVal = (float)lattice[i].lattice_X + ((float)lattice[i].lattice_length / (float)2f);
|
unloadTipsMParam.yAxisVal = (float)lattice[i].lattice_Y + ((float)lattice[i].lattice_width / (float)2f);
|
unloadTipsMParam.zAxisVal = (float)lattice[i].lattice_Z - ControlCom.CurrentLengthOfTip - 50 - (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
|
|
unloadTipsMParam.armId = Convert.ToInt32(armId);
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
|
launchView.SetWaitOne();//暂停
|
HxResult ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, isSimulator);
|
|
#region 错误处理
|
result = DoError(platformNodeList, methodNode, isSimulator, ret, null, string.Empty, lattice[i].lattice_num);
|
#endregion
|
}
|
else if(Shared.ChannelCount > 1)
|
{
|
UnloadTipsMParamSH unloadTipsMParam = new UnloadTipsMParamSH();
|
unloadTipsMParam.xAxisVal = (float)lattice[i].lattice_X;
|
unloadTipsMParam.yAxisVal = (float)lattice[i].lattice_Y;
|
|
float[] f = new float[channelNums.Split(',').Length];
|
for (int j = 0; j < f.Length; j++)
|
{
|
f[j] = (float)lattice[i].lattice_Z - ControlCom.CurrentLengthOfTip - 50- (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
}
|
|
unloadTipsMParam.channelCount = f.Length;
|
int[] c = new int[channelNums.Split(',').Length];
|
string[] cn = channelNums.Split(',');
|
for (int j = 0; j < c.Length; j++)
|
{
|
c[j] = Convert.ToInt32(cn[j]);
|
}
|
|
unloadTipsMParam.channelId = c;
|
unloadTipsMParam.zAxisVal = f;
|
|
unloadTipsMParam.armId = Convert.ToInt32(armId);
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
unloadTipsMParam.yChannelGapVal = (float)9f;
|
|
launchView.SetWaitOne();//暂停
|
HxResult ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, isSimulator);
|
|
#region 错误处理
|
result = DoError(platformNodeList, methodNode, isSimulator, ret, null, string.Empty, lattice[i].lattice_num);
|
#endregion
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
result = false;
|
}
|
|
return result;
|
}
|
#endregion
|
|
#region 控制面板用
|
/// <summary>
|
/// 卸载枪头
|
/// </summary>
|
/// <returns></returns>
|
public string UnLoadTip(string armValue="0")
|
{
|
string strMsg = string.Empty;
|
string currentArmValue = string.Empty;
|
|
// 获取当前垃圾桶台面板位信息
|
List<Lattice> lattice = new List<Lattice>();
|
if (armValue != "0" || armValue != Shared.ChanelArmId.ToString())
|
{
|
currentArmValue = armValue;
|
lattice = LatticeDB.GetTrashLatticeDataByIdFromdb(armValue, Shared.SoftwareInformation.software_device_number);
|
}
|
else
|
{
|
currentArmValue = Shared.ChanelArmId.ToString();
|
lattice = LatticeDB.GetTrashLatticeDataByIdFromdb(Shared.ChanelArmId.ToString(), Shared.SoftwareInformation.software_device_number);
|
}
|
Random random = new Random();
|
int index = random.Next(0, lattice.Count);
|
HxResult ret = new HxResult();
|
|
if (Shared.ChannelCount == 1)
|
{
|
UnloadTipsMParam unloadTipsMParam = new UnloadTipsMParam();
|
if (Shared.SoftwareInformation.software_device_number == DeviceCategory.DeviceHXFX)
|
{
|
unloadTipsMParam.xAxisVal = (float)lattice[index].lattice_X + (float)lattice[index].lattice_length / 2f;
|
unloadTipsMParam.yAxisVal = (float)lattice[index].lattice_Y + (float)lattice[index].lattice_length / 2f;
|
}
|
else
|
{
|
unloadTipsMParam.xAxisVal = (float)lattice[index].lattice_X;
|
unloadTipsMParam.yAxisVal = (float)lattice[index].lattice_Y + 30f;
|
}
|
unloadTipsMParam.zAxisVal = (float)lattice[index].lattice_Z - ControlCom.CurrentLengthOfTip - 50 - (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
|
unloadTipsMParam.armId = Convert.ToInt32(currentArmValue);//Shared.ChanelArmId;
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, false);
|
}
|
else if (Shared.ChannelCount > 1)
|
{
|
UnloadTipsMParamSH unloadTipsMParam = new UnloadTipsMParamSH();
|
unloadTipsMParam.yAxisVal = (float)lattice[index].lattice_Y + 30f;
|
float[] f = new float[Shared.ChannelsId.Length];
|
for (int i = 0; i < f.Length; i++)
|
{
|
f[i] = (float)lattice[index].lattice_Z - ControlCom.CurrentLengthOfTip - 50-(float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
}
|
|
unloadTipsMParam.channelCount = f.Length;
|
unloadTipsMParam.channelId = Shared.ChannelsId;
|
unloadTipsMParam.zAxisVal = f;
|
unloadTipsMParam.yChannelGapVal = 9;
|
unloadTipsMParam.armId = Convert.ToInt32(currentArmValue);// Shared.ChanelArmId;
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
|
ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, false);
|
}
|
|
if (ret.Result != ResultType.Success)
|
{
|
strMsg = string.Format("卸载Tip失败:{0}", ret.AlarmInfo);
|
}
|
|
return strMsg;
|
}
|
|
#endregion
|
|
#region 控制面板用
|
/// <summary>
|
/// 卸载所有臂通道枪头
|
/// </summary>
|
/// <returns></returns>
|
public string UnLoadTipFromAllArm()
|
{
|
string strMsg = string.Empty;
|
List<DeviceArm> deviceArmList = DeviceArmDB.GetDeviceArmFromdb(Shared.SoftwareInformation.software_information_id);
|
Shared.DeviceArmList = deviceArmList;
|
List<DeviceArm> deviceArmArray= Shared.DeviceArmList.Where(x => x.software_information_id.Equals(Shared.SoftwareInformation.software_information_id) && x.arm_type.Equals(1)).ToList();
|
foreach (DeviceArm decArm in deviceArmArray)
|
{
|
DeviceArm deviceArm = decArm;
|
|
// 获取当前垃圾桶台面板位信息
|
List<Lattice> lattice = LatticeDB.GetTrashLatticeDataByIdFromdb(deviceArm.device_arm_id.ToString(), Shared.SoftwareInformation.software_device_number);
|
Random random = new Random();
|
int index = random.Next(0, lattice.Count);
|
HxResult ret = new HxResult();
|
|
if (deviceArm.channels == 1)
|
{
|
UnloadTipsMParam unloadTipsMParam = new UnloadTipsMParam();
|
unloadTipsMParam.xAxisVal = (float)lattice[index].lattice_X;
|
unloadTipsMParam.yAxisVal = (float)lattice[index].lattice_Y + 30f;
|
unloadTipsMParam.zAxisVal = (float)lattice[index].lattice_Z - ControlCom.CurrentLengthOfTip - 50 - (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
|
unloadTipsMParam.armId = deviceArm.device_arm_id;
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, false);
|
}
|
else if (deviceArm.channels > 1)
|
{
|
UnloadTipsMParamSH unloadTipsMParam = new UnloadTipsMParamSH();
|
unloadTipsMParam.yAxisVal = (float)lattice[index].lattice_X;
|
unloadTipsMParam.yAxisVal = (float)lattice[index].lattice_Y + 30f;
|
|
if (deviceArm.device_arm_property == "")
|
{
|
continue;
|
}
|
string[] strChannels = deviceArm.device_arm_property.Trim().Split(',');
|
int[] iChannels = new int[strChannels.Length];
|
for (int j = 0; j < strChannels.Length; j++)
|
{
|
iChannels[j] = Convert.ToInt32(strChannels[j]);
|
}
|
|
float[] f = new float[iChannels.Length];
|
for (int i = 0; i < f.Length; i++)
|
{
|
f[i] = (float)lattice[index].lattice_Z - ControlCom.CurrentLengthOfTip - 50 - (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisWasteVal"].ToString());
|
}
|
|
unloadTipsMParam.channelCount = f.Length;
|
unloadTipsMParam.channelId = iChannels;
|
unloadTipsMParam.zAxisVal = f;
|
unloadTipsMParam.yChannelGapVal = 9;
|
unloadTipsMParam.armId = deviceArm.device_arm_id;
|
unloadTipsMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]);
|
|
ret = unloadTipsBll.ExecuteUnLoadTips(unloadTipsMParam, false);
|
}
|
|
if (ret.Result != ResultType.Success)
|
{
|
strMsg = string.Format("卸载Tip失败:{0}", ret.AlarmInfo);
|
break;
|
}
|
}
|
|
return strMsg;
|
}
|
|
#endregion
|
}
|
}
|