ProcessImage.java 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156
  1. /*
  2. * ============================================================================
  3. * GNU General Public License
  4. * ============================================================================
  5. *
  6. * Copyright (C) 2006-2011 Serotonin Software Technologies Inc. http://serotoninsoftware.com
  7. * @author Matthew Lohbihler
  8. *
  9. * This program is free software: you can redistribute it and/or modify
  10. * it under the terms of the GNU General Public License as published by
  11. * the Free Software Foundation, either version 3 of the License, or
  12. * (at your option) any later version.
  13. *
  14. * This program is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  17. * GNU General Public License for more details.
  18. * You should have received a copy of the GNU General Public License
  19. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  20. */
  21. package com.serotonin.cdc.modbus4j;
  22. import com.serotonin.cdc.modbus4j.exception.IllegalDataAddressException;
  23. /**
  24. * Used by slave implementors. Provides an interface by which slaves can easily manage data.
  25. *
  26. * @author mlohbihler
  27. */
  28. public interface ProcessImage {
  29. int getSlaveId();
  30. //
  31. // /
  32. // / Coils
  33. // /
  34. //
  35. /**
  36. * Returns the current value of the coil for the given offset.
  37. *
  38. * @param offset
  39. * @return the value of the coil
  40. */
  41. boolean getCoil(int offset) throws IllegalDataAddressException;
  42. /**
  43. * Used internally for setting the value of the coil.
  44. *
  45. * @param offset
  46. * @param value
  47. */
  48. void setCoil(int offset, boolean value);
  49. /**
  50. * Used to set the coil as a result of a write command from the master.
  51. *
  52. * @param offset
  53. * @param value
  54. */
  55. void writeCoil(int offset, boolean value) throws IllegalDataAddressException;
  56. //
  57. // /
  58. // / Inputs
  59. // /
  60. //
  61. /**
  62. * Returns the current value of the input for the given offset.
  63. *
  64. * @param offset
  65. * @return the value of the input
  66. */
  67. boolean getInput(int offset) throws IllegalDataAddressException;
  68. /**
  69. * Used internally for setting the value of the input.
  70. *
  71. * @param offset
  72. * @param value
  73. */
  74. void setInput(int offset, boolean value);
  75. //
  76. // /
  77. // / Holding registers
  78. // /
  79. //
  80. /**
  81. * Returns the current value of the holding register for the given offset.
  82. *
  83. * @param offset
  84. * @return the value of the register
  85. */
  86. short getHoldingRegister(int offset) throws IllegalDataAddressException;
  87. /**
  88. * Used internally for setting the value of the holding register.
  89. *
  90. * @param offset
  91. * @param value
  92. */
  93. void setHoldingRegister(int offset, short value);
  94. /**
  95. * Used to set the holding register as a result of a write command from the master.
  96. *
  97. * @param offset
  98. * @param value
  99. */
  100. void writeHoldingRegister(int offset, short value) throws IllegalDataAddressException;
  101. //
  102. // /
  103. // / Input registers
  104. // /
  105. //
  106. /**
  107. * Returns the current value of the input register for the given offset.
  108. *
  109. * @param offset
  110. * @return the value of the register
  111. */
  112. short getInputRegister(int offset) throws IllegalDataAddressException;
  113. /**
  114. * Used internally for setting the value of the input register.
  115. *
  116. * @param offset
  117. * @param value
  118. */
  119. void setInputRegister(int offset, short value);
  120. //
  121. // /
  122. // / Exception status
  123. // /
  124. //
  125. /**
  126. * Returns the current value of the exception status.
  127. *
  128. * @return the current value of the exception status.
  129. */
  130. byte getExceptionStatus();
  131. //
  132. // /
  133. // / Report slave id
  134. // /
  135. //
  136. /**
  137. * Returns the data for the report slave id command.
  138. *
  139. * @return the data for the report slave id command.
  140. */
  141. byte[] getReportSlaveIdData();
  142. }