diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index 368a002..c9f949c 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -79,30 +79,54 @@ namespace DyeingComputer.ViewModel private int MT39;//中水位 private int MT40;//低水位 private static int MT90;//呼叫操作员 + private int SM01;//副缸 + private int SM02;//副缸 + private int SM03;//副缸 + void SYS_SET() { SQLiteHelpers = new SQLiteHelper(DBAddress); //数据库连接路径 SQLiteHelpers.Open(); //打开数据库 - dt_sys = SQLiteHelpers.ExecuteDataSet("select * from Parameters order by ParameterID desc", null).Tables[0]; //读取表写入缓存 + dt_con = SQLiteHelpers.ExecuteDataSet("select * from Parameters order by ParameterID desc", null).Tables[0]; //读取表写入缓存 + dt_sys = SQLiteHelpers.ExecuteDataSet("select * from System order by ParameterID desc", null).Tables[0]; //读取表写入缓存 SQLiteHelpers.Close(); - pid.Kp = Convert.ToDouble(Selet_sys("MT21")); //读取pid - pid.Ki = Convert.ToDouble(Selet_sys("MT22")); - pid.Kd = Convert.ToDouble(Selet_sys("MT23")); - pid.N = Convert.ToDouble(Selet_sys("MT24")); - pid.OutputUpperLimit = Convert.ToDouble(Selet_sys("MT25")); - pid.OutputLowerLimit = Convert.ToDouble(Selet_sys("MT26")); - - MT05 = Convert.ToInt16(Selet_sys("MT05"));//主缸排水延时 - MT06 = Convert.ToInt16(Selet_sys("MT06"));//动力排水延时 - MT16 = Convert.ToDouble(Selet_sys("MT16"));//流量计数系数 - MT33 = Convert.ToDouble(Selet_sys("MT33"));//温度偏差参数 - MT38 = Convert.ToInt16(Selet_sys("MT38"));// - MT39 = Convert.ToInt16(Selet_sys("MT39"));// - MT40 = Convert.ToInt16(Selet_sys("MT40"));// - MT90 = Convert.ToInt16(Selet_sys("MT90"));//呼叫操作员 - + pid.Kp = Convert.ToDouble(Selet_con("MT21")); //读取pid + pid.Ki = Convert.ToDouble(Selet_con("MT22")); + pid.Kd = Convert.ToDouble(Selet_con("MT23")); + pid.N = Convert.ToDouble(Selet_con("MT24")); + pid.OutputUpperLimit = Convert.ToDouble(Selet_con("MT25")); + pid.OutputLowerLimit = Convert.ToDouble(Selet_con("MT26")); + + MT05 = Convert.ToInt16(Selet_con("MT05"));//主缸排水延时 + MT06 = Convert.ToInt16(Selet_con("MT06"));//动力排水延时 + MT16 = Convert.ToDouble(Selet_con("MT16"));//流量计数系数 + MT33 = Convert.ToDouble(Selet_con("MT33"));//温度偏差参数 + MT38 = Convert.ToInt16(Selet_con("MT38"));// + MT39 = Convert.ToInt16(Selet_con("MT39"));// + MT40 = Convert.ToInt16(Selet_con("MT40"));// + MT90 = Convert.ToInt16(Selet_con("MT90"));//呼叫操作员 + + SM01 = Convert.ToInt16(Selet_sys("SM01"));//FG + SM02 = Convert.ToInt16(Selet_sys("SM02"));//FG + SM03 = Convert.ToInt16(Selet_sys("SM03"));//FG + } + DataTable dt_con = new DataTable(); + public string Selet_con(string key)//配置缓存 + { + try + { + DataRow[] arrRows = dt_con.Select("ParameterID ='" + key + "'"); + string index = arrRows[0]["Value"].ToString(); + return index; + } + catch (Exception ex) + { + LogGing.LogGingDATA(ex.ToString()); + return "0"; + } } + DataTable dt_sys = new DataTable(); public string Selet_sys(string key)//配置缓存 { @@ -118,7 +142,6 @@ namespace DyeingComputer.ViewModel return "0"; } } - public string work_Temp; //显示温度 public string Work_Temp //通知UI控件参数改变 { @@ -938,7 +961,10 @@ namespace DyeingComputer.ViewModel } Sys_log = Sys_log + "\n-------------------------------------------------------"; Sys_log = Sys_log + "\n" + Resources.ClothWheel; - + Sys_log = Sys_log + "\n-------------------------------------------------------"; + if (SM01 == 1) Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "1 => [" + Resources.WaterLevel + ":" + Convert.ToInt16(Selet_dtm("1017")) + "L][" + Resources.Temperature + ":" + Convert.ToInt16(Selet_dtm("1012")) + "°C]"; + if (SM02 == 1) Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "2 => [" + Resources.WaterLevel + ":" + Convert.ToInt16(Selet_dtm("1018")) + "L][" + Resources.Temperature + ":" + Convert.ToInt16(Selet_dtm("1013")) + "°C]"; + if (SM03 == 1) Sys_log = Sys_log + "\n" + Resources.Medicine + Resources.Tank + "3 => [" + Resources.WaterLevel + ":" + Convert.ToInt16(Selet_dtm("1019")) + "L][" + Resources.Temperature + ":" + Convert.ToInt16(Selet_dtm("1014")) + "°C]"; } public static DataTable dt_d = new DataTable("DIO");