|
12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364 |
- 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;
-
- namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
- {
- public class SiemensDeviceStatus
- {
- public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
- public bool IsConnected => Siemens_PLC_S7.IsConnected;
-
- /// <summary>
- /// 配方接收信号复位
- /// </summary>
- public void RecipeSignReset()
- {
- this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
- }
- /// <summary>
- /// AGV到位信号复位
- /// </summary>
- public void AgvSignReset()
- {
- this.Siemens_PLC_S7.Write(SiemensCommAddress.StateSign, (ushort)0);
- }
- public void Init()
- {
- if (IsConnected)
- {
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- var res = this.Siemens_PLC_S7.Read(SiemensCommAddress.RecipeState);
- if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
- {
- ActionManage.GetInstance.Send("西门子下发配方");
- RecipeSignReset();
- }
- var AgvState = this.Siemens_PLC_S7.Read(SiemensCommAddress.StateSign);
- if (AgvState != null && RTrig.GetInstance("AgvTrig").Start(res is bool AgvSignTrig))
- {
- ActionManage.GetInstance.Send("AGV到位信号");
- AgvSignReset();
- }
- }),"监听服务数据");
- }
- }
- /// <summary>
- /// 配方配料完成信号
- /// </summary>
- /// <param name="TrayLocation"></param>
- /// <param name="recipeID"></param>
- private void DosingFinsih(int TrayLocation,int recipeID)
- {
- this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayLocationNumToSiemens, TrayLocation);
- this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayStateToSiemens, 1);
- this.Siemens_PLC_S7.Write(SiemensCommAddress.TrayRecipeIDToSiemens, recipeID);
- }
- }
- }
|