using Aucma.Core.CodeBinding.ViewModels; using Aucma.Core.CodeBinding.Common; using Aucma.Core.CodeBinding.ViewModels; 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; using Aucma.Core.HwPLc; namespace Aucma.Core.CodeBinding.Views { /// /// IndexPageView.xaml 的交互逻辑 /// public partial class IndexPageView : UserControl { public IndexPageView() { InitializeComponent(); this.DataContext = new IndexPageViewModel(); } private void DataGrid_SelectionChanged(object sender, SelectionChangedEventArgs e) { } private void Button_Click(object sender, RoutedEventArgs e) { if (SendPlcPass()) { MessageBox.Show("放行成功"); } else { MessageBox.Show("放行失败,plc未连接"); } } /// /// 下发plc放行信号 /// /// /// private bool SendPlcPass() { bool result = false; try { var obj = PlcHelper.melsecList.FirstOrDefault(d => d.EquipName.Equals("条码绑定Plc")); if (obj != null) { //log.Info("停止信号D7102写1"); // 停止信号复位 obj.plc.WriteInt16("D7102", "0"); // 报警信号复位 obj.plc.WriteInt16("D7101", "0"); result = true; } else { result = false; } } catch (Exception ex) { result = false; // log.Error("下发plc停止信号方法出现异常,ex:" + ex); } return result; } } }