dc/Handlers/S1F4Handler.cs
13118993771@163.com 562bd7a7b8 新版
2023-02-23 11:33:23 +08:00

96 líneas
4.8 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 = Configurations.conf.commandContentCollection.findContent("S1F3").content;
for(int i = 0; i < content.Count; i++)
{
if (trans.Secondary.Root.Item(i + 1).Value != null)
{
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.CommunicationState = 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(trans, LoggerService.Receive, "Selected Equipment Status Request", 1);
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();
}
}
}
}