added experimental packet counters
This commit is contained in:
parent
5f1fda0406
commit
13b6fe2cd5
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: UDGMVisualizerSkin.java,v 1.2 2009/03/24 16:07:44 fros4943 Exp $
|
||||
* $Id: UDGMVisualizerSkin.java,v 1.3 2009/03/26 16:24:31 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.plugins.skins;
|
||||
|
@ -38,6 +38,8 @@ import java.awt.event.MouseEvent;
|
|||
import java.awt.event.MouseListener;
|
||||
import java.util.Observable;
|
||||
import java.util.Observer;
|
||||
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.event.ChangeEvent;
|
||||
|
@ -81,6 +83,10 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||
private UDGM radioMedium = null;
|
||||
private Observer radioMediumObserver;
|
||||
|
||||
private JLabel txCounter = null;
|
||||
private JLabel rxCounter = null;
|
||||
private JLabel interferedCounter = null;
|
||||
|
||||
private JSpinner txRangeSpinner = null;
|
||||
private JSpinner interferenceRangeSpinner = null;
|
||||
private JSpinner successRatioTxSpinner = null;
|
||||
|
@ -207,6 +213,13 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||
visualizer.registerSimulationMenuAction(SuccessRatioMenuAction.class);
|
||||
|
||||
/* Add (currently invisible) spinners */
|
||||
txCounter = new JLabel("TX: " + radioMedium.COUNTER_TX);
|
||||
rxCounter = new JLabel("RX: " + radioMedium.COUNTER_RX);
|
||||
interferedCounter = new JLabel("INT: " + + radioMedium.COUNTER_INTERFERED);
|
||||
visualizer.getCurrentCanvas().add(txCounter);
|
||||
visualizer.getCurrentCanvas().add(rxCounter);
|
||||
visualizer.getCurrentCanvas().add(interferedCounter);
|
||||
|
||||
visualizer.getCurrentCanvas().add(txRangeSpinner);
|
||||
visualizer.getCurrentCanvas().add(interferenceRangeSpinner);
|
||||
visualizer.getCurrentCanvas().add(successRatioTxSpinner);
|
||||
|
@ -215,6 +228,16 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||
/* Start observing radio medium */
|
||||
radioMedium.addRadioMediumObserver(radioMediumObserver = new Observer() {
|
||||
public void update(Observable obs, Object obj) {
|
||||
if (txCounter != null) {
|
||||
txCounter.setText("TX: " + radioMedium.COUNTER_TX);
|
||||
}
|
||||
if (rxCounter != null) {
|
||||
rxCounter.setText("RX: " + radioMedium.COUNTER_RX);
|
||||
}
|
||||
if (interferedCounter != null) {
|
||||
interferedCounter.setText("INT: " + + radioMedium.COUNTER_INTERFERED);
|
||||
}
|
||||
|
||||
visualizer.repaint();
|
||||
}
|
||||
});
|
||||
|
@ -229,6 +252,10 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||
radioMediumObserver = null;
|
||||
radioMedium = null;
|
||||
|
||||
visualizer.getCurrentCanvas().remove(txCounter);
|
||||
visualizer.getCurrentCanvas().remove(rxCounter);
|
||||
visualizer.getCurrentCanvas().remove(interferedCounter);
|
||||
|
||||
/* Remove spinners */
|
||||
visualizer.getCurrentCanvas().remove(txRangeSpinner);
|
||||
visualizer.getCurrentCanvas().remove(interferenceRangeSpinner);
|
||||
|
@ -329,7 +356,8 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||
if (conns != null) {
|
||||
g.setColor(Color.BLACK);
|
||||
for (RadioConnection conn : conns) {
|
||||
Point sourcePoint = visualizer.transformPositionToPixel(conn.getSource().getPosition());
|
||||
Radio source = conn.getSource();
|
||||
Point sourcePoint = visualizer.transformPositionToPixel(source.getPosition());
|
||||
for (Radio destRadio : conn.getDestinations()) {
|
||||
Position destPos = destRadio.getPosition();
|
||||
Point destPoint = visualizer.transformPositionToPixel(destPos);
|
||||
|
|
|
@ -26,7 +26,7 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: AbstractRadioMedium.java,v 1.7 2009/02/24 15:12:22 fros4943 Exp $
|
||||
* $Id: AbstractRadioMedium.java,v 1.8 2009/03/26 16:24:31 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.radiomediums;
|
||||
|
@ -59,6 +59,11 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
|||
|
||||
private Simulation simulation = null;
|
||||
|
||||
/* Book-keeping */
|
||||
public int COUNTER_TX = 0;
|
||||
public int COUNTER_RX = 0;
|
||||
public int COUNTER_INTERFERED = 0;
|
||||
|
||||
public class RadioMediumObservable extends Observable {
|
||||
public void setRadioMediumChanged() {
|
||||
setChanged();
|
||||
|
@ -243,7 +248,9 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
|||
} else {
|
||||
activeConnections.remove(connection);
|
||||
finishedConnections.add(connection);
|
||||
COUNTER_TX++;
|
||||
for (Radio dstRadio : connection.getDestinations()) {
|
||||
COUNTER_RX++;
|
||||
if (connection.getDestinationDelay(dstRadio) == 0) {
|
||||
dstRadio.signalReceptionEnd();
|
||||
} else {
|
||||
|
@ -262,6 +269,7 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
|||
}
|
||||
}
|
||||
for (Radio dstRadio : connection.getInterfered()) {
|
||||
COUNTER_INTERFERED++;
|
||||
dstRadio.signalReceptionEnd();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue