implemented new mote type interfaces
This commit is contained in:
parent
adf1489cda
commit
1ca67916a4
|
@ -26,22 +26,16 @@
|
||||||
* 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: MicaZMote.java,v 1.2 2009/02/24 07:49:42 joxe Exp $
|
* $Id: MicaZMote.java,v 1.3 2009/03/11 14:12:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.avrmote;
|
package se.sics.cooja.avrmote;
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.io.PrintStream;
|
|
||||||
import java.net.URL;
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Observable;
|
|
||||||
import java.util.Observer;
|
import java.util.Observer;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
import org.jdom.Element;
|
import org.jdom.Element;
|
||||||
import se.sics.cooja.GUI;
|
|
||||||
import se.sics.cooja.Mote;
|
import se.sics.cooja.Mote;
|
||||||
import se.sics.cooja.MoteInterface;
|
import se.sics.cooja.MoteInterface;
|
||||||
import se.sics.cooja.MoteInterfaceHandler;
|
import se.sics.cooja.MoteInterfaceHandler;
|
||||||
|
@ -56,8 +50,6 @@ import avrora.sim.*;
|
||||||
import avrora.sim.platform.*;
|
import avrora.sim.platform.*;
|
||||||
import avrora.sim.mcu.*;
|
import avrora.sim.mcu.*;
|
||||||
import avrora.core.*;
|
import avrora.core.*;
|
||||||
import avrora.sim.radio.*;
|
|
||||||
import avrora.sim.util.SimUtil;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,7 +103,7 @@ public class MicaZMote implements Mote {
|
||||||
|
|
||||||
protected void initMote() {
|
protected void initMote() {
|
||||||
if (myMoteType != null) {
|
if (myMoteType != null) {
|
||||||
initEmulator(myMoteType.getELFFile());
|
initEmulator(myMoteType.getContikiFirmwareFile().getName());
|
||||||
myMoteInterfaceHandler = createMoteInterfaceHandler();
|
myMoteInterfaceHandler = createMoteInterfaceHandler();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -242,7 +234,7 @@ public class MicaZMote implements Mote {
|
||||||
getType().setIdentifier(element.getText());
|
getType().setIdentifier(element.getText());
|
||||||
|
|
||||||
try {
|
try {
|
||||||
prepareMote(myMoteType.getELFFile());
|
prepareMote(myMoteType.getContikiFirmwareFile().getName());
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
// TODO Auto-generated catch block
|
// TODO Auto-generated catch block
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -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: MicaZMoteType.java,v 1.1 2009/02/22 16:45:01 joxe Exp $
|
* $Id: MicaZMoteType.java,v 1.2 2009/03/11 14:12:18 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.avrmote;
|
package se.sics.cooja.avrmote;
|
||||||
|
@ -65,7 +65,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
private String description = null;
|
private String description = null;
|
||||||
|
|
||||||
/* If source file is defined, (re)compilation is performed */
|
/* If source file is defined, (re)compilation is performed */
|
||||||
private String fileFirmware = null;
|
private File fileFirmware = null;
|
||||||
private File fileSource = null;
|
private File fileSource = null;
|
||||||
private String compileCommand = null;
|
private String compileCommand = null;
|
||||||
|
|
||||||
|
@ -85,37 +85,31 @@ public class MicaZMoteType implements MoteType {
|
||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public Class<? extends MoteInterface>[] getMoteInterfaceClasses() {
|
||||||
* Set ELF file.
|
logger.fatal("Not implemented");
|
||||||
*
|
return null;
|
||||||
* @param file
|
|
||||||
* ELF file
|
|
||||||
*/
|
|
||||||
public void setELFFile(File file) {
|
|
||||||
this.fileFirmware = file.getAbsolutePath();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void setMoteInterfaceClasses(Class<? extends MoteInterface>[] classes) {
|
||||||
* Set compile command.
|
logger.fatal("Not implemented");
|
||||||
*
|
}
|
||||||
* @param command
|
|
||||||
* Compile command
|
public void setContikiFirmwareFile(File file) {
|
||||||
*/
|
this.fileFirmware = file;
|
||||||
public void setCompileCommand(String command) {
|
}
|
||||||
|
|
||||||
|
public void setCompileCommands(String command) {
|
||||||
this.compileCommand = command;
|
this.compileCommand = command;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public File getContikiFirmwareFile() {
|
||||||
* @return ELF file
|
|
||||||
*/
|
|
||||||
public String getELFFile() {
|
|
||||||
return fileFirmware;
|
return fileFirmware;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Compile command
|
* @return Compile command
|
||||||
*/
|
*/
|
||||||
public String getCompileCommand() {
|
public String getCompileCommands() {
|
||||||
return compileCommand;
|
return compileCommand;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -124,14 +118,14 @@ public class MicaZMoteType implements MoteType {
|
||||||
*
|
*
|
||||||
* @param file Source file
|
* @param file Source file
|
||||||
*/
|
*/
|
||||||
public void setSourceFile(File file) {
|
public void setContikiSourceFile(File file) {
|
||||||
fileSource = file;
|
fileSource = file;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return Source file
|
* @return Source file
|
||||||
*/
|
*/
|
||||||
public File getSourceFile() {
|
public File getContikiSourceFile() {
|
||||||
return fileSource;
|
return fileSource;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -212,7 +206,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
setDescription(targetNice + " Mote Type #" + getIdentifier());
|
setDescription(targetNice + " Mote Type #" + getIdentifier());
|
||||||
}
|
}
|
||||||
|
|
||||||
if (getSourceFile() != null) {
|
if (getContikiSourceFile() != null) {
|
||||||
compileFromSource = true;
|
compileFromSource = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -223,9 +217,9 @@ public class MicaZMoteType implements MoteType {
|
||||||
if (visAvailable) {
|
if (visAvailable) {
|
||||||
boolean success = compiler.showDialog(GUI.getTopParentContainer(), this);
|
boolean success = compiler.showDialog(GUI.getTopParentContainer(), this);
|
||||||
if (success) {
|
if (success) {
|
||||||
setSourceFile(compiler.getSourceFile());
|
setContikiSourceFile(compiler.getSourceFile());
|
||||||
setELFFile(compiler.getOutputFile());
|
setContikiFirmwareFile(compiler.getOutputFile());
|
||||||
setCompileCommand(compiler.getLastCompileCommand());
|
setCompileCommands(compiler.getLastCompileCommand());
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
|
@ -233,7 +227,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
} else {
|
} else {
|
||||||
MessageList compilationOutput = new MessageList();
|
MessageList compilationOutput = new MessageList();
|
||||||
try {
|
try {
|
||||||
compiler.compileFirmware(getSourceFile(), null, null, compilationOutput,
|
compiler.compileFirmware(getContikiSourceFile(), null, null, compilationOutput,
|
||||||
true);
|
true);
|
||||||
|
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
@ -255,9 +249,9 @@ public class MicaZMoteType implements MoteType {
|
||||||
throw newException;
|
throw newException;
|
||||||
}
|
}
|
||||||
|
|
||||||
setSourceFile(compiler.getSourceFile());
|
setContikiSourceFile(compiler.getSourceFile());
|
||||||
setELFFile(compiler.getOutputFile());
|
setContikiFirmwareFile(compiler.getOutputFile());
|
||||||
setCompileCommand(compiler.getLastCompileCommand());
|
setCompileCommands(compiler.getLastCompileCommand());
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -269,12 +263,12 @@ public class MicaZMoteType implements MoteType {
|
||||||
|
|
||||||
// Check dependency files
|
// Check dependency files
|
||||||
File elfFile = null;
|
File elfFile = null;
|
||||||
if (getELFFile() != null) {
|
if (getContikiFirmwareFile() != null) {
|
||||||
elfFile = new File(getELFFile());
|
elfFile = new File(getContikiFirmwareFile().getName());
|
||||||
}
|
}
|
||||||
if (elfFile == null || !elfFile.exists()) {
|
if (elfFile == null || !elfFile.exists()) {
|
||||||
if (!visAvailable) {
|
if (!visAvailable) {
|
||||||
throw new MoteTypeCreationException("ELF file does not exist: " + getELFFile());
|
throw new MoteTypeCreationException("ELF file does not exist: " + getContikiFirmwareFile());
|
||||||
}
|
}
|
||||||
|
|
||||||
JFileChooser fc = new JFileChooser();
|
JFileChooser fc = new JFileChooser();
|
||||||
|
@ -335,7 +329,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
setELFFile(fc.getSelectedFile());
|
setContikiFirmwareFile(fc.getSelectedFile());
|
||||||
} else {
|
} else {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -385,7 +379,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
this.target = target;
|
this.target = target;
|
||||||
}
|
}
|
||||||
|
|
||||||
private String getCompileCommand(String filename) {
|
private String getCompileCommands(String filename) {
|
||||||
if (customizedCompileCommand != null) {
|
if (customizedCompileCommand != null) {
|
||||||
return customizedCompileCommand;
|
return customizedCompileCommand;
|
||||||
}
|
}
|
||||||
|
@ -451,7 +445,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
|
|
||||||
compileButton.setEnabled(true);
|
compileButton.setEnabled(true);
|
||||||
createButton.setEnabled(false);
|
createButton.setEnabled(false);
|
||||||
compileCommandTextField.setText(getCompileCommand(name));
|
compileCommandTextField.setText(getCompileCommands(name));
|
||||||
compileButton.requestFocusInWindow();
|
compileButton.requestFocusInWindow();
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -481,7 +475,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
final String filenameNoExtension = sourceFile.getName().substring(0,
|
final String filenameNoExtension = sourceFile.getName().substring(0,
|
||||||
sourceFile.getName().length() - 2);
|
sourceFile.getName().length() - 2);
|
||||||
|
|
||||||
final String command = getCompileCommand(filenameNoExtension);
|
final String command = getCompileCommands(filenameNoExtension);
|
||||||
logger.info("-- Compiling AVR/MicaZ Firmware --");
|
logger.info("-- Compiling AVR/MicaZ Firmware --");
|
||||||
|
|
||||||
compileFirmware(command, sourceFile, filenameNoExtension + getTargetFileExtension(target),
|
compileFirmware(command, sourceFile, filenameNoExtension + getTargetFileExtension(target),
|
||||||
|
@ -771,8 +765,8 @@ public class MicaZMoteType implements MoteType {
|
||||||
label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));
|
label.setPreferredSize(new Dimension(LABEL_WIDTH, LABEL_HEIGHT));
|
||||||
|
|
||||||
sourceTextField.setText("");
|
sourceTextField.setText("");
|
||||||
if (moteType.getSourceFile() != null) {
|
if (moteType.getContikiSourceFile() != null) {
|
||||||
sourceTextField.setText(moteType.getSourceFile().getAbsolutePath());
|
sourceTextField.setText(moteType.getContikiSourceFile().getAbsolutePath());
|
||||||
}
|
}
|
||||||
sourceTextField.setColumns(25);
|
sourceTextField.setColumns(25);
|
||||||
|
|
||||||
|
@ -958,7 +952,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
});
|
});
|
||||||
|
|
||||||
updateDialog(DialogState.NO_SOURCE);
|
updateDialog(DialogState.NO_SOURCE);
|
||||||
if (moteType.getSourceFile() != null) {
|
if (moteType.getContikiSourceFile() != null) {
|
||||||
updateDialog(DialogState.SELECTED_SOURCE);
|
updateDialog(DialogState.SELECTED_SOURCE);
|
||||||
if (customizedCompileCommand != null && !customizedCompileCommand.equals("")) {
|
if (customizedCompileCommand != null && !customizedCompileCommand.equals("")) {
|
||||||
compileCommandTextField.setText(customizedCompileCommand);
|
compileCommandTextField.setText(customizedCompileCommand);
|
||||||
|
@ -1000,7 +994,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
smallPane = new JPanel(new BorderLayout());
|
smallPane = new JPanel(new BorderLayout());
|
||||||
label = new JLabel("ELF file");
|
label = new JLabel("ELF file");
|
||||||
smallPane.add(BorderLayout.WEST, label);
|
smallPane.add(BorderLayout.WEST, label);
|
||||||
File elfFile = new File(getELFFile());
|
File elfFile = getContikiFirmwareFile();
|
||||||
label = new JLabel(elfFile.getName());
|
label = new JLabel(elfFile.getName());
|
||||||
label.setToolTipText(elfFile.getPath());
|
label.setToolTipText(elfFile.getPath());
|
||||||
smallPane.add(BorderLayout.EAST, label);
|
smallPane.add(BorderLayout.EAST, label);
|
||||||
|
@ -1010,9 +1004,9 @@ public class MicaZMoteType implements MoteType {
|
||||||
smallPane = new JPanel(new BorderLayout());
|
smallPane = new JPanel(new BorderLayout());
|
||||||
label = new JLabel("Source file");
|
label = new JLabel("Source file");
|
||||||
smallPane.add(BorderLayout.WEST, label);
|
smallPane.add(BorderLayout.WEST, label);
|
||||||
if (getSourceFile() != null) {
|
if (getContikiSourceFile() != null) {
|
||||||
label = new JLabel(getSourceFile().getName());
|
label = new JLabel(getContikiSourceFile().getName());
|
||||||
label.setToolTipText(getSourceFile().getPath());
|
label.setToolTipText(getContikiSourceFile().getPath());
|
||||||
} else {
|
} else {
|
||||||
label = new JLabel("[not specified]");
|
label = new JLabel("[not specified]");
|
||||||
}
|
}
|
||||||
|
@ -1075,9 +1069,9 @@ public class MicaZMoteType implements MoteType {
|
||||||
} else {
|
} else {
|
||||||
// ELF file
|
// ELF file
|
||||||
element = new Element("elf");
|
element = new Element("elf");
|
||||||
File file = new File(fileFirmware);
|
File file = fileFirmware;
|
||||||
file = GUI.stripAbsoluteContikiPath(file);
|
file = GUI.stripAbsoluteContikiPath(file);
|
||||||
fileFirmware = file.getAbsolutePath();
|
fileFirmware = file;
|
||||||
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
element.setText(file.getPath().replaceAll("\\\\", "/"));
|
||||||
config.add(element);
|
config.add(element);
|
||||||
}
|
}
|
||||||
|
@ -1100,7 +1094,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
} else if (name.equals("command")) {
|
} else if (name.equals("command")) {
|
||||||
compileCommand = element.getText();
|
compileCommand = element.getText();
|
||||||
} else if (name.equals("elf")) {
|
} else if (name.equals("elf")) {
|
||||||
fileFirmware = new File(element.getText()).getAbsolutePath();
|
fileFirmware = new File(element.getText());
|
||||||
} else {
|
} else {
|
||||||
logger.fatal("Unrecognized entry in loaded configuration: " + name);
|
logger.fatal("Unrecognized entry in loaded configuration: " + name);
|
||||||
throw new MoteTypeCreationException(
|
throw new MoteTypeCreationException(
|
||||||
|
@ -1118,7 +1112,7 @@ public class MicaZMoteType implements MoteType {
|
||||||
if (GUI.isVisualizedInApplet()) {
|
if (GUI.isVisualizedInApplet()) {
|
||||||
String firmware = GUI.getExternalToolsSetting("MICAZ_FIRMWARE", "");
|
String firmware = GUI.getExternalToolsSetting("MICAZ_FIRMWARE", "");
|
||||||
if (!firmware.equals("")) {
|
if (!firmware.equals("")) {
|
||||||
setELFFile(new File(firmware));
|
setContikiFirmwareFile(new File(firmware));
|
||||||
JOptionPane.showMessageDialog(GUI.getTopParentContainer(),
|
JOptionPane.showMessageDialog(GUI.getTopParentContainer(),
|
||||||
"Creating mote type from precompiled firmware: " + firmware,
|
"Creating mote type from precompiled firmware: " + firmware,
|
||||||
"Compiled firmware file available", JOptionPane.INFORMATION_MESSAGE);
|
"Compiled firmware file available", JOptionPane.INFORMATION_MESSAGE);
|
||||||
|
|
|
@ -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: MicaClock.java,v 1.1 2009/02/24 07:49:42 joxe Exp $
|
* $Id: MicaClock.java,v 1.2 2009/03/11 14:12:19 fros4943 Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package se.sics.cooja.avrmote.interfaces;
|
package se.sics.cooja.avrmote.interfaces;
|
||||||
|
@ -42,7 +42,7 @@ import se.sics.cooja.interfaces.Clock;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Fredrik Österlind, Joakim Eriksson
|
* @author Fredrik Osterlind, Joakim Eriksson
|
||||||
*/
|
*/
|
||||||
@ClassDescription("Cycle clock")
|
@ClassDescription("Cycle clock")
|
||||||
public class MicaClock extends Clock {
|
public class MicaClock extends Clock {
|
||||||
|
|
Loading…
Reference in a new issue