|
|
|
|
using System.Collections.Concurrent;
|
|
|
|
|
using System.Reflection;
|
|
|
|
|
using Autofac;
|
|
|
|
|
using Entity.DbModel.Station;
|
|
|
|
|
using HybirdFrameworkCore.Autofac;
|
|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
|
|
using HybirdFrameworkCore.Redis;
|
|
|
|
|
using HybirdFrameworkCore.Utils;
|
|
|
|
|
using HybirdFrameworkDriver.Session;
|
|
|
|
|
using HybirdFrameworkDriver.TcpClient;
|
|
|
|
|
using log4net;
|
|
|
|
|
using Newtonsoft.Json;
|
|
|
|
|
using Repository.Station;
|
|
|
|
|
using Service.Fire.Codec;
|
|
|
|
|
using Service.Fire.Common;
|
|
|
|
|
using Service.Fire.Handler;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
|
|
|
|
|
namespace Service.Fire.Client;
|
|
|
|
|
|
|
|
|
|
[Scope("InstancePerDependency")]
|
|
|
|
|
public class FireClient : TcpClient<IBaseHandler, Decoder, Encoder>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 消防设备编号
|
|
|
|
|
/// </summary>
|
|
|
|
|
public string Sn { get; set; }
|
|
|
|
|
|
|
|
|
|
private ILog Log()
|
|
|
|
|
{
|
|
|
|
|
var name = "Fire";
|
|
|
|
|
ILog logger = LogManager.GetLogger(name);
|
|
|
|
|
|
|
|
|
|
Console.WriteLine(name + "-" + logger.GetHashCode());
|
|
|
|
|
return logger;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public bool Connect()
|
|
|
|
|
{
|
|
|
|
|
base.BaseConnect();
|
|
|
|
|
Log().Info("Fire connect succeed");
|
|
|
|
|
return Connected;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="sn"></param>
|
|
|
|
|
/// <param name="destAddr"></param>
|
|
|
|
|
public void SessionAttr(string sn)
|
|
|
|
|
{
|
|
|
|
|
ChannelUtils.AddAttr(Channel, FireConst.FireSn, sn);
|
|
|
|
|
ChannelUtils.AddAttr(Channel, FireConst.EqmTypeNo, sn);
|
|
|
|
|
ChannelUtils.AddAttr(Channel, FireConst.EqmCode, sn);
|
|
|
|
|
}
|
|
|
|
|
}
|