|
@ -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,14 +37,17 @@ 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 (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() |
|
|
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,9 +948,14 @@ namespace DyeingComputer.ViewModel |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
DataRow[] arrRows = dt_m.Select("ID='" + key+"'"); |
|
|
lock (dt_m) |
|
|
double index = Convert.ToDouble(arrRows[0]["Value"].ToString()); |
|
|
{ |
|
|
return index; |
|
|
// 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) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
@ -939,9 +967,14 @@ namespace DyeingComputer.ViewModel |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
DataRow[] arrRows = dt_d.Select("ID='" + key + "'"); |
|
|
lock (dt_d) |
|
|
bool index = Convert.ToBoolean(arrRows[0]["DIO"].ToString()); |
|
|
{ |
|
|
return index; |
|
|
// 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) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
@ -953,9 +986,14 @@ namespace DyeingComputer.ViewModel |
|
|
{ |
|
|
{ |
|
|
try |
|
|
try |
|
|
{ |
|
|
{ |
|
|
DataRow[] arrRows = dt_a.Select("ID='" + key + "'"); |
|
|
lock (dt_a) |
|
|
int index = Convert.ToInt16(arrRows[0]["AIO"].ToString()); |
|
|
{ |
|
|
return index; |
|
|
// 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) |
|
|
catch (Exception ex) |
|
|
{ |
|
|
{ |
|
@ -969,15 +1007,21 @@ 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) |
|
|
{ |
|
|
{ |
|
|
DataRow drEmployee = dt_m.Rows[index]; |
|
|
DataRow drEmployee = dt_m.Rows[index]; |
|
|
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,17 +1036,23 @@ 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) |
|
|
{ |
|
|
{ |
|
|
DataRow drEmployee = dt_d.Rows[index]; |
|
|
DataRow drEmployee = dt_d.Rows[index]; |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee.BeginEdit(); |
|
|
drEmployee["DIO"] = Value; |
|
|
drEmployee["DIO"] = Value; |
|
|
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,15 +1066,21 @@ 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) |
|
|
{ |
|
|
{ |
|
|
DataRow drEmployee = dt_a.Rows[index]; |
|
|
DataRow drEmployee = dt_a.Rows[index]; |
|
|
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) |
|
|