From 98dda4bcc7f00804f3f236c3b99caa42638cf827 Mon Sep 17 00:00:00 2001 From: lxw Date: Tue, 28 May 2024 13:20:21 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=BB=E6=B5=81=E7=A8=8B=E6=B5=8B=E8=AF=95?= =?UTF-8?q?=E6=8F=90=E4=BA=A4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Repository/Station/BinInfoRepository.cs | 6 ++--- Service/Execute/Api/RfidApi.cs | 21 ++++++++++++------ Service/Execute/Api/TboxApi.cs | 16 +++++++------- Service/Execute/Mgr/CommonMgr.cs | 10 ++++----- Service/Execute/Step/CarCtrlState.cs | 5 +++-- Service/Execute/Step/CarPrepareState.cs | 1 + Service/Execute/Step/DoSwappingState.cs | 4 ++-- Service/Execute/Step/StationReadyState.cs | 12 ++-------- Service/Execute/Step/SwapDoneState.cs | 2 +- Service/Plc/Client/PlcClient.cs | 3 ++- Service/Plc/Client/PlcMgr.cs | 4 ++-- WebStarter/Program.cs | 4 ++-- .../Debug/net6.0/staticwebassets.build.json | 22 ++++++++++++------- 13 files changed, 59 insertions(+), 51 deletions(-) diff --git a/Repository/Station/BinInfoRepository.cs b/Repository/Station/BinInfoRepository.cs index 6a71f0d..b1cf4eb 100644 --- a/Repository/Station/BinInfoRepository.cs +++ b/Repository/Station/BinInfoRepository.cs @@ -42,15 +42,15 @@ public class BinInfoRepository : BaseRepository } - list = list.Where(i => i.Soc > int.Parse(swapSoc)).ToList(); + list = list.Where(i =>i.Soc!=null && i.Soc > int.Parse(swapSoc)).ToList(); if (list.Count <= 0) { selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOfSoc; return selectPackDto; } - list = list.Where(i => new TimeSpan(DateTime.Now.Ticks - - i.LastChargeFinishTime.ToDateTime().Ticks) + list = list.Where(i => i.LastChargeFinishTime!=null &&new TimeSpan(DateTime.Now.Ticks - + i.LastChargeFinishTime.ToDateTime().Ticks) .TotalMinutes > int.Parse(swapFinishChargeTime)).ToList(); if (list.Count <= 0) { diff --git a/Service/Execute/Api/RfidApi.cs b/Service/Execute/Api/RfidApi.cs index 992d961..a8922ef 100644 --- a/Service/Execute/Api/RfidApi.cs +++ b/Service/Execute/Api/RfidApi.cs @@ -18,7 +18,7 @@ public class RfidApi 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); @@ -29,14 +29,15 @@ public class RfidApi { Console.WriteLine(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}"); @@ -46,13 +47,14 @@ public class RfidApi { Console.WriteLine(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,9 +72,14 @@ public class RfidApi { Console.WriteLine(e); return null; - } + }*/ - return null; + return new RfidReadModel() + { + VelVin = "LC1HMYBF6R0004575", + VelNo = "LC1HMYBF6R0004575", + + }; } } \ No newline at end of file diff --git a/Service/Execute/Api/TboxApi.cs b/Service/Execute/Api/TboxApi.cs index 3d492df..65ee2ea 100644 --- a/Service/Execute/Api/TboxApi.cs +++ b/Service/Execute/Api/TboxApi.cs @@ -10,7 +10,7 @@ public class TBoxApi private static readonly ILog Log = LogManager.GetLogger(typeof(TBoxApi)); //TODO::TBox 服务地址 - private static readonly string BASE_URL = "http://localhost:7243"; + private static readonly string BASE_URL = "http://localhost:5034"; private static readonly HttpClient _httpClient = new HttpClient() { @@ -20,7 +20,7 @@ public class TBoxApi public static async Task GetCarInfo() { Log.Info("GetCarInfo"); - string url = BASE_URL + "/CarControl/getCarInfo"; + string url = BASE_URL + "/getCarInfo"; try { string s = await _httpClient.GetStringAsync(url); @@ -43,7 +43,7 @@ public class TBoxApi public static async Task Reset() { Log.Info("Reset"); - string url = BASE_URL + "/CarControl/Clear"; + string url = BASE_URL + "/Clear"; try { string s = await _httpClient.GetStringAsync(url); @@ -61,7 +61,7 @@ public class TBoxApi public static async Task IsConnected() { Log.Info("IsConnected"); - string url = BASE_URL + "/CarControl/getCarInfo"; + string url = BASE_URL + "/getCarInfo"; try { string s = await _httpClient.GetStringAsync(url); @@ -85,10 +85,10 @@ public class TBoxApi /// 车辆解锁 /// /// - public static async Task UnLockCar() + public static async Task UnLockCar(string carNo) { Log.Info("UnLockCar"); - string url = BASE_URL + "/CarControl/unLock"; + string url = BASE_URL + "/unLock/"+carNo; try { string s = await _httpClient.GetStringAsync(url); @@ -108,10 +108,10 @@ public class TBoxApi /// 车辆上锁 /// /// - public static async Task LockCar() + public static async Task LockCar(string carNo) { Log.Info("LockCar"); - string url = BASE_URL + "/CarControl/lock"; + string url = BASE_URL + "/lock/"+carNo; try { string s = await _httpClient.GetStringAsync(url); diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs index d74b413..3f949c9 100644 --- a/Service/Execute/Mgr/CommonMgr.cs +++ b/Service/Execute/Mgr/CommonMgr.cs @@ -15,12 +15,12 @@ namespace Service.Execute.Utils; [Scope("SingleInstance")] public class CommonMgr { - private SwapOrderStepService _swapOrderStepService { get; set; } - private SwapOrderRepository _swapOrderRepository { get; set; } + public SwapOrderStepService _swapOrderStepService { get; set; } + public SwapOrderRepository _swapOrderRepository { get; set; } - private BinInfoRepository _binInfoRepository { get; set; } - private SwapAmtOrderRepository _amtOrderRepository { get; set; } - private SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; } + public BinInfoRepository _binInfoRepository { get; set; } + public SwapAmtOrderRepository _amtOrderRepository { get; set; } + public SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; } /// /// 新增小步状态 diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs index b52fb5c..647be8b 100644 --- a/Service/Execute/Step/CarCtrlState.cs +++ b/Service/Execute/Step/CarCtrlState.cs @@ -50,13 +50,14 @@ public class CarCtrlState : IState return Invoker.Invoke("UnLockCar", 500, 100, machine.IsCanceled, () => machine.VelUnlockFlag, () => { - Task result = TBoxApi.UnLockCar(); + Task result = TBoxApi.UnLockCar(machine.RfidReadModel.VelNo); bool unLock = result.Result; if (unLock) { //查询车辆锁止状态 Task carInfo = TBoxApi.GetCarInfo(); - if (carInfo.Result.HeartBeatMsg.LockStatus == 1) + var resultHeartBeatMsg = carInfo.Result.HeartBeatMsg; + if (resultHeartBeatMsg.LockStatus == 1) { machine.VelUnlockFlag = true; _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag, diff --git a/Service/Execute/Step/CarPrepareState.cs b/Service/Execute/Step/CarPrepareState.cs index f2a1dce..56231e5 100644 --- a/Service/Execute/Step/CarPrepareState.cs +++ b/Service/Execute/Step/CarPrepareState.cs @@ -217,6 +217,7 @@ public class CarPrepareState : IState if (tBoxCarInfoModel.CarNo!.Trim().Equals(machine.RfidReadModel!.VelNo.Trim())) { machine.BoxLocalCheckFlag = true; + machine.BoxCarInfoModel = tBoxCarInfoModel; } }, () => { machine.ExceptionReason = ExceptionReason.LocalCheckVarError; }, true, () => { diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs index 5fe81ad..38a0176 100644 --- a/Service/Execute/Step/DoSwappingState.cs +++ b/Service/Execute/Step/DoSwappingState.cs @@ -100,7 +100,7 @@ public class DoSwappingState : IState return Invoker.Invoke("UnLockCar", 1000, 5, machine.IsCanceled, () => machine.StartSwappingFlag, () => { - Task result = TBoxApi.UnLockCar(); + Task result = TBoxApi.UnLockCar(machine.RfidReadModel.VelNo); bool unLock = result.Result; if (unLock) { @@ -248,7 +248,7 @@ public class DoSwappingState : IState else if (channelStatus == 1020) { //需要移车 先解锁 提示移动车辆,等待3分钟 - var lockCar = TBoxApi.LockCar(); + var lockCar = TBoxApi.LockCar(machine.RfidReadModel.VelNo); if (lockCar.Result) { // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed()); diff --git a/Service/Execute/Step/StationReadyState.cs b/Service/Execute/Step/StationReadyState.cs index 64ddd7a..0428309 100644 --- a/Service/Execute/Step/StationReadyState.cs +++ b/Service/Execute/Step/StationReadyState.cs @@ -181,17 +181,9 @@ public class StationReadyState : IState //TODO::开始读rfid RfidService.BeginRead(); Task rfidReadModel = RfidApi.ReadRifd(); rfidReadModel.Wait(); - if (rfidReadModel.IsCompletedSuccessfully && rfidReadModel.Result != null) + if (/*rfidReadModel.IsCompletedSuccessfully &&*/ rfidReadModel.Result != null) { - var resultFVelMac = rfidReadModel.Result.VelMac; - StringBuilder sb = new StringBuilder(16); - sb.Append(resultFVelMac[0]).Append(resultFVelMac[1]).Append(" ") - .Append(resultFVelMac[2]).Append(resultFVelMac[3]).Append(" ") - .Append(resultFVelMac[4]).Append(resultFVelMac[5]).Append(" ") - .Append(resultFVelMac[6]).Append(resultFVelMac[7]).Append(" ") - .Append(resultFVelMac[8]).Append(resultFVelMac[9]).Append(" ") - .Append(resultFVelMac[10]).Append(resultFVelMac[11]); - rfidReadModel.Result.VelMac = sb.ToString(); + machine.RfidReadModel = rfidReadModel.Result; _log.Info($"read rfid={JsonConvert.SerializeObject(machine.RfidReadModel)}"); diff --git a/Service/Execute/Step/SwapDoneState.cs b/Service/Execute/Step/SwapDoneState.cs index c3c9125..a049ad3 100644 --- a/Service/Execute/Step/SwapDoneState.cs +++ b/Service/Execute/Step/SwapDoneState.cs @@ -71,7 +71,7 @@ public class SwapDoneState : IState return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, () => machine.VelLockFlag, () => { - Task result = TBoxApi.LockCar(); + Task result = TBoxApi.LockCar(machine.RfidReadModel.VelNo); bool unLock = result.Result; if (unLock) { diff --git a/Service/Plc/Client/PlcClient.cs b/Service/Plc/Client/PlcClient.cs index 20ecf3a..aaf912d 100644 --- a/Service/Plc/Client/PlcClient.cs +++ b/Service/Plc/Client/PlcClient.cs @@ -1,6 +1,7 @@ using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkDriver.ModbusTcpMaster; using Repository.Station; +using Service.Execute.Api; using Service.Plc.Msg; namespace Service.Plc.Client; @@ -21,7 +22,7 @@ public class PlcClient : ModbusTcpMaster Duration = 2000; AutoReConnect = true; _binInfoRepository = binInfoRepository; - DataFormat = HslCommunication.Core.DataFormat.DCBA; + //DataFormat = HslCommunication.Core.DataFormat.DCBA; } private void BatchRead(ModbusTcpMaster master) diff --git a/Service/Plc/Client/PlcMgr.cs b/Service/Plc/Client/PlcMgr.cs index 1307953..f8f65d4 100644 --- a/Service/Plc/Client/PlcMgr.cs +++ b/Service/Plc/Client/PlcMgr.cs @@ -18,7 +18,7 @@ public class PlcMgr /// /// 数据有效时间。单位秒 /// - static int DataTimeSeconds = 3; + static int DataTimeSeconds = 20; /// /// 数据刷新时间 @@ -61,7 +61,7 @@ public class PlcMgr { if ((DateTime.Now - DataValidityTime).Seconds <= DataTimeSeconds) { - return PlcToHostData.RemoteLocalControlState.Value == 1010 ? true : false; + return (PlcToHostData.ModeControl.Value == 1010 && PlcToHostData.RemoteLocalControlState.Value==1010) ? true : false; } else { diff --git a/WebStarter/Program.cs b/WebStarter/Program.cs index ef4fdba..d8e4ca8 100644 --- a/WebStarter/Program.cs +++ b/WebStarter/Program.cs @@ -155,6 +155,6 @@ CloudClientMgr.Init(); PlcMgr.Init(); //启动换电流程 -//StationSoftMgr.SwappingStateMachineStart(); -StationSoftMgr.StartTasks(); +StationSoftMgr.SwappingStateMachineStart(); +//StationSoftMgr.StartTasks(); app.Run(); \ No newline at end of file diff --git a/WebStarter/obj/Debug/net6.0/staticwebassets.build.json b/WebStarter/obj/Debug/net6.0/staticwebassets.build.json index 954d25a..6f60ec1 100644 --- a/WebStarter/obj/Debug/net6.0/staticwebassets.build.json +++ b/WebStarter/obj/Debug/net6.0/staticwebassets.build.json @@ -1,6 +1,6 @@ { "Version": 1, - "Hash": "4RoVPOm6CrNVXwDoB2EbnGpUxlL4C9N9XdUuvmvE6xI=", + "Hash": "LS9utnIO5mfHvtDI6/Yvv5jVnmRGtwfQUGBjyueTZQE=", "Source": "WebStarter", "BasePath": "_content/WebStarter", "Mode": "Default", @@ -10,22 +10,24 @@ { "Name": "WebStarter\\wwwroot", "Source": "WebStarter", - "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", + "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "Pattern": "**" } ], "Assets": [ { - "Identity": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\20240523\\0.jpg", + "Identity": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\20240523\\0.jpg", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", + "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240523/0.jpg", "AssetKind": "All", "AssetMode": "All", "AssetRole": "Primary", + "AssetMergeBehavior": "PreferTarget", + "AssetMergeSource": "", "RelatedAsset": "", "AssetTraitName": "", "AssetTraitValue": "", @@ -34,15 +36,17 @@ "OriginalItemSpec": "wwwroot\\20240523\\0.jpg" }, { - "Identity": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\20240524\\0.jpg", + "Identity": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\20240524\\0.jpg", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", + "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240524/0.jpg", "AssetKind": "All", "AssetMode": "All", "AssetRole": "Primary", + "AssetMergeBehavior": "PreferTarget", + "AssetMergeSource": "", "RelatedAsset": "", "AssetTraitName": "", "AssetTraitValue": "", @@ -51,15 +55,17 @@ "OriginalItemSpec": "wwwroot\\20240524\\0.jpg" }, { - "Identity": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\20240524\\0.png", + "Identity": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\20240524\\0.png", "SourceId": "WebStarter", "SourceType": "Discovered", - "ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", + "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\", "BasePath": "_content/WebStarter", "RelativePath": "20240524/0.png", "AssetKind": "All", "AssetMode": "All", "AssetRole": "Primary", + "AssetMergeBehavior": "PreferTarget", + "AssetMergeSource": "", "RelatedAsset": "", "AssetTraitName": "", "AssetTraitValue": "",