using DataCalcDAL; using DataEntity; using DataEntity.Device; using DataEntity.Rack; using DataEntity.Share; using DataRWDAL; using DataRWDAL.Device; using DataRWDAL.Rack; using DriverLib.Engine; using HxEnum; using HxSocket; using Newtonsoft.Json.Linq; using System; using System.CodeDom.Compiler; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Configuration; using System.Data; using System.IO; using System.Linq; using System.Runtime.Remoting.Metadata.W3cXsd2001; using System.Windows; using System.Windows.Controls; using System.Windows.Input; using System.Windows.Media; using System.Xml; using XCommon; using XCommon.Log; using XCore; using XCoreBLL; using XHandler.Class; using XHandler.Class.DataEx; using XHandler.View; using XHandler.View.BacteriaProperty; using XHandler.View.Com; using XHandler.View.Dialog; using XHandler.View.MethodProperty; using XImagingXhandler.XDAL; using static HxEnum.OperationTypeEnum; using static HxEnum.OtherEnum; namespace XHandler.Controls.Run.Com { /// /// 控制逻辑共用类 /// public class ControlCom { #region 变量 private static WellCalc wellCalc = new WellCalc(); private static CoatingFileBll coatingFileBll = new CoatingFileBll(); private static CutGumFileBll cutGumFileBll = new CutGumFileBll(); private static CoatingBll coatingBll = new CoatingBll(); private static UltrasonicBll ultrasonicBll = new UltrasonicBll(); private static AspirateBll aspirateBll = new AspirateBll(); private static DispenseBll dispenseBll = new DispenseBll(); private static LiquidAccuracyBll liquidAccuracyBll = new LiquidAccuracyBll(); private static GripTransportBll gripTransportBll = new GripTransportBll(); #endregion #region 获取实验挑菌信息 /// /// 获取实验挑菌信息 /// /// public static ExperimentRunChoiceBacteraModel ExpChoiceBactera(bool isRemoteOper=false,string experimentrunid="") { if (Shared.ExpChoiceBactera == null) { ExperimentRunChoiceBacteraModel model = new ExperimentRunChoiceBacteraModel(); if (isRemoteOper) { model.ExperimentId = experimentrunid; } else { model.ExperimentId = Shared.Exp.ExperimentId; } model.RunChoiceBacteraId = ComUtility.GetGuid(); ExperimentRunChoiceBacteraDB.Add(model); Shared.ExpChoiceBactera = model; } return Shared.ExpChoiceBactera; } #endregion #region 转移板到目标位 /// /// 转移板到目标位 /// /// /// /// /// /// /// /// 0:开盖; 1:关盖; 2:转板; /// public static bool DoReadMethodFileAndActionTransfer(string methodPath, XmlNode xmlEnv, string source, PositonTypeEnum srcPositonType, GripperModelEnum srcGripperModel, string target, PositonTypeEnum tgtPositonType, GripperModelEnum tgtGripperModel, bool isSimulator, RunWnd launchView, TransferTypeEnum transferType) { bool result = false; string strMsg = string.Format("【{0}】>Xhandler: 【{1}】error:{2}->{3}", DateTime.Now.ToString("HH:mm:ss:fff"), "抓板转移", source, target); #region 任务被取消 if (launchView._cancelSource.IsCancellationRequested) { return result; } #endregion bool bIsExists = File.Exists(methodPath); if (bIsExists) { XmlDocument xmlDocument = new XmlDocument(); xmlDocument.Load(methodPath); XmlNodeList xmlNodeMethodList = xmlDocument.SelectNodes("root/method[@id=3]"); if (xmlNodeMethodList.Count < 1) { launchView.AddLogs(strMsg); return result; } XmlNode xmlNode = xmlNodeMethodList[0]; #region gripModel、gripModelSet xmlNode.SelectSingleNode("gripModel/value").InnerText = EnumManagement.GetEnumValue(srcGripperModel).ToString(); xmlNode.SelectSingleNode("gripModelSet/value").InnerText = EnumManagement.GetEnumValue(tgtGripperModel).ToString(); #endregion #region 更新source、target string sourceLatticeId = ControlCom.GetLatticeIdFromXml(xmlEnv, launchView, source, srcPositonType); string destinationLatticeId = ControlCom.GetLatticeIdFromXml(xmlEnv, launchView, target, tgtPositonType); if (sourceLatticeId == null || destinationLatticeId == null) { return result; } xmlNode.SelectSingleNode("sourceLattice/text").InnerText = source; xmlNode.SelectSingleNode("sourceLattice/value").InnerText = sourceLatticeId; xmlNode.SelectSingleNode("sourceLattice/type").InnerText = EnumManagement.GetEnumValue(srcPositonType).ToString(); xmlNode.SelectSingleNode("destinationLattice/text").InnerText = target; xmlNode.SelectSingleNode("destinationLattice/value").InnerText = destinationLatticeId; xmlNode.SelectSingleNode("destinationLattice/type").InnerText = EnumManagement.GetEnumValue(tgtPositonType).ToString(); #endregion #region gripPickObject、gripPlaceObject string gripPickLabwareId = ControlCom.GetLabwareIdFromXml(xmlEnv, launchView, source); string gripPlaceLabwareId = ControlCom.GetLabwareIdFromXml(xmlEnv, launchView, target); if (gripPickLabwareId == null || gripPlaceLabwareId == null) { return result; } xmlNode.SelectSingleNode("gripPickObject/text").InnerText = string.Empty; xmlNode.SelectSingleNode("gripPickObject/value").InnerText = gripPickLabwareId; xmlNode.SelectSingleNode("gripPlaceObject/text").InnerText = string.Empty; xmlNode.SelectSingleNode("gripPlaceObject/value").InnerText = string.Empty; if (transferType == TransferTypeEnum.Open) // 0:开盖 { xmlNode.SelectSingleNode("gripPlaceObject/value").InnerText = "-1"; // 目标位为空板位 } else if (transferType == TransferTypeEnum.Close) // 1:关盖 { xmlNode.SelectSingleNode("gripPlaceObject/value").InnerText = gripPlaceLabwareId; } else if (transferType == TransferTypeEnum.TransferPlate) // 2:转板 { xmlNode.SelectSingleNode("gripPlaceObject/value").InnerText = "-1"; // 目标位为空板位 } #endregion GripTransportControl gripTransportControl = new GripTransportControl(Shared.SoftwareInformation.currentculture); gripTransportControl.launchView = launchView; gripTransportControl.socketTcpListener = null; result = gripTransportControl.ExecuteGripTransport(xmlEnv, xmlNode, isSimulator); } else { LoggerHelper.InfoLog(string.Format("[DoReadMethodFileAndActionTransfer]:方法path:{0}, File.Exists = {1}", methodPath, bIsExists)); launchView.AddLogs(strMsg); } return result; } #endregion #region 抓板 /// /// 抓板 /// /// /// /// /// /// /// /// public static bool ExecuteGripTransportPick(XmlNode xmlEnv, MethodGripTransport gripTransportData, Labware labwareFrom, ObservableCollection piledLabwares, string methodName, RunWnd launchView, bool isSimulator) { bool result = false; float angleVal = 0.0f; float squeezeVal = 0.0f; float spreadVal = 0.0f; float gripSpeed = 0.0f; float fGripperBaseHeight = (float)Convert.ToDouble(ConfigurationManager.AppSettings["fGripperBaseHeight"]); // 指尖高度 float fCircularDishMount = (float)Convert.ToDouble(ConfigurationManager.AppSettings["circularDishMount"]); // 圆形皿底托高度 string strCurrentCulture = Shared.SoftwareInformation.currentculture; #region 构建抓板参数 // 上次往成像位移动的皿编号 //按设定的层次抓耗材 if (gripTransportData.transportMode == (int)GripTransportModeEnum.TransportAll) { if (gripTransportData.desPositionText.Equals(ConfigurationManager.AppSettings["choiceLatticeId"].ToString())) { var latticeDes = xmlEnv.SelectSingleNode("platform[lattice_id="+ ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue),false)+ "]/labware[@id=1][labware_sname='" + gripTransportData.srcPositionText + "']"); if (latticeDes != null) { launchView.choiceBarcode = latticeDes.SelectSingleNode("labware_barcode").InnerText; launchView.choiceSrcLabwareSname = latticeDes.SelectSingleNode("labware_sname").InnerText; } } } else if (gripTransportData.transportMode == (int)GripTransportModeEnum.TransportExceptOne) { if (gripTransportData.desPositionText.Equals(ConfigurationManager.AppSettings["choiceLatticeId"].ToString())) { var latticeDes = xmlEnv.SelectSingleNode("platform[lattice_id="+ ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue),false)+ "]/labware[@id=2][labware_sname='" + gripTransportData.srcPositionText + "']"); if (latticeDes != null) { launchView.choiceBarcode = latticeDes.SelectSingleNode("labware_barcode").InnerText; launchView.choiceSrcLabwareSname = latticeDes.SelectSingleNode("labware_sname").InnerText; } } } else if (gripTransportData.transportMode == (int)GripTransportModeEnum.TransportCount) { if (gripTransportData.desPositionText.Equals(ConfigurationManager.AppSettings["choiceLatticeId"].ToString())) { XmlNodeList labwareNode = xmlEnv.SelectNodes("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false) + "]/labware"); int countOfLabware = labwareNode.Count; var latticeDes = xmlEnv.SelectSingleNode("platform[lattice_id="+ ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue),false)+ "]/labware[@id=" + (countOfLabware- gripTransportData.transportCount+1).ToString()+ "][labware_sname='" + gripTransportData.srcPositionText + "']"); if (latticeDes != null) { launchView.choiceBarcode = latticeDes.SelectSingleNode("labware_barcode").InnerText; launchView.choiceSrcLabwareSname = latticeDes.SelectSingleNode("labware_sname").InnerText; } } } //计算抓板目标板位值 HxResult ret = new HxResult(); if (labwareFrom != null) { GripTransportMParam gripTransportMParam = new GripTransportMParam(); // 获取夹爪信息 GripperCoordinate gripperCoordinateg = GetGripperData(gripTransportData, gripTransportData.srcPositionValue, gripTransportData.srcPositionText, gripTransportData.srcPositionType, gripTransportData.gripModelValue); //如果是镂空的板位上,抓的是正常非镂空的耗材时,需要把z轴坐标减少36.332mm(依据是项目板位校准的坐标) if(labwareFrom.labware_type_id!="4"&&Shared.SoftwareInformation.software_device_number==DeviceCategory.DeviceX3) { if (gripTransportData.srcPositionText == "P9" || gripTransportData.srcPositionText == "P21") { gripperCoordinateg.lattice_Z = gripperCoordinateg.lattice_Z - 36.332f; } } // 判断当前的形式和角度 gripTransportMParam.xAxisVal = (float)gripperCoordinateg.lattice_X + (float)labwareFrom.gripper_x_offset; gripTransportMParam.yAxisVal = (float)gripperCoordinateg.lattice_Y + (float)labwareFrom.gripper_y_offset; gripTransportMParam.zAxisVal = (float)gripperCoordinateg.lattice_Z + (float)labwareFrom.gripper_z_offset; #region 耗材总高度 float labwareMainHeight = 0.0f; float heightOfBottomLabware = 0f;//要抓的那层的底部离板位的平面距离 //按设定的层次抓耗材 if (gripTransportData.transportMode==(int)GripTransportModeEnum.TransportAll) { if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) { // 圆形皿耗材总高度,单位毫米 labwareMainHeight = (float)Convert.ToDouble(labwareFrom.labware_round_totalheight); } else { labwareMainHeight = (float)Convert.ToDouble(labwareFrom.labware_height); } } else if(gripTransportData.transportMode == (int)GripTransportModeEnum.TransportExceptOne)//总高度要增加最底层的高度 { var latticeDes = xmlEnv.SelectSingleNode("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false) + "]/labware[@id=1]"); Labware bottomLabware = new Labware(); if (latticeDes != null) { bottomLabware = LabwareDB.GetLabware(latticeDes.SelectSingleNode("labware_id").InnerText); heightOfBottomLabware = (float)Convert.ToDouble(bottomLabware.piled_height); } if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) { // 圆形皿耗材总高度,单位毫米 labwareMainHeight = (float)Convert.ToDouble(labwareFrom.labware_round_totalheight)+ heightOfBottomLabware; } else { labwareMainHeight = (float)Convert.ToDouble(labwareFrom.labware_height)+ heightOfBottomLabware; } } else if (gripTransportData.transportMode == (int)GripTransportModeEnum.TransportCount) { XmlNodeList labwareNode = xmlEnv.SelectNodes("platform[lattice_id="+ ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue),false)+ "]/labware"); int countOfLabware = labwareNode.Count; int loopCount = countOfLabware - gripTransportData.transportCount + 1; for (int i = 1; i <= loopCount; i++) { Labware bottomLabware = new Labware(); var latticeDes = xmlEnv.SelectSingleNode("platform[lattice_id="+ ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue),false)+ "]/labware[@id=" + (i).ToString() + "]"); if (latticeDes != null) { bottomLabware = LabwareDB.GetLabware(latticeDes.SelectSingleNode("labware_id").InnerText); heightOfBottomLabware += (float)Convert.ToDouble(bottomLabware.piled_height); } } if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) { // 圆形皿耗材总高度,单位毫米 labwareMainHeight = (float)Convert.ToDouble(labwareFrom.labware_round_totalheight) + heightOfBottomLabware; } else { labwareMainHeight = (float)Convert.ToDouble(labwareFrom.labware_height) + heightOfBottomLabware; } } #endregion // 判断被抓对象是什么类型,是盖子类型全抓顶部,是其他的类型全抓底部 if (gripTransportData.gripModelPosValue == 1) // 抓底部 { if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) // 圆形皿 { // 减掉指尖高度 gripTransportMParam.zAxisVal = (float)gripperCoordinateg.lattice_Z - heightOfBottomLabware + (float)labwareFrom.gripper_z_offset; } else { gripTransportMParam.zAxisVal = (float)gripperCoordinateg.lattice_Z - heightOfBottomLabware + (float)labwareFrom.gripper_z_offset; } gripTransportMParam.zAxisVal = gripTransportMParam.zAxisVal- heightOfBottomLabware - 1f; } else if (gripTransportData.gripModelPosValue == 2) // 抓顶部 { if (piledLabwares.Count > 0) // 判断是否有叠放的盖子 { // 盖子的厚度 float lidTopLength = (float)Convert.ToDouble(piledLabwares[0].with_lid_height); if (lidTopLength >= fGripperBaseHeight) //盖子厚度大于等于指尖 { gripTransportMParam.zAxisVal = (float)gripperCoordinateg.lattice_Z + (float)labwareFrom.gripper_z_offset - labwareMainHeight - (lidTopLength - fGripperBaseHeight); } else { // 获取夹爪刚好扣住盖子的高度 gripTransportMParam.zAxisVal = (float)gripperCoordinateg.lattice_Z + (float)labwareFrom.gripper_z_offset - labwareMainHeight + fGripperBaseHeight; } } else { gripTransportMParam.zAxisVal = (float)gripperCoordinateg.lattice_Z + (float)labwareFrom.gripper_z_offset - labwareMainHeight + fGripperBaseHeight; } } if (gripTransportData.pickPosMode == 1)//抓行,x轴不变,y轴变 { int rowNum = Convert.ToInt32(gripTransportData.pickPosValue); if (Shared.SoftwareInformation.originType == 0) { if (rowNum < labwareFrom.number_row / 2) { gripTransportMParam.yAxisVal = (float)(gripTransportMParam.yAxisVal - (labwareFrom.a1_b1_distance / (double)2 + (double)(labwareFrom.number_row / 2 - 1 - rowNum)) * labwareFrom.a1_b1_distance); } else { gripTransportMParam.yAxisVal = (float)(gripTransportMParam.yAxisVal + (labwareFrom.a1_b1_distance / (double)2 + (double)((rowNum - labwareFrom.number_row / 2))) * labwareFrom.a1_b1_distance); } } else { if (rowNum < labwareFrom.number_row / 2) { gripTransportMParam.yAxisVal = (float)(gripTransportMParam.yAxisVal - (labwareFrom.a1_b1_distance / (double)2 + (double)(labwareFrom.number_row / 2 - 1 - rowNum)) * labwareFrom.a1_b1_distance); } else { gripTransportMParam.yAxisVal = (float)(gripTransportMParam.yAxisVal + (labwareFrom.a1_b1_distance / (double)2 + (double)((rowNum - labwareFrom.number_row / 2))) * labwareFrom.a1_b1_distance); } } } else if (gripTransportData.pickPosMode == 2)//抓列,y轴不变,x轴变 { int colNum = Convert.ToInt32(gripTransportData.pickPosValue); if (Shared.SoftwareInformation.originType == 0) { if (colNum < labwareFrom.number_column / 2) { gripTransportMParam.xAxisVal = (float)(gripTransportMParam.xAxisVal - (labwareFrom.a1_a2_distance / (double)2 + (double)(labwareFrom.number_column / 2 - 1 - colNum)) * labwareFrom.a1_a2_distance); } else { gripTransportMParam.xAxisVal = (float)(gripTransportMParam.xAxisVal + (labwareFrom.a1_a2_distance / (double)2 + (double)((colNum - labwareFrom.number_column / 2))) * labwareFrom.a1_a2_distance); } } else { if (colNum < labwareFrom.number_column / 2) { gripTransportMParam.xAxisVal = (float)(gripTransportMParam.xAxisVal - (labwareFrom.a1_a2_distance / (double)2 + (double)(labwareFrom.number_column / 2 - 1 - colNum)) * labwareFrom.a1_a2_distance); } else { gripTransportMParam.xAxisVal = (float)(gripTransportMParam.xAxisVal + (labwareFrom.a1_a2_distance / (double)2 + (double)((colNum - labwareFrom.number_column / 2))) * labwareFrom.a1_a2_distance); } } } else if (gripTransportData.pickPosMode == 3)//抓孔 { if(Shared.SoftwareInformation.software_device_number==DeviceCategory.DeviceHXFX)//目前仅支持化学工作站,其余不支持 { Labware centrifugalLabware = ControlCom.GetCentrifugalLabwer(labwareFrom.piled_script); //转化成夹爪板位 List gripperCoordinateForWells = new WellCalcOfGripper().GetReallyWellsLabwareCoordinatesOnLattice(labwareFrom, gripperCoordinateg); GripperCoordinateForWell gripperPickCoordinateForWell = null; gripperPickCoordinateForWell = gripperCoordinateForWells.SingleOrDefault(t => t.lattice_num.Equals(gripTransportData.srcPositionText) && t.gripper_model.Equals(gripTransportData.gripModelPosValue) && t.wellname.Equals(gripTransportData.pickPosValue)); gripTransportMParam.xAxisVal = (float)gripperPickCoordinateForWell.lattice_X + (float)labwareFrom.gripper_x_offset; gripTransportMParam.yAxisVal = (float)gripperPickCoordinateForWell.lattice_Y + (float)labwareFrom.gripper_y_offset; gripTransportMParam.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareFrom.gripper_z_offset; if (gripTransportData.gripModelPosValue == 1) //抓底部 { gripTransportMParam.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z - heightOfBottomLabware; gripTransportMParam.zAxisVal = gripTransportMParam.zAxisVal - heightOfBottomLabware - 1f; } else if (gripTransportData.gripModelPosValue == 2) //抓顶部 { if (ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false).ToString() == "1") { if (centrifugalLabware.lid_in_radius < 10d) { gripTransportMParam.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareFrom.gripper_z_offset - labwareMainHeight + 13f; } else { gripTransportMParam.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareFrom.gripper_z_offset - labwareMainHeight + 10f; } } else { gripTransportMParam.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareFrom.gripper_z_offset - labwareMainHeight + (float)centrifugalLabware.gripper_z_offset; ; } } } else { string logInfo = string.Empty; if (strCurrentCulture.Equals("zh-CN")) { logInfo = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}.{5}{6}{7}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, Properties.MachineRunResource.strProgress, Properties.GripTransportResource.strPickError, "抓孔位功能,目前仅支持化学工作站", Properties.Resources.strBoardPosition, gripTransportData.srcPositionText, gripTransportData.pickPosValue); launchView.AddLogs(logInfo); } else { logInfo = string.Format("【{0}】>Xhandler: 【{1}】progress: the action of pick is fail! error information:{2}.lattice:{3}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, "The action of pick well is only supporting on Chemistry Work Station.", gripTransportData.srcPositionText); launchView.AddLogs(logInfo); } result = false; return result; } } angleVal = gripTransportMParam.angleVal = (float)gripperCoordinateg.gripper_rotational; gripTransportMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]); squeezeVal = gripTransportMParam.squeezeVal = (float)labwareFrom.gripper_squeeze; spreadVal = gripTransportMParam.spreadVal = (float)labwareFrom.gripper_spread; gripSpeed = gripTransportMParam.gripSpeed = (float)100f; gripTransportMParam.gripModel = gripTransportData.gripModelPosValue; // 抓板位置;1:底部;2:顶部 gripTransportMParam.gripState = 1; // 请求夹爪的状态:1:向内夹紧;2:向外张开 gripTransportMParam.gripperpowerVal = (float)labwareFrom.gripper_power; // From点位的耗材是皿 if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString() || (gripTransportData.srcPositionText.Equals(ConfigurationManager.AppSettings["choiceLatticeId"].ToString()))) // 圆形皿、挑菌板位 { // 减掉 圆形皿底托高度 gripTransportMParam.zAxisVal = gripTransportMParam.zAxisVal - fCircularDishMount; } //调用抓取方法 launchView.SetWaitOne();//暂停 ret = gripTransportBll.ExecuteGripTransportPick(gripTransportMParam, isSimulator); string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}.{5}{6}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, Properties.MachineRunResource.strProgress, Properties.GripTransportResource.strPickError, ret.AlarmInfo, Properties.Resources.strBoardPosition, gripTransportData.srcPositionText); launchView.AddLogs(log); } else { log = string.Format("【{0}】>Xhandler: 【{1}】progress: the action of pick is fail! error information:{2}.lattice:{3}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, ret.AlarmInfo, gripTransportData.srcPositionText); launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; if (!launchView.isRemotingOper) { Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.GripTransportResource.strPickFailWhatToDo : "The action of pick was fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); } else { launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1027", 5, Properties.GripTransportResource.strPickFailWhatToDo, 2); plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.GripTransportResource.strPickFailWhatToDo : "The action of pick was fail! What do you want to do?"); launchView.AddLogs(strCurrentCulture.Equals("zh-CN") ? Properties.GripTransportResource.strPickFailWhatToDo : "The action of pick was fail! What do you want to do?"); plsConfirmOper.ShowDialog(); } if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试 { return ControlCom.ExecuteGripTransportPick(xmlEnv, gripTransportData, labwareFrom, piledLabwares, methodName, launchView, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) // 终止 { if(launchView.isRemotingOper) { launchView.AddLogs(Properties.GripTransportResource.strPickWasStopped); launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1045", 5, Properties.GripTransportResource.strPickWasStopped, 2); } result = false; return result; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过 { result = true; return result; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}{5}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, Properties.MachineRunResource.strProgress, Properties.GripTransportResource.strPickOk, Properties.Resources.strBoardPosition, gripTransportData.srcPositionText); launchView.AddLogs(log); } else { log = string.Format("【{0}】>Xhandler: 【{1}】progress: the action of pick is success! lattice:{2}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, gripTransportData.srcPositionText); launchView.AddLogs(log); } if (gripperCoordinateg.is_after_pick_move == EnumManagement.GetEnumValue(IsAfterPickMoveEnum.Yes)) { return ControlCom.Move((float)gripperCoordinateg.move_x, (float)gripperCoordinateg.move_y, isSimulator, launchView, MoveTypeEnum.Gripper); } } } #endregion result = true; return result; } #endregion #region 放板 /// /// 放板 /// /// 台面数据xml /// /// /// /// /// /// public static bool ExecuteGripTransportPlace(XmlNode xmlEnv, MethodGripTransport gripTransportData, Labware labwareFrom, Labware labwareTo, ObservableCollection piledFromLabwares, string methodName, RunWnd launchView, bool isSimulator) { bool result = false; float fGripperBaseHeight = (float)Convert.ToDouble(ConfigurationManager.AppSettings["fGripperBaseHeight"]); // 指尖高度 float fCircularDishMount = (float)Convert.ToDouble(ConfigurationManager.AppSettings["circularDishMount"]); // 圆形皿底托高度 string strCurrentCulture = Shared.SoftwareInformation.currentculture; #region 构建放板参数 GripTransportMParam gripTransportMParamSet = new GripTransportMParam(); // 获取夹爪信息 GripperCoordinate gripperCoordinateTarget = GetGripperData(gripTransportData, gripTransportData.desPositionValue, gripTransportData.desPositionText, gripTransportData.desPositionType, gripTransportData.gripModelSetValue); //如果是镂空的板位上,放的是正常非镂空的耗材时,需要把z轴坐标减少36.332mm(依据是项目板位校准的坐标) if (labwareFrom.labware_type_id != "4" && Shared.SoftwareInformation.software_device_number == DeviceCategory.DeviceX3) { if (gripTransportData.desPositionText == "P9" || gripTransportData.desPositionText == "P21") { gripperCoordinateTarget.lattice_Z = gripperCoordinateTarget.lattice_Z - 36.332f; } } gripTransportMParamSet.xAxisVal = (float)gripperCoordinateTarget.lattice_X + (float)labwareTo.gripper_x_offset; gripTransportMParamSet.yAxisVal = (float)gripperCoordinateTarget.lattice_Y + (float)labwareTo.gripper_y_offset; gripTransportMParamSet.gripSpeed = 100f; float labwareMainHeight = 0.0f; // 耗材总高度 float heightOfBottomLabware = 0f;//要放上的那层的底部离板位的平面距离 //按目标板位已有的耗材高度,放耗材 XmlNodeList labwareNode = xmlEnv.SelectNodes("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.desPositionValue), false) + "]/labware"); if (labwareNode != null) { int countOfLabware = labwareNode.Count; for (int i = 1; i <= countOfLabware; i++) { Labware bottomLabware = new Labware(); var latticeDes = xmlEnv.SelectSingleNode("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.desPositionValue), false) + "]/labware[@id=" + (i).ToString() + "]"); if (latticeDes != null) { bottomLabware = LabwareDB.GetLabware(latticeDes.SelectSingleNode("labware_id").InnerText); heightOfBottomLabware += (float)Convert.ToDouble(bottomLabware.piled_height); } } if (labwareTo.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) // 圆形皿 { // 圆形皿耗材总高度,单位毫米 labwareMainHeight = (float)Convert.ToDouble(labwareTo.labware_round_totalheight)+ heightOfBottomLabware; } else { labwareMainHeight = (float)Convert.ToDouble(labwareTo.labware_height)+ heightOfBottomLabware; } } else { if (labwareTo.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) // 圆形皿 { // 圆形皿耗材总高度,单位毫米 labwareMainHeight = (float)Convert.ToDouble(labwareTo.labware_round_totalheight); } else { labwareMainHeight = (float)Convert.ToDouble(labwareTo.labware_height); } } // 判断抓板位置 if (gripTransportData.gripModelPosValue == 1) // 底部 { if (labwareTo.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) // 皿 { gripTransportMParamSet.zAxisVal = (float)gripperCoordinateTarget.lattice_Z- heightOfBottomLabware + (float)labwareTo.gripper_z_offset; } else { gripTransportMParamSet.zAxisVal = (float)gripperCoordinateTarget.lattice_Z- heightOfBottomLabware + (float)labwareTo.gripper_z_offset - 1.0f; } } else if (gripTransportData.gripModelPosValue == 2) // 顶部 { if (piledFromLabwares.Count > 1) // 判断是否有叠放的盖子 { // 放盖子时 减掉的是盖子的高度。 gripTransportMParamSet.zAxisVal = (float)gripperCoordinateTarget.lattice_Z + (float)labwareFrom.gripper_z_offset - labwareMainHeight; } else { gripTransportMParamSet.zAxisVal = (float)gripperCoordinateTarget.lattice_Z + (float)labwareTo.gripper_z_offset - labwareMainHeight + fGripperBaseHeight - 2f; // 盖子、圆形皿盖子 if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.Lid).ToString() || labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.Rounddishlid).ToString()) { gripTransportMParamSet.zAxisVal = (float)gripperCoordinateTarget.lattice_Z + (float)labwareTo.gripper_z_offset - labwareMainHeight; } else { gripTransportMParamSet.zAxisVal = (float)gripperCoordinateTarget.lattice_Z + (float)labwareTo.gripper_z_offset - labwareMainHeight + fGripperBaseHeight; } } } if (gripTransportData.placePosMode == 1)//抓行,x轴不变,y轴变 { int rowNum = Convert.ToInt32(gripTransportData.placePosValue); if (Shared.SoftwareInformation.originType == 0) { if (rowNum < labwareTo.number_row / 2) { gripTransportMParamSet.yAxisVal = (float)(gripTransportMParamSet.yAxisVal - (labwareTo.a1_b1_distance / (double)2 + (double)(labwareTo.number_row / 2 - 1 - rowNum)) * labwareTo.a1_b1_distance); } else { gripTransportMParamSet.yAxisVal = (float)(gripTransportMParamSet.yAxisVal + (labwareTo.a1_b1_distance / (double)2 + (double)((rowNum - labwareTo.number_row / 2))) * labwareTo.a1_b1_distance); } } else { if (rowNum < labwareFrom.number_row / 2) { gripTransportMParamSet.yAxisVal = (float)(gripTransportMParamSet.yAxisVal - (labwareTo.a1_b1_distance / (double)2 + (double)(labwareTo.number_row / 2 - 1 - rowNum)) * labwareTo.a1_b1_distance); } else { gripTransportMParamSet.yAxisVal = (float)(gripTransportMParamSet.yAxisVal + (labwareTo.a1_b1_distance / (double)2 + (double)((rowNum - labwareTo.number_row / 2))) * labwareTo.a1_b1_distance); } } } else if (gripTransportData.placePosMode == 2)//抓列,y轴不变,x轴变 { int colNum = Convert.ToInt32(gripTransportData.placePosValue); if (Shared.SoftwareInformation.originType == 0) { if (colNum < labwareFrom.number_column / 2) { gripTransportMParamSet.xAxisVal = (float)(gripTransportMParamSet.xAxisVal - (labwareTo.a1_a2_distance / (double)2 + (double)(labwareTo.number_column / 2 - 1 - colNum)) * labwareTo.a1_a2_distance); } else { gripTransportMParamSet.xAxisVal = (float)(gripTransportMParamSet.xAxisVal + (labwareTo.a1_a2_distance / (double)2 + (double)((colNum - labwareTo.number_column / 2))) * labwareTo.a1_a2_distance); } } else { if (colNum < labwareFrom.number_column / 2) { gripTransportMParamSet.xAxisVal = (float)(gripTransportMParamSet.xAxisVal - (labwareTo.a1_a2_distance / (double)2 + (double)(labwareTo.number_column / 2 - 1 - colNum)) * labwareTo.a1_a2_distance); } else { gripTransportMParamSet.xAxisVal = (float)(gripTransportMParamSet.xAxisVal + (labwareTo.a1_a2_distance / (double)2 + (double)((colNum - labwareTo.number_column / 2))) * labwareTo.a1_a2_distance); } } } else if (gripTransportData.placePosMode == 3)//抓孔 { if (Shared.SoftwareInformation.software_device_number == DeviceCategory.DeviceHXFX)//目前仅支持化学工作站,其余不支持 { Labware centrifugalLabware = ControlCom.GetCentrifugalLabwer(labwareTo.piled_script); //转化成夹爪板位 List gripperCoordinateForWells = new WellCalcOfGripper().GetReallyWellsLabwareCoordinatesOnLattice(labwareTo, gripperCoordinateTarget); GripperCoordinateForWell gripperPickCoordinateForWell = null; gripperPickCoordinateForWell = gripperCoordinateForWells.SingleOrDefault(t => t.lattice_num.Equals(gripTransportData.desPositionText) && t.gripper_model.Equals(gripTransportData.gripModelSetValue) && t.wellname.Equals(gripTransportData.placePosValue)); gripTransportMParamSet.xAxisVal = (float)gripperPickCoordinateForWell.lattice_X + (float)labwareTo.gripper_x_offset; gripTransportMParamSet.yAxisVal = (float)gripperPickCoordinateForWell.lattice_Y + (float)labwareTo.gripper_y_offset; gripTransportMParamSet.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareTo.gripper_z_offset; if (gripTransportData.gripModelPosValue == 1) //抓底部 { gripTransportMParamSet.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z - heightOfBottomLabware; gripTransportMParamSet.zAxisVal = gripTransportMParamSet.zAxisVal - heightOfBottomLabware - 1f; } else if (gripTransportData.gripModelPosValue == 2) //抓顶部 { if (ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false).ToString() == "1") { if (centrifugalLabware.lid_in_radius < 10d) { gripTransportMParamSet.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareTo.gripper_z_offset - labwareMainHeight + 13f; } else { gripTransportMParamSet.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareTo.gripper_z_offset - labwareMainHeight + 10f; } } else { gripTransportMParamSet.zAxisVal = (float)gripperPickCoordinateForWell.lattice_Z + (float)labwareTo.gripper_z_offset - labwareMainHeight + (float)centrifugalLabware.gripper_z_offset; ; } } } else { string logInfo = string.Empty; if (strCurrentCulture.Equals("zh-CN")) { logInfo = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}.{5}{6}{7}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, Properties.MachineRunResource.strProgress, Properties.GripTransportResource.strPickError, "放孔位功能,目前仅支持化学工作站", Properties.Resources.strBoardPosition, gripTransportData.desPositionText, gripTransportData.placePosValue); launchView.AddLogs(logInfo); } else { logInfo = string.Format("【{0}】>Xhandler: 【{1}】progress: the action of pick is fail! error information:{2}.lattice:{3}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, "The action of place well is only supporting on Chemistry Work Station.", gripTransportData.desPositionText); launchView.AddLogs(logInfo); } result = false; return result; } } gripTransportMParamSet.angleVal = (float)gripperCoordinateTarget.gripper_rotational; gripTransportMParamSet.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]); gripTransportMParamSet.squeezeVal = (float)labwareTo.gripper_squeeze; gripTransportMParamSet.spreadVal = (float)labwareTo.gripper_spread; gripTransportMParamSet.gripSpeed = (float)100f;//labwareTo.gripper_speed; gripTransportMParamSet.gripModel = gripTransportData.gripModelSetValue; gripTransportMParamSet.gripState = 2; // From圆形皿 && To圆形皿 if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString() && labwareTo.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) { // 减掉 圆形皿底托高度 gripTransportMParamSet.zAxisVal = gripTransportMParamSet.zAxisVal - fCircularDishMount - 1; } // From圆盖子 && To圆形皿 else if (labwareFrom.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.Rounddishlid).ToString() && labwareTo.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.CircularDish).ToString()) { // 减掉 圆形皿底托高度, 减掉指尖高度 gripTransportMParamSet.zAxisVal = gripTransportMParamSet.zAxisVal - fCircularDishMount + fGripperBaseHeight - 1; } launchView.SetWaitOne();//暂停 HxResult ret = gripTransportBll.ExecuteGripTransportPlace(gripTransportMParamSet, isSimulator); string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}.{5}{6}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, Properties.MachineRunResource.strProgress, Properties.GripTransportResource.strPlacekError, ret.AlarmInfo, Properties.Resources.strBoardPosition, gripTransportData.desPositionText); launchView.AddLogs(log); } else { log = string.Format("【{0}】>Xhandler: 【{1}】progress: the action of place is fail! error information:{2}.lattice:{3}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, ret.AlarmInfo, gripTransportData.desPositionText); launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; if (!launchView.isRemotingOper) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.GripTransportResource.strPlaceFailWhatToDo : "The action of place was fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); } else { launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1046", 5, Properties.GripTransportResource.strPlaceFailWhatToDo, 2); plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.GripTransportResource.strPlaceFailWhatToDo : "The action of place was fail! What do you want to do?"); launchView.AddLogs(strCurrentCulture.Equals("zh-CN") ? Properties.GripTransportResource.strPlaceFailWhatToDo : "The action of place was fail! What do you want to do?"); plsConfirmOper.ShowDialog(); } if (plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry)//重试 { return ExecuteGripTransportPlace(xmlEnv,gripTransportData, labwareFrom, labwareTo, piledFromLabwares, methodName, launchView, isSimulator); } else if (plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel)//终止 { if (strCurrentCulture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress + Properties.GripTransportResource.strPlaceWasStopped); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress: the action of place is abort!"); } if (launchView.isRemotingOper) { launchView.AddLogs(Properties.GripTransportResource.strPlaceWasStopped); launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1047", 5, Properties.GripTransportResource.strPlaceWasStopped, 2); } result = false; return result; } else if (plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue)//跳过 { if (strCurrentCulture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress + Properties.GripTransportResource.strPlaceWasSkipped); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress: the action of place is skip!"); } result = true; return result; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}{5}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, Properties.MachineRunResource.strProgress, Properties.GripTransportResource.strPlaceOk, Properties.Resources.strBoardPosition, gripTransportData.desPositionText); launchView.AddLogs(log); } else { log = string.Format("【{0}】>Xhandler: 【{1}】progress: the action of place is success! lattice:{2}", DateTime.Now.ToString("HH:mm:ss:fff"), methodName, gripTransportData.desPositionText); launchView.AddLogs(log); } } #endregion result = true; XmlNode srcNode = xmlEnv.SelectSingleNode("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false) + "]"); XmlNodeList srcLabwareAllNode = xmlEnv.SelectNodes("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.srcPositionValue), false) + "]/labware"); XmlNode desNode = xmlEnv.SelectSingleNode("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.desPositionValue), false) + "]"); if(desNode==null) { XmlElement xeformX = xmlEnv.OwnerDocument.CreateElement("platform"); XmlElement xeformX1 = xmlEnv.OwnerDocument.CreateElement("lattice_id"); xeformX1.InnerText = ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.desPositionValue), false).ToString(); xeformX.AppendChild(xeformX1); xmlEnv.AppendChild(xeformX); } desNode = xmlEnv.SelectSingleNode("platform[lattice_id=" + ControlCom.GetLatticeId(Convert.ToInt32(gripTransportData.desPositionValue), false) + "]"); int countDesLabware = desNode.SelectNodes("labware").Count; if (gripTransportData.transportMode == (int)GripTransportModeEnum.TransportAll) { //更新被移动的耗材在xml中的节点 foreach (XmlNode xn in srcLabwareAllNode) { srcNode.RemoveChild(xn); countDesLabware++; xn.Attributes["id"].Value = countDesLabware.ToString(); xn.SelectSingleNode("labware_sname").InnerText = LatticeDB.GetLatticeDataByIdFromdb(ControlCom.GetLatticeId(Convert.ToInt32(desNode.SelectSingleNode("lattice_id").InnerText), true).ToString()).lattice_num; desNode.AppendChild(xn); } } else if (gripTransportData.transportMode == (int)GripTransportModeEnum.TransportExceptOne) { for (int i = 1; i < srcLabwareAllNode.Count; i++) { srcNode.RemoveChild(srcLabwareAllNode[i]); countDesLabware++; srcLabwareAllNode[i].Attributes["id"].Value = countDesLabware.ToString(); srcLabwareAllNode[i].SelectSingleNode("labware_sname").InnerText = LatticeDB.GetLatticeDataByIdFromdb(ControlCom.GetLatticeId(Convert.ToInt32(desNode.SelectSingleNode("lattice_id").InnerText), true).ToString()).lattice_num; desNode.AppendChild(srcLabwareAllNode[i]); } } else if (gripTransportData.transportMode == (int)GripTransportModeEnum.TransportCount) { int countOfLabware = srcLabwareAllNode.Count; int startIndex = countOfLabware - gripTransportData.transportCount; for (int i = startIndex; i < countOfLabware; i++) { srcNode.RemoveChild(srcLabwareAllNode[i]); countDesLabware++; srcLabwareAllNode[i].Attributes["id"].Value = countDesLabware.ToString(); srcLabwareAllNode[i].SelectSingleNode("labware_sname").InnerText = LatticeDB.GetLatticeDataByIdFromdb(ControlCom.GetLatticeId(Convert.ToInt32(desNode.SelectSingleNode("lattice_id").InnerText), true).ToString()).lattice_num; desNode.AppendChild(srcLabwareAllNode[i]); } } return result; } #region 获取夹爪信息 /// /// 获取夹爪信息 /// /// /// /// /// /// private static GripperCoordinate GetGripperData(MethodGripTransport gripTransportData, string positionValue, string positionText, int positionType, int gripModel) { GripperCoordinate gripperData = new GripperCoordinate(); if (positionType == EnumManagement.GetEnumValue(PositonTypeEnum.Desktop)) // 台面 { List gripperCoordinates = GripperCoordinateDB.GetAGripperCoordinateFromdb(Shared.SoftwareInformation.software_information_id, Convert.ToInt32(gripTransportData.armValue), positionText); gripperData = gripperCoordinates.FirstOrDefault(x => x.gripper_model.Equals(gripModel)); gripperData.is_after_pick_move = EnumManagement.GetEnumValue(IsAfterPickMoveEnum.No); } else { var positionModel = PositionDB.GetInfoById(positionValue); gripperData.gripper_model = positionModel.gripper_model; gripperData.gripper_rotational = positionModel.gripper_rotational; gripperData.lattice_X = positionModel.positon_x; gripperData.lattice_Y = positionModel.positon_y; gripperData.lattice_Z = positionModel.positon_z; gripperData.is_after_pick_move = positionModel.is_after_pick_move; gripperData.move_x = positionModel.move_x; gripperData.move_y = positionModel.move_y; } return gripperData; } #endregion #endregion #region 机械臂移动到指定点位 /// /// 机械臂移动到指定点位 /// /// /// /// /// /// /// public static bool Move(float x, float y, bool isSimulator, RunWnd launchView, MoveTypeEnum moveType) { bool bRtn = false; if (!isSimulator) { HxResult ret = new HxResult(); if (moveType == MoveTypeEnum.Chanel) { // Tip ret = MethodAction.Instance.Move(x, y); } else { // 夹爪 ret = MethodAction.Instance.Move(x, y, Shared.GripperArmId); } if (ret.Result != ResultType.Success) { string log = string.Format("【{0}】>Xhandler: {1}{2}{3}.", DateTime.Now.ToString("HH:mm:ss:fff"), Properties.MachineRunResource.strProgress, "抓板失败!错误信息:", ret.AlarmInfo); launchView.AddLogs(log); OperateDialog plsConfirmOper = null; Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog("移动失败!想要如何处理?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试 { return Move(x, y, isSimulator, launchView, moveType); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) // 终止 { return bRtn; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过 { return true; } } } bRtn = true; return bRtn; } #endregion #region 根据latticeName从xml获取LabwareId /// /// 根据latticeName从xml获取LabwareId /// /// /// /// /// private static string GetLabwareIdFromXml(XmlNode xmlEnv, RunWnd launchView, string latticeName) { string labwareId = string.Empty; var latticeXn = xmlEnv.SelectSingleNode("platform[labware_sname='" + latticeName + "']"); if (latticeXn != null) { labwareId = latticeXn.SelectSingleNode("labware_id").InnerText; } else { if (Shared.SoftwareInformation.currentculture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【抓板转移】" + Properties.MachineRunResource.strProgress + "板位的耗材没有找到:" + latticeName); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【抓板转移】progress:Can't find labware:" + latticeName); } } return labwareId; } #endregion #region 根据latticeName从xml获取LatticeId /// /// 根据latticeName从xml获取LatticeId /// /// /// /// /// private static string GetLatticeIdFromXml(XmlNode xmlEnv, RunWnd launchView, string positionName, PositonTypeEnum positonType) { string latticeId = string.Empty; if (positonType == PositonTypeEnum.Desktop) { var latticeXn = xmlEnv.SelectSingleNode("platform[labware_sname='" + positionName + "']"); if (latticeXn != null) { latticeId = latticeXn.SelectSingleNode("lattice_id").InnerText; latticeId = ControlCom.GetLatticeId(Convert.ToInt32(latticeId)).ToString(); } } else { var positionModel = PositionDB.GetInfoByPositinName(positionName, Shared.SoftwareInformation.software_information_id); if (positionModel != null) { latticeId = positionModel.id; } } if (string.IsNullOrEmpty(latticeId)) { if (Shared.SoftwareInformation.currentculture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【抓板转移】" + Properties.MachineRunResource.strProgress + "板位的lattice没有找到:" + positionName); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【抓板转移】progress:Can't find lattice:" + positionName); } } return latticeId; } #endregion #region 自动计算位置安装Tip public static float CurrentLengthOfTip = 0f; public static Labware CurrentTipLabware = null;//当前枪头对应的耗材对象 public static float CurrentLengthOfTipOffSetVal = 0f; // 装枪偏差 public static float InWidthOfTip = 0f; // 圆锥部分最小半径 public static float OutWidthOfTip = 0f; // 圆锥部分最大半径 /// /// 自动计算位置安装Tip /// /// /// /// /// /// /// /// public static bool LoadTipAutomation(XmlNodeList platformNodeList, XmlNode methodNode, bool isSimulator, RunWnd launchView, HxSocketClient socketTcpClientToRemote, float tipoffsetLength=0f) { bool bReslut = true; LoadTipsControl loadTipsControl = new LoadTipsControl(Shared.SoftwareInformation.currentculture); LoadTipsControl.launchView = launchView; loadTipsControl.socketTcpClientToRemote = socketTcpClientToRemote; if (launchView.currentIsLoadingTips) //当前运行时,设备枪上是否装上了枪头 { if (socketTcpClientToRemote != null) { MethodMsg methodMsgS = new MethodMsg(Guid.NewGuid().ToString(), "ID202_Choice_machine", 3, "", "ExecuteCoatingFile", "1001", "warning:" + "It seems to have loaded tips, you should unload them from the choice machine!", 3, 2); socketTcpClientToRemote.sendmessageError(socketTcpClientToRemote.CreateSendMsgContent(methodMsgS, false), launchView.isRemotingOper); } if (!launchView.isRemotingOper) // 是否是远程整合运行 { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { PlsToolTipWin plsToolTipWin = new PlsToolTipWin("It seems to have loaded tips, do you unload them?"); plsToolTipWin.Height = launchView.ActualHeight; plsToolTipWin.Width = launchView.ActualWidth; plsToolTipWin.btnClearData.Visibility = Visibility.Visible; plsToolTipWin.lauchView = launchView; SolidColorBrush mybtn1_Brush = new SolidColorBrush(System.Windows.Media.Color.FromArgb(70, 0, 0, 0)); plsToolTipWin.Background = (System.Windows.Media.Brush)mybtn1_Brush; plsToolTipWin.ShowDialog(); if (plsToolTipWin.DialogResult == true) { // 调用执行方法,更新执行结果字符串 UnloadTipsControl unloadTipsControl = new UnloadTipsControl(Shared.SoftwareInformation.currentculture); unloadTipsControl.launchView = launchView; unloadTipsControl.socketTcpClientToRemote = socketTcpClientToRemote; unloadTipsControl.ExecuteUnloadTipsInToTrash(platformNodeList, methodNode, isSimulator); } })); } } #region 计算加载Tip头后,Z轴多出来的长度 LabwareBll labwareBll = new LabwareBll(); Labware labwares = labwareBll.GetLabware(methodNode.SelectSingleNode("labwaretip/value").InnerText); // 调高 //CurrentLengthOfTip = (float)labwares.tip_length - (float)labwares.press_tip_depth + tipoffsetLength; CurrentLengthOfTip = (float)labwares.tip_length - (float)labwares.press_tipinto_depth + tipoffsetLength; CurrentLengthOfTipOffSetVal = ((float)labwares.press_tip_depth - (float)labwares.press_tipinto_depth) / (float)2; ControlCom.CurrentLengthOfTip = CurrentLengthOfTip; InWidthOfTip = (float)labwares.tip_cone_radius_min; OutWidthOfTip = (float)labwares.tip_cone_radius_max; #endregion bool result = loadTipsControl.ExecuteLoadTips(platformNodeList, methodNode, isSimulator); bReslut = result; return bReslut; } #endregion #region 获取LatticeId /// /// 获取LatticeId /// /// /// /// public static int GetLatticeId(int baseLatticeid, bool isAdd = true) { int nLatticeid = -1; int nStep = -1; if (Shared.SoftwareInformation.software_device_number.Equals(DeviceCategory.DeviceChoice)) { nStep = 29; } else if (Shared.SoftwareInformation.software_device_number.Equals(DeviceCategory.DeviceLite)) { nStep = 20; } // 微牧 else if (Shared.SoftwareInformation.software_device_number.Equals(DeviceCategory.DeviceLiteChoice)) { nStep = 106; } else if (Shared.SoftwareInformation.software_device_number.Equals(DeviceCategory.DeviceT200)) { nStep = 125; } else if (Shared.SoftwareInformation.software_device_number.Equals(DeviceCategory.DeviceElisa)) { nStep = 144; } else if (Shared.SoftwareInformation.software_device_number.Equals(DeviceCategory.DeviceX3)) { nStep = 175; } else // X1 { nStep = 0; } if (isAdd) { nLatticeid = baseLatticeid + nStep; } else { nLatticeid = baseLatticeid - nStep; } return nLatticeid; } #endregion #region 更新已使用的涂布目标孔的颜色 /// /// 更新已使用的涂布目标孔的颜色 /// /// /// /// public static void UpdateDesPlateWellsColor(XmlNode plateNode, string labwareName, RunWnd launchView) { var platformNode = plateNode.SelectSingleNode("platform[labware_sname='" + labwareName + "']"); if (platformNode != null) { int pid = ControlCom.GetLatticeId(Convert.ToInt32(platformNode.SelectSingleNode("lattice_id").InnerText)); Labware labwares = LabwareDB.GetLabware(platformNode.SelectSingleNode("labware_id").InnerText); Lattice lattice = LatticeDB.GetLatticeDataByIdFromdb(pid.ToString()); TipsTable tipsTable = new TipsTable(); tipsTable.lattice_id = pid.ToString(); tipsTable.lattice_num = labwareName; string allValidWells = platformNode.SelectSingleNode("allValidWells").InnerText; string[] wells = allValidWells.Split(','); launchView.UpdateLabwareWells(tipsTable, wells, 5); // 有效未使用蓝色 // 有效孔还原 platformNode.SelectSingleNode("residueValidWells").InnerText = allValidWells; } } #endregion #region 获取挑菌点位的中心坐标 /// /// 获取挑菌点位的中心坐标 /// /// public static float[] GetChoiceCenterPointVal() { string choiceCenterPointVal = ConfigurationManager.AppSettings["choiceCenterPointVal"].ToString(); string[] strCenterArry = choiceCenterPointVal.Split(','); float[] floatCenterArry = Array.ConvertAll(strCenterArry, s => float.Parse(s)); return floatCenterArry; } #endregion #region 执行挑菌动作 /// /// 执行挑菌动作 /// /// /// /// /// /// /// /// /// /// public static bool RunChoice(RunWnd launchView, string strMethodName, ChoiceMParam choiceMParam, string strChoiceWellOrXYZ, string strSrcPlateName, string strSrcPlateBarcode, bool isSimulator = false, TipsTable targetWellInfo = null) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; // 执行挑菌动作 DateTime startTime = DateTime.Now; HxResult ret = coatingFileBll.ExecuteChoice(choiceMParam, isSimulator); DateTime endTime = DateTime.Now; string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strChoiceErrorExec + " 菌坐标:" + strChoiceWellOrXYZ + ", 板位:" + strSrcPlateName + Properties.MachineRunResource.strError + ret.AlarmInfo; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:pick bacteria was failed from " + strChoiceWellOrXYZ + " lattice of " + strSrcPlateName + "lattice! error info:" + ret.AlarmInfo; launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunCoatingFileResource.strChoiceFailWhatToDo : "choice is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); // 重试 if (plsConfirmOper != null && plsConfirmOper.OperMark == OperationTypeEnum.NodeOperationTypeEnum.Retry) { return RunChoice(launchView, strMethodName, choiceMParam, strChoiceWellOrXYZ, strSrcPlateName, strSrcPlateBarcode, isSimulator); } // 终止 else if (plsConfirmOper != null && plsConfirmOper.OperMark == OperationTypeEnum.NodeOperationTypeEnum.Cancel) { launchView.addChoiceDataIntoReport(null, strSrcPlateName, "0", new string[] { strChoiceWellOrXYZ }, "block", "", startTime, endTime, "Choice", strSrcPlateBarcode); return false; } // 跳过 else if (plsConfirmOper != null && plsConfirmOper.OperMark == OperationTypeEnum.NodeOperationTypeEnum.Continue) { launchView.addChoiceDataIntoReport(null, strSrcPlateName, "0", new string[] { strChoiceWellOrXYZ }, "block", "", startTime, endTime, "Choice", strSrcPlateBarcode); return true; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strChoiceSuccessExec + " 菌坐标:" + strChoiceWellOrXYZ + ", 板位:" + strSrcPlateName; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:pick bacteria was successful from " + strChoiceWellOrXYZ + " lattice of " + strSrcPlateName + "!"; launchView.AddLogs(log); } if (targetWellInfo != null) // 从皿中挑菌时,变量为null { // 挑菌完成颜色更新 launchView.UpdateLabwareWells(targetWellInfo, new string[] { strChoiceWellOrXYZ }, 4); // 放液完成绿色 } launchView.addChoiceDataIntoReport(null, strSrcPlateName, "0", new string[] { strChoiceWellOrXYZ }, "pass", "", startTime, endTime, "Choice", strSrcPlateBarcode); } return true; } #endregion #region 执行涂布动作 /// /// 执行涂布动作 /// /// /// /// /// /// /// /// /// /// public static bool RunCoating(RunWnd launchView, string strMethodName, CoatingMParam coatingMParam, TipsTable targetWellInfo, string strDesWell, string strLabwareName, string strLabwareBarcode, bool isSimulator = false) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; // 执行涂布动作 launchView.UpdateLabwareWells(targetWellInfo, new string[] { strDesWell }, 3); // 正在放液水红色 DateTime startTime = DateTime.Now; // 执行涂布动作 HxResult ret = coatingBll.ExecuteCoating(coatingMParam, isSimulator); DateTime endTime = DateTime.Now; string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strCoatingErrorExec + " 孔位:" + strDesWell + ", 板位:" + strLabwareName + Properties.MachineRunResource.strError + ret.AlarmInfo; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: Coating was failed on " + strDesWell + " of " + strLabwareName + " lattice! Error info:" + ret.AlarmInfo; launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunCoatingFileResource.strCoatingFailWhatToDo : "coating is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) //重试 { return RunCoating(launchView, strMethodName, coatingMParam, targetWellInfo, strDesWell, strLabwareName, strLabwareBarcode, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) //终止 { launchView.addCoatingFinishDataIntoReport(null, strLabwareName, "0", new string[] { strDesWell }, "0", new string[] { }, strLabwareBarcode, startTime, endTime, "Coating", 1, 0); return false; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) //跳过 { launchView.addCoatingFinishDataIntoReport(null, strLabwareName, "0", new string[] { strDesWell }, "0", new string[] { }, strLabwareBarcode, startTime, endTime, "Coating", 1, 0); return true; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strCoatingSuccessExec + " 孔位:" + strDesWell + ", 板位:" + strLabwareName; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:Coating was successful on " + strDesWell + " of " + strLabwareName + " lattice!"; launchView.AddLogs(log); } // 涂布完成颜色更新 launchView.UpdateLabwareWells(targetWellInfo, new string[] { strDesWell }, 4); // 放液完成绿色 launchView.addCoatingFinishDataIntoReport(null, strLabwareName, "0", new string[] { strDesWell }, "1", new string[] { }, strLabwareBarcode, startTime, endTime, "Coating", 1, 0); } return true; } #endregion #region 执行混合动作 /// /// 执行混合动作 /// /// /// /// /// /// /// /// /// /// public static bool RunMix(RunWnd launchView, string strMethodName, MixMParam mixMParam, TipsTable targetWellInfo, string strDesWell, string strLabwareName, string strLabwareBarcode, bool isSimulator = false) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; launchView.UpdateLabwareWells(targetWellInfo, new string[] { strDesWell }, 3); // 正在放液水红色 DateTime startTime = DateTime.Now; // 执行混合动作 HxResult ret = coatingBll.ExecuteMixing(mixMParam, isSimulator); DateTime endTime = DateTime.Now; string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strMixingErrorExec + " 孔位:" + strDesWell + ", 板位:" + strLabwareName + Properties.MachineRunResource.strError + ret.AlarmInfo; launchView.AddLogs(log); } else { log = string.Format("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: mixing was failed on " + strDesWell + " of " + strLabwareName + " lattice! Error info:" + ret.AlarmInfo); launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunMixResource.strFailWhatToDo : "mixing is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) //重试 { return RunMix(launchView, strMethodName, mixMParam, targetWellInfo, strDesWell, strLabwareName, strLabwareBarcode, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) //终止 { launchView.addCoatingFinishDataIntoReport(null, strLabwareName, "0", new string[] { strDesWell }, "0", new string[] { }, strLabwareBarcode, startTime, endTime, "Mix", 1, 0); return false; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) //跳过 { launchView.addCoatingFinishDataIntoReport(null, strLabwareName, "0", new string[] { strDesWell }, "0", new string[] { }, strLabwareBarcode, startTime, endTime, "Mix", 1, 0); return true; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strMixingSuccessExec + " 孔位:" + strDesWell + ", 板位:" + strLabwareName; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:Mixing was successful on " + strDesWell + " of " + strLabwareName + " lattice!"; launchView.AddLogs(log); } // 涂布完成颜色更新 launchView.UpdateLabwareWells(targetWellInfo, new string[] { strDesWell }, 4); // 放液完成绿色 launchView.addCoatingFinishDataIntoReport(null, strLabwareName, "0", new string[] { strDesWell }, "1", new string[] { }, strLabwareBarcode, startTime, endTime, "Mix", 1, 0); } return true; } #endregion #region 超声探测 /// /// 执行超声单步操作(文件涂布用) /// /// /// /// /// /// /// /// 0:正常;1:继续;2:停止 public static int DoUltrasonicForFileCoating(RunWnd launchView, XmlNode plateNode, XmlNode methodNode, MethodCoatingFile methodCoatingFile, string labwarePositon, bool isSimulator) { // 超声关闭 if (!methodCoatingFile.isEnableultrasonic) { return 0; } // 用目标板点位名查找目标板的类型 XmlNode latticePlatform = plateNode.SelectSingleNode("platform[labware_sname='" + labwarePositon + "']"); if (latticePlatform == null) { LoggerHelper.DebugLog(string.Format("[ExecuteCoatingFile]:xml.platform中找不到{0}的点位信息,跳过超声", labwarePositon)); return 1; } // 超声板位的耗材ID string labwareId = latticePlatform.SelectSingleNode("labware_id").InnerText; // 获取点位信息 int latticeId = ControlCom.GetLatticeId(Convert.ToInt32(latticePlatform.SelectSingleNode("lattice_id").InnerText)); Lattice lattice = LatticeDB.GetLatticeDataByIdFromdb(latticeId.ToString()); // 圆形皿超声信息 UltrasonicDishObject ultrasonicDishObject = null; if (methodCoatingFile.ultrasonicDishObjectList != null) { ultrasonicDishObject = methodCoatingFile.ultrasonicDishObjectList.FirstOrDefault(it => it.labwareValue.Equals(labwareId)); } // 非圆形皿超声信息 UltrasonicObject ultrasonicObject = null; if (methodCoatingFile.ultrasonicObjectList != null) { ultrasonicObject = methodCoatingFile.ultrasonicObjectList.FirstOrDefault(it => it.labwareValue.Equals(labwareId)); } if (ultrasonicDishObject == null && ultrasonicObject == null) { LoggerHelper.DebugLog(string.Format("[ExecuteCoatingFile]:labwareId({0})在超声属性里不存在,跳过超声", labwareId)); return 1; } UltrasonicMParam ultrasonicMParam = null; #region 圆形皿 if (ultrasonicDishObject != null) { ultrasonicMParam = new UltrasonicMParam(); ultrasonicMParam.latticeName = labwarePositon; ultrasonicMParam.ultrasonicObjectType = 1; // 挑菌点位 if (labwarePositon.Equals(ConfigurationManager.AppSettings["choiceLatticeId"].ToString())) { // 获取挑菌点位的中心坐标 float[] floatCenterArry = ControlCom.GetChoiceCenterPointVal(); ultrasonicMParam.objectCenterXVal = floatCenterArry[0]; ultrasonicMParam.objectCenterYVal = floatCenterArry[1]; } else { ultrasonicMParam.objectCenterXVal = (float)lattice.lattice_X - ((float)lattice.lattice_length / (float)2); ultrasonicMParam.objectCenterYVal = (float)lattice.lattice_Y + ((float)lattice.lattice_width / (float)2); } float[] xPoint = new float[ultrasonicDishObject.pointList.Count()]; float[] yPoint = new float[ultrasonicDishObject.pointList.Count()]; for (int i = 0; i < ultrasonicDishObject.pointList.Count; i++) { xPoint[i] = (float)Convert.ToDouble(ultrasonicDishObject.pointList[i].dropdown_id); yPoint[i] = (float)Convert.ToDouble(ultrasonicDishObject.pointList[i].dropdown_name); } ultrasonicMParam.objectDividePointXVal = xPoint; ultrasonicMParam.objectDividePointYVal = yPoint; } #endregion #region 非圆形皿 else if (ultrasonicObject != null) { ultrasonicMParam = new UltrasonicMParam(); ultrasonicMParam.latticeName = labwarePositon; ultrasonicMParam.ultrasonicObjectType = 2; ultrasonicMParam.objectDivideRowCount = ultrasonicObject.rowNum; ultrasonicMParam.objectDivideColumnCount = ultrasonicObject.columnNum; ultrasonicMParam.objectCenterXVal = (float)lattice.lattice_X + ((float)lattice.lattice_length / (float)2); ultrasonicMParam.objectCenterYVal = (float)lattice.lattice_Y + ((float)lattice.lattice_width / (float)2); ultrasonicMParam.objectDividePointA1ToWideVal = (float)ultrasonicObject.closeLeftVal; // 超声对象探测分割的A1点到左侧边距离(毫米) ultrasonicMParam.objectDividePointA1ToLongVal = (float)ultrasonicObject.closeTopVal; // 超声对象探测分割的A1点到顶部侧边距离(毫米) ultrasonicMParam.objectDividePointA1ToA2Val = (float)ultrasonicObject.xAxisVal; // 超声对象探测分割的A1点到A2两点之间距离(毫米) ultrasonicMParam.objectDividePointA1ToB1Val = (float)ultrasonicObject.yAxisVal; // 超声对象探测分割的A1点到B1两点之间距离(毫米) } #endregion if (ultrasonicMParam == null) { LoggerHelper.DebugLog(string.Format("[ExecuteCoatingFile]:labwareId({0})在超声属性里不存在,跳过超声2", labwareId)); return 1; } bool bIsOk = RunUltrasonic(launchView, methodNode, ultrasonicMParam, isSimulator); if (!bIsOk) { return 2; } return 0; } /// /// 执行超声探测 /// /// /// /// /// /// private static bool RunUltrasonic(RunWnd launchView, XmlNode methodNode, UltrasonicMParam ultrasonicMParam, bool isSimulator = false) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; HxResult ret = ultrasonicBll.ExecuteUltrasonic(ultrasonicMParam, isSimulator); string strMethodName = methodNode.SelectSingleNode("name").InnerText; string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}.{5}{6}", DateTime.Now.ToString("HH:mm:ss:fff"), strMethodName, Properties.MachineRunResource.strProgress, Properties.RunUltrasonicResource.strUltrasonicFail, ret.AlarmInfo, Properties.Resources.strBoardPosition, ultrasonicMParam.latticeName); launchView.AddLogs(log); } else { log = string.Format("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: ultrasonic is fail on " + ultrasonicMParam.latticeName + " lattice! error information:" + ret.AlarmInfo); launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunUltrasonicResource.strFailWhatToDo : "ultrasonic is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) //重试 { return RunUltrasonic(launchView, methodNode, ultrasonicMParam, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) //终止 { return false; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) //跳过 { return true; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}{5}", DateTime.Now.ToString("HH:mm:ss:fff"), strMethodName, Properties.MachineRunResource.strProgress, Properties.RunUltrasonicResource.strUltrasonicSuccess, Properties.Resources.strBoardPosition, ultrasonicMParam.latticeName); launchView.AddLogs(log); } else { log = string.Format("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: the action of ultrasonic is success! on " + ultrasonicMParam.latticeName); launchView.AddLogs(log); } } return true; } /// /// 超声探测 /// /// /// /// /// /// 0:正常;1:继续;2:停止 /// 挑选转运方法会传值,挑菌点位是不定的 public static int DoUltrasonic(RunWnd launchView, XmlNode xmlEnv, XmlNode methodNode, bool isSimulator, string latticeName = "") { // 从xml获取超声子页面数据 MethodUltrasonicChild ultrasonicData = UltrasonicBll.GenerateMethodUltrasonicChildDataByXmlNode(methodNode); string strCurrentCulture = Shared.SoftwareInformation.currentculture; string positionText = !string.IsNullOrEmpty(ultrasonicData.positionText) ? ultrasonicData.positionText : latticeName; #region 任务被取消 if (launchView._cancelSource.IsCancellationRequested) { return 2; } #endregion #region 检查数据 Lattice lattice = null; TabletopTemplate tabletopTemplate = TabletopTemplateDB.GetCurrentAppTabletopTemplateCollectionFromdb(); //增加台面模板判断 if (tabletopTemplate == null) { lattice = LatticeDB.GetLatticeDataByIdFromdb(positionText, Shared.ChanelArmId, Shared.SoftwareInformation.software_device_number); } else { lattice = LatticeDB.GetLatticeDataByLatticeNumAndTempIdFromdb(positionText, Convert.ToInt32(Shared.DeviceArmList.SingleOrDefault(x => x.arm_type.Equals(1)).device_arm_id), Shared.SoftwareInformation.software_device_number, tabletopTemplate.tabletopid); } Labware labwares = new Labware(); var latticeXn = xmlEnv.SelectSingleNode("platform[labware_sname='" + positionText + "']"); if (latticeXn != null) { labwares.labware_id = latticeXn.SelectSingleNode("labware_id").InnerText; labwares = LabwareDB.GetLabware(labwares.labware_id); } 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.RunUltrasonicResource.strWithoutLattice.ToString()); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress: the lattice of ultrasonic is wrong! please check!"); } return 2; } #endregion #region 执行探测 UltrasonicMParam ultrasonicMParam = new UltrasonicMParam(); // 超声板位名称 ultrasonicMParam.latticeName = positionText; // 1:圆形皿;2:其他耗材 ultrasonicMParam.ultrasonicObjectType = Convert.ToInt32(ultrasonicData.labwareValue); if (ultrasonicData.labwareValue == "1") // 圆形皿 { string strChoiceLatticeName = ConfigurationManager.AppSettings["choiceLatticeId"].ToString(); // 挑菌点位 if (ultrasonicMParam.latticeName.Equals(strChoiceLatticeName)) { // 获取挑菌点位的中心坐标 float[] floatCenterArry = ControlCom.GetChoiceCenterPointVal(); ultrasonicMParam.objectCenterXVal = floatCenterArry[0]; // 超声对象中心x轴坐标 ultrasonicMParam.objectCenterYVal = floatCenterArry[1]; // 超声对象中心y轴坐标 } else { ultrasonicMParam.objectCenterXVal = (float)ultrasonicData.xDishAxisVal; // 超声对象中心x轴坐标 ultrasonicMParam.objectCenterYVal = (float)ultrasonicData.yDishAxisVal; // 超声对象中心y轴坐标 } float[] xPoint = new float[ultrasonicData.pointList.Count()]; float[] yPoint = new float[ultrasonicData.pointList.Count()]; for (int i = 0; i < ultrasonicData.pointList.Count; i++) { xPoint[i] = (float)Convert.ToDouble(ultrasonicData.pointList[i].dropdown_id); yPoint[i] = (float)Convert.ToDouble(ultrasonicData.pointList[i].dropdown_name); } // 超声对象探测点距离中心x方向便宜距离(毫米),默认数组里有3个 ultrasonicMParam.objectDividePointXVal = xPoint; // 超声对象探测点距离中心y方向便宜距离(毫米),默认数组里有3个 ultrasonicMParam.objectDividePointYVal = yPoint; } else if (ultrasonicData.labwareValue == "2") // 非圆形皿 { ultrasonicMParam.objectDivideRowCount = ultrasonicData.rowNum; // 超声对象探测分割行数 ultrasonicMParam.objectDivideColumnCount = ultrasonicData.columnNum; // 超声对象探测分割列数 // objectCenterXVal、objectCenterYVal 非圆皿没传值 ultrasonicMParam.objectCenterXVal = (float)lattice.lattice_X + ((float)lattice.lattice_length / (float)2); ultrasonicMParam.objectCenterYVal = (float)lattice.lattice_Y + ((float)lattice.lattice_width / (float)2); ultrasonicMParam.objectDividePointA1ToWideVal = (float)ultrasonicData.closeLeftVal; // 超声对象探测分割的A1点到左侧边距离(毫米) ultrasonicMParam.objectDividePointA1ToLongVal = (float)ultrasonicData.closeTopVal; // 超声对象探测分割的A1点到顶部侧边距离(毫米) ultrasonicMParam.objectDividePointA1ToA2Val = (float)ultrasonicData.xAxisVal; // 超声对象探测分割的A1点到A2两点之间距离(毫米) ultrasonicMParam.objectDividePointA1ToB1Val = (float)ultrasonicData.yAxisVal; // 超声对象探测分割的A1点到B1两点之间距离(毫米) } // 执行超声探测 HxResult ret = ultrasonicBll.ExecuteUltrasonic(ultrasonicMParam, isSimulator); string strMethodName = methodNode.SelectSingleNode("name").InnerText; string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = string.Format("【{0}】>Xhandler: 【{1}】{2}{3}{4}.{5}{6}", DateTime.Now.ToString("HH:mm:ss:fff"), strMethodName, Properties.MachineRunResource.strProgress, Properties.RunUltrasonicResource.strUltrasonicFail, ret.AlarmInfo, Properties.Resources.strBoardPosition, ultrasonicData.positionText); launchView.AddLogs(log); } else { log = string.Format("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: ultrasonic is fail on " + ultrasonicData.positionText + " lattice! error information:" + ret.AlarmInfo); launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; if (!launchView.isRemotingOper) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunUltrasonicResource.strFailWhatToDo : "ultrasonic is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); } if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试 { return DoUltrasonic(launchView, xmlEnv, methodNode, isSimulator, latticeName); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) // 终止 { return 2; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过 { return 1; } } else { launchView.currentIsLoadingTips = false; if (strCurrentCulture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.RunUltrasonicResource.strUltrasonicSuccess.ToString() + "板位 " + ultrasonicData.positionText); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress:ultrasonic is success on " + methodNode.SelectSingleNode("position / text").InnerText + " lattice!"); } } #endregion return 0; } #endregion #region 检查枪头 /// /// 检查枪头 /// /// /// /// /// /// 0:正常;1:继续;2:停止 /// 挑选转运方法会传值,挑菌点位是不定的 public static int ExecuteADPCheckTip(RunWnd launchView, bool isSimulator) { #region 任务被取消 if (launchView._cancelSource.IsCancellationRequested) { return 2; } #endregion string strCurrentCulture = Shared.SoftwareInformation.currentculture; bool isExist = false; int retN = ADPBll.ExecuteADPCheckTip(out isExist, false); if (retN != 0) { OperateDialog plsConfirmOper = null; if (!launchView.isRemotingOper) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.MachineRunResource.strCheckTipFailWhatToDo : "check tip is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); } if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry)//重试 { return ExecuteADPCheckTip(launchView, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel)//终止 { return 2; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue)//跳过 { return 1; } } else if (isExist) // 检查正常 && 有枪头 { PlsToolTipWin plsToolTipWin = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsToolTipWin = new PlsToolTipWin("机械臂将在垃圾位卸载Tip头?"); plsToolTipWin.ShowDialog(); })); // 确认卸载 if (plsToolTipWin.DialogResult == true && !isSimulator) { // 卸载枪头 string strMsg = new UnloadTipsControl(Shared.SoftwareInformation.currentculture).UnLoadTip(); if (!string.IsNullOrEmpty(strMsg)) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsToolTipWin = new PlsToolTipWin(strMsg); plsToolTipWin.ShowDialog(); })); return 2; } } } return 0; } #endregion #region 清除Tip缓存数据 /// /// 清除Tip缓存数据 /// /// /// labwareTip = null: Tip全清除 public static void ClearTipData(RunWnd lauchView, Labware labwareTip = null) { if (labwareTip == null) { lauchView.currentWellLatticeId = string.Empty; lauchView.currentInValidWell = string.Empty; lauchView.currentIsLoadingTips = false; lauchView.currentLengthOfTip = 0; CurrentLengthOfTip = 0; lauchView.dataTableTotal.Clear(); } CurrentLengthOfTip = 0; var platformNodeList = lauchView.xmlDocument.SelectSingleNode("root/env").SelectNodes("platform"); // wellstip恢复, 本方法重新执行 foreach (XmlNode platformNodeItem in platformNodeList) { string latticeId = platformNodeItem.SelectSingleNode("lattice_id").InnerText; XmlNodeList labwareNode = platformNodeItem.SelectNodes("labware"); int countOfLabware = labwareNode.Count; if(countOfLabware==0) { continue; } string labwareId = string.Empty; string latticeNum = string.Empty; var labwareXml = platformNodeItem.SelectSingleNode("labware[@id=" + (countOfLabware).ToString() + "]"); if (labwareXml != null) { labwareId = labwareXml.SelectSingleNode("labware_id").InnerText; latticeNum = labwareXml.SelectSingleNode("labware_sname").InnerText; if (labwareId == null || labwareId.Equals("")) { continue; } } else { continue; } Labware labWare = LabwareDB.GetLabware(labwareId); // 清除特定Tip Or 全清除 if ((labwareTip != null && labwareTip.labware_id.Equals(labWare.labware_id)) || labwareTip == null) { if (labWare.labware_type_id != EnumManagement.GetEnumValue(ConsumableTypeEnum.TipsBox).ToString()) // 吸头盒 { continue; } //latticeId = ControlCom.GetLatticeId(Convert.ToInt32(latticeId)).ToString(); //查找出此设备所有枪对应的板位id int armCount= Shared.DeviceArmList.Where(x => x.arm_type.Equals(1)).ToList().Count; List deviceArms = Shared.DeviceArmList.Where(x => x.arm_type.Equals(1)).ToList(); string[] strPos = new string[armCount]; string baseLatticeId = latticeId; for (int i = 0; i < armCount; i++) { TabletopTemplate tabletopTemplate = TabletopTemplateDB.GetCurrentAppTabletopTemplateCollectionFromdb(); //增加台面模板判断 if (tabletopTemplate == null) { latticeId = ControlCom.GetLatticeId(Convert.ToInt32(baseLatticeId)).ToString(); } else { string latticeNumber = "P" + baseLatticeId; latticeId = LatticeDB.GetLatticeDataByLatticeNumAndTempIdFromdb(latticeNumber, Convert.ToInt32(deviceArms[i].device_arm_id), Shared.SoftwareInformation.software_device_number, tabletopTemplate.tabletopid).lattice_id; } var selUsedWellLattice = RunWnd.currentIsUsedWellLattice.Where(x => x.dropdown_id.Equals(latticeId)); if (selUsedWellLattice.Any()) { List usedWellLatticeList = selUsedWellLattice.ToList(); // 清除当前被使用过的板位和孔对象 foreach (var selUsedWellLatticeItem in usedWellLatticeList) { RunWnd.currentIsUsedWellLattice.Remove(selUsedWellLatticeItem); } } } // 设置有效孔位 string validWells = ComUtility.GetValidWells((int)labWare.number_row, (int)labWare.number_column); labwareXml.SelectSingleNode("allValidWells").InnerText = labwareXml.SelectSingleNode("residueValidWells").InnerText = validWells; foreach (var canvasItem in lauchView.gridTable.Children) { Canvas canvas = canvasItem as Canvas; if (canvas.Children.Count < 2) { continue; } ControlLabware control = Utilities.FindVisualChild(canvas); if (control == null || !control.Label.Equals(latticeNum)) { continue; } control.ValidWells = validWells; if (canvas.DataContext != null) { LabwareEx labwareEx = (LabwareEx)canvas.DataContext; labwareEx.validWells = validWells; } foreach (Canvas gridTest in lauchView.mainWindow.testDesign.gridTable.Children) { ControlLabware controlLbw = (ControlLabware)Utilities.FindVisualChild(gridTest); if (controlLbw != null && canvas.Name.Equals(gridTest.Name)) { ControlLabware controlTest = Utilities.FindVisualChild(gridTest); if (controlTest == null) { continue; } controlTest.ValidWells = validWells; if (gridTest.DataContext != null) { LabwareEx labwareEx = (LabwareEx)gridTest.DataContext; labwareEx.validWells = validWells; } } } } } } } #endregion #region 获取台面孔位坐标 /// /// 获取台面孔位坐标 /// /// /// /// public static List GenerateWellCoordinate(Labware labware, Lattice lattice) { int posVal = 0; // 原点坐标:左上角 if (Shared.SoftwareInformation.originType == EnumManagement.GetEnumValue(OriginTypeEnum.LeftTop)) { posVal = 2; } // 原点坐标:右上角 else if (Shared.SoftwareInformation.originType == EnumManagement.GetEnumValue(OriginTypeEnum.RightTop)) { posVal = 3; } // 获取目标板位上孔坐标数据 DataTable dtWellDes = wellCalc.GenerateWellCoordinate(labware, lattice, posVal); List lstWells = new List(); // dt 转化为实体类对象集合 for (int k = 0; k < dtWellDes.Rows.Count; k++) { TipsTable wellDes = new TipsTable(); wellDes.labware_id = dtWellDes.Rows[k]["labware_id"].ToString(); wellDes.lattice_id = dtWellDes.Rows[k]["lattice_id"].ToString(); wellDes.wellname = dtWellDes.Rows[k]["wellname"].ToString(); wellDes.axis_b_X = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_X"].ToString()); wellDes.axis_b_Y = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_Y"].ToString()); wellDes.axis_b_Z = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_Z"].ToString()) - ControlCom.CurrentLengthOfTip; // - 枪头突出长度 = 带枪头扎到最底的高度 wellDes.well_top_shape = Convert.ToInt32(dtWellDes.Rows[k]["well_top_shape"].ToString()); wellDes.lattice_num = dtWellDes.Rows[k]["lattice_num"].ToString(); wellDes.axis_b_r = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_r"].ToString()); wellDes.isUsed = Convert.ToInt32(dtWellDes.Rows[k]["isUsed"].ToString()); lstWells.Add(wellDes); } return lstWells; } #endregion #region 获取台面孔位坐标 /// /// 获取台面孔位坐标 /// /// /// /// public static List GenerateWellCoordinateForChemistry(Labware labware, Lattice lattice) { int posVal = 0; // 原点坐标:左上角 if (Shared.SoftwareInformation.originType == EnumManagement.GetEnumValue(OriginTypeEnum.LeftTop)) { posVal = 2; } // 原点坐标:右上角 else if (Shared.SoftwareInformation.originType == EnumManagement.GetEnumValue(OriginTypeEnum.RightTop)) { posVal = 3; } // 获取目标板位上孔坐标数据 DataTable dtWellDes = wellCalc.GenerateWellCoordinateForChemsitry(labware, lattice, posVal); List lstWells = new List(); // dt 转化为实体类对象集合 for (int k = 0; k < dtWellDes.Rows.Count; k++) { TipsTable wellDes = new TipsTable(); wellDes.labware_id = dtWellDes.Rows[k]["labware_id"].ToString(); wellDes.wellname = dtWellDes.Rows[k]["wellname"].ToString(); wellDes.axis_b_X = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_X"].ToString()); wellDes.axis_b_Y = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_Y"].ToString()); wellDes.axis_b_Z = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_Z"].ToString()) - ControlCom.CurrentLengthOfTip; // - 枪头突出长度 = 带枪头扎到最底的高度 wellDes.well_top_shape = Convert.ToInt32(dtWellDes.Rows[k]["well_top_shape"].ToString()); wellDes.lattice_num = dtWellDes.Rows[k]["lattice_num"].ToString(); wellDes.axis_b_r = (float)Convert.ToDouble(dtWellDes.Rows[k]["axis_b_r"].ToString()); wellDes.isUsed = Convert.ToInt32(dtWellDes.Rows[k]["isUsed"].ToString()); lstWells.Add(wellDes); } return lstWells; } #endregion #region 根据labwareId获取当前台面上布局的所有同类耗材的孔坐标数据--吸头盒子 public static DataTable GenerateCurrentTablayoutWellCoordinate(Labware labware, List lattices) { int posVal = 0; // 原点坐标:左上角 if (Shared.SoftwareInformation.originType == EnumManagement.GetEnumValue(OriginTypeEnum.LeftTop)) { posVal = 2; } // 原点坐标:右上角 else if (Shared.SoftwareInformation.originType == EnumManagement.GetEnumValue(OriginTypeEnum.RightTop)) { posVal = 3; } DataTable dtWellCoordinate = wellCalc.GenerateCurrentTablayoutWellCoordinate(labware, lattices, posVal); return dtWellCoordinate; } #endregion #region 获取孔位信息 /// /// 获取孔位信息 /// /// /// /// /// /// /// /// public static TipsTable GetWellInfo(Labware labware, Lattice lattice, int latticeId, string labwareId, string wellName) { // 存放目标板所有孔位坐标 // 获取板位孔的坐标数据 List lstWellDes = ControlCom.GenerateWellCoordinate(labware, lattice); // 获取目标板上指定孔位的坐标 TipsTable targetWellInfo = lstWellDes.SingleOrDefault(t => t.lattice_id.Equals(latticeId.ToString()) && t.labware_id.Equals(labwareId) && t.wellname.Equals(wellName)); return targetWellInfo; } #endregion #region 挑菌前吸液 /// /// 挑菌前吸液 /// /// /// /// /// /// /// /// /// /// 挑菌方式为吸液时:None以外 /// /// public static bool DoBeforeAspirate(RunWnd launchView, XmlNode xmlEnv, string methodName, MethodChoiceAgoAspirateChild choiceAgoAspirateData, Lattice latticeAspirate, string wellName, string labwareId, string plateBarcode, bool isSimulator) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; string log = string.Empty; #region 数据准备 string liquididText = choiceAgoAspirateData.liquididText1; string liquididValue = choiceAgoAspirateData.liquididValue1; string liquidrangeidText = choiceAgoAspirateData.liquidrangeidText1; string liquidrangeidValue = choiceAgoAspirateData.liquidrangeidValue1; string liquidpidText = choiceAgoAspirateData.liquidpidText1; string liquidpidValue = choiceAgoAspirateData.liquidpidValue1; #endregion // 吸液耗材板位存在 if (latticeAspirate != null) { // 获取吸液耗材 Labware labwareAspirate = LabwareDB.GetLabware(labwareId); //int nLatticeIdAspirate = ControlCom.GetLatticeId(Convert.ToInt32(latticeAspirate.lattice_id)); // 获取孔位信息 TipsTable targetWellInfo = ControlCom.GetWellInfo(labwareAspirate, latticeAspirate, Convert.ToInt32(latticeAspirate.lattice_id), labwareId, wellName); // 液体参数 Liquid liquid = LiquidDB.GetALiquidFromdb(liquidpidValue); #region 参数准备 AspirateMParam aspirateMParam = new AspirateMParam(); aspirateMParam.afterAirDelay = (int)liquid.after_aspirate_delay; // 后吸空气的延迟时间ms aspirateMParam.armId = Convert.ToInt32(choiceAgoAspirateData.armValue); // 吸液所用机械臂Id aspirateMParam.aspirateAcceleration = (float)liquid.aspirate_acceleration; // 吸液时电机的加速度 微升/秒平方 aspirateMParam.aspirateDeceleration = (float)liquid.aspirate_deceleration; // 吸液时电机的减速度 微升/秒平方 aspirateMParam.aspirateDelay = (int)liquid.aspirate_delay; // 吸液时电机的延迟等待时间ms aspirateMParam.aspirateEnterSpeed = (float)liquid.aspirate_enter_speed; // 吸液时进入孔内的时速 aspirateMParam.aspirateOutSpeed = (float)liquid.aspirate_out_speed; // 吸液时出孔的时速 aspirateMParam.aspirateSpeed = (float)liquid.aspirate_speed; // 吸液时电机速度,微升/秒 aspirateMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]); // z轴默认安全坐标点距 aspirateMParam.beforeAirDelay = (int)liquid.before_aspirate_delay; // 前吸空气的延迟时间ms #region 后吸空气的体积 if ((float)liquid.after_aspirate_volume == 0f) { aspirateMParam.isAfterAir = false; } else { aspirateMParam.isAfterAir = true; aspirateMParam.afterAirpAxisVal = (float)liquid.after_aspirate_volume; } #endregion #region 前吸空气的体积 if (liquid.before_aspirate_volume == 0d) { aspirateMParam.isBeforeAir = false; } else { aspirateMParam.isBeforeAir = true; aspirateMParam.beforeAirpAxisVal = (float)liquid.before_aspirate_volume; } #endregion #region 吸液后多吸液体的体积 if (liquid.after_a_liquid_volume == 0d) { aspirateMParam.isIncLiquidAfter = false; } else { aspirateMParam.isIncLiquidAfter = true; aspirateMParam.IncLiquidAfterpAxisVal = (float)liquid.after_a_liquid_volume; } #endregion #region 吸液前多吸液体的体积 if (liquid.before_a_liquid_volume == 0d) { aspirateMParam.isIncLiquidBefore = false; } else { aspirateMParam.isIncLiquidBefore = true; aspirateMParam.IncLiquidBeforepAxisVal = (float)liquid.before_a_liquid_volume; } #endregion // 所吸液体的体积大小归类:1:0.5-20ul;2:2-200ul:3:10-1000ul aspirateMParam.liquidVolumeType = (int)Convert.ToInt32((liquid.liquid_volume_type != null ? "1" : liquid.liquid_volume_type)); // 精度校准后的体积 LiquidAccuracy liquidAccuracy = liquidAccuracyBll.GetLiquidAccuracyFromdb(Convert.ToInt32(liquidrangeidValue), Convert.ToInt32(aspirateMParam.armId), Convert.ToDouble(choiceAgoAspirateData.wellvolume), liquididValue); double targetVolume = liquidAccuracyBll.CalculateAspirateParamVolume(Convert.ToDouble(choiceAgoAspirateData.wellvolume), liquidAccuracy); if (liquid.aspirate_is_knock_wall == 0) { aspirateMParam.isKnockWall = false; // 是否碰壁 } else { aspirateMParam.isKnockWall = true; aspirateMParam.knockDirection = (int)liquid.knock_direction; aspirateMParam.knockSpeed = (float)liquid.knock_speed; aspirateMParam.knockWallDelay = (int)liquid.knock_wall_delay; aspirateMParam.knockWellxOryAxisVal = (float)liquid.knock_wall_length; aspirateMParam.knockWellzAxisVal = (float)liquid.knock_well_height; } aspirateMParam.isMix = false; aspirateMParam.mixAspirateDistance = 0; aspirateMParam.mixAspirateSpeed = 100; aspirateMParam.mixDispenseDistance = 0; aspirateMParam.mixDispenseSpeed = 100; aspirateMParam.xAxisVal = targetWellInfo.axis_b_X; // x轴移动到的坐标点距 aspirateMParam.yAxisVal = targetWellInfo.axis_b_Y; // y轴移动到的坐标点距 float zVal = targetWellInfo.axis_b_Z + ControlCom.CurrentLengthOfTipOffSetVal; aspirateMParam.wellzAxisVal = zVal - (float)labwareAspirate.well_height; // z轴孔位平面的坐标点距 string[] zOffsiteArray = liquid.aspirate_well_bottom_length.Split(','); if (liquid.aspirate_position_type == 0) // 0:Liquid(液面) { } else if (liquid.aspirate_position_type == 1) // 1:孔口以下 { zVal = aspirateMParam.wellzAxisVal + (float)Convert.ToDouble(zOffsiteArray[0]); } else if (liquid.aspirate_position_type == 2) // 2:孔底部 { zVal = zVal - (float)Convert.ToDouble(zOffsiteArray[0]); } // 吸液z轴移动坐标点距 aspirateMParam.zAxisVal = zVal < 0 ? 0 : zVal; // 吸液泵轴体积转化的坐标点距 aspirateMParam.pAxisVal = (float)targetVolume == 0f ? 20f : (float)targetVolume; // 混合吸液z轴初始移动坐标点距(相对吸液距离) aspirateMParam.mixzAxisVal = 0f; #endregion return ControlCom.RunAspirateSingle(launchView, methodName, aspirateMParam, targetWellInfo, wellName, latticeAspirate.lattice_num, plateBarcode, isSimulator); } else { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunAspirateResource.strWithoutLattice; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodName + "】progress: the lattice of aspirate liquid is wrong! please check!"; launchView.AddLogs(log); } return false; } } /// /// 执行吸液 /// /// /// /// /// /// /// /// /// /// private static bool RunAspirateSingle(RunWnd launchView, string methodName, AspirateMParam aspirateMParam, TipsTable targetWellInfo, string wellName, string latticeNum, string plateBarcode, bool isSimulator = false) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; string log = string.Empty; launchView.UpdateLabwareWells(targetWellInfo, new string[] { wellName }, 2); // 正在吸液 DateTime startTime = DateTime.Now; HxResult ret = aspirateBll.ExecuteAspirate(aspirateMParam, isSimulator); DateTime endTime = DateTime.Now; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.RunAspirateResource.strAspirateFail.ToString() + ret.AlarmInfo + "孔:" + wellName + ", 板位:" + latticeNum; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress: Aspirate was failed on " + wellName + " of " + latticeNum + " lattice! Error info:" + ret.AlarmInfo; launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunAspirateResource.strFailWhatToDo : "Aspirate is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试 { return RunAspirateSingle(launchView, methodName, aspirateMParam, targetWellInfo, wellName, latticeNum, plateBarcode, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) // 终止 { if (!"None".Equals(plateBarcode)) { launchView.addChoiceDataIntoReport(null, latticeNum, "0", new string[] { wellName }, "block", "", startTime, endTime, "Aspirate", plateBarcode); } return false; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过 { if (!"None".Equals(plateBarcode)) { launchView.addChoiceDataIntoReport(null, latticeNum, "0", new string[] { wellName }, "block", "", startTime, endTime, "Aspirate", plateBarcode); } return true; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunAspirateResource.strAspirateSuccess + " 孔位:" + wellName + ", 板位:" + latticeNum; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress:Aspirate was successful on " + wellName + " of " + latticeNum + " lattice!"; launchView.AddLogs(log); } if (!"None".Equals(plateBarcode)) { launchView.addChoiceDataIntoReport(null, latticeNum, "0", new string[] { wellName }, "pass", "", startTime, endTime, "Aspirate", plateBarcode); } } return true; } #endregion #region 执行放液 /// /// 放液 /// /// /// /// /// /// /// /// /// /// public static bool DoDispense(RunWnd launchView, string strMethodName, MethodChoiceAgoAspirateChild choiceAgoAspirateData, Labware labwareDispense, Lattice latticeDispense, TipsTable targetWellInfo, string strDesLabwareBarcode, bool isSimulator) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; string log = string.Empty; #region 数据准备 string liquididText = choiceAgoAspirateData.liquididText1; string liquididValue = choiceAgoAspirateData.liquididValue1; string liquidrangeidText = choiceAgoAspirateData.liquidrangeidText1; string liquidrangeidValue = choiceAgoAspirateData.liquidrangeidValue1; string liquidpidText = choiceAgoAspirateData.liquidpidText1; string liquidpidValue = choiceAgoAspirateData.liquidpidValue1; //string strWell = dataTable.Rows[6 * i * iDouble + baseCoatCount][methodCoatingFile.destinationWell].ToString();//目标板孔位 #endregion // 获取液体参数 Liquid liquid = LiquidDB.GetALiquidFromdb(liquidpidValue); #region 参数 DispenseMParam dispenseMParam = new DispenseMParam(); dispenseMParam.afterAirDelay = (int)liquid.after_dispense_delay; // 排后吸空气的延迟时间s dispenseMParam.armId = Convert.ToInt32(choiceAgoAspirateData.armValue); // 排液所用机械臂Id dispenseMParam.dispenseAcceleration = (float)liquid.dispense_acceleration; // 排液时电机的加速度 dispenseMParam.dispenseDeceleration = (float)liquid.dispense_deceleration; // 排液时电机的减速度 dispenseMParam.dispenseDelay = (int)liquid.dispense_delay; // 排液时电机的延迟等待时间s dispenseMParam.dispenseEnterSpeed = (float)liquid.dispense_enter_speed; // 进孔速度 dispenseMParam.dispenseOutSpeed = (float)liquid.dispense_out_speed; // 出孔速度 dispenseMParam.dispenseSpeed = (float)liquid.dispense_speed; // 排液速度 dispenseMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]); // z轴默认安全坐标点距 dispenseMParam.beforeAirDelay = (int)liquid.before_dispense_delay; // 前吸空气的延迟时间s #region 后吸空气 if ((float)liquid.after_dispense_volume == 0f) { dispenseMParam.isAfterAir = false; } else { dispenseMParam.isAfterAir = true; dispenseMParam.afterAirpAxisVal = (float)liquid.after_dispense_volume; } #endregion #region 前吸空气 if (liquid.before_dispense_volume == 0d) { dispenseMParam.isBeforeAir = false; } else { dispenseMParam.isBeforeAir = true; dispenseMParam.beforeAirpAxisVal = (float)liquid.before_dispense_volume; } #endregion //aspirateMParamWH.liquidVolumeType = (int)Convert.ToInt32((liquid.liquid_volume_type != null ? "1" : liquid.liquid_volume_type)); // 获取液体参数校准的数据 LiquidAccuracyBll liquidAccuracyBll = new LiquidAccuracyBll(); LiquidAccuracy liquidAccuracy = liquidAccuracyBll.GetLiquidAccuracyFromdb(Convert.ToInt32(liquidrangeidValue), Convert.ToInt32(dispenseMParam.armId), Convert.ToDouble(choiceAgoAspirateData.wellvolume), liquididValue); double targetVolume = liquidAccuracyBll.CalculateAspirateParamVolume(Convert.ToDouble(choiceAgoAspirateData.wellvolume), liquidAccuracy); #region 排液后碰壁 if (liquid.dispense_is_knock_wall == 0) { dispenseMParam.isKnockWall = false; } else { dispenseMParam.isKnockWall = true; dispenseMParam.knockDirection = (int)liquid.dispense_knock_direction; dispenseMParam.knockSpeed = (float)liquid.dispense_knock_speed; dispenseMParam.knockWallDelay = (int)liquid.dispense_knock_wall_delay; dispenseMParam.knockWellxOryAxisVal = (float)liquid.dispense_knock_wall_length; dispenseMParam.knockWellzAxisVal = (float)liquid.dispense_knock_well_height; } #endregion dispenseMParam.isMix = false; dispenseMParam.mixAspirateDistance = 0; dispenseMParam.mixAspirateSpeed = 100; dispenseMParam.mixDispenseDistance = 0; dispenseMParam.mixDispenseSpeed = 100; dispenseMParam.enableVolumeToNull = true; dispenseMParam.xAxisVal = targetWellInfo.axis_b_X; dispenseMParam.yAxisVal = targetWellInfo.axis_b_Y; dispenseMParam.mixzAxisVal = 0f; float zVal = targetWellInfo.axis_b_Z + ControlCom.CurrentLengthOfTipOffSetVal; dispenseMParam.wellzAxisVal = zVal - (float)labwareDispense.well_height; // 吸液位置类型 if (liquid.dispense_position_type == 0) // 0:Liquid(液面) { } else if (liquid.dispense_position_type == 1) // 1:孔底部 { zVal = dispenseMParam.wellzAxisVal + (float)liquid.dispense_well_bottom_length; } else if (liquid.dispense_position_type == 2) // 2:孔口以下 { zVal = zVal - (float)liquid.dispense_well_bottom_length; } dispenseMParam.zAxisVal = zVal < 0 ? 0 : zVal; dispenseMParam.pAxisVal = (float)targetVolume == 0f ? 20f : (float)targetVolume; #endregion // 放液 return RunDispenseSingle(launchView, strMethodName, dispenseMParam, targetWellInfo, latticeDispense, strDesLabwareBarcode, isSimulator); } /// /// 执行放液 /// /// /// /// /// /// /// /// /// private static bool RunDispenseSingle(RunWnd launchView, string strMethodName, DispenseMParam dispenseMParam, TipsTable targetWellInfo, Lattice latticeDispense, string strLabwareBarcode, bool isSimulator = false) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; launchView.UpdateLabwareWells(targetWellInfo, new string[] { targetWellInfo.wellname }, 3); // 正在放液水红色 DateTime startTime = DateTime.Now; HxResult ret = dispenseBll.ExecuteDispense(dispenseMParam, isSimulator); DateTime endTime = DateTime.Now; string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunDispenseResource.strDispenseFail + " 孔位:" + targetWellInfo.wellname + ", 板位:" + latticeDispense.lattice_num + Properties.MachineRunResource.strError + ret.AlarmInfo; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: Dispense was failed on " + targetWellInfo.wellname + " of " + latticeDispense.lattice_num + " lattice! Error info:" + ret.AlarmInfo; launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunDispenseResource.strFailWhatToDo : "Dispense is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试 { return RunDispenseSingle(launchView, strMethodName, dispenseMParam, targetWellInfo, latticeDispense, strLabwareBarcode, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) //终止 { launchView.addCoatingFinishDataIntoReport(null, latticeDispense.lattice_num, "0", new string[] { targetWellInfo.wellname }, "0", new string[] { }, strLabwareBarcode, startTime, endTime, "Dispense", 1, 0); return false; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过 { launchView.addCoatingFinishDataIntoReport(null, latticeDispense.lattice_num, "0", new string[] { targetWellInfo.wellname }, "0", new string[] { }, strLabwareBarcode, startTime, endTime, "Dispense", 1, 0); return true; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunDispenseResource.strDispenseSuccess + " 孔位:" + targetWellInfo.wellname + ", 板位:" + latticeDispense.lattice_num; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:Coating was successful on " + targetWellInfo.wellname + " of " + latticeDispense.lattice_num + " lattice!"; launchView.AddLogs(log); } // 放液完成颜色更新 launchView.UpdateLabwareWells(targetWellInfo, new string[] { targetWellInfo.wellname }, 4); // 放液完成绿色 launchView.addCoatingFinishDataIntoReport(null, latticeDispense.lattice_num, "0", new string[] { targetWellInfo.wellname }, "1", new string[] { }, strLabwareBarcode, startTime, endTime, "Dispense", 1, 0); } return true; } #endregion #region 吸液--多通道 public static bool DoAspirateForMulti(RunWnd launchView, string currentCulture, AspirateMultiParams aspirateParams, MultiChannel multiChannel, Labware labware, float dilutionVol, string strMethodName, string plateBarcode, bool isSimulator) { if (launchView._cancelSource.IsCancellationRequested) { return false; } #region 数据准备 string liquidTypeText = aspirateParams.liquidTypeText; string liquidTypeValue = aspirateParams.liquidTypeValue; string liquidRangeText = aspirateParams.liquidRangeText; string liquidRangeValue = aspirateParams.liquidRangeValue; string liquidText = aspirateParams.liquidText; string liquidValue = aspirateParams.liquidValue; #region No Used //double mixvolume = Convert.ToDouble(methodNode.SelectSingleNode("mixvolume").InnerText);//混合体积 //int mixcount = Convert.ToInt32(methodNode.SelectSingleNode("mixcount").InnerText);//混合次数 //string mixAspiratePositionText = methodNode.SelectSingleNode("mixAspiratePosition/text").InnerText;//吸液混合位置名称 //string mixAspiratePositionValue = methodNode.SelectSingleNode("mixAspiratePosition/value").InnerText;//吸液混合位置Id //double mixAspirateDistance = Convert.ToDouble(methodNode.SelectSingleNode("mixAspirateDistance").InnerText);//吸液混合时距离 //double mixAspirateSpeed = Convert.ToDouble(methodNode.SelectSingleNode("mixAspirateSpeed").InnerText);//吸液混合时速度 //string mixDispensePositionText = methodNode.SelectSingleNode("mixDispensePosition/text").InnerText;//排液混合位置名称 //string mixDispensePositionValue = methodNode.SelectSingleNode("mixDispensePosition/value").InnerText;//排液混合位置Id //double mixDispenseDistance = Convert.ToDouble(methodNode.SelectSingleNode("mixDispenseDistance").InnerText);//排液混合时距离 //double mixDispenseSpeed = Convert.ToDouble(methodNode.SelectSingleNode("mixDispenseSpeed").InnerText);//排液混合时速度 //bool enableLiquidSensor = methodNode.SelectSingleNode("enableLiquidSensor").InnerText.ToLower() == "true" ? true : false;//是否开启液面探测 //int liquidSensorCount = Convert.ToInt32(methodNode.SelectSingleNode("liquidSensorCount").InnerText);//液面探测次数 //double liquidSensorDistance = Convert.ToDouble(methodNode.SelectSingleNode("liquidSensorDistance").InnerText);//液面探测距离 //string liquidSensorDisIdText = methodNode.SelectSingleNode("liquidSensorDistance").InnerText;//未探测到液面时选项名称 //int liquidSensorDisIdValue = Convert.ToInt32(methodNode.SelectSingleNode("liquidSensorDisId").InnerText);//未探测到液面时选项Id //bool enableSensorBlock = methodNode.SelectSingleNode("enableSensorBlock").InnerText.ToLower() == "true" ? true : false;//是否开启堵塞探测 //double liquidSensorBlockDistance = Convert.ToDouble(methodNode.SelectSingleNode("liquidSensorBlockDistance").InnerText);//堵塞探测距离 //string liquidSensorBlockDisIdText = methodNode.SelectSingleNode("liquidSensorBlockDisId/text").InnerText;//未探测到堵塞时选项名称 //int liquidSensorBlockDisIdValue = Convert.ToInt32(methodNode.SelectSingleNode("liquidSensorBlockDisId/value").InnerText);//未探测到堵塞时选项Id #endregion #endregion // 液体参数 Liquid liquid = LiquidDB.GetALiquidFromdb(liquidValue); AspirateMParamSH aspirateMParam = new AspirateMParamSH(); aspirateMParam.channelCount = aspirateParams.channels.Length; aspirateMParam.channelId = aspirateParams.channels; aspirateMParam.afterAirDelay = (int)liquid.after_aspirate_delay; aspirateMParam.armId = Convert.ToInt32(aspirateParams.armValue); aspirateMParam.aspirateAcceleration = (float)liquid.aspirate_acceleration; aspirateMParam.aspirateDeceleration = (float)liquid.aspirate_deceleration; aspirateMParam.aspirateDelay = (int)liquid.aspirate_delay; aspirateMParam.aspirateEnterSpeed = (float)liquid.aspirate_enter_speed; aspirateMParam.aspirateOutSpeed = (float)liquid.aspirate_out_speed; aspirateMParam.aspirateSpeed = (float)liquid.aspirate_speed; aspirateMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]); aspirateMParam.beforeAirDelay = (int)liquid.before_aspirate_delay; #region 后吸空气的体积 if ((float)liquid.after_aspirate_volume == 0f) { aspirateMParam.isAfterAir = false; } else { aspirateMParam.isAfterAir = true; aspirateMParam.afterAirpAxisVal = (float)liquid.after_aspirate_volume; } #endregion #region 前吸空气的体积 if (liquid.before_aspirate_volume == 0d) { aspirateMParam.isBeforeAir = false; } else { aspirateMParam.isBeforeAir = true; aspirateMParam.beforeAirpAxisVal = (float)liquid.before_aspirate_volume; } #endregion #region 吸液后多吸液体的体积 if (liquid.after_a_liquid_volume == 0d) { aspirateMParam.isIncLiquidAfter = false; } else { aspirateMParam.isIncLiquidAfter = true; aspirateMParam.IncLiquidAfterpAxisVal = (float)liquid.after_a_liquid_volume; } #endregion #region 吸液前多吸液体的体积 if (liquid.before_a_liquid_volume == 0d) { aspirateMParam.isIncLiquidBefore = false; } else { aspirateMParam.isIncLiquidBefore = true; aspirateMParam.IncLiquidBeforepAxisVal = (float)liquid.before_a_liquid_volume; } #endregion #region 所吸液体的体积大小归类 aspirateMParam.liquidVolumeType = (int)Convert.ToInt32((liquid.liquid_volume_type != null ? "1" : liquid.liquid_volume_type)); aspirateMParam.wellzAxisVal = (float)liquid.well_top_length; #endregion #region 吸液后,是否碰壁 if (liquid.aspirate_is_knock_wall == 0) { aspirateMParam.isKnockWall = false; } else { aspirateMParam.isKnockWall = true; aspirateMParam.knockDirection = (int)liquid.knock_direction; aspirateMParam.knockSpeed = (int)Convert.ToInt32(liquid.knock_speed); aspirateMParam.knockWallDelay = (int)liquid.knock_wall_delay; aspirateMParam.knockWellxOryAxisVal = (float)liquid.knock_wall_length; aspirateMParam.knockWellzAxisVal = (float)liquid.knock_well_height; } #endregion float[] zAxisVals = new float[multiChannel.SrcPlateWells.Count]; float[] pVolmunVals = new float[multiChannel.SrcPlateWells.Count]; aspirateMParam.xAxisVal = multiChannel.SrcPlateWells[0].axis_b_X; aspirateMParam.yAxisVal = multiChannel.SrcPlateWells[0].axis_b_Y; if (multiChannel.SrcPlateWells.Count == 1) { aspirateMParam.yChannelGapVal = 20f; } else { aspirateMParam.yChannelGapVal = ((float)labware.a1_b1_distance).Equals(0f) ? 9f : (float)labware.a1_b1_distance; } aspirateMParam.zAxisVal = zAxisVals; aspirateMParam.pAxisVal = pVolmunVals; float pVolumnVas = 0f; for (int nSrcPlateIndex = 0; nSrcPlateIndex < multiChannel.SrcPlateWells.Count; nSrcPlateIndex++) { TipsTable well = multiChannel.SrcPlateWells[nSrcPlateIndex]; // 防止在安装tip之前计算的数据 Z轴值不正确的问题,再取一次! Lattice lattice = LatticeDB.GetLatticeDataByIdFromdb(well.lattice_id); List dtWells = ControlCom.GenerateWellCoordinate(labware, lattice); well = dtWells.FirstOrDefault(it => it.wellname.Equals(well.wellname)); pVolumnVas = dilutionVol; // 体积 // 获取液体校准的体积 LiquidAccuracy liquidAccuracy = liquidAccuracyBll.GetLiquidAccuracyFromdb(Convert.ToInt32(liquidRangeValue), Convert.ToInt32(aspirateMParam.armId), Convert.ToDouble(pVolumnVas), liquidValue); double targetVolume = liquidAccuracyBll.CalculateAspirateParamVolume(Convert.ToDouble(pVolumnVas), liquidAccuracy); float zVal = well.axis_b_Z + ControlCom.CurrentLengthOfTipOffSetVal; string[] zOffsiteArray = liquid.aspirate_well_bottom_length.Split(','); aspirateMParam.wellzAxisVal = zVal - (float)labware.well_height; if (liquid.aspirate_position_type == 0) { } else if (liquid.aspirate_position_type == 2) { zVal = zVal - (float)Convert.ToDouble(zOffsiteArray[0]); } else if (liquid.aspirate_position_type == 1) { zVal = aspirateMParam.wellzAxisVal + (float)Convert.ToDouble(zOffsiteArray[0]); } zAxisVals[nSrcPlateIndex] = zVal < 0 ? 0 : zVal; pVolmunVals[nSrcPlateIndex] = (float)targetVolume == 0f ? 20f : (float)targetVolume; } #region 混合 aspirateMParam.isMix = aspirateParams.isMix; aspirateMParam.mixzAxisVal = (float)Convert.ToDouble(aspirateMParam.zAxisVal[0]); if (aspirateMParam.isMix == true) { // TODO //aspirateMParamWH.mixAspiratePositionValue = Convert.ToInt32(mixAspiratePositionValue); //aspirateMParamWH.mixAspiratePositionText = mixAspiratePositionText; //if (mixAspiratePositionValue == "0")//liquid //{ //} //else if (mixAspiratePositionValue == "1")//top //{ // aspirateMParamWH.mixAspirateDistance = ((float)labware.well_height - (float)mixAspirateDistance); //} //else if (mixAspiratePositionValue == "2")//bottom //{ // aspirateMParamWH.mixAspirateDistance = (float)mixAspirateDistance; //} //aspirateMParamWH.mixAspirateSpeed = (float)Convert.ToDouble(mixAspirateSpeed); //aspirateMParamWH.mixDispensePositionValue = Convert.ToInt32(mixDispensePositionValue); //aspirateMParamWH.mixDispensePositionText = mixDispensePositionText; //if (mixDispensePositionValue == "0")//liquid //{ //} //else if (mixDispensePositionValue == "1")//top //{ // aspirateMParamWH.mixDispenseDistance = ((float)labware.well_height - (float)mixDispenseDistance); //} //else if (mixDispensePositionValue == "2")//bottom //{ // aspirateMParamWH.mixDispenseDistance = (float)mixDispenseDistance; //} //aspirateMParamWH.mixDispenseSpeed = (float)Convert.ToDouble(mixDispenseSpeed); //aspirateMParamWH.mixvolume = (float)mixvolume; //aspirateMParamWH.mixCount = mixcount; } else { aspirateMParam.mixAspirateDistance = 0; aspirateMParam.mixAspirateSpeed = 100; aspirateMParam.mixDispenseDistance = 0; aspirateMParam.mixDispenseSpeed = 100; } #endregion // 孔位集合 List wellNameList = multiChannel.SrcPlateWells.Select(it => it.wellname).ToList(); string wellName = string.Join(",", wellNameList); // 正在吸液颜色更新 launchView.UpdateLabwareWells(multiChannel.SrcPlateWells[0], wellNameList.ToArray(), 2); launchView.SetWaitOne(); // 暂停 DateTime startTime = DateTime.Now; HxResult ret = aspirateBll.ExecuteAspirate(aspirateMParam, isSimulator); DateTime endTime = DateTime.Now; // 板位集合 List latticeNumList = multiChannel.SrcPlateWells.Select(it => it.lattice_num).ToList(); latticeNumList = latticeNumList.Distinct().ToList(); string latticeNum = string.Join(",", latticeNumList); if (ret.Result != ResultType.Success) { if (currentCulture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.RunAspirateResource.strAspirateFail.ToString() + ret.AlarmInfo + "孔:" + wellName + ", 板位:" + latticeNum); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: Aspirate was failed on " + wellName + " of " + latticeNum + " lattice! Error info:" + ret.AlarmInfo); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(currentCulture.Equals("zh-CN") ? Properties.RunAspirateResource.strFailWhatToDo : "Aspirate is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试 { return DoAspirateForMulti(launchView, currentCulture, aspirateParams, multiChannel, labware, dilutionVol, strMethodName, plateBarcode, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) // 终止 { launchView.addChoiceDataIntoReport(null, latticeNum, dilutionVol.ToString(), wellNameList.ToArray(), "block", "", startTime, endTime, "Aspirate", plateBarcode); return false; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过 { launchView.addChoiceDataIntoReport(null, latticeNum, dilutionVol.ToString(), wellNameList.ToArray(), "block", "", startTime, endTime, "Aspirate", plateBarcode); return true; } return false; } else { if (currentCulture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunAspirateResource.strAspirateSuccess + " 孔位:" + wellName + ", 板位:" + latticeNum); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:Aspirate was successful on " + wellName + " of " + latticeNum + " lattice!"); } if (labware.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.Through).ToString()) // 试剂槽 { launchView.UpdateLabwareWells(multiChannel.SrcPlateWells[0], wellNameList.ToArray(), 1); // 无效孔白色 } launchView.addChoiceDataIntoReport(null, latticeNum, dilutionVol.ToString(), wellNameList.ToArray(), "pass", "", startTime, endTime, "Aspirate", plateBarcode); return true; } } #endregion #region 放液--多通道 public static bool DoDispenseForMulti(RunWnd launchView, string currentCulture, DispenseMultiParams dispenseParams, MultiChannel multiChannel, Labware labware, float dilutionVol, string strMethodName, string plateBarcode, bool isSimulator) { if (launchView._cancelSource.IsCancellationRequested) { return false; } #region 数据准备 string liquidTypeText = dispenseParams.liquidTypeText; string liquidTypeValue = dispenseParams.liquidTypeValue; string liquidRangeText = dispenseParams.liquidRangeText; string liquidRangeValue = dispenseParams.liquidRangeValue; string liquidText = dispenseParams.liquidText; string liquidValue = dispenseParams.liquidValue; float[] zAxisVals = new float[multiChannel.DesPlateWells.Count]; float[] pVolmunVals = new float[multiChannel.DesPlateWells.Count]; #endregion // 液体参数 Liquid liquid = LiquidDB.GetALiquidFromdb(liquidValue); DispenseMParamSH dispenseMParam = new DispenseMParamSH(); dispenseMParam.channelCount = dispenseParams.channels.Length; dispenseMParam.channelId = dispenseParams.channels; dispenseMParam.afterAirDelay = (int)liquid.after_dispense_delay; dispenseMParam.armId = Convert.ToInt32(dispenseParams.armValue); dispenseMParam.dispenseAcceleration = (float)liquid.dispense_acceleration; dispenseMParam.dispenseDeceleration = (float)liquid.dispense_deceleration; dispenseMParam.dispenseDelay = (int)liquid.dispense_delay; dispenseMParam.dispenseEnterSpeed = (float)liquid.dispense_enter_speed; dispenseMParam.dispenseOutSpeed = (float)liquid.dispense_out_speed; dispenseMParam.dispenseSpeed = (float)liquid.dispense_speed; dispenseMParam.basezAxisVal = (float)Convert.ToDouble(ConfigurationManager.AppSettings["zAxisSafeVal"]); dispenseMParam.beforeAirDelay = (int)liquid.before_dispense_delay; #region 后吸空气的体积,单位微升 if ((float)liquid.after_dispense_volume == 0f) { dispenseMParam.isAfterAir = false; } else { dispenseMParam.isAfterAir = true; dispenseMParam.afterAirpAxisVal = (float)liquid.after_dispense_volume; } #endregion #region 前吸空气的体积,单位微升 if (liquid.before_dispense_volume == 0d) { dispenseMParam.isBeforeAir = false; } else { dispenseMParam.isBeforeAir = true; dispenseMParam.beforeAirpAxisVal = (float)liquid.before_dispense_volume; } #endregion dispenseMParam.liquidVolumeType = (int)Convert.ToInt32((liquid.liquid_volume_type != null ? "1" : liquid.liquid_volume_type)); dispenseMParam.wellzAxisVal = (float)liquid.well_top_length; #region 排液后,是否碰壁 if (liquid.dispense_is_knock_wall == 0) { dispenseMParam.isKnockWall = false; } else { dispenseMParam.isKnockWall = true; dispenseMParam.knockDirection = (int)liquid.knock_direction; dispenseMParam.knockSpeed = (float)liquid.knock_speed; dispenseMParam.knockWallDelay = (int)liquid.knock_wall_delay; dispenseMParam.knockWellxOryAxisVal = (float)liquid.knock_wall_length; dispenseMParam.knockWellzAxisVal = (float)liquid.knock_well_height; } #endregion #region 是否混合 dispenseMParam.isMix = dispenseParams.isMix; dispenseMParam.mixvolume = (float)dispenseParams.mixvolume; dispenseMParam.mixCount = dispenseParams.mixCount; if (dispenseMParam.isMix == true) { #region 吸液参数 dispenseMParam.mixAspiratePositionValue = dispenseParams.mixAspiratePositionValue; dispenseMParam.mixAspiratePositionText = dispenseParams.mixAspiratePositionText; if (dispenseMParam.mixAspiratePositionValue == EnumManagement.GetEnumValue(MixPositionEnum.Liquid)) // liquid { } else if (dispenseMParam.mixAspiratePositionValue == EnumManagement.GetEnumValue(MixPositionEnum.Top)) // top { dispenseMParam.mixAspirateDistance = ((float)labware.well_height - dispenseParams.mixAspirateDistance); } else if (dispenseMParam.mixAspiratePositionValue == EnumManagement.GetEnumValue(MixPositionEnum.Bottom)) // bottom { dispenseMParam.mixAspirateDistance = dispenseParams.mixAspirateDistance; } dispenseMParam.mixAspirateSpeed = dispenseParams.mixAspirateSpeed; #endregion #region 放液参数 dispenseMParam.mixDispensePositionValue = Convert.ToInt32(dispenseParams.mixDispensePositionValue); dispenseMParam.mixDispensePositionText = dispenseParams.mixDispensePositionText; if (dispenseMParam.mixDispensePositionValue == EnumManagement.GetEnumValue(MixPositionEnum.Liquid)) // liquid { } else if (dispenseMParam.mixDispensePositionValue == EnumManagement.GetEnumValue(MixPositionEnum.Top)) // top { dispenseMParam.mixDispenseDistance = ((float)labware.well_height - (float)dispenseParams.mixDispenseDistance); } else if (dispenseMParam.mixDispensePositionValue == EnumManagement.GetEnumValue(MixPositionEnum.Bottom)) // bottom { dispenseMParam.mixDispenseDistance = (float)dispenseParams.mixDispenseDistance; } dispenseMParam.mixDispenseSpeed = (float)Convert.ToDouble(dispenseParams.mixDispenseSpeed); #endregion } else { dispenseMParam.mixAspirateDistance = 0; dispenseMParam.mixAspirateSpeed = 100; dispenseMParam.mixDispenseDistance = 0; dispenseMParam.mixDispenseSpeed = 100; } #endregion dispenseMParam.enableVolumeToNull = true; dispenseMParam.xAxisVal = multiChannel.DesPlateWells[0].axis_b_X; dispenseMParam.yAxisVal = multiChannel.DesPlateWells[0].axis_b_Y; if (multiChannel.DesPlateWells.Count == 1) { dispenseMParam.yChannelGapVal = 20f; } else { dispenseMParam.yChannelGapVal = ((float)labware.a1_b1_distance).Equals(0f) ? 9f : (float)labware.a1_b1_distance; } dispenseMParam.zAxisVal = zAxisVals; dispenseMParam.pAxisVal = pVolmunVals; // 精度校准后的体积 LiquidAccuracy liquidAccuracy = liquidAccuracyBll.GetLiquidAccuracyFromdb(Convert.ToInt32(liquidRangeValue), Convert.ToInt32(dispenseMParam.armId), Convert.ToDouble(dilutionVol), liquidTypeValue); double targetVolume = liquidAccuracyBll.CalculateAspirateParamVolume(dilutionVol, liquidAccuracy); for (int nDesPlateIndex = 0; nDesPlateIndex < multiChannel.DesPlateWells.Count; nDesPlateIndex++) { TipsTable well = multiChannel.DesPlateWells[nDesPlateIndex]; // 防止在安装tip之前计算的数据 Z轴值不正确的问题,再取一次! Lattice lattice = LatticeDB.GetLatticeDataByIdFromdb(well.lattice_id); List dtWells = ControlCom.GenerateWellCoordinate(labware, lattice); well = dtWells.FirstOrDefault(it => it.wellname.Equals(well.wellname)); float zVal = well.axis_b_Z + ControlCom.CurrentLengthOfTipOffSetVal; dispenseMParam.wellzAxisVal = zVal - (float)labware.well_height; if (liquid.dispense_position_type == 0) { } else if (liquid.dispense_position_type == 2) { zVal = zVal - (float)liquid.dispense_well_bottom_length; } else if (liquid.dispense_position_type == 1) { zVal = dispenseMParam.wellzAxisVal + (float)liquid.dispense_well_bottom_length; } zAxisVals[nDesPlateIndex] = zVal < 0 ? 0 : zVal; pVolmunVals[nDesPlateIndex] = (float)targetVolume == 0f ? 20f : (float)targetVolume; } dispenseMParam.mixzAxisVal = (float)Convert.ToDouble(dispenseMParam.zAxisVal[0]); // 孔位集合 List wellNameList = multiChannel.DesPlateWells.Select(it => it.wellname).ToList(); string wellName = string.Join(",", wellNameList); // 正在放液颜色更新 launchView.UpdateLabwareWells(multiChannel.DesPlateWells[0], wellNameList.ToArray(), 3); launchView.SetWaitOne(); // 暂停 DateTime startTime = DateTime.Now; HxResult ret = dispenseBll.ExecuteDispense(dispenseMParam, isSimulator); DateTime endTime = DateTime.Now; // 板位集合 List latticeNumList = multiChannel.DesPlateWells.Select(it => it.lattice_num).ToList(); latticeNumList = latticeNumList.Distinct().ToList(); string latticeNum = string.Join(",", latticeNumList); if (ret.Result != ResultType.Success) { if (currentCulture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunDispenseResource.strDispenseFail + " 孔位:" + wellName + ", 板位:" + latticeNum + Properties.MachineRunResource.strError + ret.AlarmInfo); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress: Dispense was failed on " + wellName + " of " + latticeNum + " lattice! Error info:" + ret.AlarmInfo); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(currentCulture.Equals("zh-CN") ? Properties.RunDispenseResource.strFailWhatToDo : "Dispense is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry) // 重试 { return DoDispenseForMulti(launchView, currentCulture, dispenseParams, multiChannel, labware, dilutionVol, strMethodName, plateBarcode, isSimulator); } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel) //终止 { launchView.addCoatingFinishDataIntoReport(null, latticeNum, dilutionVol.ToString(), wellNameList.ToArray(), "0", new string[] { }, plateBarcode, startTime, endTime, "Dispense", multiChannel.DesPlateWells.Count, 0); return false; } else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue) // 跳过 { launchView.addCoatingFinishDataIntoReport(null, latticeNum, dilutionVol.ToString(), wellNameList.ToArray(), "0", new string[] { }, plateBarcode, startTime, endTime, "Dispense", multiChannel.DesPlateWells.Count, 0); return true; } return false; } else { if (currentCulture.Equals("zh-CN")) { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunDispenseResource.strDispenseSuccess + " 孔位:" + wellName + ", 板位:" + latticeNum); } else { launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:Dispense was successful on " + wellName + " of " + latticeNum + " lattice!"); } // 放液完成颜色更新 if (labware.labware_type_id == EnumManagement.GetEnumValue(ConsumableTypeEnum.Through).ToString()) // 试剂槽 { launchView.UpdateLabwareWells(multiChannel.DesPlateWells[0], wellNameList.ToArray(), 1); // 无效孔白色 } else { launchView.UpdateLabwareWells(multiChannel.DesPlateWells[0], wellNameList.ToArray(), 4); // 放液完成绿色 } launchView.addCoatingFinishDataIntoReport(null, latticeNum, "0", wellNameList.ToArray(), "1", new string[] { }, plateBarcode, startTime, endTime, "Dispense", multiChannel.DesPlateWells.Count, 0); return true; } } #endregion #region 根据板位别名和台面信息xml查找到对应唯一板位节点 /// /// 根据板位别名和台面信息xml查找到对应唯一板位 /// /// /// /// public static XmlNode GetXmlNodeByBoardName(XmlNodeList platformList, string boardName) { XmlNode result = null; for (int i = 0; i < platformList.Count; i++) { XmlNodeList labwareNodeList = platformList[i].SelectNodes("labware"); var labwareSrcNode = labwareNodeList[0].SelectSingleNode("labware_sname[text()='" + boardName + "']"); if (labwareSrcNode != null) { result = platformList[i]; break; } } return result; } #endregion #region 把本次要装载的孔位集合按列分开 public static List> GetGroupTipsByColumn(List tipsTables) { List> tipsTablesList = new List>(); List colNumList = new List(); foreach (var tipItem in tipsTables) { colNumList.Add(ComUtility.GetColNum(tipItem.wellname)); } colNumList = colNumList.Distinct().ToList(); foreach (var colNumItem in colNumList) { var selColTips = tipsTables.Where(it => ComUtility.GetColNum(it.wellname) == colNumItem); if (selColTips.Any()) { List colTipList = selColTips.ToList(); //if (colTipList.Count != Shared.ChannelsId.Length) //{ // foreach (var tipItem in colTipList) // { // List newTipList = new List(); // newTipList.Add(tipItem); // tipsTablesList.Add(newTipList); // } //} //else //{ tipsTablesList.Add(colTipList); //} } } return tipsTablesList; } #endregion #region 从全局变量中查找对应的变量值 public static string SearchValueOfGlobalVariable(RunWnd runWnd,string strName) { Variable variableResult = null; Stack stackTem = new Stack();//临时存储变量过得对象 int totalLoop = runWnd.gloadVariable.Count; // 从当前变量字典中取出变量的值 for (int i = 0; i < totalLoop; i++) { Variable v = runWnd.gloadVariable.Pop(); //取出最近的一个匹配变量 stackTem.Push(v); if (v.variablename.Equals(strName)) { variableResult = v; break; } } int totalLoopTem = stackTem.Count; for (int i = 0; i < totalLoopTem; i++) { Variable v = stackTem.Pop(); runWnd.gloadVariable.Push(v); } //var searchResult = runWnd.gloadVariable.SingleOrDefault(x => x.variablename.Equals(strName)); if (variableResult != null) { return variableResult.variablecurval; } else { return ""; } } #endregion #region 从全局变量中查找对应的变量对象 public static Variable SearchGlobalVariable(RunWnd runWnd, string strName) { Variable searchResult=null; Stack stackTem = new Stack();//临时存储变量过得对象 int totalLoop = runWnd.gloadVariable.Count; // 从当前变量字典中取出变量的值 for (int i = 0; i < totalLoop; i++) { Variable v = runWnd.gloadVariable.Pop(); //取出最近的一个匹配变量 stackTem.Push(v); if (v.variablename.Equals(strName)) { searchResult = v; break; } } int totalLoopTem = stackTem.Count; for (int i = 0; i < totalLoopTem; i++) { Variable v = stackTem.Pop(); runWnd.gloadVariable.Push(v); } return searchResult; } #endregion #region 管架关联的管子底部厚度 /// /// 管架关联的管子底部厚度 /// /// 管架关联的管子json文本 /// 管子底部厚度 public static float CalculateWellBottomThickness(string jsonText) { float fWellBottomThickness = 0f; string labwareCentrifugalId = string.Empty; Labware centrifugalLabware = new Labware(); if (!string.IsNullOrEmpty(jsonText)) { JObject job = JObject.Parse(jsonText); JArray jArray = (JArray)job["list"]; if (jArray != null) { if (jArray.Count > 0) { labwareCentrifugalId = jArray[0]["labwereid"].ToString(); centrifugalLabware = LabwareDB.GetLabware(labwareCentrifugalId); } } } if (!string.IsNullOrEmpty(centrifugalLabware.labware_id)) { fWellBottomThickness = (float)centrifugalLabware.labware_height - ((float)centrifugalLabware.well_height + (float)centrifugalLabware.well_bottom_height); } return 0; } #endregion #region 获取管架关联的管子 /// /// 获取管架关联的管子 /// /// 管架关联的管子json文本 /// 管子对象 public static Labware GetCentrifugalLabwer(string jsonText) { string labwareCentrifugalId = string.Empty; Labware centrifugalLabware = new Labware(); if (!string.IsNullOrEmpty(jsonText)) { JObject job = JObject.Parse(jsonText); JArray jArray = (JArray)job["list"]; if (jArray != null) { if (jArray.Count > 0) { labwareCentrifugalId = jArray[0]["labwereid"].ToString(); centrifugalLabware = LabwareDB.GetLabware(labwareCentrifugalId); } } } return centrifugalLabware; } #endregion /// /// 把孔位文本重新排序为正常顺序 /// /// 待排序的孔串 /// 行数 /// 列数 /// public static string SortWellName(string strWellNameList,int rowNum=8,int column=12) { string strResult = string.Empty; //构建正常孔位字串 string baseWellList = ComUtility.GetValidWells(rowNum, column); string baseWellName = baseWellList;//"A1,B1,C1,D1,E1,F1,G1,H1,A2,B2,C2,D2,E2,F2,G2,H2,A3,B3,C3,D3,E3,F3,G3,H3,A4,B4,C4,D4,E4,F4,G4,H4,A5,B5,C5,D5,E5,F5,G5,H5,A6,B6,C6,D6,E6,F6,G6,H6,A7,B7,C7,D7,E7,F7,G7,H7,A8,B8,C8,D8,E8,F8,G8,H8,A9,B9,C9,D9,E9,F9,G9,H9,A10,B10,C10,D10,E10,F10,G10,H10,A11,B11,C11,D11,E11,F11,G11,H11,A12,B12,C12,D12,E12,F12,G12,H12"; string[] baseWellNameArray = baseWellName.Split(','); string[] strWellNameArray = strWellNameList.Split(','); for(int i=0;i /// 解析xml往Tree上绑定命令集 /// /// /// /// /// 是否从打开文件加载: true: 不加载keyId /// public static void BindWorkFlowIntoTree(XmlDocument xmlDocument, MethodEx rootMethod, TreeView treeviewWorkflow, Grid gridProperty1, bool isOpenFile, bool isSubMethod = false) { gridProperty = gridProperty1; // 方法 XmlNodeList xmlNodeMethodList = xmlDocument.SelectNodes("root/method"); rootMethod.Children.RemoveAt(rootMethod.Children.Count - 1); // 处理第一个节点 StartBll startBll = new StartBll(); MethodListBll methodListBll = new MethodListBll(); MethodStart methodStart = startBll.GenerateMethodStartDataByXmlNode(xmlNodeMethodList[0], isOpenFile); MethodEx mi = rootMethod.Children[0]; mi.tag = methodStart; if (mi.control != null) { (mi.control as StartProperty).methodStart = methodStart; } //开始和结尾不要,其他的方法循环绑定数据 for (int i = 1; i < xmlNodeMethodList.Count; i++) { string MethodName = xmlNodeMethodList[i].SelectSingleNode("label").InnerText; int iNum = methodListBll.getNumByMethodName(MethodName); MethodEx methodEx = null; switch (iNum) { case (int)MethodNameEnum.start: //m = this.GenerateMethodEx(xmlNodeMethodList[i]); //MethodStart methodStart = new MethodStart(); //StartBll startBll = new StartBll(); //methodStart = startBll.GenerateMethodStartDataByXmlNode(xmlNodeMethodList[i]); //m.tag= methodStart; //rootMethod.Children.Add(m); break; case (int)MethodNameEnum.loadtips: #region 安装吸头 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodLoadTips methodLoadTips = new MethodLoadTips(); LoadTipsBll loadTipsBll = new LoadTipsBll(); methodLoadTips = loadTipsBll.GenerateMethodLoadTipsDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodLoadTips; if (methodLoadTips != null) { methodEx.method_Tipcontent = string.Format("安装{0}", methodLoadTips.labwaretipText); } methodEx.isEnabled = methodLoadTips.status == "enable"; //Method_LoadTips(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.unloadtips: #region 卸载吸头 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodUnloadTips methodUnloadTips = new MethodUnloadTips(); UnloadTipsBll unloadTipsBll = new UnloadTipsBll(); methodUnloadTips = unloadTipsBll.GenerateMethodUnloadTipsDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodUnloadTips; methodEx.isEnabled = methodUnloadTips.status == "enable"; //Method_UnloadTips(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.end: #region 结束 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodEnd methodEnd = new MethodEnd(); EndBll endBll = new EndBll(); methodEnd = endBll.GenerateMethodEndDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodEnd; methodEx.isEnabled = methodEnd.status == "enable"; methodEx.canDrop = false; methodEx.Moveable = false; //Method_End(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.loop: #region 开始循环 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodLoop methodLoop = new MethodLoop(); LoopBll loopBll = new LoopBll(); methodLoop = loopBll.GenerateMethodLoopDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodLoop; if (methodLoop != null) { methodEx.method_Tipcontent = string.Format("从{0}到{1},递增{2}", methodLoop.variablesValue.ToString(), methodLoop.variableeValue.ToString(), methodLoop.incrementValue.ToString()); } methodEx.isEnabled = methodLoop.status == "enable"; //Method_Loop(methodEx); //testDesign.rootMethod.Children.Add(m); #endregion break; case (int)MethodNameEnum.endloop: #region 结束循环 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); methodEx.Children[methodEx.Children.Count - 1].isEnabled = new LoopBll().GenerateMethodLoopDataByXmlNode(xmlNodeMethodList[i]).status == "enable"; if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { sourceItem = null; methodExes[methodExes.Count - 1] = null; bool isAllNull = true; //循环向前找,找到最后一个不为null的,设置为sourceItem for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = methodExes[k]; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } methodExes.RemoveAt(methodExes.Count - 1); } else { bool isAllNull = true; int counAllNull = 0;//计算不为Null的个数 for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { counAllNull++; } } //循环向前找,找到最后一个不为null的,设置为null for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = null; methodExes[k] = null; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } else { if (counAllNull == 1) { rootMethod.Children.Add(methodEx); } } } } else { rootMethod.Children.Add(methodEx); sourceItem = null; methodExes[methodExes.Count - 1] = null; } #endregion break; case (int)MethodNameEnum.aspirate: #region 吸液 methodEx = GenerateMethodEx(xmlNodeMethodList[i],rootMethod); MethodAspirate methodAspirate = new MethodAspirate(); AspirateBll aspirateBll = new AspirateBll(); methodAspirate = aspirateBll.GenerateMethodAspirateDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodAspirate; if (methodAspirate != null) { methodEx.method_Tipcontent = string.Format("{0};{1}", methodAspirate.positionText, methodAspirate.wellvolume); } methodEx.isEnabled = methodAspirate.status == "enable"; //Method_Aspirate(methodEx); //treeviewWorkflow.SelectedItem = m; if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.dispense: #region 排液 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodDispense methodDispense = new MethodDispense(); DispenseBll dispenseBll = new DispenseBll(); methodDispense = dispenseBll.GenerateMethodDispenseDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodDispense; if (methodDispense != null) { methodEx.method_Tipcontent = string.Format("{0};{1}", methodDispense.positionText, methodDispense.wellvolume); } methodEx.isEnabled = methodDispense.status == "enable"; //Method_Dispense(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.mixing: #region 混合 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodMixing methodMixing = new MethodMixing(); MixingBll mixingBll = new MixingBll(); methodMixing = mixingBll.GenerateMethodMixingDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodMixing; if (methodMixing != null) { methodEx.method_Tipcontent = string.Format("{0};{1}", methodMixing.positionText, methodMixing.mixcount); } methodEx.isEnabled = methodMixing.status == "enable"; //Method_Mix(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.transferfile: #region 文件 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodTransferFile methodTransferFile = new MethodTransferFile(); TransferFileBll transferFileBll = new TransferFileBll(); methodTransferFile = transferFileBll.GenerateMethodTransferFileDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodTransferFile; methodEx.isEnabled = methodTransferFile.status == "enable"; //Method_File(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.griptransport: #region 抓板转移 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodGripTransport methodGripTransport = new MethodGripTransport(); GripTransportBll gripTransportBll = new GripTransportBll(); methodGripTransport = gripTransportBll.GenerateMethodGripTransport(xmlNodeMethodList[i]); methodEx.tag = methodGripTransport; if (methodGripTransport != null) { methodEx.method_Tipcontent = string.Format("从{0}到{1}", methodGripTransport.srcPositionText, methodGripTransport.desPositionText); } methodEx.isEnabled = methodGripTransport.status == "enable"; //Method_GripTransport(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.gripmove: #region 移动夹爪 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodGripMove methodGripMove = new MethodGripMove(); GripMoveBll gripMoveBll = new GripMoveBll(); methodGripMove = gripMoveBll.GenerateMethodGripMove(xmlNodeMethodList[i]); methodEx.tag = methodGripMove; methodEx.isEnabled = methodGripMove.status == "enable"; //Method_GripMove(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.holdingLabware: #region 夹爪保持开始 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodHoldingLabware methodHoldingLabware = new HoldingLabwareBll().GenerateMethodBeginHoldingLabware(xmlNodeMethodList[i]); methodEx.tag = methodHoldingLabware; methodEx.isEnabled = methodHoldingLabware.status == "enable"; methodEx.method_Tipcontent = string.Format("从{0}抓板", methodHoldingLabware.srcPositionText); //Method_HoldingLabware(methodEx); #endregion break; case (int)MethodNameEnum.endHoldingLabware: #region 夹爪保持结束 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodHoldingLabware endMethodHoldingLabware = new HoldingLabwareBll().GenerateMethodEndHoldingLabware(xmlNodeMethodList[i]); methodEx.Children[methodEx.Children.Count - 1].tag = endMethodHoldingLabware; methodEx.Children[methodEx.Children.Count - 1].isEnabled = endMethodHoldingLabware.status == "enable"; methodEx.Children[methodEx.Children.Count - 1].method_Tipcontent = string.Format("放板到{0}", endMethodHoldingLabware.desPositionText); //Method_HoldingLabware(methodEx.Children[methodEx.Children.Count - 1]); if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { sourceItem = null; methodExes[methodExes.Count - 1] = null; bool isAllNull = true; //循环向前找,找到最后一个不为null的,sourceItem for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = methodExes[k]; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } methodExes.RemoveAt(methodExes.Count - 1); } else { bool isAllNull = true; int counAllNull = 0;//计算不为Null的个数 for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { counAllNull++; } } //循环向前找,找到最后一个不为null的,设置为null for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = null; methodExes[k] = null; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } else { if (counAllNull == 1) { rootMethod.Children.Add(methodEx); } } } } else { rootMethod.Children.Add(methodEx); sourceItem = null; methodExes[methodExes.Count - 1] = null; } #endregion break; case (int)MethodNameEnum.home: #region 复位 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodHome methodHome = new MethodHome(); HomeBll homeBll = new HomeBll(); methodHome = homeBll.GenerateMethodHome(xmlNodeMethodList[i]); methodEx.tag = methodHome; methodEx.isEnabled = methodHome.status == "enable"; //Method_Reset(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.pause: #region 暂停 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodPauseMove methodPauseMove = new MethodPauseMove(); PauseMoveBll pauseMoveBll = new PauseMoveBll(); methodPauseMove = pauseMoveBll.GenerateMethodPauseMove(xmlNodeMethodList[i]); methodEx.tag = methodPauseMove; if (methodPauseMove != null) { methodEx.method_Tipcontent = string.Format("{0};{1}", methodPauseMove.pauseTime, methodPauseMove.pauseTipInfo); } methodEx.isEnabled = methodPauseMove.status == "enable"; //Method_Pause(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.remark: #region 备注 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodRemark methodRemark = new MethodRemark(); CommentBll commentBll = new CommentBll(); methodRemark = commentBll.GenerateMethodRemark(xmlNodeMethodList[i]); methodEx.tag = methodRemark; if (methodRemark != null) { methodEx.method_Tipcontent = string.Format("{0}", methodRemark.title.ToString()); } methodEx.isEnabled = methodRemark.status == "enable"; //Method_Comment(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.dataimport: #region 数据导入 methodEx = GenerateMethodEx(xmlNodeMethodList[i],rootMethod); MethodDataImport methodDataImport = new MethodDataImport(); DataImportBll dataImportBll = new DataImportBll(); methodDataImport = dataImportBll.GenerateMethodDataImportDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodDataImport; methodEx.isEnabled = methodDataImport.status == "enable"; //Method_DataImport(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.dataexport: #region 数据导出 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodDataExport methodDataExport = new MethodDataExport(); DataExportBll dataExportBll = new DataExportBll(); methodDataExport = dataExportBll.GenerateMethodDataExport(xmlNodeMethodList[i]); methodEx.tag = methodDataExport; methodEx.isEnabled = methodDataExport.status == "enable"; //Method_DataExport(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.group: #region 组合 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodCombination methodCombination = new MethodCombination(); GroupBll groupBll = new GroupBll(); methodCombination = groupBll.GenerateMethodGroup(xmlNodeMethodList[i]); methodEx.tag = methodCombination; methodEx.isEnabled = methodCombination.status == "enable"; //Method_Group(methodEx); #endregion break; case (int)MethodNameEnum.endgroup: #region 结束组合 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); methodEx.Children[methodEx.Children.Count - 1].isEnabled = new GroupBll().GenerateMethodGroup(xmlNodeMethodList[i]).status == "enable"; if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { sourceItem = null; methodExes[methodExes.Count - 1] = null; bool isAllNull = true; //循环向前找,找到最后一个不为null的,sourceItem for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = methodExes[k]; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } methodExes.RemoveAt(methodExes.Count - 1); } else { bool isAllNull = true; int counAllNull = 0;//计算不为Null的个数 for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { counAllNull++; } } //循环向前找,找到最后一个不为null的,设置为null for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = null; methodExes[k] = null; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } else { if (counAllNull == 1) { rootMethod.Children.Add(methodEx); } } } } else { rootMethod.Children.Add(methodEx); sourceItem = null; methodExes[methodExes.Count - 1] = null; } #endregion break; case (int)MethodNameEnum.takephoto: #region 拍照 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodTakePhoto methodTakePhoto = new MethodTakePhoto(); TakePhotoBll takePhotoBll = new TakePhotoBll(); methodTakePhoto = takePhotoBll.GenerateMethodTakePhotoDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodTakePhoto; methodEx.isEnabled = methodTakePhoto.status == "enable"; //Method_Capture(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.choice: #region 挑选 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodChoice methodChoice = new ChoiceBll().GenerateMethodChoiceDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodChoice; methodEx.isEnabled = methodChoice.status == "enable"; //Method_Pick(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.coating: #region 涂布 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodCoating methodCoating = coatingBll.GenerateMethodCoatingDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodCoating; methodEx.isEnabled = methodCoating.status == "enable"; //Method_Coating(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.coatingfile: #region 涂布文件 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodCoatingFile methodCoatingFile = new MethodCoatingFile(); CoatingFileBll coatingFileBll = new CoatingFileBll(); methodCoatingFile = coatingFileBll.GenerateMethodCoatingFileDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodCoatingFile; methodEx.isEnabled = methodCoatingFile.status == "enable"; //Method_FileCoating(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.coatingReport: #region 涂布报告 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodCoatingReport methodCoatingReport = new MethodCoatingReport(); CoatingReportBll coatingReportBll = new CoatingReportBll(); methodCoatingReport = coatingReportBll.GenerateMethodDataExport(xmlNodeMethodList[i]); methodEx.tag = methodCoatingReport; methodEx.isEnabled = methodCoatingReport.status == "enable"; //Method_CoatingFileExport(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.ultrasonic: #region 超声探测 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodUltrasonic methodUltrasonic = new MethodUltrasonic(); UltrasonicBll ultrasonicBll = new UltrasonicBll(); methodUltrasonic = ultrasonicBll.GenerateMethodUltrasonicDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodUltrasonic; methodEx.isEnabled = methodUltrasonic.status == "enable"; //Method_Ultrasonic(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.choiceTransfer: #region 挑选转板 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodChoiceAndTransfer methodChoiceTransfer = new ChoiceBll().GenerateMethodChoiceAndTransferDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodChoiceTransfer; methodEx.isEnabled = methodChoiceTransfer.status == "enable"; //Method_PickAndTransfer(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.coatingTransfer: #region 涂布转板 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodCoatingAndTransfer methodCoatingTransfer = coatingBll.GenerateMethodCoatingAndTransferDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodCoatingTransfer; methodEx.isEnabled = methodCoatingTransfer.status == "enable"; //Method_CoatingAndTransfer(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.dilution: #region 梯度稀释 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodDilution methodDilution = new MethodDilution(); DilutionBll dilutionBll = new DilutionBll(); methodDilution = dilutionBll.GenerateMethodDilutionDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodDilution; methodEx.isEnabled = methodDilution.status == "enable"; //Method_Dilution(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.setVariable: #region 设置变量 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodSetVariable methodSetVariable = new MethodSetVariable(); SetVariableBll setVariableBll = new SetVariableBll(); methodSetVariable = setVariableBll.GenerateMethodSetVariable(xmlNodeMethodList[i]); methodEx.tag = methodSetVariable; if (methodSetVariable != null) { methodEx.method_Tipcontent = string.Format("{0}={1}", methodSetVariable.variablename.ToString(), methodSetVariable.variablevalue.ToString()); } methodEx.isEnabled = methodSetVariable.status == "enable"; //Method_SetVariable(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.VariableImport: #region 文件导入变量 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodVariableImport methodVariableImport = new MethodVariableImport(); VariableImportBll variableImportBll = new VariableImportBll(); methodVariableImport = variableImportBll.GenerateMethodVariableImportDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodVariableImport; methodEx.isEnabled = methodVariableImport.status == "enable"; //Method_VariableImport(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.ifStart: #region 开始if methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodIfElse methodIfElse = new MethodIfElse(); IfElseBll ifElseBll = new IfElseBll(); methodIfElse = ifElseBll.GenerateMethodIfElseDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodIfElse; if (methodIfElse != null) { string logicSymbol = string.Empty; if (methodIfElse.logicCondition == LogicMark.Above) { logicSymbol = ">"; } else if (methodIfElse.logicCondition == LogicMark.Below) { logicSymbol = "<"; } else if (methodIfElse.logicCondition == LogicMark.Equal) { logicSymbol = "="; } else if (methodIfElse.logicCondition == LogicMark.Unequal) { logicSymbol = "!="; } else if (methodIfElse.logicCondition == LogicMark.AboveEqual) { logicSymbol = ">="; } else if (methodIfElse.logicCondition == LogicMark.BelowEqual) { logicSymbol = "<="; } methodEx.method_Tipcontent = string.Format("{0}{1}{2}", methodIfElse.variableName, logicSymbol, methodIfElse.variableValue); } methodEx.isEnabled = methodIfElse.status == "enable"; //Method_IfElse(methodEx); #endregion break; case (int)MethodNameEnum.ifEnd: #region 结束if methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); methodEx.Children[methodEx.Children.Count - 1].isEnabled = true;// new IfElseBll().GenerateMethodIfElseDataByXmlNode(xmlNodeMethodList[i]).status == "enable"; if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { sourceItem = null; methodExes[methodExes.Count - 1] = null; bool isAllNull = true; //循环向前找,找到最后一个不为null的,设置为sourceItem for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = methodExes[k]; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } methodExes.RemoveAt(methodExes.Count - 1); } else { bool isAllNull = true; int counAllNull = 0;//计算不为Null的个数 for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { counAllNull++; } } //循环向前找,找到最后一个不为null的,设置为null for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = null; methodExes[k] = null; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } else { if (counAllNull == 1) { rootMethod.Children.Add(methodEx); } } } } else { rootMethod.Children.Add(methodEx); sourceItem = null; methodExes[methodExes.Count - 1] = null; } #endregion break; case (int)MethodNameEnum.elseStart: #region 开始if methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); methodIfElse = new MethodIfElse(); ifElseBll = new IfElseBll(); methodIfElse = ifElseBll.GenerateMethodIfElseDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodIfElse; if (methodIfElse != null) { string logicSymbol = string.Empty; if (methodIfElse.logicCondition == LogicMark.Above) { logicSymbol = ">"; } else if (methodIfElse.logicCondition == LogicMark.Below) { logicSymbol = "<"; } else if (methodIfElse.logicCondition == LogicMark.Equal) { logicSymbol = "="; } else if (methodIfElse.logicCondition == LogicMark.Unequal) { logicSymbol = "!="; } else if (methodIfElse.logicCondition == LogicMark.AboveEqual) { logicSymbol = ">="; } else if (methodIfElse.logicCondition == LogicMark.BelowEqual) { logicSymbol = "<="; } methodEx.method_Tipcontent = string.Format("{0}{1}{2}", methodIfElse.variableName, logicSymbol, methodIfElse.variableValue); } methodEx.isEnabled = methodIfElse.status == "enable"; //Method_IfElse(methodEx); #endregion break; case (int)MethodNameEnum.elseEnd: #region 结束if methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); methodEx.Children[methodEx.Children.Count - 1].isEnabled = true;//new IfElseBll().GenerateMethodIfElseDataByXmlNode(xmlNodeMethodList[i]).status == "enable"; if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { sourceItem = null; methodExes[methodExes.Count - 1] = null; bool isAllNull = true; //循环向前找,找到最后一个不为null的,设置为sourceItem for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = methodExes[k]; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } methodExes.RemoveAt(methodExes.Count - 1); } else { bool isAllNull = true; int counAllNull = 0;//计算不为Null的个数 for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { counAllNull++; } } //循环向前找,找到最后一个不为null的,设置为null for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = null; methodExes[k] = null; isAllNull = false; break; } } //如果向前找没有一个不为null的,则添加到tree;否则不添加 if (isAllNull) { rootMethod.Children.Add(methodEx); } else { if (counAllNull == 1) { rootMethod.Children.Add(methodEx); } } } } else { rootMethod.Children.Add(methodEx); sourceItem = null; methodExes[methodExes.Count - 1] = null; } #endregion break; case (int)MethodNameEnum.timerSet: #region 计时器 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodTimer methodTimer = new MethodTimer(); TimerBll timerBll = new TimerBll(); methodTimer = timerBll.GenerateMethodTimer(xmlNodeMethodList[i]); methodEx.tag = methodTimer; if (methodTimer != null) { methodEx.method_Tipcontent = string.Format("{0}s", methodTimer.duringTime.ToString()); } methodEx.isEnabled = methodTimer.status == "enable"; //Method_Timer(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.waitFor: #region 等待 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodWaitFor methodWaitFor = new MethodWaitFor(); WaitForBll waitForBll = new WaitForBll(); methodWaitFor = waitForBll.GenerateMethodTimer(xmlNodeMethodList[i]); methodEx.tag = methodWaitFor; methodEx.isEnabled = methodWaitFor.status == "enable"; //Method_WaitFor(methodEx, null); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.pumpDispense: #region 泵排液 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodPumpDispese methodPumpDispese = new MethodPumpDispese(); PumpDispenseBll pumpDispenseBll = new PumpDispenseBll(); methodPumpDispese = pumpDispenseBll.GenerateMethodPumpDispenseDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodPumpDispese; methodEx.isEnabled = methodPumpDispese.status == "enable"; //Method_PumpDispense(methodEx); //treeviewWorkflow.SelectedItem = m; if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.shaker: #region 振荡 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodShake methodShake = new MethodShake(); ShakerBll shakerBll = new ShakerBll(); methodShake = shakerBll.GenerateMethodShakeDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodShake; methodEx.isEnabled = methodShake.status == "enable"; //Method_Shake(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.switchLid: #region 开关盖 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodSwitchLid methodSwitchLid = new MethodSwitchLid(); SwitchLidBll switchLidBll = new SwitchLidBll(); methodSwitchLid = switchLidBll.GenerateMethodSwitchLidDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodSwitchLid; methodEx.isEnabled = methodSwitchLid.status == "enable"; //Method_SwitchLid(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.fileMoveLiquid: #region 文件开关盖移液 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodFileMoveLiquid methodFileMoveLiquid = new MethodFileMoveLiquid(); FileMoveLiquidBll fileMoveLiquidBll = new FileMoveLiquidBll(); methodFileMoveLiquid = fileMoveLiquidBll.GenerateMethodFileMoveLiquidDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodFileMoveLiquid; methodEx.isEnabled = methodFileMoveLiquid.status == "enable"; //Method_FileMoveLiquid(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.fileMoveLabware: #region 文件转板 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodFileMoveLabware methodFileMoveLabware = new MethodFileMoveLabware(); FileMoveLabwareBll fileMoveLabwareBll = new FileMoveLabwareBll(); methodFileMoveLabware = fileMoveLabwareBll.GenerateMethodFileMoveLabwareDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodFileMoveLabware; methodEx.isEnabled = methodFileMoveLabware.status == "enable"; //Method_FileMoveLabware(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.subMethod: #region 子方法 methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); MethodSubMethod methodSubMethod = new SubMethodBll().GenerateMethodSubMethodDataByXmlNode(xmlNodeMethodList[i], true); methodEx.tag = methodSubMethod; methodEx.isEnabled = methodSubMethod.status == "enable"; //Method_SubMethod(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; case (int)MethodNameEnum.varCalc: #region 变量计算 methodEx = GenerateMethodEx(xmlNodeMethodList[i],rootMethod); MethodVarCalc methodVarCalc = new MethodVarCalc(); VarCalcBll varCalcBll = new VarCalcBll(); methodVarCalc = varCalcBll.GenerateMethodVarCalcDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodVarCalc; if (methodVarCalc != null) { string logicSymbol = string.Empty; if (methodVarCalc.calcOperator == (int)CalcOperatorTypeEnum.Add) { logicSymbol = "+"; } else if (methodVarCalc.calcOperator == (int)CalcOperatorTypeEnum.Minus) { logicSymbol = "-"; } else if (methodVarCalc.calcOperator == (int)CalcOperatorTypeEnum.Time) { logicSymbol = "×"; } else if (methodVarCalc.calcOperator == (int)CalcOperatorTypeEnum.Pide) { logicSymbol = "÷"; } else if (methodVarCalc.calcOperator == (int)CalcOperatorTypeEnum.Mod) { logicSymbol = "%"; } methodEx.method_Tipcontent = string.Format("{0}{1}{2}={3}", methodVarCalc.calcValue1.ToString(), logicSymbol, methodVarCalc.calcValue2.ToString(), methodVarCalc.calcResult.ToString()); } methodEx.isEnabled = methodVarCalc.status == "enable"; //Method_VariableCalculate(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } #endregion break; default: #region 第三方设备 if (xmlNodeMethodList[i].SelectSingleNode("isThirdPart") != null) { bool isThirdPart = bool.Parse(xmlNodeMethodList[i].SelectSingleNode("isThirdPart").InnerText); if (!isThirdPart) { break; } methodEx = GenerateMethodEx(xmlNodeMethodList[i], rootMethod); ThirdPartBll thirdPartBll = new ThirdPartBll(); MethodThirdPart methodThirdPart = thirdPartBll.GenerateMethodThirdPartDataByXmlNode(xmlNodeMethodList[i]); methodEx.tag = methodThirdPart; methodEx.method_Tipcontent = string.Format("{0}", methodThirdPart.deviceMethod.ParameterName); methodEx.isEnabled = methodThirdPart.status == "enable"; //Method_ThirdPart(methodEx); if (sourceItem == null) { rootMethod.Children.Add(methodEx); } } #endregion break; } var mainWindow = (MainWindow)Application.Current.MainWindow; if (mainWindow != null) { if (methodEx != null) { mainWindow.SetObserverNode(methodEx); } } } // MethodEx重新排序号 ViewCom.ReOrderMethodIndex("", rootMethod); if (treeviewWorkflow != null) { treeviewWorkflow.ItemsSource = rootMethod.Children; } } #endregion static List methodExes = new List(); static MethodEx sourceItem = null; static List methodExesForGroup = new List(); static Grid gridProperty = null; #region 根据XmlNode创建MethodEx public static MethodEx GenerateMethodEx(XmlNode xmlNode, MethodEx rootMethod) { MethodEx methodEx = null; try { ObservableCollection methods = MethodDB.GetMethodFromdb(Shared.SoftwareInformation.software_device_number); if (xmlNode.SelectSingleNode("label").InnerText == "start") { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("开始")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); rootMethod.Children.Add(methodEx); } } #region 循环 else if (xmlNode.SelectSingleNode("label").InnerText == "循环开始") { if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("循环")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); //methodExes[methodExes.Count - 1] = methodEx; methodExes.Add(methodEx); sourceItem.Children.Add(methodEx); methodEx.SetParent(sourceItem); sourceItem = methodEx; } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("循环")); if (currentMethod != null) { sourceItem = methodEx; methodEx = new MethodEx(currentMethod, rootMethod); sourceItem = methodEx; methodExes.Add(sourceItem); } } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("循环")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); sourceItem = methodEx; methodExes.Add(sourceItem); } } } else if (xmlNode.SelectSingleNode("label").InnerText == "循环结束") { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("循环")); if (currentMethod != null) { string id = Guid.NewGuid().ToString(); sourceItem.method_name += Properties.Resources.strBegin; sourceItem.groupID = id; MethodEx source = new MethodEx(sourceItem); MethodEx endItem = new MethodEx(source, sourceItem); endItem.groupID = id; endItem.method_name = "循环" + Properties.Resources.strEnd; endItem.method_ico = "循环结束.png"; endItem.Moveable = false; endItem.method_Tipcontent = ""; sourceItem.Children.Add(endItem); } methodEx = sourceItem; } #endregion #region 组合 else if (xmlNode.SelectSingleNode("label").InnerText == "组合开始") { if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("组合")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); methodExes.Add(methodEx); sourceItem.Children.Add(methodEx); methodEx.SetParent(sourceItem); sourceItem = methodEx; } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("组合")); if (currentMethod != null) { sourceItem = methodEx; methodEx = new MethodEx(currentMethod, rootMethod); sourceItem = methodEx; methodExes.Add(sourceItem); } } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("组合")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); sourceItem = methodEx; methodExes.Add(sourceItem); } } } else if (xmlNode.SelectSingleNode("label").InnerText == "组合结束") { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("组合")); if (currentMethod != null) { string id = Guid.NewGuid().ToString(); sourceItem.groupID = id; MethodEx source = new MethodEx(sourceItem); MethodEx endItem = new MethodEx(source, sourceItem); endItem.groupID = id; endItem.method_name = "组合" + Properties.Resources.strEnd; endItem.method_ico = "组合结束.png"; endItem.Moveable = false; sourceItem.Children.Add(endItem); } methodEx = sourceItem; } #endregion #region 夹爪保持 else if (xmlNode.SelectSingleNode("label").InnerText == "夹爪保持开始") { if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("夹爪保持")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); methodExes.Add(methodEx); sourceItem.Children.Add(methodEx); methodEx.SetParent(sourceItem); sourceItem = methodEx; } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("夹爪保持")); if (currentMethod != null) { sourceItem = methodEx; methodEx = new MethodEx(currentMethod, rootMethod); sourceItem = methodEx; methodExes.Add(sourceItem); } } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("夹爪保持")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); sourceItem = methodEx; methodExes.Add(sourceItem); } } } else if (xmlNode.SelectSingleNode("label").InnerText == "夹爪保持结束") { Method currentMethod = methods.FirstOrDefault(x => x.method_content.Equals("夹爪保持")); if (currentMethod != null) { string id = Guid.NewGuid().ToString(); sourceItem.groupID = id; MethodEx source = new MethodEx(sourceItem); MethodEx endItem = new MethodEx(source, sourceItem); endItem.groupID = id; endItem.method_content = endItem.method_name = "夹爪保持" + Properties.Resources.strEnd; endItem.method_ico = "夹爪保持结束.png"; endItem.Moveable = false; sourceItem.Children.Add(endItem); //methodEx = endItem; } methodEx = sourceItem; } #endregion #region if开始 else if (xmlNode.SelectSingleNode("label").InnerText == "if开始") { if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); //methodExes[methodExes.Count - 1] = methodEx; methodEx.method_ico = "开始If.png"; methodEx.method_name = "if开始"; methodEx.method_content = "if开始"; methodExes.Add(methodEx); sourceItem.Children.Add(methodEx); methodEx.SetParent(sourceItem); sourceItem = methodEx; } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { sourceItem = methodEx; methodEx = new MethodEx(currentMethod, rootMethod); methodEx.method_ico = "开始If.png"; methodEx.method_name = "if开始"; methodEx.method_content = "if开始"; sourceItem = methodEx; methodExes.Add(sourceItem); } } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); methodEx.method_ico = "开始If.png"; methodEx.method_name = "if开始"; methodEx.method_content = "if开始"; sourceItem = methodEx; methodExes.Add(sourceItem); } } } else if (xmlNode.SelectSingleNode("label").InnerText == "if结束") { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { string id = Guid.NewGuid().ToString(); sourceItem.method_ico = "开始If.png"; sourceItem.method_name = "if开始"; sourceItem.method_content = "if开始"; sourceItem.groupID = id; MethodEx source = new MethodEx(sourceItem); MethodEx endItem = new MethodEx(source, sourceItem); endItem.groupID = id; endItem.method_name = "if" + Properties.Resources.strEnd; endItem.method_ico = "结束If.png"; endItem.Moveable = false; sourceItem.Children.Add(endItem); } methodEx = sourceItem; } #endregion #region else开始 else if (xmlNode.SelectSingleNode("label").InnerText == "else开始") { if (methodExes.Count > 0) { if (methodExes[methodExes.Count - 1] != null) { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); //methodExes[methodExes.Count - 1] = methodEx; methodEx.method_ico = "开始else.png"; methodEx.method_name = "else开始"; methodEx.method_content = "else开始"; methodExes.Add(methodEx); sourceItem.Children.Add(methodEx); methodEx.SetParent(sourceItem); sourceItem = methodEx; } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { sourceItem = methodEx; methodEx = new MethodEx(currentMethod, rootMethod); methodEx.method_ico = "开始else.png"; methodEx.method_name = "else开始"; methodEx.method_content = "else开始"; sourceItem = methodEx; methodExes.Add(sourceItem); } } } else { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); methodEx.method_ico = "开始else.png"; methodEx.method_name = "else开始"; methodEx.method_content = "else开始"; sourceItem = methodEx; methodExes.Add(sourceItem); } } } else if (xmlNode.SelectSingleNode("label").InnerText == "else结束") { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals("条件判定")); if (currentMethod != null) { string id = Guid.NewGuid().ToString(); sourceItem.method_ico = "开始else.png"; sourceItem.method_name = "else开始"; sourceItem.method_content = "else开始"; sourceItem.groupID = id; MethodEx source = new MethodEx(sourceItem); MethodEx endItem = new MethodEx(source, sourceItem); endItem.groupID = id; endItem.method_name = "else" + Properties.Resources.strEnd; endItem.method_ico = "结束else.png"; endItem.Moveable = false; sourceItem.Children.Add(endItem); } methodEx = sourceItem; } #endregion #region 其它 else { Method currentMethod = methods.FirstOrDefault(x => x.method_name.Equals(xmlNode.SelectSingleNode("label").InnerText)); // 第三方设备名称变更后,可通过ID找出来 if (xmlNode.SelectSingleNode("isThirdPart") != null && bool.Parse(xmlNode.SelectSingleNode("isThirdPart").InnerText) && currentMethod == null) { currentMethod = methods.FirstOrDefault(x => x.method_id.Equals(xmlNode.SelectSingleNode("device/id").InnerText)); } Method currentMethodEnd = methods.FirstOrDefault(x => x.method_name.Equals("结束")); #region 常规方法 if (currentMethod != null) { methodEx = new MethodEx(currentMethod, rootMethod); //节点内容绑定 //methodEx.control //判断是否还在循环内,如果还在,则取出最后一个添加 bool isInnerLoop = false; for (int i = methodExes.Count - 1; i >= 0; i--) { if (methodExes[i] != null) { isInnerLoop = true; break; } } if (isInnerLoop) { for (int k = methodExes.Count - 1; k >= 0; k--) { if (methodExes[k] != null) { sourceItem = methodExes[k]; break; } } if (sourceItem != null) { sourceItem.Children.Add(methodEx); methodEx.SetParent(sourceItem); } } else { if (sourceItem != null) { sourceItem.Children.Add(methodEx); } } } #endregion #region 结束 else if (currentMethodEnd != null && xmlNode.SelectSingleNode("name").InnerText == "Method_End") { methodEx = new MethodEx(currentMethodEnd, rootMethod); if (sourceItem != null) { sourceItem.Children.Add(methodEx); } currentMethodEnd = null; } #endregion } #endregion } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } return methodEx; } #endregion private static void HideConsumable() { } #region 开始 private void Method_Start(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { StartProperty property = new StartProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is StartProperty) { StartProperty property = method.control as StartProperty; gridProperty.Children.Add(property); } } } #endregion #region 台面布置 private void Method_SetTable() { //ShowConsumable(); } #endregion #region 结束 public static void Method_End(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { EndProperty property = new EndProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is EndProperty) { EndProperty property = method.control as EndProperty; gridProperty.Children.Add(property); } } } #endregion #region 安装枪头 public static void Method_LoadTips(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { LoadTipsProperty property = new LoadTipsProperty(method); //if (property.methodLoadTips != null) //{ // property.methodLoadTips.channels = property.tipsChannel.SelectedChannels.ToArray(); //} gridProperty.Children.Add(property); method.control = property; } else { //原始创建 if (method.control is LoadTipsProperty) { LoadTipsProperty property = method.control as LoadTipsProperty; //property.methodLoadTips.channels = property.tipsChannel.SelectedChannels.ToArray(); gridProperty.Children.Add(property); } //打开创建 } } #endregion #region 卸载枪头 public static void Method_UnloadTips(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { UnLoadTipsProperty property = new UnLoadTipsProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is UnLoadTipsProperty) { UnLoadTipsProperty property = method.control as UnLoadTipsProperty; //property.methodUnLoadTips.channels = property.tipsChannel.SelectedChannels.ToArray(); gridProperty.Children.Add(property); property.UserControl_Loaded("", new RoutedEventArgs()); } } } #endregion #region 备注 public static void Method_Comment(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { CommentProperty property = new CommentProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is CommentProperty) { CommentProperty property = method.control as CommentProperty; if ((MethodRemark)method.tag != null) { property.methodRemark = (MethodRemark)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 变量计算 private static void Method_VariableCaculation() { HideConsumable(); gridProperty.Children.Clear(); VariableCaculationProperty property = new VariableCaculationProperty(); gridProperty.Children.Add(property); } #endregion #region 设置变量 public static void Method_SetVariable(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { SetVariableProperty property = new SetVariableProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is SetVariableProperty) { SetVariableProperty property = method.control as SetVariableProperty; if ((MethodSetVariable)method.tag != null) { property.methodSetVariable = (MethodSetVariable)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 文件导入变量 public static void Method_VariableImport(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { VariableImportProperty property = new VariableImportProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is VariableImportProperty) { VariableImportProperty property = method.control as VariableImportProperty; if ((MethodVariableImport)method.tag != null) { property.methodVariableImport = (MethodVariableImport)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 条件判定 public static void Method_IfElse(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { if (method.method_name == "if结束") { return; } else if (method.method_name == "else结束") { return; } IfElseProperty property = new IfElseProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is IfElseProperty) { IfElseProperty property = method.control as IfElseProperty; if ((MethodIfElse)method.tag != null) { property.methodIfElse = (MethodIfElse)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 循环 public static void Method_Loop(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { if (method.method_name == "循环结束") { return; } else if (method.method_name == "组合结束") { return; } LoopProperty property = new LoopProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is LoopProperty) { LoopProperty property = method.control as LoopProperty; gridProperty.Children.Add(property); } } } #endregion #region 暂停 public static void Method_Pause(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { PauseProperty property = new PauseProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is PauseProperty) { PauseProperty property = method.control as PauseProperty; if ((MethodPauseMove)method.tag != null) { property.methodPauseMove = (MethodPauseMove)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 计时器 public static void Method_Timer(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { TimerProperty property = new TimerProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is TimerProperty) { TimerProperty property = method.control as TimerProperty; if ((MethodTimer)method.tag != null) { property.methodTimer = (MethodTimer)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 加液泵 public static void Method_PumpDispense(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { PumpDispenseProperty property = new PumpDispenseProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is PumpDispenseProperty) { PumpDispenseProperty property = method.control as PumpDispenseProperty; if ((MethodPumpDispese)method.tag != null) { property.methodPumpDispese = (MethodPumpDispese)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 振荡 化学 public static void Method_Shake(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { ShakeProperty property = new ShakeProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is ShakeProperty) { ShakeProperty property = method.control as ShakeProperty; if ((MethodShake)method.tag != null) { property.methodShake = (MethodShake)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 开关盖 public static void Method_SwitchLid(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { SwitchLidProperty property = new SwitchLidProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is SwitchLidProperty) { SwitchLidProperty property = method.control as SwitchLidProperty; if ((MethodSwitchLid)method.tag != null) { property.methodSwitchLid = (MethodSwitchLid)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 文件开关盖移液 public static void Method_FileMoveLiquid(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { FileMoveLiquidProperty property = new FileMoveLiquidProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is FileMoveLiquidProperty) { FileMoveLiquidProperty property = method.control as FileMoveLiquidProperty; if ((MethodFileMoveLiquid)method.tag != null) { property.methodFileMoveLiquid = (MethodFileMoveLiquid)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 文件转板 public static void Method_FileMoveLabware(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { FileMoveLabwareProperty property = new FileMoveLabwareProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is FileMoveLabwareProperty) { FileMoveLabwareProperty property = method.control as FileMoveLabwareProperty; if ((MethodFileMoveLabware)method.tag != null) { property.methodFileMoveLabware = (MethodFileMoveLabware)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 等待 public static void Method_WaitFor(MethodEx method, List duringTimerList) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { WaitforProperty property = new WaitforProperty(method, duringTimerList); gridProperty.Children.Add(property); method.control = property; //mainWindow.SetObserverNode(method);//注册观察者 } else { if (method.control is WaitforProperty) { WaitforProperty property = method.control as WaitforProperty; if ((MethodWaitFor)method.tag != null) { property.methodWaitFor = (MethodWaitFor)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 混合 public static void Method_Mix(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { MixProperty property = new MixProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is MixProperty) { MixProperty property = method.control as MixProperty; if ((MethodMixing)method.tag != null) { property.methodMix = (MethodMixing)method.tag; } gridProperty.Children.Add(property); property.UserControl_Loaded("", new RoutedEventArgs()); } } } #endregion #region 文件 public static void Method_File(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { FileProperty property = new FileProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is FileProperty) { FileProperty property = method.control as FileProperty; if ((MethodTransferFile)method.tag != null) { property.methodTransferFile = (MethodTransferFile)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 复位 public static void Method_Reset(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { ResetProperty property = new ResetProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is ResetProperty) { ResetProperty property = method.control as ResetProperty; if ((MethodHome)method.tag != null) { property.methodHome = (MethodHome)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 组合 public static void Method_Group(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { if (method.method_name == "循环结束") { return; } else if (method.method_name == "组合结束") { return; } GroupProperty property = new GroupProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is GroupProperty) { GroupProperty property = method.control as GroupProperty; gridProperty.Children.Add(property); } } } #endregion #region 吸液 public static void Method_Aspirate(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { AspirateProperty property = new AspirateProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is AspirateProperty) { AspirateProperty property = method.control as AspirateProperty; if ((MethodAspirate)method.tag != null) { property.methodAspirate = (MethodAspirate)method.tag; } gridProperty.Children.Add(property); property.UserControl_Loaded("", new RoutedEventArgs()); } } } #endregion #region 放液 public static void Method_Dispense(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { DispenseProperty property = new DispenseProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is DispenseProperty) { DispenseProperty property = method.control as DispenseProperty; if ((MethodDispense)method.tag != null) { property.methodDispense = (MethodDispense)method.tag; } gridProperty.Children.Add(property); property.UserControl_Loaded("", new RoutedEventArgs()); } } } #endregion #region 抓板转移 public static void Method_GripTransport(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { GripTransportProperty property = new GripTransportProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is GripTransportProperty) { GripTransportProperty property = method.control as GripTransportProperty; if ((MethodGripTransport)method.tag != null) { property.methodGripTransport = (MethodGripTransport)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 移动夹爪 public static void Method_GripMove(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { GripMoveProperty property = new GripMoveProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is GripMoveProperty) { GripMoveProperty property = method.control as GripMoveProperty; if ((MethodGripMove)method.tag != null) { property.methodGripMove = (MethodGripMove)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 抓板保持开始\抓板保持结束 public static void Method_HoldingLabware(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { if (method.method_name == "夹爪保持" || method.method_name == "夹爪保持开始") { BeginHoldingLabwareProperty property = new BeginHoldingLabwareProperty(method); gridProperty.Children.Add(property); method.control = property; } else if (method.method_name == "夹爪保持结束") { EndHoldingLabwareProperty property = new EndHoldingLabwareProperty(method); gridProperty.Children.Add(property); method.control = property; } } else { if (method.control is BeginHoldingLabwareProperty) { BeginHoldingLabwareProperty property = method.control as BeginHoldingLabwareProperty; gridProperty.Children.Add(property); } else if (method.control is EndHoldingLabwareProperty) { EndHoldingLabwareProperty property = method.control as EndHoldingLabwareProperty; gridProperty.Children.Add(property); } } } #endregion #region 数据导入 public static void Method_DataImport(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { DataImportProperty property = new DataImportProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is DataImportProperty) { DataImportProperty property = method.control as DataImportProperty; if ((MethodDataImport)method.tag != null) { property.methodDataImport = (MethodDataImport)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 数据导出 public static void Method_DataExport(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { DataExportProperty property = new DataExportProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is DataExportProperty) { DataExportProperty property = method.control as DataExportProperty; if ((MethodDataExport)method.tag != null) { property.methodDataExport = (MethodDataExport)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 拍照 public static void Method_Capture(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { CaptureProperty property = new CaptureProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is CaptureProperty) { CaptureProperty property = method.control as CaptureProperty; if ((MethodTakePhoto)method.tag != null) { property.methodTakePhoto = (MethodTakePhoto)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 文件涂布 public static void Method_FileCoating(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { FileCoatingProperty property = new FileCoatingProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is FileCoatingProperty) { FileCoatingProperty property = method.control as FileCoatingProperty; if ((MethodCoatingFile)method.tag != null) { property.methodCoatingFile = (MethodCoatingFile)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 挑菌 public static void Method_Pick(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { PickProperty property = new PickProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is PickProperty) { PickProperty property = method.control as PickProperty; if ((MethodChoice)method.tag != null) { property.methodChoice = (MethodChoice)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 涂布 public static void Method_Coating(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { CoatingProperty property = new CoatingProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is CoatingProperty) { CoatingProperty property = method.control as CoatingProperty; if ((MethodCoating)method.tag != null) { property.methodCoating = (MethodCoating)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 文件涂布 public static void Method_CoatingFileExport(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { CoatingFileExportProperty property = new CoatingFileExportProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is CoatingFileExportProperty) { CoatingFileExportProperty property = method.control as CoatingFileExportProperty; if ((MethodCoatingReport)method.tag != null) { property.methodCoatingReport = (MethodCoatingReport)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 超声探测 public static void Method_Ultrasonic(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { UltrasonicProperty property = new UltrasonicProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is UltrasonicProperty) { UltrasonicProperty property = method.control as UltrasonicProperty; if ((MethodUltrasonic)method.tag != null) { property.methodUltrasonic = (MethodUltrasonic)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 涂布+转板 public static void Method_CoatingAndTransfer(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { CoatingAndTransferProperty property = new CoatingAndTransferProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is CoatingAndTransferProperty) { CoatingAndTransferProperty property = method.control as CoatingAndTransferProperty; if ((MethodCoatingAndTransfer)method.tag != null) { property.methodCoating = (MethodCoatingAndTransfer)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 挑菌+转板 public static void Method_PickAndTransfer(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { PickAndTransferProperty property = new PickAndTransferProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is PickAndTransferProperty) { PickAndTransferProperty property = method.control as PickAndTransferProperty; if ((MethodChoiceAndTransfer)method.tag != null) { property.methodChoice = (MethodChoiceAndTransfer)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 第三方设备 public static void Method_ThirdPart(MethodEx mEx) { HideConsumable(); mEx.device = DeviceConfigDB.GetInfodById(mEx.method_id.ToString()); if (mEx.device == null) { new MessageDialog(string.Format("【{0}】设备不存在!", mEx.method_name)).ShowDialog(); return; } gridProperty.Children.Clear(); if (mEx.control == null) { UserControl property = null; // Socket-TCP标准协议 if (mEx.device.CommunicateType == EnumManagement.GetEnumValue(CommunicateTypeEnum.Socket)) { property = new ThirdPartPropertySocketProperty(mEx); } gridProperty.Children.Add(property); mEx.control = property; } else { if (mEx.control is ThirdPartPropertySocketProperty) { ThirdPartPropertySocketProperty property = mEx.control as ThirdPartPropertySocketProperty; if ((MethodThirdPart)mEx.tag != null) { property.methodProperty = (MethodThirdPart)mEx.tag; } gridProperty.Children.Add(property); } } } #endregion #region 梯度稀释 public static void Method_Dilution(MethodEx method) { HideConsumable(); gridProperty.Children.Clear(); if (method.control == null) { DilutionProperty property = new DilutionProperty(method); gridProperty.Children.Add(property); method.control = property; } else { if (method.control is DilutionProperty) { DilutionProperty property = method.control as DilutionProperty; if ((MethodDilution)method.tag != null) { property.methodDilution = (MethodDilution)method.tag; } gridProperty.Children.Add(property); } } } #endregion #region 子方法 public static void Method_SubMethod(MethodEx method) { HideConsumable(); if (gridProperty != null) { gridProperty.Children.Clear(); } if (method.control == null) { SubMethodProperty property = new SubMethodProperty(method); if (gridProperty != null) { gridProperty.Children.Add(property); } method.control = property; } else { if (method.control is SubMethodProperty) { SubMethodProperty property = method.control as SubMethodProperty; if (method.tag != null) { property.MethodSubMethod = (MethodSubMethod)method.tag; } if (gridProperty != null) { gridProperty.Children.Add(property); } } } } #endregion #region 判断参数是否是变量 /// /// 判断参数是否是变量 /// /// /// public static string IsVariable(string variableName) { variableName = variableName.Trim(); CodeDomProvider provider = CodeDomProvider.CreateProvider("C#"); if (provider.IsValidIdentifier(variableName)) { return variableName; } else { return null; } // // 判断是否是变量 // if (!(!string.IsNullOrEmpty(variableName) && // variableName.Length > 1 && variableName.Substring(0, 1).Equals("="))) //{ // return null; //} //else //{ // string[] varSplit = variableName.Split('='); // return varSplit[1]; //} } #endregion #region 执行切胶动作 /// /// 执行切胶动作 /// /// /// /// /// /// /// /// /// /// public static bool RunCutGum(RunWnd launchView, string strMethodName, CutGumMParam cutGumMParam, string strChoiceWellOrXYZ, string strSrcPlateName, string strSrcPlateBarcode, bool isSimulator = false, TipsTable targetWellInfo = null) { if (launchView._cancelSource.IsCancellationRequested) { return false; } string strCurrentCulture = Shared.SoftwareInformation.currentculture; // 执行挑菌动作 DateTime startTime = DateTime.Now; HxResult ret = cutGumFileBll.ExecuteCutGum(cutGumMParam, isSimulator); DateTime endTime = DateTime.Now; string log = string.Empty; if (ret.Result != ResultType.Success) { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strChoiceErrorExec + " 胶坐标:" + strChoiceWellOrXYZ + ", 板位:" + strSrcPlateName + Properties.MachineRunResource.strError + ret.AlarmInfo; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:cut gum was failed from " + strChoiceWellOrXYZ + " lattice of " + strSrcPlateName + "lattice! error info:" + ret.AlarmInfo; launchView.AddLogs(log); } OperateDialog plsConfirmOper = null; System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.RunCoatingFileResource.strChoiceFailWhatToDo : "cut is fail! What do you want to do?"); plsConfirmOper.ShowDialog(); })); // 重试 if (plsConfirmOper != null && plsConfirmOper.OperMark == OperationTypeEnum.NodeOperationTypeEnum.Retry) { return RunCutGum(launchView, strMethodName, cutGumMParam, strChoiceWellOrXYZ, strSrcPlateName, strSrcPlateBarcode, isSimulator); } // 终止 else if (plsConfirmOper != null && plsConfirmOper.OperMark == OperationTypeEnum.NodeOperationTypeEnum.Cancel) { launchView.addChoiceDataIntoReport(null, strSrcPlateName, "0", new string[] { strChoiceWellOrXYZ }, "block", "", startTime, endTime, "Choice", strSrcPlateBarcode); return false; } // 跳过 else if (plsConfirmOper != null && plsConfirmOper.OperMark == OperationTypeEnum.NodeOperationTypeEnum.Continue) { launchView.addChoiceDataIntoReport(null, strSrcPlateName, "0", new string[] { strChoiceWellOrXYZ }, "block", "", startTime, endTime, "Choice", strSrcPlateBarcode); return true; } } else { if (strCurrentCulture.Equals("zh-CN")) { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】" + Properties.MachineRunResource.strProgress + Properties.RunCoatingFileResource.strChoiceSuccessExec + " 胶坐标:" + strChoiceWellOrXYZ + ", 板位:" + strSrcPlateName; launchView.AddLogs(log); } else { log = "【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + strMethodName + "】progress:cut gum was successful from " + strChoiceWellOrXYZ + " lattice of " + strSrcPlateName + "!"; launchView.AddLogs(log); } if (targetWellInfo != null) // 从皿中挑菌时,变量为null { // 挑菌完成颜色更新 launchView.UpdateLabwareWells(targetWellInfo, new string[] { strChoiceWellOrXYZ }, 4); // 放液完成绿色 } launchView.addChoiceDataIntoReport(null, strSrcPlateName, "0", new string[] { strChoiceWellOrXYZ }, "pass", "", startTime, endTime, "Choice", strSrcPlateBarcode); } return true; } #endregion } }