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

71
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,24 +1132,15 @@ 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_);
if (!exists)
{ {
stringQueueSerial_1.Enqueue(new QueueSerial stringQueueSerial_1.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC827[" + MachinesRow["Station"] + "]"
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_2.Enqueue(new QueueSerial stringQueueSerial_2.Enqueue(new QueueSerial
{ {
@ -1154,11 +1148,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
DAT = "SC827[" + MachinesRow["Station"] + "]" 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_);
if (!exists)
{ {
stringQueueSerial_3.Enqueue(new QueueSerial stringQueueSerial_3.Enqueue(new QueueSerial
{ {
@ -1166,11 +1156,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
DAT = "SC827[" + MachinesRow["Station"] + "]" 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_);
if (!exists)
{ {
stringQueueSerial_4.Enqueue(new QueueSerial stringQueueSerial_4.Enqueue(new QueueSerial
{ {
@ -1181,7 +1167,6 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
} }
} }
} }
}
catch (Exception EX) { LogGing.ERRDATA(EX); } catch (Exception EX) { LogGing.ERRDATA(EX); }
/**染机呼叫完成**/ /**染机呼叫完成**/
try try
@ -1208,57 +1193,39 @@ 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_);
if (!exists)
{ {
stringQueueSerial_1.Enqueue(new QueueSerial stringQueueSerial_1.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT2") else if (MachinesRow["Serial"].ToString() == "PORT2")
{
bool exists = stringQueueSerial_2.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_2.Enqueue(new QueueSerial stringQueueSerial_2.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT3") else if (MachinesRow["Serial"].ToString() == "PORT3")
{
bool exists = stringQueueSerial_3.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_3.Enqueue(new QueueSerial stringQueueSerial_3.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
}
else if (MachinesRow["Serial"].ToString() == "PORT4") else if (MachinesRow["Serial"].ToString() == "PORT4")
{
bool exists = stringQueueSerial_4.Any(item => item.ID == index && item.DAT == dat_);
if (!exists)
{ {
stringQueueSerial_4.Enqueue(new QueueSerial stringQueueSerial_4.Enqueue(new QueueSerial
{ {
ID = index, ID = Convert.ToInt16(MachinesRow["ID"]),
DAT = dat_ DAT = "SC828[" + MachinesRow["Station"] + "]" + Product_.ToJsonString()
}); });
} }
} }
}
if (row["State"].ToString() == "309") if (row["State"].ToString() == "309")
{ {
@ -1392,7 +1359,7 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
{ {
await Task.Run(() => await Task.Run(() =>
{ {
while (MachiensPortClient[0].Online ) while (MachiensPortClient[0].Online)
{ {
try try
{ {
@ -1660,7 +1627,7 @@ 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;
@ -1672,8 +1639,8 @@ namespace SunlightCentralizedControlManagement_SCCM_.ViewModel
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