schangxiang@126.com
2025-11-04 f5ed29dc26c7cd952d56ec5721a2efc43cd25992
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
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
{
    /// <summary>
    /// 夹爪保持结束 属性页面
    /// </summary>
    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 构造函数
        /// <summary>
        /// 构造函数
        /// </summary>
        /// <param name="method"></param>
        public EndHoldingLabwareProperty(MethodEx method)
        {
            InitializeComponent();
 
            #region 臂
            // 获取机械臂信息
            List<DeviceArm> armList = DataModule.getInstance().GetDeviceArm();
            cbArm.ItemsSource = armList;
            #endregion
 
            #region 转运点位
            // 加载转运点位
            LoadGripPosition(Shared.ChanelArmId);
            #endregion
 
            #region 放板方向
            List<GripTransportModel> gripTransportModels = gripTransportBll.GenerateGripTransportModel(Shared.SoftwareInformation.software_device_number);
            cbGripModelSet.ItemsSource = gripTransportModels;
            #endregion
 
            #region 放在耗材上
            ObservableCollection<Labware> dropdownNames = LabwareDB.GetLabware(2);
            ObservableCollection<Labware> pickDropdownNames = new ObservableCollection<Labware>(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;
        /// <summary>
        /// 耗材变更后,更新节点
        /// </summary>
        /// <param name="consumableManagement">耗材管理对象</param>
        public void ReceiveAndUpdate(ConsumableManagement consumableManagement)
        {
            // 放在耗材上
            isConsumableUpdate = true;
            ObservableCollection<Labware> dropdownNames = LabwareDB.GetLabware(2);
            ObservableCollection<Labware> pickDropdownNames = new ObservableCollection<Labware>(dropdownNames);
            pickDropdownNames.Insert(0, new Labware() { labware_id = "-1", labware_name = "空板位" });
            cbGripPlaceObject.ItemsSource = pickDropdownNames;
            cbGripPlaceObject.SelectedValue = methodHoldingLabware.gripPlaceLabwareValue;
        }
 
        #region 加载转运点位
        /// <summary>
        /// 加载转运点位
        /// </summary>
        /// <param name="armId"></param>
        private void LoadGripPosition(int armId)
        {
            List<GripTransportPosition> gripPositionList = new List<GripTransportPosition>();
 
            // 获取台面点位
            List<Lattice> lattices = aspirateBll.ProviderLatticeList(Shared.SoftwareInformation.software_device_number, armId);
            // 获取台面以外点位
            List<PositionModel> 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 初始化
        /// <summary>
        /// 初始化
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void UserControl_Loaded(object sender, RoutedEventArgs e)
        {
            mark += 1;
            try
            {
                if (mark > 1)
                {
                    return;
                }
 
                List<DeviceArm> armList = (List<DeviceArm>)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 臂
        /// <summary>
        /// 臂
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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 转运板位
        /// <summary>
        /// 转运板位
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        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 放板方向
        /// <summary>
        /// 放板方向
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
 
        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)
        {
        }
    }
}