|
|
|
|
using HybirdFrameworkCore.Autofac.Attribute;
|
|
|
|
|
using HybirdFrameworkDriver.Common;
|
|
|
|
|
using HybirdFrameworkDriver.TcpServer;
|
|
|
|
|
using Service.Car.Codec;
|
|
|
|
|
using Service.Car.Handler;
|
|
|
|
|
using Service.Car.Msg.Car.Req;
|
|
|
|
|
using Service.Car.Msg.Car.Resp;
|
|
|
|
|
using Service.Car.Msg.Host.Req;
|
|
|
|
|
|
|
|
|
|
namespace Service.Car.Server;
|
|
|
|
|
|
|
|
|
|
[Scope("SingleInstance")]
|
|
|
|
|
public class CarServer : TcpServer<IBaseHandler, Decoder, Encoder>
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 客户端连接状态
|
|
|
|
|
/// </summary>
|
|
|
|
|
public bool Connected { get; set; }
|
|
|
|
|
|
|
|
|
|
public string? CarNo { get; set; }
|
|
|
|
|
|
|
|
|
|
public MsgPair<LockMsg, LockMsgResp> LockMsgPair { get; set; } = new ();
|
|
|
|
|
|
|
|
|
|
public MsgPair<UnLockMsg, UnLockMsgResp> UnLockMsgPair { get; set; } = new ();
|
|
|
|
|
|
|
|
|
|
public MsgPair<SetParamMsg, SetParamMsgResp> SetParamMsgPair { get; set; } = new ();
|
|
|
|
|
|
|
|
|
|
public MsgPair<SettleConfirmMsg, SettleConfirmMsgResp> SettleConfirmMsgPair { get; set; } = new ();
|
|
|
|
|
public HeartBeatMsg? HeartBeatMsg { get; set; }
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 1 待机 2 换电
|
|
|
|
|
/// </summary>
|
|
|
|
|
public byte StationStatus { get; set; } = 1;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 度电数据车载设备连接上换电站的 Wifi 网络时,主动上送度电数据报文(命令代码: 0x01),发送周期 60s,服务器回复相应的报文(命令代码:0x02)
|
|
|
|
|
/// </summary>
|
|
|
|
|
public ElecMsg? ElecMsg { get; set; }
|
|
|
|
|
|
|
|
|
|
public CarServer() : base()
|
|
|
|
|
{
|
|
|
|
|
this.ChannelInActiveAction = Clean;
|
|
|
|
|
this.LogLevel = DotNetty.Handlers.Logging.LogLevel.INFO;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// 清理数据
|
|
|
|
|
/// </summary>
|
|
|
|
|
public void Clean()
|
|
|
|
|
{
|
|
|
|
|
Connected = false;
|
|
|
|
|
CarNo = null;
|
|
|
|
|
HeartBeatMsg = null;
|
|
|
|
|
ElecMsg = null;
|
|
|
|
|
LockMsgPair.ClearResp();
|
|
|
|
|
UnLockMsgPair.ClearResp();
|
|
|
|
|
SetParamMsgPair.ClearResp();
|
|
|
|
|
SettleConfirmMsgPair.ClearResp();
|
|
|
|
|
}
|
|
|
|
|
}
|