sc 1 year ago
parent
commit
07463625c8
  1. 10
      MainWindow.xaml.cs
  2. 4
      View/TechnologicalProcessView.xaml.cs
  3. 59
      ViewModel/MainWindowViewModel.cs

10
MainWindow.xaml.cs

@ -161,13 +161,15 @@ namespace DyeingComputer
{ {
if(e.Key == Key.N) if(e.Key == Key.N)
{ {
if (MainWindowViewModel.WORK_RUN == 2) MainWindowViewModel.WORK_RUN = 1;// 运行时停止键为暂停 if (MainWindowViewModel.WORK_RUN == 2)
if (MainWindowViewModel.WORK_RUN == 1) {
MainWindowViewModel.WORK_RUN = 1;// 运行时停止键为暂停
}else if (MainWindowViewModel.WORK_RUN == 1)
{ {
MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("800", Properties.Resources.Save, MessageBoxButton.OKCancel); MessageBoxResult messageBoxResult = System.Windows.MessageBox.Show("800", Properties.Resources.Save, MessageBoxButton.OKCancel);
if (messageBoxResult == MessageBoxResult.Yes) if (messageBoxResult == MessageBoxResult.OK)
{ {
MainWindowViewModel.WORK_RUN = 1;// 运行时停止键为 MainWindowViewModel.WORK_RUN = 0;// 运行时停止键为
} }
} }
} }

4
View/TechnologicalProcessView.xaml.cs

@ -104,8 +104,8 @@ namespace DyeingComputer.View
{ {
if (e.Key == Key.Y) //按键y if (e.Key == Key.Y) //按键y
{ {
MainWindowViewModel strart = new MainWindowViewModel();//实例 // MainWindowViewModel strart = new MainWindowViewModel();//实例
strart.STEP_START(Numder, Convert.ToDouble(P1), Convert.ToDouble(P2), Convert.ToDouble(P3), Convert.ToDouble(P4), Convert.ToDouble(P5));//传入参数开始 // strart.STEP_START(Numder, Convert.ToDouble(P1), Convert.ToDouble(P2), Convert.ToDouble(P3), Convert.ToDouble(P4), Convert.ToDouble(P5));//传入参数开始
} }
} }
} }

59
ViewModel/MainWindowViewModel.cs

@ -184,17 +184,17 @@ namespace DyeingComputer.ViewModel
public static int WORK_RUN = 0; //运行状态0停止1暂停2运行 public static int WORK_RUN = 0; //运行状态0停止1暂停2运行
string STEP_ID = "0"; private string STEP_ID = "0";
double STEP_P1 = 0; private double STEP_P1 = 0;
double STEP_P2 = 0; private double STEP_P2 = 0;
double STEP_P3 = 0; private double STEP_P3 = 0;
double STEP_P4 = 0; private double STEP_P4 = 0;
double STEP_P5 = 0; private double STEP_P5 = 0;
int SETP_runtime; //步骤开始 private int SETP_runtime; //步骤开始
bool STEP_finish = false; //步骤结束 private bool STEP_finish = false; //步骤结束
int STEP_TIME = 0; //步骤计时S private int STEP_TIME = 0; //步骤计时S
int THL_mode = 0; //温控模式 0保温 1加热 2降 private int THL_mode = 0; //温控模式 0保温 1加热 2降
double TEMP_co = 0; //计算温度 private double TEMP_co = 0; //计算温度
public void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5) public void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5)
{ {
@ -213,17 +213,18 @@ namespace DyeingComputer.ViewModel
updata_dtm("1003", STEP_P2 / 600); updata_dtm("1003", STEP_P2 / 600);
STEP_TIME = Convert.ToInt16(STEP_P3) * 60; STEP_TIME = Convert.ToInt16(STEP_P3) * 60;
WORK_RUN = 2; WORK_RUN = 2;
SETP_runtime =1; SETP_runtime = 1;
} }
} }
TimeSpan ts=new TimeSpan(1);//1秒间隔 TimeSpan ts=new TimeSpan(1);//1秒间隔
void STEP_RUN() void STEP_RUN()
{ {
if (WORK_RUN == 2)
/* if (WORK_RUN == 2)
{
if (SETP_runtime == 1)
{ {
// if (SETP_runtime == 1)
// {
if (STEP_ID == "001") if (STEP_ID == "001")
{ {
@ -231,7 +232,6 @@ namespace DyeingComputer.ViewModel
double T = Selet_dtm("1010"); //实际温度 double T = Selet_dtm("1010"); //实际温度
if (THL_mode == 0) //保温 if (THL_mode == 0) //保温
{ {
//STEP_TIME--;
if (STEP_TIME == 0) { STEP_finish = true; } if (STEP_TIME == 0) { STEP_finish = true; }
else { STEP_TIME--; } else { STEP_TIME--; }
TO = pid.PID_iterate(STEP_P1, T, ts); TO = pid.PID_iterate(STEP_P1, T, ts);
@ -263,20 +263,21 @@ namespace DyeingComputer.ViewModel
} }
// } }
// else else
// { {
// if (Name_err == null) if (Name_err == null)
// { {
// Status_Str = Resources.Await; Status_Str = Resources.Await;
// } }
// } }
} }
else if (WORK_RUN == 1) else if (WORK_RUN == 1)
{ {
Status_Str = Resources. Paused; Status_Str = Resources.Paused;
} }
else if (WORK_RUN == 0) else */
if (WORK_RUN == 0)
{ {
if (Name_err == null) if (Name_err == null)
{ {
@ -389,9 +390,9 @@ namespace DyeingComputer.ViewModel
await Task.Run(() => await Task.Run(() =>
{ {
// SYSData_A = ToObservableCollection<DATA_A>(dt_a); SYSData_A = ToObservableCollection<DATA_A>(dt_a);
// SYSData_D = ToObservableCollection<DATA_D>(dt_d); SYSData_D = ToObservableCollection<DATA_D>(dt_d);
// SYSData_M = ToObservableCollection<DATA_M>(dt_m); SYSData_M = ToObservableCollection<DATA_M>(dt_m);
}); });
} }

Loading…
Cancel
Save