using Entity.Api.Resp;
using Entity.Constant;
using HybirdFrameworkCore.Entity;
using Microsoft.AspNetCore.Mvc;
using Service.Execute;
using Service.Execute.Api;
using Service.Init;
using Service.Plc.Client;
using Service.Station;
namespace WebStarter.Controllers;
///
/// 换电大屏
///
[ApiController]
[Route("api/[controller]")]
public class SwapMonitorController : ControllerBase
{
private readonly MonitorService _swapMonitorService;
private readonly BinInfoService _binInfoService;
public SwapMonitorController(MonitorService swapMonitorService, BinInfoService binInfoService)
{
_swapMonitorService = swapMonitorService;
_binInfoService = binInfoService;
}
///
/// 获取设备连接状态 目前 Tbox 云平台 plc
///
///
[HttpPost("GetDeviceState")]
public async Task> GetDeviceState()
{
return _swapMonitorService.GetDeviceState();
}
///
/// 首页换电状态信息
///
///
[HttpPost("GetSwapMonitorData")]
public async Task> GetSwapMonitorData()
{
return _swapMonitorService.GetSwapMonitorData();
}
///
/// 获取模式类
///
///
[HttpPost("GetModel")]
public async Task> GetModel()
{
return _swapMonitorService.GetModel();
}
///
/// 车辆手动上锁解锁
///
///
[HttpPost("LockCar")]
public async Task> LockCar()
{
if (StationSoftMgr.SwappingStateMachine.RfidReadModel == null)
{
return Result.Fail("暂无车辆");
}
var success = await TBoxApi.LockCarManyTimes(StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo);
return success ? Result.Success() : Result.Fail();
}
///
/// 车辆手动解锁
///
///
[HttpPost("UnLockCar")]
public async Task> UnLockCar()
{
if (StationSoftMgr.SwappingStateMachine.RfidReadModel == null)
{
return Result.Fail("暂无车辆");
}
var success = await TBoxApi.UnLockCarManyTimes(StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo);
return success ? Result.Success() : Result.Fail();
}
///
/// 获取充电监控大屏 充电次数 每五分钟获取一次
///
[HttpPost("GetSwapAndChargingCount")]
public async Task> SwapAndChargingCount()
{
return _swapMonitorService.SwapAndChargingCount();
}
///
/// 设置换电模式:1:本地换电 2:远程换电
///
[HttpPost("SetSwapModel/{swapModel}")]
public async Task> SetSwapModel(int swapModel)
{
StaticStationInfo.StationModel = swapModel;
return Result.Success();
}
///
/// 换电复位
///
[HttpPost("SwapReset")]
public async Task> SwapReset()
{
StationSoftMgr.SwappingStateMachineCancel();
return Result.Success();
}
///
/// 红绿灯操控
/// 0:无颜色
/// 1000:绿灯
/// 1010:绿灯闪烁
/// 1020:红灯
/// 1030:红灯闪烁
/// 1040:黄灯
/// 1050:黄灯闪烁
/// 1100:所有灯亮
///
///
///
[HttpPost("OperateOutstationLamp")]
public async Task> OperateOutstationLamp(byte lampCmd)
{
return PlcMgr.WriteEntranceLamp(lampCmd) ? Result.Success(true) : Result.Fail();
}
///
/// 灯光控制:全部关闭
///
///
[HttpPost("AllLightsOff")]
public async Task> AllLightsOff()
{
return PlcMgr.AllLightsOff() ? Result.Success(true) : Result.Fail();
}
///
/// 灯光控制:全部打开
///
///
[HttpPost("AllLightsOn")]
public async Task> AllLightsOn()
{
return PlcMgr.AllLightsOn() ? Result.Success(true) : Result.Fail();
}
///
/// 得到现在灯光状态
///
///
[HttpPost("GetNowLightsOn")]
public async Task> GetNowLightsOn()
{
return Result.Success(PlcMgr.GetNowLightsOn());
}
///
/// 消防移仓
///
/// 入仓位选择:移仓仓位号
///
[HttpPost("FireProtectionRelocation/{entrySelect}")]
public Result FireProtectionRelocation(string entrySelect)
{
return _binInfoService.FireProtectionRelocation(entrySelect);
}
///
/// 换电大屏 换电成功 按钮 status :1成功 2:失败
///
///
///
/*[HttpGet("ManualSwapStatus/{swapNo}/{status}")]
public async Task> ManualChangeSuccess(string swapNo, int status)
{
return Result.Success();
}*/
///
/// 切换成 手动换电
///
[HttpPost("ManualSwapping")]
public Result ManualSwapping()
{
StaticStationInfo.StationWay = (int)StationConstant.StationWay.Manual;
return Result.Success();
}
///
/// 切换成 自动换电
///
[HttpPost("AutoSwapping")]
public Result AutoSwapping()
{
StaticStationInfo.StationWay = (int)StationConstant.StationWay.Auto;
return Result.Success();
}
///
/// 切换成 营业状态
/// 换电站状态: 1:营运中 2:歇业中 3:设备维护状态 4:暂停营业
///
[HttpPost("HandoverStationStatus/{status}")]
public Result HandoverStationStatus(int status)
{
StaticStationInfo.StationStatus = status;
return Result.Success();
}
}