You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

88 lines
2.3 KiB
C#

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

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
{
/// <summary>
/// IndexPageView.xaml 的交互逻辑
/// </summary>
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未连接");
}
}
/// <summary>
/// 下发plc放行信号
/// </summary>
/// <param name="obj"></param>
/// <returns></returns>
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;
}
}
}