diff --git a/MainWindow.xaml b/MainWindow.xaml index 522552a..4a16346 100644 --- a/MainWindow.xaml +++ b/MainWindow.xaml @@ -6,7 +6,7 @@ xmlns:lang="clr-namespace:DyeingComputer.Properties" xmlns:local="clr-namespace:DyeingComputer" xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel" d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}" - mc:Ignorable="d" + mc:Ignorable="d" KeyDown="W_KeyDown" Title="SUNLIGHT 838 b0.0.1 (2024/08/10)" Height="720" Width="1280"> diff --git a/MainWindow.xaml.cs b/MainWindow.xaml.cs index 1195667..727b411 100644 --- a/MainWindow.xaml.cs +++ b/MainWindow.xaml.cs @@ -35,7 +35,7 @@ namespace DyeingComputer } private SQLiteHelper SQLiteHelpers = null; //定义数据库 - + private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径 /// @@ -55,12 +55,13 @@ namespace DyeingComputer if (!result_IOName) LogGing.LogGingDATA("Master_IOName_Table_Loss"); if (!result_ProgramName) LogGing.LogGingDATA("Master_ProgramName_Table_Loss"); if (!result_ProgramSteps) LogGing.LogGingDATA("Master_ProgramSteps_Table_Loss"); - if (!result_System || !result_IOName || !result_ProgramName || !result_ProgramSteps) + if (!result_System || !result_IOName || !result_ProgramName || !result_ProgramSteps) { SQLiteHelpers.Close(); MessageBox.Show(Properties.Resources.SysDatLoss); return true; - }else + } + else { SQLiteHelpers.Close(); return false; @@ -156,6 +157,22 @@ namespace DyeingComputer } } - + private void W_KeyDown(object sender, KeyEventArgs e) //键盘监控 + { + if(e.Key == Key.N) + { + if (MainWindowViewModel.WORK_RUN == 2) MainWindowViewModel.WORK_RUN = 1;// 运行时停止键为暂停 + if (MainWindowViewModel.WORK_RUN == 1) + { + MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("800", Properties.Resources.Save, MessageBoxButton.OKCancel); + if (messageBoxResult == MessageBoxResult.Yes) + { + MainWindowViewModel.WORK_RUN = 1;// 运行时停止键为 + } + } + } + } + + } } diff --git a/Properties/Resources.Designer.cs b/Properties/Resources.Designer.cs index 388bf48..7e52ee0 100644 --- a/Properties/Resources.Designer.cs +++ b/Properties/Resources.Designer.cs @@ -546,6 +546,15 @@ namespace DyeingComputer.Properties { } } + /// + /// 查找类似 Paused 的本地化字符串。 + /// + public static string Paused { + get { + return ResourceManager.GetString("Paused", resourceCulture); + } + } + /// /// 查找类似 PHControl 的本地化字符串。 /// diff --git a/Properties/Resources.en-US.resx b/Properties/Resources.en-US.resx index eb18298..65061a6 100644 --- a/Properties/Resources.en-US.resx +++ b/Properties/Resources.en-US.resx @@ -414,4 +414,7 @@ Language + + Paused + \ No newline at end of file diff --git a/Properties/Resources.resx b/Properties/Resources.resx index 03bffdb..1a24c84 100644 --- a/Properties/Resources.resx +++ b/Properties/Resources.resx @@ -414,4 +414,7 @@ Language + + Paused + \ No newline at end of file diff --git a/Properties/Resources.zh-CN.resx b/Properties/Resources.zh-CN.resx index 80566dd..a6cb02c 100644 --- a/Properties/Resources.zh-CN.resx +++ b/Properties/Resources.zh-CN.resx @@ -414,4 +414,7 @@ 语言 + + 暂停 + \ No newline at end of file diff --git a/Properties/Resources.zh-TW.resx b/Properties/Resources.zh-TW.resx index 8583960..2349a55 100644 --- a/Properties/Resources.zh-TW.resx +++ b/Properties/Resources.zh-TW.resx @@ -414,4 +414,7 @@ 語言 + + 已暫停 + \ No newline at end of file diff --git a/View/TechnologicalProcessView.xaml b/View/TechnologicalProcessView.xaml index c23d605..26c185b 100644 --- a/View/TechnologicalProcessView.xaml +++ b/View/TechnologicalProcessView.xaml @@ -6,6 +6,7 @@ xmlns:local="clr-namespace:DyeingComputer.View" xmlns:lang="clr-namespace:DyeingComputer.Properties" mc:Ignorable="d" Loaded="UserControl_Loaded" + KeyDown="UserControl_KeyDown" d:DesignHeight="630" d:DesignWidth="1280"> t_t) { THL_mode = 1; } @@ -213,80 +212,81 @@ namespace DyeingComputer.ViewModel TEMP_co = t_t; updata_dtm("1003", STEP_P2 / 600); STEP_TIME = Convert.ToInt16(STEP_P3) * 60; - SETP_runtime =true; + WORK_RUN = 2; + SETP_runtime =1; } } TimeSpan ts=new TimeSpan(1);//1秒间隔 void STEP_RUN() { - if (SETP_runtime) + if (WORK_RUN == 2) { - switch (STEP_ID) + // if (SETP_runtime == 1) + // { + if (STEP_ID == "001") { - case "001": - double TO = 0; - double T = Selet_dtm("1010"); //实际温度 - if (THL_mode == 0) //保温 - { - //STEP_TIME--; - if (STEP_TIME == 0) { STEP_finish = true; } - else { STEP_TIME--; } - TO = pid.PID_iterate(STEP_P1, T, ts); - if (TO < 0) TO = 0; - - int TIME_H = STEP_TIME / 3600; - int TIME_M = (STEP_TIME - TIME_H * 3600) / 60; - int TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60; - Status_Str = Resources.Temperature+Resources.Time+ string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); - } - else if (THL_mode == 1)//升温 - { - TEMP_co = TEMP_co + (STEP_P2 / 60); - TO = pid.PID_iterate(TEMP_co, T, ts); - if (TO < 0) TO = 0; - if (STEP_P1 0) TO = 0; - TO = Math.Abs(TO); - if (STEP_P1 > T) THL_mode = 0; - } - - updata_dtm("1004", TO); - updata_dtm("1005", TEMP_co); - break; - case "007": - - break; - case "008": - break; - case "013": - - break; - case "015": + double TO = 0; + double T = Selet_dtm("1010"); //实际温度 + if (THL_mode == 0) //保温 + { + //STEP_TIME--; + if (STEP_TIME == 0) { STEP_finish = true; } + else { STEP_TIME--; } + TO = pid.PID_iterate(STEP_P1, T, ts); + if (TO < 0) TO = 0; + + int TIME_H = STEP_TIME / 3600; + int TIME_M = (STEP_TIME - TIME_H * 3600) / 60; + int TIME_S = STEP_TIME - TIME_H * 3600 - TIME_M * 60; + Status_Str = Resources.Temperature + Resources.Time + string.Format(" {0:D2}", TIME_H) + ":" + string.Format(" {0:D2}", TIME_M) + ":" + string.Format(" {0:D2}", TIME_S); + } + else if (THL_mode == 1)//升温 + { + TEMP_co = TEMP_co + (STEP_P2 / 60); + TO = pid.PID_iterate(TEMP_co, T, ts); + if (TO < 0) TO = 0; + if (STEP_P1 < T) THL_mode = 0; + } + else if (THL_mode == 2)//降温 + { + TEMP_co = TEMP_co - (STEP_P2 / 60); + TO = pid.PID_iterate(TEMP_co, T, ts); + if (TO > 0) TO = 0; + TO = Math.Abs(TO); + if (STEP_P1 > T) THL_mode = 0; + } - break; - case "017": + updata_dtm("1004", TO); + updata_dtm("1005", TEMP_co); - break; - default: break; } + + // } + // else + // { + // if (Name_err == null) + // { + // Status_Str = Resources.Await; + // } + // } } - else + else if (WORK_RUN == 1) { - if (Name_err == null) + Status_Str = Resources. Paused; + } + else if (WORK_RUN == 0) + { + if (Name_err == null) { int TIMEH = DIDETime / 3600; int TIMEM = (DIDETime - TIMEH * 3600) / 60; - int TIMES = DIDETime - TIMEH*3600 - TIMEM*60; - Status_Str = Resources.Dide + string.Format(" {0:D4}", TIMEH) +":"+ string.Format(" {0:D2}", TIMEM) + ":" + string.Format(" {0:D2}", TIMES); + int TIMES = DIDETime - TIMEH * 3600 - TIMEM * 60; + Status_Str = Resources.Dide + string.Format(" {0:D4}", TIMEH) + ":" + string.Format(" {0:D2}", TIMEM) + ":" + string.Format(" {0:D2}", TIMES); } } + } @@ -389,9 +389,9 @@ namespace DyeingComputer.ViewModel await Task.Run(() => { - SYSData_A = ToObservableCollection(dt_a); - SYSData_D = ToObservableCollection(dt_d); - SYSData_M = ToObservableCollection(dt_m); + // SYSData_A = ToObservableCollection(dt_a); + // SYSData_D = ToObservableCollection(dt_d); + // SYSData_M = ToObservableCollection(dt_m); }); }