ModbusSlaveSet.java 1.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  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 java.util.Collection;
  23. import java.util.LinkedHashMap;
  24. import com.serotonin.cdc.modbus4j.exception.ModbusInitException;
  25. abstract public class ModbusSlaveSet extends Modbus {
  26. protected LinkedHashMap processImages = new LinkedHashMap();
  27. public void addProcessImage(ProcessImage processImage) {
  28. processImages.put(new Integer(processImage.getSlaveId()), processImage);
  29. }
  30. public ProcessImage getProcessImage(int slaveId) {
  31. return (ProcessImage) processImages.get(new Integer(slaveId));
  32. }
  33. public Collection getProcessImages() {
  34. return processImages.values();
  35. }
  36. /**
  37. * Starts the slave. If an exception is not thrown, this method does not return, but uses the thread to execute the
  38. * listening.
  39. *
  40. * @throws ModbusInitException
  41. */
  42. abstract public void start() throws ModbusInitException;
  43. abstract public void stop();
  44. }