169 lines
6.0 KiB
C#
169 lines
6.0 KiB
C#
|
|
using AutomaticApp.Common;
|
|||
|
|
using AutomaticApp.ViewModels;
|
|||
|
|
using FTP;
|
|||
|
|
using MaterialDesignThemes.Wpf;
|
|||
|
|
using System;
|
|||
|
|
using System.Collections.Generic;
|
|||
|
|
using System.Globalization;
|
|||
|
|
using System.Linq;
|
|||
|
|
using System.Runtime.Intrinsics.Arm;
|
|||
|
|
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 AutomaticApp.Views
|
|||
|
|
{
|
|||
|
|
/// <summary>
|
|||
|
|
/// ControlPageView.xaml 的交互逻辑
|
|||
|
|
/// </summary>
|
|||
|
|
public partial class ControlPageView : UserControl
|
|||
|
|
{
|
|||
|
|
public ControlPageView()
|
|||
|
|
{
|
|||
|
|
InitializeComponent();
|
|||
|
|
this.DataContext = MainWindow.mainViewModel;
|
|||
|
|
|
|||
|
|
//卫通自动控制使能
|
|||
|
|
string[] items = new string[] { "自动", "手动" };
|
|||
|
|
foreach (var item in items)
|
|||
|
|
{
|
|||
|
|
this.SATCOMAutomaticControlEnable.Items.Add(item);
|
|||
|
|
this.SystemControlMode.Items.Add(item);
|
|||
|
|
this.CommunicationControlMode.Items.Add(item);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 北斗连接
|
|||
|
|
//串口号
|
|||
|
|
for (int i = 0; i < tools.GetSerialPort().Length; i++)
|
|||
|
|
{
|
|||
|
|
this.GDCKH.Items.Add(tools.GetSerialPort()[i]);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
//波特率
|
|||
|
|
string[] btl = new string[] { "110", "300", "600", "1200", "2400", "4800", "9600", "14400", "19200", "38400", "56000", "57600", "115200", "128000", "256000" };
|
|||
|
|
for (int i = 0; i < btl.Length; i++)
|
|||
|
|
{
|
|||
|
|
this.BTL.Items.Add(btl[i]);
|
|||
|
|
}
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
//this.ControlGrid.DataContext = MainViewModel.CPV1;
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#region 系统状态连接 + 参数设置
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 北斗连接
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private async void Button_Click(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
await Task.Delay(200);
|
|||
|
|
MessageBox.Show("北斗" + MainViewModel.EM.ComStateMessage, "北斗连接信息提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// Socket通信连接1
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private async void Button_Click_1(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
await Task.Delay(200);
|
|||
|
|
MessageBox.Show("Socket通信连接1" + MainViewModel.EM.Socket1StateMessage, "Socket连接信息提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// Socket连接2
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private async void Button_Click_2(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
await Task.Delay(200);
|
|||
|
|
MessageBox.Show("Socket通信连接2" + MainViewModel.EM.Socket2StateMessage, "Socket连接信息提示", MessageBoxButton.OK, MessageBoxImage.Information);
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// FTP连接
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void Button_Click_3(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
FTPControlWindow fTPControlWindow = new FTPControlWindow(MainViewModel.ftp1.IP, MainViewModel.ftp1.Port, tools.GetAppSetting("UserName1"), tools.GetAppSetting("PassWord1"));
|
|||
|
|
fTPControlWindow.ShowDialog();
|
|||
|
|
}
|
|||
|
|
/// <summary>
|
|||
|
|
/// 信标连接
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void Button_Click_4(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
FTPControlWindow fTPControlWindow = new FTPControlWindow(MainViewModel.ftp2.IP, MainViewModel.ftp2.Port, tools.GetAppSetting("UserName2"), tools.GetAppSetting("PassWord2"));
|
|||
|
|
fTPControlWindow.ShowDialog();
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
|
|||
|
|
/// <summary>
|
|||
|
|
/// 地震仪参数设置
|
|||
|
|
/// </summary>
|
|||
|
|
/// <param name="sender"></param>
|
|||
|
|
/// <param name="e"></param>
|
|||
|
|
private void Button_Click_5(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
MessageBox.Show("地震仪参数设置成功");
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
#endregion
|
|||
|
|
|
|||
|
|
bool isan = false;
|
|||
|
|
private async void Switch_ClickAsync(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
if (!isan)
|
|||
|
|
{
|
|||
|
|
isan = true;
|
|||
|
|
while (string.IsNullOrEmpty(MainViewModel.EM.ControlMessage))
|
|||
|
|
{
|
|||
|
|
await Task.Delay(1);
|
|||
|
|
}
|
|||
|
|
//if (!MainViewModel.EM.ControlMessage.Contains("失败"))
|
|||
|
|
//{
|
|||
|
|
// MainWindow.mainViewModel.BDCountDownCommand();
|
|||
|
|
//}
|
|||
|
|
MessageBox.Show(MainViewModel.EM.ControlMessage, "控制指令", MessageBoxButton.OK, MessageBoxImage.Information);
|
|||
|
|
MainViewModel.EM.ControlMessage = "";
|
|||
|
|
isan = false;
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
private void Button_Click_6(object sender, RoutedEventArgs e)
|
|||
|
|
{
|
|||
|
|
FTPControlWindow fTPControlWindow = new FTPControlWindow(MainViewModel.ftp2.IP, MainViewModel.ftp2.Port, tools.GetAppSetting("UserName1"), tools.GetAppSetting("PassWord1"));
|
|||
|
|
fTPControlWindow.ShowDialog();
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
|
|||
|
|
public class ParaSetValidationRule : ValidationRule
|
|||
|
|
{
|
|||
|
|
public override ValidationResult Validate(object value, CultureInfo cultureInfo)
|
|||
|
|
{
|
|||
|
|
int ret = 0;
|
|||
|
|
if (!int.TryParse(value.ToString(), out ret))
|
|||
|
|
return new ValidationResult(false, "不是有效的数字");
|
|||
|
|
if (ret > 130 || ret < 1)
|
|||
|
|
return new ValidationResult(false, "年龄必须是1-130之间");
|
|||
|
|
return new ValidationResult(true, "");
|
|||
|
|
}
|
|||
|
|
}
|
|||
|
|
}
|