修改消防移仓

master
lch 6 months ago
parent 151e11aef5
commit 623f0e3bce

@ -0,0 +1,29 @@
namespace Service.Execute.Model;
/// <summary>
/// 消防移仓
/// </summary>
public class FireProtectionRelocation
{
/// <summary>
/// 任务类型
/// <para>0.无任务</para>
/// <para>1.换电任务</para>
/// <para>2.移舱任务</para>
/// <para>3.移出任务</para>
/// <para>4.移入任务</para>
/// <para>5.消防任务</para>
/// </summary>
public ushort TaskType { get; set; }
/// <summary>
/// 入仓位选择
/// </summary>
public ushort EntrySelection { get; set; }
/// <summary>
/// 出仓位选择
/// </summary>
public ushort ExitSelection { get; set; }
/// <summary>
/// 电池包类型
/// </summary>
public ushort BatteryPackType { get; set; }
}

@ -1,4 +1,5 @@
using Autofac; using Autofac;
using log4net;
using HslCommunication; using HslCommunication;
using HybirdFrameworkCore.Autofac; using HybirdFrameworkCore.Autofac;
using HybirdFrameworkCore.Utils; using HybirdFrameworkCore.Utils;
@ -346,7 +347,7 @@ public class PlcMgr
} }
return bResult; return bResult;
} }
private static readonly ILog Log = LogManager.GetLogger(typeof(FireProtectionRelocation));
/// <summary> /// <summary>
/// 消防移仓 /// 消防移仓
/// </summary> /// </summary>
@ -354,22 +355,42 @@ public class PlcMgr
/// <returns></returns> /// <returns></returns>
public static bool FireProtectionRelocation(ushort entrySelection) public static bool FireProtectionRelocation(ushort entrySelection)
{ {
//TODO::
bool bResult = false; bool bResult = false;
if (PlcClient != null) if (PlcClient != null)
{ {
HostToPlc writeHostToPlc = new HostToPlc(); FireProtectionRelocation distributeTask = new()
writeHostToPlc.TaskType.Value = 5; {
writeHostToPlc.EntrySelection.Value = entrySelection; TaskType = 5,
writeHostToPlc.ExitSelection.Value = 5; EntrySelection = entrySelection,
writeHostToPlc.BatteryPackType.Value = 0; ExitSelection = 5,
//TODO:: 连续写多个寄存器 是否影响速度 BatteryPackType = 0
bool bResultTaskType = PlcClient.WriteValue(writeHostToPlc.TaskType); };
bool bResultEntrySelection = PlcClient.WriteValue(writeHostToPlc.EntrySelection); byte[] encode = ModelConvert.Encode(distributeTask);
bool bResultExitSelection = PlcClient.WriteValue(writeHostToPlc.ExitSelection); //TODO::現在手動處理encode
bool bResultBatteryPackType = PlcClient.WriteValue(writeHostToPlc.BatteryPackType); for (int i = 0; i < encode.Length; i++)
if (bResultTaskType && bResultEntrySelection && bResultExitSelection && bResultBatteryPackType) {
if (i % 2 == 0)
{
var temp = encode[i + 1];
encode[i + 1] = encode[i];
encode[i] = temp;
}
}
//需要将数据转换成byte数组
OperateResult operateResult = PlcClient.Write("x=16;111",encode);
//查询人物状态
if (operateResult.IsSuccess)
{ {
bResult = true; bool readPlcTaskStatus9000 = false;
while (!readPlcTaskStatus9000)
{
Thread.Sleep(1000);
readPlcTaskStatus9000 = PlcMgr.ReadPlcTaskStatus() == 9000;
}
Log.Info($"execute FireProtectionRelocation success from EntrySelection ={distributeTask.EntrySelection}");
} }
} }
return bResult; return bResult;

Loading…
Cancel
Save