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
using FLY.OBJComponents.Client;
using FLY.Winder.Common;
using FLY.Winder.IService;
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 Unity;
namespace FLY.Winder.UI.Client.UiModule
{
/// <summary>
/// MainPanel.xaml 的交互逻辑
/// </summary>
public partial class MainPanel : UserControl
{
IUnityContainer container;
IWinderSystemService winderSystem;
SetPLCUpdatePlan setPlan_accessory;
SetPLCUpdatePlan[] setPlan_winders = new SetPLCUpdatePlan[2];
public MainPanel()
{
InitializeComponent();
}
[InjectionMethod]
public void Init(
IUnityContainer container,
IWinderSystemService winderSystem)
{
this.container = container;
this.winderSystem = winderSystem;
this.DataContext = winderSystem;
grid_winder.DataContext = winderSystem;
//注册属性更新计划
setPlan_accessory = new SetPLCUpdatePlan(
winderSystem.PLCos,
winderSystem.Accessory,
new string[] {
"VelocitySet",
"IsVelocityChanged",
"Velocity",
"RotaryFreqSet",
"IsRotaryFreqChanged",
"RotaryCurrent",
"RotaryFreq",
"IsRotaryOn",
"IsRotaryOrg",
"IsRotaryForw",
"IsRotaryBackw",
"IsRotaryForwLimit",
"IsRotaryForwTurn",
"IsRotaryOrgSign",
"IsRotaryBackwLimit",
"IsRotaryBackwTurn",
"Traction1Current",
"IsTraction1On",
"IsTraction2Manual",
"Traction2TensionKgSet",
"Traction2TensionKg",
"Traction2Current",
"IsTraction2Manual",
"IsTraction2On"
});
for (int i = 0; i < 2; i++)
{
setPlan_winders[i] = new SetPLCUpdatePlan(
winderSystem.PLCos,
winderSystem.Items[i],
new string[] {
"MeasureLenSet",
"MeasurePreWarning",
"MeasureLen",
"MeasureStop",
"TensionKgSet",
"TensionKg",
"Current",
"IsManual",
"IsOn"
});
}
}
private void button_v_set_Click(object sender, RoutedEventArgs e)
{
WdSetValue w = new WdSetValue();
w.Init(winderSystem.Accessory.VelocitySet, 200, 1, 0.1f, "速度设置", "m/min");
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true) {
winderSystem.Accessory.VelocitySet = w.Value;
winderSystem.Accessory.IsVelocityChanged = true;
winderSystem.Accessory.IsVelocityChanged = false;
}
}
private void button_manual_Click(object sender, RoutedEventArgs e)
{
var w = container.Resolve<WdManual>();
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
w.ShowDialog();
}
private void button_freq_Click(object sender, RoutedEventArgs e)
{
WdSetValue w = new WdSetValue();
w.Init(winderSystem.Accessory.RotaryFreqSet, 50, 0.1f, 0.1f, "旋转频率", "Hz");
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
winderSystem.Accessory.RotaryFreqSet = w.Value;
winderSystem.Accessory.IsRotaryFreqChanged = true;
}
}
private void button_measure_Click(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
WinderInsideOutside item = (WinderInsideOutside)(button.Tag);
WdMeasure w = new WdMeasure();
w.Init((int)(item.MeasureLenSet), (int)(item.MeasurePreWarning));
w.Owner = FLY.ControlLibrary.COMMON.GetWindow(this);
if (w.ShowDialog() == true)
{
item.MeasureLenSet = w.viewmodel.MeasureLenSet;
item.MeasurePreWarning = w.viewmodel.MeasurePreWarning;
}
}
}
}