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.JXJFoodSmallStation.Model.Siemens
{
public class SiemensDeviceStatus
{
public SiemensHelper Siemens_PLC_S7 = new SiemensHelper();
public bool IsConnected => Siemens_PLC_S7.IsConnected;
///
/// 配方接收信号复位
///
public void RecipeSignReset()
{
this.Siemens_PLC_S7.Write(SiemensCommAddress.RecipeState, (ushort)0);
}
///
/// AGV到位信号复位
///
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();
}
}),"监听服务数据");
}
}
///
/// 配方配料完成信号
///
///
///
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);
}
}
}