using DataEntity.Rack; using DataEntity.Share; using DataRWDAL; using DataRWDAL.Rack; using HxEnum; using System; using System.Collections.Generic; using System.Collections.ObjectModel; using System.Linq; using System.Windows; using System.Windows.Controls; using XCommon.Log; using XCore; using XHandler.Class; using XHandler.Class.DataEx; using XHandler.View.Dialog; using XImagingXhandler.XDAL; using XHandler.View.Consumables; namespace XHandler.View.MethodProperty { /// /// 夹爪保持结束 属性页面 /// public partial class EndHoldingLabwareProperty : UserControl, IMethodProperty,IConsumableObserver { #region 变量 private MethodEx method = null; public MethodHoldingLabware methodHoldingLabware { get; set; } private int mark = 0; #endregion #region BLL private AspirateBll aspirateBll = new AspirateBll(); private GripTransportBll gripTransportBll = new GripTransportBll(); #endregion #region 构造函数 /// /// 构造函数 /// /// public EndHoldingLabwareProperty(MethodEx method) { InitializeComponent(); #region 臂 // 获取机械臂信息 List armList = DataModule.getInstance().GetDeviceArm(); cbArm.ItemsSource = armList; #endregion #region 转运点位 // 加载转运点位 LoadGripPosition(Shared.ChanelArmId); #endregion #region 放板方向 List gripTransportModels = gripTransportBll.GenerateGripTransportModel(Shared.SoftwareInformation.software_device_number); cbGripModelSet.ItemsSource = gripTransportModels; #endregion #region 放在耗材上 ObservableCollection dropdownNames = LabwareDB.GetLabware(2); ObservableCollection pickDropdownNames = new ObservableCollection(dropdownNames); pickDropdownNames.Insert(0, new Labware() { labware_id = "-1", labware_name = "空板位" }); cbGripPlaceObject.ItemsSource = pickDropdownNames; #endregion methodHoldingLabware = new MethodHoldingLabware(); methodHoldingLabware.name = method.method_name; methodHoldingLabware.label = method.method_name; //methodHoldingLabware.transportMode = 0; methodHoldingLabware.status = (method.isEnabled == true ? "enable" : "disable"); methodHoldingLabware.strIndex = method.strIndex; this.method = method; if (method.tag != null) { methodHoldingLabware = (MethodHoldingLabware)method.tag; } this.DataContext = methodHoldingLabware; } #endregion bool isConsumableUpdate = false; /// /// 耗材变更后,更新节点 /// /// 耗材管理对象 public void ReceiveAndUpdate(ConsumableManagement consumableManagement) { // 放在耗材上 isConsumableUpdate = true; ObservableCollection dropdownNames = LabwareDB.GetLabware(2); ObservableCollection pickDropdownNames = new ObservableCollection(dropdownNames); pickDropdownNames.Insert(0, new Labware() { labware_id = "-1", labware_name = "空板位" }); cbGripPlaceObject.ItemsSource = pickDropdownNames; cbGripPlaceObject.SelectedValue = methodHoldingLabware.gripPlaceLabwareValue; } #region 加载转运点位 /// /// 加载转运点位 /// /// private void LoadGripPosition(int armId) { List gripPositionList = new List(); // 获取台面点位 List lattices = aspirateBll.ProviderLatticeList(Shared.SoftwareInformation.software_device_number, armId); // 获取台面以外点位 List positons = PositionDB.GetList(Shared.SoftwareInformation.software_information_id); foreach (var lattice in lattices) { if (!lattice.lattice_num.Equals("请选择")) { GripTransportPosition gripPosition = new GripTransportPosition(); gripPosition.position_id = lattice.lattice_id; gripPosition.position_name = lattice.lattice_num; gripPosition.position_type = EnumManagement.GetEnumValue(PositonTypeEnum.Desktop); gripPositionList.Add(gripPosition); } } foreach (var positon in positons) { GripTransportPosition gripPosition = new GripTransportPosition(); gripPosition.position_id = positon.id; gripPosition.position_name = positon.name; gripPosition.position_type = positon.type; gripPositionList.Add(gripPosition); } cbDestinationLattice.ItemsSource = gripPositionList; cbDestinationLattice.SelectedIndex = 0; } #endregion #region 初始化 /// /// 初始化 /// /// /// private void UserControl_Loaded(object sender, RoutedEventArgs e) { mark += 1; try { if (mark > 1) { return; } List armList = (List)cbArm.ItemsSource; DeviceArm gripper = armList.FirstOrDefault(it => it.arm_type == EnumManagement.GetEnumValue(ArmTypeEnum.Gripper)); cbArm.SelectedItem = gripper; if (!string.IsNullOrEmpty(methodHoldingLabware.armValue)) { // 机械臂 cbArm.SelectedValue = methodHoldingLabware.armValue; // 放板位 cbDestinationLattice.SelectedValue = methodHoldingLabware.desPositionValue; // 放板方向 cbGripModelSet.SelectedValue = methodHoldingLabware.gripModelSetValue; // 放在耗材上 cbGripPlaceObject.SelectedValue = methodHoldingLabware.gripPlaceLabwareValue; if (this.method != null) { this.method.method_Tipcontent = string.Format("放板到{0}", methodHoldingLabware.desPositionText); } } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } #endregion #region 臂 /// /// 臂 /// /// /// private void cbArm_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cbArm.SelectedIndex < 0) { return; } DeviceArm arm = (DeviceArm)cbArm.SelectedItem; methodHoldingLabware.armText = arm.device_arm_name; methodHoldingLabware.armValue = arm.device_arm_id.ToString(); } #endregion #region 转运板位 /// /// 转运板位 /// /// /// private void cbDestinationLattice_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (cbDestinationLattice.SelectedIndex < 0 || mark == 0) { return; } if (cbDestinationLattice.SelectedIndex >= 0) { GripTransportPosition gripPosition = cbDestinationLattice.SelectedItem as GripTransportPosition; if (methodHoldingLabware != null) { methodHoldingLabware.desPositionText = gripPosition.position_name; methodHoldingLabware.desPositionValue = gripPosition.position_id; methodHoldingLabware.desPositionType = gripPosition.position_type; } if (this.method != null) { this.method.method_Tipcontent = string.Format("放板到{0}", methodHoldingLabware.desPositionText); } } } #endregion #region 放板方向 /// /// 放板方向 /// /// /// private void cbGripModelSet_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { GripTransportModel gripTransportModel = cbGripModelSet.SelectedItem as GripTransportModel; if (methodHoldingLabware != null) { methodHoldingLabware.gripModelSetText = gripTransportModel.model_name; methodHoldingLabware.gripModelSetValue = Convert.ToInt32(gripTransportModel.model_id); } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } #endregion #region 放在耗材上 private void cbGripPlaceObject_SelectionChanged(object sender, SelectionChangedEventArgs e) { try { if (isConsumableUpdate) { isConsumableUpdate = false; return; } Labware gripTransportModel = cbGripPlaceObject.SelectedItem as Labware; if (methodHoldingLabware != null) { methodHoldingLabware.gripPlaceLabwareText = gripTransportModel.labware_name; methodHoldingLabware.gripPlaceLabwareValue = gripTransportModel.labware_id; } } catch (Exception ex) { LoggerHelper.ErrorLog("ERROR:", ex); } } #endregion public void SetTableName(string name, Labware labware) { } } }