diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index 363ab41..7c3b2a2 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -208,7 +208,7 @@ 計量 - 轉入 + 未執行 diff --git a/UserClass/AsyncTcpServer.cs b/UserClass/AsyncTcpServer.cs index 2022337..0f245c7 100644 --- a/UserClass/AsyncTcpServer.cs +++ b/UserClass/AsyncTcpServer.cs @@ -426,30 +426,30 @@ namespace DyeingComputer.UserClass { try { - DataTable Dyelot_dat; - Dyelot_dat = SerializeConvert.JsonDeserializeFromString(SYSDAT); + Dictionary Dyelot_dat; + Dyelot_dat = SerializeConvert.JsonDeserializeFromString>(SYSDAT); SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径 SQLiteHelpers.Open(); //打开数据库 Dictionary Product_data = new Dictionary();//缓存函数 - for (int i=0;i<=Dyelot_dat.Rows.Count;i++) + + Product_data.Add("State", Dyelot_dat.GetValue("State")); + if (Dyelot_dat.GetValue("State").ToString() == "301") { - DataRow drEmployee = Dyelot_dat.Rows[i]; - Product_data.Add("State", drEmployee.Field("State")); - Product_data.Add("Amount", drEmployee.Field("Amount")); - Product_data.Add("DispenseEndTime", drEmployee.Field("DispenseEndTime")); - - SQLiteHelpers.Update("Dyelot", Product_data, "Dyelot ='" + drEmployee.Field("Dyelot") - + "' AND Step ='"+ drEmployee.Field("Step") + "' AND ProductCode='"+ - drEmployee.Field("ProductCode") + "'", null); - Product_data.Clear(); - MainWindowViewModel.Dyelot_dat = SQLiteHelpers.ExecuteDataSet( - "select * from Dyelot where WorkOrder = '" + - MainWindowViewModel.WorkNumder + "'", null).Tables[0]; - int dt = SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Dyelot='" + - drEmployee.Field("Dyelot") + "' AND State ='201'", null).Tables[0].Rows.Count; - if (dt == 0) MainWindowViewModel.CALL_FR = false; - } + Product_data.Add("Amount", Dyelot_dat.GetValue("Amount")); + Product_data.Add("DispenseEndTime", Dyelot_dat.GetValue("DispenseEndTime")); + } + SQLiteHelpers.Update("Dyelot", Product_data, "Dyelot ='" + Dyelot_dat.GetValue("Dyelot") + + "' AND Step ='" + Dyelot_dat.GetValue("Step") + "' AND ProductCode='" + + Dyelot_dat.GetValue("ProductCode") + "'", null); + Product_data.Clear(); + MainWindowViewModel.Dyelot_dat = SQLiteHelpers.ExecuteDataSet( + "select * from Dyelot where WorkOrder = '" + + MainWindowViewModel.WorkNumder + "'", null).Tables[0]; + int dt = SQLiteHelpers.ExecuteDataSet("select * from Dyelot where Dyelot='" + + Dyelot_dat.GetValue("Dyelot") + "' AND State ='201'", null).Tables[0].Rows.Count; + if (dt == 0) MainWindowViewModel.CALL_FR = false; + SQLiteHelpers.Close(); //关闭连接 client.SendAsync("SC828" + SYSKEY + SYSDAT); diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index b52140f..e7a2751 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -565,6 +565,7 @@ namespace DyeingComputer.ViewModel if (TX_t != TX) { _Link_bool = true; TX_t = TX; } else { _Link_bool = false; TX_t = TX; } //中央连接状态判断 if(WORK_RUN !=0) Chart();//写入记录 if(!UserButton) TechnologicalProcess_view();//刷新步骤页面 + FeedingRecords_inf(); if ((Selet_dtm("1025") > 0) && (Selet_dtd("3021") || Selet_dtd("3022"))) { @@ -1746,7 +1747,6 @@ namespace DyeingComputer.ViewModel TANK1 = "High Water Level"; return; } - TANK1 = Resources.CallDistribution; TANK1_REDYE = SYS_REDYE; if(string.IsNullOrEmpty(TANK1_DYELOT)) TANK1_DYELOT = WorkNumder.ToString(); TANK1_STEP =Convert.ToInt16(STEP_P3); @@ -1761,7 +1761,6 @@ namespace DyeingComputer.ViewModel TANK2 = "High Water Level"; return; } - TANK2 = Resources.CallDistribution; TANK2_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK2_DYELOT)) TANK2_DYELOT = WorkNumder.ToString(); TANK2_STEP = Convert.ToInt16(STEP_P3); @@ -1776,7 +1775,6 @@ namespace DyeingComputer.ViewModel TANK3 = "High Water Level"; return; } - TANK3 = Resources.CallDistribution; TANK3_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK3_DYELOT)) TANK3_DYELOT = WorkNumder.ToString(); TANK3_STEP = Convert.ToInt16(STEP_P3); @@ -2237,7 +2235,6 @@ namespace DyeingComputer.ViewModel TANK1 = "High Water Level"; return; } - TANK1 = Resources.CallDistribution; TANK1_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK1_DYELOT)) TANK1_DYELOT = WorkNumder.ToString(); TANK1_STEP = Convert.ToInt16(STEP_P3p1); @@ -2251,7 +2248,6 @@ namespace DyeingComputer.ViewModel TANK2 = "High Water Level"; return; } - TANK2 = Resources.CallDistribution; TANK2_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK2_DYELOT)) TANK2_DYELOT = WorkNumder.ToString(); TANK2_STEP = Convert.ToInt16(STEP_P3p1); @@ -2265,7 +2261,6 @@ namespace DyeingComputer.ViewModel TANK3 = "High Water Level"; return; } - TANK3 = Resources.CallDistribution; TANK3_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK3_DYELOT)) TANK3_DYELOT = WorkNumder.ToString(); TANK3_STEP = Convert.ToInt16(STEP_P3p1); @@ -2496,7 +2491,6 @@ namespace DyeingComputer.ViewModel TANK1 = "High Water Level"; return; } - TANK1 = Resources.CallDistribution; TANK1_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK1_DYELOT)) TANK1_DYELOT = WorkNumder.ToString(); TANK1_STEP = Convert.ToInt16(STEP_P3p2); @@ -2510,7 +2504,6 @@ namespace DyeingComputer.ViewModel TANK2 = "High Water Level"; return; } - TANK2 = Resources.CallDistribution; TANK2_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK2_DYELOT)) TANK2_DYELOT = WorkNumder.ToString(); TANK2_STEP = Convert.ToInt16(STEP_P3p2); @@ -2524,7 +2517,6 @@ namespace DyeingComputer.ViewModel TANK3 = "High Water Level"; return; } - TANK3 = Resources.CallDistribution; TANK3_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK3_DYELOT)) TANK3_DYELOT = WorkNumder.ToString(); TANK3_STEP = Convert.ToInt16(STEP_P3p2); @@ -2755,7 +2747,6 @@ namespace DyeingComputer.ViewModel TANK1 = "High Water Level"; return; } - TANK1 = Resources.CallDistribution; TANK1_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK1_DYELOT)) TANK1_DYELOT = WorkNumder.ToString(); TANK1_STEP = Convert.ToInt16(STEP_P3p3); @@ -2769,7 +2760,6 @@ namespace DyeingComputer.ViewModel TANK2 = "High Water Level"; return; } - TANK2 = Resources.CallDistribution; TANK2_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK2_DYELOT)) TANK2_DYELOT = WorkNumder.ToString(); TANK2_STEP = Convert.ToInt16(STEP_P3p3); @@ -2783,7 +2773,6 @@ namespace DyeingComputer.ViewModel TANK3 = "High Water Level"; return; } - TANK3 = Resources.CallDistribution; TANK3_REDYE = SYS_REDYE; if (string.IsNullOrEmpty(TANK3_DYELOT)) TANK3_DYELOT = WorkNumder.ToString(); TANK3_STEP = Convert.ToInt16(STEP_P3p3); @@ -2875,6 +2864,36 @@ namespace DyeingComputer.ViewModel STEP + "' AND Redye ='" + SYS_REDYE + "'", null);//行更新 SQLiteHelpers.Close(); //关闭连接 } + void FeedingRecords_inf() + { + for (int i = 0; Dyelot_dat.Rows.Count > i; i++) + { + if (Dyelot_dat.Rows[i]["State"].ToString() == "201") + { + if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "1")&&(Dyelot_dat.Rows[i]["Step"].ToString() == TANK1_STEP.ToString())) TANK1 = Resources.CallDistribution; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "2") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK2_STEP.ToString())) TANK2 = Resources.CallDistribution; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "3") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK3_STEP.ToString())) TANK3 = Resources.CallDistribution; + } + else if (Dyelot_dat.Rows[i]["State"].ToString() == "202") + { + if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "1") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK1_STEP.ToString())) TANK1 = Resources.LineUp; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "2") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK2_STEP.ToString())) TANK2 = Resources.LineUp; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "3") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK3_STEP.ToString())) TANK3 = Resources.LineUp; + } + else if (Dyelot_dat.Rows[i]["State"].ToString() == "301") + { + if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "1") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK1_STEP.ToString())) TANK1 = Resources.Finish; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "2") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK2_STEP.ToString())) TANK2 = Resources.Finish; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "3") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK3_STEP.ToString())) TANK3 = Resources.Finish; + } + else if (Dyelot_dat.Rows[i]["State"].ToString() == "309") + { + if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "1") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK1_STEP.ToString())) TANK1 = Resources.Abnormal; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "2") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK2_STEP.ToString())) TANK2 = Resources.Abnormal; + else if ((Dyelot_dat.Rows[i]["Tank"].ToString() == "3") && (Dyelot_dat.Rows[i]["Step"].ToString() == TANK3_STEP.ToString())) TANK3 = Resources.Abnormal; + } + } + } public static SerialPort port = new SerialPort();//创建串口 static ModbusFactory factory = new ModbusFactory();