sc 1 year ago
parent
commit
aa954eb61b
  1. 2
      MainWindow.xaml
  2. 25
      MainWindow.xaml.cs
  3. 9
      Properties/Resources.Designer.cs
  4. 3
      Properties/Resources.en-US.resx
  5. 3
      Properties/Resources.resx
  6. 3
      Properties/Resources.zh-CN.resx
  7. 3
      Properties/Resources.zh-TW.resx
  8. 1
      View/TechnologicalProcessView.xaml
  9. 11
      View/TechnologicalProcessView.xaml.cs
  10. 132
      ViewModel/MainWindowViewModel.cs

2
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">
<!--WindowState ="Maximized" WindowStyle="None"-->

25
MainWindow.xaml.cs

@ -35,7 +35,7 @@ namespace DyeingComputer
}
private SQLiteHelper SQLiteHelpers = null; //定义数据库
private readonly string DBAddress = Environment.CurrentDirectory + "\\DataBase\\800COMPUTER.db"; //数据库路径
/// <summary>
@ -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;// 运行时停止键为
}
}
}
}
}
}

9
Properties/Resources.Designer.cs

@ -546,6 +546,15 @@ namespace DyeingComputer.Properties {
}
}
/// <summary>
/// 查找类似 Paused 的本地化字符串。
/// </summary>
public static string Paused {
get {
return ResourceManager.GetString("Paused", resourceCulture);
}
}
/// <summary>
/// 查找类似 PHControl 的本地化字符串。
/// </summary>

3
Properties/Resources.en-US.resx

@ -414,4 +414,7 @@
<data name="Language" xml:space="preserve">
<value>Language</value>
</data>
<data name="Paused" xml:space="preserve">
<value>Paused</value>
</data>
</root>

3
Properties/Resources.resx

@ -414,4 +414,7 @@
<data name="Language" xml:space="preserve">
<value>Language</value>
</data>
<data name="Paused" xml:space="preserve">
<value>Paused</value>
</data>
</root>

3
Properties/Resources.zh-CN.resx

@ -414,4 +414,7 @@
<data name="Language" xml:space="preserve">
<value>语言</value>
</data>
<data name="Paused" xml:space="preserve">
<value>暂停</value>
</data>
</root>

3
Properties/Resources.zh-TW.resx

@ -414,4 +414,7 @@
<data name="Language" xml:space="preserve">
<value>語言</value>
</data>
<data name="Paused" xml:space="preserve">
<value>已暫停</value>
</data>
</root>

1
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">
<Grid Focusable="True">
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"

11
View/TechnologicalProcessView.xaml.cs

@ -100,9 +100,13 @@ namespace DyeingComputer.View
private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控
{
if (e.Key == Key.Y) //按键y
if ((MainWindowViewModel.WORK_RUN == 1) || (MainWindowViewModel.WORK_RUN == 0))//停止暂停时可以启用开始
{
if (e.Key == Key.Y) //按键y
{
MainWindowViewModel strart = new MainWindowViewModel();//实例
strart.STEP_START(Numder, Convert.ToDouble(P1), Convert.ToDouble(P2), Convert.ToDouble(P3), Convert.ToDouble(P4), Convert.ToDouble(P5));//传入参数开始
}
}
}
@ -209,7 +213,7 @@ namespace DyeingComputer.View
string Numder = null;
string ID = null;
string P1, P2, P3, P4, P5;
string P1 = "0", P2 = "0", P3 = "0", P4 = "0", P5 = "0";
private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
@ -224,5 +228,6 @@ namespace DyeingComputer.View
P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列,
}
}
}
}

132
ViewModel/MainWindowViewModel.cs

@ -183,28 +183,27 @@ namespace DyeingComputer.ViewModel
}
public static int WORK_RUN = 0; //运行状态0停止1暂停2运行
string STEP_ID = "0";
double STEP_P1 = 0;
double STEP_P2 = 0;
double STEP_P3 = 0;
double STEP_P4 = 0;
double STEP_P5 = 0;
bool SETP_runtime = false; //步骤开始
int SETP_runtime; //步骤开始
bool STEP_finish = false; //步骤结束
int STEP_TIME = 0; //步骤计时S
int THL_mode = 0; //温控模式 0保温 1加热 2降
double TEMP_co = 0; //计算温度
public void STEP_START(AddressUpdateEventArgs e)
public void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5)
{
if (e.StepID == "001")
if (ID == "001")
{
STEP_ID = "001";
STEP_P1 = Convert.ToDouble(e.P1);
STEP_P2 = Convert.ToDouble(e.P2);
STEP_P3 = Convert.ToDouble(e.P3);
STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(P2);
STEP_P3 = Convert.ToDouble(P3);
double t_t = Convert.ToDouble(Selet_dtm("1010"));
if (STEP_P1 > 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 <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;
}
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<DATA_A>(dt_a);
SYSData_D = ToObservableCollection<DATA_D>(dt_d);
SYSData_M = ToObservableCollection<DATA_M>(dt_m);
// SYSData_A = ToObservableCollection<DATA_A>(dt_a);
// SYSData_D = ToObservableCollection<DATA_D>(dt_d);
// SYSData_M = ToObservableCollection<DATA_M>(dt_m);
});
}

Loading…
Cancel
Save