added predefined obstacles (no need for external images)

This commit is contained in:
fros4943 2008-02-18 08:21:59 +00:00
parent 3675479274
commit f577b17ab3
2 changed files with 87 additions and 82 deletions

View file

@ -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: FormulaViewer.java,v 1.2 2007/03/23 21:13:43 fros4943 Exp $ * $Id: FormulaViewer.java,v 1.3 2008/02/18 08:21:59 fros4943 Exp $
*/ */
package se.sics.mrm; package se.sics.mrm;
@ -336,11 +336,12 @@ public class FormulaViewer extends se.sics.cooja.VisPlugin {
JCheckBox collapseCheckBox = new JCheckBox("show settings", false); JCheckBox collapseCheckBox = new JCheckBox("show settings", false);
collapseCheckBox.addActionListener(new ActionListener() { collapseCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (((JCheckBox) e.getSource()).isSelected()) if (((JCheckBox) e.getSource()).isSelected()) {
collapsableArea.setVisible(true); collapsableArea.setVisible(true);
else } else {
collapsableArea.setVisible(false); collapsableArea.setVisible(false);
} }
}
}); });
collapsableArea.putClientProperty("my_checkbox", collapseCheckBox); collapsableArea.putClientProperty("my_checkbox", collapseCheckBox);
@ -511,21 +512,21 @@ public class FormulaViewer extends se.sics.cooja.VisPlugin {
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
// Update all integers // Update all integers
for (int i=0; i < allIntegerParameters.size(); i++) { for (int i=0; i < allIntegerParameters.size(); i++) {
JFormattedTextField textField = (JFormattedTextField) allIntegerParameters.get(i); JFormattedTextField textField = allIntegerParameters.get(i);
String id = (String) textField.getClientProperty("id"); String id = (String) textField.getClientProperty("id");
textField.setValue(currentChannelModel.getParameterValue(id)); textField.setValue(currentChannelModel.getParameterValue(id));
} }
// Update all doubles // Update all doubles
for (int i=0; i < allDoubleParameters.size(); i++) { for (int i=0; i < allDoubleParameters.size(); i++) {
JFormattedTextField textField = (JFormattedTextField) allDoubleParameters.get(i); JFormattedTextField textField = allDoubleParameters.get(i);
String id = (String) textField.getClientProperty("id"); String id = (String) textField.getClientProperty("id");
textField.setValue(currentChannelModel.getParameterValue(id)); textField.setValue(currentChannelModel.getParameterValue(id));
} }
// Update all booleans // Update all booleans
for (int i=0; i < allBooleanParameters.size(); i++) { for (int i=0; i < allBooleanParameters.size(); i++) {
JCheckBox checkBox = (JCheckBox) allBooleanParameters.get(i); JCheckBox checkBox = allBooleanParameters.get(i);
String id = (String) checkBox.getClientProperty("id"); String id = (String) checkBox.getClientProperty("id");
checkBox.setSelected(currentChannelModel.getParameterBooleanValue(id)); checkBox.setSelected(currentChannelModel.getParameterBooleanValue(id));
} }

View file

@ -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: MRM.java,v 1.5 2007/03/23 21:22:37 fros4943 Exp $ * $Id: MRM.java,v 1.6 2008/02/18 08:21:59 fros4943 Exp $
*/ */
package se.sics.mrm; package se.sics.mrm;
@ -91,10 +91,12 @@ public class MRM extends AbstractRadioMedium {
// Loop through all radios // Loop through all radios
for (Radio listeningRadio: getRegisteredRadios()) { for (Radio listeningRadio: getRegisteredRadios()) {
// Ignore sending radio and radios on different channels // Ignore sending radio and radios on different channels
if (sendingRadio == listeningRadio) if (sendingRadio == listeningRadio) {
continue; continue;
if (sendingRadio.getChannel() != listeningRadio.getChannel()) }
if (sendingRadio.getChannel() != listeningRadio.getChannel()) {
continue; continue;
}
double listeningPositionX = listeningRadio.getPosition().getXCoordinate(); double listeningPositionX = listeningRadio.getPosition().getXCoordinate();
double listeningPositionY = listeningRadio.getPosition().getYCoordinate(); double listeningPositionY = listeningRadio.getPosition().getYCoordinate();
@ -188,17 +190,19 @@ public class MRM extends AbstractRadioMedium {
// ((MRMRadioConnection) conn).getSource().setCurrentSignalStrength(12345); // TODO Set signal strength on source? // ((MRMRadioConnection) conn).getSource().setCurrentSignalStrength(12345); // TODO Set signal strength on source?
for (Radio dstRadio : ((MRMRadioConnection) conn).getDestinations()) { for (Radio dstRadio : ((MRMRadioConnection) conn).getDestinations()) {
double signalStrength = ((MRMRadioConnection) conn).getDestinationSignalStrength(dstRadio); double signalStrength = ((MRMRadioConnection) conn).getDestinationSignalStrength(dstRadio);
if (signalStrength > dstRadio.getCurrentSignalStrength()) if (signalStrength > dstRadio.getCurrentSignalStrength()) {
dstRadio.setCurrentSignalStrength(signalStrength); dstRadio.setCurrentSignalStrength(signalStrength);
} }
} }
}
// Set signal strength on all interferences // Set signal strength on all interferences
for (RadioConnection conn : getActiveConnections()) { for (RadioConnection conn : getActiveConnections()) {
for (Radio interferedRadio : ((MRMRadioConnection) conn).getInterfered()) { for (Radio interferedRadio : ((MRMRadioConnection) conn).getInterfered()) {
double signalStrength = ((MRMRadioConnection) conn).getInterferenceSignalStrength(interferedRadio); double signalStrength = ((MRMRadioConnection) conn).getInterferenceSignalStrength(interferedRadio);
if (signalStrength > interferedRadio.getCurrentSignalStrength()) if (signalStrength > interferedRadio.getCurrentSignalStrength()) {
interferedRadio.setCurrentSignalStrength(signalStrength); interferedRadio.setCurrentSignalStrength(signalStrength);
}
if (!interferedRadio.isInterfered()) { if (!interferedRadio.isInterfered()) {
// Set to interfered again // Set to interfered again