using SecsGem.Core.SecsEnumData; using SecsGem.Core; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using SecsGem.Core.ItemModel; using SecsGem.Core.EnumData; using SecsGem.Core.Hsms; namespace EapClientSimulator { public class SecsMessageReplyUtil { /// /// 构建连接测试命令(心跳) /// /// /// public static SecsMessage CreateLinkTestReplyMessage(int transactionId) { SecsHsmsMessageHeader header = new SecsHsmsMessageHeader() { Stream = 0, Function = 0, SType = SType.LinkTestResponse, TransactionId = transactionId, ReplyFlag = false }; return new SecsMessage(header, null); } #region S1 Reply Message public static SecsMessage CreateS1F13ReplyMessage(int transactionId, SecsCOMMACK COMMACK) { SecsHsmsMessageHeader header = new SecsHsmsMessageHeader() { Stream = 0x01, Function = 14, SType = SType.DataMessage, TransactionId = transactionId, ReplyFlag = false }; Item item = new ListItem(); Item commackItem = new BinaryItem((byte)COMMACK); item.AddItem(commackItem); Item subItem = new ListItem(); StringItem mdlnItem = new StringItem(DataFormat.Ascii, "EAP"); subItem.AddItem(mdlnItem); StringItem verItem = new StringItem(DataFormat.Ascii, "1.0.1"); subItem.AddItem(verItem); item.AddItem(subItem); return new SecsMessage(header, item); } public static SecsMessage CreateS1F1ReplyMessage(int transactionId) { SecsHsmsMessageHeader header = new SecsHsmsMessageHeader() { Stream = 0x01, Function = 2, SType = SType.DataMessage, TransactionId = transactionId, ReplyFlag = false }; Item item = new ListItem(); StringItem mdlnItem = new StringItem(DataFormat.Ascii, "EAP"); item.AddItem(mdlnItem); StringItem verItem = new StringItem(DataFormat.Ascii, "1.0.1"); item.AddItem(verItem); return new SecsMessage(header, item); } #endregion #region S5 public static SecsMessage CreateS5F1ReplyMessage(int transactionId) { SecsHsmsMessageHeader header = new SecsHsmsMessageHeader() { Stream = 0x05, Function = 2, SType = SType.DataMessage, TransactionId = transactionId, ReplyFlag = false }; Item item = new BinaryItem(0); return new SecsMessage(header, item); } #endregion #region S6 public static SecsMessage CreateS6F11ReplyMessage(int transactionId) { SecsHsmsMessageHeader header = new SecsHsmsMessageHeader() { Stream = 0x06, Function = 12, SType = SType.DataMessage, TransactionId = transactionId, ReplyFlag = false }; Item item = new BinaryItem(0); return new SecsMessage(header, item); } #endregion } }