分支自 SuZhouGuanHong/TaiYuanTaiZhong

dengjunjie
2024-07-05 ddab693f389b648157c8b48c7fcbdefc92561dd2
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
using Newtonsoft.Json;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using System.Text;
using System.Threading.Tasks;
using System.Xml.Linq;
using WIDESEA_Comm.LogInfo;
using WIDESEA_Entity.ToAGV;
using WIDESEA_WCS.WCSClient;
 
namespace WIDESEA_WCS.Common
{
    public class AGVandPipeline
    {
        /// <summary>
        /// 获取货位光电信号
        /// </summary>
        /// <param name="address">货位号</param>
        /// <returns></returns>
        public static Signal GetSignal(string address)
        {
            Signal signal = new Signal();
            AGVGteaddress gteaddress = new AGVGteaddress();
            try
            {
                if (string.IsNullOrEmpty(address) || address == "null")
                    throw new Exception("未获取到请求参数数据");
                gteaddress = JsonConvert.DeserializeObject<AGVGteaddress>(address);
 
                var Pipeline_client = PLCClient.Clients.FirstOrDefault(t => t.PLCName == "链条机");
                if (Pipeline_client == null) throw new Exception("链条机调度服务未开启!");
                if (!Pipeline_client.IsConnected) throw new Exception("与链条机连接超时!");
                signal.PalletSignal = Pipeline_client.ReadByOrder<Int16>("R_PalletSignal", gteaddress.address);//读取托盘信号:1:有,2无
                signal.MaterialSignal = Pipeline_client.ReadByOrder<Int16>("R_MaterialSignal", gteaddress.address);//读取货物信号:1:有,2无
                signal.success = 1;
            }
            catch (Exception ex)
            {
                signal.Message = ex.Message;
            }
            WritePCSLog.LogAdd(address, signal.success == 1 ? "成功 " : "失败", "PCS", "AGV", address, JsonConvert.SerializeObject(signal), $"{gteaddress.TASK_NO}的AGV获取{gteaddress.address}光电信号", "GetSignal", signal.Message);
            return signal;
        }
    }
}