SecsMessageReplyUtil.cs 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. using SecsGem.Core.SecsEnumData;
  2. using SecsGem.Core;
  3. using System;
  4. using System.Collections.Generic;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using SecsGem.Core.ItemModel;
  9. using SecsGem.Core.EnumData;
  10. using SecsGem.Core.Hsms;
  11. namespace EapClientSimulator
  12. {
  13. public class SecsMessageReplyUtil
  14. {
  15. /// <summary>
  16. /// 构建连接测试命令(心跳)
  17. /// </summary>
  18. /// <param name="deviceId"></param>
  19. /// <returns></returns>
  20. public static SecsMessage CreateLinkTestReplyMessage(int transactionId)
  21. {
  22. SecsHsmsMessageHeader header = new SecsHsmsMessageHeader()
  23. {
  24. Stream = 0,
  25. Function = 0,
  26. SType = SType.LinkTestResponse,
  27. TransactionId = transactionId,
  28. ReplyFlag = false
  29. };
  30. return new SecsMessage(header, null);
  31. }
  32. #region S1 Reply Message
  33. public static SecsMessage CreateS1F13ReplyMessage(int transactionId, SecsCOMMACK COMMACK)
  34. {
  35. SecsHsmsMessageHeader header = new SecsHsmsMessageHeader()
  36. {
  37. Stream = 0x01,
  38. Function = 14,
  39. SType = SType.DataMessage,
  40. TransactionId = transactionId,
  41. ReplyFlag = false
  42. };
  43. Item item = new ListItem();
  44. Item commackItem = new BinaryItem((byte)COMMACK);
  45. item.AddItem(commackItem);
  46. Item subItem = new ListItem();
  47. StringItem mdlnItem = new StringItem(DataFormat.Ascii, "EAP");
  48. subItem.AddItem(mdlnItem);
  49. StringItem verItem = new StringItem(DataFormat.Ascii, "1.0.1");
  50. subItem.AddItem(verItem);
  51. item.AddItem(subItem);
  52. return new SecsMessage(header, item);
  53. }
  54. public static SecsMessage CreateS1F1ReplyMessage(int transactionId)
  55. {
  56. SecsHsmsMessageHeader header = new SecsHsmsMessageHeader()
  57. {
  58. Stream = 0x01,
  59. Function = 2,
  60. SType = SType.DataMessage,
  61. TransactionId = transactionId,
  62. ReplyFlag = false
  63. };
  64. Item item = new ListItem();
  65. StringItem mdlnItem = new StringItem(DataFormat.Ascii, "EAP");
  66. item.AddItem(mdlnItem);
  67. StringItem verItem = new StringItem(DataFormat.Ascii, "1.0.1");
  68. item.AddItem(verItem);
  69. return new SecsMessage(header, item);
  70. }
  71. #endregion
  72. #region S5
  73. public static SecsMessage CreateS5F1ReplyMessage(int transactionId)
  74. {
  75. SecsHsmsMessageHeader header = new SecsHsmsMessageHeader()
  76. {
  77. Stream = 0x05,
  78. Function = 2,
  79. SType = SType.DataMessage,
  80. TransactionId = transactionId,
  81. ReplyFlag = false
  82. };
  83. Item item = new BinaryItem(0);
  84. return new SecsMessage(header, item);
  85. }
  86. #endregion
  87. #region S6
  88. public static SecsMessage CreateS6F11ReplyMessage(int transactionId)
  89. {
  90. SecsHsmsMessageHeader header = new SecsHsmsMessageHeader()
  91. {
  92. Stream = 0x06,
  93. Function = 12,
  94. SType = SType.DataMessage,
  95. TransactionId = transactionId,
  96. ReplyFlag = false
  97. };
  98. Item item = new BinaryItem(0);
  99. return new SecsMessage(header, item);
  100. }
  101. #endregion
  102. }
  103. }