|
- using BPASmartClient.Helper;
- using BPASmartClient.Modbus;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
-
- namespace BPASmartClient.JXJFoodBigStation.Model.Siemens
- {
- public class SiemensDeviceStatus
- {
- public ModbusTcp SiemensTcp = new ModbusTcp();
- public bool IsConnected => SiemensTcp.Connected;
- public string IpAddress => SiemensTcp.IPAdress;
-
- /// <summary>
- /// 配方接收信号复位
- /// </summary>
- public void RecipeSignReset()
- {
- this.SiemensTcp.Write(SiemensCommAddress.RecipeState, (ushort)0);
- }
- /// <summary>
- /// AGV到位信号复位
- /// </summary>
- public void AgvSignReset()
- {
- this.SiemensTcp.Write(SiemensCommAddress.TrayState, (ushort)0);
- }
- public void Init()
- {
- if (IsConnected)
- {
- ThreadManage.GetInstance().StartLong(new Action(() =>
- {
- var res = this.SiemensTcp.Read(SiemensCommAddress.RecipeState);
- if (res != null && RTrig.GetInstance("RecipeTrig").Start(res is bool SignTrig))
- {
- ActionManage.GetInstance.Send("西门子下发配方");
- RecipeSignReset();
- }
- var AgvState = this.SiemensTcp.Read(SiemensCommAddress.TrayState);
- 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.SiemensTcp.Write(SiemensCommAddress.TrayLocationNumToPLC, TrayLocation);
- this.SiemensTcp.Write(SiemensCommAddress.TrayStateToPLC, 1);
- this.SiemensTcp.Write(SiemensCommAddress.TrayRecipeIDToPLC, recipeID);
- }
- }
- }
|