|
|
using Entity.Api.Req;
|
|
|
using Entity.Api.Resp;
|
|
|
using Entity.Constant;
|
|
|
using HybirdFrameworkCore.Entity;
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
using Service.Execute;
|
|
|
using Service.Init;
|
|
|
using Service.Plc.Client;
|
|
|
using Service.Station;
|
|
|
|
|
|
namespace WebStarter.Controllers;
|
|
|
|
|
|
/// <summary>
|
|
|
/// 换电大屏
|
|
|
/// </summary>
|
|
|
[ApiController]
|
|
|
[Route("api/[controller]")]
|
|
|
public class SwapMonitorController : ControllerBase
|
|
|
{
|
|
|
private readonly MonitorService? _swapMonitorService;
|
|
|
|
|
|
public SwapMonitorController(MonitorService? swapMonitorService)
|
|
|
{
|
|
|
_swapMonitorService = swapMonitorService;
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取设备连接状态 目前 Tbox 云平台 plc
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("GetDeviceState")]
|
|
|
public async Task<Result<DeviceStateResp>> GetDeviceState()
|
|
|
{
|
|
|
return _swapMonitorService.GetDeviceState();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 首页换电状态信息
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("GetSwapMonitorData")]
|
|
|
public async Task<Result<SwapMonitorScreenResp>> GetSwapMonitorData()
|
|
|
{
|
|
|
return _swapMonitorService.GetSwapMonitorData();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取模式类
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("GetModel")]
|
|
|
public async Task<Result<SwapModelResp>> GetModel()
|
|
|
{
|
|
|
return _swapMonitorService.GetModel();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 获取充电监控大屏 充电次数 每五分钟获取一次
|
|
|
/// </summary>
|
|
|
[HttpPost("GetSwapAndChargingCount")]
|
|
|
public async Task<Result<SwapAndChargingCountResp>> SwapAndChargingCount()
|
|
|
{
|
|
|
return _swapMonitorService.SwapAndChargingCount();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置换电模式:1:本地换电 2:远程换电
|
|
|
/// </summary>
|
|
|
[HttpPost("SetSwapModel/{swapModel}")]
|
|
|
public async Task<Result<bool>> SetSwapModel(int swapModel)
|
|
|
{
|
|
|
StaticStationInfo.StationModel = swapModel;
|
|
|
return Result<bool>.Success();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 设置换电方式:1:自动换电 2:手动换电
|
|
|
/// </summary>
|
|
|
[HttpPost("SetSwapWay/{swapWay}")]
|
|
|
public async Task<Result<bool>> SetSwapWay(int stationSwapWay)
|
|
|
{
|
|
|
StaticStationInfo.StationWay = stationSwapWay;
|
|
|
return Result<bool>.Success();
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 换电复位
|
|
|
/// </summary>
|
|
|
[HttpPost("SwapReset")]
|
|
|
public async Task<Result<bool>> SwapReset()
|
|
|
{
|
|
|
StationSoftMgr.SwappingStateMachineCancel();
|
|
|
|
|
|
return Result<bool>.Success();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 红绿灯操控
|
|
|
/// 0:无颜色
|
|
|
/// 1000:绿灯
|
|
|
/// 1010:绿灯闪烁
|
|
|
/// 1020:红灯
|
|
|
/// 1030:红灯闪烁
|
|
|
/// 1040:黄灯
|
|
|
/// 1050:黄灯闪烁
|
|
|
/// 1100:所有灯亮
|
|
|
/// </summary>
|
|
|
/// <param name="lampCmd"></param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("OperateOutstationLamp")]
|
|
|
public async Task<Result<bool>> OperateOutstationLamp(byte lampCmd)
|
|
|
{
|
|
|
return PlcMgr.WriteEntranceLamp(lampCmd) ? Result<bool>.Success(true) : Result<bool>.Fail();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 灯光控制:全部关闭
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("AllLightsOff")]
|
|
|
public async Task<Result<bool>> AllLightsOff()
|
|
|
{
|
|
|
return Result<bool>.Success(PlcMgr.AllLightsOff());
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 灯光控制:全部打开
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("AllLightsOn")]
|
|
|
public async Task<Result<bool>> AllLightsOn()
|
|
|
{
|
|
|
return Result<bool>.Success(PlcMgr.AllLightsOn());
|
|
|
}
|
|
|
/// <summary>
|
|
|
///
|
|
|
/// </summary>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("GetNowLightsOn")]
|
|
|
public async Task<Result<ushort>> GetNowLightsOn()
|
|
|
{
|
|
|
return Result<ushort>.Success(PlcMgr.GetNowLightsOn());
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 消防移仓
|
|
|
/// </summary>
|
|
|
/// <param name="entrySelet">入仓位选择:0-无操作、1-缓存位舱位号、2-20:电池存储仓位</param>
|
|
|
/// <returns></returns>
|
|
|
[HttpPost("FireProtectionRelocation/{entrySelet}")]
|
|
|
public async Task<Result<bool>> FireProtectionRelocation(ushort entrySelet)
|
|
|
{
|
|
|
return Result<bool>.Success(PlcMgr.FireProtectionRelocation(entrySelet));
|
|
|
}
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
/// 换电大屏 换电成功 按钮 status :1成功 2:失败
|
|
|
/// </summary>
|
|
|
/// <param name="swapNo"></param>
|
|
|
/// <returns></returns>
|
|
|
/*[HttpGet("ManualSwapStatus/{swapNo}/{status}")]
|
|
|
public async Task<Result<bool>> ManualChangeSuccess(string swapNo, int status)
|
|
|
{
|
|
|
return Result<bool>.Success();
|
|
|
}*/
|
|
|
|
|
|
/// <summary>
|
|
|
/// 切换成 手动换电
|
|
|
/// </summary>
|
|
|
[HttpPost("ManualSwapping")]
|
|
|
public Result<bool> ManualSwapping()
|
|
|
{
|
|
|
StaticStationInfo.StationWay = (int)StationConstant.StationWay.Manual;
|
|
|
return Result<bool>.Success();
|
|
|
}
|
|
|
|
|
|
/// <summary>
|
|
|
/// 切换成 自动换电
|
|
|
/// </summary>
|
|
|
[HttpPost("AutoSwapping")]
|
|
|
public Result<bool> AutoSwapping()
|
|
|
{
|
|
|
StaticStationInfo.StationWay = (int)StationConstant.StationWay.Auto;
|
|
|
return Result<bool>.Success();
|
|
|
}
|
|
|
} |