WorkModeUtil.cs
3.2 KB
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
using PUSICANLibrary;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml.Linq;
using TSA_V.Common;
namespace TSA_V.DeviceLibrary
{
/// <summary>
/// 工作模式选择
/// </summary>
public class WorkModeUtil
{
/// <summary>
/// 只能进入过板模式
/// </summary>
public static bool OnlyGuoBan = false;
public static bool HasZhuanPan = true;
private static bool IsSelected = false;
public static event ModeBoxShow boxShowEvent;
public delegate DialogResult ModeBoxShow(string msg,string okMsg);
public static event CheckModeEnd checkModeEndEvent;
public delegate void CheckModeEnd( );
public static bool SelectOk()
{
return IsSelected;
}
public static void ModeCheckEnd()
{
WorkModeUtil.checkModeEndEvent?.Invoke();
}
internal static void AutoSelect(string Name)
{
//自动设置为过板模式
if (IsSelected)
{
return;
}
OnlyGuoBan = true;
IsSelected = true;
LogUtil.error(Name + " 默认进入过板模式,不加载转盘");
ModeCheckEnd();
}
internal static void SelectMode(string Name)
{
if (IsSelected)
{
return;
}
//如果是无轨道程序,不能选择仅过板模式
if (IOBase.NoLine)
{
LogUtil.error(Name + " 无轨道程序,不能选择仅过板模式 ,直接返回");
ModeCheckEnd();
return;
}
try
{
//如果超时,且调宽轴已上线,旋转轴上线失败,提示是否进入过板模式
IsSelected = true;
LogUtil.error(Name + " 询问是否进入过板模式");
//DialogResult result = MessageBox.Show("料塔加载失败,是否进入过板模式?", "提示", MessageBoxButtons.OKCancel, MessageBoxIcon.Warning);
string msg = ResourceControl.GetString("SelectModeMsg", "料塔加载失败,是否进入过板模式?");
string okMsg = ResourceControl.GetString("SelectModeMsgOK", "您已选择流水线过板模式");
DialogResult result = (DialogResult)(boxShowEvent?.Invoke(msg, okMsg));
LogUtil.error(Name + " 询问是否进入过板模式 ,结果:" + result.ToString());
if (result.Equals(DialogResult.OK))
{
OnlyGuoBan = true;
LogUtil.info(Name + " 选择过板模式,不需要复位料塔 ");
TSAVBean.RemoveNode();
}
else
{
LogUtil.info(Name + " 继续复位料塔");
}
}
catch(Exception ex)
{
LogUtil.error("询问是否进入过板模式出错:"+ex.ToString());
}finally
{
ModeCheckEnd();
}
}
}
}