FrmChangeWidth.cs
5.5 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
using PUSICANLibrary;
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;
using TSA_V.LoadCSVLibrary;
namespace TSA_V
{
public partial class FrmChangeWidth : FrmBase
{
private int defaultWidth = 100;
public FrmChangeWidth()
{
InitializeComponent();
}
private void FrmPutCom_Load(object sender, EventArgs e)
{
LanguageProcess();
SetScreen();
LoadData();
}
private List<int> widthList = new List<int>();
private void LoadData()
{
numChangeValue.Value = ConfigAppSettings.GetIntValue(Setting_Init.Line_ChangeValue);
numHomeWidth.Value = ConfigAppSettings.GetIntValue(Setting_Init.Line_HomeWidth);
numSlv.Value = ConfigAppSettings.GetIntValue(Setting_Init.Line_NodeAddr);
numTarget.Value = defaultWidth;
txtTargetPosition.Text = (defaultWidth - ((int)numHomeWidth.Value)) * ((int)numChangeValue.Value) + "";
LoadList();
}
private void LoadList()
{
widthList = new List<int>();
lbWidthMap.Items.Clear();
foreach (int key in LWidthManager.WPositionMap.Keys)
{
int value = LWidthManager.WPositionMap[key];
lbWidthMap.Items.Add(" " + key + "mm = " + value);
if (txtW.Text.Equals(""))
{
txtW.Text = key.ToString();
txtWP.Text = value.ToString();
}
widthList.Add(key);
}
}
private void btnChWidth_Click(object sender, EventArgs e)
{
numTarget_ValueChanged(null, null);
int w = (int)numTarget.Value;
int p = FormUtil.GetIntValue(txtTargetPosition);
LogUtil.info("点击 轨道调宽:【" + w + "】【" + p + "】");
if (!LWidthManager.CanStartChWidth())
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ChangeWFail, "启动调宽失败"));
return;
}
Task.Factory.StartNew(delegate
{
string result = LWidthManager.StartChangeWidth(w, p);
LogUtil.info("调宽" + w + "=" + p + "结束:" + result);
if (String.IsNullOrEmpty(result))
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ChangeWOk, "调宽{0}={1}完成", w, p));
}
else
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.ChangeWEnd, "调宽{0}={1}结束:{2}", w, p, result));
}
});
}
private void btnClose_Click(object sender, EventArgs e)
{
this.Close();
}
private void btnSave_Click(object sender, EventArgs e)
{
int slvAddr = (int)numSlv.Value;
int homeWidth = (int)numHomeWidth.Value;
int numChange = (int)numChangeValue.Value;
ConfigAppSettings.SaveValue(Setting_Init.Line_NodeAddr, slvAddr);
ConfigAppSettings.SaveValue(Setting_Init.Line_ChangeValue, numChange);
ConfigAppSettings.SaveValue(Setting_Init.Line_HomeWidth, homeWidth);
LWidthManager.Line_NodeAddr = (uint)slvAddr;
LWidthManager.Line_HomeWidth = homeWidth;
LWidthManager.Line_ChangeValue = numChange;
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.SaveOk, "保存成功!"));
}
private void FrmPutCom_FormClosing(object sender, FormClosingEventArgs e)
{
}
private void timer1_Tick(object sender, EventArgs e)
{
}
private void FrmPutCom_Shown(object sender, EventArgs e)
{
}
private void btnDSave_Click(object sender, EventArgs e)
{
int width = FormUtil.GetIntValue(txtW);
int position = FormUtil.GetIntValue(txtWP);
if (width <= 0 || width > 1000)
{
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.WriteLength, "请输入宽度"));
txtW.Focus();
}
LWidthManager.UpdateWPosition(width, position);
MessageBox.Show(ResourceCulture.GetString(ResourceCulture.SaveOk, "保存成功!"));
LoadList();
}
private void listDetitalP2_SelectedIndexChanged(object sender, EventArgs e)
{
if (lbWidthMap.SelectedIndex < 0)
{
return;
}
int index = lbWidthMap.SelectedIndex;
if (index >= widthList.Count)
{
return;
}
int width = widthList[index];
txtW.Text = width.ToString();
txtWP.Text = LWidthManager.GetWidthPosition(width).ToString();
}
private void numTarget_ValueChanged(object sender, EventArgs e)
{
int value = (int)numTarget.Value;
int p = LWidthManager.GetWidthPosition(value);
txtTargetPosition.Text = p.ToString();
}
private void btnHomeM_Click(object sender, EventArgs e)
{
LogUtil.info(Name+ "点击 原点返回");
PUSICANControl.HomeMove(LWidthManager.Line_NodeAddr, true);
}
}
}