WCS
dengjunjie
2024-10-14 901c64f294ee75784f3fec80b47ae6b77932fff3
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Communicator;
using WIDESEAWCS_Core;
using WIDESEAWCS_DTO.AGVInfo;
using WIDESEAWCS_QuartzJob;
 
namespace WIDESEAWCS_Tasks.ConveyorLineExtend
{
    public class AGVsignal
    {
        public static WebResponseContent AGVRequestin<T>(T conveyor) where T : ConveyorLineDTO, new()
        {
            WebResponseContent content = new WebResponseContent();
            try
            {
                if (conveyor == null) throw new Exception("请求数据为空");
                if (string.IsNullOrEmpty(conveyor.Station)) throw new Exception("站点编号为空");
                CommonConveyorLine conveyorLine = Storage.Devices.FirstOrDefault(x => x.DeviceName == "输送线") as CommonConveyorLine;
                if (!conveyorLine.IsConnected) throw new Exception($"通讯连接错误,请检查网络");
                switch (conveyor.Type)
                {
                    case 1:
                        content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestPut, true, conveyor.Station);
                        if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitPut, conveyor.Station);
                        break;
                    case 2:
                        content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVPutComplete, true, conveyor.Station);
                        break;
                    case 3:
                        content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVRequestTake, true, conveyor.Station);
                        if (content.Status) content.Status = conveyorLine.GetValue<ConveyorLine_AGV, bool>(ConveyorLine_AGV.ConveyorLinePermitTake, conveyor.Station);
                        break;
                    case 4:
                        content.Status = conveyorLine.SetValue(ConveyorLine_AGV.WriteAGVTakeComplete, true, conveyor.Station);
                        break;
                    default: throw new Exception($"类型有误[Type:{conveyor.Type}]");
                }
                content = content.Status ? content.OK() : content.Error();
            }
            catch (Exception ex)
            {
                content.Error(ex.Message);
            }
            return content;
        }
    }
}