Link.java 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. package de.tu_darmstadt.tk.SmartHomeNetworkSim.core;
  2. import java.util.Collection;
  3. /**
  4. * Physical Link medium for SmartDevices, which connects two or more devices and
  5. * allows communication between them
  6. *
  7. * @author Andreas T. Meyer-Berg
  8. */
  9. public interface Link {
  10. /**
  11. * @return the name
  12. */
  13. public String getName();
  14. /**
  15. * @param name
  16. * the name to set
  17. */
  18. public void setName(String name);
  19. /**
  20. * @return the devices
  21. */
  22. public Collection<SmartDevice> getDevices();
  23. /**
  24. * @param device
  25. * the devices to add
  26. */
  27. public void addDevice(SmartDevice device);
  28. /**
  29. * @param device
  30. * the devices to remove
  31. */
  32. public void removeDevice(SmartDevice device);
  33. /**
  34. * @return the connections
  35. */
  36. public Collection<Connection> getConnections();
  37. /**
  38. * @param connection
  39. * the connection to add
  40. */
  41. public void addConnection(Connection connection);
  42. /**
  43. * @param connection
  44. * the connection to remove
  45. */
  46. public void removeConnection(Connection connection);
  47. /**
  48. * Simulates an interval starting at startTime for a given duration
  49. *
  50. * @param startTime
  51. * Time the simulation interval starts in
  52. * System.currentTimeMillis() time
  53. * @param duration
  54. * Duration of the simulation interval in milliseconds
  55. */
  56. @Deprecated
  57. public void simulateTimeInterval(long startTime, long duration);
  58. /**
  59. * Initializes the simulation interval, by clearing the previously generated
  60. * packets and adds Packets of previous iterations, which are are part of this interval.
  61. * @param startTime startTime of the simulation interval
  62. * @param duration duration of the simulation interval
  63. */
  64. public void initSimulationInterval(long startTime, long duration);
  65. /**
  66. * Encapsulates the given Packets
  67. * @param packets Packets which should be encapsulated
  68. * @return Encapsulated Packets
  69. */
  70. public Collection<Packet> encapsulatePackages(Collection<Packet> packets);
  71. /**
  72. * Time at the end of an simulation interval, to remove Packets, which are not in bound, sort the array
  73. * or manipulate the packets slightly.
  74. *
  75. * @param startTime startTime of the simulation interval
  76. * @param duration duration of the interval
  77. */
  78. public void finalizeSimulationInterval(long startTime, long duration);
  79. /**
  80. * Returns all packets which where sent during the last Simulation time step
  81. *
  82. * @return packets, which were sent during the last time step
  83. */
  84. public Collection<Packet> getPackets();
  85. /**
  86. * Returns true if one or more connections have changed, and the Panel might have to be repainted
  87. * @return true if changed
  88. */
  89. public boolean getStatusChanged();
  90. /**
  91. * Returns the Transmission delay between the two given devices
  92. * @param from SmartDevice which starts transmission
  93. * @param to SmartDevices which receives transmission
  94. * @return delay of the transmission, infinite if to is unreachable or the Packets is lost.
  95. */
  96. public long getTransmissionDelayFrom(SmartDevice from, SmartDevice to);
  97. /**
  98. * Adds Packets to the internal data structure
  99. * @param packets Packets, which should be added
  100. */
  101. public void addPackets(Collection<Packet> packets);
  102. }