FrmDeviceConfig.cs
7.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
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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using TSA_V.Common;
using TSA_V.DeviceLibrary;
namespace TSA_V
{
public partial class FrmDeviceConfig : FrmBase
{
public FrmDeviceConfig()
{
InitializeComponent();
List<string> typeList = new List<string>();
this.cmbType.Items.Clear();
typeList.AddRange(new string[] {
"1=●",
"2=✚",
"3=┃",
"4=━━",
"5=□",
"6=○",
"7=极性_上方",
"8=极性_下方",
"9=极性_左方",
"10=极性_右方"
});
foreach (string str in typeList)
{
cmbType.Items.Add(str);
}
}
private void FrmLanguage_Load(object sender, EventArgs e)
{
LanguageProcess();
this.chbISDebug.Checked = TSAVBean.IsDebug;
this.chbDisBottomCylinder.Checked = TSAVBean.DisableBottomCylinder;
this.chbDisSideCylinder.Checked = TSAVBean.DisableSideCylinder;
this.txtKNDIP.Text = IOManager.KNDIP.ToString();
this.txtKNDPort.Text = IOManager.KNDPort.ToString();
LoadCom();
SetScreen();
cmbType.SelectedIndex = 0;
int value= TSAVBean.DefaultPType - 1;
if (cmbBoardList.Items.Count > value && value >= 0)
{
cmbBoardList.SelectedIndex = value;
}
numSizeX.Text = TSAVBean.DefaultPSize.ToString();
numSizeY.Text = TSAVBean.DefaultPSize.ToString();
txtAddr.Text = ConfigAppSettings.GetValue(Setting_Init.DCSServerAddr);
if(MesUtil.CodeISOk&& MesUtil.CurrPCBCode != "")
{
txtCode.Text = MesUtil.CurrPCBCode;
}
}
public void LoadCom()
{
cmbBoardList.DataSource = null;
List<BoardInfo> list = new List<BoardInfo>(BoardManager.boardList);
cmbTestProName.DataSource = list;
cmbTestProName.DisplayMember = "boardName";
cmbTestProName.ValueMember = "boardId";
if (list.Count > 0)
{
cmbTestProName.SelectedIndex = 0;
}
list = new List<BoardInfo>(BoardManager.boardList);
BoardInfo board = new BoardInfo();
board.boardName = "--ALL--";
board.boardId = -1;
list.Insert(0, board);
cmbBoardList.DataSource = list;
cmbBoardList.DisplayMember = "boardName";
cmbBoardList.ValueMember = "boardId";
if (list.Count > 0)
{
cmbBoardList.SelectedIndex = 0;
}
}
private void btnCancel_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnOk_Click(object sender, EventArgs e)
{
SaveData();
this.Close();
}
private void SaveData()
{
bool isDebug = chbISDebug.Checked;
ConfigAppSettings.SaveValue(Setting_Init.IsDebug, isDebug);
TSAVBean.IsDebug = isDebug;
bool disBottom = chbDisBottomCylinder.Checked;
ConfigAppSettings.SaveValue(Setting_Init.DisableBottomCylinder,disBottom);
TSAVBean.DisableBottomCylinder = disBottom;
bool disSide = chbDisSideCylinder.Checked;
ConfigAppSettings.SaveValue(Setting_Init.DisableSideCylinder, disSide);
TSAVBean.DisableSideCylinder = disSide;
string server = txtAddr.Text.Trim();
ConfigAppSettings.SaveValue(Setting_Init.DCSServerAddr, server);
MesUtil.serverAddress = server;
LogUtil.info($"保存配置成功: 调试{ isDebug },禁用底部气缸{disBottom},禁用侧挡气缸{disSide},地址{server} ");
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.SaveOk, "保存成功"));
}
private void chbISDebug_CheckedChanged(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
BoardInfo board = new BoardInfo();
board.boardId = -1;
if (cmbBoardList.Text != "" && cmbBoardList.SelectedIndex >= 0)
{
board = (BoardInfo)cmbBoardList.SelectedItem;
}
int pSizeX = FormUtil.GetIntValue(numSizeX);
int pSizeY = FormUtil.GetIntValue(numSizeY);
int pointType = cmbType.SelectedIndex + 1;
int penWidth = (int)numPenWidth.Value;
if (pSizeX.Equals(0))
{
MessageBox.Show(ResourceCulture.GetString("请输入正确的点大小"));
numSizeX.Focus();
return;
}
if (pSizeY.Equals(0))
{
MessageBox.Show(ResourceCulture.GetString("请输入正确的点大小"));
numSizeY.Focus();
return;
}
DialogResult result;
if (board.boardId.Equals(-1))
{
result = MessageBox.Show(ResourceCulture.GetString("确定更新所有程序的组装点信息?"),
ResourceCulture.GetString(ResourceCulture.Sure, "确认"), MessageBoxButtons.YesNo);
}
else
{
result = MessageBox.Show(ResourceCulture.GetString("确定更新程序【{0}】的组装点信息", "确定更新程序【{0}】的组装点信息", board.boardName),
ResourceCulture.GetString(ResourceCulture.Sure, "确认"), MessageBoxButtons.YesNo);
}
if (result.Equals(DialogResult.Yes))
{
BoardManager.UpdatePointSize(board.boardId, pSizeX,pSizeY, pointType,penWidth);
MessageBox.Show(ResourceCulture.GetString( "更改完成"));
}
else
{
MessageBox.Show(ResourceCulture.GetString( "已取消更改"));
}
}
private void btnTest_Click(object sender, EventArgs e)
{
string serverAddress = txtAddr.Text.Trim();
if (String.IsNullOrEmpty(serverAddress))
{
MessageBox.Show(ResourceCulture.GetString("请输入正确的接口地址"));
}
BoardInfo board = new BoardInfo();
board.boardId = -1;
if (cmbTestProName.Text != "" && cmbTestProName.SelectedIndex >= 0)
{
board = (BoardInfo)cmbTestProName.SelectedItem;
}
else
{
MessageBox.Show("请选择一个程序");
}
string barcode = txtCode.Text.Trim();
DeviceStatus status = MesUtil.GetTestStatus(board, barcode);
string result = HttpHelper.PostJson(serverAddress, new JsonParam( status));
LogUtil.info("DCS地址【" + serverAddress + "】 返回值【" + result + "】");
}
}
}