|
|
@@ -7,6 +7,7 @@ using System.Text; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using System.Windows; |
|
|
|
using System.Windows.Controls; |
|
|
|
using System.Windows.Controls.Primitives; |
|
|
|
using System.Windows.Data; |
|
|
|
using System.Windows.Documents; |
|
|
|
using System.Windows.Input; |
|
|
@@ -32,5 +33,65 @@ namespace BPASmartClient.Academy.View |
|
|
|
private void ReactionKettle50LView_Loaded(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
} |
|
|
|
|
|
|
|
private void PipeLineTR_Loaded(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
private void open_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
if (sender is ButtonBase button && !string.IsNullOrWhiteSpace(button.Tag.ToString().Trim())) |
|
|
|
{ |
|
|
|
if (PlcControl.GetInstance.IsConnect) |
|
|
|
{ |
|
|
|
var tag = button.Tag.ToString().Trim(); |
|
|
|
BoolAddEnum addr=(BoolAddEnum)Enum.Parse(typeof(BoolAddEnum), tag); |
|
|
|
var result= PlcControl.GetInstance.Write(addr, true); |
|
|
|
if (result !=null && result.IsSuccess) |
|
|
|
{ |
|
|
|
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入{tag}:True"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Notify(EnumPromptType.Error, $"写入失败", $"失败:写入{tag}:True\n{result.Message}"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Notify(EnumPromptType.Error, "失败", "设备未连接"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void close_Click(object sender, RoutedEventArgs e) |
|
|
|
{ |
|
|
|
if (sender is ButtonBase button && !string.IsNullOrWhiteSpace(button.Tag.ToString().Trim())) |
|
|
|
{ |
|
|
|
if (PlcControl.GetInstance.IsConnect) |
|
|
|
{ |
|
|
|
var tag = button.Tag.ToString().Trim(); |
|
|
|
BoolAddEnum addr = (BoolAddEnum)Enum.Parse(typeof(BoolAddEnum), tag); |
|
|
|
var result = PlcControl.GetInstance.Write(addr, false); |
|
|
|
if (result != null && result.IsSuccess) |
|
|
|
{ |
|
|
|
Notify(EnumPromptType.Success, $"写入成功", $"成功:写入{tag}:False"); |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Notify(EnumPromptType.Error, $"写入失败", $"失败:写入{tag}:False\n{result.Message}"); |
|
|
|
} |
|
|
|
} |
|
|
|
else |
|
|
|
{ |
|
|
|
Notify(EnumPromptType.Error, "失败", "设备未连接"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private void Notify(EnumPromptType promptType,string title,string msg) |
|
|
|
{ |
|
|
|
NoticeDemoViewModel.OpenMsg(promptType, App.Current.MainWindow, title, msg); |
|
|
|
} |
|
|
|
} |
|
|
|
} |