Plc部分更改

master
CZ 3 days ago
parent af052fe1cc
commit 0dd96219a9

@ -57,6 +57,7 @@ public class CarCtrlState : IState
{
//查询车辆锁止状态
Task<TboxCarInfoModel> carInfo = TBoxApi.GetCarInfo(machine.RfidReadModel.VelVin);
carInfo.Wait();
var resultHeartBeatMsg = carInfo.Result.CarStatus;
if (resultHeartBeatMsg?.LockStatus == 1 || machine.ManualConfirmCarUnlockFlag)
{

@ -132,9 +132,9 @@ public class DoSwappingState : IState
return Invoker.Invoke("StartSwapping", 1000, 5, machine.IsCanceled,
() => machine.StartSwappingFlag, () =>
{
//PlcApi.CarStatus(1);
if (PlcAfricaMgr.PlcAfricaClient.IsTaskFree())
{
PlcApi.CarStatus(1);
var startSwapping = PlcApi.StartSwapping(machine.SwapOrderBatteryInfo.InBinInfo.No,
machine.SwapOrderBatteryInfo.UpBinInfo.No);
@ -256,7 +256,7 @@ public class DoSwappingState : IState
return Invoker.Invoke("plc Pack Finish", 500, 5, machine.IsCanceled,
() => machine.FinishNewBatteryFlag, () =>
{
if (PlcApi.ReadAction()==44 && (PlcApi.RobotWorkFinish() || PlcApi.RobotReady()))
if (PlcApi.ReadAction()==44 || PlcApi.RobotWorkFinish() || PlcApi.RobotReady())
{
machine.FinishNewBatteryFlag = true;
machine.BusinessSwappingForCloudState =

@ -175,7 +175,8 @@ public class StationReadyState : IState
public InvokeStatus ControlRadar(SwappingStateMachine machine, byte flag)
{
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () => PadarMgr._PadarClient?.CarState > 0
return Invoker.Invoke("begin Radar", 1000, 20, machine.IsCanceled, () =>
PadarMgr._PadarClient?.CarState > 0
|| machine.ManualSkipRadar,
() => { PadarMgr._PadarClient?.PadarControl(flag); });
}

@ -0,0 +1,81 @@
using HybirdFrameworkCore.Autofac.Attribute;
using HybirdFrameworkCore.AutoTask;
using log4net;
using Service.Execute;
using Service.Execute.Api;
using Service.PlcAfrica.Client;
using Service.PlcAfrica.Msg;
namespace Service.MyTask;
[Scope]
public class WritePlcTask : ITask
{
private static readonly ILog Log = LogManager.GetLogger("WritePlcTask");
private volatile bool _stop;
private PlcAfricaMsg PlcAfricaMsg = new PlcAfricaMsg();
public string Name()
{
return "WritePlcTask";
}
public int Interval()
{
return 1000 * 1;
}
private static bool heart = false;
public void Handle()
{
Log.Info("Plc Start write");
PlcAfricaMsg.TboxUnlock.Value = 0;
if (StationSoftMgr.SwappingStateMachine != null)
{
var swappingStateMachine = StationSoftMgr.SwappingStateMachine;
if (swappingStateMachine.BoxConnectFlag) //TBOX
{
var carInfo = TBoxApi.GetCarInfo(swappingStateMachine.RfidReadModel.VelVin);
carInfo.Wait();
if (swappingStateMachine.BoxCarInfoModel != null && carInfo != null)
{
PlcAfricaMsg.TboxUnlock.Value = (ushort)carInfo.Result?.CarStatus?.LockStatus;
bool writeCharge = PlcAfricaMgr.PlcAfricaClient.WriteValue(PlcAfricaMsg.TboxUnlock);
Log.Info($"写锁止状态:{PlcAfricaMsg.TboxUnlock.Value}");
}
else
{
bool writeCharge = PlcAfricaMgr.PlcAfricaClient.WriteValue(PlcAfricaMsg.TboxUnlock);
Log.Info($"写锁止状态:{PlcAfricaMsg.TboxUnlock.Value}");
}
}
else
{
bool writeCharge = PlcAfricaMgr.PlcAfricaClient.WriteValue(PlcAfricaMsg.TboxUnlock);
Log.Info($"写锁止状态:{PlcAfricaMsg.TboxUnlock.Value}");
}
}
else
{
bool writeCharge = PlcAfricaMgr.PlcAfricaClient.WriteValue(PlcAfricaMsg.TboxUnlock);
Log.Info($"写锁止状态:{PlcAfricaMsg.TboxUnlock.Value}");
}
}
public bool Stoped()
{
return _stop;
}
public void Stop()
{
_stop = true;
}
public void ResetStop()
{
_stop = false;
}
}

@ -155,7 +155,7 @@ namespace Service.PlcAfrica.Client
if (PlcAfricaClient == null)
{
PlcAfricaMsg.TboxUnlock.Value = cmd;
return PlcAfricaClient!.WriteValue(PlcAfricaMsg.TboxUnlock);
return PlcAfricaClient.WriteValue(PlcAfricaMsg.TboxUnlock);
}

@ -322,16 +322,17 @@ public class PlcAfricaMsg
/// 加载机1落座传感器1 0-不在位1-在位
/// </summary>
public ModbusProperty<bool> Loader1SeatSensor1 {get;set;}= new(49043,start:0,length:1,type:ModbusDataType.Bit);
/// <summary>
/// 加载机1落座传感器2
/// 加载机2落座传感器1
/// </summary>
public ModbusProperty<bool> Loader1SeatSensor2 {get;set;}= new(49043,start:1,length:1,type:ModbusDataType.Bit);
public ModbusProperty<bool> Loader2SeatSensor1 {get;set;}= new(49043,start:1,length:1,type:ModbusDataType.Bit);
/// <summary>
/// 加载机2落座传感器1
/// 加载机1落座传感器2
/// </summary>
public ModbusProperty<bool> Loader2SeatSensor1 {get;set;}= new(49043,start:1,length:1,type:ModbusDataType.Bit);
public ModbusProperty<bool> Loader1SeatSensor2 {get;set;}= new(49043,start:1,length:1,type:ModbusDataType.Bit);
/// <summary>
/// 加载机2落座传感器2
@ -596,4 +597,11 @@ public class PlcAfricaMsg
/// </summary>
public ModbusProperty<bool> TransferBinSeatSensor2 {get;set;}= new(49438,start:1,length:1,type:ModbusDataType.Bit);
/// <summary>
/// 电池充电状态
/// </summary>
public ModbusProperty<ushort> ChargerState1 {get;set;}= new(49437);
public ModbusProperty<ushort> ChargerState2 {get;set;}= new(49437);
public ModbusProperty<ushort> ChargerState3 {get;set;}= new(49437);
public ModbusProperty<ushort> ChargerState4 {get;set;}= new(49437);
}
Loading…
Cancel
Save