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
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
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;
namespace FLY.DownBlowing.UI.Server
{
/// <summary>
/// PgMain.xaml 的交互逻辑
/// </summary>
public partial class PgMain : Page
{
FLY.DownBlowing.Server.TDGage gage;
public PgMain()
{
InitializeComponent();
}
public void Init(FLY.DownBlowing.Server.TDGage gage)
{
this.gage = gage;
FLY.OBJComponents.Server.PLCProxySystem plsos =
gage.mData.PLCos as FLY.OBJComponents.Server.PLCProxySystem;
this.itemcontrol.ItemsSource = plsos.PLCs;
this.gbRotary.DataContext = gage.rotarySystem;
}
private void btnSetupClick(object sender, RoutedEventArgs e)
{
WdSetup w = new WdSetup();
w.Owner = App.Current.MainWindow;
w.ShowDialog();
}
private void btnMoreClick(object sender, RoutedEventArgs e)
{
Button button = sender as Button;
var plc = button.Tag as Modbus.WithThread.ModbusMapper_Client;
WdDRList w = new WdDRList();
w.Init(plc);
w.ShowDialog();
}
private void btnRotaryClick(object sender, RoutedEventArgs e)
{
WdRotary w = new WdRotary();
w.Init(gage.rotarySystem);
w.ShowDialog();
}
}
public class PgMainVmUt : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public List<ModbusMapperClientView> PLCs { get; set; }
public PgMainVmUt()
{
PLCs = new List<ModbusMapperClientView>() {
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds( 623),
Client = new TcpClientView(){
IsConnected = true,
RemoteAddr = "127.168.50.1:502"
},
DRCnt = 130,
DRNeedUpdateCnt = 30,
ErrorCnt = 2
},
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds(2623),
Client = new TcpClientView(){
IsConnected = false,
RemoteAddr = "127.168.50.2:502"
},
DRCnt = 45,
DRNeedUpdateCnt = 40,
ErrorCnt = 2
},
new ModbusMapperClientView(){
ActUpdateInterval = TimeSpan.FromMilliseconds(123),
Client = new TcpClientView(){
IsConnected = true,
RemoteAddr = "127.168.50.3:502"
},
DRCnt = 10,
DRNeedUpdateCnt = 3,
ErrorCnt = 0
}
};
}
}
public class ModbusMapperClientView : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// 实际更新间隔
/// </summary>
public TimeSpan ActUpdateInterval { get; set; }
public int ErrorCnt { get; set; }
public int DRNeedUpdateCnt { get; set; }
public int DRCnt { get; set; }
public TcpClientView Client { get; set; }
}
public class TcpClientView : INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
public string RemoteAddr { get; set; }
public bool IsConnected { get; set; }
}
}