parent
af052fe1cc
commit
0dd96219a9
@ -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;
|
||||
}
|
||||
}
|
Loading…
Reference in new issue