|
|
@ -1,9 +1,7 @@
|
|
|
|
using HybirdFrameworkDriver.Session;
|
|
|
|
using log4net;
|
|
|
|
using log4net;
|
|
|
|
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
using Service.Car.Server;
|
|
|
|
|
|
|
|
using Service.TBox.Msg.Host;
|
|
|
|
|
|
|
|
using Service.TBox.Server;
|
|
|
|
using Service.TBox.Server;
|
|
|
|
|
|
|
|
using WebStarter.Dto.Resp;
|
|
|
|
|
|
|
|
|
|
|
|
namespace WebStarter.Controllers;
|
|
|
|
namespace WebStarter.Controllers;
|
|
|
|
|
|
|
|
|
|
|
@ -17,36 +15,96 @@ public class TBoxController : ControllerBase
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(TBoxController));
|
|
|
|
private static readonly ILog Log = LogManager.GetLogger(typeof(TBoxController));
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 加锁
|
|
|
|
/// 连接车辆
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="carNo">vin码</param>
|
|
|
|
/// <param name="carNo">vin码</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpGet("/connect/{carNo}")]
|
|
|
|
|
|
|
|
public bool Connect(string carNo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
Log.Info($"Connect-{carNo}");
|
|
|
|
|
|
|
|
TBoxServerMgr.Server.StartSendVin(carNo);
|
|
|
|
|
|
|
|
return TBoxServerMgr.Server != null && TBoxServerMgr.Server.Connected;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 加锁
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="carNo">vin码</param>
|
|
|
|
|
|
|
|
/// <returns>"0:未解锁未上锁 1:解锁成功 2:上锁成功 3:无效数据 其他状态无效" </returns>
|
|
|
|
[HttpGet("/lock/{carNo}")]
|
|
|
|
[HttpGet("/lock/{carNo}")]
|
|
|
|
public bool Lock()
|
|
|
|
public int Lock(string carNo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"Lock");
|
|
|
|
Log.Info($"Lock");
|
|
|
|
return false;
|
|
|
|
TBoxServerMgr.Server?.StartSendLock(1);
|
|
|
|
|
|
|
|
return TBoxServerMgr.Server?.LockStatusMsg?.LockStatus ?? 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 解锁
|
|
|
|
/// 解锁
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="carNo">vin码</param>
|
|
|
|
/// <param name="carNo">vin码</param>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns>发送状态</returns>
|
|
|
|
[HttpGet("/unLock/{carNo}")]
|
|
|
|
[HttpGet("/unLock/{carNo}")]
|
|
|
|
public bool UnLock(string carNo)
|
|
|
|
public int UnLock(string carNo)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"UnLock {carNo}");
|
|
|
|
Log.Info($"UnLock {carNo}");
|
|
|
|
return false;
|
|
|
|
TBoxServerMgr.Server?.StartSendLock(2);
|
|
|
|
|
|
|
|
return TBoxServerMgr.Server?.LockStatusMsg?.LockStatus ?? 100;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// <summary>
|
|
|
|
/// 重启
|
|
|
|
/// 获取车辆信息
|
|
|
|
/// </summary>
|
|
|
|
/// </summary>
|
|
|
|
/// <returns></returns>
|
|
|
|
/// <returns></returns>
|
|
|
|
[HttpGet("/Restart")]
|
|
|
|
[HttpGet("/getCarInfo/{carNo}")]
|
|
|
|
public bool Restart()
|
|
|
|
public TBoxInfo GetCarInfo()
|
|
|
|
{
|
|
|
|
{
|
|
|
|
Log.Info($"Restart");
|
|
|
|
Log.Info($"Restart");
|
|
|
|
return false;
|
|
|
|
TBoxInfo result = new TBoxInfo()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
BatteryOneSn = TBoxServerMgr.Server?.BatteryOneSn,
|
|
|
|
|
|
|
|
BatteryTwoSn = TBoxServerMgr.Server?.BatteryTwoSn,
|
|
|
|
|
|
|
|
BatteryThreeSn = TBoxServerMgr.Server?.BatteryThreeSn,
|
|
|
|
|
|
|
|
BatteryFourSn = TBoxServerMgr.Server?.BatteryFourSn,
|
|
|
|
|
|
|
|
BatteryInfo1 = TBoxServerMgr.Server?.BatteryInfo1,
|
|
|
|
|
|
|
|
LockStatusMsg = TBoxServerMgr.Server?.LockStatusMsg,
|
|
|
|
|
|
|
|
SocMsg = TBoxServerMgr.Server?.SocMsg,
|
|
|
|
|
|
|
|
SohMsg = TBoxServerMgr.Server?.SohMsg,
|
|
|
|
|
|
|
|
StatusMsg = TBoxServerMgr.Server?.StatusMsg,
|
|
|
|
|
|
|
|
SubMileMsg = TBoxServerMgr.Server?.SubMileMsg,
|
|
|
|
|
|
|
|
TotalMileMsg = TBoxServerMgr.Server?.TotalMileMsg,
|
|
|
|
|
|
|
|
VersionMsg = TBoxServerMgr.Server?.VersionMsg,
|
|
|
|
|
|
|
|
RestartMsg = TBoxServerMgr.Server?.RestartMsg,
|
|
|
|
|
|
|
|
Vin = TBoxServerMgr.Server?.ReadVin(),
|
|
|
|
|
|
|
|
CarConnected = TBoxServerMgr.Server != null && TBoxServerMgr.Server.Connected,
|
|
|
|
|
|
|
|
TBoxConnected = TBoxServerMgr.Server != null
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// 断开连接
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="carNo">vin码</param>
|
|
|
|
|
|
|
|
/// <returns>发送状态</returns>
|
|
|
|
|
|
|
|
[HttpGet("/disConnect/{carNo}")]
|
|
|
|
|
|
|
|
public bool DisConnect(string carNo)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TBoxServerMgr.Server?.StartSendLock(0);
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
|
|
/// Reset
|
|
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
|
|
/// <param name="carNo">vin码</param>
|
|
|
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
|
|
|
[HttpGet("/reset")]
|
|
|
|
|
|
|
|
public bool Reset()
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
TBoxServerMgr.Server?.Reset();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|