You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
139 lines
5.3 KiB
139 lines
5.3 KiB
using ScottPlot.TickGenerators.TimeUnits;
|
|
using SunlightCentralizedControlManagement_SCCM_.ViewModel;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.Linq;
|
|
using System.Net;
|
|
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.Forms;
|
|
using System.Windows.Input;
|
|
using System.Windows.Markup;
|
|
using System.Windows.Media;
|
|
using System.Windows.Media.Animation;
|
|
using System.Windows.Media.Imaging;
|
|
using System.Windows.Shapes;
|
|
using System.Windows.Threading;
|
|
using System.Xml.Linq;
|
|
using TouchSocket.Core;
|
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
|
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
|
|
|
|
namespace SunlightCentralizedControlManagement_SCCM_.WindowsView
|
|
{
|
|
/// <summary>
|
|
/// ViewProgram.xaml 的交互逻辑
|
|
/// </summary>
|
|
public partial class UserWorkOrder : Window
|
|
{
|
|
|
|
public DataTable WorkOrderTable = new DataTable();//信息
|
|
private string WorkOrder_=null;
|
|
private string machine_ = null;
|
|
public UserWorkOrder()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
private void Window_Loaded(object sender, RoutedEventArgs e)
|
|
{
|
|
WorkOrder.ItemsSource = WorkOrderTable.DefaultView;
|
|
}
|
|
|
|
private void Start_Click(object sender, RoutedEventArgs e)//确认
|
|
{
|
|
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
|
|
dat_821.Clear();
|
|
dat_821.Add("INSTRUCTION", "START");
|
|
dat_821.Add("WorkOrder", WorkOrder_);
|
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine_ + "'").First();
|
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
|
string dat = "SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString();
|
|
|
|
lock (MainWindowViewModel.Machines.Rows.SyncRoot)
|
|
{
|
|
if (drEmployee.Field<bool>("Type"))
|
|
{//网络
|
|
MainWindowViewModel.stringQueue.Enqueue(new MainWindowViewModel.QueueString
|
|
{
|
|
ID = index,
|
|
DAT = dat
|
|
});
|
|
}
|
|
else
|
|
{//串口
|
|
if (drEmployee.Field<string>("Serial") == "PORT1")
|
|
{
|
|
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat);
|
|
if (!exists)
|
|
{
|
|
stringQueueSerial_1.Enqueue(new QueueSerial
|
|
{
|
|
ID = index,
|
|
DAT = dat
|
|
});
|
|
}
|
|
}
|
|
else if (drEmployee.Field<string>("Serial") == "PORT2")
|
|
{
|
|
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat);
|
|
if (!exists)
|
|
{
|
|
stringQueueSerial_2.Enqueue(new QueueSerial
|
|
{
|
|
ID = index,
|
|
DAT = dat
|
|
});
|
|
}
|
|
}
|
|
else if (drEmployee.Field<string>("Serial") == "PORT3")
|
|
{
|
|
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat);
|
|
if (!exists)
|
|
{
|
|
stringQueueSerial_3.Enqueue(new QueueSerial
|
|
{
|
|
ID = index,
|
|
DAT = dat
|
|
});
|
|
}
|
|
}
|
|
else if (drEmployee.Field<string>("Serial") == "PORT4")
|
|
{
|
|
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat);
|
|
if (!exists)
|
|
{
|
|
stringQueueSerial_4.Enqueue(new QueueSerial
|
|
{
|
|
ID = index,
|
|
DAT = dat
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
this.Close();
|
|
}
|
|
private void Quit_Click(object sender, RoutedEventArgs e)//退出
|
|
{
|
|
this.Close(); //关闭窗口
|
|
}
|
|
private void WorkOrder_SelectedCellsChanged(object sender, SelectedCellsChangedEventArgs e)
|
|
{
|
|
int rownum = WorkOrder.SelectedIndex;//获取鼠标选中行并定义变量
|
|
if (rownum != -1)//判断鼠标定位是否有效
|
|
{
|
|
WorkOrder_ = (WorkOrder.Columns[0].GetCellContent(WorkOrder.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
machine_ = (WorkOrder.Columns[3].GetCellContent(WorkOrder.Items[rownum]) as TextBlock).Text;//定位第0列,
|
|
|
|
Start.IsEnabled = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|