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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using XHandler.View;
using XCore;
using XImagingXhandler.XDAL;
using DriverLib;
using DriverLib.Engine;
using System.Xml;
using System.Windows.Threading;
using DriverLibrary;
using System.Windows;
using XCommon.Log;
using System.Reflection;
using XHandler.View.MethodProperty;
using static HxEnum.OperationTypeEnum;
 
namespace XHandler.Controls
{
    public class HomeControl
    {
        string strCurrentCulture = "";
        LatticeBll latticeBll = new LatticeBll();
        HomeBll homeBll = new HomeBll();
        public RunWnd launchView = null;
 
        public HomeControl(string strCurrentCulture)
        {
            this.strCurrentCulture= strCurrentCulture;
        }
 
        #region 复位
        /// <summary>
        /// 复位
        /// </summary>
        /// <param name="labwareNode">装载吸头的板位节点对象</param>
        /// <param name="methodNode">装载方法属性节点对象</param>
        /// <param name="channelNums">已选的通道数量</param>
        /// <param name="isSimulator">0:连接谁;1:仿真</param>
        /// <param name="dtsTips">本次使用前的吸头列表</param>
        /// <param name="dteTips">使用过的吸头列表</param>
        /// <returns></returns>
        public bool ExecuteHome(XmlNode methodNode, float xAxisVal, float yAxisVal, float zAxisVal, bool isSimulator)
        {
            bool result = true;
            if (launchView._cancelSource.IsCancellationRequested)
            {
                result = false;
                return result;
            }
            if(strCurrentCulture.Equals("zh-CN"))
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】"+Properties.MachineRunResource.strStart.ToString());
            }
            else
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】> Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】start:");
            }
 
            // 状态2 初始化      黄蓝绿交替闪
            HxResult ret = CommonBll.StatusLamp(2, isSimulator);
 
            HomeMParam homeMParam = new HomeMParam();
            homeMParam.xAxisVal = xAxisVal;
            homeMParam.yAxisVal = yAxisVal;
            homeMParam.zAxisVal = zAxisVal;
 
            launchView.SetWaitOne();//暂停
            ret = homeBll.ExecuteHome(homeMParam, isSimulator);
          
            if (ret.Result != ResultType.Success)
            {
                if (strCurrentCulture.Equals("zh-CN"))
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】"+ Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strHomeFail.ToString() + ret.AlarmInfo);
                }
                else
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress: home is fail! error information:" + ret.AlarmInfo);
                }
 
                OperateDialog plsConfirmOper = null;
                if (!launchView.isRemotingOper)
                {
                    System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.MachineRunResource.strGoHomeFailWhatToDo : "The action of go home was fail! What do you want to do?");
                        plsConfirmOper.ShowDialog();
                    }));
                }
                else
                {
                    launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1048", 5, Properties.MachineRunResource.strGoHomeFailWhatToDo, 2);
                    plsConfirmOper = new OperateDialog(strCurrentCulture.Equals("zh-CN") ? Properties.MachineRunResource.strGoHomeFailWhatToDo : "The action of go home was fail! What do you want to do?");
                    plsConfirmOper.ShowDialog();
                }
 
                if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Retry)         // 重试
                {
                    return ExecuteHome(methodNode, xAxisVal, yAxisVal, zAxisVal, isSimulator);
                }
                else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Cancel)    // 终止
                {
                    if (launchView.isRemotingOper)
                    {
                        launchView.OnError?.Invoke(launchView.remoteObjectCmd, "EC-1049", 5, Properties.MachineRunResource.strHomeFailWasStoped, 2);
                    }
                    result = false;
                    return result;
                }
                else if (plsConfirmOper != null && plsConfirmOper.OperMark == NodeOperationTypeEnum.Continue)    // 跳过
                {
                    result = true;
                    return result;
                }
            }
            else
            {
                if (strCurrentCulture.Equals("zh-CN"))
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strHomeSuccess.ToString());
                }
                else
                {
                    launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress:home is success!");
                }
            }
 
            if (strCurrentCulture.Equals("zh-CN"))
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】" + Properties.MachineRunResource.strProgress.ToString() + Properties.MachineRunResource.strEnd.ToString());
            }
            else
            {
                launchView.AddLogs("【" + DateTime.Now.ToString("HH:mm:ss:fff") + "】>Xhandler: 【" + methodNode.SelectSingleNode("name").InnerText + "】progress: complete;");
            }
            return result;
        }
        #endregion
    }
}