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
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
| using Microsoft.AspNetCore.Authorization;
| using Microsoft.AspNetCore.Mvc;
| using OfficeOpenXml.FormulaParsing.Excel.Functions.Numeric;
| using WIDESEAWCS_Core;
| using WIDESEAWCS_QuartzJob;
| using WIDESEAWCS_QuartzJob.Models;
| using WIDESEAWCS_QuartzJob.Repository;
| using WIDESEAWCS_Tasks.ElevatorJob;
| using WIDESEAWCS_Tasks.StackerCraneJob;
|
| namespace WIDESEAWCS_Server.Controllers.Task
| {
| [Route("/api/EquipmentStatus")]
| [ApiController]
| public class EquipmentStatusController : ControllerBase
| {
| private readonly IDeviceInfoRepository _deviceInfoRepository;
|
| public EquipmentStatusController(IDeviceInfoRepository deviceInfoRepository)
| {
| _deviceInfoRepository = deviceInfoRepository;
| }
|
| [HttpGet, HttpPost, Route("GetData"), AllowAnonymous]
| public WebResponseContent GetData()
| {
| WebResponseContent content = new WebResponseContent();
| try
| {
| List<Equipment> equipments = new List<Equipment>();
| List<Dt_DeviceInfo> dt_DeviceInfos = _deviceInfoRepository.QueryData();
| if(dt_DeviceInfos.Count() > 0)
| {
|
| foreach(var item in dt_DeviceInfos)
| {
| Equipment equipment = new Equipment();
| if (item.DeviceCode == "1001") continue;
| if (item.DeviceCode == "TSJ2") continue;
|
| equipment.DeviceCode = item.DeviceCode;
| equipment.DeviceName = item.DeviceName;
| equipment.DeviceType = item.DeviceType;
| equipments.Add(equipment);
| }
| }
| else
| {
| return content.Error("未查询到设备!!");
|
| }
| CommonElevator? commonElevator = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "TSJ1") as CommonElevator;
| CommonStackerCrane? commonStackerCrane = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "SC1") as CommonStackerCrane;
| foreach (var item in equipments)
| {
| if(item.DeviceCode == "TSJ1")
| {
| if (commonElevator.GetValue<ElevatorDBName, short>(ElevatorDBName.ElevatorStatus) == 0)
| {
| item.DeviceRunStatus = "无状态";
| }
| else if(commonElevator.GetValue<ElevatorDBName, short>(ElevatorDBName.ElevatorStatus) == 1)
| {
| item.DeviceRunStatus = "运行中";
| }
| else if (commonElevator.GetValue<ElevatorDBName, short>(ElevatorDBName.ElevatorStatus) == 2)
| {
| item.DeviceRunStatus = "待机";
| }
| else
| {
| item.DeviceRunStatus = "报警";
| }
| if(commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm1)) { item.AlarmInformation = "急停被按下报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm2)) { item.AlarmInformation = "电梯内输送线电机过载报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm3)) { item.AlarmInformation = "地面输送线电机过载报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm4)) { item.AlarmInformation = "电梯系统异常报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm5)) { item.AlarmInformation = "初始化时设备上有货物报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm6)) { item.AlarmInformation = "一层输送线AGV放货异常报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm7)) { item.AlarmInformation = "一层光幕检测到物体报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm8)) { item.AlarmInformation = "二层光幕检测到物体报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm9)) { item.AlarmInformation = "二层输送线AGV放货异常报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm10)) { item.AlarmInformation = "一层电梯对准光电未检测到报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm11)) { item.AlarmInformation = "二层电梯对准光电未检测到报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm12)) { item.AlarmInformation = "有货物在一层输送线上报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm13)) { item.AlarmInformation = "AGV一层取货异常报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm14)) { item.AlarmInformation = "AGV二层取货异常报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm15)) { item.AlarmInformation = "有货物在二层输送线上报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm16)) { item.AlarmInformation = "电梯不在1楼报警"; }
| if (commonElevator.GetValue<ElevatorDBName, bool>(ElevatorDBName.ElevatorAlarm17)) { item.AlarmInformation = "电梯不在2楼报警"; }
| }
|
| if (item.DeviceCode == "SC1")
| {
| var alarm = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.Alarm);
| if(StackerCraneAlarm(alarm) != null)
| {
| item.AlarmInformation = StackerCraneAlarm(alarm);
| }
| var status = commonStackerCrane.GetValue<StackerCraneDBName, short>(StackerCraneDBName.StackerCraneWorkStatus);
| if(StackerCraneStatus(status) != null)
| {
| item.DeviceRunStatus = StackerCraneStatus(status);
| }
|
| }
| }
| content = WebResponseContent.Instance.OK(data: equipments);
| }
| catch(Exception ex)
| {
| return content.Error(ex.Message);
| }
| return content;
| }
|
| public class Equipment
| {
| public string DeviceCode { get; set; }
| public string DeviceName { get; set; }
| public string DeviceType { get; set; }
| public string DeviceRunStatus { get; set; }
| public string AlarmInformation {get; set;}
| }
|
| #region 报警代码转换成文字说明
| public string StackerCraneAlarm(short alarm) => alarm switch
| {
| 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 => "安全门打开故障",
| _ => ""
| };
| #endregion
| #region 设备状态转换成文字说明
| public string StackerCraneStatus(short status) => status switch
| {
| 0 => "空闲",
| 1 => "取货走行",
| 2 => "取货等待",
| 3 => "取货中",
| 4 => "放货走行",
| 5 => "放货等待",
| 6 => "放货中",
| 7 => "回原点",
| 8 => "回反原点",
| 9 => "走行中",
| 10 => "任务完成等待WCS确认",
| 11 => "有货待命",
| 99 => "报警",
| 100 => "维护",
| _ => $"未知状态({status})"
| };
| #endregion
| }
| }
|
|