using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.Session;
using HybirdFrameworkDriver.TcpClient;
using log4net;
using Service.Charger.Common;
using Service.Charger.Handler;
using Service.WaterCool.Msg.WaterCool;
using Decoder = Service.Charger.Codec.Decoder;
using Encoder = Service.Charger.Codec.Encoder;
namespace Service.WaterCool.Client;
///
/// 水冷客户端
///
[Scope("InstancePerDependency")]
public class WaterCoolClient : TcpClient
{
///
/// 水冷数据主动上报
///
public WaterCoolStatus? WaterCoolStatus { get; set; }
///
/// 水冷是否连接成功
///
public bool IsConnect { get; set; } = false;
private ILog Log()
{
var name = "WaterCool" + this.Sn;
ILog logger = LogManager.GetLogger(name);
Console.WriteLine(name + "-" + logger.GetHashCode());
return logger;
}
///
/// 水冷机编号
///
public string Sn { get; set; }
///
///
///
///
///
public void SessionAttr(string sn, string destAddr)
{
ChannelUtils.AddAttr(Channel, ChargerConst.WaterCoolSn, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.EqmTypeNo, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.EqmCode, sn);
ChannelUtils.AddAttr(Channel, ChargerConst.DestAddr, destAddr);
}
public bool Connect()
{
base.BaseConnect();
Log().Info($"charger {Sn} connect succeed");
return Connected;
}
}