|
- 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 DL_Status_DB DL_Status = new DL_Status_DB();
- bool a = false;
- public void Init()
- {
- if (IsConnected)
- {
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- var res = this.Siemens_PLC_S7.ReadClass<DL_Start_DB>(2301);
- var res1 = this.Siemens_PLC_S7.ReadClass<DL_Status_DB>(2331);
- var res2 = this.Siemens_PLC_S7.ReadClass<DL_Finish_DB>(2361);
- var res3 = this.Siemens_PLC_S7.ReadClass<DL_DataColl_DB>(2391);
- if (res != null && res is DL_Start_DB start)
- {
- if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request) && GVL_BigStation.SiemensSendRecipeStatus == 0)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 1;
- this.Siemens_PLC_S7.Write("DB2301.DBX330.0", true);
- }
- if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 1)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 2;
- ActionManage.GetInstance.Send("SiemensSendRecipe", start);
- this.Siemens_PLC_S7.Write("DB2301.DBX330.0", false);
- }
- if (TTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack) && GVL_BigStation.SiemensSendRecipeStatus == 2)
- {
- GVL_BigStation.SiemensSendRecipeStatus = 3;
- GVL_BigStation.Order_Request = false;
- }
- }
- if (res1 != null && res1 is DL_Status_DB status)
- {
- DL_Status = status;
- }
- if (res2 != null && res2 is DL_Finish_DB finish)
- {
- if (RTrig.GetInstance("Ask_For_Finish_PLC").Start(finish.Ask_For_Finish_PLC) && GVL_BigStation.SiemensSendRecipeStatus == 7)
- {
- finish.Order_No = "";
- finish.Product_Code = "";
- finish.job_No = 0;
- for (int i = 0; i < 20; i++)
- {
- finish.Material[i] = new UDT1();
- }
- GVL_BigStation.SiemensSendRecipeStatus = 0;
- finish.Ask_For_Finish = false;
- finish.ProcessTime = 0;
- this.Siemens_PLC_S7.WriteClass<DL_Finish_DB>(finish, 2361);
- }
- }
- Thread.Sleep(10);
- }), "监听服务数据");
- }
- }
- }
- }
|