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 res = this.Siemens_PLC_S7.ReadClass(1); var res1 = this.Siemens_PLC_S7.ReadClass(2); var res2 = this.Siemens_PLC_S7.ReadClass(3); if (res != null && RTrig.GetInstance("RecipeTrig").Start(res.Ask_For_Send_Bit)) { ActionManage.GetInstance.Send("SiemensRecipeRecive", res); res.Ask_For_Send_Bit = false; this.Siemens_PLC_S7.WriteClass(res, 1); } if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[0]").Start(res1.Allow_AGV_Put[0])) { ActionManage.GetInstance.Send("AGV到工位1信号",res1); res1.Allow_AGV_Put[0] = false; this.Siemens_PLC_S7.WriteClass(res1, 2); } if (res1 != null && RTrig.GetInstance("Allow_AGV_Put[1]").Start(res1.Allow_AGV_Put[1])) { ActionManage.GetInstance.Send("AGV到工位2信号",res1); res1.Allow_AGV_Put[1] = false; this.Siemens_PLC_S7.WriteClass(res1, 2); } if (res2 != null && res2.Ask_For_Finish_PLC) { ActionManage.GetInstance.Send("配料完成信号确认完成"); res2.Ask_For_Finish_PLC = false; this.Siemens_PLC_S7.WriteClass(res2, 3); } Thread.Sleep(10); }),"监听服务数据"); } } } }