using HslCommunication;
using HslCommunication.ModBus;
using HslCommunication.Profinet.Melsec;
using HslCommunication.Profinet.Siemens;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using WIDESEA_Entity.DomainModels;
namespace WIDESEA_WCS.WCSClient
{
public class PLCClient
{
///
/// PLC连接对象集合
///
public static List Clients = new List();
#region 基础参数
///
/// PLC名称
///
public string PLCName { get; set; }
///
/// PLC类型\协议类型
///
public string PLCType { get; set; }
///
/// Ip地址
///
public string Ip { get; set; }
///
/// Ip地址
///
public int Port { get; set; }
///
/// 插槽
///
public int Slot { get; set; }
#endregion
#region 拓展属性
///
/// 交互协议
///
public List itemGroups = new List();
///
/// 心跳
///
public bool Heart { get; set; }
///
/// 是否连接
///
public bool IsConnected { get; set; }
#endregion
#region PLC对象
///
/// 西门子 PLC
///
public SiemensS7Net siemensPLCClient { get; set; }
public ModbusTcpNet modbusTcpNet { get; set; }
public MelsecMcNet melsecMcNet { get; set; }
#endregion
#region 公用方法
///
/// 连接PLC
///
///
public virtual string Connect()
{
throw new NotImplementedException();
}
///
/// 断开PLC连接
///
///
public virtual bool DisConnect()
{
throw new NotImplementedException();
}
///
/// 读取数据,根据DB地址
///
///
///
///
///
///
public virtual DataType Read(string dbAddress, int len = 1)
{
throw new NotImplementedException();
}
///
/// 读取数据,根据数据库指令
///
///
///
///
///
public virtual DataType ReadByOrder(string orderName, string Method = null)
{
throw new NotImplementedException();
}
public object ReadValues(string equipNum)
{
throw new NotImplementedException();
}
///
/// 写入数据,根据DB地址
///
///
///
///
///
public virtual bool Write(string dbAddress, object value)
{
throw new NotImplementedException();
}
///
/// 写入数据,根据数据库指令
///
///
///
///
///
public virtual bool WriteByOrder(string orderName, object value, string Method = null)
{
throw new NotImplementedException();
}
///
/// 获取内容
///
///
///
public object GetContent(OperateResult operateResult, DBItemGroup item)
{
if (!operateResult.IsSuccess)
{
IsConnected = false;
throw new Exception($"【Error】数据读取失败,指令{item.name},DB地址{item.dbAddress}\n错误信息:{operateResult.Message}");
}
return operateResult.Content;
}
///
/// 获取内容
///
///
///
///
///
public object GetContent(OperateResult operateResult, string dbAddress)
{
if (!operateResult.IsSuccess)
{
IsConnected = false;
throw new Exception($"【Error】数据读取失败,DB地址{dbAddress}\n错误信息:{operateResult.Message}");
}
return operateResult.Content;
}
#endregion
}
}