diff --git a/Service/BusinessTask/MyTask/BatteryMoveTask.cs b/Service/BusinessTask/MyTask/BatteryMoveTask.cs index 794560d..1e8558c 100644 --- a/Service/BusinessTask/MyTask/BatteryMoveTask.cs +++ b/Service/BusinessTask/MyTask/BatteryMoveTask.cs @@ -2,6 +2,7 @@ using Autofac; using Entity.Constant; using Entity.DbModel.Station; using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.AutoTask; using HybirdFrameworkCore.Entity; using log4net; using Repository.Station; @@ -16,62 +17,85 @@ namespace Service.BusinessTask.MyTask; /// /// 电池移仓任务 /// -public class BatteryMoveTask : AbstractTaskHandler +public class BatteryMoveTask : ITask { private static readonly ILog Log = LogManager.GetLogger(typeof(BatteryMoveTask)); - - private readonly BinInfoRepository _binInfoRepository = - AppInfo.Container.Resolve(); + public BinInfoRepository _binInfoRepository { get; set; } - private readonly MonitorService _monitorService = - AppInfo.Container.Resolve(); + public MonitorService _monitorService { get; set; } - protected override int Interval() + + private volatile bool _stop; + + + public string Name() + { + return "BatteryMoveTask"; + } + + public int Interval() { - return 20 * 1000; + return 1000 * 20; } - /// - /// 自动移仓 当缓存仓没有电池的时候 如果有电池充满了 就移仓 - /// - protected override void Handle() + public void Handle() { - var cacheBin = _binInfoRepository.QueryByClause(i => i.CacheBinFlag == 1); - if (cacheBin.Exists == 1) + try { - return; - } + var cacheBin = _binInfoRepository.QueryByClause(i => i.CacheBinFlag == 1); + if (cacheBin.Exists == 1) + { + return; + } - List queryListByClause = _binInfoRepository.QueryListByClause(i => i.ChargeStatus == 4 && i.CacheBinFlag==0, "battery_enter_seq asc"); + List queryListByClause = + _binInfoRepository.QueryListByClause(i => i.ChargeStatus == 4 && i.CacheBinFlag == 0, + "battery_enter_seq asc"); - if (queryListByClause.Count<=0) - { - return; - } + if (queryListByClause.Count <= 0) + { + return; + } - var binInfo = queryListByClause[0]; + var binInfo = queryListByClause[0]; - Result success = _monitorService.BatteryRelocation(ushort.Parse(binInfo.No), ushort.Parse(cacheBin.No)); + Result success = + _monitorService.BatteryRelocation(ushort.Parse(binInfo.No), ushort.Parse(cacheBin.No)); - //查询人物状态 - if (success.IsSuccess) - { - bool readPlcTaskStatus9000 = false; - while (!readPlcTaskStatus9000) + //查询人物状态 + if (success.IsSuccess) { - Thread.Sleep(1000); - readPlcTaskStatus9000 = PlcMgr.ReadPlcTaskStatus() == 9000; - } + bool readPlcTaskStatus9000 = false; + while (!readPlcTaskStatus9000) + { + Thread.Sleep(1000); + readPlcTaskStatus9000 = PlcMgr.ReadPlcTaskStatus() == 9000; + } - Log.Info($"execute BatteryMoveTask success from binNo ={binInfo.No}"); + Log.Info($"execute BatteryMoveTask success from binNo ={binInfo.No}"); + } + } + catch (Exception e) + { + Log.Error($" SwapOrderReportCloudTask err e={e}"); } } - protected override string Name() + public bool Stoped() + { + return _stop; + } + + public void Stop() + { + _stop = true; + } + + public void ResetStop() { - return "SwapOrderReportCloudTask"; + _stop = false; } } \ No newline at end of file diff --git a/Service/BusinessTask/MyTask/SwapOrderReportCloudTask.cs b/Service/BusinessTask/MyTask/SwapOrderReportCloudTask.cs index 57bbb66..1a978e2 100644 --- a/Service/BusinessTask/MyTask/SwapOrderReportCloudTask.cs +++ b/Service/BusinessTask/MyTask/SwapOrderReportCloudTask.cs @@ -1,12 +1,8 @@ -using Autofac; -using Entity.Constant; using Entity.DbModel.Station; -using HybirdFrameworkCore.Autofac; +using HybirdFrameworkCore.Autofac.Attribute; +using HybirdFrameworkCore.AutoTask; using log4net; using Repository.Station; -using Service.Execute; -using Service.Execute.Api; -using Service.Execute.Model; using Service.Mgr; namespace Service.BusinessTask.MyTask; @@ -14,30 +10,52 @@ namespace Service.BusinessTask.MyTask; /// /// 充电结束上报云平台task /// -public class SwapOrderReportCloudTask : AbstractTaskHandler +[Scope] +public class SwapOrderReportCloudTask : ITask { private static readonly ILog Log = LogManager.GetLogger(typeof(SwapOrderReportCloudTask)); - private readonly SwapOrderReportCloudRepository _reportCloudRepository = - AppInfo.Container.Resolve(); + private volatile bool _stop; + public SwapOrderReportCloudRepository? ReportCloudRepository { get; set; } - private readonly SwapOrderMgr _swapOrderMgr = - AppInfo.Container.Resolve(); + public SwapOrderMgr? SwapOrderMgr { get; set; } - protected override int Interval() + public string Name() { - return 20 * 1000; + return "SwapOrderReportCloudTask"; } - protected override void Handle() + public int Interval() { - List list = _reportCloudRepository.QueryListByClause(i => i.CloudReportStatus == 0); + return 1000 * 20; + } - _swapOrderMgr.UploadCloud(list); + public void Handle() + { + try + { + List list = ReportCloudRepository.QueryListByClause(i => i.CloudReportStatus == 0); + + SwapOrderMgr.UploadCloud(list); + } + catch (Exception e) + { + Log.Error($" SwapOrderReportCloudTask err e={e}"); + } } - protected override string Name() + public bool Stoped() { - return "SwapOrderReportCloudTask"; + return _stop; + } + + public void Stop() + { + _stop = true; + } + + public void ResetStop() + { + _stop = false; } } \ No newline at end of file diff --git a/Service/Execute/Api/RfidApi.cs b/Service/Execute/Api/RfidApi.cs index a8922ef..5867831 100644 --- a/Service/Execute/Api/RfidApi.cs +++ b/Service/Execute/Api/RfidApi.cs @@ -7,18 +7,19 @@ namespace Service.Execute.Api; public class RfidApi { private static readonly ILog Log = LogManager.GetLogger(typeof(RfidApi)); + //TODO::Rfid 服务地址 - private static readonly string BASE_URL = "http://localhost:7243"; + private static readonly string BASE_URL = "http://localhost:5037"; private static readonly HttpClient _httpClient = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) }; - + public static async Task BeginRead() { Log.Info("BeginRead"); - /*string url = BASE_URL + "/Api/BeginRead"; + string url = BASE_URL + "/Api/BeginRead"; try { string s = await _httpClient.GetStringAsync(url); @@ -27,17 +28,16 @@ public class RfidApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"RfidApi BeginRead err e={e}"); return false; - }*/ - return true; + } } public static async Task StopRead() { Log.Info("StopRead"); string url = BASE_URL + "/Api/StopRead"; - /*try + try { string s = await _httpClient.GetStringAsync(url); Log.Info($"StopRead resp = {s}"); @@ -45,16 +45,15 @@ public class RfidApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"RfidApi StopRead err e={e}"); return false; - }*/ - return true; + } } public static async Task ReadRifd() { Log.Info("ReadRifd"); - /*string url = BASE_URL + "/Api/ReadRfidData"; + string url = BASE_URL + "/Api/ReadRfidData"; try { string s = await _httpClient.GetStringAsync(url); @@ -70,16 +69,10 @@ public class RfidApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"RfidApi ReadRifd err e={e}"); return null; - }*/ + } - return new RfidReadModel() - { - VelVin = "LC1HMYBF6R0004575", - VelNo = "LC1HMYBF6R0004575", - - }; + return null; } - } \ No newline at end of file diff --git a/Service/Execute/Api/TboxApi.cs b/Service/Execute/Api/TboxApi.cs index 203fff4..9fa0cc5 100644 --- a/Service/Execute/Api/TboxApi.cs +++ b/Service/Execute/Api/TboxApi.cs @@ -9,20 +9,20 @@ public class TBoxApi { private static readonly ILog Log = LogManager.GetLogger(typeof(TBoxApi)); - //TODO::TBox 服务地址 private static readonly string BASE_URL = "http://localhost:5036"; private static int _times = 5; private static int _successTimes = 3; + private static readonly HttpClient _httpClient = new HttpClient() { Timeout = TimeSpan.FromSeconds(60) }; - public static async Task GetCarInfo() + public static async Task GetCarInfo(string carNo) { Log.Info("GetCarInfo"); - string url = BASE_URL + "/getCarInfo"; + string url = BASE_URL + "/getCarInfo/" + carNo; try { string s = await _httpClient.GetStringAsync(url); @@ -37,15 +37,15 @@ public class TBoxApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"GetCarInfo e = {e}"); return null; } } - public static async Task Reset() + public static async Task Reset(string carNo) { Log.Info("Reset"); - string url = BASE_URL + "/Clear"; + string url = BASE_URL + "/Clear/" + carNo; try { string s = await _httpClient.GetStringAsync(url); @@ -55,15 +55,15 @@ public class TBoxApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"Reset e = {e}"); return false; } } - public static async Task IsConnected() + public static async Task IsConnected(string carNo) { Log.Info("IsConnected"); - string url = BASE_URL + "/getCarInfo"; + string url = BASE_URL + "/getCarInfo/"+carNo; try { string s = await _httpClient.GetStringAsync(url); @@ -78,7 +78,7 @@ public class TBoxApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"IsConnected e = {e}"); return false; } } @@ -93,16 +93,13 @@ public class TBoxApi var unLockCar = await UnLockCar(carNo); if (unLockCar) { - bools.Add(unLockCar); } - } return bools.Select(i => i).Count() > _successTimes; - } - + public static async Task LockCarManyTimes(string carNo) { List bools = new List(); @@ -112,13 +109,11 @@ public class TBoxApi var unLockCar = await LockCar(carNo); if (unLockCar) { - bools.Add(unLockCar); } } return bools.Select(i => i).Count() > _successTimes; - } /// @@ -128,7 +123,7 @@ public class TBoxApi public static async Task UnLockCar(string carNo) { Log.Info("UnLockCar"); - string url = BASE_URL + "/unLock/"+carNo; + string url = BASE_URL + "/unLock/" + carNo; try { string s = await _httpClient.GetStringAsync(url); @@ -139,11 +134,34 @@ public class TBoxApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"UnLockCar e = {e}"); return false; } } + public static async Task> GetCarInfoList() + { + Log.Info("GetCarInfoList"); + string url = BASE_URL + "/getCarInfoList" ; + try + { + string s = await _httpClient.GetStringAsync(url); + List? tboxCarInfoModels = null; + if (!String.IsNullOrWhiteSpace(s)) + { + tboxCarInfoModels = JsonConvert.DeserializeObject>(s); + } + + Log.Info($"GetCarInfoList resp = {tboxCarInfoModels}"); + return tboxCarInfoModels; + } + catch (Exception e) + { + Log.Error($"GetCarInfoList e = {e}"); + return null; + } + } + /// /// 车辆上锁 /// @@ -151,7 +169,7 @@ public class TBoxApi public static async Task LockCar(string carNo) { Log.Info("LockCar"); - string url = BASE_URL + "/lock/"+carNo; + string url = BASE_URL + "/lock/" + carNo; try { string s = await _httpClient.GetStringAsync(url); @@ -162,7 +180,7 @@ public class TBoxApi } catch (Exception e) { - Console.WriteLine(e); + Log.Error($"LockCar e = {e}"); return false; } } diff --git a/Service/Execute/Model/RfidReadModel.cs b/Service/Execute/Model/RfidReadModel.cs index ff0dda1..82e4530 100644 --- a/Service/Execute/Model/RfidReadModel.cs +++ b/Service/Execute/Model/RfidReadModel.cs @@ -5,22 +5,13 @@ public class RfidReadModel /// /// 1:成功 0:失败 /// - public string Result { get; set; } + public int Result { get; set; } /// /// 车辆VIN码 /// public string VelVin { get; set; } - /// - /// 车辆电池包数 - /// - public string BattNum { set; get; } - - /// - /// 车辆配方-加解锁高度,整型,单位:mm - /// - public string VelRecp { set; get; } /// /// 车辆MAC地址 diff --git a/Service/Execute/StationSoftMgr.cs b/Service/Execute/StationSoftMgr.cs index fe21d77..0206095 100644 --- a/Service/Execute/StationSoftMgr.cs +++ b/Service/Execute/StationSoftMgr.cs @@ -9,33 +9,7 @@ namespace Service.Execute public class StationSoftMgr { public static readonly SwappingStateMachine SwappingStateMachine = SwappingStateMachine.GetInstance(); - - - private static readonly AbstractTaskHandler SwapOrderReportCloudTask = new SwapOrderReportCloudTask(); - private static readonly AbstractTaskHandler BatteryMoveTask = new BatteryMoveTask(); - - - #region Task - - /// - /// 启动task - /// - public static void StartTasks() - { - SwapOrderReportCloudTask.Start(); - BatteryMoveTask.Start(); - } - - /// - /// 停止task - /// - public static void StopTasks() - { - SwapOrderReportCloudTask.Stop(); - } - - #endregion Task - + #region 换电流程 diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index 012607c..a99d8a2 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -50,12 +50,12 @@ public class CarCtrlState : IState return Invoker.Invoke("UnLockCar", 500, 100, machine.IsCanceled, () => machine.VelUnlockFlag, () => { - Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelNo); + Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); bool unLock = result.Result; if (unLock) { //查询车辆锁止状态 - Task carInfo = TBoxApi.GetCarInfo(); + Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelNo); var resultHeartBeatMsg = carInfo.Result.HeartBeatMsg; if (resultHeartBeatMsg.LockStatus == 1 || resultHeartBeatMsg.LockStatus==0) { diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index 383bd41..277e510 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -100,7 +100,7 @@ public class CarPrepareState : IState return Invoker.Invoke("check CarInPosition", 500, 50, machine.IsCanceled, () => machine.VehiclesInPlaceFlag, () => { - var result = TBoxApi.GetCarInfo(); + var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); TboxCarInfoModel tboxCarInfoModel = result.Result; if (tboxCarInfoModel.HeartBeatMsg.KeyStatus == 0) @@ -161,6 +161,8 @@ public class CarPrepareState : IState machine.CloudVelCheckFlag = true; // machine.LedTool?.WriteProgramContent("换电准备中:云平台车辆验证完成"); + //TODO:: + // machine.SwapOrder.CloudSn= _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.CloudVelCheckFlag, machine); } @@ -187,7 +189,7 @@ public class CarPrepareState : IState return Invoker.Invoke("check TBox connect", 1000, 10, machine.IsCanceled, () => machine.BoxConnectFlag, () => { - Task result = TBoxApi.IsConnected(); + Task result = TBoxApi.IsConnected(machine.RfidReadModel.VelVin); bool isConnect = result.Result; if (isConnect) { @@ -213,7 +215,7 @@ public class CarPrepareState : IState return Invoker.Invoke("check TBox VelLocal", 1000, 20, machine.IsCanceled, () => machine.BoxLocalCheckFlag, () => { - Task carInfo = TBoxApi.GetCarInfo(); + Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); var tBoxCarInfoModel = carInfo.Result; //TODO::不知道Tbox给的CardNo是什么 if (tBoxCarInfoModel.CarNo!.Trim().Equals(machine.RfidReadModel!.VelNo.Trim())) @@ -238,7 +240,7 @@ public class CarPrepareState : IState return Invoker.Invoke("cloud TBox upload", 500, 20, machine.IsCanceled, () => machine.CloudTBoxFlag, () => { - Task result = TBoxApi.GetCarInfo(); + Task result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); TboxCarInfoModel tBoxCarInfoModel = result.Result; machine.BoxCarInfoModel = tBoxCarInfoModel; if (tBoxCarInfoModel != null) diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index 91e33b8..a033f0e 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -115,7 +115,7 @@ public class DoSwappingState : IState return Invoker.Invoke("UnLockCar", 1000, 5, machine.IsCanceled, () => machine.StartSwappingFlag, () => { - Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelNo); + Task result = TBoxApi.UnLockCarManyTimes(machine.RfidReadModel.VelVin); bool unLock = result.Result; if (unLock) { @@ -360,7 +360,7 @@ public class DoSwappingState : IState else if (channelStatus == 1020) { //需要移车 先解锁 提示移动车辆,等待3分钟 - var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelNo); + var lockCar = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin); if (lockCar.Result) { // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed()); @@ -404,7 +404,7 @@ public class DoSwappingState : IState return Invoker.Invoke("check CarInPosition2", 500, 50, machine.IsCanceled, () => machine.VehiclesInPlace2Flag, () => { - var result = TBoxApi.GetCarInfo(); + var result = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); TboxCarInfoModel tboxCarInfoModel = result.Result; if (tboxCarInfoModel.HeartBeatMsg.KeyStatus == 0) diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index a485342..b1d3191 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -207,7 +207,6 @@ public class StationReadyState : IState return Invoker.Invoke("read rfid", 1000, 20, machine.IsCanceled, () => machine.RfidReadFlag, () => { - //TODO::开始读rfid RfidService.BeginRead(); Task rfidReadModel = RfidApi.ReadRifd(); rfidReadModel.Wait(); if ( /*rfidReadModel.IsCompletedSuccessfully &&*/ rfidReadModel.Result != null) diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index b1ccd54..425c7b7 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -76,12 +76,12 @@ public class SwapDoneState : IState return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, () => machine.VelLockFlag, () => { - Task result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelNo); + Task result = TBoxApi.LockCarManyTimes(machine.RfidReadModel.VelVin); bool unLock = result.Result; if (unLock) { //查询车辆锁止状态 - Task carInfo = TBoxApi.GetCarInfo(); + Task carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin); if (carInfo.Result.HeartBeatMsg!.LockStatus == 2) { //设置出口的是绿灯 diff --git a/Service/Execute/SwappingStateMachine.cs b/Service/Execute/SwappingStateMachine.cs index d0dca18..8514feb 100644 --- a/Service/Execute/SwappingStateMachine.cs +++ b/Service/Execute/SwappingStateMachine.cs @@ -227,15 +227,19 @@ public class SwappingStateMachine : IDisposable { Log.Info("reset data"); ResetOrderAmtStatus(); - //wifi数据重置 - TBoxApi.Reset(); + if (RfidReadModel != null && RfidReadModel.VelNo != null) + { + //wifi数据重置 + TBoxApi.Reset(RfidReadModel.VelVin); + } + //重置所有小步状态 ResetStep(); ResetData(); //重置云平台下发的指令 - // CloudApi.ClearCarCanStartInfo(); + // CloudApi.ClearCarCanStartInfo(); } public bool Cancel() diff --git a/Service/Plc/Client/PlcMgr.cs b/Service/Plc/Client/PlcMgr.cs index 306de3a..73cf1a0 100644 --- a/Service/Plc/Client/PlcMgr.cs +++ b/Service/Plc/Client/PlcMgr.cs @@ -65,6 +65,17 @@ public class PlcMgr return false; } + + public static ushort BlowerStatus() + { + if (PlcClient != null) + { + + return PlcToHostData.ExhaustFanStatus.Value; + } + + return 0; + } /// /// 是否远程模式 diff --git a/Service/Station/MonitorService.cs b/Service/Station/MonitorService.cs index 61cbe3a..1f0ef40 100644 --- a/Service/Station/MonitorService.cs +++ b/Service/Station/MonitorService.cs @@ -27,13 +27,40 @@ public class MonitorService public ChargeOrderRepository ChargeOrderRepository { get; set; } public PlcTaskMgr PlcTaskMgr { get; set; } - public Result GetSwapMonitorData() + public Result GetSwapMonitorData() { var configBinInfo = new MapperConfiguration(cfg => cfg.CreateMap().ReverseMap()); IMapper mapperBinInfo = configBinInfo.CreateMapper(); - List stateInfoList = - mapperBinInfo.Map>(StationSoftMgr.SwappingStateMachine.StepModel); + List stateInfoList = new List() + { + new SwappingStateInfoResp() + { + StepName = "空闲1", + StepNo = 1, + StartTime = DateTime.Now + }, + new SwappingStateInfoResp() + { + StepName = "空闲2", + StepNo = 2, + StartTime = DateTime.Now + }, + new SwappingStateInfoResp() + { + StepName = "空闲3", + StepNo = 3, + StartTime = DateTime.Now + }, + new SwappingStateInfoResp() + { + StepName = "空闲4", + StepNo = 4, + StartTime = DateTime.Now + }, + }; + /*List stateInfoList = + mapperBinInfo.Map>(StationSoftMgr.SwappingStateMachine.StepModel);*/ var tboxCarInfoModel = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel; @@ -102,14 +129,17 @@ public class MonitorService /// 连接状态类 /// /// - public async Task> GetDeviceState() + public Result GetDeviceState() { - var isConnected = await TBoxApi.IsConnected(); + bool isConnected = StationSoftMgr.SwappingStateMachine.BoxCarInfoModel == null + ? false + : StationSoftMgr.SwappingStateMachine.BoxCarInfoModel.Connected; + DeviceStateResp resp = new() { BoxConnectFlag = isConnected != null ? isConnected : false, - CloudConnectFlag = CloudClientMgr.CloudClient==null? false:CloudClientMgr.CloudClient.Connected, - PlcConnectFlag = PlcMgr.PlcClient==null? false:PlcMgr.PlcClient.Connected + CloudConnectFlag = CloudClientMgr.CloudClient == null ? false : CloudClientMgr.CloudClient.Connected, + PlcConnectFlag = PlcMgr.PlcClient == null ? false : PlcMgr.PlcClient.Connected }; return Result.Success(resp); diff --git a/WebStarter/Controllers/BinInfoController.cs b/WebStarter/Controllers/BinInfoController.cs index 14a35a1..a9ed7be 100644 --- a/WebStarter/Controllers/BinInfoController.cs +++ b/WebStarter/Controllers/BinInfoController.cs @@ -79,4 +79,17 @@ public class BinInfoController : ControllerBase { return PlcMgr.AirBlowerControl(cmd) ? Result.Success() : Result.Fail(); } + + /// + /// 查询风机状态 + /// 0:无状态 + /// 1000:已全部打开 + /// 1010:已全部关闭 + /// + /// + [HttpGet("AirBlowerStatus")] + public Result AirBlowerStatus() + { + return Result.Success(PlcMgr.BlowerStatus()); + } } \ No newline at end of file diff --git a/WebStarter/Controllers/SwapMonitorController.cs b/WebStarter/Controllers/SwapMonitorController.cs index 5b2e0b2..3d6e83f 100644 --- a/WebStarter/Controllers/SwapMonitorController.cs +++ b/WebStarter/Controllers/SwapMonitorController.cs @@ -1,9 +1,11 @@ using Entity.Api.Resp; using Entity.Constant; +using HybirdFrameworkCore.Attribute; using HybirdFrameworkCore.Entity; using Microsoft.AspNetCore.Mvc; using Service.Execute; using Service.Execute.Api; +using Service.Execute.Model; using Service.Init; using Service.Plc.Client; using Service.Station; @@ -32,9 +34,9 @@ public class SwapMonitorController : ControllerBase /// /// [HttpPost("GetDeviceState")] - public async Task> GetDeviceState() + public Result GetDeviceState() { - return await _swapMonitorService.GetDeviceState(); + return _swapMonitorService.GetDeviceState(); } /// @@ -64,14 +66,9 @@ public class SwapMonitorController : ControllerBase /// /// [HttpPost("LockCar")] - public async Task> LockCar() + public async Task> LockCar( string carNo) { - if (StationSoftMgr.SwappingStateMachine.RfidReadModel == null) - { - return Result.Fail("暂无车辆"); - } - - var success = await TBoxApi.LockCarManyTimes(StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo); + var success = await TBoxApi.LockCarManyTimes(carNo); return success ? Result.Success() : Result.Fail(); } @@ -80,14 +77,9 @@ public class SwapMonitorController : ControllerBase /// /// [HttpPost("UnLockCar")] - public async Task> UnLockCar() + public async Task> UnLockCar( string carNo) { - if (StationSoftMgr.SwappingStateMachine.RfidReadModel == null) - { - return Result.Fail("暂无车辆"); - } - - var success = await TBoxApi.UnLockCarManyTimes(StationSoftMgr.SwappingStateMachine.RfidReadModel.VelNo); + var success = await TBoxApi.UnLockCarManyTimes(carNo); return success ? Result.Success() : Result.Fail(); } @@ -226,4 +218,33 @@ public class SwapMonitorController : ControllerBase return Result.Success(); } + + + /// + /// 获取所有连接车辆 + /// + [HttpGet("GetCarList")] + public async Task>> GetCarList() + { + /*var carInfoList = await TBoxApi.GetCarInfoList(); + if (carInfoList == null || carInfoList.Count <= 0) + { + return Result>.Success(new List()); + } + + return Result>.Success(carInfoList);*/ + return Result>.Success(new List() + { + new TboxCarInfoModel() + { + Connected = true, + CarNo = "carNo1", + }, + new TboxCarInfoModel() + { + Connected = true, + CarNo = "carNo2", + } + }); + } } \ No newline at end of file diff --git a/WebStarter/Controllers/Test/GenController.cs b/WebStarter/Controllers/Test/GenController.cs index 84cc515..158d131 100644 --- a/WebStarter/Controllers/Test/GenController.cs +++ b/WebStarter/Controllers/Test/GenController.cs @@ -47,9 +47,9 @@ public class GenController : ControllerBase { VehicleCertificationResp vehicleCertificationResp = CloudApi.VehicleCheck(new RfidReadModel() { - VelMac = "111", - VelNo = "LC1HMYBF6R0004575", - VelVin = "LC1HMYBF6R0004575", + //VelMac = "111", + VelNo = "晋C03733D", + // VelVin = "LC1HMYBF6R0004575", }, new SwapOrder() { VehicleEnterTime = DateTime.Now diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index c3190a1..a4d681b 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -163,11 +163,7 @@ if (AppSettingsHelper.GetBool("swap", "enable")) StationSoftMgr.SwappingStateMachineStart(); } -//Task -if (AppSettingsHelper.GetBool("task", "enable")) -{ - StationSoftMgr.StartTasks(); -} + TaskInit.Init();