diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 1bf14c2..c5a8d0a 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -186,6 +186,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 Compute 的本地化字符串。 + /// + public static string Compute { + get { + return ResourceManager.GetString("Compute", resourceCulture); + } + } + /// /// 查找类似 Confirm 的本地化字符串。 /// @@ -402,6 +411,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 High-water level 的本地化字符串。 + /// + public static string High_waterlevel { + get { + return ResourceManager.GetString("High-waterlevel", resourceCulture); + } + } + /// /// 查找类似 History 的本地化字符串。 /// @@ -474,6 +492,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 Low-water level 的本地化字符串。 + /// + public static string Low_waterlevel { + get { + return ResourceManager.GetString("Low-waterlevel", resourceCulture); + } + } + /// /// 查找类似 Malfunction 的本地化字符串。 /// @@ -483,6 +510,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 MasterCylinder 的本地化字符串。 + /// + public static string MasterCylinder { + get { + return ResourceManager.GetString("MasterCylinder", resourceCulture); + } + } + /// /// 查找类似 Measure 的本地化字符串。 /// @@ -501,6 +537,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 Mid-waterlevel 的本地化字符串。 + /// + public static string Mid_waterlevel { + get { + return ResourceManager.GetString("Mid-waterlevel", resourceCulture); + } + } + /// /// 查找类似 Min 的本地化字符串。 /// @@ -708,6 +753,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 ProportionalValves 的本地化字符串。 + /// + public static string ProportionalValves { + get { + return ResourceManager.GetString("ProportionalValves", resourceCulture); + } + } + /// /// 查找类似 Pump 的本地化字符串。 /// diff --git a/Properties/Resources.en-US.resx b/Properties/Resources.en-US.resx index 59f57a4..24f2eb0 100644 --- a/Properties/Resources.en-US.resx +++ b/Properties/Resources.en-US.resx @@ -423,16 +423,12 @@ Min - - - + + Expected Heat insulating - - Expected - Malfunction @@ -445,4 +441,22 @@ End the current process + + Compute + + + Master Cylinder + + + Proportional Valves + + + Mid-water level + + + High-water level + + + Low-water level + \ No newline at end of file diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 5625e01..24a3672 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -441,4 +441,22 @@ StopProcess + + Compute + + + MasterCylinder + + + ProportionalValves + + + Mid-waterlevel + + + High-water level + + + Low-water level + \ No newline at end of file diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index ee0f2d4..dc7435c 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -423,26 +423,40 @@ 分钟 - - - + + 预计 保温 - - 传感器 - - - 预计 - 故障 + + 传感器 + 异常恢复 结束当前工艺 + + 计算 + + + 主缸 + + + 比例控制 + + + 中水位 + + + 高水位 + + + 低水位 + \ No newline at end of file diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index cebfb9f..dde1e19 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -117,50 +117,26 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - - 返回 - - - 系統 - - - 製程流程 - - - 參數 - - - 程序組 - - - 更多 - - - 輸入輸出 + + 製程曲線 - - 歷史 + + 刪除 - - 設備模擬 + + 結束時間 工程師 - - 製程曲線 - - - 工作清單 - - - 系統資料遺失 + + 設備模擬 - - 工單號碼 + + 歷史 - - 溫度 + + 輸入輸出 鎖定 @@ -168,27 +144,51 @@ 新建 - - 刪除 + + 更多 - - 重染 + + 參數 - - 結束時間 + + 返回 工藝名 + + 程序組 + + + 重染 + 備註 開始時間 + + 系統資料遺失 + + + 系統 + + + 製程流程 + + + 溫度 + 時間 + + 工作清單 + + + 工單號碼 + 準備 @@ -204,20 +204,20 @@ 完成 - - 轉入 - 計量 - - 狀態 + + 轉入 + + + 未執行 確認 - - 步驟 + + 狀態 編輯 @@ -225,47 +225,56 @@ 重新命名 - - ID - - - 指令 + + 步驟 代碼 - - 恢復 + + 指令 + + + ID 插入 + + 恢復 + 儲存 退出 - - 溫度控制 - 入水 + + 冷卻 + + + 排水 + 流量 - - 水位 + + 溫度控制 洗滌 - - 冷卻 + + 水位 - - 排水 + + 準備入布 + + + 準備出布 泵排水 @@ -273,12 +282,6 @@ 運轉 - - 準備入布 - - - 準備出布 - 加藥 @@ -300,6 +303,9 @@ PH控制 + + PH檢測 + PH溫度控制 @@ -324,84 +330,78 @@ 取樣 - - PH檢測 + + 機能 無效的圖徵 - - 機能 - - - 速率 + + 提前 - - 目標 + + 開始 + + + 容器 + + + 曲線 來源 + + + + + 攪拌 + 次數 壓力 - - 容器 - - - + + 速率 + + 目標 + 類別 - - 開始 - - - 提前 - - - 曲線 - - - 攪拌 - 風機 - - - 噴頭 - - 擺佈 - 溢流 - - 流程不存在 + + - - 未執行 + + 擺佈 執行 + + 流程不存在 + 網路斷開 @@ -423,12 +423,12 @@ 分鐘 - - 保溫 - 預計 + + 保溫 + 故障 @@ -439,6 +439,12 @@ 異常恢復 - 結束當前製程! + 結束當前製程 + + + 計算 + + + 主缸 \ No newline at end of file diff --git a/View/TechnologicalProcessView.xaml b/View/TechnologicalProcessView.xaml index 37ce4a9..440f944 100644 --- a/View/TechnologicalProcessView.xaml +++ b/View/TechnologicalProcessView.xaml @@ -4,14 +4,16 @@ xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:local="clr-namespace:DyeingComputer.View" - xmlns:lang="clr-namespace:DyeingComputer.Properties" + xmlns:lang="clr-namespace:DyeingComputer.Properties" + xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel" + d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}" mc:Ignorable="d" Loaded="UserControl_Loaded" KeyDown="UserControl_KeyDown" d:DesignHeight="630" d:DesignWidth="1280"> - + diff --git a/View/TechnologicalProcessView.xaml.cs b/View/TechnologicalProcessView.xaml.cs index 3274713..fd3cff9 100644 --- a/View/TechnologicalProcessView.xaml.cs +++ b/View/TechnologicalProcessView.xaml.cs @@ -1,6 +1,7 @@ using DyeingComputer.UserClass; using DyeingComputer.ViewModel; using DyeingComputer.Windows; +using ScottPlot; using System; using System.Collections.Generic; using System.Data; @@ -28,7 +29,7 @@ namespace DyeingComputer.View public partial class TechnologicalProcessView : UserControl { public TechnologicalProcessView() - { + { InitializeComponent(); DataContext = new MainWindowViewModel(); FocusManager.SetFocusedElement(Grid, Grid); @@ -39,7 +40,7 @@ namespace DyeingComputer.View else { TechnologicalProcess_sql(); - } + } } public static object workName; diff --git a/ViewModel/MainWindowViewModel.cs b/ViewModel/MainWindowViewModel.cs index a31534f..7dc6175 100644 --- a/ViewModel/MainWindowViewModel.cs +++ b/ViewModel/MainWindowViewModel.cs @@ -75,6 +75,9 @@ namespace DyeingComputer.ViewModel private static int MT06;//主缸排水延时 private static double MT16;//流量计数系数 private static double MT33;//主缸温度偏差 + private int MT38;//高水位 + private int MT39;//中水位 + private int MT40;//低水位 private static int MT90;//呼叫操作员 void SYS_SET() { @@ -94,6 +97,9 @@ namespace DyeingComputer.ViewModel 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"));//呼叫操作员 } @@ -102,7 +108,7 @@ namespace DyeingComputer.ViewModel { try { - DataRow[] arrRows = dt_sys.Select("ParameterID ='" + key+"'"); + DataRow[] arrRows = dt_sys.Select("ParameterID ='" + key + "'"); string index = arrRows[0]["Value"].ToString(); return index; } @@ -143,6 +149,12 @@ namespace DyeingComputer.ViewModel get { return sys_workSTEPID; } set { sys_workSTEPID = value; OnPropertyChanged("Sys_workSTEPID"); } } + public string sys_log; // + public string Sys_log //通知UI控件参数改变 + { + get { return sys_log; } + set { sys_log = value; OnPropertyChanged("Sys_log"); } + } public static int ViewID = 0;//页面id public static object Name_err = ""; @@ -171,8 +183,8 @@ namespace DyeingComputer.ViewModel { Interval = TimeSpan.FromMilliseconds(500) //毫秒 }; - disTimer.Tick += new EventHandler(DisTimer_500MS);//每一秒执行的方法 - disTimer.Start();//计时开始 + disTimer.Tick += new EventHandler(DisTimer_500MS);//每一秒执行的方法 + disTimer.Start();//计时开始 }//时间周期初始化 void Tick_Event_1S(object sender, EventArgs e)//Tick_Event周期执行事件1S { @@ -180,11 +192,12 @@ namespace DyeingComputer.ViewModel Work_Temp = Selet_dtm("1010") + " ℃"; Work_Numder = WorkNumder.ToString(); - // if (LINK_OK) Modbus_link(); - if(!SETP_runtime) DIDETime++; + // if (LINK_OK) Modbus_link(); + if (!SETP_runtime) DIDETime++; STEP_RUN(); - IO_view(); + IO_view(); + LOG_view(); if (!string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Name_err.ToString(); } @@ -200,14 +213,14 @@ namespace DyeingComputer.ViewModel Modbus_link(); IO_data(); if (!string.IsNullOrEmpty(Name_err.ToString()) && (!ERR_JOG)) //有故障信息,无故障保持 - { + { ERR_JOG = true; LogGing.LogGingDATA(Name_err.ToString());//输出故障信息 } if (string.IsNullOrEmpty(Name_err.ToString()) && (ERR_JOG)) //无故障信息,有故障保持 { ERR_JOG = false; - LogGing.LogGingDATA(Name_err.ToString()+ "=>"+Resources.FailureRecovery);//解除故障信息 + LogGing.LogGingDATA(Name_err.ToString() + "=>" + Resources.FailureRecovery);//解除故障信息 } } @@ -223,10 +236,12 @@ namespace DyeingComputer.ViewModel private static int STEP_TIME = 0; //步骤计时S private static int THL_mode = 0; //温控模式 0保温 1加热 2降 private static double TEMP_co = 0; //计算温度 + private static double TEMP_tar = 16.5; //目标温度 + private bool Pump_M = false;//主泵状态 private bool Alert_yellow = false; //警报黄灯 private bool Alert_red = false; //警报红灯 private bool Alert_bell = false; //警报铃声 - public static void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5) //启动模块 + public static void STEP_START(string ID, double P1, double P2, double P3, double P4, double P5) //启动模块 { STEP_ID = ID; switch (ID) @@ -235,6 +250,7 @@ namespace DyeingComputer.ViewModel STEP_P1 = Convert.ToDouble(P1); STEP_P2 = Convert.ToDouble(P2); STEP_P3 = Convert.ToDouble(P3); + TEMP_tar = STEP_P1; double t_t = Convert.ToDouble(Selet_dtm("1010")); if (STEP_P1 > t_t) { THL_mode = 1; } @@ -286,7 +302,7 @@ namespace DyeingComputer.ViewModel STEP_finish = false; break; case "031": - STEP_TIME = Convert.ToInt16(P1)*60; + STEP_TIME = Convert.ToInt16(P1) * 60; WORK_RUN = 2; SETP_runtime = true; STEP_finish = false; @@ -370,16 +386,16 @@ namespace DyeingComputer.ViewModel } } - TimeSpan ts=new TimeSpan(1);//1秒间隔 + TimeSpan ts = new TimeSpan(1);//1秒间隔 void STEP_RUN() { if (WORK_RUN == 2) { - if (SETP_runtime && (!STEP_finish))// + if (SETP_runtime && (!STEP_finish))// { switch (STEP_ID) { - case "001": + case "001": int TIME_H; int TIME_M; int TIME_S; @@ -387,12 +403,12 @@ namespace DyeingComputer.ViewModel double T = Selet_dtm("1010"); //实际温度 if (THL_mode == 0) //保温 { - if (STEP_TIME == 0) - { - STEP_finish = true; + if (STEP_TIME == 0) + { + STEP_finish = true; } - else - { + else + { STEP_TIME--; } TO = pid.PID_iterate(STEP_P1, T, ts); @@ -440,15 +456,15 @@ namespace DyeingComputer.ViewModel updata_dtm("1005", TEMP_co); break;//功能模块001温度控制 case "007": - if (STEP_P1.ToString() == "1") - { + if (STEP_P1.ToString() == "1") + { updata_dtd("3012", true); updata_dtd("3013", false); updata_dtd("3014", false); updata_dtd("3015", false); if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; } - else if (STEP_P1.ToString() == "2") + else if (STEP_P1.ToString() == "2") { updata_dtd("3012", false); updata_dtd("3013", true); @@ -456,7 +472,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3015", false); if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "2"; } - else if (STEP_P1.ToString() == "3") + else if (STEP_P1.ToString() == "3") { updata_dtd("3012", false); updata_dtd("3013", false); @@ -464,7 +480,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3015", false); if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "3"; } - else if (STEP_P1.ToString() == "4") + else if (STEP_P1.ToString() == "4") { updata_dtd("3012", false); updata_dtd("3013", false); @@ -474,7 +490,7 @@ namespace DyeingComputer.ViewModel } if (Selet_dtm("1015") >= STEP_P2) //到达水位 - { + { updata_dtd("3012", false); updata_dtd("3013", false); updata_dtd("3014", false); @@ -491,7 +507,7 @@ namespace DyeingComputer.ViewModel updata_dtd("3014", false); updata_dtd("3015", false); - if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources. AddWater + ":" + Resources.AddWater + "1"; + if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.AddWater + ":" + Resources.AddWater + "1"; } else if (STEP_P1.ToString() == "2") { @@ -571,7 +587,7 @@ namespace DyeingComputer.ViewModel if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Finish; STEP_finish = true; } - else + else { STEP_TIME--; //排水延时计时 if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Drainage + ":" + Resources.Time + STEP_TIME; @@ -606,7 +622,7 @@ namespace DyeingComputer.ViewModel if (Selet_dtm("1015") <= STEP_P2) //排水状态完成 { if (STEP_TIME == 0)//排水延时 - { + { updata_dtd("3016", false); updata_dtd("3017", false); updata_dtd("3018", false); @@ -623,13 +639,13 @@ namespace DyeingComputer.ViewModel break;//动力排水 case "031": if (STEP_TIME == 0) - { - STEP_finish = true; + { + STEP_finish = true; } - else + else { STEP_TIME--; - TIME_M = STEP_TIME/ 60; + TIME_M = STEP_TIME / 60; TIME_S = STEP_TIME - TIME_M * 60; if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.RunningTime + ":" + Resources.Time + string.Format(" {0:D3}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); } @@ -719,7 +735,7 @@ namespace DyeingComputer.ViewModel if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.Sampling; break;//取样 case "041": - + STEP_finish = true; if (string.IsNullOrEmpty(Name_err.ToString())) Status_Str = Resources.End; break;//结束 @@ -800,7 +816,7 @@ namespace DyeingComputer.ViewModel double T_P4 = Convert.ToDouble(arrRows[0]["Parameter4"].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; } } @@ -819,7 +835,7 @@ namespace DyeingComputer.ViewModel STEP_finish = false; Status_Str = Resources.Paused; } - else + else if (WORK_RUN == 0) { if (string.IsNullOrEmpty(Name_err.ToString())) @@ -836,7 +852,6 @@ namespace DyeingComputer.ViewModel static ModbusFactory factory = new ModbusFactory(); // Create Modbus Master static IModbusMaster master = factory.CreateRtuMaster(port); - void UPort() { try @@ -865,13 +880,12 @@ namespace DyeingComputer.ViewModel bool[] DO = new bool[128]; ushort DO_L = 128; //int[] MW = new int[128]; - // ushort MW_L = 128; + // ushort MW_L = 128; ushort[] DW = new ushort[100]; ushort DW_L = 100; ushort[] RW = new ushort[100]; ushort RW_L = 100; readonly byte slaveId = 1; - private async void Modbus_link() { await Task.Run(() => @@ -880,21 +894,50 @@ namespace DyeingComputer.ViewModel try { master.WriteMultipleCoils(slaveId, 00000, DQ); //写入线圈 - master.WriteMultipleRegisters(slaveId,07000,DW); //写入寄存器 + master.WriteMultipleRegisters(slaveId, 07000, DW); //写入寄存器 DO = master.ReadCoils(slaveId, 01000, DO_L); //读取线圈 - RW = master.ReadHoldingRegisters(slaveId,06000, RW_L); //读取寄存器 - LINK_OK =true; + RW = master.ReadHoldingRegisters(slaveId, 06000, RW_L); //读取寄存器 + LINK_OK = true; Name_err = ""; } - catch (Exception ex) + catch (Exception ex) { - LINK_OK=false; + LINK_OK = false; LINK_ERR++; - Name_err = "PLC"+Properties.Resources.Connectionlost+"("+ ex.Message + ")"; - } + Name_err = "PLC" + Properties.Resources.Connectionlost + "(" + ex.Message + ")"; + } }); } + void LOG_view()//细节页面 + { + Sys_log = Resources.Target + Resources.Temperature + ":"+ string.Format(" {0:###.#}", TEMP_tar) + "°C";//显示目标温度 + Sys_log = Sys_log + "\n" + Resources.Compute + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToDouble(Selet_dtm("1005"))) + "°C";//显示计算温度 + Sys_log = Sys_log + "\n" + Resources.MasterCylinder + Resources.Temperature + ":" + string.Format(" {0:###.#}", Convert.ToDouble(Selet_dtm("1010"))) + "°C";//显示实际温度 + Sys_log = Sys_log + "\n" + Resources.ProportionalValves + ":" + string.Format("{0:###.#}", Convert.ToDouble(Selet_dtm("1004"))) + "%";//显示比例 + int IO1015 = Convert.ToInt16( Selet_dtm("1015")); + if (IO1015["+Resources.Low_waterlevel+"]";//显示水位 + } + else if ((IO1015 > MT39) && (IO1015 < MT38)) + { + Sys_log = Sys_log + "\n" + Resources.MasterCylinder + Resources.WaterLevel + ":" + IO1015 + "L =>[" + Resources.Mid_waterlevel + "]";//显示水位 + } + else if (IO1015 > MT38) + { + Sys_log = Sys_log + "\n" + Resources.MasterCylinder + Resources.WaterLevel + ":" + IO1015 + "L =>[" + Resources.High_waterlevel + "]";//显示水位 + } + if (Pump_M) //主泵状态 + { + Sys_log = Sys_log + "\n" + Resources.PumpSpeed + ":" + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1030"))) + "% => [" + Resources.PumpStart+"]";//主泵状态 + } + else + { + Sys_log = Sys_log + "\n" + Resources.PumpSpeed + ":" + string.Format("{0:D3}", Convert.ToInt16(Selet_dtm("1030"))) + "% => [" + Resources.PumpStops+"]";//主泵状态 + } + } + public static DataTable dt_d = new DataTable("DIO"); public static DataTable dt_a = new DataTable("AIO"); public static DataTable dt_m = new DataTable("M"); @@ -916,7 +959,6 @@ namespace DyeingComputer.ViewModel DataColumn[] dt_mcols = new DataColumn[] { dt_m.Columns["ID"] }; dt_m.PrimaryKey = dt_mcols; } - private async void IO_data()//刷新 { updata_dtm("1001", LINK_RUN); @@ -934,7 +976,7 @@ namespace DyeingComputer.ViewModel for (ushort i = 0; i < DW_L; i++) { DW[i] = Convert.ToUInt16(Selet_dta((i + 5001).ToString())); } }); } - private async void IO_view() + private async void IO_view()//IO显示 { await Task.Run(() => {