-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMainWindow.xaml.cs
136 lines (106 loc) · 3.51 KB
/
MainWindow.xaml.cs
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Timers;
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 DEService;
namespace MFService
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
ECU curEcu;
System.Timers.Timer timer;
public MainWindow()
{
InitializeComponent();
this.Loaded += FrmMainWin_Loaded;
this.Unloaded += MainWindow_Unloaded;
this.Dispatcher.ShutdownStarted += Dispatcher_ShutdownStarted;
}
private void Dispatcher_ShutdownStarted(object sender, EventArgs e)
{
MainWindow_Unloaded(sender, null);
}
private void MainWindow_Unloaded(object sender, RoutedEventArgs e)
{
timer.Elapsed -= Timer_Elapsed;
Global.Can.Stop();
}
#region Event Handlers
private void FrmMainWin_Loaded(object sender, RoutedEventArgs e)
{
Global.Can = new UCan();
Global.Can.Start(0, 250);
Global.Can.SetDiagnosticMode(false);
timer = new System.Timers.Timer(1000);
timer.Elapsed += Timer_Elapsed;
timer.Start();
Global.MainControl = grid;
Global.diag = new Diag.A_Diag(Global.Can);
}
private void Timer_Elapsed(object sender, ElapsedEventArgs e)
{
Dispatcher.Invoke(new Action(() =>
{
if (Global.Can.IsConnected)
{
sbCanAdapter.Text = "Адаптер: подключен";
sbCanSpeed.Text = "Скорость: " + Global.Can.BitRate + " кБит/с";
sbCanLoad.Text = "Загрузка: " + Global.Can.CanLoadPercent + "%" + " (Tx/c: " + Global.Can.CanLoadTx + ", Rx/c: " + Global.Can.CanLoadRx + ")";
}
else
{
sbCanAdapter.Text = "Адаптер: не подключен.";
sbCanSpeed.Text = "Скорость: -";
sbCanLoad.Text = "Загрузка: -";
}
}));
}
// private void btnCoding_Click(object sender, RoutedEventArgs e)
// {
///* Bms_ECUCoding ecu_form = new Bms_ECUCoding();
// ecu_form.ShowDialog();
// */
// }
// private void btnMeasuring_Click(object sender, RoutedEventArgs e)
// {
// }
// private void btnSearchNodes_Click(object sender, RoutedEventArgs e)
// {
// SearchNodes();
// }
// private void comboECU_SelectionChanged(object sender, SelectionChangedEventArgs e)
// {
// Global.EcuList.CurrentEcu = Tools.GetComboItem(comboECU) as ECU;
// curEcu = Global.EcuList.CurrentEcu;
// if (Global.EcuList.CurrentEcu != null)
// {
// panelEcuHeader.Visibility = Visibility.Visible;
// GetInfo(curEcu);
// }
// else
// panelEcuHeader.Visibility = Visibility.Collapsed;
// }
#endregion
// async void GetInfo(ECU ecu)
// {
// }
// async void SearchNodes()
// {
// //Global.EcuList =
// }
}
}