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