主流程测试提交

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)
{
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)
{

@ -18,7 +18,7 @@ public class RfidApi
public static async Task<bool> 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<bool> 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<RfidReadModel?> 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",
};
}
}

@ -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<TboxCarInfoModel> 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<bool> 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<bool> 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
/// 车辆解锁
/// </summary>
/// <returns></returns>
public static async Task<bool> UnLockCar()
public static async Task<bool> 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
/// 车辆上锁
/// </summary>
/// <returns></returns>
public static async Task<bool> LockCar()
public static async Task<bool> 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);

@ -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; }
/// <summary>
/// 新增小步状态

@ -50,13 +50,14 @@ public class CarCtrlState : IState
return Invoker.Invoke("UnLockCar", 500, 100, machine.IsCanceled,
() => machine.VelUnlockFlag, () =>
{
Task<bool> result = TBoxApi.UnLockCar();
Task<bool> result = TBoxApi.UnLockCar(machine.RfidReadModel.VelNo);
bool unLock = result.Result;
if (unLock)
{
//查询车辆锁止状态
Task<TboxCarInfoModel> 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,

@ -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, () =>
{

@ -100,7 +100,7 @@ public class DoSwappingState : IState
return Invoker.Invoke("UnLockCar", 1000, 5, machine.IsCanceled,
() => machine.StartSwappingFlag, () =>
{
Task<bool> result = TBoxApi.UnLockCar();
Task<bool> 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());

@ -181,17 +181,9 @@ public class StationReadyState : IState
//TODO::开始读rfid RfidService.BeginRead();
Task<RfidReadModel?> 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)}");

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

@ -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)

@ -18,7 +18,7 @@ public class PlcMgr
/// <summary>
/// 数据有效时间。单位秒
/// </summary>
static int DataTimeSeconds = 3;
static int DataTimeSeconds = 20;
/// <summary>
/// 数据刷新时间
@ -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
{

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

@ -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": "",

Loading…
Cancel
Save