sc 1 year ago
parent
commit
aa954eb61b
  1. 2
      MainWindow.xaml
  2. 19
      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. 9
      View/TechnologicalProcessView.xaml.cs
  10. 62
      ViewModel/MainWindowViewModel.cs

2
MainWindow.xaml

@ -6,7 +6,7 @@
xmlns:lang="clr-namespace:DyeingComputer.Properties" xmlns:lang="clr-namespace:DyeingComputer.Properties"
xmlns:local="clr-namespace:DyeingComputer" xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel" xmlns:local="clr-namespace:DyeingComputer" xmlns:viewmodel="clr-namespace:DyeingComputer.ViewModel"
d:DataContext="{d:DesignInstance Type=viewmodel:MainWindowViewModel}" 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)" Title="SUNLIGHT 838 b0.0.1 (2024/08/10)"
Height="720" Width="1280"> Height="720" Width="1280">
<!--WindowState ="Maximized" WindowStyle="None"--> <!--WindowState ="Maximized" WindowStyle="None"-->

19
MainWindow.xaml.cs

@ -60,7 +60,8 @@ namespace DyeingComputer
SQLiteHelpers.Close(); SQLiteHelpers.Close();
MessageBox.Show(Properties.Resources.SysDatLoss); MessageBox.Show(Properties.Resources.SysDatLoss);
return true; return true;
}else }
else
{ {
SQLiteHelpers.Close(); SQLiteHelpers.Close();
return false; 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> /// <summary>
/// 查找类似 PHControl 的本地化字符串。 /// 查找类似 PHControl 的本地化字符串。
/// </summary> /// </summary>

3
Properties/Resources.en-US.resx

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

3
Properties/Resources.resx

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

3
Properties/Resources.zh-CN.resx

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

3
Properties/Resources.zh-TW.resx

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

1
View/TechnologicalProcessView.xaml

@ -6,6 +6,7 @@
xmlns:local="clr-namespace:DyeingComputer.View" xmlns:local="clr-namespace:DyeingComputer.View"
xmlns:lang="clr-namespace:DyeingComputer.Properties" xmlns:lang="clr-namespace:DyeingComputer.Properties"
mc:Ignorable="d" Loaded="UserControl_Loaded" mc:Ignorable="d" Loaded="UserControl_Loaded"
KeyDown="UserControl_KeyDown"
d:DesignHeight="630" d:DesignWidth="1280"> d:DesignHeight="630" d:DesignWidth="1280">
<Grid Focusable="True"> <Grid Focusable="True">
<DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged" <DataGrid x:Name="Grid" AlternationCount="2" IsReadOnly="True" SelectionChanged="Grid_SelectionChanged"

9
View/TechnologicalProcessView.xaml.cs

@ -99,10 +99,14 @@ namespace DyeingComputer.View
} }
private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控 private void UserControl_KeyDown(object sender, KeyEventArgs e) //键盘监控
{
if ((MainWindowViewModel.WORK_RUN == 1) || (MainWindowViewModel.WORK_RUN == 0))//停止暂停时可以启用开始
{ {
if (e.Key == Key.Y) //按键y 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 Numder = null;
string ID = 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) private void Grid_SelectionChanged(object sender, SelectionChangedEventArgs e)
{ {
int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量 int rownum = Grid.SelectedIndex;//获取鼠标选中行并定义变量
@ -224,5 +228,6 @@ namespace DyeingComputer.View
P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列, P5 = (Grid.Columns[10].GetCellContent(Grid.Items[rownum]) as TextBlock).Text;//定位第10列,
} }
} }
} }
} }

62
ViewModel/MainWindowViewModel.cs

@ -183,28 +183,27 @@ namespace DyeingComputer.ViewModel
} }
public static int WORK_RUN = 0; //运行状态0停止1暂停2运行
string STEP_ID = "0"; string STEP_ID = "0";
double STEP_P1 = 0; double STEP_P1 = 0;
double STEP_P2 = 0; double STEP_P2 = 0;
double STEP_P3 = 0; double STEP_P3 = 0;
double STEP_P4 = 0; double STEP_P4 = 0;
double STEP_P5 = 0; double STEP_P5 = 0;
bool SETP_runtime = false; //步骤开始 int SETP_runtime; //步骤开始
bool STEP_finish = false; //步骤结束 bool STEP_finish = false; //步骤结束
int STEP_TIME = 0; //步骤计时S int STEP_TIME = 0; //步骤计时S
int THL_mode = 0; //温控模式 0保温 1加热 2降 int THL_mode = 0; //温控模式 0保温 1加热 2降
double TEMP_co = 0; //计算温度 double TEMP_co = 0; //计算温度
public void STEP_START(string ID,double P1,double P2,double P3,double P4,double P5)
public void STEP_START(AddressUpdateEventArgs e)
{ {
if (e.StepID == "001") if (ID == "001")
{ {
STEP_ID = "001"; STEP_ID = "001";
STEP_P1 = Convert.ToDouble(e.P1); STEP_P1 = Convert.ToDouble(P1);
STEP_P2 = Convert.ToDouble(e.P2); STEP_P2 = Convert.ToDouble(P2);
STEP_P3 = Convert.ToDouble(e.P3); STEP_P3 = Convert.ToDouble(P3);
double t_t = Convert.ToDouble(Selet_dtm("1010")); double t_t = Convert.ToDouble(Selet_dtm("1010"));
if (STEP_P1 > t_t) { THL_mode = 1; } if (STEP_P1 > t_t) { THL_mode = 1; }
@ -213,18 +212,21 @@ namespace DyeingComputer.ViewModel
TEMP_co = t_t; TEMP_co = t_t;
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;
SETP_runtime =true; WORK_RUN = 2;
SETP_runtime =1;
} }
} }
TimeSpan ts=new TimeSpan(1);//1秒间隔 TimeSpan ts=new TimeSpan(1);//1秒间隔
void STEP_RUN() 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 TO = 0;
double T = Selet_dtm("1010"); //实际温度 double T = Selet_dtm("1010"); //实际温度
if (THL_mode == 0) //保温 if (THL_mode == 0) //保温
@ -258,26 +260,23 @@ namespace DyeingComputer.ViewModel
updata_dtm("1004", TO); updata_dtm("1004", TO);
updata_dtm("1005", TEMP_co); updata_dtm("1005", TEMP_co);
break;
case "007":
break;
case "008":
break;
case "013":
break; }
case "015":
break;
case "017":
break; // }
default: break; // else
// {
// if (Name_err == null)
// {
// Status_Str = Resources.Await;
// }
// }
} }
else if (WORK_RUN == 1)
{
Status_Str = Resources. Paused;
} }
else else if (WORK_RUN == 0)
{ {
if (Name_err == null) if (Name_err == null)
{ {
@ -287,6 +286,7 @@ namespace DyeingComputer.ViewModel
Status_Str = Resources.Dide + string.Format(" {0:D4}", TIMEH) + ":" + string.Format(" {0:D2}", TIMEM) + ":" + string.Format(" {0:D2}", TIMES); 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(() => 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