using DriverLib.Engine;
using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Runtime.Remoting.Channels;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
using XCommon;
using XCoreBLL.Resource;
using XImagingXhandler.XDAL;
namespace XCore
{
public class LoadTipsBll
{
string strCurrentCulture = "";
WellCalc wellCalc = new WellCalc();
LatticeBll latticeBll = new LatticeBll();
public LoadTipsBll()
{
strCurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
}
public MethodLoadTips GenerateMethodLoadTipsDataByXmlNode(XmlNode xmlNode)
{
MethodLoadTips methodLoadTips= new MethodLoadTips();
methodLoadTips.isrun = xmlNode.SelectSingleNode("isrun").InnerText;
methodLoadTips.status = xmlNode.SelectSingleNode("status").InnerText;
methodLoadTips.name = xmlNode.SelectSingleNode("name").InnerText;
methodLoadTips.label = xmlNode.SelectSingleNode("label").InnerText;
methodLoadTips.strIndex = xmlNode.SelectSingleNode("strIndex").InnerText;
//methodLoadTips.labwareValue = xmlNode.SelectSingleNode("").InnerText;
//methodLoadTips.positionText = xmlNode.SelectSingleNode("").InnerText;
//methodLoadTips.positionValue = xmlNode.SelectSingleNode("").InnerText;
methodLoadTips.armText = xmlNode.SelectSingleNode("arm/text").InnerText;
methodLoadTips.armValue = xmlNode.SelectSingleNode("arm/value").InnerText;
//methodLoadTips.headType = xmlNode.SelectSingleNode("").InnerText;
methodLoadTips.labwaretipText = xmlNode.SelectSingleNode("labwaretip/text").InnerText;
methodLoadTips.labwaretipValue = xmlNode.SelectSingleNode("labwaretip/value").InnerText;
//methodLoadTips.wellarray = xmlNode.SelectSingleNode("").InnerText;
string strchs= xmlNode.SelectSingleNode("channels").InnerText;
methodLoadTips.channels = ComUtility.GetChannelsFromXml(strchs);
return methodLoadTips;
}
#region 检查所有属性设置是否满足要求
///
/// 检查所有属性设置是否满足要求
///
/// 吸液属性对象
/// 检查所有属性设置是否满足要求
public MethodPropertyInfo CheckProperty(MethodLoadTips methodLoadTips)
{
MethodPropertyInfo methodPropertyInfo = new MethodPropertyInfo();
if (strCurrentCulture == "zh-CN")
{
methodPropertyInfo.property_tips_info = LoadTipsResourceCHS.tipsInfo.ToString();
if (methodLoadTips.labwaretipText == null || methodLoadTips.labwaretipText == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceCHS.labwareText.ToString();
}
if (methodLoadTips.positionValue == null || methodLoadTips.positionValue == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceCHS.positionText.ToString();
}
if (methodLoadTips.armValue == null || methodLoadTips.armValue == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceCHS.armText.ToString();
}
else
{
if(methodLoadTips.armValue== "arm1")
{
if(LoadTipsResourceCHS.wellarray.Contains(","))
{
methodPropertyInfo.property_name_info = LoadTipsResourceCHS.armWithSingleChannel.ToString();
methodPropertyInfo.property_tips_info = LoadTipsResourceCHS.errorInfo.ToString();
}
}
else if(methodLoadTips.armValue == "arm2")
{
if (!LoadTipsResourceCHS.wellarray.Contains(","))
{
methodPropertyInfo.property_name_info = LoadTipsResourceCHS.armWithSingleChannel.ToString();
methodPropertyInfo.property_tips_info = LoadTipsResourceCHS.errorInfo.ToString();
}
}
}
if (methodLoadTips.wellarray == null || methodLoadTips.wellarray == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceCHS.wellarray.ToString();
}
}
else if (strCurrentCulture == "en-US")
{
methodPropertyInfo.property_tips_info = LoadTipsResourceENU.tipsInfo.ToString();
if (methodLoadTips.labwaretipText == null || methodLoadTips.labwaretipText == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceENU.labwareText.ToString();
}
if (methodLoadTips.positionValue == null || methodLoadTips.positionValue == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceENU.positionText.ToString();
}
if (methodLoadTips.armValue == null || methodLoadTips.armValue == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceENU.armText.ToString();
}
else
{
if (methodLoadTips.armValue == "arm1")
{
if (LoadTipsResourceENU.wellarray.Contains(","))
{
methodPropertyInfo.property_name_info = LoadTipsResourceENU.armWithSingleChannel.ToString();
methodPropertyInfo.property_tips_info = LoadTipsResourceENU.errorInfo.ToString();
}
}
else if (methodLoadTips.armValue == "arm2")
{
if (!LoadTipsResourceENU.wellarray.Contains(","))
{
methodPropertyInfo.property_name_info = LoadTipsResourceENU.armWithSingleChannel.ToString();
methodPropertyInfo.property_tips_info = LoadTipsResourceENU.errorInfo.ToString();
}
}
}
if (methodLoadTips.wellarray == null || methodLoadTips.wellarray == "")
{
methodPropertyInfo.property_name_info = LoadTipsResourceENU.labwareText.ToString();
}
}
return methodPropertyInfo;
}
#endregion
#region 执行装载吸头,返回结果字符串
///
/// 执行装载吸头,返回结果字符串
///
/// 装载吸头的板位节点对象
///
/// 结果实体对象
public HxResult ExecuteLoadTips(LoadTipsMParam loadTipsMParam,bool isSimulator=false)
{
HxResult ret = new HxResult();
if (!isSimulator)
{
ret = MethodAction.Instance.LoadTip(loadTipsMParam);
}
else
{
ret.Result = ResultType.Success;
}
return ret;
}
#endregion
#region 执行装载吸头,返回结果字符串
///
/// 执行装载吸头,返回结果字符串
///
/// 装载吸头的板位节点对象
///
/// 结果实体对象
public HxResult ExecuteLoadTips(LoadTipsMParamSH loadTipsMParam, bool isSimulator = false)
{
HxResult ret = new HxResult();
if (!isSimulator)
{
ret = MethodAction.Instance.LoadTip(loadTipsMParam);
}
else
{
ret.Result = ResultType.Success;
}
return ret;
}
#endregion
#region 检查所有属性设置是否满足要求
///
/// 检查所有属性设置是否满足要求
///
/// 吸液属性对象
/// 检查所有属性设置是否满足要求
public DataCheckResult CheckProperty(XmlNode xmlNode)
{
DataCheckResult dataCheckResult = new DataCheckResult();
dataCheckResult.result = 0;
dataCheckResult.errorlist = new List();
dataCheckResult.errorlist.Add("LoadTips method:");
if (strCurrentCulture == "zh-CN")
{
string armValue = xmlNode.SelectSingleNode("arm/value").InnerText;
if(string.IsNullOrEmpty(armValue)||armValue=="0")
{
dataCheckResult.result = 1;
dataCheckResult.errorlist.Add(LoadTipsResourceCHS.armText.ToString()+"未设置;");
}
string channels = xmlNode.SelectSingleNode("channels").InnerText;
if(string.IsNullOrEmpty(channels))
{
dataCheckResult.result = 1;
dataCheckResult.errorlist.Add(LoadTipsResourceCHS.armWithSingleChannel.ToString() + "未设置;");
}
string labwaretiptype = xmlNode.SelectSingleNode("labwaretip/value").InnerText;
if (string.IsNullOrEmpty(labwaretiptype))
{
dataCheckResult.result = 1;
dataCheckResult.errorlist.Add(LoadTipsResourceCHS.labwaretipText.ToString() + "未设置;");
}
}
else if (strCurrentCulture == "en-US")
{
string armValue = xmlNode.SelectSingleNode("arm/value").InnerText;
if (string.IsNullOrEmpty(armValue)||armValue=="0")
{
dataCheckResult.result = 1;
dataCheckResult.errorlist.Add(LoadTipsResourceENU.armText.ToString() + "isn't set;");
}
string channels = xmlNode.SelectSingleNode("channels").InnerText;
if (string.IsNullOrEmpty(channels))
{
dataCheckResult.result = 1;
dataCheckResult.errorlist.Add(LoadTipsResourceENU.armWithSingleChannel.ToString() + "isn't set;");
}
string labwaretiptype = xmlNode.SelectSingleNode("labwaretip/value").InnerText;
if (string.IsNullOrEmpty(labwaretiptype))
{
dataCheckResult.result = 1;
dataCheckResult.errorlist.Add(LoadTipsResourceENU.labwaretipText.ToString() + "isn't set;");
}
}
return dataCheckResult;
}
#endregion
}
}