修改io表查改逻辑,降低i资源开销60=>10
This commit is contained in:
commit
2db3bfd186
5 files changed
+121
-52
No files matched your search
@@ -124,33 +124,43 @@ namespace DyeingComputer
|
||||
{
|
||||
case "Work_Order":
|
||||
container.Content = new WorkOrderView();
|
||||
MainWindowViewModel.ViewID = 0;
|
||||
break;
|
||||
case "Technological_Process":
|
||||
container.Content = new TechnologicalProcessView();
|
||||
MainWindowViewModel.ViewID = 1;
|
||||
break;
|
||||
case "Curve_Diagram":
|
||||
container.Content = new CurveDiagramView();
|
||||
MainWindowViewModel.ViewID = 2;
|
||||
break;
|
||||
case "Equipment_Simulation":
|
||||
container.Content = new EquipmentSimulationView();
|
||||
MainWindowViewModel.ViewID = 3;
|
||||
break;
|
||||
case "History_Records":
|
||||
container.Content = new HistoryRecordsView();
|
||||
MainWindowViewModel.ViewID = 4;
|
||||
break;
|
||||
case "In_Out":
|
||||
container.Content = new InOutView();
|
||||
MainWindowViewModel.ViewID = 5;
|
||||
break;
|
||||
case "Sys_Set":
|
||||
container.Content = new SysSetView();
|
||||
MainWindowViewModel.ViewID = 6;
|
||||
break;
|
||||
case "Parameter_Set":
|
||||
container.Content = new ParameterSetView();
|
||||
MainWindowViewModel.ViewID = 7;
|
||||
break;
|
||||
case "Program_group":
|
||||
container.Content = new ProgramgroupView();
|
||||
MainWindowViewModel.ViewID = 8;
|
||||
break;
|
||||
case "Engineer_Set":
|
||||
container.Content = new EngineerSetView();
|
||||
MainWindowViewModel.ViewID = 9;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
HorizontalGridLinesBrush="#FFC9C9C9" VerticalGridLinesBrush="#FFC9C9C9" GridLinesVisibility="All" BorderBrush="Black"
|
||||
BorderThickness="1,1,1,1" ColumnHeaderHeight="40" HorizontalContentAlignment="Right" Grid.ColumnSpan="2" AllowDrop="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">
|
||||
<DataGrid.RowStyle >
|
||||
<Style TargetType="{x:Type DataGridRow}">
|
||||
|
||||
@@ -28,8 +28,9 @@ namespace DyeingComputer.View
|
||||
public partial class TechnologicalProcessView : UserControl
|
||||
{
|
||||
public TechnologicalProcessView()
|
||||
{
|
||||
{
|
||||
InitializeComponent();
|
||||
DataContext = new MainWindowViewModel();
|
||||
FocusManager.SetFocusedElement(Grid, Grid);
|
||||
if (workName != null)
|
||||
{
|
||||
@@ -38,7 +39,7 @@ namespace DyeingComputer.View
|
||||
else
|
||||
{
|
||||
TechnologicalProcess_sql();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static object workName;
|
||||
@@ -94,7 +95,8 @@ namespace DyeingComputer.View
|
||||
|
||||
private void UserControl_Loaded(object sender, RoutedEventArgs e)
|
||||
{
|
||||
// FocusManager.SetFocusedElement(Grid, Grid);
|
||||
// FocusManager.SetFocusedElement(Grid, Grid);
|
||||
// Grid.DataContext = new MainWindowViewModel();
|
||||
if (workName != null)
|
||||
{
|
||||
Grid.SelectedIndex = 0;
|
||||
|
||||
@@ -206,6 +206,7 @@ namespace DyeingComputer.View
|
||||
MainWindowViewModel.WorkNumder = WorkOrder_Numder;
|
||||
TechnologicalProcessView.workName = Process_id;
|
||||
|
||||
MainWindowViewModel.ViewID = 1;
|
||||
var _mainWindow = Application.Current.Windows.Cast<Window>().FirstOrDefault(window => window is MainWindow) as MainWindow;//跨页面
|
||||
_mainWindow.container.Content = new TechnologicalProcessView();//获取控件
|
||||
}
|
||||
|
||||
@@ -24,6 +24,7 @@ using DyeingComputer.Properties;
|
||||
using Microsoft.Win32;
|
||||
using static DyeingComputer.Windows.ViewStep;
|
||||
using System.Windows.Media;
|
||||
using System.Runtime.Remoting.Channels;
|
||||
|
||||
|
||||
namespace DyeingComputer.ViewModel
|
||||
@@ -36,14 +37,17 @@ namespace DyeingComputer.ViewModel
|
||||
public event PropertyChangedEventHandler PropertyChanged;
|
||||
protected virtual void OnPropertyChanged(string propertyName)
|
||||
{
|
||||
if (this.PropertyChanged != null)
|
||||
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
if (PropertyChanged != null)
|
||||
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
public void RaisePropertyChanged(string propertyName)
|
||||
{
|
||||
if (propertyName != null)
|
||||
if (PropertyChanged != null)
|
||||
{
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
if (propertyName != null)
|
||||
{
|
||||
PropertyChanged.Invoke(this, new PropertyChangedEventArgs(propertyName));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -59,6 +63,7 @@ namespace DyeingComputer.ViewModel
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
Sys_workSTEPID = -1;
|
||||
WorkNumder = "----------";
|
||||
SYS_SET(); //crbl
|
||||
CountDown(); //启动循环任务
|
||||
@@ -132,6 +137,19 @@ namespace DyeingComputer.ViewModel
|
||||
get { return 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()
|
||||
{
|
||||
DispatcherTimer timer1s = new DispatcherTimer//初始化循环,每1秒调用一次Tick
|
||||
@@ -156,12 +174,6 @@ namespace DyeingComputer.ViewModel
|
||||
disTimer.Tick += new EventHandler(DisTimer_500MS);//每一秒执行的方法
|
||||
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
|
||||
{
|
||||
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());
|
||||
|
||||
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()))
|
||||
@@ -892,6 +906,15 @@ namespace DyeingComputer.ViewModel
|
||||
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];
|
||||
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()//刷新
|
||||
@@ -925,9 +948,14 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow[] arrRows = dt_m.Select("ID='" + key+"'");
|
||||
double index = Convert.ToDouble(arrRows[0]["Value"].ToString());
|
||||
return index;
|
||||
lock (dt_m)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -939,9 +967,14 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow[] arrRows = dt_d.Select("ID='" + key + "'");
|
||||
bool index = Convert.ToBoolean(arrRows[0]["DIO"].ToString());
|
||||
return index;
|
||||
lock (dt_d)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -953,9 +986,14 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
try
|
||||
{
|
||||
DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
||||
int index = Convert.ToInt16(arrRows[0]["AIO"].ToString());
|
||||
return index;
|
||||
lock (dt_a)
|
||||
{
|
||||
// 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;
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
@@ -969,15 +1007,21 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
lock (dt_m)
|
||||
{
|
||||
DataRow[] arrRows = dt_m.Select("ID='" + key + "'");
|
||||
int index = dt_m.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_m.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["Value"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
}
|
||||
/* DataRow[] arrRows = dt_m.Select("ID='" + key + "'");
|
||||
int index = dt_m.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_m.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["Value"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
}*/
|
||||
DataRow drEmployee = dt_m.Rows.Find(key);
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["Value"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -992,17 +1036,23 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
lock (dt_d)//锁
|
||||
{
|
||||
DataRow[] arrRows = dt_d.Select("ID='" + key + "'");
|
||||
int index = dt_d.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_d.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["DIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
}
|
||||
/* DataRow[] arrRows = dt_d.Rows.Find(key); //dt_d.Select("ID='" + key + "'");
|
||||
int index = dt_d.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_d.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["DIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
}*/
|
||||
DataRow drEmployee = dt_d.Rows.Find(key);
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["DIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
@@ -1016,15 +1066,21 @@ namespace DyeingComputer.ViewModel
|
||||
{
|
||||
lock (dt_a)
|
||||
{
|
||||
DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
||||
int index = dt_a.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_a.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["AIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
}
|
||||
/* DataRow[] arrRows = dt_a.Select("ID='" + key + "'");
|
||||
int index = dt_a.Rows.IndexOf(arrRows[0]);
|
||||
if (index != -1)
|
||||
{
|
||||
DataRow drEmployee = dt_a.Rows[index];
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["AIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
}*/
|
||||
DataRow drEmployee = dt_a.Rows.Find(key);
|
||||
drEmployee.BeginEdit();
|
||||
drEmployee["AIO"] = Value;
|
||||
drEmployee.EndEdit();
|
||||
drEmployee.AcceptChanges();
|
||||
drEmployee.ClearErrors();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
||||
Reference in new issue
Block a user