|
@@ -2,6 +2,7 @@
|
|
|
using SCADA_DAQ.Customer.Models;
|
|
|
using System;
|
|
|
using System.Collections.Generic;
|
|
|
+using System.IO.Ports;
|
|
|
using System.Linq;
|
|
|
using System.Text;
|
|
|
using System.Threading.Tasks;
|
|
@@ -30,7 +31,8 @@ namespace SCADA_DAQ.Customer
|
|
|
{
|
|
|
InitializeComponent();
|
|
|
|
|
|
- ToolBar.Visibility = Visibility.Collapsed;
|
|
|
+ //ToolBar.Visibility = Visibility.Collapsed;
|
|
|
+ ToolBar.Items.Clear();
|
|
|
|
|
|
var view = new AutoView(
|
|
|
CustomerEnv.CustomerConfig.SerialModel);
|
|
@@ -38,6 +40,11 @@ namespace SCADA_DAQ.Customer
|
|
|
(from t in new int[] { 5, 6, 7, 8 } select new KeyValuePair<int, int>(t, t)).ToList(),
|
|
|
"Key", "Value");
|
|
|
Gp_Config.Content = view;
|
|
|
+
|
|
|
+
|
|
|
+ var comTest = new ToolBarButton() { ButtonKind = SCADA.CommonCtrl.ButtonKind.StartButton, Title = "串口测试" };
|
|
|
+ ToolBar.Items.Add(comTest);
|
|
|
+ comTest.Click += ComTest_Click;
|
|
|
//Gp_Config.Content = new AutoView(
|
|
|
// CustomerEnv.CustomerConfig,
|
|
|
// nameof(CustomerConfig.BatchSize),
|
|
@@ -57,5 +64,23 @@ namespace SCADA_DAQ.Customer
|
|
|
// ContentBackground = Brushes.LightBlue,
|
|
|
//};
|
|
|
}
|
|
|
+
|
|
|
+ private void ComTest_Click(object sender, RoutedEventArgs e)
|
|
|
+ {
|
|
|
+ using (var comm = new SerialPort()
|
|
|
+ {
|
|
|
+ PortName = CustomerEnv.CustomerConfig.SerialModel.PortName,
|
|
|
+ BaudRate = CustomerEnv.CustomerConfig.SerialModel.BaudRate,
|
|
|
+ Parity = CustomerEnv.CustomerConfig.SerialModel.Parity,
|
|
|
+ DataBits = CustomerEnv.CustomerConfig.SerialModel.DataBits,
|
|
|
+ StopBits = CustomerEnv.CustomerConfig.SerialModel.StopBits
|
|
|
+ })
|
|
|
+ {
|
|
|
+ comm.Open();
|
|
|
+ comm.Write(new byte[] { 0x31, 0x31, 0x33, 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x30 }, 0, 10);
|
|
|
+ System.Threading.Thread.Sleep(10000);
|
|
|
+ comm.Close();
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|