mirror of
https://github.com/oliverschmidt/contiki.git
synced 2025-01-02 19:29:30 +00:00
automatically listening to newly added nodes
This commit is contained in:
parent
c3bcf8569c
commit
0e8f94ed77
@ -26,7 +26,7 @@
|
||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
* $Id: LogListener.java,v 1.6 2007/04/02 17:44:43 fros4943 Exp $
|
||||
* $Id: LogListener.java,v 1.7 2008/02/08 14:42:33 fros4943 Exp $
|
||||
*/
|
||||
|
||||
package se.sics.cooja.plugins;
|
||||
@ -78,8 +78,9 @@ public class LogListener extends VisPlugin {
|
||||
// Log observer
|
||||
logObserver = new Observer() {
|
||||
public void update(Observable obs, Object obj) {
|
||||
if (logTextArea == null)
|
||||
if (logTextArea == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
Mote mote = (Mote) obj;
|
||||
Log moteLogInterface = (Log) obs;
|
||||
@ -89,8 +90,9 @@ public class LogListener extends VisPlugin {
|
||||
}
|
||||
// Match against filter (if any)
|
||||
if (filterText != null && !filterText.equals("") &&
|
||||
!moteLogInterface.getLastLogMessages().contains(filterText))
|
||||
!moteLogInterface.getLastLogMessages().contains(filterText)) {
|
||||
return;
|
||||
}
|
||||
|
||||
outputString = outputString.concat(moteLogInterface.getLastLogMessages());
|
||||
|
||||
@ -114,6 +116,21 @@ public class LogListener extends VisPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
simulation.addObserver(new Observer() {
|
||||
public void update(Observable obs, Object obj) {
|
||||
/* Reregister as log listener */
|
||||
int nrLogs = 0;
|
||||
for (int i=0; i < simulation.getMotesCount(); i++) {
|
||||
if (simulation.getMote(i).getInterfaces().getLog() != null) {
|
||||
simulation.getMote(i).getInterfaces().getLog().deleteObserver(logObserver);
|
||||
simulation.getMote(i).getInterfaces().getLog().addObserver(logObserver);
|
||||
nrLogs++;
|
||||
}
|
||||
}
|
||||
setTitle("Log Listener - Listening on " + nrLogs + " mote logs");
|
||||
}
|
||||
});
|
||||
|
||||
// Main panel
|
||||
logTextArea = new JTextArea(8,50);
|
||||
logTextArea.setMargin(new Insets(5,5,5,5));
|
||||
@ -171,10 +188,11 @@ public class LogListener extends VisPlugin {
|
||||
return;
|
||||
}
|
||||
|
||||
} else
|
||||
} else {
|
||||
logger.fatal("No write access to file");
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
getContentPane().add(BorderLayout.CENTER, new JScrollPane(logTextArea));
|
||||
@ -194,10 +212,11 @@ public class LogListener extends VisPlugin {
|
||||
public void closePlugin() {
|
||||
// Remove log observer from all log interfaces
|
||||
for (int i=0; i < simulation.getMotesCount(); i++) {
|
||||
if (simulation.getMote(i).getInterfaces().getLog() != null)
|
||||
if (simulation.getMote(i).getInterfaces().getLog() != null) {
|
||||
simulation.getMote(i).getInterfaces().getLog().deleteObserver(logObserver);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public Collection<Element> getConfigXML() {
|
||||
Vector<Element> config = new Vector<Element>();
|
||||
|
Loading…
Reference in New Issue
Block a user