using BPASmartClient.Helper; using BPASmartClient.Modbus; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using BPASmartClient.S7Net; using System.Threading; namespace BPASmartClient.JXJFoodSmallStation.Model.Siemens { public class SiemensDeviceStatus { public SiemensHelper Siemens_PLC_S7 = new SiemensHelper(); public bool IsConnected => Siemens_PLC_S7.IsConnected; public void Init() { if (IsConnected) { ThreadManage.GetInstance().StartLong(new Action(() => { var Start = this.Siemens_PLC_S7.ReadClass(2201); var Status = this.Siemens_PLC_S7.ReadClass(2231); var Finish = this.Siemens_PLC_S7.ReadClass(2261); var DataColl = this.Siemens_PLC_S7.ReadClass(2291); if (Start != null && Start.Order_Request == false && GVL_SmallStation.IsAllowSiemensSendRecipe) { Start.Order_Request = true; this.Siemens_PLC_S7.WriteClass(Start, 1); } if (Start != null && RTrig.GetInstance("RecipeTrig").Start(Start.Order_Request_ACK)) { ActionManage.GetInstance.Send("SiemensRecipeRecive", Start); Start.Order_Request_ACK = false; this.Siemens_PLC_S7.WriteClass(Start, 1); } if (Status != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(Status.AgvRequestPut)) { ActionManage.GetInstance.Send("AGV放货架到位",Status); Status.AgvRequestPut = false; this.Siemens_PLC_S7.WriteClass(Status, 2); } if (Status != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(Status.AgvRequestGet)) { ActionManage.GetInstance.Send("AGV取货架到位", Status); Status.AgvRequestGet = false; this.Siemens_PLC_S7.WriteClass(Status, 2); } Thread.Sleep(10); }),"监听服务数据"); } } } }