SecsMessageSendUtil.cs 2.2 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. using SecsGem.Core;
  2. using SecsGem.Core.EnumData;
  3. using SecsGem.Core.Hsms;
  4. using SecsGem.Core.ItemModel;
  5. using System;
  6. using System.Collections.Generic;
  7. using System.Linq;
  8. using System.Text;
  9. using System.Threading.Tasks;
  10. namespace EapClientSimulator
  11. {
  12. public class SecsMessageSendUtil
  13. {
  14. public static SecsMessage CreateS1F13Message()
  15. {
  16. SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
  17. {
  18. Stream = 0x01,
  19. Function = 13,
  20. SType = SType.DataMessage,
  21. TransactionId = IdGenerator.GenerateTransactionId(),
  22. ReplyFlag = true,
  23. };
  24. Item item = new ListItem();
  25. return new SecsMessage(secsMessageHeader, item, true);
  26. }
  27. /// <summary>
  28. /// 建立通讯S1F13
  29. /// </summary>
  30. /// <returns></returns>
  31. public static SecsMessage CreateS2F49Message(RemoteCommand remoteCommand)
  32. {
  33. SecsHsmsMessageHeader secsMessageHeader = new SecsHsmsMessageHeader()
  34. {
  35. Stream = 0x02,
  36. Function = 49,
  37. SType = SType.DataMessage,
  38. TransactionId = IdGenerator.GenerateTransactionId(),
  39. ReplyFlag = true,
  40. };
  41. Item item = new ListItem();
  42. Item dataIdItem = new IntItem(1);
  43. item.AddItem(dataIdItem);
  44. Item objSpecItem=new IntItem(0);
  45. item.AddItem(objSpecItem);
  46. Item rmcdItem = new StringItem(DataFormat.Ascii, remoteCommand.Command);
  47. item.AddItem(rmcdItem);
  48. Item parameters = new ListItem();
  49. for(int i = 0; i < remoteCommand.RemoteParameters.Count; i++)
  50. {
  51. Item lstItem=new ListItem();
  52. Item paramNameItem = new StringItem(DataFormat.Ascii, remoteCommand.RemoteParameters[i].Name);
  53. lstItem.AddItem(paramNameItem);
  54. lstItem.AddItem(remoteCommand.RemoteParameters[i].Value);
  55. parameters.AddItem(lstItem);
  56. }
  57. item.AddItem(parameters);
  58. return new SecsMessage(secsMessageHeader, item, true);
  59. }
  60. }
  61. }