HandDeviceTask.xaml.cs
3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Windows;
namespace HH_WCS_Standard
{
/// <summary>
/// HandDeviceTask.xaml 的交互逻辑
/// </summary>
public partial class HandDeviceTask
{
public HandDeviceTask()
{
InitializeComponent();
}
private void DMSkinWindow_Loaded(object sender, RoutedEventArgs e)
{
// 设备绑定
List<BindComboxType<string>> bindComboxTypes = new List<BindComboxType<string>>();
var deviceList = App.f_ServiceModels.FindAll(a => a.device.Type == "Srm" || a.device.Type == "Rgv");
foreach (F_ServiceModel device in deviceList)
{
bindComboxTypes.Add(new BindComboxType<string> { Name = device.device.Name, Type = device.device.Code });
}
//Comm_Device.ItemsSource = bindComboxTypes;
//Comm_Device.DisplayMemberPath = "Name";
//Comm_Device.SelectedValuePath = "Type";
//任务类型绑定
Comm.ItemsSource = BindComboxEnumType<E_SrmHandTask>.BindTyps;
Comm.DisplayMemberPath = "Name";
Comm.SelectedValuePath = "Type";
}
private void Button_Click(object sender, RoutedEventArgs e)
{
if (Comm.SelectedValue == null) //Comm_Device.SelectedValue == null &&
{
MessageBox.Show("请选择必选项", "提示");
return;
}
//var deviceCode = Comm_Device.SelectedValue.ToString();
var deviceCode = "Srm01";
var taskType = (E_SrmHandTask)Comm.SelectedValue;
if (string.IsNullOrWhiteSpace(from.Text))
{
MessageBox.Show("起点不能为空");
return;
}
if (string.IsNullOrWhiteSpace(to.Text))
{
MessageBox.Show("终点不能为空");
}
var excute_device = App.i_Excutes.FirstOrDefault(a => a.f_service.device.Code == deviceCode);
if (excute_device == null)
{
MessageBox.Show($"找不到此设备{deviceCode}对应的处理类");
return;
}
var excute = excute_device as I_Excute_S; //堆垛机处理类
if (excute != null)
{
var result = excute.HandDeviceTask(taskType.GetIndexInt(), from.Text, to.Text);
if (!result.Success)
{
MessageBox.Show($"手动下发设备{deviceCode}任务失败,错误原因是:【{result.Msg}】");
return;
}
else
{
MessageBox.Show($"手动下发设备{deviceCode}任务成功");
}
}
else
{
MessageBox.Show($"手动下发设备{deviceCode}任务失败,找不到此设备的类型");
return;
}
}
}
}