主流程测试提交

master
lxw 6 months ago
parent 06da4922f9
commit 98dda4bcc7

@ -42,15 +42,15 @@ public class BinInfoRepository : BaseRepository<BinInfo>
} }
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) if (list.Count <= 0)
{ {
selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOfSoc; selectPackDto.Info = InfoEnum.SelectBinStatusInfo.LessOfSoc;
return selectPackDto; return selectPackDto;
} }
list = list.Where(i => new TimeSpan(DateTime.Now.Ticks - list = list.Where(i => i.LastChargeFinishTime!=null &&new TimeSpan(DateTime.Now.Ticks -
i.LastChargeFinishTime.ToDateTime().Ticks) i.LastChargeFinishTime.ToDateTime().Ticks)
.TotalMinutes > int.Parse(swapFinishChargeTime)).ToList(); .TotalMinutes > int.Parse(swapFinishChargeTime)).ToList();
if (list.Count <= 0) if (list.Count <= 0)
{ {

@ -18,7 +18,7 @@ public class RfidApi
public static async Task<bool> BeginRead() public static async Task<bool> BeginRead()
{ {
Log.Info("BeginRead"); Log.Info("BeginRead");
string url = BASE_URL + "/Api/BeginRead"; /*string url = BASE_URL + "/Api/BeginRead";
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -29,14 +29,15 @@ public class RfidApi
{ {
Console.WriteLine(e); Console.WriteLine(e);
return false; return false;
} }*/
return true;
} }
public static async Task<bool> StopRead() public static async Task<bool> StopRead()
{ {
Log.Info("StopRead"); Log.Info("StopRead");
string url = BASE_URL + "/Api/StopRead"; string url = BASE_URL + "/Api/StopRead";
try /*try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
Log.Info($"StopRead resp = {s}"); Log.Info($"StopRead resp = {s}");
@ -46,13 +47,14 @@ public class RfidApi
{ {
Console.WriteLine(e); Console.WriteLine(e);
return false; return false;
} }*/
return true;
} }
public static async Task<RfidReadModel?> ReadRifd() public static async Task<RfidReadModel?> ReadRifd()
{ {
Log.Info("ReadRifd"); Log.Info("ReadRifd");
string url = BASE_URL + "/Api/ReadRfidData"; /*string url = BASE_URL + "/Api/ReadRfidData";
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -70,9 +72,14 @@ public class RfidApi
{ {
Console.WriteLine(e); Console.WriteLine(e);
return null; return null;
} }*/
return null; return new RfidReadModel()
{
VelVin = "LC1HMYBF6R0004575",
VelNo = "LC1HMYBF6R0004575",
};
} }
} }

@ -10,7 +10,7 @@ public class TBoxApi
private static readonly ILog Log = LogManager.GetLogger(typeof(TBoxApi)); private static readonly ILog Log = LogManager.GetLogger(typeof(TBoxApi));
//TODO::TBox 服务地址 //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() private static readonly HttpClient _httpClient = new HttpClient()
{ {
@ -20,7 +20,7 @@ public class TBoxApi
public static async Task<TboxCarInfoModel> GetCarInfo() public static async Task<TboxCarInfoModel> GetCarInfo()
{ {
Log.Info("GetCarInfo"); Log.Info("GetCarInfo");
string url = BASE_URL + "/CarControl/getCarInfo"; string url = BASE_URL + "/getCarInfo";
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -43,7 +43,7 @@ public class TBoxApi
public static async Task<bool> Reset() public static async Task<bool> Reset()
{ {
Log.Info("Reset"); Log.Info("Reset");
string url = BASE_URL + "/CarControl/Clear"; string url = BASE_URL + "/Clear";
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -61,7 +61,7 @@ public class TBoxApi
public static async Task<bool> IsConnected() public static async Task<bool> IsConnected()
{ {
Log.Info("IsConnected"); Log.Info("IsConnected");
string url = BASE_URL + "/CarControl/getCarInfo"; string url = BASE_URL + "/getCarInfo";
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -85,10 +85,10 @@ public class TBoxApi
/// 车辆解锁 /// 车辆解锁
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static async Task<bool> UnLockCar() public static async Task<bool> UnLockCar(string carNo)
{ {
Log.Info("UnLockCar"); Log.Info("UnLockCar");
string url = BASE_URL + "/CarControl/unLock"; string url = BASE_URL + "/unLock/"+carNo;
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);
@ -108,10 +108,10 @@ public class TBoxApi
/// 车辆上锁 /// 车辆上锁
/// </summary> /// </summary>
/// <returns></returns> /// <returns></returns>
public static async Task<bool> LockCar() public static async Task<bool> LockCar(string carNo)
{ {
Log.Info("LockCar"); Log.Info("LockCar");
string url = BASE_URL + "/CarControl/lock"; string url = BASE_URL + "/lock/"+carNo;
try try
{ {
string s = await _httpClient.GetStringAsync(url); string s = await _httpClient.GetStringAsync(url);

@ -15,12 +15,12 @@ namespace Service.Execute.Utils;
[Scope("SingleInstance")] [Scope("SingleInstance")]
public class CommonMgr public class CommonMgr
{ {
private SwapOrderStepService _swapOrderStepService { get; set; } public SwapOrderStepService _swapOrderStepService { get; set; }
private SwapOrderRepository _swapOrderRepository { get; set; } public SwapOrderRepository _swapOrderRepository { get; set; }
private BinInfoRepository _binInfoRepository { get; set; } public BinInfoRepository _binInfoRepository { get; set; }
private SwapAmtOrderRepository _amtOrderRepository { get; set; } public SwapAmtOrderRepository _amtOrderRepository { get; set; }
private SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; } public SwapOrderBatteryRepository _swapOrderBatteryRepository { get; set; }
/// <summary> /// <summary>
/// 新增小步状态 /// 新增小步状态

@ -50,13 +50,14 @@ public class CarCtrlState : IState
return Invoker.Invoke("UnLockCar", 500, 100, machine.IsCanceled, return Invoker.Invoke("UnLockCar", 500, 100, machine.IsCanceled,
() => machine.VelUnlockFlag, () => () => machine.VelUnlockFlag, () =>
{ {
Task<bool> result = TBoxApi.UnLockCar(); Task<bool> result = TBoxApi.UnLockCar(machine.RfidReadModel.VelNo);
bool unLock = result.Result; bool unLock = result.Result;
if (unLock) if (unLock)
{ {
//查询车辆锁止状态 //查询车辆锁止状态
Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(); Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo();
if (carInfo.Result.HeartBeatMsg.LockStatus == 1) var resultHeartBeatMsg = carInfo.Result.HeartBeatMsg;
if (resultHeartBeatMsg.LockStatus == 1)
{ {
machine.VelUnlockFlag = true; machine.VelUnlockFlag = true;
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag, _CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.VelUnlockFlag,

@ -217,6 +217,7 @@ public class CarPrepareState : IState
if (tBoxCarInfoModel.CarNo!.Trim().Equals(machine.RfidReadModel!.VelNo.Trim())) if (tBoxCarInfoModel.CarNo!.Trim().Equals(machine.RfidReadModel!.VelNo.Trim()))
{ {
machine.BoxLocalCheckFlag = true; machine.BoxLocalCheckFlag = true;
machine.BoxCarInfoModel = tBoxCarInfoModel;
} }
}, () => { machine.ExceptionReason = ExceptionReason.LocalCheckVarError; }, true, () => }, () => { machine.ExceptionReason = ExceptionReason.LocalCheckVarError; }, true, () =>
{ {

@ -100,7 +100,7 @@ public class DoSwappingState : IState
return Invoker.Invoke("UnLockCar", 1000, 5, machine.IsCanceled, return Invoker.Invoke("UnLockCar", 1000, 5, machine.IsCanceled,
() => machine.StartSwappingFlag, () => () => machine.StartSwappingFlag, () =>
{ {
Task<bool> result = TBoxApi.UnLockCar(); Task<bool> result = TBoxApi.UnLockCar(machine.RfidReadModel.VelNo);
bool unLock = result.Result; bool unLock = result.Result;
if (unLock) if (unLock)
{ {
@ -248,7 +248,7 @@ public class DoSwappingState : IState
else if (channelStatus == 1020) else if (channelStatus == 1020)
{ {
//需要移车 先解锁 提示移动车辆,等待3分钟 //需要移车 先解锁 提示移动车辆,等待3分钟
var lockCar = TBoxApi.LockCar(); var lockCar = TBoxApi.LockCar(machine.RfidReadModel.VelNo);
if (lockCar.Result) if (lockCar.Result)
{ {
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed()); // machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.ErrChannelStatus.GetLed());

@ -181,17 +181,9 @@ public class StationReadyState : IState
//TODO::开始读rfid RfidService.BeginRead(); //TODO::开始读rfid RfidService.BeginRead();
Task<RfidReadModel?> rfidReadModel = RfidApi.ReadRifd(); Task<RfidReadModel?> rfidReadModel = RfidApi.ReadRifd();
rfidReadModel.Wait(); 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; machine.RfidReadModel = rfidReadModel.Result;
_log.Info($"read rfid={JsonConvert.SerializeObject(machine.RfidReadModel)}"); _log.Info($"read rfid={JsonConvert.SerializeObject(machine.RfidReadModel)}");

@ -71,7 +71,7 @@ public class SwapDoneState : IState
return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled, return Invoker.Invoke("LockCar", 500, 100, machine.IsCanceled,
() => machine.VelLockFlag, () => () => machine.VelLockFlag, () =>
{ {
Task<bool> result = TBoxApi.LockCar(); Task<bool> result = TBoxApi.LockCar(machine.RfidReadModel.VelNo);
bool unLock = result.Result; bool unLock = result.Result;
if (unLock) if (unLock)
{ {

@ -1,6 +1,7 @@
using HybirdFrameworkCore.Autofac.Attribute; using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkDriver.ModbusTcpMaster; using HybirdFrameworkDriver.ModbusTcpMaster;
using Repository.Station; using Repository.Station;
using Service.Execute.Api;
using Service.Plc.Msg; using Service.Plc.Msg;
namespace Service.Plc.Client; namespace Service.Plc.Client;
@ -21,7 +22,7 @@ public class PlcClient : ModbusTcpMaster
Duration = 2000; Duration = 2000;
AutoReConnect = true; AutoReConnect = true;
_binInfoRepository = binInfoRepository; _binInfoRepository = binInfoRepository;
DataFormat = HslCommunication.Core.DataFormat.DCBA; //DataFormat = HslCommunication.Core.DataFormat.DCBA;
} }
private void BatchRead(ModbusTcpMaster master) private void BatchRead(ModbusTcpMaster master)

@ -18,7 +18,7 @@ public class PlcMgr
/// <summary> /// <summary>
/// 数据有效时间。单位秒 /// 数据有效时间。单位秒
/// </summary> /// </summary>
static int DataTimeSeconds = 3; static int DataTimeSeconds = 20;
/// <summary> /// <summary>
/// 数据刷新时间 /// 数据刷新时间
@ -61,7 +61,7 @@ public class PlcMgr
{ {
if ((DateTime.Now - DataValidityTime).Seconds <= DataTimeSeconds) 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 else
{ {

@ -155,6 +155,6 @@ CloudClientMgr.Init();
PlcMgr.Init(); PlcMgr.Init();
//启动换电流程 //启动换电流程
//StationSoftMgr.SwappingStateMachineStart(); StationSoftMgr.SwappingStateMachineStart();
StationSoftMgr.StartTasks(); //StationSoftMgr.StartTasks();
app.Run(); app.Run();

@ -1,6 +1,6 @@
{ {
"Version": 1, "Version": 1,
"Hash": "4RoVPOm6CrNVXwDoB2EbnGpUxlL4C9N9XdUuvmvE6xI=", "Hash": "LS9utnIO5mfHvtDI6/Yvv5jVnmRGtwfQUGBjyueTZQE=",
"Source": "WebStarter", "Source": "WebStarter",
"BasePath": "_content/WebStarter", "BasePath": "_content/WebStarter",
"Mode": "Default", "Mode": "Default",
@ -10,22 +10,24 @@
{ {
"Name": "WebStarter\\wwwroot", "Name": "WebStarter\\wwwroot",
"Source": "WebStarter", "Source": "WebStarter",
"ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\",
"BasePath": "_content/WebStarter", "BasePath": "_content/WebStarter",
"Pattern": "**" "Pattern": "**"
} }
], ],
"Assets": [ "Assets": [
{ {
"Identity": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\20240523\\0.jpg", "Identity": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\20240523\\0.jpg",
"SourceId": "WebStarter", "SourceId": "WebStarter",
"SourceType": "Discovered", "SourceType": "Discovered",
"ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\",
"BasePath": "_content/WebStarter", "BasePath": "_content/WebStarter",
"RelativePath": "20240523/0.jpg", "RelativePath": "20240523/0.jpg",
"AssetKind": "All", "AssetKind": "All",
"AssetMode": "All", "AssetMode": "All",
"AssetRole": "Primary", "AssetRole": "Primary",
"AssetMergeBehavior": "PreferTarget",
"AssetMergeSource": "",
"RelatedAsset": "", "RelatedAsset": "",
"AssetTraitName": "", "AssetTraitName": "",
"AssetTraitValue": "", "AssetTraitValue": "",
@ -34,15 +36,17 @@
"OriginalItemSpec": "wwwroot\\20240523\\0.jpg" "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", "SourceId": "WebStarter",
"SourceType": "Discovered", "SourceType": "Discovered",
"ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\",
"BasePath": "_content/WebStarter", "BasePath": "_content/WebStarter",
"RelativePath": "20240524/0.jpg", "RelativePath": "20240524/0.jpg",
"AssetKind": "All", "AssetKind": "All",
"AssetMode": "All", "AssetMode": "All",
"AssetRole": "Primary", "AssetRole": "Primary",
"AssetMergeBehavior": "PreferTarget",
"AssetMergeSource": "",
"RelatedAsset": "", "RelatedAsset": "",
"AssetTraitName": "", "AssetTraitName": "",
"AssetTraitValue": "", "AssetTraitValue": "",
@ -51,15 +55,17 @@
"OriginalItemSpec": "wwwroot\\20240524\\0.jpg" "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", "SourceId": "WebStarter",
"SourceType": "Discovered", "SourceType": "Discovered",
"ContentRoot": "D:\\项目文件\\项目报表\\19焕能后背式站控\\04项目源码\\主服务\\主服务\\WebStarter\\wwwroot\\", "ContentRoot": "C:\\Users\\Administrator\\Desktop\\01主服务\\01主服务\\WebStarter\\wwwroot\\",
"BasePath": "_content/WebStarter", "BasePath": "_content/WebStarter",
"RelativePath": "20240524/0.png", "RelativePath": "20240524/0.png",
"AssetKind": "All", "AssetKind": "All",
"AssetMode": "All", "AssetMode": "All",
"AssetRole": "Primary", "AssetRole": "Primary",
"AssetMergeBehavior": "PreferTarget",
"AssetMergeSource": "",
"RelatedAsset": "", "RelatedAsset": "",
"AssetTraitName": "", "AssetTraitName": "",
"AssetTraitValue": "", "AssetTraitValue": "",

Loading…
Cancel
Save