huanghongfeng
2025-09-26 83f3c63f1cae6224320a8d19251e3bc0404da096
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
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEAWCS_Model.Models;
using WIDESEAWCS_QuartzJob.DTO;
using WIDESEAWCS_QuartzJob;
using WIDESEA_Common.Log;
using System.Xml.Linq;
using SixLabors.ImageSharp;
 
namespace WIDESEAWCS_Tasks.StackerCraneJob
{
 
 
    public class GetDeviceAddress
    {
        /// <summary>
        /// 传入设备,获取当前位置位置
        /// </summary>
        /// <param name="ChildPosiDeviceCode">设备</param>
        /// <returns></returns>
        public static int GetEquipmentlocation(string ChildPosiDeviceCode)   
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            return getStackerObject.RGVCurrentlocation;
        }
 
        /// <summary>
        /// 传入设备,返回当前设备信息
        /// </summary>
        /// <param name="ChildPosiDeviceCode">设备</param>
        /// <returns></returns>
        public static int GetEquipmentInformation(string ChildPosiDeviceCode)
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
            {
                return getStackerObject.RGVCurrentlocation;
            }
            else
            {
                return 0;
            }
                
        }
 
        /// <summary>
        /// 传入设备,返回当前设备信息(入库母车,需要加入是否有货判断)
        /// </summary>
        /// <param name="ChildPosiDeviceCode">设备</param>
        /// <returns></returns>
        public static int GetEquipmentInMuche(string ChildPosiDeviceCode)
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction && getStackerObject.RgvCraneStatusValue == RgvEquipmentStatus.NoCargo)
            {
                return getStackerObject.RGVCurrentlocation;
            }
            else
            {
                return 0;
            }
 
        }
 
 
        /// <summary>
        /// 传入设备编号,判断设备状态是否可进入
        /// </summary>
        /// <param name="ChildPosiDeviceCode"></param>
        /// <returns></returns>
        public static bool ReturnCurrentStatus(string ChildPosiDeviceCode)
        {
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == ChildPosiDeviceCode);
            SpeStackerCrane speStackerCrane = (SpeStackerCrane)device;
            GetStackerObject getStackerObject = new GetStackerObject(speStackerCrane);
            if (getStackerObject.RgvCraneAutoStatusValue == RgvCraneAutoStatus.Automatic &&
                        getStackerObject.StaclerkJobJobStatusValue == RgvJobCraneStatus.Ready && getStackerObject.RgvCraneWorkStatusValue == RGVStepprocess.NoAction)
            {
                return true;
            }
            else
            {
                return false;
            }
        }
 
 
        /// <summary>
        /// 查询HCJ站台设备
        /// </summary>
        /// <param name="Commonstacker"></param>
        /// <param name="SCAddress"></param>
        /// <param name="Interactivet"></param>
        /// <returns></returns>
        public static DeviceProDTO? GetDeviceProDTO(CommonStackerCrane Commonstacker, string SCAddress, string Interactivet)
        {
            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
        }
 
        /// <summary>
        /// 查询RGV设备
        /// </summary>
        /// <param name="Commonstacker"></param>
        /// <param name="SCAddress"></param>
        /// <param name="Interactivet"></param>
        /// <returns></returns>
        public static DeviceProDTO? GetRGVDeviceProDTO(SpeStackerCrane Commonstacker, string SCAddress, string Interactivet)
        {
            return Commonstacker.DeviceProDTOs.FirstOrDefault(x => x.DeviceChildCode == SCAddress && x.DeviceProParamName == Interactivet && x.DeviceProParamType == "ReadDeviceCommand");
        }
        /// <summary>
        /// 读取设备信息
        /// </summary>
        /// <param name="conveyorLine"></param>
        /// <param name="DeviceProDataBlock"></param>
        /// <returns></returns>
        public static int GetLine(CommonStackerCrane Commonstacker, string DeviceProDataBlock)
        {
            return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
        }
 
        public static int RGVGetLine(SpeStackerCrane Commonstacker, string DeviceProDataBlock)
        {
            return Commonstacker.Communicator.Read<short>(DeviceProDataBlock);
        }
 
 
        /// <summary>
        /// 日志记录
        /// </summary>
        /// <param name="SCLLinStack">设备名称</param>
        /// <param name="Filename">文件名称</param>
        /// <param name="Logtype">日志类型</param>
        /// <param name="Magessadd">内容</param>
        public void wcsWriteLog(string SCLLinStack,string Filename, string Logtype, string Magessadd)
        {
            WriteLog.Write_Log(SCLLinStack, Filename, Logtype, new { 信息 = Magessadd });
        }
 
        /// <summary>
        /// 传入站台编号,判断是否有货
        /// </summary>
        /// <param name="Platformnumber">站台编号</param>
        public static bool HCJIsstock(string Platformnumber)
        {
            //获取需要区分是否去入库与去不合格载货台任务
            IDevice? device = Storage.Devices.FirstOrDefault(x => x.DeviceCode == "HCJ2000");
            CommonStackerCrane Commonstacker = (CommonStackerCrane)device;
            DeviceProDTO? deviceProDTO = GetDeviceProDTO(Commonstacker, Platformnumber.ToString(), "HCJ_GoodsStatus");
            int HCJGStatus = GetLine(Commonstacker, deviceProDTO.DeviceProAddress);
            if (HCJGStatus == 0)    //为无货
            {
                return true;
            }
            else
            {
                return false;
            }
        }
    }
}