CarController条件

master
CZ 6 months ago
parent cb55e15c52
commit 0c65da76da

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

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

Loading…
Cancel
Save