dc/Handlers/EventHandlers/AlarmClearedHandler.cs

96 lines
3.7 KiB
C#
Raw Normal View History

2022-04-01 17:03:54 +08:00
#region << >>
/*----------------------------------------------------------------
* Hupe
* 2021/10/14 20:04:50
* V1.0.0
*
*
* ----------------------------------------------------------------
*
*
*
*
* V1.0.1
*----------------------------------------------------------------*/
#endregion << >>
using ARI.EAP.HOST.Common;
using ARI.EAP.HOST.MQ;
using ARI.EAP.HOST.MQ.body;
using ARI.EAP.HOST.SRD;
using Glorysoft.SECS.EQP;
using Glorysoft.SECS.EQP.Common;
using Glorysoft.SECS.EQP.Utilities;
using Glorysoft.SECSwell;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ARI.EAP.HOST.Handlers.EventHandlers
{
public class AlarmClearedHandler : IEventHandler
{
public void Execute(SECSTransaction trans, EVENT even)
{
try
{
MQMessage mQMessage = new MQMessage();
mQMessage.header.messageName = "AlarmReport";
AlarmReportBody alarmReportBody = new AlarmReportBody();
alarmReportBody.spoolingFlag = EquipmentStatus.SpoolingFlag.ToString();
alarmReportBody.alarmStatus = "0";
int index = 1;
foreach (var key in even.validVariables)
{
string name = Configuration.conf.sRDConfiguration.tryGetSVOrDV(key);
switch (name)
{
case ("AlarmID"):
{
alarmReportBody.alarmCode = trans.Primary.Root.Item(3).Item(2).Item(index).Value.ToString();
}
break;
case ("Clock"):
{
alarmReportBody.eventTimestamp = trans.Primary.Root.Item(3).Item(2).Item(index).Value.ToString();
}
break;
case ("StateFlag"):
{
alarmReportBody.stateFlag = trans.Primary.Root.Item(3).Item(2).Item(index).Value.ToString();
}
break;
case ("AlarmText"):
{
alarmReportBody.alarmText = trans.Primary.Root.Item(3).Item(2).Item(index).Value.ToString();
}
break;
case ("AlarmCategory"):
{
alarmReportBody.alarmCategory = trans.Primary.Root.Item(3).Item(2).Item(index).Value.ToString();
}
break;
}
trans.Primary.Root.Item(3).Item(2).Item(index).Name = name;
index++;
}
Global.MF.addlog(LoggerService.EtoH, $"S{trans.Primary.Stream}F{trans.Primary.Function}", LoggerService.Receive, even.name, "=" + trans.Primary.SystemBytes.ToString());
LoggerService.SECSLogger.Info(trans.Primary);
Global.MF.addlog(LoggerService.HtoE, $"S{trans.Secondary.Stream}F{trans.Secondary.Function}", LoggerService.Send, even.name, "=" + trans.Secondary.SystemBytes.ToString());
LoggerService.SECSLogger.Info(trans.Secondary);
mQMessage.body = alarmReportBody;
Task.Run(() => MainForm.mq.EAPRequest(mQMessage));
}
catch (Exception e)
{
LoggerService.SECSLogger.Error(e);
}
}
}
}