return createErrorMessage("No mote ID specified");
int moteNr = Integer.parseInt(mote);
if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
return createErrorMessage("Bad mote ID specified: " + moteNr);
}
Mote moteObject = simulation.getMote(moteNr);
MoteMemory memory = simulation.getMote(moteNr).getMemory();
if (!(memory instanceof AddressMemory))
return createErrorMessage("Can't write mote memory variables (not address memory)");
if (!((AddressMemory) memory).variableExists(variable)) {
return createErrorMessage("Variable does not exist: " + variable);
}
Eventpoint newEventpoint = new IntegerWatchpoint(moteObject, variable);
myEvaluator.addEventpoint(newEventpoint);
return createOkMessage(newEventpoint, simulation.getSimulationTime());
}
// Variable watchpoint
if (type.equals(XML_WATCHPOINT_VARIABLE)) {
if (variable == null)
return createErrorMessage("No variable name specified");
if (variable.contains(" "))
return createErrorMessage("Variable name must not contain spaces: " + variable);
if (mote == null)
return createErrorMessage("No mote ID specified");
if (size == null)
return createErrorMessage("No size specified");
int sizeParsed = Integer.parseInt(size);
if (sizeParsed < 0) {
return createErrorMessage("Bad size specified: " + sizeParsed);
}
int moteNr = Integer.parseInt(mote);
if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
return createErrorMessage("Bad mote ID specified: " + moteNr);
}
Mote moteObject = simulation.getMote(moteNr);
MoteMemory memory = simulation.getMote(moteNr).getMemory();
if (!(memory instanceof AddressMemory))
return createErrorMessage("Can't write mote memory variables (not address memory)");
if (!((AddressMemory) memory).variableExists(variable)) {
return createErrorMessage("Variable does not exist: " + variable);
}
Eventpoint newEventpoint = new VariableWatchpoint(moteObject, variable, sizeParsed);
myEvaluator.addEventpoint(newEventpoint);
return createOkMessage(newEventpoint, simulation.getSimulationTime());
}
// Memory area watchpoint
if (type.equals(XML_WATCHPOINT_ADDRESS)) {
if (mote == null)
return createErrorMessage("No mote ID specified");
if (size == null)
return createErrorMessage("No size specified");
int sizeParsed = Integer.parseInt(size);
if (sizeParsed < 0) {
return createErrorMessage("Bad size specified: " + sizeParsed);
}
int addressParsed = Integer.parseInt(address);
if (addressParsed < 0) {
return createErrorMessage("Bad start address specified: " + addressParsed);
}
int moteNr = Integer.parseInt(mote);
if (moteNr < 0 || simulation.getMotesCount() <= moteNr) {
return createErrorMessage("Bad mote ID specified: " + moteNr);
}
Mote moteObject = simulation.getMote(moteNr);
MoteMemory memory = simulation.getMote(moteNr).getMemory();
Eventpoint newEventpoint = new Watchpoint(moteObject, addressParsed, sizeParsed);
myEvaluator.addEventpoint(newEventpoint);
return createOkMessage(newEventpoint, simulation.getSimulationTime());