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; using RabbitMQ.Client; 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) { } public void Button_Click(object sender, RoutedEventArgs e) { MessageBoxResult result = MessageBox.Show("请先确认当前无未绑定箱体,如导致未绑定箱体将无法下线!!\n\n系统将会记录您当前行为,请谨慎使用该功能!!\n\n是否继续启动?", "确认", MessageBoxButton.YesNo, MessageBoxImage.Question); if (result == MessageBoxResult.Yes) { if (SendPlcPass()) { MessageBox.Show("放行成功"); } else { MessageBox.Show("放行失败,plc未连接"); } } } /// /// 下发plc放行信号 /// /// /// public 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; } } }