master
lxw 3 days ago
parent 18c671dbda
commit 48957e1a9e

@ -17,6 +17,7 @@ using Service.Execute.Utils;
using Service.Init;
using Service.Led;
using Service.Padar.Client;
using Service.PlcAfrica.Client;
using Service.Sound.SoundClient;
namespace Service.Execute.Step;
@ -67,7 +68,7 @@ public class DoSwappingState : IState
{
return SwappingStateMachine.ReturnWithInvokeErr(packFinish, ExceptionReason.None);
}
ClientMgr.PlcClient.ResetTaskNo();
PlcAfricaMgr.PlcAfricaClient.ResetTaskNo();
return new StateResult()
{
@ -131,10 +132,9 @@ public class DoSwappingState : IState
return Invoker.Invoke("StartSwapping", 1000, 5, machine.IsCanceled,
() => machine.StartSwappingFlag, () =>
{
if (ClientMgr.PlcClient.IsTaskFree())
if (PlcAfricaMgr.PlcAfricaClient.IsTaskFree())
{
PlcApi.CarStatus(1);
// ClientMgr.PlcClient.ExChangeTaskNo(1);
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
machine.SwapOrderBatteryInfo.UpBinInfo.No);
@ -151,7 +151,7 @@ public class DoSwappingState : IState
//查詢當前任務狀態是否被更改
if (startSwapping)
{
ClientMgr.PlcClient.ExChangeTaskNo(1);
PlcAfricaMgr.PlcAfricaClient.ExChangeTaskNo(1);
machine.SwapOrder.SwapBeginTime = DateTime.Now;
_CommonMgr.UpdateSwapOrder(machine);
machine.SwapStatus = 0;

@ -15,6 +15,7 @@ namespace Service.PlcAfrica.Client
[Scope]
public class PlcAfricaClient : ModbusTcpMaster
{
private long TaskNo = 0;
public PlcAfricaClient()
{
ReadAction = BatchRead;
@ -45,5 +46,28 @@ namespace Service.PlcAfrica.Client
return resul;
}
//修改当前任务
public void ExChangeTaskNo(long taskNo)
{
Interlocked.Exchange(ref TaskNo, taskNo);
}
//重置当前任务
public void ResetTaskNo()
{
Interlocked.Exchange(ref TaskNo, 0);
}
public bool IsTaskFree()
{
return ReadTaskNo() == 0l;
}
//读取当前任务
public long ReadTaskNo()
{
return Interlocked.Read(ref TaskNo);
}
}
}

Loading…
Cancel
Save