SECSTransactionBuilder.cs 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. using Brooks.WinSECS;
  2. using System;
  3. using System.Collections.Generic;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. namespace MECF.Framework.RT.EquipmentLibrary.HardwareUnits.LoadPorts.Fortrend
  8. {
  9. public static class SECSTransactionBuilder
  10. {
  11. public static SECSTransaction BuildS2F15(int id,int value)
  12. {
  13. SECSTransaction secsTransaction = new SECSTransaction(2, 15);
  14. secsTransaction.Primary.Root.Name = "HCS";
  15. secsTransaction.Primary.Root.AddNew("L2", "");
  16. secsTransaction.Primary.Root.Item("L2").Format = SECS_FORMAT.LIST;
  17. secsTransaction.Primary.Root.Item("L2").AddNew("NAME", "ECID NAME");
  18. secsTransaction.Primary.Root.Item("L2").Item("NAME").Format = SECS_FORMAT.U1;
  19. secsTransaction.Primary.Root.Item("L2").Item("NAME").Value = id;
  20. secsTransaction.Primary.Root.Item("L2").AddNew("VALUE", "ECID VALUE");
  21. secsTransaction.Primary.Root.Item("L2").Item("VALUE").Format = SECS_FORMAT.U1;
  22. secsTransaction.Primary.Root.Item("L2").Item("VALUE").Value = value;
  23. return secsTransaction;
  24. }
  25. public static SECSTransaction BuildS1F5(int formCode)
  26. {
  27. SECSTransaction secsTransaction = new SECSTransaction(1, 5);
  28. secsTransaction.Primary.Root.Name = "FSR";
  29. secsTransaction.Primary.Root.AddNew("SFCD", "Status form code");
  30. secsTransaction.Primary.Root.Item("SFCD").Format = SECS_FORMAT.BINARY;
  31. secsTransaction.Primary.Root.Item("SFCD").Value = formCode;
  32. secsTransaction.ReplyExpected = true;
  33. return secsTransaction;
  34. }
  35. public static SECSTransaction BuildS2F41(int rcmd, string cpname = "", string cpval = "")
  36. {
  37. SECSTransaction secsTransaction = new SECSTransaction(2, 41);
  38. secsTransaction.Primary.Root.Name = "HCS";
  39. secsTransaction.Primary.Root.AddNew("L2", "");
  40. secsTransaction.Primary.Root.Item("L2").Format = SECS_FORMAT.LIST;
  41. secsTransaction.Primary.Root.Item("L2").AddNew("RCMD", "Remote command code");
  42. secsTransaction.Primary.Root.Item("L2").Item("RCMD").Format = SECS_FORMAT.U1;
  43. secsTransaction.Primary.Root.Item("L2").Item("RCMD").Value = rcmd;
  44. secsTransaction.Primary.Root.Item("L2").AddNew("Ln", "");
  45. secsTransaction.Primary.Root.Item("L2").Item("Ln").Format = SECS_FORMAT.LIST;
  46. if (cpval != "")
  47. {
  48. secsTransaction.Primary.Root.Item("L2").Item("Ln").AddNew("CPAL", "Command parameter value");
  49. secsTransaction.Primary.Root.Item("L2").Item("Ln").Item("CPAL").Format = SECS_FORMAT.U2;
  50. secsTransaction.Primary.Root.Item("L2").Item("Ln").Item("CPAL").Value = cpval;
  51. }
  52. secsTransaction.ReplyExpected = true;
  53. return secsTransaction;
  54. }
  55. public static SECSTransaction BuildS2F21(int rcmd, string cpname = "", string cpval = "")
  56. {
  57. SECSTransaction secsTransaction = new SECSTransaction(2, 21);
  58. secsTransaction.Primary.Root.Name = "HCS";
  59. secsTransaction.Primary.Root.AddNew("L2", "");
  60. secsTransaction.Primary.Root.Item("L2").Format = SECS_FORMAT.LIST;
  61. secsTransaction.Primary.Root.Item("L2").AddNew("RCMD", "Remote command code");
  62. secsTransaction.Primary.Root.Item("L2").Item("RCMD").Format = SECS_FORMAT.U1;
  63. secsTransaction.Primary.Root.Item("L2").Item("RCMD").Value = rcmd;
  64. secsTransaction.Primary.Root.Item("L2").AddNew("Ln", "");
  65. secsTransaction.Primary.Root.Item("L2").Item("Ln").Format = SECS_FORMAT.LIST;
  66. if (cpval != "")
  67. {
  68. secsTransaction.Primary.Root.Item("L2").Item("Ln").AddNew("CPAL", "Command parameter value");
  69. secsTransaction.Primary.Root.Item("L2").Item("Ln").Item("CPAL").Format = SECS_FORMAT.U2;
  70. secsTransaction.Primary.Root.Item("L2").Item("Ln").Item("CPAL").Value = cpval;
  71. }
  72. secsTransaction.ReplyExpected = true;
  73. return secsTransaction;
  74. }
  75. public static SECSTransaction BuildS1F3(int[] vids)
  76. {
  77. SECSTransaction secsTransaction = new SECSTransaction(1, 3);
  78. secsTransaction.Primary.Root.Name = "VID";
  79. for(int i=0;i<vids.Length; i++)
  80. {
  81. secsTransaction.Primary.Root.AddNew($"SVID{i}");
  82. secsTransaction.Primary.Root.Item(i).Format = SECS_FORMAT.U1;
  83. secsTransaction.Primary.Root.Item(i).Value = vids[i];
  84. }
  85. secsTransaction.ReplyExpected = true;
  86. return secsTransaction;
  87. }
  88. }
  89. }