忱 沈 4 months ago
parent
commit
33b970eff9
  1. 139
      ViewModel/MainWindowViewModel.cs

139
ViewModel/MainWindowViewModel.cs

@ -79,7 +79,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
public static string SN_ID; public static string SN_ID;
public static string SN_KEY; public static string SN_KEY;
public static bool DyelotsDispenser; public static bool DyelotsDispenser;
public static SqlConnection conn_SC =new SqlConnection();//数据库 public static SqlConnection conn_SC = new SqlConnection();//数据库
public static SQLiteHelper SQLiteHelpers = null; //定义数据库 public static SQLiteHelper SQLiteHelpers = null; //定义数据库
private BDC_SQL.BDCSqlHelper bDCSqlHelper = new BDC_SQL.BDCSqlHelper(); private BDC_SQL.BDCSqlHelper bDCSqlHelper = new BDC_SQL.BDCSqlHelper();
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径 private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\SCCM.db"; //数据库路径
@ -258,6 +258,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
dat_.Add("Dye", dataRow["DYELOT"].ToString()); dat_.Add("Dye", dataRow["DYELOT"].ToString());
dat_.Add("Time", dataRow["StepTime"].ToString()); dat_.Add("Time", dataRow["StepTime"].ToString());
dat_.Add("ReDye", dataRow["ReDye"].ToString()); dat_.Add("ReDye", dataRow["ReDye"].ToString());
dat_.Add("Program", dataRow["Program"].ToString());
dat_.Add("Step", dataRow["Step"].ToString()); dat_.Add("Step", dataRow["Step"].ToString());
dat_.Add("StepID", dataRow["StepID"].ToString()); dat_.Add("StepID", dataRow["StepID"].ToString());
dat_.Add("P1", dataRow["Parameter1"].ToString()); dat_.Add("P1", dataRow["Parameter1"].ToString());
@ -400,6 +401,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
dat_.Add("Dye", dt_temp["DYELOT"].ToString()); dat_.Add("Dye", dt_temp["DYELOT"].ToString());
dat_.Add("STime", dt_temp["StartTime"].ToString()); dat_.Add("STime", dt_temp["StartTime"].ToString());
dat_.Add("Time", dt_temp["Time"].ToString()); dat_.Add("Time", dt_temp["Time"].ToString());
dat_.Add("ReDye", 0);
int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString()); int index = Convert.ToInt16(Selet_Machines(Machines, "ID", "Name='" + WorkOrderdata_m + "'").ToString());
string dat = "SC810[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString(); string dat = "SC810[" + Selet_Machines(Machines, "Station", "ID='" + index + "'") + "]" + dat_.ToJsonString();
@ -648,6 +650,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
}); });
} }
} }
Updata_Machines(Machines, "State", "ID='" + MachinesRow["ID"] + "'", "101");
} }
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{ {
@ -786,7 +789,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
} }
} }
if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309")|| (mac_s == "802"))//获取信息 if ((mac_s == "101") || (mac_s == "201") || (mac_s == "202") || (mac_s == "301") || (mac_s == "309"))//获取信息
{ {
if (MachinesRow["Serial"].ToString() == "PORT1") if (MachinesRow["Serial"].ToString() == "PORT1")
{ {
@ -1129,55 +1132,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
else else
{//串口 {//串口
int index = Convert.ToInt16(MachinesRow["ID"]);
string dat_ = "SC827[" + MachinesRow["Station"] + "]";
if (MachinesRow["Serial"].ToString() == "PORT1") if (MachinesRow["Serial"].ToString() == "PORT1")
{ {
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_1.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_1.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC827[" + MachinesRow["Station"] + "]"
ID = index, });
DAT = dat_
});
}
} }
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{ {
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_2.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_2.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC827[" + MachinesRow["Station"] + "]"
ID = Convert.ToInt16(MachinesRow["ID"]), });
DAT = "SC827[" + MachinesRow["Station"] + "]"
});
}
} }
else if (MachinesRow["Serial"].ToString() == "PORT3") else if (MachinesRow["Serial"].ToString() == "PORT3")
{ {
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_3.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_3.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC827[" + MachinesRow["Station"] + "]"
ID = Convert.ToInt16(MachinesRow["ID"]), });
DAT = "SC827[" + MachinesRow["Station"] + "]"
});
}
} }
else if (MachinesRow["Serial"].ToString() == "PORT4") else if (MachinesRow["Serial"].ToString() == "PORT4")
{ {
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_4.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_4.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC827[" + MachinesRow["Station"] + "]"
ID = Convert.ToInt16(MachinesRow["ID"]), });
DAT = "SC827[" + MachinesRow["Station"] + "]"
});
}
} }
} }
} }
@ -1208,55 +1193,37 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
else else
{//串口 {//串口
int index = Convert.ToInt16(MachinesRow["ID"]);
string dat_ = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString();
if (MachinesRow["Serial"].ToString() == "PORT1") if (MachinesRow["Serial"].ToString() == "PORT1")
{ {
bool exists = stringQueueSerial_1.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_1.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_1.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
ID = index, });
DAT = dat_
});
}
} }
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{ {
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_2.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_2.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
ID = index, });
DAT = dat_
});
}
} }
else if (MachinesRow["Serial"].ToString() == "PORT3") else if (MachinesRow["Serial"].ToString() == "PORT3")
{ {
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_3.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_3.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
ID = index, });
DAT = dat_
});
}
} }
else if (MachinesRow["Serial"].ToString() == "PORT4") else if (MachinesRow["Serial"].ToString() == "PORT4")
{ {
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat_); stringQueueSerial_4.Enqueue(new QueueSerial
if (!exists)
{ {
stringQueueSerial_4.Enqueue(new QueueSerial ID = Convert.ToInt16(MachinesRow["ID"]),
{ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
ID = index, });
DAT = dat_
});
}
} }
} }
@ -1349,7 +1316,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
, Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1"))); , Convert.ToInt32(Configini.IniReadvalue("SYS", "BAUD1")));
AsyncSerialPortClient._responseEvent.Set(); AsyncSerialPortClient._responseEvent.Set();
Port1_link(); Port1_link();
} }
if (Machines.Select("Type='false' AND Serial='PORT2'").Length > 0) if (Machines.Select("Type='false' AND Serial='PORT2'").Length > 0)
{ {
@ -1392,7 +1359,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{ {
await Task.Run(() => await Task.Run(() =>
{ {
while (MachiensPortClient[0].Online ) while (MachiensPortClient[0].Online)
{ {
try try
{ {
@ -1609,12 +1576,12 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
set { sys_Time = value; OnPropertyChanged("Sys_Time"); } set { sys_Time = value; OnPropertyChanged("Sys_Time"); }
} }
public static string MachineLOG; public static string MachineLOG;
/* public string sys_machine; //显示log /* public string sys_machine; //显示log
public string Sys_machine //通知UI控件参数改变 public string Sys_machine //通知UI控件参数改变
{ {
get { return sys_machine; } get { return sys_machine; }
set { sys_machine = value; OnPropertyChanged("Sys_machine"); } set { sys_machine = value; OnPropertyChanged("Sys_machine"); }
}*/ }*/
public static object Selet_Machines(DataTable DB, string name, string key)//查询 public static object Selet_Machines(DataTable DB, string name, string key)//查询
{ {
@ -1644,7 +1611,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
drEmployee[name] = Value; drEmployee[name] = Value;
drEmployee.EndEdit(); drEmployee.EndEdit();
drEmployee.AcceptChanges(); drEmployee.AcceptChanges();
// drEmployee.ClearErrors(); // drEmployee.ClearErrors();
} }
} }
catch (Exception ex) catch (Exception ex)
@ -1660,20 +1627,20 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
public static DataTable dt_TP = new DataTable(); public static DataTable dt_TP = new DataTable();
public static DataTable dt_ParameterSet = new DataTable(); public static DataTable dt_ParameterSet = new DataTable();
public static DataTable dt_SysSet = new DataTable(); public static DataTable dt_SysSet = new DataTable();
public static bool TechnologicalProcess_bool =true; public static bool TechnologicalProcess_bool = true;
// public static bool A_view =true; // public static bool A_view =true;
// public static bool D_view =true; // public static bool D_view =true;
public static bool IO_view; public static bool IO_view;
// public static bool ParameterSet_view=true; // public static bool ParameterSet_view=true;
// public static bool SysSet_view=true; // public static bool SysSet_view=true;
public static string machine; public static string machine;
public static string workOrder; public static string workOrder;
public static string dyelot; public static string dyelot;
public static string machin_LOG; public static string machin_LOG;
//通讯队列 //通讯队列
public static UInt32 RX=0; public static UInt32 RX = 0;
public static UInt32 TX=0; public static UInt32 TX = 0;
public class QueueSerial public class QueueSerial
{ {
public int ID { get; set; } public int ID { get; set; }

Loading…
Cancel
Save