GenTools.cs
8.51 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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
using HHECS.Application.Enums;
using HHECS.Infrastructure.Enums;
using HHECS.Model.Entities;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace HHECS.Test
{
/// <summary>
/// 设备生成帮助类
/// </summary>
public class GenTools
{
/// <summary>
/// 生成站台请求到达地址,按需修改
/// </summary>
/// <param name="stationGenModels"></param>
/// <param name="delete"></param>
static void GenStation(List<StationGenModel> stationGenModels, bool delete)
{
//EquipmentService equipmentService = new EquipmentService();
//if (delete)
//{
// var temp = stationGenModels.Select(t => t.EquipmentTypeConst.ToString()).ToList();
// equipmentService.DeleteEuipmentByIds(equipmentService.GetEquipments(t => temp.Contains(t.EquipmentType.Code)).Data.Select(t => t.Id).ToList());
//}
//foreach (var station in stationGenModels)
//{
// var w = station.MapTo<StationGenModel, Equipment>();
// w.Code = $"{station.EquipmentTypeConst}{station.Code}";
// w.Name = $"{station.EquipmentTypeConst.ToDescriptionOrString()}{station.Code}";
// w.EquipmentTypeId = equipmentService.GetEquipmentTypes(t => t.Code == station.EquipmentTypeConst.ToString()).Data.First().Id;
// w.Created = DateTime.Now;
// var temp = equipmentService.InsertEquipment(w).Data;
// equipmentService.SyncEquipmentProp(temp.Id, "", "");
// temp.EquipmentProps = equipmentService.GetEquipmentProps(t => t.EquipmentId == temp.Id).Data;
// //删除控制指令和PLC的ACK,现在还用不上
// equipmentService.DeleteEquipmentPropByIds(temp.EquipmentProps.Where(t => t.EquipmentTypePropTemplateCode.Contains("Control")).Select(t => t.Id).ToList());
// equipmentService.DeleteEquipmentPropByIds(temp.EquipmentProps.Where(t => t.EquipmentTypePropTemplateCode.StartsWith("ACK")).Select(t => t.Id).ToList());
// if (station.RequestDB == 0)
// {
// equipmentService.DeleteEquipmentPropByIds(temp.EquipmentProps.Where(t => t.EquipmentTypePropTemplateCode.StartsWith("Request")).Select(t => t.Id).ToList());
// }
// else
// {
// temp[StationProps.RequestMessage.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 0}";
// temp[StationProps.RequestLoadStatus.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 2}";
// temp[StationProps.RequestNumber.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 4}";
// temp[StationProps.RequestBarcode.ToString()].Address = $"DB{station.RequestDB}CHAR{station.RequestStart + 6},20";
// temp[StationProps.RequestWeight.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 26}";
// temp[StationProps.RequestLength.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 28}";
// temp[StationProps.RequestWidth.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 30}";
// temp[StationProps.RequestHeight.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 32}";
// temp[StationProps.RequestRetCode.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 34}";
// temp[StationProps.RequestBackup.ToString()].Address = $"DB{station.RequestDB}W{station.RequestStart + 36}";
// equipmentService.UpdateEquipmentProp(temp.EquipmentProps.FindAll(t => t.EquipmentTypePropTemplateCode.StartsWith("Request")));
// }
// if (station.WCSRequestDB == 0)
// {
// equipmentService.DeleteEquipmentPropByIds(temp.EquipmentProps.Where(t => t.EquipmentTypePropTemplateCode.StartsWith("WCSReply")).Select(t => t.Id).ToList());
// }
// else
// {
// temp[StationProps.WCSReplyMessage.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 0}";
// temp[StationProps.WCSReplyLoadStatus.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 2}";
// temp[StationProps.WCSReplyNumber.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 4}";
// temp[StationProps.WCSReplyBarcode.ToString()].Address = $"DB{station.WCSRequestDB}CHAR{station.WCSRequestStart + 6},20";
// temp[StationProps.WCSReplyWeight.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 26}";
// temp[StationProps.WCSReplyLength.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 28}";
// temp[StationProps.WCSReplyWidth.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 30}";
// temp[StationProps.WCSReplyHeight.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 32}";
// temp[StationProps.WCSReplyAddress.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 34}";
// temp[StationProps.WCSReplyBackUp.ToString()].Address = $"DB{station.WCSRequestDB}W{station.WCSRequestStart + 36}";
// equipmentService.UpdateEquipmentProp(temp.EquipmentProps.FindAll(t => t.EquipmentTypePropTemplateCode.StartsWith("WCSReply")));
// }
// if (station.ArrivaDB == 0)
// {
// equipmentService.DeleteEquipmentPropByIds(temp.EquipmentProps.Where(t => t.EquipmentTypePropTemplateCode.StartsWith("Arrive")).Select(t => t.Id).ToList());
// }
// else
// {
// temp[StationProps.ArriveMessage.ToString()].Address = $"DB{station.ArrivaDB}W{station.ArrivaStart + 0}";
// temp[StationProps.ArriveResult.ToString()].Address = $"DB{station.ArrivaDB}W{station.ArrivaStart + 2}";
// temp[StationProps.ArriveRealAddress.ToString()].Address = $"DB{station.ArrivaDB}W{station.ArrivaStart + 4}";
// temp[StationProps.ArriveAllocationAddress.ToString()].Address = $"DB{station.ArrivaDB}W{station.ArrivaStart + 6}";
// temp[StationProps.ArriveBarcode.ToString()].Address = $"DB{station.ArrivaDB}CHAR{station.ArrivaStart + 8},20";
// temp[StationProps.ArrivePaddingBit.ToString()].Address = $"DB{station.ArrivaDB}W{station.ArrivaStart + 28}";
// equipmentService.UpdateEquipmentProp(temp.EquipmentProps.FindAll(t => t.EquipmentTypePropTemplateCode.StartsWith("Arrive")));
// }
// if (station.WCSArrivaDB == 0)
// {
// equipmentService.DeleteEquipmentPropByIds(temp.EquipmentProps.Where(t => t.EquipmentTypePropTemplateCode.StartsWith("WCSACK")).Select(t => t.Id).ToList());
// }
// else
// {
// temp[StationProps.WCSACKMessage.ToString()].Address = $"DB{station.WCSArrivaDB}W{station.WCSArrivaStart + 0}";
// temp[StationProps.WCSACKLoadStatus.ToString()].Address = $"DB{station.WCSArrivaDB}W{station.WCSArrivaStart + 2}";
// temp[StationProps.WCSACKNumber.ToString()].Address = $"DB{station.WCSArrivaDB}W{station.WCSArrivaStart + 4}";
// temp[StationProps.WCSACKBackup.ToString()].Address = $"DB{station.WCSArrivaDB}W{station.WCSArrivaStart + 6}";
// equipmentService.UpdateEquipmentProp(temp.EquipmentProps.FindAll(t => t.EquipmentTypePropTemplateCode.StartsWith("WCSACK")));
// }
//}
}
}
/// <summary>
/// 站台地址生成model
/// </summary>
public class StationGenModel : Equipment
{
public EquipmentTypeConst EquipmentTypeConst { get; set; }
public int RequestDB { get; set; }
public int RequestStart { get; set; }
public int WCSRequestDB { get; set; }
public int WCSRequestStart { get; set; }
public int ArrivaDB { get; set; }
public int ArrivaStart { get; set; }
public int WCSArrivaDB { get; set; }
public int WCSArrivaStart { get; set; }
}
}