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
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
using DataEntity.Share;
using DriverLib.Engine;
using HxEnum;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Data;
using System.Xml;
using XCommon;
using XCoreBLL.Resource;
using XImagingXhandler.XDAL;
 
namespace XCore
{
    public class CoatingFileBll
    {
        string strCurrentCulture = "";
        public CoatingFileBll()
        {
            strCurrentCulture = System.Threading.Thread.CurrentThread.CurrentCulture.Name;
        }
 
        public MethodCoatingFile GenerateMethodCoatingFileDataByXmlNode(XmlNode xmlNode)
        {
            MethodCoatingFile methodCoatingFile = new MethodCoatingFile();
 
            methodCoatingFile.isrun = xmlNode.SelectSingleNode("isrun").InnerText;
            methodCoatingFile.status = xmlNode.SelectSingleNode("status").InnerText;
            methodCoatingFile.name = xmlNode.SelectSingleNode("name").InnerText;
            methodCoatingFile.label = xmlNode.SelectSingleNode("label").InnerText;
            methodCoatingFile.strIndex = xmlNode.SelectSingleNode("strIndex").InnerText;
            methodCoatingFile.armText = xmlNode.SelectSingleNode("arm/text").InnerText;
            methodCoatingFile.armValue = xmlNode.SelectSingleNode("arm/value").InnerText;
            methodCoatingFile.labwaretipText = xmlNode.SelectSingleNode("labwaretip/text").InnerText;
            methodCoatingFile.labwaretipValue = xmlNode.SelectSingleNode("labwaretip/value").InnerText;
 
            string strchs = xmlNode.SelectSingleNode("channels").InnerText;
            methodCoatingFile.channels = ComUtility.GetChannelsFromXml(strchs);
 
            methodCoatingFile.filePath = xmlNode.SelectSingleNode("filePath").InnerText;
            methodCoatingFile.beginLine = Convert.ToInt32(xmlNode.SelectSingleNode("beginLine").InnerText);
            //到原始路径下,重新获取一下数据表
 
            methodCoatingFile.transferDataTable = GenerateTransferFileDataTable(xmlNode);
            methodCoatingFile.sourceLabware = xmlNode.SelectSingleNode("sourceLabware").InnerText;
            methodCoatingFile.sourceWell = xmlNode.SelectSingleNode("sourceWell").InnerText;
            if (xmlNode.SelectSingleNode("coatingOffset") != null)
            {
                methodCoatingFile.coatingOffset = Convert.ToDouble(xmlNode.SelectSingleNode("coatingOffset").InnerText);
            }
            else
            {
                methodCoatingFile.coatingOffset = 0d;
            }
            methodCoatingFile.destinationLabware = xmlNode.SelectSingleNode("destinationLabware").InnerText;
            methodCoatingFile.destinationWell = xmlNode.SelectSingleNode("destinationWell").InnerText;
            methodCoatingFile.bacteriaText = xmlNode.SelectSingleNode("bacteria/text").InnerText;
            methodCoatingFile.bacteriaValue = xmlNode.SelectSingleNode("bacteria/value").InnerText;
            if (xmlNode.SelectSingleNode("choiceCategory") != null)
            {
                // 挑菌方式 1:单选; 2:穿刺; 3:吸放液; 4:放液
                methodCoatingFile.choiceCategory = Convert.ToInt32(xmlNode.SelectSingleNode("choiceCategory").InnerText);
            }
            else
            {
                methodCoatingFile.choiceCategory = 0;
            }
 
            // 多块目标板涂布前要挑菌
            methodCoatingFile.pickEveryTime = (xmlNode.SelectSingleNode("pickEveryTime").InnerText.ToLower().ToString() == "true" ? true : false);
            // 多块目标板挑菌前要换枪头
            methodCoatingFile.pickAgoChangeTipEveryTime = (xmlNode.SelectSingleNode("pickAgoChangeTipEveryTime").InnerText.ToLower().ToString() == "true" ? true : false);
 
            // 涂布方式 1:回字型  2:Z字型;3:上下移动
            methodCoatingFile.coatingModeValue = Convert.ToInt32(xmlNode.SelectSingleNode("coatingmodeValue").InnerText);
            if (methodCoatingFile.coatingModeValue == EnumManagement.GetEnumValue(CoatingModeEnum.UpDownMode))
            {
                // 涂布方式为上下移动时次数
                methodCoatingFile.shakeCountValue = Convert.ToInt32(xmlNode.SelectSingleNode("shakeCountValue").InnerText);
                // 涂布方式为上下移动时的距离
                methodCoatingFile.shakeDistanceValue = Convert.ToDouble(xmlNode.SelectSingleNode("shakeDistanceValue").InnerText);
            }
 
            // 同时挑菌的通道数量
            methodCoatingFile.coatingCount = Convert.ToInt32(xmlNode.SelectSingleNode("coatingCount").InnerText);
            // 涂布自动开关盖
            methodCoatingFile.autoOpenCloseCoverCoating = (xmlNode.SelectSingleNode("autoOpenCloseCoverCoating").InnerText.ToLower().ToString() == "true" ? true : false);
 
            if (methodCoatingFile.coatingModeValue == EnumManagement.GetEnumValue(CoatingModeEnum.AspirateDispenseMode))    // 涂布方式 = 4:吸放液
            {
                #region 吸放液
                methodCoatingFile.liquididText = xmlNode.SelectSingleNode("liquidid/text").InnerText;
                methodCoatingFile.liquididValue = xmlNode.SelectSingleNode("liquidid/value").InnerText;
                methodCoatingFile.liquidrangeidText = xmlNode.SelectSingleNode("liquidrangeid/text").InnerText;
                methodCoatingFile.liquidrangeidValue = xmlNode.SelectSingleNode("liquidrangeid/value").InnerText;
                methodCoatingFile.liquidpidText = xmlNode.SelectSingleNode("liquidpid/text").InnerText;
                methodCoatingFile.liquidpidValue = xmlNode.SelectSingleNode("liquidpid/value").InnerText;
                methodCoatingFile.bMix = xmlNode.SelectSingleNode("enableMix").InnerText.ToLower() == "true" ? true : false;
                methodCoatingFile.mixvolume = Convert.ToDouble(xmlNode.SelectSingleNode("mixvolume").InnerText);
                methodCoatingFile.mixcount = Convert.ToInt32(xmlNode.SelectSingleNode("mixcount").InnerText);
                methodCoatingFile.mixAspiratePositionText = xmlNode.SelectSingleNode("mixAspiratePosition/text").InnerText;
                methodCoatingFile.mixAspiratePositionValue = Convert.ToInt32(xmlNode.SelectSingleNode("mixAspiratePosition/value").InnerText);
                methodCoatingFile.mixAspirateDistance = Convert.ToDouble(xmlNode.SelectSingleNode("mixAspirateDistance").InnerText);
                methodCoatingFile.mixAspirateSpeed = Convert.ToDouble(xmlNode.SelectSingleNode("mixAspirateSpeed").InnerText);
                methodCoatingFile.mixDispensePositionText = xmlNode.SelectSingleNode("mixDispensePosition/text").InnerText;
                methodCoatingFile.mixDispensePositionValue = Convert.ToInt32(xmlNode.SelectSingleNode("mixDispensePosition/value").InnerText);
                methodCoatingFile.mixDispenseDistance = Convert.ToDouble(xmlNode.SelectSingleNode("mixDispenseDistance").InnerText);
                methodCoatingFile.mixDispenseSpeed = Convert.ToDouble(xmlNode.SelectSingleNode("mixDispenseSpeed").InnerText);
                #endregion
            }
 
            // 获取挑菌前环境设置参数
            if (xmlNode.SelectSingleNode("bEnableBeforeAspirate") != null)
            {
                methodCoatingFile.choiceAgoAspirateData = CommonBll.GenerateChoiceAgoAspirateChildDataByXmlNode(xmlNode);
            }
 
            // 是否开启超声
            methodCoatingFile.isEnableultrasonic = false;
            if (xmlNode.SelectSingleNode("enableUltrasonic") != null)
            {
                methodCoatingFile.isEnableultrasonic = (xmlNode.SelectSingleNode("enableUltrasonic").InnerText.ToLower().ToString() == "true" ? true : false);
                if (methodCoatingFile.isEnableultrasonic)
                {
                    // 获取圆形皿耗材超声属性
                    methodCoatingFile.ultrasonicDishObjectList = GenerateUltrasonicDishObjectData(xmlNode);
                    // 获取非圆形皿耗材超声属性
                    methodCoatingFile.ultrasonicObjectList = GenerateUltrasonicObjectData(xmlNode);
                }
            }
 
            return methodCoatingFile;
        }
 
      
 
 
        /// <summary>
        /// 获取圆形皿耗材超声属性
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        public List<UltrasonicDishObject> GenerateUltrasonicDishObjectData(XmlNode xmlNode)
        {
            XmlNode xmlNode2 = xmlNode.SelectSingleNode("ultrasonicDishObject");
            List<UltrasonicDishObject> data = new List<UltrasonicDishObject>();
 
            foreach (XmlNode childNode in xmlNode2.ChildNodes)
            {
                UltrasonicDishObject ultrasonicDishObject = new UltrasonicDishObject();
                ultrasonicDishObject.labwareValue = childNode.SelectSingleNode("labwareValue").InnerText.ToString();
                ultrasonicDishObject.labwareText = childNode.SelectSingleNode("labwareText").InnerText.ToString();
                ObservableCollection<DropdownName> list = new ObservableCollection<DropdownName>();
                var a = childNode.SelectNodes("pointList/point");
                if (a != null)
                {
                    for (int i = 0; i < a.Count; i++)
                    {
                        DropdownName dropdownName = new DropdownName();
                        dropdownName.dropdown_id = a[i].SelectSingleNode("xAxisVal").InnerText.ToString();
                        dropdownName.dropdown_name = a[i].SelectSingleNode("yAxisVal").InnerText.ToString();
                        dropdownName.index_id = i + 1;
                        list.Add(dropdownName);
                    }
                }
                ultrasonicDishObject.pointList = list;
 
                data.Add(ultrasonicDishObject);
            }
 
            return data;
        }
 
        /// <summary>
        /// 获取非圆形皿耗材超声属性
        /// </summary>
        /// <param name="xmlNode"></param>
        /// <returns></returns>
        public List<UltrasonicObject> GenerateUltrasonicObjectData(XmlNode xmlNode)
        {
            XmlNode xmlNode2 = xmlNode.SelectSingleNode("ultrasonicObject");
            List<UltrasonicObject> data = new List<UltrasonicObject>();
 
            foreach (XmlNode childNode in xmlNode2.ChildNodes)
            {
                UltrasonicObject ultrasonicObject = new UltrasonicObject();
                ultrasonicObject.labwareValue = childNode.SelectSingleNode("labwareValue").InnerText.ToString();
                ultrasonicObject.labwareText = childNode.SelectSingleNode("labwareText").InnerText.ToString();
 
                ultrasonicObject.rowNum = Convert.ToInt32(childNode.SelectSingleNode("rowNum").InnerText.ToString());
                ultrasonicObject.columnNum = Convert.ToInt32(childNode.SelectSingleNode("columnNum").InnerText.ToString());
 
                ultrasonicObject.closeTopVal = Convert.ToDouble(childNode.SelectSingleNode("closeTopVal").InnerText.ToString());
                ultrasonicObject.closeLeftVal = Convert.ToDouble(childNode.SelectSingleNode("closeLeftVal").InnerText.ToString());
 
                ultrasonicObject.xAxisVal = Convert.ToDouble(childNode.SelectSingleNode("xAxisVal").InnerText.ToString());
                ultrasonicObject.yAxisVal = Convert.ToDouble(childNode.SelectSingleNode("yAxisVal").InnerText.ToString());
 
                data.Add(ultrasonicObject);
            }
 
            return data;
        }
 
        public DataTable GenerateTransferFileDataTable(XmlNode xmlNode)
        {
            XmlNode xmlNode2 = xmlNode.SelectSingleNode("transferDataTable");
            DataTable dataTable = new DataTable();
            foreach (XmlNode childNode in xmlNode2.ChildNodes)
            {
                DataColumn dataColumn = new DataColumn();
                dataColumn.ColumnName = childNode.Name.ToString();
                dataTable.Columns.Add(dataColumn);
            }
            if (xmlNode2.ChildNodes[0] != null)
            {
                for (int i = 0; i < xmlNode2.ChildNodes[0].ChildNodes.Count; i++)
                {
                    DataRow dataRow = dataTable.NewRow();
                    for (int j = 0; j < xmlNode2.ChildNodes.Count; j++)
                    {
                        dataRow[j] = xmlNode2.ChildNodes[j].ChildNodes[i].InnerText;
                    }
 
                    dataTable.Rows.Add(dataRow);
                }
            }
 
            return dataTable;
        }
 
        #region 检查所有属性设置是否满足要求
        /// <summary>
        /// 检查所有属性设置是否满足要求
        /// </summary>
        /// <param name="methodAspirate">涂布文件属性对象</param>
        /// <returns>检查所有属性设置是否满足要求</returns>
        public MethodPropertyInfo CheckProperty(MethodCoatingFile methodCoatingFile)
        {
            MethodPropertyInfo methodPropertyInfo = new MethodPropertyInfo();
 
            if (strCurrentCulture == "zh-CN")
            {
                methodPropertyInfo.property_tips_info = CoatingFileResourceCHS.tipsInfo.ToString();
 
                if (methodCoatingFile.filePath == null || methodCoatingFile.filePath == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceCHS.filePath.ToString();
                }
                if (methodCoatingFile.transferDataTable == null || methodCoatingFile.transferDataTable.Rows.Count == 0)
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceCHS.transferDataTable.ToString();
                }
                if (methodCoatingFile.sourceLabware == null || methodCoatingFile.sourceLabware == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceCHS.sourceLabware.ToString();
                }
                if (methodCoatingFile.sourceWell == null || methodCoatingFile.sourceWell == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceCHS.sourceWell.ToString();
                }
                if (methodCoatingFile.destinationLabware == null || methodCoatingFile.destinationLabware == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceCHS.destinationLabware.ToString();
                }
                if (methodCoatingFile.destinationWell == null || methodCoatingFile.destinationWell == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceCHS.destinationWell.ToString();
                }
                if (methodCoatingFile.bacteriaText == null || methodCoatingFile.bacteriaText == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceCHS.bacteriaText.ToString();
                }
            }
            else if (strCurrentCulture == "en-US")
            {
                methodPropertyInfo.property_tips_info = CoatingFileResourceENU.tipsInfo.ToString();
 
                if (methodCoatingFile.filePath == null || methodCoatingFile.filePath == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceENU.filePath.ToString();
                }
                if (methodCoatingFile.transferDataTable == null || methodCoatingFile.transferDataTable.Rows.Count == 0)
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceENU.transferDataTable.ToString();
                }
                if (methodCoatingFile.sourceLabware == null || methodCoatingFile.sourceLabware == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceENU.sourceLabware.ToString();
                }
                if (methodCoatingFile.sourceWell == null || methodCoatingFile.sourceWell == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceENU.sourceWell.ToString();
                }
                if (methodCoatingFile.destinationLabware == null || methodCoatingFile.destinationLabware == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceENU.destinationLabware.ToString();
                }
                if (methodCoatingFile.destinationWell == null || methodCoatingFile.destinationWell == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceENU.destinationWell.ToString();
                }
                if (methodCoatingFile.bacteriaText == null || methodCoatingFile.bacteriaText == "")
                {
                    methodPropertyInfo.property_name_info = CoatingFileResourceENU.bacteriaText.ToString();
                }
            }
            return methodPropertyInfo;
        }
        #endregion
 
        #region 执行涂布文件,返回结果对象
        /// <summary>
        /// 执行涂布文件,返回结果对象
        /// </summary>
        /// <param name="choiceMParam">卸载吸头的板位节点对象</param>
        /// <param name="isSimulator">是否虚拟运行</param>
        /// <returns>挑选执行结果</returns>
        public HxResult ExecuteChoice(ChoiceMParam choiceMParam, bool isSimulator)
        {
            HxResult ret = new HxResult();
            if (!isSimulator)
            {
                ret = MethodAction.Instance.Choice(choiceMParam);
            }
            else
            {
                ret.Result = ResultType.Success;
            }
 
            return ret;
        }
        #endregion
 
        #region 执行涂布文件,返回结果对象
        /// <summary>
        /// 执行涂布文件,返回结果对象
        /// </summary>
        /// <param name="choiceMParam">卸载吸头的板位节点对象</param>
        /// <param name="isSimulator">是否虚拟运行</param>
        /// <returns>挑选执行结果</returns>
        public HxResult ExecuteChoice(ChoiceMParamWH choiceMParam, bool isSimulator)
        {
            HxResult ret = new HxResult();
            if (!isSimulator)
            {
                ret = MethodAction.Instance.Choice(choiceMParam);
            }
            else
            {
                ret.Result = ResultType.Success;
            }
 
            return ret;
        }
        #endregion
 
        #region 获取涂布通道数量
        /// <summary>
        /// 获取涂布通道数量
        /// </summary>
        /// <param name="softwareDeviceNumber"></param>
        /// <returns></returns>
        public List<DropdownName> GenerateCoatingCountOfChannel(string softwareDeviceNumber)
        {
            List<DropdownName> dropdownNames = new List<DropdownName>();
            int channelCnt = Shared.ChannelCount;
 
            #region Del
            //if (softwareDeviceNumber.Equals(DeviceCategory.DeviceChoice))
            //{
            //    channelCnt = 6;
            //}
            //else if (softwareDeviceNumber.Equals(DeviceCategory.DeviceLiteChoice) ||
            //    softwareDeviceNumber.Equals(DeviceCategory.DeviceT200))
            //{
            //    channelCnt = 1;
            //}
            #endregion
 
            for (int i = 1; i <= channelCnt; i++)
            {
                DropdownName dropdownName = new DropdownName();
                dropdownName.dropdown_id = i.ToString();
                dropdownName.dropdown_name = i.ToString();
                dropdownNames.Add(dropdownName);
            }
            return dropdownNames;
        }
        #endregion
 
        #region 把ObservableCollection<ManualChoiceData>转化为DataTable
        public DataTable ManualChoiceDataTypeChangeToDataTable(ObservableCollection<ManualChoiceData> manualChoiceDatas)
        {
            DataTable dataTable = new DataTable();
            DataColumn dc = new DataColumn();
            dc.ColumnName = "SourceA";
            dataTable.Columns.Add(dc);
 
            dc = new DataColumn();
            dc.ColumnName = "SourceBarcode";
            dataTable.Columns.Add(dc);
 
            dc = new DataColumn();
            dc.ColumnName = "SourceCoordinate";
            dataTable.Columns.Add(dc);
 
            dc = new DataColumn();
            dc.ColumnName = "TargetB";
            dataTable.Columns.Add(dc);
 
            dc = new DataColumn();
            dc.ColumnName = "TargetBarcode";
            dataTable.Columns.Add(dc);
 
            dc = new DataColumn();
            dc.ColumnName = "TargetWell";
            dataTable.Columns.Add(dc);
 
            dc = new DataColumn();
            dc.ColumnName = "IsNewPlateBatch";
            dataTable.Columns.Add(dc);
 
            dc = new DataColumn();
            dc.ColumnName = "IsPlateLastWell";
            dataTable.Columns.Add(dc);
 
            if (manualChoiceDatas != null)
            {
                foreach (ManualChoiceData manualChoiceData in manualChoiceDatas)
                {
                    DataRow dr = dataTable.NewRow();
                    dr["SourceA"] = manualChoiceData.sourceplate;
                    dr["SourceBarcode"] = manualChoiceData.sourceplate_num;
                    dr["SourceCoordinate"] = manualChoiceData.machine_coordinate;
                    dr["TargetB"] = manualChoiceData.targetplate;
                    dr["TargetBarcode"] = manualChoiceData.targetplate_num;
                    dr["TargetWell"] = manualChoiceData.targetplate_well;
                    dr["IsNewPlateBatch"] = manualChoiceData.is_new_plate_batch;
                    dr["IsPlateLastWell"] = manualChoiceData.is_plate_last_well;
                    dataTable.Rows.Add(dr);
                }
            }
 
            return dataTable;
        }
        #endregion
    }
}