Merge branch 'master' of http://www.scserverddns.top:13000/sc/SunlightCentralizedControlManagement
This commit is contained in:
commit
6e4c993835
3 files changed
+207
-12
No files matched your search
@@ -6,6 +6,8 @@
|
|||||||
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
|
xmlns:local="clr-namespace:SunlightCentralizedControlManagement_SCCM_.View"
|
||||||
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
xmlns:lang="clr-namespace:SunlightCentralizedControlManagement_SCCM_.Properties"
|
||||||
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
xmlns:materialDesign="http://materialdesigninxaml.net/winfx/xaml/themes"
|
||||||
|
xmlns:viewmodel="clr-namespace:SunlightCentralizedControlManagement_SCCM_.ViewModel"
|
||||||
|
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}"
|
||||||
mc:Ignorable="d"
|
mc:Ignorable="d"
|
||||||
d:DesignHeight="1000" d:DesignWidth="1900">
|
d:DesignHeight="1000" d:DesignWidth="1900">
|
||||||
<Grid Cursor="">
|
<Grid Cursor="">
|
||||||
@@ -71,6 +73,7 @@
|
|||||||
</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" SelectionChanged="Gridstep_SelectionChanged"
|
||||||
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}"
|
||||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" Background="White"
|
||||||
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
|
GridLinesVisibility="All" ColumnHeaderHeight="40" HorizontalContentAlignment="Right"
|
||||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||||
|
|||||||
+42
-12
@@ -2,9 +2,12 @@
|
|||||||
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
using SunlightCentralizedControlManagement_SCCM_.WindowsView;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Net;
|
using System.Net;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows;
|
using System.Windows;
|
||||||
@@ -21,6 +24,7 @@ using System.Xml.Linq;
|
|||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
|
using static SunlightCentralizedControlManagement_SCCM_.WindowsView.ViewStep;
|
||||||
|
using static System.Net.WebRequestMethods;
|
||||||
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
|
using static System.Windows.Forms.VisualStyles.VisualStyleElement.Rebar;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.View
|
namespace SunlightCentralizedControlManagement_SCCM_.View
|
||||||
@@ -33,6 +37,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
public MonitorView()
|
public MonitorView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
|
||||||
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
Griddata.ItemsSource = MainWindowViewModel.Machines.DefaultView;
|
||||||
CountDown();
|
CountDown();
|
||||||
}
|
}
|
||||||
@@ -140,13 +145,13 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
if (ID == null) ID = TechnologicalProcess.Rows.Count.ToString();
|
if (ID == null) ID = TechnologicalProcess.Rows.Count.ToString();
|
||||||
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
|
ViewStep viewstop = new ViewStep(Numder, P1, P2, P3, P4, P5);
|
||||||
viewstop.data = ID;
|
viewstop.data = ID;
|
||||||
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
|
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(edit_ButtonClicked);
|
||||||
viewstop.ShowDialog();
|
viewstop.ShowDialog();
|
||||||
}//编辑
|
}//编辑
|
||||||
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 Address_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
|
private void edit_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
|
||||||
{
|
{
|
||||||
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
|
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
|
||||||
dat_821.Clear();
|
dat_821.Clear();
|
||||||
@@ -172,12 +177,31 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
}//跳步
|
}//跳步
|
||||||
private void ListViewItem_Insert(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_Insert(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
if (ID == null) ID = (TechnologicalProcess.Rows.Count-1).ToString();
|
if (ID == null) ID = (TechnologicalProcess.Rows.Count).ToString();
|
||||||
ViewStep viewstop = new ViewStep(null, "0", "0", "0", "0", "0");
|
ViewStep viewstop = new ViewStep(null, "0", "0", "0", "0", "0");
|
||||||
viewstop.data = ID;
|
viewstop.data = ID;
|
||||||
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Address_ButtonClicked);
|
viewstop.AddressUpdated += new ViewStep.AddressUpdateHandler(Insert_ButtonClicked);
|
||||||
viewstop.ShowDialog();
|
viewstop.ShowDialog();
|
||||||
}//插入
|
}//插入
|
||||||
|
private void Insert_ButtonClicked(object sender, AddressUpdateEventArgs e)//编辑返回结果
|
||||||
|
{
|
||||||
|
Dictionary<string, object> dat_821 = new Dictionary<string, object>();
|
||||||
|
dat_821.Clear();
|
||||||
|
dat_821.Add("INSTRUCTION", "INSERT");
|
||||||
|
dat_821.Add("StepID", e.StepID);
|
||||||
|
dat_821.Add("StepName", e.StepNAME);
|
||||||
|
dat_821.Add("ParameterName", e.PNAME);
|
||||||
|
dat_821.Add("Parameter1", e.P1);
|
||||||
|
dat_821.Add("Parameter2", e.P2);
|
||||||
|
dat_821.Add("Parameter3", e.P3);
|
||||||
|
dat_821.Add("Parameter4", e.P4);
|
||||||
|
dat_821.Add("Parameter5", e.P5);
|
||||||
|
dat_821.Add("ID", ID);
|
||||||
|
|
||||||
|
DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First();
|
||||||
|
int index = Convert.ToInt16(drEmployee.Field<object>("ID"));
|
||||||
|
MainWindowViewModel.MachiensTcpClient[index].SendAsync("SC821" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index) + dat_821.ToJsonString());
|
||||||
|
}
|
||||||
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
|
private void ListViewItem_Delete(object sender, MouseButtonEventArgs e)
|
||||||
{
|
{
|
||||||
|
|
||||||
@@ -230,25 +254,31 @@ namespace SunlightCentralizedControlManagement_SCCM_.View
|
|||||||
MainWindowViewModel.MachiensTcpClient[index].SendAsync("SC831" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index));
|
MainWindowViewModel.MachiensTcpClient[index].SendAsync("SC831" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", index));
|
||||||
if (TechnologicalProcess.Rows.Count > 0)
|
if (TechnologicalProcess.Rows.Count > 0)
|
||||||
{
|
{
|
||||||
DataView dataView = TechnologicalProcess.DefaultView;
|
// Gridstep.ItemsSource = MainWindowViewModel.dt_TP.DefaultView;
|
||||||
if (Gridstep.ItemsSource != dataView)
|
// if (!Equals(Gridstep.ItemsSource , TechnologicalProcess.DefaultView))
|
||||||
{
|
// {
|
||||||
Gridstep.ItemsSource = dataView;
|
MainWindowViewModel.dt_TP = TechnologicalProcess;
|
||||||
}
|
// }
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Gridstep.ItemsSource = null;
|
// MainWindowViewModel.dt_TP = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Gridstep.ItemsSource = null;
|
// MainWindowViewModel.dt_TP = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ) { log.Text = null; Gridstep.ItemsSource = null; }//返回错误为空
|
catch (Exception )
|
||||||
|
{
|
||||||
|
log.Text = null;
|
||||||
|
// MainWindowViewModel.dt_TP = null;
|
||||||
|
}//返回错误为空
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -5,18 +5,22 @@ using SunlightCentralizedControlManagement_SCCM_.Properties;
|
|||||||
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
using SunlightCentralizedControlManagement_SCCM_.UserClass;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
|
using System.Collections.ObjectModel;
|
||||||
using System.ComponentModel;
|
using System.ComponentModel;
|
||||||
using System.Data;
|
using System.Data;
|
||||||
using System.Data.SqlClient;
|
using System.Data.SqlClient;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
using System.Reflection;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
|
using System.Windows.Forms;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
using System.Windows.Threading;
|
using System.Windows.Threading;
|
||||||
using TouchSocket.Core;
|
using TouchSocket.Core;
|
||||||
using TouchSocket.Sockets;
|
using TouchSocket.Sockets;
|
||||||
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
using static SunlightCentralizedControlManagement_SCCM_.UserClass.SqliteHelper;
|
||||||
|
using static System.Net.WebRequestMethods;
|
||||||
|
|
||||||
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
||||||
{
|
{
|
||||||
@@ -121,6 +125,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
void Tick_Event_5S(object sender, EventArgs e)//Tick_Event周期执行事件5S
|
||||||
{
|
{
|
||||||
|
|
||||||
for (int i = 0; i < Machinesdata_Count; i++)
|
for (int i = 0; i < Machinesdata_Count; i++)
|
||||||
{
|
{
|
||||||
if (Selet_Machines(Machines, "State", i).ToString() == "801")
|
if (Selet_Machines(Machines, "State", i).ToString() == "801")
|
||||||
@@ -132,6 +137,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
}
|
}
|
||||||
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
void DisTimer_500MS(object sender, EventArgs e)//Tick_Event周期执行事件500MS
|
||||||
{
|
{
|
||||||
|
DATA_view();
|
||||||
|
|
||||||
for (int i = 0; i < Machinesdata_Count; i++)
|
for (int i = 0; i < Machinesdata_Count; i++)
|
||||||
{
|
{
|
||||||
string mac_s = Selet_Machines(Machines, "State", i).ToString();
|
string mac_s = Selet_Machines(Machines, "State", i).ToString();
|
||||||
@@ -157,6 +164,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
CountDown();
|
CountDown();
|
||||||
TcpClientNEW();
|
TcpClientNEW();
|
||||||
SQL_LINK();
|
SQL_LINK();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static TcpClient[] MachiensTcpClient = new TcpClient[999];
|
public static TcpClient[] MachiensTcpClient = new TcpClient[999];
|
||||||
@@ -224,5 +232,159 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
|
|||||||
// LogGing.LogGingDATA("SDTD:" + ex.ToString());
|
// LogGing.LogGingDATA("SDTD:" + ex.ToString());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
public static DataTable dt_d = new DataTable("DIO");
|
||||||
|
public static DataTable dt_a = new DataTable("AIO");
|
||||||
|
public static DataTable dt_m = new DataTable("M");
|
||||||
|
public static DataTable dt_TP = new DataTable();
|
||||||
|
private async void DATA_view()//IO显示
|
||||||
|
{
|
||||||
|
await Task.Run(() =>
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
TechnologicalProcess_View = ToObservableCollection<Technological>(dt_TP);
|
||||||
|
}
|
||||||
|
catch (Exception) { }
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
ObservableCollection<DATA_A> sysData_A = new ObservableCollection<DATA_A>();
|
||||||
|
ObservableCollection<DATA_D> sysData_D = new ObservableCollection<DATA_D>();
|
||||||
|
ObservableCollection<DATA_M> sysData_M = new ObservableCollection<DATA_M>();
|
||||||
|
ObservableCollection<Technological> technologicalProcess_View = new ObservableCollection<Technological>();
|
||||||
|
public ObservableCollection<DATA_A> SYSData_A
|
||||||
|
{
|
||||||
|
|
||||||
|
get { return sysData_A; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
sysData_A = value;
|
||||||
|
RaisePropertyChanged("SYSData_A");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ObservableCollection<DATA_D> SYSData_D
|
||||||
|
{
|
||||||
|
|
||||||
|
get { return sysData_D; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
sysData_D = value;
|
||||||
|
RaisePropertyChanged("SYSData_D");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ObservableCollection<DATA_M> SYSData_M
|
||||||
|
{
|
||||||
|
|
||||||
|
get { return sysData_M; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
sysData_M = value;
|
||||||
|
RaisePropertyChanged("SYSData_M");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public ObservableCollection<Technological> TechnologicalProcess_View
|
||||||
|
{
|
||||||
|
|
||||||
|
get { return technologicalProcess_View; }
|
||||||
|
set
|
||||||
|
{
|
||||||
|
technologicalProcess_View = value;
|
||||||
|
RaisePropertyChanged("TechnologicalProcess_View");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
public class DATA_A
|
||||||
|
{
|
||||||
|
public string IOName { get; set; }
|
||||||
|
public int AIO { get; set; }
|
||||||
|
public string ID { get; set; }
|
||||||
|
public string PLC { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
}
|
||||||
|
public class DATA_D
|
||||||
|
{
|
||||||
|
public string IOName { get; set; }
|
||||||
|
public bool DIO { get; set; }
|
||||||
|
public string ID { get; set; }
|
||||||
|
public string PLC { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
}
|
||||||
|
public class DATA_M
|
||||||
|
{
|
||||||
|
public string IOName { get; set; }
|
||||||
|
public double Value { get; set; }
|
||||||
|
public string ID { get; set; }
|
||||||
|
public string PLC { get; set; }
|
||||||
|
public string type { get; set; }
|
||||||
|
}
|
||||||
|
public class Technological
|
||||||
|
{
|
||||||
|
public string ProgramID { get; set; }
|
||||||
|
public string Program { get; set; }
|
||||||
|
public double Step { get; set; }
|
||||||
|
public string StepID { get; set; }
|
||||||
|
public string StepName { get; set; }
|
||||||
|
public string ParameterName { get; set; }
|
||||||
|
public string Parameter1 { get; set; }
|
||||||
|
public string Parameter2 { get; set; }
|
||||||
|
public string Parameter3 { get; set; }
|
||||||
|
public string Parameter4 { get; set; }
|
||||||
|
public string Parameter5 { get; set; }
|
||||||
|
public string Parameter6 { get; set; }
|
||||||
|
public string Parameter7 { get; set; }
|
||||||
|
public string Parameter8 { get; set; }
|
||||||
|
public string Parameter9 { get; set; }
|
||||||
|
public string Parameter10 { get; set; }
|
||||||
|
public string DYELOT { get; set; }
|
||||||
|
}
|
||||||
|
public ObservableCollection<T> ToObservableCollection<T>(DataTable dt) where T : class, new()
|
||||||
|
{
|
||||||
|
Type t = typeof(T);
|
||||||
|
PropertyInfo[] propertys = t.GetProperties();
|
||||||
|
ObservableCollection<T> lst = new ObservableCollection<T>();
|
||||||
|
string typeName = string.Empty;
|
||||||
|
foreach (DataRow dr in dt.Rows)
|
||||||
|
{
|
||||||
|
T entity = new T();
|
||||||
|
foreach (PropertyInfo pi in propertys)
|
||||||
|
{
|
||||||
|
typeName = pi.Name;
|
||||||
|
if (dt.Columns.Contains(typeName))
|
||||||
|
{
|
||||||
|
if (!pi.CanWrite) continue;
|
||||||
|
object value = dr[typeName];
|
||||||
|
if (value == DBNull.Value) continue;
|
||||||
|
if (pi.PropertyType == typeof(string))
|
||||||
|
{
|
||||||
|
pi.SetValue(entity, value.ToString(), null);
|
||||||
|
}
|
||||||
|
else if (pi.PropertyType == typeof(int) || pi.PropertyType == typeof(int?))
|
||||||
|
{
|
||||||
|
pi.SetValue(entity, int.Parse(value.ToString()), null);
|
||||||
|
}
|
||||||
|
else if (pi.PropertyType == typeof(DateTime?) || pi.PropertyType == typeof(DateTime))
|
||||||
|
{
|
||||||
|
pi.SetValue(entity, DateTime.Parse(value.ToString()), null);
|
||||||
|
}
|
||||||
|
else if (pi.PropertyType == typeof(float))
|
||||||
|
{
|
||||||
|
pi.SetValue(entity, float.Parse(value.ToString()), null);
|
||||||
|
}
|
||||||
|
else if (pi.PropertyType == typeof(double))
|
||||||
|
{
|
||||||
|
pi.SetValue(entity, double.Parse(value.ToString()), null);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
pi.SetValue(entity, value, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
lst.Add(entity);
|
||||||
|
}
|
||||||
|
return lst;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user