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 { /// /// 获取货位光电信号 /// /// 货位号 /// 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(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("R_PalletSignal", gteaddress.address);//读取托盘信号:1:有,2无 signal.MaterialSignal = Pipeline_client.ReadByOrder("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; } } }