#region << 版 本 注 释 >> /*---------------------------------------------------------------- * 创建者:Hupe * 创建时间:2021/10/27 16:08:09 * 版本:V1.0.0 * 描述: * * ---------------------------------------------------------------- * 修改人: * 时间: * 修改说明: * * 版本:V1.0.1 *----------------------------------------------------------------*/ #endregion << 版 本 注 释 >> using ARI.EAP.HOST.Common; using ARI.EAP.HOST.Common.Entity; using ARI.EAP.HOST.MQ; using ARI.EAP.HOST.MQ.body; using ARI.EAP.HOST.SRD; using ARI.EAP.HOST.Utilities; using Glorysoft.SECS.EQP; using Glorysoft.SECS.EQP.Commands; using Glorysoft.SECS.EQP.Message; using Glorysoft.SECS.EQP.Utilities; using Newtonsoft.Json.Linq; using System; using System.Collections.Generic; using System.Linq; using System.Reflection; using System.Text; using System.Threading.Tasks; using System.Net; using System.IO; namespace ARI.EAP.HOST.Handlers.EventHandlers { /// /// MESRequestHandler 的摘要说明 /// 利用反射将事件名称和方法对应起来 /// public class MESRequestHandler { public static void Execute(MQMessage mQMessage) { try { Header header = mQMessage.header; JObject body = null; if (mQMessage.body != null) { body = JObject.Parse(mQMessage.body.ToString()); } Type type = typeof(MESRequestHandler); MethodInfo method = type.GetMethod(header.messageName); if (method == null) throw new Exception("method is null"); method.Invoke(null, new object[] { body }); ReturnBody returnbody = new ReturnBody(0); mQMessage.body = returnbody; mQMessage.header.from = "EAP"; mQMessage.header.to = "MES"; mQMessage.header.messageType = "Response"; Task.Run(() => MainForm.mq.EAPResponse(mQMessage)); } catch (Exception e) { LoggerService.SECSLogger.Error("MES Request 接口映射出错:" + e); }; } public static void Target_Update(JObject body = null) { string VSubstrateId = body["virtualId"].ToString(); string substrateId = body["substrateId"].ToString(); S2F49Item item = new S2F49Item(); item.DATAID = EquipmentStatus.commandCount++; item.OBJSPEC = ""; item.RCMD = "NEW-SUBSTRATEID"; Param p1 = new Param(); p1.ParanName = "ToolName"; p1.ParanVal = Configuration.conf.connectSetting.name; item.PARAMS.Add(p1); Param p2 = new Param(); p2.ParanName = "STATIONID"; p2.ParanVal = "LSTA_1"; item.PARAMS.Add(p2); Param p3 = new Param(); p3.ParanName = "VIRTUALSUBSTRATEID"; p3.ParanVal = VSubstrateId; item.PARAMS.Add(p3); Param p4 = new Param(); p4.ParanName = "SUBSTRATEID"; p4.ParanVal = substrateId; item.PARAMS.Add(p4); Command.S2F49Command(item); } public static void RequestChangeControlState(JObject body = null) { if (body["controlState"].ToString() == "4") { Global.MF.pushBotton("Local"); } else if (body["controlState"].ToString() == "5") { Global.MF.pushBotton("Remote"); } } public static void RequestS1F3(JObject body = null) { Global.MF.pushBotton("S1F3Request"); } public static void RequestS2F13(JObject body = null) { Global.MF.pushBotton("S2F13"); } public static void RequestS7F19(JObject body = null) { Global.MF.pushBotton("S7F19"); } public static void RequestS7F5(JObject body = null) { } public static void RequestS5F5(JObject body = null) { Global.MF.pushBotton("S5F5"); } public static void RequestS5F3(JObject body = null) { if (EquipmentStatus.S5F3 == "AlarmEnable" && body["enabledorDisabled"].ToString().Equals("0")) { Global.MF.pushBotton("S5F3"); } else if(EquipmentStatus.S5F3 == "AlarmDisable" && body["enabledorDisabled"].ToString().Equals("1")) { Global.MF.pushBotton("S5F3"); } } public static void RequestChangeE10State(JObject body = null) { S2F49Item item = new S2F49Item(); item.DATAID = EquipmentStatus.commandCount++; item.OBJSPEC = ""; item.RCMD = "EQSTATEUPDATE"; Param p1 = new Param(); p1.ParanName = "ToolName"; p1.ParanVal = Configuration.conf.connectSetting.name; item.PARAMS.Add(p1); Param p2 = new Param(); p2.ParanName = "NEWSTATE"; p2.ParanVal = body["e10State"].ToString(); item.PARAMS.Add(p2); Command.S2F49Command(item); } public static void RequestSlotList(JObject body = null) { S2F49Item item = new S2F49Item(); item.DATAID = EquipmentStatus.commandCount++; item.OBJSPEC = ""; item.RCMD = "Slotlist_Request"; Command.S2F49Command(item); } public static void RequestStart(JObject body = null) { Global.MF.pushBotton("Connect"); } public static void RequestStop(JObject body = null) { if(SimulatorInfo.Instance.Context != null) SimulatorInfo.Instance.Context.Close(); } public static void UploadFile(JObject body = null) { long fileId = long.Parse(body["fileId"].ToString()); DownLoadFileParam downLoadFileParam = new DownLoadFileParam(fileId, Constants.eapName + ".xml", "1"); string param = SECSUtil.ObjectToGetParam(downLoadFileParam); HttpWebResponse response = HttpUtils.sentGET(Configuration.conf.httpConfiguration.fileDownloadUrl, param); if(response.StatusCode != HttpStatusCode.OK) { return; } using(Stream respnseStream = response.GetResponseStream()) { using(Stream fileStream = new FileStream(Constants.configuerPath, FileMode.Create)) { byte[] bArr = new byte[1024]; int size = respnseStream.Read(bArr, 0, (int)bArr.Length); while (size > 0) { fileStream.Write(bArr, 0, size); size = respnseStream.Read(bArr, 0, (int)bArr.Length); } fileStream.Close(); } respnseStream.Close(); } } } }