mirror of
https://github.com/oliverschmidt/contiki.git
synced 2024-12-23 01:29:33 +00:00
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
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.plugins.skins;
|
||||||
@ -38,6 +38,8 @@ import java.awt.event.MouseEvent;
|
|||||||
import java.awt.event.MouseListener;
|
import java.awt.event.MouseListener;
|
||||||
import java.util.Observable;
|
import java.util.Observable;
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
|
|
||||||
|
import javax.swing.JLabel;
|
||||||
import javax.swing.JSpinner;
|
import javax.swing.JSpinner;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import javax.swing.event.ChangeEvent;
|
import javax.swing.event.ChangeEvent;
|
||||||
@ -81,6 +83,10 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||||||
private UDGM radioMedium = null;
|
private UDGM radioMedium = null;
|
||||||
private Observer radioMediumObserver;
|
private Observer radioMediumObserver;
|
||||||
|
|
||||||
|
private JLabel txCounter = null;
|
||||||
|
private JLabel rxCounter = null;
|
||||||
|
private JLabel interferedCounter = null;
|
||||||
|
|
||||||
private JSpinner txRangeSpinner = null;
|
private JSpinner txRangeSpinner = null;
|
||||||
private JSpinner interferenceRangeSpinner = null;
|
private JSpinner interferenceRangeSpinner = null;
|
||||||
private JSpinner successRatioTxSpinner = null;
|
private JSpinner successRatioTxSpinner = null;
|
||||||
@ -207,6 +213,13 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||||||
visualizer.registerSimulationMenuAction(SuccessRatioMenuAction.class);
|
visualizer.registerSimulationMenuAction(SuccessRatioMenuAction.class);
|
||||||
|
|
||||||
/* Add (currently invisible) spinners */
|
/* 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(txRangeSpinner);
|
||||||
visualizer.getCurrentCanvas().add(interferenceRangeSpinner);
|
visualizer.getCurrentCanvas().add(interferenceRangeSpinner);
|
||||||
visualizer.getCurrentCanvas().add(successRatioTxSpinner);
|
visualizer.getCurrentCanvas().add(successRatioTxSpinner);
|
||||||
@ -215,6 +228,16 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||||||
/* Start observing radio medium */
|
/* Start observing radio medium */
|
||||||
radioMedium.addRadioMediumObserver(radioMediumObserver = new Observer() {
|
radioMedium.addRadioMediumObserver(radioMediumObserver = new Observer() {
|
||||||
public void update(Observable obs, Object obj) {
|
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();
|
visualizer.repaint();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -229,6 +252,10 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||||||
radioMediumObserver = null;
|
radioMediumObserver = null;
|
||||||
radioMedium = null;
|
radioMedium = null;
|
||||||
|
|
||||||
|
visualizer.getCurrentCanvas().remove(txCounter);
|
||||||
|
visualizer.getCurrentCanvas().remove(rxCounter);
|
||||||
|
visualizer.getCurrentCanvas().remove(interferedCounter);
|
||||||
|
|
||||||
/* Remove spinners */
|
/* Remove spinners */
|
||||||
visualizer.getCurrentCanvas().remove(txRangeSpinner);
|
visualizer.getCurrentCanvas().remove(txRangeSpinner);
|
||||||
visualizer.getCurrentCanvas().remove(interferenceRangeSpinner);
|
visualizer.getCurrentCanvas().remove(interferenceRangeSpinner);
|
||||||
@ -329,7 +356,8 @@ public class UDGMVisualizerSkin implements VisualizerSkin {
|
|||||||
if (conns != null) {
|
if (conns != null) {
|
||||||
g.setColor(Color.BLACK);
|
g.setColor(Color.BLACK);
|
||||||
for (RadioConnection conn : conns) {
|
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()) {
|
for (Radio destRadio : conn.getDestinations()) {
|
||||||
Position destPos = destRadio.getPosition();
|
Position destPos = destRadio.getPosition();
|
||||||
Point destPoint = visualizer.transformPositionToPixel(destPos);
|
Point destPoint = visualizer.transformPositionToPixel(destPos);
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* 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;
|
package se.sics.cooja.radiomediums;
|
||||||
@ -59,6 +59,11 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
|||||||
|
|
||||||
private Simulation simulation = null;
|
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 class RadioMediumObservable extends Observable {
|
||||||
public void setRadioMediumChanged() {
|
public void setRadioMediumChanged() {
|
||||||
setChanged();
|
setChanged();
|
||||||
@ -243,7 +248,9 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
|||||||
} else {
|
} else {
|
||||||
activeConnections.remove(connection);
|
activeConnections.remove(connection);
|
||||||
finishedConnections.add(connection);
|
finishedConnections.add(connection);
|
||||||
|
COUNTER_TX++;
|
||||||
for (Radio dstRadio : connection.getDestinations()) {
|
for (Radio dstRadio : connection.getDestinations()) {
|
||||||
|
COUNTER_RX++;
|
||||||
if (connection.getDestinationDelay(dstRadio) == 0) {
|
if (connection.getDestinationDelay(dstRadio) == 0) {
|
||||||
dstRadio.signalReceptionEnd();
|
dstRadio.signalReceptionEnd();
|
||||||
} else {
|
} else {
|
||||||
@ -262,6 +269,7 @@ public abstract class AbstractRadioMedium extends RadioMedium {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
for (Radio dstRadio : connection.getInterfered()) {
|
for (Radio dstRadio : connection.getInterfered()) {
|
||||||
|
COUNTER_INTERFERED++;
|
||||||
dstRadio.signalReceptionEnd();
|
dstRadio.signalReceptionEnd();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user