|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970 |
- 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;
-
- 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 (a)
- {
- start.RecipeName = "配方1";
- start.RecipeCode = "1201";
- start.Order_Request_Ack = true;
-
- for (int i = 0; i < GVL_BigStation.StockBinNum ; i++)
- {
- start.Material[i] = new UDT();
- start.Material[i].Material_Name = "" + (i +1);
- start.Material[i].Material_Weight = 100 + (i + 1);
- start.Material[i].Material_BarrelNum = (short)(i + 1);
- }
- }
- if (RTrig.GetInstance("Order_Request").Start(GVL_BigStation.Order_Request))
- {
- start.Order_Request = true;
- Siemens_PLC_S7.WriteClass<DL_Start_DB>(start, 2301);
- }
- if (RTrig.GetInstance("Order_Request_Ack").Start(start.Order_Request_Ack))
- {
- ActionManage.GetInstance.Send("SiemensSendRecipe", start);
- }
- }
- if (res1 != null && res1 is DL_Status_DB status)
- {
-
- }
- 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);
- }), "监听服务数据");
- }
- }
- }
- }
|