StationExcute.cs
4.39 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
84
85
86
87
88
89
90
91
92
93
using HHECS.Model;
using HHECS.OPC;
using S7.Net;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HHECS.Common
{
public abstract class StationExcute
{
/// <summary>
/// 用于标记站台的类型
/// </summary>
public EquipmentType EquipmentType { get; set; }
/// <summary>
/// 具体的站台实现逻辑
/// </summary>
/// <param name="stations"></param>
/// <param name="plcs"></param>
/// <returns></returns>
public abstract BllResult Excute(List<Equipment> stations, List<Plc> plcs);
/// <summary>
/// 实现地址回复
/// </summary>
/// <param name="station"></param>
/// <param name="plc"></param>
/// <param name="message"></param>
/// <param name="loadStatus"></param>
/// <param name="number"></param>
/// <param name="barcode"></param>
/// <param name="weight"></param>
/// <param name="lenght"></param>
/// <param name="width"></param>
/// <param name="height"></param>
/// <param name="address"></param>
/// <param name="backup"></param>
/// <returns></returns>
public BllResult SendAddressReplyToPlc(Equipment station, Plc plc, string message, string loadStatus, string number, string barcode, string weight, string lenght, string width, string height, string address, string backup)
{
var prop1 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyMessage");
prop1.Value = message;
var prop2 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyLoadStatus");
prop2.Value = loadStatus;
var prop3 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyNumber");
prop3.Value = number;
var prop4 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyBarcode");
prop4.Value = barcode;
var prop5 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyWeight");
prop5.Value = weight;
var prop6 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyLength");
prop6.Value = lenght;
var prop7 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyWidth");
prop7.Value = width;
var prop8 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyHeight");
prop8.Value = height;
var prop9 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyAddress");
prop9.Value = address;
var prop10 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSReplyBackUp");
prop10.Value = backup;
List<EquipmentProp> props = new List<EquipmentProp> { prop2, prop3, prop4, prop5, prop6, prop7, prop8, prop9, prop10, prop1 };
return S7Helper.PlcSplitWrite(plc, props, 20);
}
/// <summary>
/// 实现ACK回复,包括地址到达和控制指令
/// </summary>
/// <param name="station"></param>
/// <param name="plc"></param>
/// <param name="message"></param>
/// <param name="loadStatus"></param>
/// <param name="number"></param>
/// <param name="backup"></param>
/// <returns></returns>
public BllResult SendAckToPlc(Equipment station, Plc plc, string message, string loadStatus, string number, string backup)
{
var prop1 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSACKMessage");
prop1.Value = message;
var prop2 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSACKLoadStatus");
prop2.Value = loadStatus;
var prop3 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSACKNumber");
prop3.Value = number;
var prop4 = station.EquipmentProps.Find(t => t.EquipmentTypePropTemplateCode == "WCSACKBackup");
prop4.Value = backup;
List<EquipmentProp> props = new List<EquipmentProp>() { prop2, prop3, prop4, prop1 };
return S7Helper.PlcSplitWrite(plc, props, 20);
}
}
}