|
|
@@ -0,0 +1,357 @@ |
|
|
|
using BPASmartClient.CustomResource.UserControls.MessageShow; |
|
|
|
using System; |
|
|
|
using System.Collections.Generic; |
|
|
|
using System.Linq; |
|
|
|
using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Data; |
|
|
|
using System.Windows.Documents; |
|
|
|
using System.Windows.Input; |
|
|
|
using System.Windows.Media; |
|
|
|
using System.Windows.Media.Imaging; |
|
|
|
using System.Windows.Navigation; |
|
|
|
using System.Windows.Shapes; |
|
|
|
|
|
|
|
namespace BPASmartClient.Academy.View |
|
|
|
{ |
|
|
|
/// <summary> |
|
|
|
/// ReactionKettle500LView.xaml 的交互逻辑 |
|
|
|
/// </summary> |
|
|
|
public partial class ReactionKettle500LView : UserControl |
|
|
|
{ |
|
|
|
public ReactionKettle500LView() |
|
|
|
{ |
|
|
|
InitializeComponent(); |
|
|
|
this.DataContext = ReactionKettle500LViewModel.GetInstance; |
|
|
|
this.Loaded += DeviceMotionView_Loaded; |
|
|
|
} |
|
|
|
|
|
|
|
private void DeviceMotionView_Loaded(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.connect = o => |
|
|
|
{ |
|
|
|
//App.Current.Dispatcher.Invoke(() => |
|
|
|
//{ |
|
|
|
// if (o) |
|
|
|
// { |
|
|
|
// ooo.Opacity = 1; |
|
|
|
// ooo.IsHitTestVisible = true; |
|
|
|
// state.Visibility = Visibility.Collapsed; |
|
|
|
// } |
|
|
|
// else |
|
|
|
// { |
|
|
|
|
|
|
|
// ooo.Opacity = 0.5; |
|
|
|
// ooo.IsHitTestVisible = false; |
|
|
|
// state.Text = "设 备 未 连 接"; |
|
|
|
// //MessageNotify.GetInstance.ShowRunLog("设备未连接"); |
|
|
|
// state.Visibility = Visibility.Visible; |
|
|
|
// state.Foreground = Brushes.Red; |
|
|
|
// } |
|
|
|
//}); |
|
|
|
|
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
private string tempName = "配料罐升温"; |
|
|
|
private void auto_click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
RadioButton radioButton = (RadioButton)sender; |
|
|
|
switch (radioButton.Content.ToString()) |
|
|
|
{ |
|
|
|
case "反应釜升温": |
|
|
|
tempName = "反应釜升温"; |
|
|
|
wokTemp.Visibility = Visibility.Visible; |
|
|
|
caliTemp.Visibility = Visibility.Collapsed; |
|
|
|
break; |
|
|
|
case "配料罐升温": |
|
|
|
tempName = "配料罐升温"; |
|
|
|
wokTemp.Visibility = Visibility.Visible; |
|
|
|
caliTemp.Visibility = Visibility.Collapsed; |
|
|
|
break; |
|
|
|
case "反应釜降温": |
|
|
|
tempName = "反应釜降温"; |
|
|
|
wokTemp.Visibility = Visibility.Visible; |
|
|
|
caliTemp.Visibility = Visibility.Collapsed; |
|
|
|
break; |
|
|
|
case "温度校准": |
|
|
|
tempName = "温度校准"; |
|
|
|
wokTemp.Visibility = Visibility.Collapsed; |
|
|
|
caliTemp.Visibility = Visibility.Visible; |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void Open_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
RadioButton radioButton = sender as RadioButton; |
|
|
|
if (radioButton.Content.ToString().Contains("配料搅拌")) |
|
|
|
{ |
|
|
|
hzSet.Visibility = Visibility.Visible; |
|
|
|
motorName.Text = "配料搅拌频率:"; |
|
|
|
ooo.Opacity = 0.5; |
|
|
|
ooo.IsHitTestVisible = false; |
|
|
|
} |
|
|
|
if (radioButton.Content.ToString().Contains("反应釜搅拌")) |
|
|
|
{ |
|
|
|
hzSet.Visibility = Visibility.Visible; |
|
|
|
motorName.Text = "反应釜搅拌频率:"; |
|
|
|
ooo.Opacity = 0.5; |
|
|
|
ooo.IsHitTestVisible = false; |
|
|
|
} |
|
|
|
if (Simens_PLC.GetInstance.IsConnected) |
|
|
|
{ |
|
|
|
|
|
|
|
int bit = Convert.ToInt32(radioButton.Tag.ToString()); |
|
|
|
if (bit < 8) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", true); |
|
|
|
} |
|
|
|
else if (bit < 16) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", true); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", true); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void Close_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
RadioButton radioButton = sender as RadioButton; |
|
|
|
if (Simens_PLC.GetInstance.IsConnected) |
|
|
|
{ |
|
|
|
int bit = Convert.ToInt32(radioButton.Tag.ToString()); |
|
|
|
if (bit < 8) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1000.{bit}", false); |
|
|
|
} |
|
|
|
else if (bit < 16) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1001.{bit - 8}", false); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>($"DB1.DBX1002.{bit - 16}", false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void TempSet_CLick(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
bool suc; |
|
|
|
switch (tempName) |
|
|
|
{ |
|
|
|
case "反应釜升温": |
|
|
|
int tempValue; |
|
|
|
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); |
|
|
|
if (suc) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", true); |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
break; |
|
|
|
case "配料罐升温": |
|
|
|
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); |
|
|
|
//int time; |
|
|
|
//suc = int.TryParse(time_1.Text.ToString(), out time); |
|
|
|
if (suc) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", true); |
|
|
|
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10)); |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1016", tempValue); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "反应釜降温": |
|
|
|
suc = int.TryParse(temp_1.Text.ToString(), out tempValue); |
|
|
|
//int time; |
|
|
|
//suc = int.TryParse(time_1.Text.ToString(), out time); |
|
|
|
if (suc) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", true); |
|
|
|
//Simens_PLC.GetInstance.siemens.Write<ushort>("DB1.DBD100", (ushort)(time*10)); |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1020", tempValue); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查温度输入是否正确", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
break; |
|
|
|
case "温度校准": |
|
|
|
bool val = true; |
|
|
|
int value; |
|
|
|
suc = int.TryParse(tempvent.Text.ToString(), out value); |
|
|
|
if (suc) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1024", value).OnFailure(o => |
|
|
|
{ |
|
|
|
val = false; |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜排气温度写入失败", 1, 1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查排气温度校准输入", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
suc = int.TryParse(tempmaterial.Text.ToString(), out value); |
|
|
|
if (suc) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1028", value).OnFailure(o => |
|
|
|
{ |
|
|
|
val = false; |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "配料罐温度写入失败", 1, 1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查配料罐温度校准输入", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
suc = int.TryParse(tempwok.Text.ToString(), out value); |
|
|
|
if (suc) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1032", value).OnFailure(o => |
|
|
|
{ |
|
|
|
val = false; |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "反应釜温度写入失败", 1, 1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查反应釜温度校准输入", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
if (val) |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Info, App.MainWindow, "成功", "校准完成", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void hzSet_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
hzSet.Visibility = Visibility.Collapsed; |
|
|
|
int value; |
|
|
|
bool suc = int.TryParse(motorValue.Text.ToString(), out value); |
|
|
|
if (suc && Simens_PLC.GetInstance.IsConnected && value >= 20 && value <= 100) |
|
|
|
{ |
|
|
|
if (motorName.Text.ToString().Contains("配料搅拌")) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1004", value).OnFailure(o => |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "频率写入失败", 1, 1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
if (motorName.Text.ToString().Contains("反应釜搅拌")) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<int>("DB1.DBD1008", value).OnFailure(o => |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "频率写入失败", 1, 1); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
App.Current.Dispatcher.Invoke(() => |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(EnumPromptType.Warn, App.MainWindow, "警告", "请检查频率设备连接、数据格式等", 1, 1); |
|
|
|
}); |
|
|
|
} |
|
|
|
ooo.Opacity = 1; |
|
|
|
ooo.IsHitTestVisible = true; |
|
|
|
} |
|
|
|
|
|
|
|
private void hzCancel_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
hzSet.Visibility = Visibility.Collapsed; |
|
|
|
ooo.Opacity = 1; |
|
|
|
ooo.IsHitTestVisible = true; |
|
|
|
} |
|
|
|
|
|
|
|
private void TempCLose_CLick(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
switch (tempName) |
|
|
|
{ |
|
|
|
case "配料罐升温": |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.6", false); |
|
|
|
break; |
|
|
|
case "反应釜升温": |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1001.7", false); |
|
|
|
break; |
|
|
|
case "反应釜降温": |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1003.0", false); |
|
|
|
break; |
|
|
|
default: |
|
|
|
break; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void ClearBtn_CLick(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
if (Simens_PLC.GetInstance.IsConnected) |
|
|
|
{ |
|
|
|
Simens_PLC.GetInstance.siemens.Write<bool>("DB1.DBX1002.7", true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
} |