diff --git a/ConvertMoels/StatexmlConvert.cs b/ConvertMoels/StatexmlConvert.cs index 345634e..3318486 100644 --- a/ConvertMoels/StatexmlConvert.cs +++ b/ConvertMoels/StatexmlConvert.cs @@ -29,7 +29,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ConvertMoels else if (i == "800") Staten = "LinkOff";//未连接 else if (i == "801") Staten = "Link";//连接成功 else if (i == "899") Staten = "LinkOff";//关闭连接 - else if (i == "TRUE") Staten = "Lock";//锁 + else if (i == "True") Staten = "Lock";//锁 return Staten; } diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index ed6bcfb..7ca5bfa 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -2688,6 +2688,24 @@ namespace SunlightCentralizedControlManagement_SCCM_.Properties { } } + /// + /// 查找类似 user_lock 的本地化字符串。 + /// + public static string user_lock { + get { + return ResourceManager.GetString("user_lock", resourceCulture); + } + } + + /// + /// 查找类似 user_unlock 的本地化字符串。 + /// + public static string user_unlock { + get { + return ResourceManager.GetString("user_unlock", resourceCulture); + } + } + /// /// 查找类似 Valid time 的本地化字符串。 /// diff --git a/Properties/Resources.en-US.resx b/Properties/Resources.en-US.resx index 3e2a764..86bf1c9 100644 --- a/Properties/Resources.en-US.resx +++ b/Properties/Resources.en-US.resx @@ -1050,4 +1050,10 @@ The machine is not ready + + LOCK + + + UNLOCK + \ No newline at end of file diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 90b5c33..3c4fb23 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -1050,4 +1050,10 @@ The machine is not ready + + user_lock + + + user_unlock + \ No newline at end of file diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index 840cbb8..3c2bf15 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -1050,4 +1050,10 @@ 机台未就绪 + + 锁定 + + + 解锁 + \ No newline at end of file diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index 4adedbd..684eccd 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -1050,4 +1050,10 @@ 機台未就緒 + + + + + + \ No newline at end of file diff --git a/UserClass/AsyncTcpClient.cs b/UserClass/AsyncTcpClient.cs index 6d2c3e4..5437742 100644 --- a/UserClass/AsyncTcpClient.cs +++ b/UserClass/AsyncTcpClient.cs @@ -74,6 +74,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass drEmployee["Process"] = ""; drEmployee["Step"] = ""; drEmployee["Message"] = ""; + drEmployee["SYSKEY"] = ""; drEmployee.EndEdit(); drEmployee.AcceptChanges(); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_STOP"); @@ -98,6 +99,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass drEmployee["Process"] = ""; drEmployee["Step"] = ""; drEmployee["Message"] = ""; + drEmployee["SYSKEY"] = ""; drEmployee.EndEdit(); drEmployee.AcceptChanges(); LogGing.LogGingDATA("[IP='" + client.IP + "' AND port='" + client.Port + "']=Link_INTERRUPT"); @@ -133,7 +135,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass { LogGing.ERRDATA(ex); MainWindowViewModel.ERR_c++; } - } else if (SYSAPI == "SC810") { @@ -174,6 +175,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass _new = JsonConvert.DeserializeObject>(DAT);//反序列化 DataRow drEmployee = MainWindowViewModel.Machines.Select("IP='" + client.IP + "'").First(); drEmployee.BeginEdit(); + drEmployee["LOCK"] = _new.GetValue("LOCK"); drEmployee["Message"] = _new.GetValue("Status"); drEmployee["WorkOrder"] = _new.GetValue("WorkNumder"); drEmployee["Temperature"] = _new.GetValue("MTT"); @@ -209,7 +211,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.UserClass } catch (Exception ex) { LogGing.LogGingDATA("[ERR='" + ex + "']=Exception"); MainWindowViewModel.ERR_c++; } - } + }//当前信息 else if (SYSAPI == "SC831") { try diff --git a/View/MachinesView.xaml.cs b/View/MachinesView.xaml.cs index a2a3425..ea4be47 100644 --- a/View/MachinesView.xaml.cs +++ b/View/MachinesView.xaml.cs @@ -460,50 +460,54 @@ namespace SunlightCentralizedControlManagement_SCCM_.View } public ObservableCollection ToObservableCollection(DataTable dt) where T : class, new() { - Type t = typeof(T); - PropertyInfo[] propertys = t.GetProperties(); - ObservableCollection lst = new ObservableCollection(); - string typeName = string.Empty; - foreach (DataRow dr in dt.Rows) + try { - T entity = new T(); - foreach (PropertyInfo pi in propertys) + Type t = typeof(T); + PropertyInfo[] propertys = t.GetProperties(); + ObservableCollection lst = new ObservableCollection(); + string typeName = string.Empty; + foreach (DataRow dr in dt.Rows) { - typeName = pi.Name; - if (dt.Columns.Contains(typeName)) + T entity = new T(); + foreach (PropertyInfo pi in propertys) { - if (!pi.CanWrite) continue; - object value = dr[typeName]; - if (value == DBNull.Value) continue; - if (pi.PropertyType == typeof(string)) + typeName = pi.Name; + if (dt.Columns.Contains(typeName)) { - 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); + 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); } - lst.Add(entity); + return lst; } - return lst; - } + catch (Exception) { return null; } + } } } diff --git a/View/MonitorView.xaml.cs b/View/MonitorView.xaml.cs index fdb3991..05b1bdf 100644 --- a/View/MonitorView.xaml.cs +++ b/View/MonitorView.xaml.cs @@ -119,7 +119,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.View else { MessageBox.Show(Properties.Resources.TMNR, "800", MessageBoxButton.OK, MessageBoxImage.Information); // - } } @@ -226,15 +225,15 @@ namespace SunlightCentralizedControlManagement_SCCM_.View Dictionary dat_821 = new Dictionary(); dat_821.Clear(); - if (mode != "TRUE") + if (mode != "True") { - dat_821.Add("LOCK", "TRUE"); - MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "TRUE"); - } + dat_821.Add("LOCK", "True"); + MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "True"); + } else { dat_821.Add("LOCK", "FALSE"); - MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "FALSE"); + MainWindowViewModel.Updata_Machines(MainWindowViewModel.Machines, "LOCK", "Name='" + machine + "'", "False"); } DataRow drEmployee = MainWindowViewModel.Machines.Select("NAME='" + machine + "'").First(); @@ -245,6 +244,10 @@ namespace SunlightCentralizedControlManagement_SCCM_.View DAT = "SC829" + MainWindowViewModel.Selet_Machines(MainWindowViewModel.Machines, "SYSKEY", "ID='" + index + "'") + dat_821.ToJsonString() }); + if (mode != "True") { MessageBox.Show(machine + Properties.Resources.user_lock, "800", MessageBoxButton.OK, MessageBoxImage.Information); + } else { + MessageBox.Show(machine + Properties.Resources.user_unlock, "800", MessageBoxButton.OK, MessageBoxImage.Information); + } }//锁定 private void ListViewItem_Curve(object sender, MouseButtonEventArgs e) { @@ -599,7 +602,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.View catch (Exception) { } try { - if (MainWindowViewModel.dt_TP.Rows.Count >= 0) + if (MainWindowViewModel.dt_TP.Rows.Count > 0) { if (TechnologicalProcess_bool) { @@ -665,50 +668,54 @@ namespace SunlightCentralizedControlManagement_SCCM_.View public ObservableCollection ToObservableCollection(DataTable dt) where T : class, new() { - Type t = typeof(T); - PropertyInfo[] propertys = t.GetProperties(); - ObservableCollection lst = new ObservableCollection(); - string typeName = string.Empty; - foreach (DataRow dr in dt.Rows) + try { - T entity = new T(); - foreach (PropertyInfo pi in propertys) + Type t = typeof(T); + PropertyInfo[] propertys = t.GetProperties(); + ObservableCollection lst = new ObservableCollection(); + string typeName = string.Empty; + foreach (DataRow dr in dt.Rows) { - typeName = pi.Name; - if (dt.Columns.Contains(typeName)) + T entity = new T(); + foreach (PropertyInfo pi in propertys) { - 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)) + typeName = pi.Name; + if (dt.Columns.Contains(typeName)) { - 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); + 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); } - lst.Add(entity); + return lst; } - return lst; + catch (Exception) { return null; } } } diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index efc7a30..090cd69 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -177,7 +177,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel void Tick_Main_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S { - DATA_view(); //下传工单信息 SQLiteHelper WorkOrderSQL = new SQLiteHelper(DBAddress); //数据库连接路径 WorkOrderSQL.Open(); //打开数据库 @@ -239,11 +238,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel });//信息插入队列 string mode = Machines.Select("ID='" + i + "'").First().Field("LOCK");//发送锁定状态 - if (mode == "TRUE") + if (mode == "True") { Dictionary dat_821 = new Dictionary(); dat_821.Clear(); - dat_821.Add("LOCK", "TRUE"); + dat_821.Add("LOCK", "True"); DataRow drEmployee = Machines.Select("ID='" + i + "'").First(); int index = Convert.ToInt16(drEmployee.Field("ID")); stringQueue.Enqueue(new QueueString @@ -406,253 +405,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel public static string workOrder; public static string dyelot; public static string machin_LOG; - - private async void DATA_view()//IO显示 - { - await Task.Run(() => - { - /* try - { - if (dt_m.Rows.Count >= 0) - { - SYSData_M = ToObservableCollection(dt_m); - } - } - catch (Exception ) { } - try - { - if (dt_a.Rows.Count >= 0) - { - if ((bool)A_view) SYSData_A = ToObservableCollection(dt_a); - } - } - catch (Exception ) { } - try - { - if (dt_d.Rows.Count >= 0) - { - if ((bool)D_view) SYSData_D = ToObservableCollection(dt_d); - } - } - catch (Exception) { }*/ - /* try - { - TechnologicalMachine_View = ToObservableCollection(Machines); - } - catch (Exception) { }*/ - /* try - { - if (dt_ParameterSet.Rows.Count >= 0) - { - if(ParameterSet_view) Paramete_Set = ToObservableCollection(dt_ParameterSet); - } - } - catch (Exception) { } - try - { - if (dt_SysSet.Rows.Count >= 0) - { - if (SysSet_view) Sys_Set = ToObservableCollection(dt_SysSet); - } - } - catch (Exception) { }*/ - /* try - { - if (dt_TP.Rows.Count >= 0) - { - if(TechnologicalProcess_bool) TechnologicalProcess_View = ToObservableCollection(dt_TP); - Sys_machine = MachineLOG; - } - } - catch (Exception) { }*/ - }); - } - - // ObservableCollection sysData_A = new ObservableCollection(); - // ObservableCollection sysData_D = new ObservableCollection(); - // ObservableCollection sysData_M = new ObservableCollection(); - // ObservableCollection paramete_Set = new ObservableCollection(); - // ObservableCollection sys_Set = new ObservableCollection(); - //ObservableCollection technologicalProcess_View = new ObservableCollection(); - //ObservableCollection technologicalMachine_View = new ObservableCollection(); - /* public ObservableCollection SYSData_A - { - - get { return sysData_A; } - set - { - sysData_A = value; - RaisePropertyChanged("SYSData_A"); - } - } - public ObservableCollection SYSData_D - { - - get { return sysData_D; } - set - { - sysData_D = value; - RaisePropertyChanged("SYSData_D"); - } - } - public ObservableCollection SYSData_M - { - get { return sysData_M; } - set - { - sysData_M = value; - RaisePropertyChanged("SYSData_M"); - } - }*/ - /* public ObservableCollection TechnologicalProcess_View - { - get { return technologicalProcess_View; } - set - { - technologicalProcess_View = value; - RaisePropertyChanged("TechnologicalProcess_View"); - } - } - public ObservableCollection TechnologicalMachine_View - { - get { return technologicalMachine_View; } - set - { - technologicalMachine_View = value; - RaisePropertyChanged("TechnologicalMachine_View"); - } - }*/ - /* public ObservableCollection Paramete_Set - { - get { return paramete_Set; } - set - { - paramete_Set = value; - RaisePropertyChanged("Paramete_Set"); - } - } - public ObservableCollection Sys_Set - { - get { return sys_Set; } - set - { - sys_Set = value; - RaisePropertyChanged("Sys_Set"); - } - }*/ - /* 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 TechnologicalM - { - public string Name { get; set; } - public string WorkOrder { get; set; } - public string Dyelot { get; set; } - public string Temperature { get; set; } - public string WaterLevel { get; set; } - public string Process { get; set; } - public string Step { get; set; } - public string Message { get; set; } - public string State { get; set; } - - } - public class TechnologicalP - { - 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 DYELOT { get; set; } - }*/ - /* public class ParameterSet - { public string Category { get; set; } - public string ParameterID { get; set; } - public string ParameterName { get; set; } - public string Value { get; set; } - - } - public class SysSet - { - public string Category { get; set; } - public string ParameterID { get; set; } - public string ParameterName { get; set; } - public string Value { get; set; } - }*/ - public ObservableCollection ToObservableCollection(DataTable dt) where T : class, new() - { - Type t = typeof(T); - PropertyInfo[] propertys = t.GetProperties(); - ObservableCollection lst = new ObservableCollection(); - 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; - } + //通讯队列 public static UInt32 RX=0; public static UInt32 TX=0;