using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XImagingXhandler.XDAL;
using System.IO;
using System.Collections.ObjectModel;
using System.Xml;
using DriverLib.Engine;
using System.Web.UI.HtmlControls;
namespace XCore
{
///
/// 工作方法列表业务处理类
///
public class MethodListBll
{
#region 获取软件包含的方法列表信息集合
///
/// 获取软件包含的方法列表信息集合
///
/// 方法列表信息集合
public ObservableCollection GetMethodListInfo()
{
return MethodDB.GetMethodFromdb();
}
#endregion
#region 根据当前插入到方法序列中的Index判断,是否循环已经嵌套超过两层
public int IsNestOverTwo(int index)
{
int iResult = 0;
return iResult;
}
#endregion
#region 根据方法名称获取方法编号
///
/// 根据方法名称获取方法编号
///
/// 方法中文名
/// 方法编号
public int getNumByMethodName(string methodName)
{
int result = -1;
switch(methodName)
{
case "开始":
case "start":
return (int)MethodNameEnum.start;
case "吸液":
case "Method_Aspirate":
return (int)MethodNameEnum.aspirate;
case "加液":
case "Method_Dispense":
return (int)MethodNameEnum.dispense;
case "备注":
case "Method_Remark":
return (int)MethodNameEnum.remark;
case "文件":
case "Method_TransferFile":
return (int)MethodNameEnum.transferfile;
case "抓板转移":
case "Method_GripTransport":
return (int)MethodNameEnum.griptransport;
case "复位":
case "Method_Home":
return (int)MethodNameEnum.home;
case "混合":
case "Method_Mixing":
return (int)MethodNameEnum.mixing;
case "设置通道":
case "Method_SetChannel":
return (int)MethodNameEnum.setchannel;
case "安装枪头":
case "Method_LoadTips":
return (int)MethodNameEnum.loadtips;
case "卸载枪头":
case "Method_UnLoadTips":
return (int)MethodNameEnum.unloadtips;
case "组合开始":
case "组合":
case "Method_Group":
return (int)MethodNameEnum.group;
case "循环开始":
case "循环":
case "Method_Loop":
return (int)MethodNameEnum.loop;
case "暂停":
case "Method_PauseMove":
return (int)MethodNameEnum.pause;
case "振荡":
case "Method_Shaker":
return (int)MethodNameEnum.shaker;
case "温控":
case "Method_Warmer":
return (int)MethodNameEnum.warmer;
case "结束":
case "Method_End":
return (int)MethodNameEnum.end;
case "循环结束":
case "Method_EndLoop":
return (int)MethodNameEnum.endloop;
case "组合结束":
case "Method_EndGroup":
return (int)MethodNameEnum.endgroup;
case "拍照":
case "Method_TakePhoto":
return (int)MethodNameEnum.takephoto;
case "挑选":
case "Method_Choice":
return (int)MethodNameEnum.choice;
case "涂布":
case "Method_Coating":
return (int)MethodNameEnum.coating;
case "文件涂布":
case "Method_CoatingFile":
return (int)MethodNameEnum.coatingfile;
case "涂布报告":
case "涂布文件输出":
case "Method_CoatingReport":
return (int)MethodNameEnum.coatingReport;
case "设置变量":
case "Method_SetVariable":
return ((int)MethodNameEnum.setVariable);
case "移动夹爪":
case "Method_GripMove":
return ((int)MethodNameEnum.gripmove);
case "数据导入":
case "Method_DataImport":
return ((int)MethodNameEnum.dataimport);
case "数据导出":
case "Method_DataExport":
return ((int)MethodNameEnum.dataexport);
case "超声探测":
case "Method_Ultrasonic":
return ((int)MethodNameEnum.ultrasonic);
case "挑选转板":
case "Method_ChoiceTransfer":
return ((int)MethodNameEnum.choiceTransfer);
case "涂布转板":
case "Method_CoatingTransfer":
return ((int)MethodNameEnum.coatingTransfer);
case "梯度稀释":
case "Method_Dilution":
return ((int)MethodNameEnum.dilution);
case "夹爪保持开始":
case "夹爪保持":
case "Method_HoldingLabware":
return (int)MethodNameEnum.holdingLabware;
case "夹爪保持结束":
case "Method_EndHoldingLabware":
return (int)MethodNameEnum.endHoldingLabware;
case "变量导入":
case "Method_VariableImport":
return (int)MethodNameEnum.VariableImport;
case "if开始":
case "Method_ifStart":
return (int)MethodNameEnum.ifStart;
case "if结束":
case "Method_ifend":
return (int)MethodNameEnum.ifEnd;
case "else开始":
case "Method_elseStart":
return (int)MethodNameEnum.elseStart;
case "else结束":
case "Method_elseend":
return (int)MethodNameEnum.elseEnd;
case "计时器":
case "Method_timer":
return (int)MethodNameEnum.timerSet;
case "等待":
case "Method_waitfor":
return (int)MethodNameEnum.waitFor;
case "泵加液":
case "Method_pumpDispense":
return (int)MethodNameEnum.pumpDispense;
case "开关盖":
case "Method_switchLid":
return (int)MethodNameEnum.switchLid;
case "文件开关盖移液":
case "Method_fileMoveLiquid":
return (int)MethodNameEnum.fileMoveLiquid;
case "文件转板":
case "Method_fileMoveLabware":
return (int)MethodNameEnum.fileMoveLabware;
case "子方法":
case "Method_subMethod":
return (int)MethodNameEnum.subMethod;
case "计算":
case "Method_varCalc":
return (int)MethodNameEnum.varCalc;
case "文件切胶":
case "Method_fileCutGum":
return (int)MethodNameEnum.cutGum;
}
return result;
}
#endregion
#region 根据方法编号获取方法名称
///
/// 根据方法编号获取方法名称
///
/// 方法编号
/// 方法中文名
public string getNameByMethodNum(int methodNum)
{
string result = "";
switch (methodNum)
{
case (int)MethodNameEnum.start:
return "开始";
case (int)MethodNameEnum.aspirate:
return "吸液";
case (int)MethodNameEnum.dispense:
return "排液";
case (int)MethodNameEnum.remark:
return "备注";
case (int)MethodNameEnum.transferfile:
return "文件";
case (int)MethodNameEnum.griptransport:
return "抓板转移";
case (int)MethodNameEnum.home:
return "复位";
case (int)MethodNameEnum.mixing:
return "混合";
case (int)MethodNameEnum.setchannel:
return "设置通道";
case (int)MethodNameEnum.loadtips:
return "安装吸头";
case (int)MethodNameEnum.unloadtips:
return "卸载吸头";
case (int)MethodNameEnum.group:
return "组合";
case (int)MethodNameEnum.loop:
return "开始循环";
case (int)MethodNameEnum.pause:
return "暂停";
case (int)MethodNameEnum.shaker:
return "振荡";
case (int)MethodNameEnum.warmer:
return "温控";
case (int)MethodNameEnum.end:
return "结束";
}
return result;
}
#endregion
#region 根据工作站内部方法文件的基础路径,获取已经编辑的工作方法文件名称集合
public List GenerateMethodNamesByBaseMethodPath(string basePath)
{
List result = new List();
string[] files = Directory.GetFiles(basePath);
foreach(string file in files)
{
string fileName=file.Substring(file.LastIndexOf('\\')+1,file.Length - file.LastIndexOf('\\')-5);
result.Add(fileName);
}
return result;
}
#endregion
public DataCheckResult CheckWorkFlow(XmlDocument xmlDocument)
{
DataCheckResult dataCheckResult = new DataCheckResult();
dataCheckResult.result = 0;
//方法
XmlNodeList xmlNodeMethodList = xmlDocument.SelectNodes("root/method[@id>=1]");
//清空方法列表
for (int n = 0; n < xmlNodeMethodList.Count; n++)
{
string MethodName = xmlNodeMethodList[n].SelectSingleNode("name").InnerText;
string id = xmlNodeMethodList[n].Attributes["id"].Value.ToString();
int iNum = getNumByMethodName(MethodName);
switch (iNum)
{
case (int)MethodNameEnum.start:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.aspirate:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.dispense:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.end:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.endgroup:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.endloop:
//if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.griptransport:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.group:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.home:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.loadtips:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
LoadTipsBll loadTipsBll = new LoadTipsBll();
DataCheckResult dataCheckResult1 = loadTipsBll.CheckProperty(xmlNodeMethodList[n]);
if(dataCheckResult1.result== 1)
{
dataCheckResult.result = 1;
dataCheckResult.errorlist = dataCheckResult1.errorlist;
return dataCheckResult;
}
}
break;
case (int)MethodNameEnum.loop:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.mixing:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.pause:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.remark:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.transferfile:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.unloadtips:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
case (int)MethodNameEnum.setVariable:
if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
{
}
break;
}
}
return dataCheckResult;
}
}
}