CarController条件

master
CZ 6 months ago
parent cb55e15c52
commit 0c65da76da

@ -14,7 +14,7 @@ public class CarServer : TcpServer<IBaseHandler, Decoder, Encoder>
/// 客户端连接状态 /// 客户端连接状态
/// </summary> /// </summary>
public bool Connected { get; set; } public bool Connected { get; set; }
public string? CarNo { get; set; } public string? CarNo { get; set; }
public HeartBeatMsg? HeartBeatMsg { get; set; } public HeartBeatMsg? HeartBeatMsg { get; set; }
@ -22,7 +22,7 @@ public class CarServer : TcpServer<IBaseHandler, Decoder, Encoder>
/// <summary> /// <summary>
/// 1 待机 2 换电 /// 1 待机 2 换电
/// </summary> /// </summary>
public byte StationStatus { get; set; } public byte StationStatus { get; set; } = 1;
/// <summary> /// <summary>
/// 度电数据车载设备连接上换电站的 Wifi 网络时,主动上送度电数据报文(命令代码: 0x01发送周期 60s服务器回复相应的报文(命令代码0x02) /// 度电数据车载设备连接上换电站的 Wifi 网络时,主动上送度电数据报文(命令代码: 0x01发送周期 60s服务器回复相应的报文(命令代码0x02)
@ -37,7 +37,7 @@ public class CarServer : TcpServer<IBaseHandler, Decoder, Encoder>
public CarServer() : base() public CarServer() : base()
{ {
this.ChannelInActiveAction = Clean; this.ChannelInActiveAction = Clean;
this.LogLevel = DotNetty.Handlers.Logging.LogLevel.TRACE; this.LogLevel = DotNetty.Handlers.Logging.LogLevel.INFO;
} }
/// <summary> /// <summary>

@ -26,7 +26,7 @@ public class CarController : ControllerBase
{ {
CarInfoResp carInfoResp = new CarInfoResp() CarInfoResp carInfoResp = new CarInfoResp()
{ {
Connected = CarServerMgr.CarServer?.Connected ?? false, Connected = CarServerMgr.CarServer != null && CarServerMgr.CarServer.Connected,
CarNo = CarServerMgr.CarServer?.HeartBeatMsg?.CarNo, CarNo = CarServerMgr.CarServer?.HeartBeatMsg?.CarNo,
ElecMsg = CarServerMgr.CarServer?.ElecMsg, ElecMsg = CarServerMgr.CarServer?.ElecMsg,
HeartBeatMsg = CarServerMgr.CarServer?.HeartBeatMsg HeartBeatMsg = CarServerMgr.CarServer?.HeartBeatMsg
@ -38,55 +38,63 @@ public class CarController : ControllerBase
/// 锁车 /// 锁车
/// </summary> /// </summary>
/// <returns>发送结果</returns> /// <returns>发送结果</returns>
[HttpGet("/lock")] [HttpGet("/lock/{carNo}")]
public bool Lock() public bool Lock(string carNo)
{ {
Log.Info("Lock "); Log.Info("Lock ");
if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) if (CarServerMgr.CarServer == null || !CarServerMgr.CarServer.Connected)
{ {
return false; return false;
} }
CarServerMgr.CarServer.LockMsgResp = null; CarServerMgr.CarServer.LockMsgResp = null;
SessionMgr.Broadcast(new LockMsg()); SessionMgr.Broadcast(new LockMsg()
{
CarNo = carNo
});
return true; return true;
} }
/// <summary> /// <summary>
/// 解锁 ///
/// </summary> /// </summary>
/// <returns>发送结果</returns> /// <param name="carNo"></param>
[HttpGet("/unLock")] /// <returns></returns>
public bool UnLock() [HttpGet("/unLock/{carNo}")]
public bool UnLock(string carNo)
{ {
Log.Info("UnLock "); Log.Info("UnLock ");
if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) if (CarServerMgr.CarServer == null || !CarServerMgr.CarServer.Connected)
{ {
return false; return false;
} }
CarServerMgr.CarServer.UnLockMsgResp = null; CarServerMgr.CarServer.UnLockMsgResp = null;
SessionMgr.Broadcast(new UnLockMsg()); SessionMgr.Broadcast(new UnLockMsg()
{
CarNo = carNo
});
return true; return true;
} }
/// <summary> /// <summary>
/// 结算 ///
/// </summary> /// </summary>
/// <returns>发送结果</returns> /// <param name="carNo"></param>
[HttpGet("/SettleConfirm")] /// <returns></returns>
public bool SettleConfirm() [HttpGet("/SettleConfirm/{carNo}")]
public bool SettleConfirm(string carNo)
{ {
Log.Info("SettleConfirm "); Log.Info("SettleConfirm ");
if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) if (CarServerMgr.CarServer == null || !CarServerMgr.CarServer.Connected)
{ {
return false; return false;
} }
CarServerMgr.CarServer.SettleConfirmMsgResp = null; CarServerMgr.CarServer.SettleConfirmMsgResp = null;
SessionMgr.Broadcast(new SettleConfirmMsg()); SessionMgr.Broadcast(new SettleConfirmMsg() { CarNo = carNo });
return true; return true;
} }
@ -99,7 +107,7 @@ public class CarController : ControllerBase
public bool SetParam(SetParam setParam) public bool SetParam(SetParam setParam)
{ {
Log.Info("SetParam"); Log.Info("SetParam");
if (CarServerMgr.CarServer == null || (CarServerMgr.CarServer?.Connected ?? false)) if (CarServerMgr.CarServer == null || !CarServerMgr.CarServer.Connected)
{ {
return false; return false;
} }

Loading…
Cancel
Save