From e00d94e103370e5eb3adb377935076596f3e23fa Mon Sep 17 00:00:00 2001
From: xjl <2595686544@qq.com>
Date: Thu, 1 Aug 2024 15:19:52 +0800
Subject: [PATCH] =?UTF-8?q?=E6=8D=A2=E7=94=B5=E6=B5=81=E7=A8=8B=E4=BF=AE?=
=?UTF-8?q?=E6=94=B9?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
Service/Execute/Api/PlcApi.cs | 10 +-
Service/Execute/Invoker.cs | 53 ++++++-
Service/Execute/Mgr/CommonMgr.cs | 2 +-
Service/Execute/Model/DistributeTask.cs | 14 +-
Service/Execute/Step/CancelState.cs | 3 +
Service/Execute/Step/CarCtrlState.cs | 2 +-
Service/Execute/Step/DoSwappingState.cs | 63 +++++++--
Service/Execute/SwappingStateMachine.cs | 14 +-
Service/Mgr/PlcTaskMgr.cs | 4 +-
Service/Plc/Client/PlcMgr.cs | 27 +++-
Service/Plc/Msg/PlcToHost.cs | 2 +-
Service/Station/BinInfoService.cs | 7 +-
Service/Station/MonitorService.cs | 132 ++++++++++--------
.../Controllers/ChargeMonitorController.cs | 1 +
14 files changed, 233 insertions(+), 101 deletions(-)
diff --git a/Service/Execute/Api/PlcApi.cs b/Service/Execute/Api/PlcApi.cs
index 758ffd2..2ac1c8c 100644
--- a/Service/Execute/Api/PlcApi.cs
+++ b/Service/Execute/Api/PlcApi.cs
@@ -110,7 +110,7 @@ public class PlcApi
{
Log.Info($"PlcApi StartSwapping param= inBinNo={inBinNo}, outBinNo={outBinNo}");
- var distributeTask = PlcMgr.DistributeTask(ushort.Parse(inBinNo), ushort.Parse(outBinNo), 1);
+ var distributeTask = PlcMgr.DistributeTask(ushort.Parse(inBinNo), ushort.Parse(outBinNo), 2);
Log.Info($"PlcApi StartSwapping resp={distributeTask}");
return distributeTask;
@@ -160,15 +160,17 @@ public class PlcApi
/// 查看拍照状态
///
///
- public static ushort ChannelStatus()
+ public static ushort[] ChannelStatus()
{
Log.Info($"PlcApi start ChannelStatus ");
PlcMgr.ResetPlc();
- var channelStatus = PlcMgr.ChannelStatus();
+ ushort[] channelStatus=new ushort[2];
+ channelStatus[0] = PlcMgr.ChannelStatus(1);
+ channelStatus[1] = PlcMgr.ChannelStatus(2);
Log.Info($"PlcApi ChannelStatus resp= {channelStatus}");
return channelStatus;
}
-
+
///
/// 读plc任务状态
diff --git a/Service/Execute/Invoker.cs b/Service/Execute/Invoker.cs
index 30a04b7..c24429e 100644
--- a/Service/Execute/Invoker.cs
+++ b/Service/Execute/Invoker.cs
@@ -119,8 +119,57 @@ public class Invoker
Log.Info($" {name} done");
return InvokeStatus.Done;
}
-
-
+
+ public static InvokeStatus Invoke(string name, int duration, int times, Func cancel, Func abnormal, Func done,
+ Action doAction,
+ Action timeoutAction, bool isTimeOutExit, int timeOutActionTime,
+ InvokeStatus timeOutException)
+ {
+ int count = 0;
+ while (!done())
+ {
+ Log.Info($"begin {name}");
+ Thread.Sleep(duration);
+ if (cancel())
+ {
+ Log.Info($" {name} canceled");
+ return InvokeStatus.Cancel;
+ }
+ if (abnormal())
+ {
+ Log.Info($" {name} Exception");
+ return InvokeStatus.Exception;
+ }
+
+ try
+ {
+ doAction();
+ }
+ catch (Exception e)
+ {
+ Log.Error($"{name}", e);
+
+ }
+
+ if (count++ > times)
+ {
+ if (count % timeOutActionTime == 0)
+ {
+ timeoutAction();
+ Log.Info($" {name} timeout");
+ if (isTimeOutExit)
+ {
+ return timeOutException;
+ }
+ }
+ }
+ }
+
+ Log.Info($" {name} done");
+ return InvokeStatus.Done;
+ }
+
+
public static InvokeStatus Invoke(string name, int duration, int times, Func cancel,Func succ, Func done,
Action doAction,
Action timeoutAction, bool isTimeOutExit, Action exceptionAction, int timeOutActionTime,
diff --git a/Service/Execute/Mgr/CommonMgr.cs b/Service/Execute/Mgr/CommonMgr.cs
index 27e4877..40422b2 100644
--- a/Service/Execute/Mgr/CommonMgr.cs
+++ b/Service/Execute/Mgr/CommonMgr.cs
@@ -174,7 +174,7 @@ public class CommonMgr
///
///
public void UpBin(SwapOrderBatteryInfo orderBatteryInfo)
- {
+ {//TODO 选包只选右侧的1~8
SelectPackDto selectPack =
_binInfoRepository.SelectPack(StaticStationInfo.SwapSoc, StaticStationInfo.SwapFinishChargeTime,
QueryMoveBinNo()[0]);
diff --git a/Service/Execute/Model/DistributeTask.cs b/Service/Execute/Model/DistributeTask.cs
index b802988..002b7e5 100644
--- a/Service/Execute/Model/DistributeTask.cs
+++ b/Service/Execute/Model/DistributeTask.cs
@@ -7,12 +7,14 @@ public class DistributeTask
{
///
/// 任务类型
- /// 0.无任务
- /// 1.换电任务
- /// 2.移舱任务
- /// 3.移出任务
- /// 4.移入任务
- /// 5.消防任务
+ /// 0.待机
+ /// 1.任务异常结束
+ /// 2.换电任务
+ /// 3.入库任务
+ /// 4.出库任务
+ /// 5.维护任务
+ /// 6.调库任务
+ /// 7.消防任务
///
[Property(0, 16)]
public ushort TaskNo { get; set; }
diff --git a/Service/Execute/Step/CancelState.cs b/Service/Execute/Step/CancelState.cs
index ae1daae..7fee212 100644
--- a/Service/Execute/Step/CancelState.cs
+++ b/Service/Execute/Step/CancelState.cs
@@ -9,6 +9,9 @@ using Service.Mgr;
namespace Service.Execute.Step;
+///
+/// 人工确认失败
+///
public class CancelState : IState
{
private readonly CommonMgr _CommonMgr = AppInfo.Container.Resolve();
diff --git a/Service/Execute/Step/CarCtrlState.cs b/Service/Execute/Step/CarCtrlState.cs
index 896834a..1aa4104 100644
--- a/Service/Execute/Step/CarCtrlState.cs
+++ b/Service/Execute/Step/CarCtrlState.cs
@@ -240,7 +240,7 @@ public class CarCtrlState : IState
count++;
- if (channelStatus == 1000)
+ if (channelStatus[0] == 1000 && channelStatus[1] == 1000)
{
machine.ChannelStatusOkFlag = true;
return null;
diff --git a/Service/Execute/Step/DoSwappingState.cs b/Service/Execute/Step/DoSwappingState.cs
index 2c49209..9798321 100644
--- a/Service/Execute/Step/DoSwappingState.cs
+++ b/Service/Execute/Step/DoSwappingState.cs
@@ -121,7 +121,7 @@ public class DoSwappingState : IState
machine.SwapOrderBatteryInfo.UpBinInfo.No);
//查詢當前任務狀態是否被更改
- var readPlcTaskStatus = PlcApi.ReadTaskStatus(1);
+ var readPlcTaskStatus = PlcApi.ReadTaskStatus(2);
if (startSwapping && readPlcTaskStatus)
{
machine.SwapOrder.SwapBeginTime = DateTime.Now;
@@ -150,7 +150,7 @@ public class DoSwappingState : IState
() => machine.PlcHoldFlag, () =>
{
//查询车辆锁止状态
- var taskPrepare = PlcApi.ReadTaskStatus(1);
+ var taskPrepare = PlcApi.ReadTaskStatus(2);
if (taskPrepare)
{
bool holdOn = PlcApi.HoldOn();
@@ -174,12 +174,20 @@ public class DoSwappingState : IState
///
public InvokeStatus UnPack(SwappingStateMachine machine)
{
- return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled,
+ return Invoker.Invoke("plc UnPack", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
() => machine.UnOldBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoUnPack.GetLed());
+ //plc任务异常结束流程
+ if (PlcApi.ReadTaskStatus(1))
+ {
+ machine.PLCAbnormalFlag = true;
+ machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
+ machine.SwapFailReason = "PLC任务异常结束";
+ }
+
int status = PlcApi.ReadPlcTaskStatus();
//处理程序太快,plc还没有初始值的状态
if (status == 1002 || status != 1003)
@@ -195,16 +203,24 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.UnOldBatteryFlag,
machine);
}
- }, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack); }, false, () => { }, 10,
+ }, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoUnPack); }, false, 10,
InvokeStatus.None);
}
public InvokeStatus OldBatteryCarryIn(SwappingStateMachine machine)
{
- return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled,
+ return Invoker.Invoke("plc OldBatteryCarryIn", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
() => machine.StorageOldBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoOldBatteryCarryIn.GetLed());
+ //plc任务异常结束流程
+ if (PlcApi.ReadTaskStatus(1))
+ {
+ machine.PLCAbnormalFlag = true;
+ machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
+ machine.SwapFailReason = "PLC任务异常结束";
+
+ }
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
if (readPlcTaskStatus == 1003 || readPlcTaskStatus != 1004)
@@ -222,17 +238,24 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.StorageOldBatteryFlag,
machine);
}
- }, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); }, false, () => { }, 10,
+ }, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoOldBatteryCarryIn); }, false, 10,
InvokeStatus.None);
}
public InvokeStatus NewBatteryCarryOut(SwappingStateMachine machine)
{
- return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled,
+ return Invoker.Invoke("plc NewBatteryCarryOut", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
() => machine.OutNewBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoNewBatteryCarryOut.GetLed());
+ //plc任务异常结束流程
+ if (PlcApi.ReadTaskStatus(1))
+ {
+ machine.PLCAbnormalFlag = true;
+ machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
+ machine.SwapFailReason = "PLC任务异常结束";
+ }
if (PlcApi.ReadPlcTaskStatus() == 1004)
{
@@ -247,16 +270,24 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.OutNewBatteryFlag,
machine);
}
- }, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);}, false, () => { }, 10,
+ }, () => { SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoNewBatteryCarryOut);}, false, 10,
InvokeStatus.None);
}
public InvokeStatus Pack(SwappingStateMachine machine)
{
- return Invoker.Invoke("plc Pack ing", 500, 5, machine.IsCanceled,
+ return Invoker.Invoke("plc Pack ing", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
() => machine.InstallNewBatteryFlag, () =>
{
+ //plc任务异常结束流程
+ if (PlcApi.ReadTaskStatus(1))
+ {
+ machine.PLCAbnormalFlag = true;
+ machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
+ machine.SwapFailReason = "PLC任务异常结束";
+
+ }
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPack.GetLed());
if (PlcApi.ReadPlcTaskStatus() == 1005)
{
@@ -275,16 +306,24 @@ public class DoSwappingState : IState
}, () =>
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoPack);
- },false, () => { },
+ },false,
10,InvokeStatus.None);
}
public InvokeStatus PackFinish(SwappingStateMachine machine)
{
- return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled,
+ return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled, machine.IsPLCAbnormal,
() => machine.FinishNewBatteryFlag, () =>
{
// machine.LedTool?.WriteProgramContent(InfoEnum.SwapInfo.InfoPackFinish.GetLed());
+ //plc任务异常结束流程
+ if (PlcApi.ReadTaskStatus(1))
+ {
+ machine.PLCAbnormalFlag = true;
+ machine.SwapStatus = (int)InfoEnum.SwapOrderResult.Fail;
+ machine.SwapFailReason = "PLC任务异常结束";
+
+ }
var readPlcTaskStatus = PlcApi.ReadPlcTaskStatus();
if (readPlcTaskStatus == 1006 || readPlcTaskStatus == 1007)
{
@@ -298,7 +337,7 @@ public class DoSwappingState : IState
_CommonMgr.InsertStep(InfoEnum.BusinessSwappingStep.FinishNewBatteryFlag,
machine);
}
- }, () => { },false, () => { },
+ }, () => { },false,
10,InvokeStatus.None);
}
diff --git a/Service/Execute/SwappingStateMachine.cs b/Service/Execute/SwappingStateMachine.cs
index 3317592..71f5912 100644
--- a/Service/Execute/SwappingStateMachine.cs
+++ b/Service/Execute/SwappingStateMachine.cs
@@ -40,6 +40,9 @@ public class SwappingStateMachine : IDisposable
//手动确认解锁/上锁成功
public bool ManualConfirmCarLockFlag { get; set; }
+ //plc任务异常,流程结束
+ public bool PLCAbnormalFlag { get; set; }
+
public OperateModel OperateModel = null;
public readonly LedTool? LedTool = null;
@@ -204,6 +207,10 @@ public class SwappingStateMachine : IDisposable
{
return new StateResult() { SwappingState = SwappingState.ManualSucc };
}
+ else if(status == InvokeStatus.Exception)
+ {
+ return new StateResult() { SwappingState = SwappingState.SwapDone };
+ }
else
{
return StateResult.Exception(exceptionReason, null);
@@ -247,7 +254,11 @@ public class SwappingStateMachine : IDisposable
{
return CancelFlag;
}
-
+ public bool IsPLCAbnormal()
+ {
+ return PLCAbnormalFlag;
+ }
+
public bool IsManualSwapSucc()
{
return ManualSwapSuccFlag;
@@ -358,6 +369,7 @@ public class SwappingStateMachine : IDisposable
ManualConfirmCarLockFlag = false;
CancelFlag = false;
StopFlag = false;
+ PLCAbnormalFlag=false;
}
private void ResetStep()
diff --git a/Service/Mgr/PlcTaskMgr.cs b/Service/Mgr/PlcTaskMgr.cs
index ad4436f..8063b44 100644
--- a/Service/Mgr/PlcTaskMgr.cs
+++ b/Service/Mgr/PlcTaskMgr.cs
@@ -43,10 +43,10 @@ public class PlcTaskMgr
{
Log.Info($"PlcTaskMgr.QueryPlcTask taskNo={taskNo} execute ing");
- if (taskNo == 2)
+ if (taskNo == 6)
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoBatteryMove);
- }else if (taskNo == 5)
+ }else if (taskNo == 7)
{
SoundApi.PlayOneSound((int)InfoEnum.SwapInfo.InfoFireRemove);
}
diff --git a/Service/Plc/Client/PlcMgr.cs b/Service/Plc/Client/PlcMgr.cs
index 5d05a86..8aa0e35 100644
--- a/Service/Plc/Client/PlcMgr.cs
+++ b/Service/Plc/Client/PlcMgr.cs
@@ -237,16 +237,23 @@ public class PlcMgr
///
- /// 下发启动换电
+ /// 下发换电任务以外的任务 6:调库 7:消防
///
+ /// 入仓位
+ /// 出仓位
+ /// 任务类型
///
- public static bool StartSwapping()
+ public static bool StartSwapping(ushort inBinNo, ushort outBinNo, ushort taskNo)
{
if (PlcClient != null)
{
HostToPlc writeHostToPlc = new HostToPlc();
- writeHostToPlc.TaskType.Value = (ushort)1;
- // writeHostToPlc.TaskEnablement.Value = (ushort)1000;
+ writeHostToPlc.TaskType.Value = taskNo;
+ writeHostToPlc.EntrySelection2.Value = inBinNo;
+ writeHostToPlc.ExitSelection2.Value = outBinNo;
+
+ //writeHostToPlc.TaskEnablement.Value = (ushort)1000;
+
bool write1 = PlcClient.WriteValue(writeHostToPlc.TaskType);
//bool write2 = PlcClient.WriteValue(writeHostToPlc.TaskEnablement);
return write1;
@@ -262,12 +269,20 @@ public class PlcMgr
///
/// 查看拍照状态
///
+ /// 位置 1:左侧 2:右侧
///
- public static ushort ChannelStatus()
+ public static ushort ChannelStatus(int location)
{
if (PlcClient != null)
{
- return PlcToHostData.ChannelLocationState.Value;
+ if (location==1)
+ {
+ return PlcToHostData.ChannelLocationState2.Value;
+ }
+ else
+ {
+ return PlcToHostData.ChannelLocationState.Value;
+ }
}
return 0;
diff --git a/Service/Plc/Msg/PlcToHost.cs b/Service/Plc/Msg/PlcToHost.cs
index 4a9a444..f2f07a8 100644
--- a/Service/Plc/Msg/PlcToHost.cs
+++ b/Service/Plc/Msg/PlcToHost.cs
@@ -259,7 +259,7 @@ namespace Service.Plc.Msg
/// 5.维护任务
/// 6.调库任务
/// 7.消防任务
- ///
+ ///
public ModbusProperty TaskType { get; set; } = new(40407);
///
/// 堆垛机任务状态
diff --git a/Service/Station/BinInfoService.cs b/Service/Station/BinInfoService.cs
index cc69c2b..689de67 100644
--- a/Service/Station/BinInfoService.cs
+++ b/Service/Station/BinInfoService.cs
@@ -82,14 +82,15 @@ namespace Service.Station
}
}
- var result = PlcMgr.DistributeTask(0, ushort.Parse(entrySelection), 5);
+ //var result = PlcMgr.DistributeTask(0, ushort.Parse(entrySelection), 5);
+ var result = PlcMgr.StartSwapping(0, ushort.Parse(entrySelection), 7);
if (!result)
{
return Result.Fail();
}
- result = PlcMgr.ReadTaskStatus(5);
+ result = PlcMgr.ReadTaskStatus(7);
if (!result)
{
return Result.Fail();
@@ -104,7 +105,7 @@ namespace Service.Station
Log.Info($"FireProtectionRelocation task Manual removeBinNo={entrySelection} ");
- return PlcTaskMgr.QueryPlcTask(5, 1100, 1101) ? Result.Success() : Result.Fail();
+ return PlcTaskMgr.QueryPlcTask(7, 1100, 1101) ? Result.Success() : Result.Fail();
}
diff --git a/Service/Station/MonitorService.cs b/Service/Station/MonitorService.cs
index 51846a1..6bed8a4 100644
--- a/Service/Station/MonitorService.cs
+++ b/Service/Station/MonitorService.cs
@@ -200,7 +200,7 @@ public class MonitorService
///
/// 电池移仓
///
- ///
+ /// 出仓位
///
///
public Result BatteryRelocation(ushort removeBinNo, ushort putBinNo, int type = 0)
@@ -209,22 +209,31 @@ public class MonitorService
try
{
//校验:出仓位
- BinInfo? removeBin = BinInfoRepository.QueryByClause(i =>
- i.No.Equals(removeBinNo) && (i.ChargeStatus != 1) && i.Exists == 1 &&
- i.AmtLock == 0);
+ BinInfo? removeBin = BinInfoRepository.QueryByClause(i =>
+ i.No.Equals(removeBinNo) && (i.ChargeStatus != 1) && i.Exists == 1 &&
+ i.AmtLock == 0);
- if (removeBin == null)
- {
+ if (removeBin == null)
+ {
return Result.Fail("出仓位状态有误");
- }
+ }
- BinInfo? putBin = BinInfoRepository.QueryByClause(i =>
- i.No.Equals(putBinNo) && i.Exists == 0 && i.AmtLock == 0 &&
- i.Status == 1);
- if (putBin == null)
- {
+ BinInfo? putBin = BinInfoRepository.QueryByClause(i =>
+ i.No.Equals(putBinNo) && i.Exists == 0 && i.AmtLock == 0 );//&& i.Status == 1
+ if (putBin == null)
+ {
return Result.Fail("入仓位状态有误");
- }
+ }
+
+ bool ipsilateral = false;
+ if ((removeBinNo <=8 && putBinNo <= 8)||( removeBinNo > 8 && putBinNo > 8))
+ {
+ ipsilateral = true;
+ }
+ if (!ipsilateral)
+ {
+ return Result.Fail("出仓位和入仓位不在同侧");
+ }
if (PlcMgr.PlcClient?.ReadTaskNo() != 0)
{
@@ -232,35 +241,36 @@ public class MonitorService
return Result.Fail("当前存在其他任务");
}
- PlcMgr.PlcClient?.ExChangeTaskNo(2);
- var result = PlcMgr.DistributeTask(putBinNo, removeBinNo, 2);
-
- if (!result)
- {
+ PlcMgr.PlcClient?.ExChangeTaskNo(6);
+ //var result = PlcMgr.DistributeTask(putBinNo, removeBinNo, 2);
+ var result = PlcMgr.StartSwapping(putBinNo, removeBinNo, 6);
+
+ if (!result)
+ {
PlcMgr.PlcClient?.ExChangeTaskNo(0);
- return Result.Fail();
- }
+ return Result.Fail();
+ }
- int count = 3;
- while (count > 0)
- {
- result = PlcMgr.ReadTaskStatus(2);
- if (result)
+ int count = 3;
+ while (count > 0)
{
- break;
+ result = PlcMgr.ReadTaskStatus(6);
+ if (result)
+ {
+ break;
+ }
+
+ count--;
+ Thread.Sleep(1000);
}
- count--;
- Thread.Sleep(1000);
- }
-
- if (!result)
- {
+ if (!result)
+ {
PlcMgr.PlcClient?.ExChangeTaskNo(0);
- Log.Error("BatteryRelocation PlcMgr.ReadTaskStatus(2) =false");
- return Result.Fail();
- }
+ Log.Error("BatteryRelocation PlcMgr.ReadTaskStatus(6) =false");
+ return Result.Fail();
+ }
moveBinRecord = new MoveBinRecord()
{
@@ -274,62 +284,60 @@ public class MonitorService
Type = type,
CreatedTime = DateTime.Now
};
- moveBinRecord= MoveBinRecordRepository.Insert(moveBinRecord);
+ moveBinRecord = MoveBinRecordRepository.Insert(moveBinRecord);
- result = PlcMgr.HoldOn();
- if (!result)
- {
+ result = PlcMgr.HoldOn();
+ if (!result)
+ {
moveBinRecord.Status = 3;
MoveBinRecordRepository.Update(moveBinRecord);
PlcMgr.PlcClient?.ExChangeTaskNo(0);
- Log.Error("BatteryRelocation PlcMgr.HoldOn() =false");
+ Log.Error("BatteryRelocation PlcMgr.HoldOn() =false");
return Result.Fail();
- }
+ }
Log.Info($"battery move task Manual removeBinNo={removeBinNo}, putBinNo={putBinNo} type={type} ");
moveBinRecord.Status = 1;
MoveBinRecordRepository.Update(moveBinRecord);
- var queryPlcTask = PlcTaskMgr.QueryPlcTask(2, 1200, 1201);
- if (!queryPlcTask)
- {
+ var queryPlcTask = PlcTaskMgr.QueryPlcTask(6, 1200, 1201);
+ if (!queryPlcTask)
+ {
PlcMgr.PlcClient?.ExChangeTaskNo(0);
Log.Info($"move battery fail update moveBin={JsonConvert.SerializeObject(moveBinRecord)}");
moveBinRecord.Status = 3;
MoveBinRecordRepository.Update(moveBinRecord);
- return Result.Fail();
- }
+ return Result.Fail();
+ }
Log.Info($"move battery success update moveBin={JsonConvert.SerializeObject(moveBinRecord)}");
//如果是缓存仓 更新缓存仓的数据
- if (putBin.CacheBinFlag == 1)
- {
- putBin.Exists = 1;
- putBin.BatteryNo = removeBin.BatteryNo;
- putBin.Soc = removeBin.Soc;
- putBin.Soe = removeBin.Soe;
- putBin.Soh = removeBin.Soh;
- putBin.BatteryEnterSeq = removeBin.BatteryEnterSeq;
- putBin.InTime = removeBin.InTime;
- BinInfoRepository.Update(putBin);
- }
+ if (putBin.CacheBinFlag == 1)
+ {
+ putBin.Exists = 1;
+ putBin.BatteryNo = removeBin.BatteryNo;
+ putBin.Soc = removeBin.Soc;
+ putBin.Soe = removeBin.Soe;
+ putBin.Soh = removeBin.Soh;
+ putBin.BatteryEnterSeq = removeBin.BatteryEnterSeq;
+ putBin.InTime = removeBin.InTime;
+ BinInfoRepository.Update(putBin);
+ }
- if (removeBin.CacheBinFlag == 1)
- {
removeBin.Exists = 0;
removeBin.BatteryNo = "-1";
removeBin.Soc = -1;
removeBin.Soe = -1;
removeBin.Soh = -1;
- }
- removeBin.BatteryEnterSeq = 0;
- BinInfoRepository.Update(removeBin);
+ removeBin.BatteryEnterSeq = 0;
+ BinInfoRepository.Update(removeBin);
moveBinRecord.Status = 2;
Log.Info($"move battery success update moveBin={JsonConvert.SerializeObject(moveBinRecord)}");
MoveBinRecordRepository.Update(moveBinRecord);
PlcMgr.PlcClient?.ExChangeTaskNo(0);
+
}
catch (Exception e)
{
diff --git a/WebStarter/Controllers/ChargeMonitorController.cs b/WebStarter/Controllers/ChargeMonitorController.cs
index 8e66d29..0bddbaf 100644
--- a/WebStarter/Controllers/ChargeMonitorController.cs
+++ b/WebStarter/Controllers/ChargeMonitorController.cs
@@ -119,6 +119,7 @@ public class ChargeMonitorController
[HttpGet("BatteryRelocation")]
public async Task> BatteryRelocation(ushort removeBinNo, ushort putBinNo)
{
+ //TODO 只能同侧移仓
return _monitorService.BatteryRelocation(removeBinNo, putBinNo);
}