using BPASmartClient.Helper;
using BPASmartClient.Modbus;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace BPASmartClient.JXJFoodSmallStation.Model.HK_PLC
{
public class HKDeviceStatus
{
public ModbusTcp ModBusHK = new ModbusTcp();
public string IpAddress => ModBusHK.IPAdress;
public bool IsConnected => ModBusHK.Connected;
public void Init()
{
if (IsConnected)
{
ThreadManage.GetInstance().StartLong(new Action(() =>
{
}),"信号收发处理");
}
}
///
/// 单个配料机配料完成
///
///
public void SingleDosing(uint value)
{
if (IsConnected)
{
ModBusHK.SetUint(HKPlcCommAddress.SingleStockBinLocationToPLC, value);
ModBusHK.Write(HKPlcCommAddress.SingleDosingFinishToPLC, (ushort)1);
}
}
///
/// 复位plc允许接料信号
///
public void AllowDosingSignReset()
{
ModBusHK.Write(HKPlcCommAddress.IsAllowDosing,(ushort)0);
}
///
/// 复位plc到达某料仓信号
///
public void StockStateSignReset()
{
ModBusHK.Write(HKPlcCommAddress.StockState, (ushort)0);
}
///
/// 复位一个配方配料完成信号
///
public void RecipeDosingFinishReset()
{
ModBusHK.Write(HKPlcCommAddress.RecipeDosingFinish, (ushort)0);
}
///
/// 下发配方数据
///
/// 单个桶的编号
/// 单个桶对应的料仓位置
public void StockBinPar(uint BarrelNum, ushort StockBinLocation)
{
if (IsConnected)
{
ModBusHK.SetUint(HKPlcCommAddress.BarrelNumToPLC, BarrelNum);
ModBusHK.Write(HKPlcCommAddress.StockBinLocationToPLC, StockBinLocation);
}
}
}
}