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
using DataRWDAL;
using HxSocket;
using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Xml;
using XCommon.Log;
using XCore;
using XHandler.Controls.Run.Com;
using XHandler.View;
using XImagingXhandler.XDAL;
 
namespace XHandler.Controls
{
    public class GripTransportControl
    {
        #region 变量
        private string strCurrentCulture = string.Empty;
        private WellCalc wellCalc = new WellCalc();
 
        #region BLL
        private LatticeBll latticeBll = new LatticeBll();
        private AspirateBll aspirateBll = new AspirateBll();
        private GripTransportBll gripTransportBll = new GripTransportBll();
        #endregion
 
        #region 转运参数
        private string strMethodName = string.Empty;
        #endregion
 
        public RunWnd launchView = null;
        public HxSocketClient socketTcpListener = null;
        #endregion
 
        /// <summary>
        /// 构造函数
        /// </summary>
        public GripTransportControl(string strCurrentCulture)
        {
            this.strCurrentCulture = strCurrentCulture;
        }
 
        #region 执行抓板放板,返回结果字符串
        /// <summary>
        /// 执行抓板放板
        /// </summary>
        /// <param name="xmlEnv"></param>
        /// <param name="methodNode"></param>
        /// <param name="isSimulator"></param>
        /// <returns></returns>
        public bool ExecuteGripTransport(XmlNode xmlEnv, XmlNode methodNode, bool isSimulator)
        {
            bool result = true;
            string methodName = methodNode.SelectSingleNode("name").InnerText;
 
            if (launchView._cancelSource.IsCancellationRequested)
            {
                result = false;
                return result;
            }
 
            try
            {
                #region StartLog
                if (strCurrentCulture.Equals("zh-CN"))
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strStart.ToString());
                }
                else
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodName + "】start:");
                }
                #endregion
 
                #region 数据准备
                MethodGripTransport gripTransportData = gripTransportBll.GenerateMethodGripTransport(methodNode);
                #endregion
 
                // From点位耗材信息
                Labware labwareFrom = LabwareDB.GetLabware(gripTransportData.gripPickLabwareValue);
                // To点位耗材信息
                Labware labwareTo = null;
                ObservableCollection<Labware> piledFromLabwares = LabwareDB.GetPiledlabwareOfALabware(labwareFrom);   // 被叠放的盖子
 
                // 放空板位
                if ("-1".Equals(gripTransportData.gripPlaceLabwareValue))
                {
                    labwareTo = labwareFrom;
 
                    // 被抓的耗材位置是顶部,且有盖子:=> labwareTo = 盖子
                    if (piledFromLabwares.Count() > 0 && gripTransportData.gripModelPosValue == 2&& labwareFrom.labware_type_id!="4")
                    {
                        labwareTo = LabwareDB.GetLabware(piledFromLabwares[0].labware_id);
                    }
                }
                else
                {
                    labwareTo = LabwareDB.GetLabware(gripTransportData.gripPlaceLabwareValue);
                }
                
                if (labwareFrom == null || labwareTo == null)
                {
                    return result;
                }
 
                
                // 抓板
                result = ControlCom.ExecuteGripTransportPick(xmlEnv, gripTransportData, labwareFrom, piledFromLabwares, methodName, launchView, isSimulator);
                if (result)
                {
                    // 放板
                    result = ControlCom.ExecuteGripTransportPlace(xmlEnv,gripTransportData, labwareFrom, labwareTo, piledFromLabwares, methodName, launchView, isSimulator);
                    if (strCurrentCulture.Equals("zh-CN"))
                    {
                        launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strEnd.ToString());
                    }
                    else
                    {
                        launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】progress: complete;");
                    }
                    if (result != false)
                    {
                        launchView.GenerateAnimation(xmlEnv, gripTransportData);
                    }
                }
 
                
            }
            catch (Exception ex)
            {
                LoggerHelper.ErrorLog("ERROR:", ex);
 
                if (strCurrentCulture.Equals("zh-CN"))
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】" + Properties.MachineRunResource.strError.ToString() + " 源 " + ex.Source + " 错误信息 " + ex.Message + ";");
                }
                else
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodName + "】error:source:" + ex.Source + ";error:" + ex.Message + ";");
                }
 
                result = false;
            }
 
            return result;
        }
        #endregion
    }
}