using DataEntity.Share; using DriverLib.Engine; using HxEnum; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Data; using System.Xml; using XCommon; using XCore; using XCoreBLL.Resource; using XImagingXhandler.XDAL; namespace XCoreBLL { public class CutGumFileBll { string strCurrentCulture = ""; public CutGumFileBll() { strCurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name; } public MethodElectroFile GenerateMethodCoatingFileDataByXmlNode(XmlNode xmlNode) { MethodElectroFile methodElectroFile = new MethodElectroFile(); methodElectroFile.isrun = xmlNode.SelectSingleNode("isrun").InnerText; methodElectroFile.status = xmlNode.SelectSingleNode("status").InnerText; methodElectroFile.name = xmlNode.SelectSingleNode("name").InnerText; methodElectroFile.label = xmlNode.SelectSingleNode("label").InnerText; methodElectroFile.strIndex = xmlNode.SelectSingleNode("strIndex").InnerText; methodElectroFile.armText = xmlNode.SelectSingleNode("arm/text").InnerText; methodElectroFile.armValue = xmlNode.SelectSingleNode("arm/value").InnerText; methodElectroFile.labwaretipText = xmlNode.SelectSingleNode("labwaretip/text").InnerText; methodElectroFile.labwaretipValue = xmlNode.SelectSingleNode("labwaretip/value").InnerText; string strchs = xmlNode.SelectSingleNode("channels").InnerText; methodElectroFile.channels = ComUtility.GetChannelsFromXml(strchs); methodElectroFile.filePath = xmlNode.SelectSingleNode("filePath").InnerText; methodElectroFile.beginLine = Convert.ToInt32(xmlNode.SelectSingleNode("beginLine").InnerText); //到原始路径下,重新获取一下数据表 methodElectroFile.transferDataTable = GenerateTransferFileDataTable(xmlNode); methodElectroFile.sourceLabware = xmlNode.SelectSingleNode("sourceLabware").InnerText; methodElectroFile.sourceWell = xmlNode.SelectSingleNode("sourceWell").InnerText; methodElectroFile.destinationLabware = xmlNode.SelectSingleNode("destinationLabware").InnerText; methodElectroFile.destinationWell = xmlNode.SelectSingleNode("destinationWell").InnerText; methodElectroFile.liquididText = xmlNode.SelectSingleNode("liquidid/text").InnerText; methodElectroFile.liquididValue = xmlNode.SelectSingleNode("liquidid/value").InnerText; methodElectroFile.liquidrangeidText = xmlNode.SelectSingleNode("liquidrangeid/text").InnerText; methodElectroFile.liquidrangeidValue = xmlNode.SelectSingleNode("liquidrangeid/value").InnerText; methodElectroFile.liquidpidText = xmlNode.SelectSingleNode("liquidpid/text").InnerText; methodElectroFile.liquidpidValue = xmlNode.SelectSingleNode("liquidpid/value").InnerText; return methodElectroFile; } public DataTable GenerateTransferFileDataTable(XmlNode xmlNode) { XmlNode xmlNodeList = xmlNode.SelectSingleNode("transferDataTable"); DataTable dt = new DataTable(); foreach (XmlNode xn in xmlNodeList.ChildNodes)// 列名称 { DataColumn dc = new DataColumn(); dc.ColumnName = xn.Attributes["columnname"].Value.ToString(); dt.Columns.Add(dc); } for (int j = 0; j < xmlNodeList.ChildNodes[0].ChildNodes.Count; j++)//行 { DataRow dr = dt.NewRow(); for (int i = 0; i < xmlNodeList.ChildNodes.Count; i++)//列 { dr[i] = xmlNodeList.ChildNodes[i].ChildNodes[j].InnerText; } dt.Rows.Add(dr); } return dt; } #region 检查所有属性设置是否满足要求 /// /// 检查所有属性设置是否满足要求 /// /// 切胶文件属性对象 /// 检查所有属性设置是否满足要求 public MethodPropertyInfo CheckProperty(MethodCoatingFile methodCoatingFile) { MethodPropertyInfo methodPropertyInfo = new MethodPropertyInfo(); if (strCurrentCulture == "zh-CN") { methodPropertyInfo.property_tips_info = CoatingFileResourceCHS.tipsInfo.ToString(); if (methodCoatingFile.filePath == null || methodCoatingFile.filePath == "") { methodPropertyInfo.property_name_info = CoatingFileResourceCHS.filePath.ToString(); } if (methodCoatingFile.transferDataTable == null || methodCoatingFile.transferDataTable.Rows.Count == 0) { methodPropertyInfo.property_name_info = CoatingFileResourceCHS.transferDataTable.ToString(); } if (methodCoatingFile.sourceLabware == null || methodCoatingFile.sourceLabware == "") { methodPropertyInfo.property_name_info = CoatingFileResourceCHS.sourceLabware.ToString(); } if (methodCoatingFile.sourceWell == null || methodCoatingFile.sourceWell == "") { methodPropertyInfo.property_name_info = CoatingFileResourceCHS.sourceWell.ToString(); } if (methodCoatingFile.destinationLabware == null || methodCoatingFile.destinationLabware == "") { methodPropertyInfo.property_name_info = CoatingFileResourceCHS.destinationLabware.ToString(); } if (methodCoatingFile.destinationWell == null || methodCoatingFile.destinationWell == "") { methodPropertyInfo.property_name_info = CoatingFileResourceCHS.destinationWell.ToString(); } if (methodCoatingFile.bacteriaText == null || methodCoatingFile.bacteriaText == "") { methodPropertyInfo.property_name_info = CoatingFileResourceCHS.bacteriaText.ToString(); } } else if (strCurrentCulture == "en-US") { methodPropertyInfo.property_tips_info = CoatingFileResourceENU.tipsInfo.ToString(); if (methodCoatingFile.filePath == null || methodCoatingFile.filePath == "") { methodPropertyInfo.property_name_info = CoatingFileResourceENU.filePath.ToString(); } if (methodCoatingFile.transferDataTable == null || methodCoatingFile.transferDataTable.Rows.Count == 0) { methodPropertyInfo.property_name_info = CoatingFileResourceENU.transferDataTable.ToString(); } if (methodCoatingFile.sourceLabware == null || methodCoatingFile.sourceLabware == "") { methodPropertyInfo.property_name_info = CoatingFileResourceENU.sourceLabware.ToString(); } if (methodCoatingFile.sourceWell == null || methodCoatingFile.sourceWell == "") { methodPropertyInfo.property_name_info = CoatingFileResourceENU.sourceWell.ToString(); } if (methodCoatingFile.destinationLabware == null || methodCoatingFile.destinationLabware == "") { methodPropertyInfo.property_name_info = CoatingFileResourceENU.destinationLabware.ToString(); } if (methodCoatingFile.destinationWell == null || methodCoatingFile.destinationWell == "") { methodPropertyInfo.property_name_info = CoatingFileResourceENU.destinationWell.ToString(); } if (methodCoatingFile.bacteriaText == null || methodCoatingFile.bacteriaText == "") { methodPropertyInfo.property_name_info = CoatingFileResourceENU.bacteriaText.ToString(); } } return methodPropertyInfo; } #endregion #region 执行切胶文件,返回结果对象 /// /// 执行切胶文件,返回结果对象 /// /// 切胶参数对象 /// 是否虚拟运行 /// 挑选执行结果 public HxResult ExecuteCutGum(CutGumMParam cutGumMParam, bool isSimulator) { HxResult ret = new HxResult(); if (!isSimulator) { ret = MethodAction.Instance.CutGum(cutGumMParam); } else { ret.Result = ResultType.Success; } return ret; } #endregion #region 执行排胶文件,返回结果对象 /// /// 执行排胶文件,返回结果对象 /// /// 排胶参数对象 /// 是否虚拟运行 /// 挑选执行结果 public HxResult ExecuteSpitGum(SpitGumMParam spitGumMParam, bool isSimulator) { HxResult ret = new HxResult(); if (!isSimulator) { ret = MethodAction.Instance.SpitGum(spitGumMParam); } else { ret.Result = ResultType.Success; } return ret; } #endregion #region 获取切胶通道数量 /// /// 获取切胶通道数量 /// /// /// public List GenerateCoatingCountOfChannel(string softwareDeviceNumber) { List dropdownNames = new List(); int channelCnt = Shared.ChannelCount; #region Del //if (softwareDeviceNumber.Equals(DeviceCategory.DeviceChoice)) //{ // channelCnt = 6; //} //else if (softwareDeviceNumber.Equals(DeviceCategory.DeviceLiteChoice) || // softwareDeviceNumber.Equals(DeviceCategory.DeviceT200)) //{ // channelCnt = 1; //} #endregion for (int i = 1; i <= channelCnt; i++) { DropdownName dropdownName = new DropdownName(); dropdownName.dropdown_id = i.ToString(); dropdownName.dropdown_name = i.ToString(); dropdownNames.Add(dropdownName); } return dropdownNames; } #endregion #region 把ObservableCollection转化为DataTable public DataTable ManualChoiceDataTypeChangeToDataTable(ObservableCollection manualChoiceDatas) { DataTable dataTable = new DataTable(); DataColumn dc = new DataColumn(); dc.ColumnName = "SourcePlate"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "SourceBarcode"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "SourcePlateWell"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "TargetPlate"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "TargetBarcode"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "TargetPlateWell"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "CutAction"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "ChangeTip"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "IsNewPlateBatch"; dataTable.Columns.Add(dc); dc = new DataColumn(); dc.ColumnName = "IsPlateLastWell"; dataTable.Columns.Add(dc); if (manualChoiceDatas != null) { foreach (ManualChoiceData manualChoiceData in manualChoiceDatas) { DataRow dr = dataTable.NewRow(); dr["SourcePlate"] = manualChoiceData.sourceplate; dr["SourceBarcode"] = manualChoiceData.sourceplate_num; dr["SourcePlateWell"] = manualChoiceData.machine_coordinate; dr["TargetPlate"] = manualChoiceData.targetplate; dr["TargetBarcode"] = manualChoiceData.targetplate_num; dr["TargetPlateWell"] = manualChoiceData.targetplate_well; dr["CutAction"] = 1; dr["ChangeTip"] = 1; dr["IsNewPlateBatch"] = manualChoiceData.is_new_plate_batch; dr["IsPlateLastWell"] = manualChoiceData.is_plate_last_well; dataTable.Rows.Add(dr); } } return dataTable; } #endregion } }