[cooja] Added @Override annotations for relevant files

This commit is contained in:
Enrico Joerns 2014-07-18 11:39:02 +02:00
parent 01bd045570
commit c6f8a2d558
7 changed files with 185 additions and 1 deletions

View file

@ -60,28 +60,34 @@ public class AvrMoteMemory implements MoteMemory, AddressMemory {
interpreter.getSimulator().insertWatch(w, address); interpreter.getSimulator().insertWatch(w, address);
} }
@Override
public void clearMemory() { public void clearMemory() {
logger.fatal("not implemented"); logger.fatal("not implemented");
} }
@Override
public byte[] getMemorySegment(int address, int size) { public byte[] getMemorySegment(int address, int size) {
logger.fatal("getMemorySegment is not implemented"); logger.fatal("getMemorySegment is not implemented");
return null; return null;
} }
@Override
public int getTotalSize() { public int getTotalSize() {
return 0; return 0;
} }
@Override
public void setMemorySegment(int address, byte[] data) { public void setMemorySegment(int address, byte[] data) {
logger.fatal("setMemorySegment is not implemented"); logger.fatal("setMemorySegment is not implemented");
} }
@Override
public byte[] getByteArray(String varName, int length) public byte[] getByteArray(String varName, int length)
throws UnknownVariableException { throws UnknownVariableException {
return null; return null;
} }
@Override
public byte getByteValueOf(String varName) throws UnknownVariableException { public byte getByteValueOf(String varName) throws UnknownVariableException {
return (byte) getValueOf(varName, 1); return (byte) getValueOf(varName, 1);
} }
@ -131,19 +137,23 @@ public class AvrMoteMemory implements MoteMemory, AddressMemory {
} }
} }
@Override
public int getIntValueOf(String varName) throws UnknownVariableException { public int getIntValueOf(String varName) throws UnknownVariableException {
return getValueOf(varName, 2); return getValueOf(varName, 2);
} }
@Override
public int getIntegerLength() { public int getIntegerLength() {
return 2; return 2;
} }
@Override
public int getVariableAddress(String varName) public int getVariableAddress(String varName)
throws UnknownVariableException { throws UnknownVariableException {
return 0; return 0;
} }
@Override
public String[] getVariableNames() { public String[] getVariableNames() {
ArrayList<String> symbols = new ArrayList<String>(); ArrayList<String> symbols = new ArrayList<String>();
for (Iterator i = memoryMap.getIterator(); i.hasNext();) { for (Iterator i = memoryMap.getIterator(); i.hasNext();) {
@ -152,32 +162,39 @@ public class AvrMoteMemory implements MoteMemory, AddressMemory {
return symbols.toArray(new String[0]); return symbols.toArray(new String[0]);
} }
@Override
public void setByteArray(String varName, byte[] data) public void setByteArray(String varName, byte[] data)
throws UnknownVariableException { throws UnknownVariableException {
} }
@Override
public void setByteValueOf(String varName, byte newVal) public void setByteValueOf(String varName, byte newVal)
throws UnknownVariableException { throws UnknownVariableException {
setValue(varName, newVal, 1); setValue(varName, newVal, 1);
} }
@Override
public void setIntValueOf(String varName, int newVal) public void setIntValueOf(String varName, int newVal)
throws UnknownVariableException { throws UnknownVariableException {
setValue(varName, newVal, 2); setValue(varName, newVal, 2);
} }
@Override
public boolean variableExists(String varName) { public boolean variableExists(String varName) {
return memoryMap.getLocation(varName) != null; return memoryMap.getLocation(varName) != null;
} }
@Override
public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) { public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) {
logger.warn("Not implemented"); logger.warn("Not implemented");
return false; return false;
} }
@Override
public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) { public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) {
} }
@Override
public int parseInt(byte[] memorySegment) { public int parseInt(byte[] memorySegment) {
logger.warn("Not implemented"); logger.warn("Not implemented");
return 0; return 0;

View file

@ -58,6 +58,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
this.cpu = cpu; this.cpu = cpu;
} }
@Override
public String[] getVariableNames() { public String[] getVariableNames() {
String[] names = new String[mapEntries.size()]; String[] names = new String[mapEntries.size()];
for (int i = 0; i < mapEntries.size(); i++) { for (int i = 0; i < mapEntries.size(); i++) {
@ -75,19 +76,23 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
throw new UnknownVariableException(varName); throw new UnknownVariableException(varName);
} }
@Override
public int getVariableAddress(String varName) throws UnknownVariableException { public int getVariableAddress(String varName) throws UnknownVariableException {
MapEntry entry = getMapEntry(varName); MapEntry entry = getMapEntry(varName);
return entry.getAddress(); return entry.getAddress();
} }
@Override
public int getIntegerLength() { public int getIntegerLength() {
return 2; return 2;
} }
@Override
public void clearMemory() { public void clearMemory() {
logger.fatal("clearMemory() not implemented"); logger.fatal("clearMemory() not implemented");
} }
@Override
public byte[] getMemorySegment(int address, int size) { public byte[] getMemorySegment(int address, int size) {
int[] memInts = new int[size]; int[] memInts = new int[size];
@ -102,6 +107,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
return memBytes; return memBytes;
} }
@Override
public void setMemorySegment(int address, byte[] data) { public void setMemorySegment(int address, byte[] data) {
/* Convert to int array */ /* Convert to int array */
int[] memInts = new int[data.length]; int[] memInts = new int[data.length];
@ -112,10 +118,12 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
System.arraycopy(memInts, 0, cpu.memory, address, data.length); System.arraycopy(memInts, 0, cpu.memory, address, data.length);
} }
@Override
public int getTotalSize() { public int getTotalSize() {
return cpu.memory.length; return cpu.memory.length;
} }
@Override
public boolean variableExists(String varName) { public boolean variableExists(String varName) {
for (MapEntry entry: mapEntries) { for (MapEntry entry: mapEntries) {
if (entry.getName().equals(varName)) { if (entry.getName().equals(varName)) {
@ -128,6 +136,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
/* TODO Check correct variable size in below methods */ /* TODO Check correct variable size in below methods */
@Override
public int getIntValueOf(String varName) throws UnknownVariableException { public int getIntValueOf(String varName) throws UnknownVariableException {
MapEntry entry = getMapEntry(varName); MapEntry entry = getMapEntry(varName);
@ -136,6 +145,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
return parseInt(varData); return parseInt(varData);
} }
@Override
public void setIntValueOf(String varName, int newVal) throws UnknownVariableException { public void setIntValueOf(String varName, int newVal) throws UnknownVariableException {
MapEntry entry = getMapEntry(varName); MapEntry entry = getMapEntry(varName);
int varAddr = entry.getAddress(); int varAddr = entry.getAddress();
@ -152,6 +162,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
setMemorySegment(varAddr, varData); setMemorySegment(varAddr, varData);
} }
@Override
public byte getByteValueOf(String varName) throws UnknownVariableException { public byte getByteValueOf(String varName) throws UnknownVariableException {
MapEntry entry = getMapEntry(varName); MapEntry entry = getMapEntry(varName);
int varAddr = entry.getAddress(); int varAddr = entry.getAddress();
@ -161,6 +172,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
return varData[0]; return varData[0];
} }
@Override
public void setByteValueOf(String varName, byte newVal) throws UnknownVariableException { public void setByteValueOf(String varName, byte newVal) throws UnknownVariableException {
MapEntry entry = getMapEntry(varName); MapEntry entry = getMapEntry(varName);
int varAddr = entry.getAddress(); int varAddr = entry.getAddress();
@ -172,6 +184,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
setMemorySegment(varAddr, varData); setMemorySegment(varAddr, varData);
} }
@Override
public byte[] getByteArray(String varName, int length) throws UnknownVariableException { public byte[] getByteArray(String varName, int length) throws UnknownVariableException {
MapEntry entry = getMapEntry(varName); MapEntry entry = getMapEntry(varName);
int varAddr = entry.getAddress(); int varAddr = entry.getAddress();
@ -179,6 +192,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
return getMemorySegment(varAddr, length); return getMemorySegment(varAddr, length);
} }
@Override
public void setByteArray(String varName, byte[] data) throws UnknownVariableException { public void setByteArray(String varName, byte[] data) throws UnknownVariableException {
MapEntry entry = getMapEntry(varName); MapEntry entry = getMapEntry(varName);
int varAddr = entry.getAddress(); int varAddr = entry.getAddress();
@ -209,6 +223,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
} }
} }
@Override
public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) { public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) {
MemoryCPUMonitor t = new MemoryCPUMonitor(mm, address, size); MemoryCPUMonitor t = new MemoryCPUMonitor(mm, address, size);
cpuMonitorArray.add(t); cpuMonitorArray.add(t);
@ -220,6 +235,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
return true; return true;
} }
@Override
public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) { public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) {
for (MemoryCPUMonitor mcm: cpuMonitorArray) { for (MemoryCPUMonitor mcm: cpuMonitorArray) {
if (mcm.mm != mm || mcm.address != address || mcm.size != size) { if (mcm.mm != mm || mcm.address != address || mcm.size != size) {
@ -233,6 +249,7 @@ public class MspMoteMemory implements MoteMemory, AddressMemory {
} }
} }
@Override
public int parseInt(byte[] memorySegment) { public int parseInt(byte[] memorySegment) {
if (memorySegment.length < 2) { if (memorySegment.length < 2) {
return -1; return -1;

View file

@ -66,10 +66,12 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
this.offset = offset; this.offset = offset;
} }
@Override
public String[] getVariableNames() { public String[] getVariableNames() {
return addresses.keySet().toArray(new String[0]); return addresses.keySet().toArray(new String[0]);
} }
@Override
public int getVariableAddress(String varName) throws UnknownVariableException { public int getVariableAddress(String varName) throws UnknownVariableException {
/* Cooja address space */ /* Cooja address space */
if (!addresses.containsKey(varName)) { if (!addresses.containsKey(varName)) {
@ -79,14 +81,17 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
return addresses.get(varName).intValue() + offset; return addresses.get(varName).intValue() + offset;
} }
@Override
public int getIntegerLength() { public int getIntegerLength() {
return 4; return 4;
} }
@Override
public void clearMemory() { public void clearMemory() {
sections.clear(); sections.clear();
} }
@Override
public byte[] getMemorySegment(int address, int size) { public byte[] getMemorySegment(int address, int size) {
/* Cooja address space */ /* Cooja address space */
address -= offset; address -= offset;
@ -113,6 +118,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
setMemorySegment(address+offset, data); setMemorySegment(address+offset, data);
} }
@Override
public void setMemorySegment(int address, byte[] data) { public void setMemorySegment(int address, byte[] data) {
/* Cooja address space */ /* Cooja address space */
address -= offset; address -= offset;
@ -193,10 +199,12 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
return sections.get(sectionNr).getData(); return sections.get(sectionNr).getData();
} }
@Override
public boolean variableExists(String varName) { public boolean variableExists(String varName) {
return addresses.containsKey(varName); return addresses.containsKey(varName);
} }
@Override
public int getIntValueOf(String varName) throws UnknownVariableException { public int getIntValueOf(String varName) throws UnknownVariableException {
int varAddr = getVariableAddress(varName); int varAddr = getVariableAddress(varName);
byte[] varData = getMemorySegment(varAddr, 4); byte[] varData = getMemorySegment(varAddr, 4);
@ -208,6 +216,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
return parseInt(varData); return parseInt(varData);
} }
@Override
public void setIntValueOf(String varName, int newVal) throws UnknownVariableException { public void setIntValueOf(String varName, int newVal) throws UnknownVariableException {
int varAddr = getVariableAddress(varName); int varAddr = getVariableAddress(varName);
@ -225,6 +234,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
setMemorySegment(varAddr, varData); setMemorySegment(varAddr, varData);
} }
@Override
public byte getByteValueOf(String varName) throws UnknownVariableException { public byte getByteValueOf(String varName) throws UnknownVariableException {
int varAddr = getVariableAddress(varName); int varAddr = getVariableAddress(varName);
byte[] varData = getMemorySegment(varAddr, 1); byte[] varData = getMemorySegment(varAddr, 1);
@ -236,6 +246,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
return varData[0]; return varData[0];
} }
@Override
public void setByteValueOf(String varName, byte newVal) throws UnknownVariableException { public void setByteValueOf(String varName, byte newVal) throws UnknownVariableException {
int varAddr = getVariableAddress(varName); int varAddr = getVariableAddress(varName);
byte[] varData = new byte[1]; byte[] varData = new byte[1];
@ -245,11 +256,13 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
setMemorySegment(varAddr, varData); setMemorySegment(varAddr, varData);
} }
@Override
public byte[] getByteArray(String varName, int length) throws UnknownVariableException { public byte[] getByteArray(String varName, int length) throws UnknownVariableException {
int varAddr = getVariableAddress(varName); int varAddr = getVariableAddress(varName);
return getMemorySegment(varAddr, length); return getMemorySegment(varAddr, length);
} }
@Override
public void setByteArray(String varName, byte[] data) throws UnknownVariableException { public void setByteArray(String varName, byte[] data) throws UnknownVariableException {
int varAddr = getVariableAddress(varName); int varAddr = getVariableAddress(varName);
setMemorySegment(varAddr, data); setMemorySegment(varAddr, data);
@ -347,6 +360,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
System.arraycopy(data, 0, this.data, addr - startAddr, data.length); System.arraycopy(data, 0, this.data, addr - startAddr, data.length);
} }
@Override
public MoteMemorySection clone() { public MoteMemorySection clone() {
byte[] dataClone = new byte[data.length]; byte[] dataClone = new byte[data.length];
System.arraycopy(data, 0, dataClone, 0, data.length); System.arraycopy(data, 0, dataClone, 0, data.length);
@ -356,6 +370,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
} }
} }
@Override
public SectionMoteMemory clone() { public SectionMoteMemory clone() {
ArrayList<MoteMemorySection> sectionsClone = new ArrayList<MoteMemorySection>(); ArrayList<MoteMemorySection> sectionsClone = new ArrayList<MoteMemorySection>();
for (MoteMemorySection section : sections) { for (MoteMemorySection section : sections) {
@ -401,12 +416,14 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
} }
} }
@Override
public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) { public boolean addMemoryMonitor(int address, int size, MemoryMonitor mm) {
PolledMemorySegments t = new PolledMemorySegments(mm, address, size); PolledMemorySegments t = new PolledMemorySegments(mm, address, size);
polledMemories.add(t); polledMemories.add(t);
return true; return true;
} }
@Override
public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) { public void removeMemoryMonitor(int address, int size, MemoryMonitor mm) {
for (PolledMemorySegments mcm: polledMemories) { for (PolledMemorySegments mcm: polledMemories) {
if (mcm.mm != mm || mcm.address != address || mcm.size != size) { if (mcm.mm != mm || mcm.address != address || mcm.size != size) {
@ -417,6 +434,7 @@ public class SectionMoteMemory implements MoteMemory, AddressMemory {
} }
} }
@Override
public int parseInt(byte[] memorySegment) { public int parseInt(byte[] memorySegment) {
int retVal = 0; int retVal = 0;
int pos = 0; int pos = 0;

View file

@ -83,10 +83,12 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
requestImmediateWakeup(); requestImmediateWakeup();
} }
@Override
public int getID() { public int getID() {
return myInterfaceHandler.getMoteID().getMoteID(); return myInterfaceHandler.getMoteID().getMoteID();
} }
@Override
public MoteInterfaceHandler getInterfaces() { public MoteInterfaceHandler getInterfaces() {
return myInterfaceHandler; return myInterfaceHandler;
} }
@ -95,6 +97,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
myInterfaceHandler = newInterfaces; myInterfaceHandler = newInterfaces;
} }
@Override
public MoteMemory getMemory() { public MoteMemory getMemory() {
return myMemory; return myMemory;
} }
@ -103,6 +106,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
myMemory = (SectionMoteMemory) memory; myMemory = (SectionMoteMemory) memory;
} }
@Override
public MoteType getType() { public MoteType getType() {
return myType; return myType;
} }
@ -121,6 +125,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
* *
* @param simTime Current simulation time * @param simTime Current simulation time
*/ */
@Override
public void execute(long simTime) { public void execute(long simTime) {
/* Poll mote interfaces */ /* Poll mote interfaces */
@ -154,6 +159,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
* *
* @return Current simulation config * @return Current simulation config
*/ */
@Override
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
ArrayList<Element> config = new ArrayList<Element>(); ArrayList<Element> config = new ArrayList<Element>();
Element element; Element element;
@ -173,6 +179,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
return config; return config;
} }
@Override
public boolean setConfigXML(Simulation simulation, Collection<Element> configXML, boolean visAvailable) { public boolean setConfigXML(Simulation simulation, Collection<Element> configXML, boolean visAvailable) {
setSimulation(simulation); setSimulation(simulation);
myMemory = myType.createInitialMemory(); myMemory = myType.createInitialMemory();
@ -212,6 +219,7 @@ public class ContikiMote extends AbstractWakeupMote implements Mote {
return true; return true;
} }
@Override
public String toString() { public String toString() {
return "Contiki " + getID(); return "Contiki " + getID();
} }

View file

@ -123,6 +123,7 @@ public class ContikiMoteType implements MoteType {
DEFAULT, MANUAL; DEFAULT, MANUAL;
public String manualHeader = "netstack-conf-example.h"; public String manualHeader = "netstack-conf-example.h";
@Override
public String toString() { public String toString() {
if (this == DEFAULT) { if (this == DEFAULT) {
return "Default (from contiki-conf.h)"; return "Default (from contiki-conf.h)";
@ -204,10 +205,12 @@ public class ContikiMoteType implements MoteType {
public ContikiMoteType() { public ContikiMoteType() {
} }
@Override
public Mote generateMote(Simulation simulation) { public Mote generateMote(Simulation simulation) {
return new ContikiMote(this, simulation); return new ContikiMote(this, simulation);
} }
@Override
public boolean configureAndInit(Container parentContainer, Simulation simulation, public boolean configureAndInit(Container parentContainer, Simulation simulation,
boolean visAvailable) throws MoteTypeCreationException { boolean visAvailable) throws MoteTypeCreationException {
myConfig = simulation.getCooja().getProjectConfig().clone(); myConfig = simulation.getCooja().getProjectConfig().clone();
@ -665,34 +668,42 @@ public class ContikiMoteType implements MoteType {
} }
} }
@Override
public String getIdentifier() { public String getIdentifier() {
return identifier; return identifier;
} }
@Override
public void setIdentifier(String identifier) { public void setIdentifier(String identifier) {
this.identifier = identifier; this.identifier = identifier;
} }
@Override
public File getContikiSourceFile() { public File getContikiSourceFile() {
return fileSource; return fileSource;
} }
@Override
public void setContikiSourceFile(File file) { public void setContikiSourceFile(File file) {
fileSource = file; fileSource = file;
} }
@Override
public File getContikiFirmwareFile() { public File getContikiFirmwareFile() {
return fileFirmware; return fileFirmware;
} }
@Override
public void setContikiFirmwareFile(File file) { public void setContikiFirmwareFile(File file) {
fileFirmware = file; fileFirmware = file;
} }
@Override
public String getCompileCommands() { public String getCompileCommands() {
return compileCommands; return compileCommands;
} }
@Override
public void setCompileCommands(String commands) { public void setCompileCommands(String commands) {
this.compileCommands = commands; this.compileCommands = commands;
} }
@ -1037,14 +1048,17 @@ public class ContikiMoteType implements MoteType {
} }
} }
@Override
public String getDescription() { public String getDescription() {
return description; return description;
} }
@Override
public void setDescription(String newDescription) { public void setDescription(String newDescription) {
description = newDescription; description = newDescription;
} }
@Override
public ProjectConfig getConfig() { public ProjectConfig getConfig() {
return myConfig; return myConfig;
} }
@ -1088,6 +1102,7 @@ public class ContikiMoteType implements MoteType {
this.coreInterfaces = coreInterfaces; this.coreInterfaces = coreInterfaces;
} }
@Override
public Class<? extends MoteInterface>[] getMoteInterfaceClasses() { public Class<? extends MoteInterface>[] getMoteInterfaceClasses() {
if (moteInterfacesClasses == null) { if (moteInterfacesClasses == null) {
return null; return null;
@ -1097,6 +1112,7 @@ public class ContikiMoteType implements MoteType {
return arr; return arr;
} }
@Override
public void setMoteInterfaceClasses(Class<? extends MoteInterface>[] moteInterfaces) { public void setMoteInterfaceClasses(Class<? extends MoteInterface>[] moteInterfaces) {
this.moteInterfacesClasses = new ArrayList<Class<? extends MoteInterface>>(); this.moteInterfacesClasses = new ArrayList<Class<? extends MoteInterface>>();
for (Class<? extends MoteInterface> intf: moteInterfaces) { for (Class<? extends MoteInterface> intf: moteInterfaces) {
@ -1192,6 +1208,7 @@ public class ContikiMoteType implements MoteType {
* *
* @return Mote type visualizer * @return Mote type visualizer
*/ */
@Override
public JComponent getTypeVisualizer() { public JComponent getTypeVisualizer() {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
// Identifier // Identifier
@ -1240,6 +1257,7 @@ public class ContikiMoteType implements MoteType {
return label; return label;
} }
@Override
public Collection<Element> getConfigXML(Simulation simulation) { public Collection<Element> getConfigXML(Simulation simulation) {
ArrayList<Element> config = new ArrayList<Element>(); ArrayList<Element> config = new ArrayList<Element>();
Element element; Element element;
@ -1280,6 +1298,7 @@ public class ContikiMoteType implements MoteType {
return config; return config;
} }
@Override
public boolean setConfigXML(Simulation simulation, public boolean setConfigXML(Simulation simulation,
Collection<Element> configXML, boolean visAvailable) Collection<Element> configXML, boolean visAvailable)
throws MoteTypeCreationException { throws MoteTypeCreationException {

View file

@ -33,7 +33,6 @@ import java.util.Collection;
import java.util.HashMap; import java.util.HashMap;
import java.util.Observable; import java.util.Observable;
import java.util.Observer; import java.util.Observer;
import java.util.Properties;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import org.jdom.Element; import org.jdom.Element;
@ -67,6 +66,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
/* Observe our own radio for incoming radio packets */ /* Observe our own radio for incoming radio packets */
private Observer radioDataObserver = new Observer() { private Observer radioDataObserver = new Observer() {
@Override
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
ApplicationRadio radio = (ApplicationRadio) obs; ApplicationRadio radio = (ApplicationRadio) obs;
if (radio.getLastEvent() == Radio.RadioEvent.RECEPTION_FINISHED) { if (radio.getLastEvent() == Radio.RadioEvent.RECEPTION_FINISHED) {
@ -99,6 +99,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
((ApplicationSerialPort)moteInterfaces.getLog()).triggerLog(msg); ((ApplicationSerialPort)moteInterfaces.getLog()).triggerLog(msg);
} }
@Override
public MoteInterfaceHandler getInterfaces() { public MoteInterfaceHandler getInterfaces() {
return moteInterfaces; return moteInterfaces;
} }
@ -107,6 +108,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
moteInterfaces = moteInterfaceHandler; moteInterfaces = moteInterfaceHandler;
} }
@Override
public MoteMemory getMemory() { public MoteMemory getMemory() {
return memory; return memory;
} }
@ -115,6 +117,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
this.memory = (SectionMoteMemory) memory; this.memory = (SectionMoteMemory) memory;
} }
@Override
public MoteType getType() { public MoteType getType() {
return moteType; return moteType;
} }
@ -123,6 +126,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
moteType = type; moteType = type;
} }
@Override
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
ArrayList<Element> config = new ArrayList<Element>(); ArrayList<Element> config = new ArrayList<Element>();
Element element; Element element;
@ -141,6 +145,7 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
return config; return config;
} }
@Override
public boolean setConfigXML(Simulation simulation, public boolean setConfigXML(Simulation simulation,
Collection<Element> configXML, boolean visAvailable) { Collection<Element> configXML, boolean visAvailable) {
setSimulation(simulation); setSimulation(simulation);
@ -176,10 +181,12 @@ public abstract class AbstractApplicationMote extends AbstractWakeupMote impleme
return true; return true;
} }
@Override
public int getID() { public int getID() {
return moteInterfaces.getMoteID().getMoteID(); return moteInterfaces.getMoteID().getMoteID();
} }
@Override
public String toString() { public String toString() {
return "AppMote " + getID(); return "AppMote " + getID();
} }

View file

@ -163,6 +163,7 @@ public class BufferListener extends VisPlugin {
private Parser parser = null; private Parser parser = null;
private Buffer buffer = null; private Buffer buffer = null;
@Override
public void startPlugin() { public void startPlugin() {
super.startPlugin(); super.startPlugin();
if (parser == null) { if (parser == null) {
@ -214,6 +215,7 @@ public class BufferListener extends VisPlugin {
private ArrayList<SegmentMemoryMonitor> memoryMonitors = new ArrayList<SegmentMemoryMonitor>(); private ArrayList<SegmentMemoryMonitor> memoryMonitors = new ArrayList<SegmentMemoryMonitor>();
private TimeEvent hourTimeEvent = new TimeEvent(0) { private TimeEvent hourTimeEvent = new TimeEvent(0) {
@Override
public void execute(long t) { public void execute(long t) {
hasHours = true; hasHours = true;
repaintTimeColumn(); repaintTimeColumn();
@ -224,11 +226,13 @@ public class BufferListener extends VisPlugin {
private static final int UPDATE_INTERVAL = 250; private static final int UPDATE_INTERVAL = 250;
private UpdateAggregator<BufferAccess> logUpdateAggregator = new UpdateAggregator<BufferAccess>(UPDATE_INTERVAL) { private UpdateAggregator<BufferAccess> logUpdateAggregator = new UpdateAggregator<BufferAccess>(UPDATE_INTERVAL) {
private Runnable scroll = new Runnable() { private Runnable scroll = new Runnable() {
@Override
public void run() { public void run() {
logTable.scrollRectToVisible( logTable.scrollRectToVisible(
new Rectangle(0, logTable.getHeight() - 2, 1, logTable.getHeight())); new Rectangle(0, logTable.getHeight() - 2, 1, logTable.getHeight()));
} }
}; };
@Override
protected void handle(List<BufferAccess> ls) { protected void handle(List<BufferAccess> ls) {
boolean isVisible = true; boolean isVisible = true;
if (logTable.getRowCount() > 0) { if (logTable.getRowCount() > 0) {
@ -276,18 +280,22 @@ public class BufferListener extends VisPlugin {
model = new AbstractTableModel() { model = new AbstractTableModel() {
private static final long serialVersionUID = 3065150390849332924L; private static final long serialVersionUID = 3065150390849332924L;
@Override
public String getColumnName(int col) { public String getColumnName(int col) {
if (col == COLUMN_TIME && formatTimeString) { if (col == COLUMN_TIME && formatTimeString) {
return "Time"; return "Time";
} }
return COLUMN_NAMES[col]; return COLUMN_NAMES[col];
} }
@Override
public int getRowCount() { public int getRowCount() {
return logs.size(); return logs.size();
} }
@Override
public int getColumnCount() { public int getColumnCount() {
return COLUMN_NAMES.length; return COLUMN_NAMES.length;
} }
@Override
public Object getValueAt(int row, int col) { public Object getValueAt(int row, int col) {
BufferAccess log = logs.get(row); BufferAccess log = logs.get(row);
if (col == COLUMN_TIME) { if (col == COLUMN_TIME) {
@ -307,6 +315,7 @@ public class BufferListener extends VisPlugin {
logTable = new JTable(model) { logTable = new JTable(model) {
private static final long serialVersionUID = -930616018336483196L; private static final long serialVersionUID = -930616018336483196L;
@Override
public String getToolTipText(MouseEvent e) { public String getToolTipText(MouseEvent e) {
java.awt.Point p = e.getPoint(); java.awt.Point p = e.getPoint();
int rowIndex = rowAtPoint(p); int rowIndex = rowAtPoint(p);
@ -356,6 +365,7 @@ public class BufferListener extends VisPlugin {
new Color(220, 255, 220), new Color(220, 255, 220),
new Color(255, 200, 255), new Color(255, 200, 255),
}; };
@Override
public Component getTableCellRendererComponent(JTable table, public Component getTableCellRendererComponent(JTable table,
Object value, boolean isSelected, boolean hasFocus, int row, Object value, boolean isSelected, boolean hasFocus, int row,
int column) { int column) {
@ -405,6 +415,7 @@ public class BufferListener extends VisPlugin {
logTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN); logTable.setAutoResizeMode(JTable.AUTO_RESIZE_LAST_COLUMN);
logTable.setFont(new Font("Monospaced", Font.PLAIN, 12)); logTable.setFont(new Font("Monospaced", Font.PLAIN, 12));
logTable.addKeyListener(new KeyAdapter() { logTable.addKeyListener(new KeyAdapter() {
@Override
public void keyPressed(KeyEvent e) { public void keyPressed(KeyEvent e) {
if (e.getKeyCode() == KeyEvent.VK_SPACE) { if (e.getKeyCode() == KeyEvent.VK_SPACE) {
showInAllAction.actionPerformed(null); showInAllAction.actionPerformed(null);
@ -419,6 +430,7 @@ public class BufferListener extends VisPlugin {
/* Toggle time format */ /* Toggle time format */
logTable.getTableHeader().addMouseListener(new MouseAdapter() { logTable.getTableHeader().addMouseListener(new MouseAdapter() {
@Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int colIndex = logTable.columnAtPoint(e.getPoint()); int colIndex = logTable.columnAtPoint(e.getPoint());
int columnIndex = logTable.convertColumnIndexToModel(colIndex); int columnIndex = logTable.convertColumnIndexToModel(colIndex);
@ -432,6 +444,7 @@ public class BufferListener extends VisPlugin {
}); });
logTable.addMouseListener(new MouseAdapter() { logTable.addMouseListener(new MouseAdapter() {
private Parser lastParser = null; private Parser lastParser = null;
@Override
public void mousePressed(MouseEvent e) { public void mousePressed(MouseEvent e) {
if (e.getButton() != MouseEvent.BUTTON2) { if (e.getButton() != MouseEvent.BUTTON2) {
return; return;
@ -444,6 +457,7 @@ public class BufferListener extends VisPlugin {
setParser(ByteArrayParser.class); setParser(ByteArrayParser.class);
} }
} }
@Override
public void mouseExited(MouseEvent e) { public void mouseExited(MouseEvent e) {
if (lastParser != null) { if (lastParser != null) {
/* Switch back to previous parser */ /* Switch back to previous parser */
@ -451,6 +465,7 @@ public class BufferListener extends VisPlugin {
lastParser = null; lastParser = null;
} }
} }
@Override
public void mouseReleased(MouseEvent e) { public void mouseReleased(MouseEvent e) {
if (lastParser != null) { if (lastParser != null) {
/* Switch back to previous parser */ /* Switch back to previous parser */
@ -458,6 +473,7 @@ public class BufferListener extends VisPlugin {
lastParser = null; lastParser = null;
} }
} }
@Override
public void mouseClicked(MouseEvent e) { public void mouseClicked(MouseEvent e) {
int colIndex = logTable.columnAtPoint(e.getPoint()); int colIndex = logTable.columnAtPoint(e.getPoint());
int columnIndex = logTable.convertColumnIndexToModel(colIndex); int columnIndex = logTable.convertColumnIndexToModel(colIndex);
@ -482,21 +498,27 @@ public class BufferListener extends VisPlugin {
/* Popup menu */ /* Popup menu */
JPopupMenu popupMenu = new JPopupMenu(); JPopupMenu popupMenu = new JPopupMenu();
bufferMenu.addMenuListener(new MenuListener() { bufferMenu.addMenuListener(new MenuListener() {
@Override
public void menuSelected(MenuEvent e) { public void menuSelected(MenuEvent e) {
updateBufferMenu(); updateBufferMenu();
} }
@Override
public void menuDeselected(MenuEvent e) { public void menuDeselected(MenuEvent e) {
} }
@Override
public void menuCanceled(MenuEvent e) { public void menuCanceled(MenuEvent e) {
} }
}); });
popupMenu.add(bufferMenu); popupMenu.add(bufferMenu);
parserMenu.addMenuListener(new MenuListener() { parserMenu.addMenuListener(new MenuListener() {
@Override
public void menuSelected(MenuEvent e) { public void menuSelected(MenuEvent e) {
updateParserMenu(); updateParserMenu();
} }
@Override
public void menuDeselected(MenuEvent e) { public void menuDeselected(MenuEvent e) {
} }
@Override
public void menuCanceled(MenuEvent e) { public void menuCanceled(MenuEvent e) {
} }
}); });
@ -521,6 +543,7 @@ public class BufferListener extends VisPlugin {
colorCheckbox = new JCheckBoxMenuItem("Mote-specific coloring"); colorCheckbox = new JCheckBoxMenuItem("Mote-specific coloring");
popupMenu.add(colorCheckbox); popupMenu.add(colorCheckbox);
colorCheckbox.addActionListener(new ActionListener() { colorCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
backgroundColors = colorCheckbox.isSelected(); backgroundColors = colorCheckbox.isSelected();
repaint(); repaint();
@ -529,6 +552,7 @@ public class BufferListener extends VisPlugin {
inverseFilterCheckbox = new JCheckBoxMenuItem("Inverse filter"); inverseFilterCheckbox = new JCheckBoxMenuItem("Inverse filter");
popupMenu.add(inverseFilterCheckbox); popupMenu.add(inverseFilterCheckbox);
inverseFilterCheckbox.addActionListener(new ActionListener() { inverseFilterCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
inverseFilter = inverseFilterCheckbox.isSelected(); inverseFilter = inverseFilterCheckbox.isSelected();
if (inverseFilter) { if (inverseFilter) {
@ -543,6 +567,7 @@ public class BufferListener extends VisPlugin {
hideReadsCheckbox = new JCheckBoxMenuItem("Hide READs", hideReads); hideReadsCheckbox = new JCheckBoxMenuItem("Hide READs", hideReads);
popupMenu.add(hideReadsCheckbox); popupMenu.add(hideReadsCheckbox);
hideReadsCheckbox.addActionListener(new ActionListener() { hideReadsCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
hideReads = hideReadsCheckbox.isSelected(); hideReads = hideReadsCheckbox.isSelected();
setFilter(getFilter()); setFilter(getFilter());
@ -553,6 +578,7 @@ public class BufferListener extends VisPlugin {
withStackTraceCheckbox = new JCheckBoxMenuItem("Capture stack traces", withStackTrace); withStackTraceCheckbox = new JCheckBoxMenuItem("Capture stack traces", withStackTrace);
popupMenu.add(withStackTraceCheckbox); popupMenu.add(withStackTraceCheckbox);
withStackTraceCheckbox.addActionListener(new ActionListener() { withStackTraceCheckbox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
withStackTrace = withStackTraceCheckbox.isSelected(); withStackTrace = withStackTraceCheckbox.isSelected();
setFilter(getFilter()); setFilter(getFilter());
@ -564,6 +590,7 @@ public class BufferListener extends VisPlugin {
/* Column width adjustment */ /* Column width adjustment */
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
/* Make sure this happens *after* adding history */ /* Make sure this happens *after* adding history */
adjuster.setDynamicAdjustment(true); adjuster.setDynamicAdjustment(true);
@ -573,6 +600,7 @@ public class BufferListener extends VisPlugin {
logUpdateAggregator.start(); logUpdateAggregator.start();
simulation.getEventCentral().addMoteCountListener(logOutputListener = new MoteCountListener() { simulation.getEventCentral().addMoteCountListener(logOutputListener = new MoteCountListener() {
@Override
public void moteWasAdded(Mote mote) { public void moteWasAdded(Mote mote) {
/* Update title */ /* Update title */
try { try {
@ -581,6 +609,7 @@ public class BufferListener extends VisPlugin {
logger.warn("Could not monitor buffer on: " + mote, e); logger.warn("Could not monitor buffer on: " + mote, e);
} }
} }
@Override
public void moteWasRemoved(Mote mote) { public void moteWasRemoved(Mote mote) {
/* Update title */ /* Update title */
stopObserving(mote); stopObserving(mote);
@ -596,12 +625,14 @@ public class BufferListener extends VisPlugin {
filterPanel.add(filterLabel); filterPanel.add(filterLabel);
filterPanel.add(filterTextField); filterPanel.add(filterTextField);
filterTextField.addActionListener(new ActionListener() { filterTextField.addActionListener(new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
String str = filterTextField.getText(); String str = filterTextField.getText();
setFilter(str); setFilter(str);
/* Autoscroll */ /* Autoscroll */
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
int s = logTable.getSelectedRow(); int s = logTable.getSelectedRow();
if (s < 0) { if (s < 0) {
@ -673,6 +704,7 @@ public class BufferListener extends VisPlugin {
lastSegmentAddress = segmentAddress; lastSegmentAddress = segmentAddress;
} }
@Override
final public void memoryChanged(MoteMemory memory, final public void memoryChanged(MoteMemory memory,
org.contikios.cooja.MoteMemory.MemoryEventType type, int address) { org.contikios.cooja.MoteMemory.MemoryEventType type, int address) {
if (type == MemoryEventType.READ) { if (type == MemoryEventType.READ) {
@ -694,10 +726,12 @@ public class BufferListener extends VisPlugin {
} }
} }
@Override
public MemoryMonitorType getType() { public MemoryMonitorType getType() {
return MemoryMonitorType.POINTER; return MemoryMonitorType.POINTER;
} }
@Override
public void dispose() { public void dispose() {
super.dispose(); super.dispose();
segmentMonitor.dispose(); segmentMonitor.dispose();
@ -746,6 +780,7 @@ public class BufferListener extends VisPlugin {
} }
} }
@Override
public void memoryChanged(MoteMemory memory, MemoryEventType type, int address) { public void memoryChanged(MoteMemory memory, MemoryEventType type, int address) {
byte[] newData = getAddress()==0?null:mote.getMemory().getMemorySegment(getAddress(), getSize()); byte[] newData = getAddress()==0?null:mote.getMemory().getMemorySegment(getAddress(), getSize());
addBufferAccess(bl, mote, oldData, newData, type, this.address); addBufferAccess(bl, mote, oldData, newData, type, this.address);
@ -793,6 +828,7 @@ public class BufferListener extends VisPlugin {
} }
} }
@Override
public void closePlugin() { public void closePlugin() {
if (hourTimeEvent != null) hourTimeEvent.remove(); if (hourTimeEvent != null) hourTimeEvent.remove();
@ -805,6 +841,7 @@ public class BufferListener extends VisPlugin {
} }
} }
@Override
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
ArrayList<Element> config = new ArrayList<Element>(); ArrayList<Element> config = new ArrayList<Element>();
Element element; Element element;
@ -845,12 +882,14 @@ public class BufferListener extends VisPlugin {
return config; return config;
} }
@Override
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) { public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
for (Element element : configXML) { for (Element element : configXML) {
String name = element.getName(); String name = element.getName();
if ("filter".equals(name)) { if ("filter".equals(name)) {
final String str = element.getText(); final String str = element.getText();
EventQueue.invokeLater(new Runnable() { EventQueue.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
setFilter(str); setFilter(str);
} }
@ -914,6 +953,7 @@ public class BufferListener extends VisPlugin {
regexp = null; regexp = null;
} }
RowFilter<Object, Object> wrapped = new RowFilter<Object, Object>() { RowFilter<Object, Object> wrapped = new RowFilter<Object, Object>() {
@Override
public boolean include(RowFilter.Entry<? extends Object, ? extends Object> entry) { public boolean include(RowFilter.Entry<? extends Object, ? extends Object> entry) {
if (hideReads) { if (hideReads) {
int row = (Integer) entry.getIdentifier(); int row = (Integer) entry.getIdentifier();
@ -945,6 +985,7 @@ public class BufferListener extends VisPlugin {
public void trySelectTime(final long time) { public void trySelectTime(final long time) {
java.awt.EventQueue.invokeLater(new Runnable() { java.awt.EventQueue.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
for (int i=0; i < logs.size(); i++) { for (int i=0; i < logs.size(); i++) {
if (logs.get(i).time < time) { if (logs.get(i).time < time) {
@ -1054,6 +1095,7 @@ public class BufferListener extends VisPlugin {
private Action saveAction = new AbstractAction("Save to file") { private Action saveAction = new AbstractAction("Save to file") {
private static final long serialVersionUID = -4140706275748686944L; private static final long serialVersionUID = -4140706275748686944L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
JFileChooser fc = new JFileChooser(); JFileChooser fc = new JFileChooser();
File suggest = new File(Cooja.getExternalToolsSetting("BUFFER_LISTENER_SAVEFILE", "BufferAccessLogger.txt")); File suggest = new File(Cooja.getExternalToolsSetting("BUFFER_LISTENER_SAVEFILE", "BufferAccessLogger.txt"));
@ -1116,6 +1158,7 @@ public class BufferListener extends VisPlugin {
private Action bufferListenerAction = new AbstractAction("in Buffer Listener") { private Action bufferListenerAction = new AbstractAction("in Buffer Listener") {
private static final long serialVersionUID = -6358463434933029699L; private static final long serialVersionUID = -6358463434933029699L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int view = logTable.getSelectedRow(); int view = logTable.getSelectedRow();
if (view < 0) { if (view < 0) {
@ -1139,6 +1182,7 @@ public class BufferListener extends VisPlugin {
private Action timeLineAction = new AbstractAction("in Timeline") { private Action timeLineAction = new AbstractAction("in Timeline") {
private static final long serialVersionUID = -6358463434933029699L; private static final long serialVersionUID = -6358463434933029699L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int view = logTable.getSelectedRow(); int view = logTable.getSelectedRow();
if (view < 0) { if (view < 0) {
@ -1162,6 +1206,7 @@ public class BufferListener extends VisPlugin {
private Action radioLoggerAction = new AbstractAction("in Radio Logger") { private Action radioLoggerAction = new AbstractAction("in Radio Logger") {
private static final long serialVersionUID = -3041714249257346688L; private static final long serialVersionUID = -3041714249257346688L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int view = logTable.getSelectedRow(); int view = logTable.getSelectedRow();
if (view < 0) { if (view < 0) {
@ -1189,6 +1234,7 @@ public class BufferListener extends VisPlugin {
putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true)); putValue(ACCELERATOR_KEY, KeyStroke.getKeyStroke(KeyEvent.VK_SPACE, 0, true));
} }
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
timeLineAction.actionPerformed(null); timeLineAction.actionPerformed(null);
radioLoggerAction.actionPerformed(null); radioLoggerAction.actionPerformed(null);
@ -1197,6 +1243,7 @@ public class BufferListener extends VisPlugin {
private Action clearAction = new AbstractAction("Clear") { private Action clearAction = new AbstractAction("Clear") {
private static final long serialVersionUID = -2115620313183440224L; private static final long serialVersionUID = -2115620313183440224L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
int size = logs.size(); int size = logs.size();
if (size > 0) { if (size > 0) {
@ -1208,6 +1255,7 @@ public class BufferListener extends VisPlugin {
private Action copyAction = new AbstractAction("Selected") { private Action copyAction = new AbstractAction("Selected") {
private static final long serialVersionUID = -8433490108577001803L; private static final long serialVersionUID = -8433490108577001803L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@ -1240,6 +1288,7 @@ public class BufferListener extends VisPlugin {
private Action copyAllAction = new AbstractAction("All") { private Action copyAllAction = new AbstractAction("All") {
private static final long serialVersionUID = -5038884975254178373L; private static final long serialVersionUID = -5038884975254178373L;
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard(); Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
@ -1269,6 +1318,7 @@ public class BufferListener extends VisPlugin {
private final ActionListener parserSelectedListener = new ActionListener() { private final ActionListener parserSelectedListener = new ActionListener() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Class<? extends Parser> bpClass = Class<? extends Parser> bpClass =
(Class<? extends Parser>) (Class<? extends Parser>)
@ -1289,6 +1339,7 @@ public class BufferListener extends VisPlugin {
private final ActionListener bufferSelectedListener = new ActionListener() { private final ActionListener bufferSelectedListener = new ActionListener() {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
Class<? extends Buffer> btClass = Class<? extends Buffer> btClass =
(Class<? extends Buffer>) (Class<? extends Buffer>)
@ -1421,6 +1472,7 @@ public class BufferListener extends VisPlugin {
} }
public static abstract class GraphicalParser implements Parser { public static abstract class GraphicalParser implements Parser {
BufferAccess ba = null; BufferAccess ba = null;
@Override
public Object parse(BufferAccess ba) { public Object parse(BufferAccess ba) {
this.ba = ba; this.ba = ba;
return ba; return ba;
@ -1430,6 +1482,7 @@ public class BufferListener extends VisPlugin {
} }
public static abstract class StringParser implements Parser { public static abstract class StringParser implements Parser {
@Override
public Object parse(BufferAccess ba) { public Object parse(BufferAccess ba) {
return parseString(ba); return parseString(ba);
} }
@ -1459,13 +1512,17 @@ public class BufferListener extends VisPlugin {
public void writeConfig(Element element); public void writeConfig(Element element);
} }
public static abstract class AbstractBuffer implements Buffer { public static abstract class AbstractBuffer implements Buffer {
@Override
public String getStatusString() { public String getStatusString() {
return null; return null;
} }
@Override
public void writeConfig(Element element) { public void writeConfig(Element element) {
} }
@Override
public void applyConfig(Element element) { public void applyConfig(Element element) {
} }
@Override
public boolean configure(BufferListener bl) { public boolean configure(BufferListener bl) {
return true; return true;
} }
@ -1474,6 +1531,7 @@ public class BufferListener extends VisPlugin {
public static abstract class PointerBuffer extends AbstractBuffer { public static abstract class PointerBuffer extends AbstractBuffer {
public abstract int getPointerAddress(Mote mote); public abstract int getPointerAddress(Mote mote);
@Override
public SegmentMemoryMonitor createMemoryMonitor(BufferListener bl, Mote mote) public SegmentMemoryMonitor createMemoryMonitor(BufferListener bl, Mote mote)
throws Exception { throws Exception {
return new PointerMemoryMonitor( return new PointerMemoryMonitor(
@ -1486,6 +1544,7 @@ public class BufferListener extends VisPlugin {
} }
} }
public static abstract class SegmentBuffer extends AbstractBuffer { public static abstract class SegmentBuffer extends AbstractBuffer {
@Override
public SegmentMemoryMonitor createMemoryMonitor(BufferListener bl, Mote mote) public SegmentMemoryMonitor createMemoryMonitor(BufferListener bl, Mote mote)
throws Exception { throws Exception {
return new SegmentMemoryMonitor( return new SegmentMemoryMonitor(
@ -1521,6 +1580,7 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Byte array") @ClassDescription("Byte array")
public static class ByteArrayParser extends StringParser { public static class ByteArrayParser extends StringParser {
@Override
public String parseString(BufferAccess ba) { public String parseString(BufferAccess ba) {
boolean[] diff = ba.getAccessedBitpattern(); boolean[] diff = ba.getAccessedBitpattern();
if (diff == null) { if (diff == null) {
@ -1562,6 +1622,7 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Integer array") @ClassDescription("Integer array")
public static class IntegerParser extends StringParser { public static class IntegerParser extends StringParser {
@Override
public String parseString(BufferAccess ba) { public String parseString(BufferAccess ba) {
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
@ -1592,6 +1653,7 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Terminated string") @ClassDescription("Terminated string")
public static class TerminatedStringParser extends StringParser { public static class TerminatedStringParser extends StringParser {
@Override
public String parseString(BufferAccess ba) { public String parseString(BufferAccess ba) {
/* TODO Diff? */ /* TODO Diff? */
int i; int i;
@ -1608,6 +1670,7 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Printable characters") @ClassDescription("Printable characters")
public static class PrintableCharactersParser extends StringParser { public static class PrintableCharactersParser extends StringParser {
@Override
public String parseString(BufferAccess ba) { public String parseString(BufferAccess ba) {
/* TODO Diff? */ /* TODO Diff? */
return new String(ba.mem).replaceAll("[^\\p{Print}]", ""); return new String(ba.mem).replaceAll("[^\\p{Print}]", "");
@ -1616,6 +1679,7 @@ public class BufferListener extends VisPlugin {
@ClassDescription("IPv6 address") @ClassDescription("IPv6 address")
public static class IPv6AddressParser extends StringParser { public static class IPv6AddressParser extends StringParser {
@Override
public String parseString(BufferAccess ba) { public String parseString(BufferAccess ba) {
/* TODO Diff? */ /* TODO Diff? */
if (ba.mem.length < 16) { if (ba.mem.length < 16) {
@ -1634,6 +1698,7 @@ public class BufferListener extends VisPlugin {
@ClassDescription("IPv4 address") @ClassDescription("IPv4 address")
public static class IPv4AddressParser extends StringParser { public static class IPv4AddressParser extends StringParser {
@Override
public String parseString(BufferAccess ba) { public String parseString(BufferAccess ba) {
/* TODO Diff? */ /* TODO Diff? */
if (ba.mem.length < 4) { if (ba.mem.length < 4) {
@ -1664,6 +1729,7 @@ public class BufferListener extends VisPlugin {
parser.ba = ba; parser.ba = ba;
setPreferredSize(new Dimension(parser.getUnscaledWidth() + 2*XOFFSET, HEIGHT)); setPreferredSize(new Dimension(parser.getUnscaledWidth() + 2*XOFFSET, HEIGHT));
} }
@Override
public void paintComponent(Graphics g) { public void paintComponent(Graphics g) {
super.paintComponent(g); super.paintComponent(g);
g.translate(XOFFSET, 0); g.translate(XOFFSET, 0);
@ -1681,9 +1747,11 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Graphical: Height") @ClassDescription("Graphical: Height")
public static class GraphicalHeight4BitsParser extends GraphicalParser { public static class GraphicalHeight4BitsParser extends GraphicalParser {
@Override
public int getUnscaledWidth() { public int getUnscaledWidth() {
return ba.mem.length*2; return ba.mem.length*2;
} }
@Override
public void paintComponent(Graphics g, JComponent c) { public void paintComponent(Graphics g, JComponent c) {
g.setColor(Color.GRAY); g.setColor(Color.GRAY);
boolean[] diff = ba.getAccessedBitpattern(); boolean[] diff = ba.getAccessedBitpattern();
@ -1707,9 +1775,11 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Graphical: Grayscale") @ClassDescription("Graphical: Grayscale")
public static class GraphicalGrayscale4BitsParser extends GraphicalParser { public static class GraphicalGrayscale4BitsParser extends GraphicalParser {
@Override
public int getUnscaledWidth() { public int getUnscaledWidth() {
return ba.mem.length*2; return ba.mem.length*2;
} }
@Override
public void paintComponent(Graphics g, JComponent c) { public void paintComponent(Graphics g, JComponent c) {
boolean[] diff = ba.getAccessedBitpattern(); boolean[] diff = ba.getAccessedBitpattern();
for (int x=0; x < ba.mem.length; x++) { for (int x=0; x < ba.mem.length; x++) {
@ -1730,12 +1800,14 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Variable: node_id") @ClassDescription("Variable: node_id")
public static class NodeIDBuffer extends SegmentBuffer { public static class NodeIDBuffer extends SegmentBuffer {
@Override
public int getAddress(Mote mote) { public int getAddress(Mote mote) {
if (!mote.getMemory().variableExists("node_id")) { if (!mote.getMemory().variableExists("node_id")) {
return -1; return -1;
} }
return mote.getMemory().getVariableAddress("node_id"); return mote.getMemory().getVariableAddress("node_id");
} }
@Override
public int getSize(Mote mote) { public int getSize(Mote mote) {
return mote.getMemory().getIntegerLength(); return mote.getMemory().getIntegerLength();
} }
@ -1744,6 +1816,7 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Queuebuf 0 RAM") @ClassDescription("Queuebuf 0 RAM")
public static class Queuebuf0Buffer extends SegmentBuffer { public static class Queuebuf0Buffer extends SegmentBuffer {
@Override
public int getAddress(Mote mote) { public int getAddress(Mote mote) {
if (!mote.getMemory().variableExists("buframmem")) { if (!mote.getMemory().variableExists("buframmem")) {
return -1; return -1;
@ -1751,6 +1824,7 @@ public class BufferListener extends VisPlugin {
int offset = 0; int offset = 0;
return mote.getMemory().getVariableAddress("buframmem") + offset; return mote.getMemory().getVariableAddress("buframmem") + offset;
} }
@Override
public int getSize(Mote mote) { public int getSize(Mote mote) {
return 128; return 128;
} }
@ -1758,12 +1832,14 @@ public class BufferListener extends VisPlugin {
@ClassDescription("packetbuf_aligned") @ClassDescription("packetbuf_aligned")
public static class PacketbufBuffer extends SegmentBuffer { public static class PacketbufBuffer extends SegmentBuffer {
@Override
public int getAddress(Mote mote) { public int getAddress(Mote mote) {
if (!mote.getMemory().variableExists("packetbuf_aligned")) { if (!mote.getMemory().variableExists("packetbuf_aligned")) {
return -1; return -1;
} }
return mote.getMemory().getVariableAddress("packetbuf_aligned"); return mote.getMemory().getVariableAddress("packetbuf_aligned");
} }
@Override
public int getSize(Mote mote) { public int getSize(Mote mote) {
return 128; return 128;
} }
@ -1771,18 +1847,21 @@ public class BufferListener extends VisPlugin {
@ClassDescription("*packetbufptr") @ClassDescription("*packetbufptr")
public static class PacketbufPointerBuffer extends PointerBuffer { public static class PacketbufPointerBuffer extends PointerBuffer {
@Override
public int getPointerAddress(Mote mote) { public int getPointerAddress(Mote mote) {
if (!mote.getMemory().variableExists("packetbufptr")) { if (!mote.getMemory().variableExists("packetbufptr")) {
return -1; return -1;
} }
return mote.getMemory().getVariableAddress("packetbufptr"); return mote.getMemory().getVariableAddress("packetbufptr");
} }
@Override
public int getAddress(Mote mote) { public int getAddress(Mote mote) {
if (!mote.getMemory().variableExists("packetbufptr")) { if (!mote.getMemory().variableExists("packetbufptr")) {
return -1; return -1;
} }
return mote.getMemory().getIntValueOf("packetbufptr"); return mote.getMemory().getIntValueOf("packetbufptr");
} }
@Override
public int getSize(Mote mote) { public int getSize(Mote mote) {
return 128; return 128;
} }
@ -1793,18 +1872,21 @@ public class BufferListener extends VisPlugin {
public String variable; public String variable;
public int size; public int size;
public int offset; public int offset;
@Override
public int getPointerAddress(Mote mote) { public int getPointerAddress(Mote mote) {
if (!mote.getMemory().variableExists(variable)) { if (!mote.getMemory().variableExists(variable)) {
return -1; return -1;
} }
return mote.getMemory().getVariableAddress(variable); return mote.getMemory().getVariableAddress(variable);
} }
@Override
public int getAddress(Mote mote) { public int getAddress(Mote mote) {
if (!mote.getMemory().variableExists(variable)) { if (!mote.getMemory().variableExists(variable)) {
return -1; return -1;
} }
return mote.getMemory().getIntValueOf(variable)+offset; return mote.getMemory().getIntValueOf(variable)+offset;
} }
@Override
public int getSize(Mote mote) { public int getSize(Mote mote) {
if (!mote.getMemory().variableExists(variable)) { if (!mote.getMemory().variableExists(variable)) {
return -1; return -1;
@ -1812,6 +1894,7 @@ public class BufferListener extends VisPlugin {
return size; return size;
} }
@Override
public String getStatusString() { public String getStatusString() {
if (offset > 0) { if (offset > 0) {
return "Pointer *" + variable + "[" + offset + "] (" + size + ")"; return "Pointer *" + variable + "[" + offset + "] (" + size + ")";
@ -1820,16 +1903,19 @@ public class BufferListener extends VisPlugin {
} }
} }
@Override
public void writeConfig(Element element) { public void writeConfig(Element element) {
element.setAttribute("variable", variable); element.setAttribute("variable", variable);
element.setAttribute("size", "" + size); element.setAttribute("size", "" + size);
element.setAttribute("offset", "" + offset); element.setAttribute("offset", "" + offset);
} }
@Override
public void applyConfig(Element element) { public void applyConfig(Element element) {
variable = element.getAttributeValue("variable"); variable = element.getAttributeValue("variable");
size = Integer.parseInt(element.getAttributeValue("size")); size = Integer.parseInt(element.getAttributeValue("size"));
offset = Integer.parseInt(element.getAttributeValue("offset")); offset = Integer.parseInt(element.getAttributeValue("offset"));
} }
@Override
public boolean configure(BufferListener bl) { public boolean configure(BufferListener bl) {
String suggestName = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARNAME", "node_id"); String suggestName = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARNAME", "node_id");
String suggestSize = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARSIZE", "2"); String suggestSize = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARSIZE", "2");
@ -1880,12 +1966,14 @@ public class BufferListener extends VisPlugin {
public String variable; public String variable;
public int size; public int size;
public int offset; public int offset;
@Override
public int getAddress(Mote mote) { public int getAddress(Mote mote) {
if (!mote.getMemory().variableExists(variable)) { if (!mote.getMemory().variableExists(variable)) {
return -1; return -1;
} }
return mote.getMemory().getVariableAddress(variable)+offset; return mote.getMemory().getVariableAddress(variable)+offset;
} }
@Override
public int getSize(Mote mote) { public int getSize(Mote mote) {
if (!mote.getMemory().variableExists(variable)) { if (!mote.getMemory().variableExists(variable)) {
return -1; return -1;
@ -1893,6 +1981,7 @@ public class BufferListener extends VisPlugin {
return size; return size;
} }
@Override
public String getStatusString() { public String getStatusString() {
if (offset > 0) { if (offset > 0) {
return "Symbol &" + variable + "[" + offset + "] (" + size + ")"; return "Symbol &" + variable + "[" + offset + "] (" + size + ")";
@ -1901,16 +1990,19 @@ public class BufferListener extends VisPlugin {
} }
} }
@Override
public void writeConfig(Element element) { public void writeConfig(Element element) {
element.setAttribute("variable", variable); element.setAttribute("variable", variable);
element.setAttribute("size", "" + size); element.setAttribute("size", "" + size);
element.setAttribute("offset", "" + offset); element.setAttribute("offset", "" + offset);
} }
@Override
public void applyConfig(Element element) { public void applyConfig(Element element) {
variable = element.getAttributeValue("variable"); variable = element.getAttributeValue("variable");
size = Integer.parseInt(element.getAttributeValue("size")); size = Integer.parseInt(element.getAttributeValue("size"));
offset = Integer.parseInt(element.getAttributeValue("offset")); offset = Integer.parseInt(element.getAttributeValue("offset"));
} }
@Override
public boolean configure(BufferListener bl) { public boolean configure(BufferListener bl) {
String suggestName = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARNAME", "node_id"); String suggestName = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARNAME", "node_id");
String suggestSize = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARSIZE", "2"); String suggestSize = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARSIZE", "2");
@ -1958,26 +2050,32 @@ public class BufferListener extends VisPlugin {
@ClassDescription("Integer...") @ClassDescription("Integer...")
public static class CustomIntegerBuffer extends SegmentBuffer { public static class CustomIntegerBuffer extends SegmentBuffer {
public String variable; public String variable;
@Override
public int getAddress(Mote mote) { public int getAddress(Mote mote) {
if (!mote.getMemory().variableExists(variable)) { if (!mote.getMemory().variableExists(variable)) {
return -1; return -1;
} }
return mote.getMemory().getVariableAddress(variable); return mote.getMemory().getVariableAddress(variable);
} }
@Override
public int getSize(Mote mote) { public int getSize(Mote mote) {
return mote.getMemory().getIntegerLength(); return mote.getMemory().getIntegerLength();
} }
@Override
public String getStatusString() { public String getStatusString() {
return "Integer " + variable; return "Integer " + variable;
} }
@Override
public void writeConfig(Element element) { public void writeConfig(Element element) {
element.setAttribute("variable", variable); element.setAttribute("variable", variable);
} }
@Override
public void applyConfig(Element element) { public void applyConfig(Element element) {
variable = element.getAttributeValue("variable"); variable = element.getAttributeValue("variable");
} }
@Override
public boolean configure(BufferListener bl) { public boolean configure(BufferListener bl) {
String suggestName = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARNAME", "node_id"); String suggestName = Cooja.getExternalToolsSetting("BUFFER_LISTENER_VARNAME", "node_id");
BufferInput infoComponent = BufferInput infoComponent =