You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
61 lines
1.7 KiB
61 lines
1.7 KiB
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;
|
|
/// <summary>
|
|
/// 水冷客户端
|
|
/// </summary>
|
|
[Scope("InstancePerDependency")]
|
|
public class WaterCoolClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
{
|
|
/// <summary>
|
|
/// 水冷数据主动上报
|
|
/// </summary>
|
|
public WaterCoolStatus? WaterCoolStatus { get; set; }
|
|
|
|
/// <summary>
|
|
/// 水冷是否连接成功
|
|
/// </summary>
|
|
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;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 水冷机编号
|
|
/// </summary>
|
|
public string Sn { get; set; }
|
|
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="sn"></param>
|
|
/// <param name="destAddr"></param>
|
|
public void SessionAttr(string sn, string destAddr)
|
|
{
|
|
ChannelUtils.AddAttr(Channel, WaterCoolerConst.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;
|
|
}
|
|
} |