sc 11 months ago
parent
commit
915aedd87b
  1. 5
      App.xaml.cs
  2. 18
      UserClass/AsyncTcpClient.cs
  3. 2
      View/MonitorView.xaml
  4. 9
      View/MonitorView.xaml.cs
  5. 6
      ViewModel/MainWindowViewModel.cs

5
App.xaml.cs

@ -1,4 +1,5 @@
using LiveChartsCore;
using DyeingComputer.UserClass;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView;
using SkiaSharp;
using System;
@ -84,7 +85,7 @@ namespace SunlightCentralizedControlManagement_SCCM_
mutex = new System.Threading.Mutex(true, "SCCM", out ret);//程序只允许启动一次
if (!ret)
{
// LogGing.LogGingDATA("800_The program has been launched");
LogGing.LogGingDATA("800_The program has been launched");
MessageBox.Show("The program has been launched");
Environment.Exit(0);
}

18
UserClass/AsyncTcpClient.cs

@ -27,6 +27,7 @@ using Newtonsoft.Json.Linq;
using System.Xml.Linq;
using ScottPlot;
using System.Collections;
using DyeingComputer.UserClass;
namespace SunlightCentralizedControlManagement_SCCM_.UserClass
{/// <summary>
@ -49,6 +50,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_OK");
return EasyTask.CompletedTask;
};//成功连接到服务器
tcpClient.Closing = (client, e) =>
@ -59,6 +62,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP");
return EasyTask.CompletedTask;
};//即将从服务器断开连接。此处仅主动断开才有效。
@ -70,6 +74,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT");
return EasyTask.CompletedTask;
};//从服务器断开连接,当连接不成功时不会触发。
@ -100,12 +105,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
_new = JsonConvert.DeserializeObject<Dictionary<string, object>>(DAT);//反序列化
DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "' AND port='" + client.Port + "'").First();
drEmployee.BeginEdit();
drEmployee["Message"] = _new.GetValue("Status").ToString();
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder").ToString();
drEmployee["Temperature"] = _new.GetValue("MTT").ToString();
drEmployee["WaterLevel"] = _new.GetValue("MTL").ToString();
drEmployee["Process"] = _new.GetValue("Process").ToString();
drEmployee["Step"] = _new.GetValue("Step").ToString();
drEmployee["Message"] = _new.GetValue("Status");
drEmployee["WorkOrder"] = _new.GetValue("WorkNumder");
drEmployee["Temperature"] = _new.GetValue("MTT");
drEmployee["WaterLevel"] = _new.GetValue("MTL");
drEmployee["Process"] = _new.GetValue("Process");
drEmployee["Step"] = _new.GetValue("Step");
drEmployee.EndEdit();
drEmployee.AcceptChanges();
drEmployee.ClearErrors();
@ -113,7 +118,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass
if (_new.GetValue("Status").ToString() != "----------")
{
Dictionary<string, object> Chart_new = new Dictionary<string, object>();//缓存函数
// Chart_new.Add("DYELOT", _new.GetValue("Status"));
Chart_new.Add("WorkOrder", _new.GetValue("WorkNumder"));
Chart_new.Add("Machine", _new.GetValue("Machine"));
Chart_new.Add("Time", _new.GetValue("Time"));

2
View/MonitorView.xaml

@ -97,7 +97,7 @@
<ColumnDefinition Width="5"/>
<ColumnDefinition/>
</Grid.ColumnDefinitions>
<DataGrid Grid.Column="2" x:Name="Gridstep" AlternationCount="2" IsReadOnly="True" SelectionChanged="Gridstep_SelectionChanged"
<DataGrid Grid.Column="2" x:Name="Gridstep" AlternationCount="2" IsReadOnly="True" MouseDoubleClick="Gridstep_MouseDoubleClick"
d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"

9
View/MonitorView.xaml.cs

@ -61,8 +61,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
}
}
private void Gridstep_SelectionChanged(object sender, SelectionChangedEventArgs e)
private void Gridstep_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
Paused.IsEnabled = true;
MainWindowViewModel.TechnologicalProcess_bool = false;
int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效
{
@ -74,8 +76,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
P4 = (Gridstep.Columns[9].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Gridstep.Columns[10].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第10列,
}
Paused.IsEnabled = true;
MainWindowViewModel.TechnologicalProcess_bool = false;
}
private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
@ -148,13 +148,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
viewstop.data = ID;
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(edit_ButtonClicked);
viewstop.ShowDialog();
MainWindowViewModel.TechnologicalProcess_bool = true;
}//编辑
string Numder = null;
string ID = null;
string P1 = "0", P2 = "0", P3 = "0", P4 = "0", P5 = "0";
private void edit_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{
MainWindowViewModel.TechnologicalProcess_bool = true;
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear();
dat_821.Add("INSTRUCTION", "EDIT");

6
ViewModel/MainWindowViewModel.cs

@ -162,15 +162,17 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
void Tick_Event_60S()
{
for (int i = 0; i < Machinesdata_Count; i++)
{
if (Selet_Machines(Machines, "State", i).ToString() == "800")
{
MachiensTcpClient[i] = new TcpClient();
DataRow dt = machinesdata[i];
Updata_Machines(Machines, "State", Convert.ToInt16(dt["ID"]), "800");
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接
, Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString()
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString());
}
}
}
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
@ -447,6 +449,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
return lst;
}
//通讯队列
public static UInt32 RX=0;
public static UInt32 TX=0;
public class QueueString
{
public int ID { get; set; }

Loading…
Cancel
Save