MelsecElement.cs 8.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace MECF.Framework.RT.Core.IoProviders.Mitsubishis
  7. {
  8. public class MelsecElement
  9. {
  10. public static MelsecElement relaySpecial =
  11. new MelsecElement("特殊继电器", "SM", 0x91, 0x000000, 0x002047, MelsecElement.EnumType.Bit);
  12. public static MelsecElement storageSpecial =
  13. new MelsecElement("特殊寄存器", "SD", 0xA9, 0x000000, 0x002047, MelsecElement.EnumType.Word, 960);
  14. public static MelsecElement relayInput =
  15. new MelsecElement("输入继电器", "X", 0x9C, 0x000000, 0x001FFF, MelsecElement.EnumType.Bit);
  16. public static MelsecElement relayOutPut =
  17. new MelsecElement("输出继电器", "Y", 0x9D, 0x000000, 0x001FFF, MelsecElement.EnumType.Bit, 7168);
  18. public static MelsecElement relayInner =
  19. new MelsecElement("内部继电器", "M", 0x90, 0x000000, 0x008191, MelsecElement.EnumType.Bit, 7904);
  20. public static MelsecElement relayLock =
  21. new MelsecElement("锁存继电器", "L", 0x92, 0x000000, 0x008191, MelsecElement.EnumType.Bit);
  22. public static MelsecElement relayAlarm =
  23. new MelsecElement("报警继电器", "F", 0x93, 0x000000, 0x002047, MelsecElement.EnumType.Bit);
  24. public static MelsecElement relayEdge =
  25. new MelsecElement("边沿继电器", "V", 0x94, 0x000000, 0x002047, MelsecElement.EnumType.Bit);
  26. public static MelsecElement relayLink =
  27. new MelsecElement("链接继电器", "B", 0xA0, 0x000000, 0x001FFF, MelsecElement.EnumType.Bit);
  28. public static MelsecElement storageData =
  29. new MelsecElement("数据寄存器", "D", 0xA8, 0x000000, 0x012287, MelsecElement.EnumType.Word, 960);
  30. public static MelsecElement storageLink =
  31. new MelsecElement("链接寄存器", "W", 0xB4, 0x000000, 0x001FFFF, MelsecElement.EnumType.Word, 960);
  32. public static MelsecElement relayTS =
  33. new MelsecElement("定时器触点", "TS", 0xC1, 0x000000, 0x002047, MelsecElement.EnumType.Bit);
  34. public static MelsecElement relayTC =
  35. new MelsecElement("定时器线圈", "TN", 0xC0, 0x000000, 0x002047, MelsecElement.EnumType.Bit);
  36. public static MelsecElement storageTN =
  37. new MelsecElement("定时器当前值", "TC", 0xC2, 0x000000, 0x002047, MelsecElement.EnumType.Word, 960);
  38. public static MelsecElement relaySS =
  39. new MelsecElement("累计定时器触点", "SS", 0xC7, 0x000000, 0x002047, MelsecElement.EnumType.Bit);
  40. public static MelsecElement relaySC =
  41. new MelsecElement("累计定时器线圈", "SC", 0xC6, 0x000000, 0x002047, MelsecElement.EnumType.Bit);
  42. public static MelsecElement storageSN =
  43. new MelsecElement("累计定时器当前值", "SN", 0xC8, 0x000000, 0x002047, MelsecElement.EnumType.Word);
  44. public static MelsecElement relayCS =
  45. new MelsecElement("计数器触点", "CS", 0xC4, 0x000000, 0x001023, MelsecElement.EnumType.Bit);
  46. public static MelsecElement relayCC =
  47. new MelsecElement("计数器线圈", "CC", 0xC3, 0x000000, 0x001023, MelsecElement.EnumType.Bit);
  48. public static MelsecElement storageCN =
  49. new MelsecElement("计数器当前值", "CN", 0xC5, 0x000000, 0x001023, MelsecElement.EnumType.Word, 960);
  50. public static MelsecElement relaySpecialLink =
  51. new MelsecElement("链接特殊继电器", "SB", 0xA1, 0x000000, 0x0007FF, MelsecElement.EnumType.Bit);
  52. public static MelsecElement storageSpecialLink =
  53. new MelsecElement("链接特殊寄存器", "SW", 0xB5, 0x000000, 0x0007FF, MelsecElement.EnumType.Word, 960);
  54. public static MelsecElement relayStep =
  55. new MelsecElement("步进继电器", "S", 0x98, 0x000000, 0x008191, MelsecElement.EnumType.Bit);
  56. public static MelsecElement relayInputDir =
  57. new MelsecElement("直接输入继电器", "DX", 0xA2, 0x000000, 0x001FFF, MelsecElement.EnumType.Bit);
  58. public static MelsecElement relayOutPutDir =
  59. new MelsecElement("直接输出继电器", "DY", 0xA3, 0x000000, 0x001FFF, MelsecElement.EnumType.Bit);
  60. public static MelsecElement storageAddr =
  61. new MelsecElement("变址寄存器", "Z", 0xCC, 0x000000, 0x000015, MelsecElement.EnumType.Word, 960);
  62. public static MelsecElement storageFile =
  63. new MelsecElement("文件寄存器", "R", 0xAF, 0x032767, 0x000015, MelsecElement.EnumType.Word, 960);
  64. public static MelsecElement storageFileZ =
  65. new MelsecElement("文件寄存器Z", "RZ", 0xB0, 0x0FE7FF, 0x000015, MelsecElement.EnumType.Word, 960);
  66. public MelsecElement() { }
  67. public MelsecElement(string strName, string strAscCode, int nBinCode,
  68. int nStartAddr, int nEndAddr, EnumType enumType, int nLen = 3584)
  69. {
  70. m_strName = strName;
  71. m_strAscCode = strAscCode;
  72. m_nBinCode = nBinCode;
  73. m_nStartAddr = nStartAddr;
  74. m_nEndAddr = nEndAddr;
  75. m_enumType = enumType;
  76. m_nLen = nLen;
  77. }
  78. public static MelsecElement ChooseMelsecElement(string registername)
  79. {
  80. if (registername == storageFile.m_strName || registername == storageFile.m_strAscCode)
  81. return storageFile;
  82. if (registername == relayLink.m_strName || registername == relayLink.m_strAscCode)
  83. return relayLink;
  84. if (registername == relayInner.m_strName || registername == relayInner.m_strAscCode)
  85. return relayInner;
  86. if (registername == storageData.m_strName || registername == storageData.m_strAscCode)
  87. return storageData;
  88. if (registername == storageFileZ.m_strName || registername == "ZR" || registername == storageFileZ.m_strAscCode)
  89. return storageFileZ;
  90. if (registername== relaySpecial.m_strName ||registername==relaySpecial.m_strAscCode)
  91. return relaySpecial;
  92. if (registername == storageSpecial.m_strName || registername == storageSpecial.m_strAscCode)
  93. return storageSpecial;
  94. if (registername == relayInput.m_strName || registername == relayInput.m_strAscCode)
  95. return relayInput;
  96. if (registername == relayOutPut.m_strName || registername == relayOutPut.m_strAscCode)
  97. return relayOutPut;
  98. if (registername == relayLock.m_strName || registername == relayLock.m_strAscCode)
  99. return relayLock;
  100. if (registername == relayAlarm.m_strName || registername == relayAlarm.m_strAscCode)
  101. return relayAlarm;
  102. if (registername == relayEdge.m_strName || registername == relayEdge.m_strAscCode)
  103. return relayEdge;
  104. if (registername == storageLink.m_strName || registername == storageLink.m_strAscCode)
  105. return storageLink;
  106. if (registername == relayTS.m_strName || registername == relayTS.m_strAscCode)
  107. return relayTS;
  108. if (registername == relayTC.m_strName || registername == relayTC.m_strAscCode)
  109. return relayTC;
  110. if (registername == storageTN.m_strName || registername == storageTN.m_strAscCode)
  111. return storageTN;
  112. if (registername == relaySS.m_strName || registername == relaySS.m_strAscCode)
  113. return relaySS;
  114. if (registername == relaySC.m_strName || registername == relaySC.m_strAscCode)
  115. return relaySC;
  116. if (registername == storageSN.m_strName || registername == storageSN.m_strAscCode)
  117. return storageSN;
  118. if (registername == relayCS.m_strName || registername == relayCS.m_strAscCode)
  119. return relayCS;
  120. if (registername == relayCC.m_strName || registername == relayCC.m_strAscCode)
  121. return relayCC;
  122. if (registername == storageCN.m_strName || registername == storageCN.m_strAscCode)
  123. return storageCN;
  124. if (registername == relaySpecialLink.m_strName || registername == relaySpecialLink.m_strAscCode)
  125. return relaySpecialLink;
  126. if (registername == storageSpecialLink.m_strName || registername == storageSpecialLink.m_strAscCode)
  127. return storageSpecialLink;
  128. if (registername == relayStep.m_strName || registername == relayStep.m_strAscCode)
  129. return relayStep;
  130. if (registername == relayInputDir.m_strName || registername == relayInputDir.m_strAscCode)
  131. return relayInputDir;
  132. if (registername == relayOutPutDir.m_strName || registername == relayOutPutDir.m_strAscCode)
  133. return relayOutPutDir;
  134. if (registername == storageAddr.m_strName || registername == storageAddr.m_strAscCode)
  135. return storageAddr;
  136. return null;
  137. }
  138. public enum EnumType
  139. {
  140. Bit = 0,//位类型
  141. Word = 1,//字类型
  142. }
  143. public string m_strName { get; set; }
  144. public string m_strAscCode { get; set; }
  145. public int m_nBinCode { get; set; }
  146. public int m_nStartAddr { get; set; }
  147. public int m_nEndAddr { get; set; }
  148. public EnumType m_enumType { get; set; }
  149. public int m_nLen { get; set; }//最大处理长度
  150. }
  151. }