dc/Handlers/S1F4Handler.cs
13118993771@163.com b593a243a5 V1.0
2022-07-27 14:46:20 +08:00

93 lines
4.6 KiB
C#

// ********************************************************************************
// 文件名字: S1F4Handler
// 文件描述: S1F4Handler
// 开发人员: Michael
// 创建时间: 2019/11/8 0:08
//
// 更新历史:
// + 创建 S1F4Handler.cs 文件. by Michael @2019/11/8 0:08
// ********************************************************************************
using ARI.EAP.HOST;
using ARI.EAP.HOST.MQ;
using ARI.EAP.HOST.MQ.body;
using ARI.EAP.HOST.SRD;
using Glorysoft.SECS.EQP.Common;
using Glorysoft.SECS.EQP.Message;
using Glorysoft.SECS.EQP.Utilities;
using Glorysoft.SECSwell;
using System;
using System.Collections.Generic;
using System.Threading;
using System.Threading.Tasks;
namespace Glorysoft.SECS.EQP.Handlers
{
public class S1F4Handler : ISECSMessageHandler
{
public void Execute(SECSContext context, SECSTransaction trans, SECSErrors err, string errmsg)
{
MQMessage mQMessage = new MQMessage();
mQMessage.header.messageName = "SVList";
SVListBody sVListBody = new SVListBody();
var content = Configuration.conf.commandContentCollection.findContent("S1F3").content;
for(int i = 0; i < content.Count; i++)
{
switch (content[i])
{
case "Clock":
sVListBody.eventTimestamp = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.eventTimestamp);
break;
case "CommunicationState":
trans.Secondary.Root.Item(i + 1).Name = nameof(sVListBody.CommunicationState);
sVListBody.ControlState = trans.Secondary.Root.Item(i + 1).Value.ToString();
break;
case "CurrentControlState":
sVListBody.ControlState = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.ControlState);
break;
case "PreviousControlState":
sVListBody.PreviousControlState = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.PreviousControlState);
break;
case "CurrentEquipmentState":
sVListBody.CurrentEquipmentState = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.CurrentEquipmentState);
break;
case "PreviousEquipmentState":
sVListBody.PreviousEquipmentState = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.PreviousEquipmentState);
break;
case "PPExecName":
sVListBody.PPExecName = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.PPExecName);
break;
case "SpoolingState":
sVListBody.SpoolingState = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.SpoolingState);
break;
case "SpoolCountActual":
sVListBody.SpoolCountActual = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.SpoolCountActual);
break;
case "SpoolCountTotal":
sVListBody.SpoolCountTotal = trans.Secondary.Root.Item(i+1).Value.ToString();
trans.Secondary.Root.Item(i+1).Name = nameof(sVListBody.SpoolCountTotal);
break;
}
}
Global.MF.addlog(LoggerService.EtoH, $"S{trans.Secondary.Stream}F{trans.Secondary.Function}", LoggerService.Receive, trans.Description, "=" + trans.Secondary.SystemBytes.ToString());
LoggerService.SECSLogger.Info(trans.Secondary);
mQMessage.body = sVListBody;
Task.Run(() => MainForm.mq.EAPRequest(mQMessage));
if (trans.Tag != null)
{
var scenario = trans.Tag as Scenario;
Thread.Sleep(500);
scenario.ExecuteNextStep();
}
}
}
}