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

9
App.xaml.cs

@ -1,4 +1,5 @@
using LiveChartsCore; using DyeingComputer.UserClass;
using LiveChartsCore;
using LiveChartsCore.SkiaSharpView; using LiveChartsCore.SkiaSharpView;
using SkiaSharp; using SkiaSharp;
using System; using System;
@ -84,7 +85,7 @@ namespace SunlightCentralizedControlManagement_SCCM_
mutex = new System.Threading.Mutex(true, "SCCM", out ret);//程序只允许启动一次 mutex = new System.Threading.Mutex(true, "SCCM", out ret);//程序只允许启动一次
if (!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"); MessageBox.Show("The program has been launched");
Environment.Exit(0); Environment.Exit(0);
} }
@ -127,8 +128,8 @@ namespace SunlightCentralizedControlManagement_SCCM_
string Log_time = DateTime.Now.ToString("yyyy-MM-dd"); string Log_time = DateTime.Now.ToString("yyyy-MM-dd");
string logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录 string logpath = System.Environment.CurrentDirectory + "\\ERR";//日志文件目录
//string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件 // string logPathtxt = "" + System.Environment.CurrentDirectory + "\\Log\\"+ Log_time + "Log.txt";//日志文件
// System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录 // System.IO.DirectoryInfo log = new System.IO.DirectoryInfo();//生成日志文件目录
string log_path = logpath + "\\ERR" + Log_time + ".txt"; string log_path = logpath + "\\ERR" + Log_time + ".txt";
string Log_timehms = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"); string Log_timehms = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss");
if (Directory.Exists(logpath))//检查日志路径 if (Directory.Exists(logpath))//检查日志路径

18
UserClass/AsyncTcpClient.cs

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

2
View/MonitorView.xaml

@ -97,7 +97,7 @@
<ColumnDefinition Width="5"/> <ColumnDefinition Width="5"/>
<ColumnDefinition/> <ColumnDefinition/>
</Grid.ColumnDefinitions> </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" d:ItemsSource="{d:SampleData ItemCount=90}" AutoGenerateColumns="False" MinColumnWidth="30"
ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" ItemsSource="{Binding Path=TechnologicalProcess_View,Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}"
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White" 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;//获取鼠标选中行并定义变量 int rownum = Gridstep.SelectedIndex;//获取鼠标选中行并定义变量
if (rownum != -1)//判断鼠标定位是否有效 if (rownum != -1)//判断鼠标定位是否有效
{ {
@ -74,8 +76,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
P4 = (Gridstep.Columns[9].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第9列, P4 = (Gridstep.Columns[9].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第9列,
P5 = (Gridstep.Columns[10].GetCellContent(Gridstep.Items[rownum]) as TextBlock).Text;//定位第10列, 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) private void ListViewItem_DyeingMachine(object sender, MouseButtonEventArgs e)
@ -148,13 +148,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
viewstop.data = ID; viewstop.data = ID;
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(edit_ButtonClicked); viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(edit_ButtonClicked);
viewstop.ShowDialog(); viewstop.ShowDialog();
MainWindowViewModel.TechnologicalProcess_bool = true;
}//编辑 }//编辑
string Numder = null; string Numder = null;
string ID = null; string ID = null;
string P1 = "0", P2 = "0", P3 = "0", P4 = "0", P5 = "0"; string P1 = "0", P2 = "0", P3 = "0", P4 = "0", P5 = "0";
private void edit_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果 private void edit_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
{ {
MainWindowViewModel.TechnologicalProcess_bool = true;
Dictionary<string, object> dat_821 = new Dictionary<string, object>(); Dictionary<string, object> dat_821 = new Dictionary<string, object>();
dat_821.Clear(); dat_821.Clear();
dat_821.Add("INSTRUCTION", "EDIT"); dat_821.Add("INSTRUCTION", "EDIT");

16
ViewModel/MainWindowViewModel.cs

@ -163,12 +163,14 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{ {
for (int i = 0; i < Machinesdata_Count; i++) for (int i = 0; i < Machinesdata_Count; i++)
{ {
MachiensTcpClient[i] = new TcpClient(); if (Selet_Machines(Machines, "State", i).ToString() == "800")
DataRow dt = machinesdata[i]; {
Updata_Machines(Machines, "State", Convert.ToInt16(dt["ID"]), "800"); MachiensTcpClient[i] = new TcpClient();
_ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接 DataRow dt = machinesdata[i];
, Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString() _ = AsyncTcpClient.TcpClient(MachiensTcpClient[i] //建立tcp连接
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString()); , Selet_Machines(Machines, "IP", Convert.ToInt16(dt["ID"])).ToString()
, Selet_Machines(Machines, "PORT", Convert.ToInt16(dt["ID"])).ToString());
}
} }
} }
@ -447,6 +449,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
return lst; return lst;
} }
//通讯队列 //通讯队列
public static UInt32 RX=0;
public static UInt32 TX=0;
public class QueueString public class QueueString
{ {
public int ID { get; set; } public int ID { get; set; }

Loading…
Cancel
Save