using System;
|
using System.Collections.Generic;
|
using System.Linq;
|
using System.Text;
|
using System.Threading.Tasks;
|
using System.Windows;
|
using System.Windows.Controls;
|
using System.Windows.Data;
|
using System.Windows.Documents;
|
using System.Windows.Input;
|
using System.Windows.Media;
|
using System.Windows.Media.Imaging;
|
using System.Windows.Navigation;
|
using System.Windows.Shapes;
|
using XImagingXhandler.XDAL;
|
using DataEntity.Share;
|
using DataEntity;
|
using System.Collections.ObjectModel;
|
using XHandler.Class.DataEx;
|
using System.Runtime.Remoting.Channels;
|
using XCommon.Log;
|
using XHandler.Controls;
|
using DataRWDAL;
|
using HandyControl.Data;
|
using XCommon.Tip;
|
using System.Windows.Shell;
|
|
namespace XHandler.View.MethodProperty
|
{
|
/// <summary>
|
/// SwitchLidProperty.xaml 的交互逻辑
|
/// </summary>
|
public partial class SwitchLidProperty : UserControl,IMethodProperty
|
{
|
public MethodSwitchLid methodSwitchLid { get; set; }
|
public MethodEx method = null;
|
|
public MethodSwitchLid currmethodSwitchLid = null;
|
|
#region 变量
|
string isrun = "";
|
string status = "";
|
string name = "";
|
string label = "";
|
string labwareText = "";
|
string labwareValue = "";
|
string positionText = "";
|
string positionValue = "";
|
string armText = "";
|
string armValue = "";
|
string wellarray = "";
|
int switchState = 0;
|
double numOfCircle = 0;
|
double switchSpeed = 0;
|
int curArmSelectedIndex = -1;
|
private Labware selectedLabware = null;
|
int mark = 0;
|
#endregion
|
|
public SwitchLidProperty()
|
{
|
InitializeComponent();
|
}
|
|
public SwitchLidProperty(MethodEx method)
|
{
|
mark = 0;
|
InitializeComponent();
|
|
List<DeviceArm> armList = DataModule.getInstance().GetDeviceArm();
|
cbArm.ItemsSource = armList;
|
if (armList.Count == 2) //只有一个臂的情况下默认选中该臂
|
{
|
curArmSelectedIndex = 1;
|
}
|
else if (armList.Count == 5)
|
{
|
curArmSelectedIndex = 2;
|
}
|
else
|
{
|
curArmSelectedIndex = 0;
|
}
|
|
//加载台面
|
List<string> list = new List<string>();
|
List<Lattice> lattices = DataModule.getInstance().GetLattices();
|
TabletopTemplate tabletopTemplate = TabletopTemplateDB.GetCurrentAppTabletopTemplateCollectionFromdb(); //增加台面模板判断
|
if (tabletopTemplate == null)
|
{
|
for (int i = 0; i < Shared.SoftwareInformation.columns; i++)
|
{
|
for (int j = 0; j < Shared.SoftwareInformation.rows; j++)
|
{
|
int tmp = i * Shared.SoftwareInformation.rows + j;
|
Lattice latt = lattices[tmp];
|
if (latt.is_trash == 1)
|
continue;
|
list.Add(latt.lattice_num);
|
}
|
}
|
}
|
else
|
{
|
foreach (Lattice lattice in lattices)
|
{
|
if (lattice.is_trash == 1)
|
continue;
|
list.Add(lattice.lattice_num);
|
}
|
}
|
comboboxTablePos.ItemsSource = list;
|
comboboxTablePos.SelectedIndex = 0;
|
|
|
tbxCommandLabel.Text = method.method_name;
|
methodSwitchLid = new MethodSwitchLid();
|
methodSwitchLid.name = method.method_name;
|
methodSwitchLid.label = method.method_name;
|
methodSwitchLid.status = (method.isEnabled == true ? "enable" : "disable");
|
methodSwitchLid.strIndex = method.strIndex;
|
methodSwitchLid.wellarray = "";
|
|
this.method = method;
|
if (method.tag != null)
|
{
|
methodSwitchLid = (MethodSwitchLid)method.tag;
|
|
currmethodSwitchLid = methodSwitchLid;
|
|
isrun = methodSwitchLid.isrun;
|
status = methodSwitchLid.status;
|
name = methodSwitchLid.name;
|
label = methodSwitchLid.label;
|
labwareText = methodSwitchLid.labwareText;
|
labwareValue = methodSwitchLid.labwareValue;
|
positionText = methodSwitchLid.positionText;
|
positionValue = methodSwitchLid.positionValue;
|
armText = methodSwitchLid.armText;
|
armValue = methodSwitchLid.armValue;
|
switchState = methodSwitchLid.switchState;
|
numOfCircle=methodSwitchLid.numOfCircle;
|
switchSpeed= methodSwitchLid.switchSpeed;
|
wellarray = methodSwitchLid.wellarray;
|
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("执行{0}盖;旋转速度:{1};旋转圈数:{2}", methodSwitchLid.switchState == 1 ? "关" : "开", methodSwitchLid.switchSpeed.ToString(), methodSwitchLid.numOfCircle.ToString());
|
}
|
}
|
this.DataContext = methodSwitchLid;
|
}
|
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
{
|
mark += 1;
|
try
|
{
|
if (mark > 1)
|
{
|
return;
|
}
|
if (!string.IsNullOrEmpty(armText))
|
{
|
tbxCommandName.Text = name;
|
cbArm.SelectedValue = armValue;
|
DeviceArm arm = cbArm.SelectedItem as DeviceArm;
|
comboboxTablePos.SelectedItem = positionText;
|
tbxWellPositionTips.Text = wellarray;
|
//根据板位上的耗材类型,显示耗材孔位示意图
|
Labware labwareA = DataRWDAL.LabwareDB.GetLabware(methodSwitchLid.labwareValue);
|
|
wellPlate.Rows = labwareA.number_row;
|
wellPlate.Columns = labwareA.number_column;
|
|
if (labwareA.labware_type_id.Equals("4"))
|
{
|
labwareA.labwareWellInfoList = DataRWDAL.LabwareDB.GetSpecialLabwareWellInfo(labwareA.labware_id);
|
wellPlate.labwareWellInfoList = labwareA.labwareWellInfoList;
|
wellPlate.LabwareRealWidth = labwareA.labware_length;
|
wellPlate.LabwareRealLength = labwareA.labware_width;
|
}
|
|
wellPlate.Selection = wellarray;
|
|
if(switchState==0)
|
{
|
radioBtnSwitchOpen.IsChecked = true;
|
}
|
else if(switchState==1)
|
{
|
radioBtnSwitchClose.IsChecked = true;
|
}
|
}
|
else
|
{
|
radioBtnSwitchOpen.IsChecked = true;
|
|
cbArm.SelectedIndex = curArmSelectedIndex;
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void radioBtnSwitchOpen_Checked(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
if (methodSwitchLid != null)
|
{
|
methodSwitchLid.switchState = 0;
|
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("执行{0}盖;旋转速度:{1};旋转圈数:{2}","开", methodSwitchLid.switchSpeed.ToString(), methodSwitchLid.numOfCircle.ToString());
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void radioBtnSwitchClose_Checked(object sender, RoutedEventArgs e)
|
{
|
try
|
{
|
if (methodSwitchLid != null)
|
{
|
methodSwitchLid.switchState = 1;
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("执行{0}盖;旋转速度:{1};旋转圈数:{2}", "关", methodSwitchLid.switchSpeed.ToString(), methodSwitchLid.numOfCircle.ToString());
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxCommandLabel_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
|
if (methodSwitchLid != null)
|
{
|
methodSwitchLid.label = tbxCommandLabel.Text;
|
methodSwitchLid.name = tbxCommandName.Text.ToString();
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxCommandName_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
|
if (methodSwitchLid != null)
|
{
|
methodSwitchLid.label = tbxCommandLabel.Text;
|
methodSwitchLid.name = tbxCommandName.Text.ToString();
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
{
|
try
|
{
|
// 臂未选择
|
if (cbArm.SelectedIndex < 0 || cbArm.SelectedIndex == 0)
|
{
|
return;
|
}
|
|
string armName = ((DeviceArm)cbArm.SelectedItem).device_arm_name.ToString();
|
DeviceArm arm = cbArm.SelectedItem as DeviceArm;
|
methodSwitchLid.armText = arm.device_arm_name;
|
methodSwitchLid.armValue = arm.device_arm_id.ToString();
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
#region 设置某些属性信息值
|
public void SetTableName(string tableName, Labware lb)
|
{
|
try
|
{
|
if (lb == null)
|
return;
|
if (string.IsNullOrEmpty(lb.labware_id))
|
return;
|
selectedLabware = lb;
|
wellPlate.Rows = lb.number_row;
|
wellPlate.Columns = lb.number_column;
|
wellPlate.labwareWellInfoList = lb.labwareWellInfoList;
|
wellPlate.LabwareRealWidth = lb.labware_length;
|
wellPlate.LabwareRealLength = lb.labware_width;
|
wellPlate.DataContext = lb;
|
|
List<Lattice> latticeList = DataRWDAL.LatticeDB.GetGripperLatticeNumDataFromdb(Shared.SoftwareInformation.software_device_number, Convert.ToInt32(Shared.DeviceArmList.FirstOrDefault(x=>x.arm_type.Equals(1)).device_arm_id));
|
Lattice lattice = latticeList.Find(s => s.lattice_num == tableName);
|
if (lattice == null)
|
{
|
LoggerHelper.InfoLog("Error: Can't find lattice with lattice_num=" + tableName);
|
return;
|
}
|
comboboxTablePos.SelectedItem = tableName;
|
if (lb.labware_tubeshelf_type.Equals(1))//异形管架耗材
|
{
|
tbxWellPositionTips.Text = "";
|
wellPlate.Selection = "";
|
}
|
if (methodSwitchLid != null)
|
{
|
methodSwitchLid.positionText = tableName;
|
methodSwitchLid.positionValue = lattice.lattice_id; //Id 在运行时不能作为条件去查询板位夹爪的坐标,只能用lattice_num
|
methodSwitchLid.labwareText = lb.labware_name;
|
methodSwitchLid.labwareValue = lb.labware_id;
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
#endregion
|
|
private void comboboxTablePos_SelectionChanged(object sender, SelectionChangedEventArgs e)
|
{
|
try
|
{
|
if (comboboxTablePos.SelectedItem == null)
|
return;
|
string name = comboboxTablePos.SelectedItem as string;
|
SetTableName(name, selectedLabware);
|
|
#region 验证台面耗材类型
|
if (TestDesign.SelectLabwares.Count() <= 0 || TestDesign.SelectLabwares.FirstOrDefault(m => m.Label.Equals(comboboxTablePos.SelectedValue.ToString())) == null)
|
return;
|
|
ControlLabware labware = TestDesign.SelectLabwares.FirstOrDefault(m => m.Label.Equals(comboboxTablePos.SelectedValue.ToString()));
|
if ("1,3,5,4".Contains(labware.LabwareType.ToString()))
|
{
|
tbkErrorWellPosition.Text = "";
|
}
|
else
|
{
|
tbkErrorWellPosition.Text = $"不能在耗材 [{labware.LabwareName}] 执行吸液";
|
}
|
#endregion
|
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
}
|
}
|
|
private void tbxNumOfCircleTransfer_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
if (methodSwitchLid != null)
|
{
|
methodSwitchLid.numOfCircle = Convert.ToDouble(tbxNumOfCircleTransfer.Text);
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("执行{0}盖;旋转速度:{1};旋转圈数:{2}", methodSwitchLid.switchState==1?"关":"开", methodSwitchLid.switchSpeed.ToString(), methodSwitchLid.numOfCircle.ToString());
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
return;
|
}
|
}
|
|
private void tbxSpeedOfCircleTransfer_TextChanged(object sender, TextChangedEventArgs e)
|
{
|
try
|
{
|
if (methodSwitchLid != null)
|
{
|
methodSwitchLid.switchSpeed = Convert.ToDouble(tbxSpeedOfCircleTransfer.Text);
|
if (this.method != null)
|
{
|
this.method.method_Tipcontent = string.Format("执行{0}盖;旋转速度:{1};旋转圈数:{2}", methodSwitchLid.switchState == 1 ? "关" : "开", methodSwitchLid.switchSpeed.ToString(), methodSwitchLid.numOfCircle.ToString());
|
}
|
}
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("ERROR:", ex);
|
return;
|
}
|
}
|
|
private void wellPlate_MouseLeftButtonDown(object sender, MouseButtonEventArgs e)
|
{
|
try
|
{
|
tbxWellPositionTips.Text = wellPlate.Selection;
|
}
|
catch (Exception ex)
|
{
|
LoggerHelper.ErrorLog("wellPlate_MouseLeftButtonDown ERROR:", ex);
|
}
|
}
|
}
|
}
|