修改信息页面MonitorView的显示逻辑,添加步骤表选择和右键的限制

This commit is contained in:
sc committed 2025-04-25 23:44:36 +08:00
1 parent de843f4e90
commit 0345229416
6 files changed
+389 -32

No files matched your search

+12 -12
View File
@@ -331,12 +331,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
set { sys_Time = value; OnPropertyChanged("Sys_Time"); }
}
public static string MachineLOG;
public string sys_machine; //显示log
/* public string sys_machine; //显示log
public string Sys_machine //通知UI控件参数改变
{
get { return sys_machine; }
set { sys_machine = value; OnPropertyChanged("Sys_machine"); }
}
}*/
public static object Selet_Machines(DataTable DB, string name, string key)//查询
{
@@ -422,11 +422,11 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
}
}
catch (Exception) { }
try
/* try
{
TechnologicalMachine_View = ToObservableCollection<TechnologicalM>(Machines);
}
catch (Exception) { }
catch (Exception) { }*/
try
{
if (dt_ParameterSet.Rows.Count >= 0)
@@ -443,7 +443,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
}
}
catch (Exception) { }
try
/* try
{
if (dt_TP.Rows.Count >= 0)
{
@@ -451,7 +451,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
Sys_machine = MachineLOG;
}
}
catch (Exception) { }
catch (Exception) { }*/
});
}
@@ -460,8 +460,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
ObservableCollection<DATA_M> sysData_M = new ObservableCollection<DATA_M>();
ObservableCollection<ParameterSet> paramete_Set = new ObservableCollection<ParameterSet>();
ObservableCollection<SysSet> sys_Set = new ObservableCollection<SysSet>();
ObservableCollection<TechnologicalP> technologicalProcess_View = new ObservableCollection<TechnologicalP>();
ObservableCollection<TechnologicalM> technologicalMachine_View = new ObservableCollection<TechnologicalM>();
//ObservableCollection<TechnologicalP> technologicalProcess_View = new ObservableCollection<TechnologicalP>();
//ObservableCollection<TechnologicalM> technologicalMachine_View = new ObservableCollection<TechnologicalM>();
public ObservableCollection<DATA_A> SYSData_A
{
@@ -491,7 +491,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
RaisePropertyChanged("SYSData_M");
}
}
public ObservableCollection<TechnologicalP> TechnologicalProcess_View
/* public ObservableCollection<TechnologicalP> TechnologicalProcess_View
{
get { return technologicalProcess_View; }
set
@@ -508,7 +508,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
technologicalMachine_View = value;
RaisePropertyChanged("TechnologicalMachine_View");
}
}
}*/
public ObservableCollection<ParameterSet> Paramete_Set
{
get { return paramete_Set; }
@@ -551,7 +551,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
public string PLC { get; set; }
public string type { get; set; }
}
public class TechnologicalM
/* public class TechnologicalM
{
public string Name { get; set; }
public string WorkOrder { get; set; }
@@ -578,7 +578,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
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; }
+162
View File
@@ -0,0 +1,162 @@
using SunlightCentralizedControlManagement_SCCM_.EX;
using SunlightCentralizedControlManagement_SCCM_.UserClass;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Threading;
using static SunlightCentralizedControlManagement_SCCM_.ViewModel.MainWindowViewModel;
namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{
public class MonitorViewModel : ViewModelBase
{
public MonitorViewModel()
{
// DispatcherTimer timer1s = new DispatcherTimer(DispatcherPriority.Normal);//初始化循环,每1秒调用一次Tick
// timer1s.Interval = TimeSpan.FromMilliseconds(950);//秒
// timer1s.Tick += Tick_Main_1S;
// timer1s.Start();
}
void Tick_Main_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
{
DATA_view();
}
public string sys_machine; //显示log
public string Sys_machine //通知UI控件参数改变
{
get { return sys_machine; }
set { sys_machine = value; OnPropertyChanged("Sys_machine"); }
}
public static bool TechnologicalProcess_bool = true;
private async void DATA_view()//IO显示
{
await Task.Run(() =>
{
try
{
TechnologicalMachine_View = ToObservableCollection<TechnologicalM>(Machines);
}
catch (Exception) { }
try
{
if (dt_TP.Rows.Count >= 0)
{
if (TechnologicalProcess_bool) TechnologicalProcess_View = ToObservableCollection<TechnologicalP>(dt_TP);
Sys_machine = MachineLOG;
}
}
catch (Exception) { }
});
}
ObservableCollection<TechnologicalP> technologicalProcess_View = new ObservableCollection<TechnologicalP>();
ObservableCollection<TechnologicalM> technologicalMachine_View = new ObservableCollection<TechnologicalM>();
public ObservableCollection<TechnologicalP> TechnologicalProcess_View
{
get { return technologicalProcess_View; }
set
{
technologicalProcess_View = value;
RaisePropertyChanged("TechnologicalProcess_View");
}
}
public ObservableCollection<TechnologicalM> TechnologicalMachine_View
{
get { return technologicalMachine_View; }
set
{
technologicalMachine_View = value;
RaisePropertyChanged("TechnologicalMachine_View");
}
}
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 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;
}
}
}