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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FLY.FeedbackRenZiJia.Common;
using System.Net;
using FLY.Thick.Base.UI;
using FLY.FeedbackRenZiJia.IService;
using System.ComponentModel;
using Unity;
using GalaSoft.MvvmLight.Command;
namespace FLY.FeedbackRenZiJia.UI.Client
{
/// <summary>
/// Page_Setup.xaml 的交互逻辑
/// </summary>
public partial class PgSetup : Page
{
PgSetupVm viewModel;
public PgSetup()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IFeedbackHeatService feedback,
IHeatBufService heatBuf,
IHeatCellService heatCell)
{
viewModel = new PgSetupVm();
viewModel.Init(feedback, heatBuf, heatCell);
this.DataContext = viewModel;
}
private void button_apply_Click(object sender, RoutedEventArgs e)
{
}
}
public class PgSetupVm : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
#region 参数
public double ThresholdHeatSigma { get; set; }
public int Step { get; set; }
public bool HasCheckFilmVelocity { get; set; }
public bool HasCheck { get; set; }
public int Delay { get; set; }
public int ThresholdSigmaMax { get; set; }
public int StableRange0 { get; set; }
public int StableRange { get; set; }
public bool IsUsedLocalKp { get; set; }
public List<int> HeatEffectCurve { get; set; }
public bool IsForbidUpDown { get; set; }
public bool IsBreakUpMode { get; set; }
public int CtrlLine { get; set; }
public double Kp { get; set; }
public double LocalKp { get; set; }
#endregion
#region Command
public RelayCommand SmoothCmd { get; }
public RelayCommand ApplyCmd { get; }
#endregion
public IFeedbackHeatService Feedback{ get; private set; }
public IHeatBufService HeatBuf { get; private set; }
public IHeatCellService HeatCell { get; private set; }
public PgSetupVm()
{
SmoothCmd = new RelayCommand(() => {
HeatCell.ThresholdHeatSigma = this.ThresholdHeatSigma;
HeatCell.Smooth();
});
ApplyCmd = new RelayCommand(Apply);
}
[InjectionMethod]
public void Init(
IFeedbackHeatService feedback,
IHeatBufService heatBuf,
IHeatCellService heatCell)
{
this.Feedback = feedback;
this.HeatBuf = heatBuf;
this.HeatCell = heatCell;
//参数绑定
#region 参数
Misc.BindingOperations.SetBinding(this.HeatCell, "ThresholdHeatSigma", this, "ThresholdHeatSigma");
Misc.BindingOperations.SetBinding(this.Feedback, "Step", this, "Step");
Misc.BindingOperations.SetBinding(this.Feedback, "HasCheckFilmVelocity", this, "HasCheckFilmVelocity");
Misc.BindingOperations.SetBinding(this.Feedback, "HasCheck", this, "HasCheck");
Misc.BindingOperations.SetBinding(this.Feedback, "Delay", this, "Delay");
Misc.BindingOperations.SetBinding(this.HeatBuf, "ThresholdSigmaMax", this, "ThresholdSigmaMax");
Misc.BindingOperations.SetBinding(this.HeatBuf, "StableRange0", this, "StableRange0");
Misc.BindingOperations.SetBinding(this.HeatBuf, "StableRange", this, "StableRange");
Misc.BindingOperations.SetBinding(this.HeatBuf, "IsUsedLocalKp", this, "IsUsedLocalKp");
Misc.BindingOperations.SetBinding(this.HeatBuf, "LocalKp", this, "LocalKp");
Misc.BindingOperations.SetBinding(this.HeatBuf, "HeatEffectCurve", this, "HeatEffectCurve");
Misc.BindingOperations.SetBinding(this.HeatCell, "IsForbidUpDown", this, "IsForbidUpDown");
Misc.BindingOperations.SetBinding(this.HeatCell, "IsBreakUpMode", this, "IsBreakUpMode");
Misc.BindingOperations.SetBinding(this.HeatCell, "CtrlLine", this, "CtrlLine");
Misc.BindingOperations.SetBinding(this.HeatCell, "Kp", this, "Kp");
#endregion
}
bool CheckValid_HeatEffectCurve()
{
List<int> list = HeatEffectCurve;
if ((list == null) || (list.Count() == 0))
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "加热效果为空", TimeSpan.FromSeconds(2));
return false;
}
int cnt = list.Count();
if ((int)(cnt / 2) * 2 == cnt)
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "加热效果格式出错,应该如2,5,8,5,2", TimeSpan.FromSeconds(2));
return false;
}
for (int i = 0; i < list.Count() / 2; i++)
{
int idx0 = i;
int idx_0 = list.Count() - 1 - idx0;
if (list[idx0] != list[idx_0])
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "加热效果格式出错,应该如2,5,8,5,2", TimeSpan.FromSeconds(2));
return false;
}
int idx1 = idx0 + 1;
if (list[idx0] > list[idx1])
{
FLY.ControlLibrary.Window_WarningTip.Show(
"参数异常", "加热效果格式出错,应该如2,5,8,5,2", TimeSpan.FromSeconds(2));
return false;
}
}
return true;
}
bool CheckValid()
{
if (CheckValid_HeatEffectCurve() == false)
return false;
return true;
}
private void Apply()
{
if (!WdPassword.Authorize("AirRing"))
return;
if (!CheckValid())
return;
//参数设置
HeatCell.ThresholdHeatSigma=this.ThresholdHeatSigma;
Feedback.Step=this.Step;
Feedback.HasCheckFilmVelocity=this.HasCheckFilmVelocity;
Feedback.HasCheck=this.HasCheck;
Feedback.Delay=this.Delay;
HeatBuf.ThresholdSigmaMax=this.ThresholdSigmaMax;
HeatBuf.StableRange0=this.StableRange0;
HeatBuf.StableRange=this.StableRange;
HeatBuf.IsUsedLocalKp=this.IsUsedLocalKp;
HeatBuf.LocalKp=this.LocalKp;
HeatBuf.HeatEffectCurve=this.HeatEffectCurve;
HeatCell.IsForbidUpDown=this.IsForbidUpDown;
HeatCell.IsBreakUpMode=this.IsBreakUpMode;
HeatCell.CtrlLine=this.CtrlLine;
HeatCell.Kp=this.Kp;
HeatCell.Apply();
HeatBuf.Apply();
Feedback.Apply();
FLY.ControlLibrary.Window_Tip.Show("参数设置", "成功", TimeSpan.FromSeconds(2));
}
}
public class HeatEffectConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
List<int> list = value as List<int>;
if (list == null)
{
return null;
}
string str = "";
for (int i = 0; i < list.Count(); i++)
{
if (i == 0)
str += list[i].ToString();
else
str += "," + list[i].ToString();
}
return str;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string str = value as string;
if (string.IsNullOrEmpty(str))
{
//不合法
return null;
}
string[] ss = str.Split(',');
List<int> list = new List<int>();
for (int i = 0; i < ss.Length; i++)
{
int num;
if (int.TryParse(ss[i], out num))
{
list.Add(num);
}
}
return list;
}
#endregion
}
public class TimeSpan2SecondConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
if (!(value is TimeSpan))
return null;
TimeSpan ts = (TimeSpan)value;
return (int)(ts.TotalSeconds);
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
#endregion
}
public class StableConverter : IValueConverter
{
#region IValueConverter 成员
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
STABILITY stable = (STABILITY)value;
switch (stable)
{
case STABILITY.IDLE:
return "等待";
case STABILITY.ERROR_NO_ARRIVE:
return "等待:加热点还没到达测厚仪";
case STABILITY.ERROR_POSITION_NOTSURE:
return "等待:位置不能确定";
case STABILITY.ERROR_SIGMA_OVERSIZE:
return "等待:2σ太大 ";
case STABILITY.ERROR_ROTATE_CHANGED:
return "等待:旋转速度波动大 ";
case STABILITY.ERROR_THICK_CHANGED:
return "等待:厚度均值波动大";
case STABILITY.ERROR_CORREL:
return "等待:相关性不够";
case STABILITY.OK_CORREL:
return "稳定:相关性高";
case STABILITY.OK_HEAT_AND_THICK_CORREL:
return "稳定:加热相关性高";
default:
return "???";
}
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
#endregion
}
}