修改io表查改逻辑,降低i资源开销60=>10
This commit is contained in:
commit
2db3bfd186
5 files changed
+90
-21
No files matched your search
@@ -124,33 +124,43 @@ namespace DyeingComputer
|
|||||||
{
|
{
|
||||||
case "Work_Order":
|
case "Work_Order":
|
||||||
container.Content = new WorkOrderView();
|
container.Content = new WorkOrderView();
|
||||||
|
MainWindowViewModel.ViewID = 0;
|
||||||
break;
|
break;
|
||||||
case "Technological_Process":
|
case "Technological_Process":
|
||||||
container.Content = new TechnologicalProcessView();
|
container.Content = new TechnologicalProcessView();
|
||||||
|
MainWindowViewModel.ViewID = 1;
|
||||||
break;
|
break;
|
||||||
case "Curve_Diagram":
|
case "Curve_Diagram":
|
||||||
container.Content = new CurveDiagramView();
|
container.Content = new CurveDiagramView();
|
||||||
|
MainWindowViewModel.ViewID = 2;
|
||||||
break;
|
break;
|
||||||
case "Equipment_Simulation":
|
case "Equipment_Simulation":
|
||||||
container.Content = new EquipmentSimulationView();
|
container.Content = new EquipmentSimulationView();
|
||||||
|
MainWindowViewModel.ViewID = 3;
|
||||||
break;
|
break;
|
||||||
case "History_Records":
|
case "History_Records":
|
||||||
container.Content = new HistoryRecordsView();
|
container.Content = new HistoryRecordsView();
|
||||||
|
MainWindowViewModel.ViewID = 4;
|
||||||
break;
|
break;
|
||||||
case "In_Out":
|
case "In_Out":
|
||||||
container.Content = new InOutView();
|
container.Content = new InOutView();
|
||||||
|
MainWindowViewModel.ViewID = 5;
|
||||||
break;
|
break;
|
||||||
case "Sys_Set":
|
case "Sys_Set":
|
||||||
container.Content = new SysSetView();
|
container.Content = new SysSetView();
|
||||||
|
MainWindowViewModel.ViewID = 6;
|
||||||
break;
|
break;
|
||||||
case "Parameter_Set":
|
case "Parameter_Set":
|
||||||
container.Content = new ParameterSetView();
|
container.Content = new ParameterSetView();
|
||||||
|
MainWindowViewModel.ViewID = 7;
|
||||||
break;
|
break;
|
||||||
case "Program_group":
|
case "Program_group":
|
||||||
container.Content = new ProgramgroupView();
|
container.Content = new ProgramgroupView();
|
||||||
|
MainWindowViewModel.ViewID = 8;
|
||||||
break;
|
break;
|
||||||
case "Engineer_Set":
|
case "Engineer_Set":
|
||||||
container.Content = new EngineerSetView();
|
container.Content = new EngineerSetView();
|
||||||
|
MainWindowViewModel.ViewID = 9;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -14,7 +14,7 @@
|
|||||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="Black"
|
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="Black"
|
||||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
|
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="False"
|
||||||
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
CanUserReorderColumns="False" CanUserSortColumns="False" CanUserResizeRows="False" CanUserResizeColumns="False"
|
||||||
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column"
|
CanUserAddRows="True" CanUserDeleteRows="False" HeadersVisibility ="Column" SelectedIndex="{Binding Sys_workSTEPID}"
|
||||||
Background="White" SelectionMode="Single" FontSize="15" MinHeight="632" TabIndex="1" Focusable="True">
|
Background="White" SelectionMode="Single" FontSize="15" MinHeight="632" TabIndex="1" Focusable="True">
|
||||||
<DataGrid.RowStyle >
|
<DataGrid.RowStyle >
|
||||||
<Style TargetType="{x:Type DataGridRow}">
|
<Style TargetType="{x:Type DataGridRow}">
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ namespace DyeingComputer.View
|
|||||||
public TechnologicalProcessView()
|
public TechnologicalProcessView()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
|
DataContext = new MainWindowViewModel();
|
||||||
FocusManager.SetFocusedElement(Grid, Grid);
|
FocusManager.SetFocusedElement(Grid, Grid);
|
||||||
if (workName != null)
|
if (workName != null)
|
||||||
{
|
{
|
||||||
@@ -95,6 +96,7 @@ namespace DyeingComputer.View
|
|||||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||||
{
|
{
|
||||||
// FocusManager.SetFocusedElement(Grid, Grid);
|
// FocusManager.SetFocusedElement(Grid, Grid);
|
||||||
|
// Grid.DataContext = new MainWindowViewModel();
|
||||||
if (workName != null)
|
if (workName != null)
|
||||||
{
|
{
|
||||||
Grid.SelectedIndex = 0;
|
Grid.SelectedIndex = 0;
|
||||||
|
|||||||
@@ -206,6 +206,7 @@ namespace DyeingComputer.View
|
|||||||
MainWindowViewModel.WorkNumder = WorkOrder_Numder;
|
MainWindowViewModel.WorkNumder = WorkOrder_Numder;
|
||||||
TechnologicalProcessView.workName = Process_id;
|
TechnologicalProcessView.workName = Process_id;
|
||||||
|
|
||||||
|
MainWindowViewModel.ViewID = 1;
|
||||||
var _mainWindow = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;//跨页面
|
var _mainWindow = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;//跨页面
|
||||||
_mainWindow.container.Content = new TechnologicalProcessView();//获取控件
|
_mainWindow.container.Content = new TechnologicalProcessView();//获取控件
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ using DyeingComputer.Properties;
|
|||||||
using Microsoft.Win32;
|
using Microsoft.Win32;
|
||||||
using static DyeingComputer.Windows.ViewStep;
|
using static DyeingComputer.Windows.ViewStep;
|
||||||
using System.Windows.Media;
|
using System.Windows.Media;
|
||||||
|
using System.Runtime.Remoting.Channels;
|
||||||
|
|
||||||
|
|
||||||
namespace DyeingComputer.ViewModel
|
namespace DyeingComputer.ViewModel
|
||||||
@@ -36,10 +37,12 @@ namespace DyeingComputer.ViewModel
|
|||||||
public event PropertyChangedEventHandler PropertyChanged;
|
public event PropertyChangedEventHandler PropertyChanged;
|
||||||
protected virtual void OnPropertyChanged(string propertyName)
|
protected virtual void OnPropertyChanged(string propertyName)
|
||||||
{
|
{
|
||||||
if (this.PropertyChanged != null)
|
if (PropertyChanged != null)
|
||||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||||
}
|
}
|
||||||
public void RaisePropertyChanged(string propertyName)
|
public void RaisePropertyChanged(string propertyName)
|
||||||
|
{
|
||||||
|
if (PropertyChanged != null)
|
||||||
{
|
{
|
||||||
if (propertyName != null)
|
if (propertyName != null)
|
||||||
{
|
{
|
||||||
@@ -47,6 +50,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public class MainWindowViewModel : ViewModelBase
|
public class MainWindowViewModel : ViewModelBase
|
||||||
{
|
{
|
||||||
@@ -59,6 +63,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
|
|
||||||
public MainWindowViewModel()
|
public MainWindowViewModel()
|
||||||
{
|
{
|
||||||
|
Sys_workSTEPID = -1;
|
||||||
WorkNumder = "----------";
|
WorkNumder = "----------";
|
||||||
SYS_SET(); //crbl
|
SYS_SET(); //crbl
|
||||||
CountDown(); //启动循环任务
|
CountDown(); //启动循环任务
|
||||||
@@ -132,6 +137,19 @@ namespace DyeingComputer.ViewModel
|
|||||||
get { return sys_Time; }
|
get { return sys_Time; }
|
||||||
set { sys_Time = value; OnPropertyChanged("Sys_Time"); }
|
set { sys_Time = value; OnPropertyChanged("Sys_Time"); }
|
||||||
}
|
}
|
||||||
|
public int sys_workSTEPID; //
|
||||||
|
public int Sys_workSTEPID //通知UI控件参数改变
|
||||||
|
{
|
||||||
|
get { return sys_workSTEPID; }
|
||||||
|
set { sys_workSTEPID = value; OnPropertyChanged("Sys_workSTEPID"); }
|
||||||
|
}
|
||||||
|
public static int ViewID = 0;//页面id
|
||||||
|
|
||||||
|
public static object Name_err = "";
|
||||||
|
public static object WorkNumder;
|
||||||
|
public static object Process_step;
|
||||||
|
public static Int32 DIDETime; //空闲计时器
|
||||||
|
bool ERR_JOG;//故障状态
|
||||||
public void CountDown()
|
public void CountDown()
|
||||||
{
|
{
|
||||||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||||
@@ -156,12 +174,6 @@ namespace DyeingComputer.ViewModel
|
|||||||
disTimer.Tick += new EventHandler(DisTimer_500MS);//每一秒执行的方法
|
disTimer.Tick += new EventHandler(DisTimer_500MS);//每一秒执行的方法
|
||||||
disTimer.Start();//计时开始
|
disTimer.Start();//计时开始
|
||||||
}//时间周期初始化
|
}//时间周期初始化
|
||||||
|
|
||||||
public static object Name_err = "";
|
|
||||||
public static object WorkNumder;
|
|
||||||
public static object Process_step;
|
|
||||||
public static Int32 DIDETime; //空闲计时器
|
|
||||||
bool ERR_JOG;//故障状态
|
|
||||||
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S
|
||||||
{
|
{
|
||||||
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
Sys_Time = DateTime.Now.ToString("yyyy/MM/dd HH:mm:ss");
|
||||||
@@ -789,6 +801,8 @@ namespace DyeingComputer.ViewModel
|
|||||||
double T_P5 = Convert.ToDouble(arrRows[0]["Parameter5"].ToString());
|
double T_P5 = Convert.ToDouble(arrRows[0]["Parameter5"].ToString());
|
||||||
|
|
||||||
STEP_START(T_ID,T_P1,T_P2,T_P3,T_P4,T_P5);
|
STEP_START(T_ID,T_P1,T_P2,T_P3,T_P4,T_P5);
|
||||||
|
|
||||||
|
if (ViewID == 1) { sys_workSTEPID = RUN_STEPID; } else { sys_workSTEPID = -1; }
|
||||||
}
|
}
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(Name_err.ToString()))
|
if (string.IsNullOrEmpty(Name_err.ToString()))
|
||||||
@@ -892,6 +906,15 @@ namespace DyeingComputer.ViewModel
|
|||||||
dt_a = SQLiteHelpers.ExecuteDataSet("select * from IOName where type='AI' OR type='AO'", null).Tables[0];
|
dt_a = SQLiteHelpers.ExecuteDataSet("select * from IOName where type='AI' OR type='AO'", null).Tables[0];
|
||||||
dt_m = SQLiteHelpers.ExecuteDataSet("select * from IOName where type='M'", null).Tables[0];
|
dt_m = SQLiteHelpers.ExecuteDataSet("select * from IOName where type='M'", null).Tables[0];
|
||||||
SQLiteHelpers.Close();
|
SQLiteHelpers.Close();
|
||||||
|
//创建dt_d主建
|
||||||
|
DataColumn[] dt_dcols =new DataColumn[] { dt_d.Columns["ID"] };
|
||||||
|
dt_d.PrimaryKey = dt_dcols;
|
||||||
|
//创建dt_a主建
|
||||||
|
DataColumn[] dt_acols = new DataColumn[] { dt_a.Columns["ID"] };
|
||||||
|
dt_a.PrimaryKey = dt_acols;
|
||||||
|
//创建dt_m主建
|
||||||
|
DataColumn[] dt_mcols = new DataColumn[] { dt_m.Columns["ID"] };
|
||||||
|
dt_m.PrimaryKey = dt_mcols;
|
||||||
}
|
}
|
||||||
|
|
||||||
private async void IO_data()//刷新
|
private async void IO_data()//刷新
|
||||||
@@ -925,10 +948,15 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataRow[] arrRows = dt_m.Select("ID='" + key+"'");
|
lock (dt_m)
|
||||||
double index = Convert.ToDouble(arrRows[0]["Value"].ToString());
|
{
|
||||||
|
// DataRow[] arrRows = dt_m.Select("ID='" + key + "'");
|
||||||
|
// double index = Convert.ToDouble(arrRows[0]["Value"].ToString());
|
||||||
|
DataRow drEmployee = dt_m.Rows.Find(key);
|
||||||
|
double index = drEmployee.Field<double>("value");
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogGing.LogGingDATA(ex.ToString());
|
LogGing.LogGingDATA(ex.ToString());
|
||||||
@@ -939,10 +967,15 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataRow[] arrRows = dt_d.Select("ID='" + key + "'");
|
lock (dt_d)
|
||||||
bool index = Convert.ToBoolean(arrRows[0]["DIO"].ToString());
|
{
|
||||||
|
// DataRow[] arrRows = dt_d.Select("ID='" + key + "'");
|
||||||
|
// bool index = Convert.ToBoolean(arrRows[0]["DIO"].ToString());
|
||||||
|
DataRow drEmployee = dt_d.Rows.Find(key);
|
||||||
|
bool index = drEmployee.Field<bool>("DIO");
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogGing.LogGingDATA(ex.ToString());
|
LogGing.LogGingDATA(ex.ToString());
|
||||||
@@ -953,10 +986,15 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
lock (dt_a)
|
||||||
int index = Convert.ToInt16(arrRows[0]["AIO"].ToString());
|
{
|
||||||
|
// DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
||||||
|
// int index = Convert.ToInt16(arrRows[0]["AIO"].ToString());
|
||||||
|
DataRow drEmployee = dt_a.Rows.Find(key);
|
||||||
|
int index = drEmployee.Field<int>("AIO");
|
||||||
return index;
|
return index;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
LogGing.LogGingDATA(ex.ToString());
|
LogGing.LogGingDATA(ex.ToString());
|
||||||
@@ -969,7 +1007,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
lock (dt_m)
|
lock (dt_m)
|
||||||
{
|
{
|
||||||
DataRow[] arrRows = dt_m.Select("ID='" + key + "'");
|
/* DataRow[] arrRows = dt_m.Select("ID='" + key + "'");
|
||||||
int index = dt_m.Rows.IndexOf(arrRows[0]);
|
int index = dt_m.Rows.IndexOf(arrRows[0]);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
@@ -977,7 +1015,13 @@ namespace DyeingComputer.ViewModel
|
|||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["Value"] = Value;
|
drEmployee["Value"] = Value;
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
}
|
}*/
|
||||||
|
DataRow drEmployee = dt_m.Rows.Find(key);
|
||||||
|
drEmployee.BeginEdit();
|
||||||
|
drEmployee["Value"] = Value;
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
drEmployee.ClearErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -992,7 +1036,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
lock (dt_d)//锁
|
lock (dt_d)//锁
|
||||||
{
|
{
|
||||||
DataRow[] arrRows = dt_d.Select("ID='" + key + "'");
|
/* DataRow[] arrRows = dt_d.Rows.Find(key); //dt_d.Select("ID='" + key + "'");
|
||||||
int index = dt_d.Rows.IndexOf(arrRows[0]);
|
int index = dt_d.Rows.IndexOf(arrRows[0]);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
@@ -1002,7 +1046,13 @@ namespace DyeingComputer.ViewModel
|
|||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
drEmployee.AcceptChanges();
|
drEmployee.AcceptChanges();
|
||||||
drEmployee.ClearErrors();
|
drEmployee.ClearErrors();
|
||||||
}
|
}*/
|
||||||
|
DataRow drEmployee = dt_d.Rows.Find(key);
|
||||||
|
drEmployee.BeginEdit();
|
||||||
|
drEmployee["DIO"] = Value;
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
drEmployee.ClearErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
@@ -1016,7 +1066,7 @@ namespace DyeingComputer.ViewModel
|
|||||||
{
|
{
|
||||||
lock (dt_a)
|
lock (dt_a)
|
||||||
{
|
{
|
||||||
DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
/* DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
||||||
int index = dt_a.Rows.IndexOf(arrRows[0]);
|
int index = dt_a.Rows.IndexOf(arrRows[0]);
|
||||||
if (index != -1)
|
if (index != -1)
|
||||||
{
|
{
|
||||||
@@ -1024,7 +1074,13 @@ namespace DyeingComputer.ViewModel
|
|||||||
drEmployee.BeginEdit();
|
drEmployee.BeginEdit();
|
||||||
drEmployee["AIO"] = Value;
|
drEmployee["AIO"] = Value;
|
||||||
drEmployee.EndEdit();
|
drEmployee.EndEdit();
|
||||||
}
|
}*/
|
||||||
|
DataRow drEmployee = dt_a.Rows.Find(key);
|
||||||
|
drEmployee.BeginEdit();
|
||||||
|
drEmployee["AIO"] = Value;
|
||||||
|
drEmployee.EndEdit();
|
||||||
|
drEmployee.AcceptChanges();
|
||||||
|
drEmployee.ClearErrors();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
|
|||||||
Reference in new issue
Block a user