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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XImagingXhandler.XDAL;
using System.IO;
using System.Collections.ObjectModel;
using System.Xml;
using DriverLib.Engine;
using System.Web.UI.HtmlControls;
 
namespace XCore
{
    /// <summary>
    /// 工作方法列表业务处理类
    /// </summary>
    public class MethodListBll
    {
        #region 获取软件包含的方法列表信息集合
        /// <summary>
        /// 获取软件包含的方法列表信息集合
        /// </summary>
        /// <returns>方法列表信息集合</returns>
        public ObservableCollection<Method> GetMethodListInfo()
        {
            return MethodDB.GetMethodFromdb();
        }
        #endregion
 
        #region 根据当前插入到方法序列中的Index判断,是否循环已经嵌套超过两层
        public int IsNestOverTwo(int index)
        {
            int iResult = 0;
            return iResult;
        }
        #endregion
 
        #region 根据方法名称获取方法编号
        /// <summary>
        /// 根据方法名称获取方法编号
        /// </summary>
        /// <param name="methodName">方法中文名</param>
        /// <returns>方法编号</returns>
        public int getNumByMethodName(string methodName)
        {
            int result = -1;
            switch(methodName)
            {
                case "开始":
                case "start":
                    return (int)MethodNameEnum.start;
                case "吸液":
                case "Method_Aspirate":
                    return (int)MethodNameEnum.aspirate;
                case "加液":
                case "Method_Dispense":
                    return (int)MethodNameEnum.dispense;
                case "备注":
                case "Method_Remark":
                    return (int)MethodNameEnum.remark;
                case "文件":
                case "Method_TransferFile":
                    return (int)MethodNameEnum.transferfile;
                case "抓板转移":
                case "Method_GripTransport":
                    return (int)MethodNameEnum.griptransport;
                case "复位":
                case "Method_Home":
                    return (int)MethodNameEnum.home;
                case "混合":
                case "Method_Mixing":
                    return (int)MethodNameEnum.mixing;
                case "设置通道":
                case "Method_SetChannel":
                    return (int)MethodNameEnum.setchannel;
                case "安装枪头":
                case "Method_LoadTips":
                    return (int)MethodNameEnum.loadtips;
                case "卸载枪头":
                case "Method_UnLoadTips":
                    return (int)MethodNameEnum.unloadtips;
                case "组合开始":
                case "组合":
                case "Method_Group":
                    return (int)MethodNameEnum.group;
                case "循环开始":
                case "循环":
                case "Method_Loop":
                    return (int)MethodNameEnum.loop;
                case "暂停":
                case "Method_PauseMove":
                    return (int)MethodNameEnum.pause;
                case "振荡":
                case "Method_Shaker":
                    return (int)MethodNameEnum.shaker;
                case "温控":
                case "Method_Warmer":
                    return (int)MethodNameEnum.warmer;
                case "结束":
                case "Method_End":
                    return (int)MethodNameEnum.end;
                case "循环结束":
                case "Method_EndLoop":
                    return (int)MethodNameEnum.endloop;
                case "组合结束":
                case "Method_EndGroup":
                    return (int)MethodNameEnum.endgroup;
                case "拍照":
                case "Method_TakePhoto":
                    return (int)MethodNameEnum.takephoto;
                case "挑选":
                case "Method_Choice":
                    return (int)MethodNameEnum.choice;
                case "涂布":
                case "Method_Coating":
                    return (int)MethodNameEnum.coating;
                case "文件涂布":
                case "Method_CoatingFile":
                    return (int)MethodNameEnum.coatingfile;
                case "涂布报告":
                case "涂布文件输出":
                case "Method_CoatingReport":
                    return (int)MethodNameEnum.coatingReport;
                case "设置变量":
                case "Method_SetVariable":
                    return ((int)MethodNameEnum.setVariable);
                case "移动夹爪":
                case "Method_GripMove":
                    return ((int)MethodNameEnum.gripmove);
                case "数据导入":
                case "Method_DataImport":
                    return ((int)MethodNameEnum.dataimport);
                case "数据导出":
                case "Method_DataExport":
                    return ((int)MethodNameEnum.dataexport);
                case "超声探测":
                case "Method_Ultrasonic":
                    return ((int)MethodNameEnum.ultrasonic);
                case "挑选转板":
                case "Method_ChoiceTransfer":
                    return ((int)MethodNameEnum.choiceTransfer);
                case "涂布转板":
                case "Method_CoatingTransfer":
                    return ((int)MethodNameEnum.coatingTransfer);
                case "梯度稀释":
                case "Method_Dilution":
                    return ((int)MethodNameEnum.dilution);
 
                case "夹爪保持开始":
                case "夹爪保持":
                case "Method_HoldingLabware":
                    return (int)MethodNameEnum.holdingLabware;
                case "夹爪保持结束":
                case "Method_EndHoldingLabware":
                    return (int)MethodNameEnum.endHoldingLabware;
                case "变量导入":
                case "Method_VariableImport":
                    return (int)MethodNameEnum.VariableImport;
                case "if开始":
                case "Method_ifStart":
                    return (int)MethodNameEnum.ifStart;
                case "if结束":
                case "Method_ifend":
                    return (int)MethodNameEnum.ifEnd;
                case "else开始":
                case "Method_elseStart":
                    return (int)MethodNameEnum.elseStart;
                case "else结束":
                case "Method_elseend":
                    return (int)MethodNameEnum.elseEnd;
                case "计时器":
                case "Method_timer":
                    return (int)MethodNameEnum.timerSet;
                case "等待":
                case "Method_waitfor":
                    return (int)MethodNameEnum.waitFor;
                case "泵加液":
                case "Method_pumpDispense":
                    return (int)MethodNameEnum.pumpDispense;
                case "开关盖":
                case "Method_switchLid":
                    return (int)MethodNameEnum.switchLid;
                case "文件开关盖移液":
                case "Method_fileMoveLiquid":
                    return (int)MethodNameEnum.fileMoveLiquid;
                case "文件转板":
                case "Method_fileMoveLabware":
                    return (int)MethodNameEnum.fileMoveLabware;
                case "子方法":
                case "Method_subMethod":
                    return (int)MethodNameEnum.subMethod;
                case "计算":
                case "Method_varCalc":
                    return (int)MethodNameEnum.varCalc;
                case "文件切胶":
                case "Method_fileCutGum":
                    return (int)MethodNameEnum.cutGum;
            }
            return result;
        }
        #endregion
 
        #region 根据方法编号获取方法名称
        /// <summary>
        /// 根据方法编号获取方法名称
        /// </summary>
        /// <param name="methodNum">方法编号</param>
        /// <returns>方法中文名</returns>
        public string getNameByMethodNum(int methodNum)
        {
            string result = "";
            switch (methodNum)
            {
                case (int)MethodNameEnum.start:
                    return "开始";
                case (int)MethodNameEnum.aspirate:
                    return "吸液";
                case (int)MethodNameEnum.dispense:
                    return "排液";
                case (int)MethodNameEnum.remark:
                    return "备注";
                case (int)MethodNameEnum.transferfile:
                    return "文件";
                case (int)MethodNameEnum.griptransport:
                    return "抓板转移";
                case (int)MethodNameEnum.home:
                    return "复位";
                case (int)MethodNameEnum.mixing:
                    return "混合";
                case (int)MethodNameEnum.setchannel:
                    return "设置通道";
                case (int)MethodNameEnum.loadtips:
                    return "安装吸头";
                case (int)MethodNameEnum.unloadtips:
                    return "卸载吸头";
                case (int)MethodNameEnum.group:
                    return "组合";
                case (int)MethodNameEnum.loop:
                    return "开始循环";
                case (int)MethodNameEnum.pause:
                    return "暂停";
                case (int)MethodNameEnum.shaker:
                    return "振荡";
                case (int)MethodNameEnum.warmer:
                    return "温控";
                case (int)MethodNameEnum.end:
                    return "结束";
            }
            return result;
        }
        #endregion
 
        #region 根据工作站内部方法文件的基础路径,获取已经编辑的工作方法文件名称集合
        public List<string> GenerateMethodNamesByBaseMethodPath(string basePath)
        {
            List<string> result = new List<string>();
            string[] files = Directory.GetFiles(basePath);
            foreach(string file in files)
            {
                string fileName=file.Substring(file.LastIndexOf('\\')+1,file.Length - file.LastIndexOf('\\')-5);
                result.Add(fileName);
            }
 
            return result;
        }
        #endregion
 
        public DataCheckResult CheckWorkFlow(XmlDocument xmlDocument)
        {
            DataCheckResult dataCheckResult = new DataCheckResult();
            dataCheckResult.result = 0;
            //方法
            XmlNodeList xmlNodeMethodList = xmlDocument.SelectNodes("root/method[@id>=1]");
 
            //清空方法列表
            for (int n = 0; n < xmlNodeMethodList.Count; n++)
            {
 
                string MethodName = xmlNodeMethodList[n].SelectSingleNode("name").InnerText;
                string id = xmlNodeMethodList[n].Attributes["id"].Value.ToString();
 
                int iNum = getNumByMethodName(MethodName);
                switch (iNum)
                {
                    case (int)MethodNameEnum.start:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.aspirate:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.dispense:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.end:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.endgroup:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.endloop:
                        //if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.griptransport:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.group:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.home:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.loadtips:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                            LoadTipsBll loadTipsBll = new LoadTipsBll();
                            DataCheckResult dataCheckResult1 = loadTipsBll.CheckProperty(xmlNodeMethodList[n]);
                            if(dataCheckResult1.result== 1)
                            {
                                dataCheckResult.result = 1;
                                dataCheckResult.errorlist = dataCheckResult1.errorlist;
                                return dataCheckResult;
                            }
                        }
                        break;
                    case (int)MethodNameEnum.loop:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.mixing:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.pause:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.remark:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.transferfile:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.unloadtips:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                    case (int)MethodNameEnum.setVariable:
                        if (xmlNodeMethodList[n].SelectSingleNode("status").InnerText == "enable")
                        {
                        }
                        break;
                }
            }
 
            return dataCheckResult;
        }
 
    }
}