added removed()-method for mote objects

This commit is contained in:
fros4943 2010-10-12 10:58:31 +00:00
parent d470c20029
commit ece7919f49
3 changed files with 15 additions and 4 deletions

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: Mote.java,v 1.8 2010/02/03 16:05:49 fros4943 Exp $ * $Id: Mote.java,v 1.9 2010/10/12 10:58:31 fros4943 Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -144,4 +144,8 @@ public interface Mote {
public abstract boolean setConfigXML(Simulation simulation, public abstract boolean setConfigXML(Simulation simulation,
Collection<Element> configXML, boolean visAvailable); Collection<Element> configXML, boolean visAvailable);
/**
* Called when mote is removed from simulation
*/
public void removed();
} }

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: Simulation.java,v 1.66 2010/10/04 10:11:56 nifi Exp $ * $Id: Simulation.java,v 1.67 2010/10/12 10:58:31 fros4943 Exp $
*/ */
package se.sics.cooja; package se.sics.cooja;
@ -662,7 +662,11 @@ public class Simulation extends Observable implements Runnable {
/* Create mote using mote type */ /* Create mote using mote type */
Mote mote = moteType.generateMote(this); Mote mote = moteType.generateMote(this);
if (mote.setConfigXML(this, element.getChildren(), visAvailable)) { if (mote.setConfigXML(this, element.getChildren(), visAvailable)) {
addMote(mote); if (getMoteWithID(mote.getID()) != null) {
logger.warn("Ignoring duplicate mote ID: " + mote.getID());
} else {
addMote(mote);
}
} else { } else {
logger.fatal("Mote was not created: " + element.getText().trim()); logger.fatal("Mote was not created: " + element.getText().trim());
throw new Exception("All motes were not recreated"); throw new Exception("All motes were not recreated");
@ -690,6 +694,7 @@ public class Simulation extends Observable implements Runnable {
currentRadioMedium.unregisterMote(mote, Simulation.this); currentRadioMedium.unregisterMote(mote, Simulation.this);
/* Dispose mote interface resources */ /* Dispose mote interface resources */
mote.removed();
for (MoteInterface i: mote.getInterfaces().getInterfaces()) { for (MoteInterface i: mote.getInterfaces().getInterfaces()) {
i.removed(); i.removed();
} }

View file

@ -24,7 +24,7 @@
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* $Id: AbstractWakeupMote.java,v 1.2 2010/10/04 12:54:01 joxe Exp $ * $Id: AbstractWakeupMote.java,v 1.3 2010/10/12 10:58:31 fros4943 Exp $
*/ */
package se.sics.cooja.motes; package se.sics.cooja.motes;
@ -128,4 +128,6 @@ public abstract class AbstractWakeupMote implements Mote {
return true; return true;
} }
public void removed() {
}
} }