Merge pull request #795 from ejoerns/pull-req/cooja-println-cleanup
[Cooja] Println cleanup
This commit is contained in:
commit
718e488b78
|
@ -3152,7 +3152,7 @@ public class Cooja extends Observable {
|
|||
if (new File(logConfigFile).exists()) {
|
||||
DOMConfigurator.configure(logConfigFile);
|
||||
} else {
|
||||
System.err.println("Failed to open " + logConfigFile);
|
||||
logger.error("Failed to open " + logConfigFile);
|
||||
System.exit(1);
|
||||
}
|
||||
} else if (new File(LOG_CONFIG_FILE).exists()) {
|
||||
|
|
|
@ -26,13 +26,6 @@
|
|||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
* SUCH DAMAGE.
|
||||
*
|
||||
*
|
||||
* -----------------------------------------------------------------
|
||||
*
|
||||
* Author : Adam Dunkels, Joakim Eriksson, Niclas Finne, Fredrik Osterlind
|
||||
* Created : 2006-06-14
|
||||
* Updated : $Date: 2009/11/13 14:27:46 $
|
||||
* $Revision: 1.15 $
|
||||
*/
|
||||
|
||||
package org.contikios.cooja.dialogs;
|
||||
|
@ -64,11 +57,21 @@ import javax.swing.JPopupMenu;
|
|||
import javax.swing.JSeparator;
|
||||
import javax.swing.ListModel;
|
||||
import javax.swing.ListSelectionModel;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.contikios.cooja.Cooja;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Adam Dunkels
|
||||
* @author Joakim Eriksson
|
||||
* @author Niclas Finne
|
||||
* @author Fredrik Osterlind
|
||||
*/
|
||||
public class MessageList extends JList {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(MessageList.class);
|
||||
|
||||
public static final int NORMAL = 0;
|
||||
public static final int WARNING = 1;
|
||||
public static final int ERROR = 2;
|
||||
|
@ -130,6 +133,7 @@ public class MessageList extends JList {
|
|||
final BufferedReader stringInput = new BufferedReader(new InputStreamReader(input));
|
||||
|
||||
Thread readThread = new Thread(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
String readLine;
|
||||
try {
|
||||
|
@ -145,8 +149,8 @@ public class MessageList extends JList {
|
|||
readThread.start();
|
||||
|
||||
return new PrintStream(output);
|
||||
} catch (Exception e) {
|
||||
System.out.println("Exception: "+ e);
|
||||
} catch (IOException e) {
|
||||
logger.error(messages);
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
@ -184,6 +188,7 @@ public class MessageList extends JList {
|
|||
messages.add(msg);
|
||||
|
||||
java.awt.EventQueue.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
updateModel();
|
||||
}
|
||||
|
@ -195,6 +200,7 @@ public class MessageList extends JList {
|
|||
((DefaultListModel) getModel()).clear();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setModel(ListModel model) {
|
||||
throw new IllegalArgumentException("changing model not permitted");
|
||||
}
|
||||
|
@ -203,16 +209,19 @@ public class MessageList extends JList {
|
|||
if (popup == null) {
|
||||
popup = new JPopupMenu();
|
||||
addMouseListener(new MouseAdapter() {
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
popup.show(MessageList.this, e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mousePressed(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
popup.show(MessageList.this, e.getX(), e.getY());
|
||||
}
|
||||
}
|
||||
@Override
|
||||
public void mouseReleased(MouseEvent e) {
|
||||
if (e.isPopupTrigger()) {
|
||||
popup.show(MessageList.this, e.getX(), e.getY());
|
||||
|
@ -230,6 +239,7 @@ public class MessageList extends JList {
|
|||
final JMenuItem hideNormalMenuItem = new JCheckBoxMenuItem("Hide normal output");
|
||||
hideNormalMenuItem.setEnabled(true);
|
||||
hideNormalMenuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MessageList.this.hideNormal = hideNormalMenuItem.isSelected();
|
||||
((MessageModel)getModel()).updateList();
|
||||
|
@ -240,16 +250,17 @@ public class MessageList extends JList {
|
|||
JMenuItem consoleOutputMenuItem = new JMenuItem("Output to console");
|
||||
consoleOutputMenuItem.setEnabled(true);
|
||||
consoleOutputMenuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
MessageContainer[] messages = getMessages();
|
||||
System.out.println("\nCOMPILATION OUTPUT:\n");
|
||||
logger.info("\nCOMPILATION OUTPUT:\n");
|
||||
for (MessageContainer msg: messages) {
|
||||
if (hideNormal && msg.type == NORMAL) {
|
||||
continue;
|
||||
}
|
||||
System.out.println(msg);
|
||||
logger.info(msg);
|
||||
}
|
||||
System.out.println();
|
||||
logger.info("\n");
|
||||
}
|
||||
});
|
||||
popup.add(consoleOutputMenuItem);
|
||||
|
@ -257,6 +268,7 @@ public class MessageList extends JList {
|
|||
JMenuItem clipboardMenuItem = new JMenuItem("Copy to clipboard");
|
||||
clipboardMenuItem.setEnabled(true);
|
||||
clipboardMenuItem.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(ActionEvent e) {
|
||||
Clipboard clipboard = Toolkit.getDefaultToolkit().getSystemClipboard();
|
||||
|
||||
|
@ -299,6 +311,7 @@ public class MessageList extends JList {
|
|||
this.type = type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return message;
|
||||
}
|
||||
|
@ -318,6 +331,7 @@ public class MessageList extends JList {
|
|||
|
||||
private class MessageRenderer extends DefaultListCellRenderer {
|
||||
private Dimension nullDimension = new Dimension(0,0);
|
||||
@Override
|
||||
public Component getListCellRendererComponent(
|
||||
JList list,
|
||||
Object value,
|
||||
|
|
|
@ -165,8 +165,7 @@ public abstract class SerialUI extends Log implements SerialPort {
|
|||
writeString(command);
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
System.err.println("could not send '" + command + "':");
|
||||
ex.printStackTrace();
|
||||
logger.error("could not send '" + command + "':", ex);
|
||||
JOptionPane.showMessageDialog(
|
||||
logTextPane,
|
||||
"Could not send '" + command + "':\n" + ex.getMessage(), "Error sending message",
|
||||
|
|
|
@ -29,12 +29,7 @@
|
|||
*/
|
||||
package org.contikios.cooja.emulatedmote;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.GridLayout;
|
||||
import java.awt.event.ActionEvent;
|
||||
import java.awt.event.ActionListener;
|
||||
import java.util.*;
|
||||
import javax.swing.*;
|
||||
import org.apache.log4j.Logger;
|
||||
import org.jdom.Element;
|
||||
|
||||
|
@ -53,7 +48,7 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
|
||||
private final static boolean DEBUG = false;
|
||||
|
||||
private static Logger logger = Logger.getLogger(Radio802154.class);
|
||||
private static final Logger logger = Logger.getLogger(Radio802154.class);
|
||||
|
||||
protected long lastEventTime = 0;
|
||||
|
||||
|
@ -103,10 +98,9 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
|
||||
buffer[len++] = val;
|
||||
|
||||
//System.out.println("## 802.15.4: " + (val&0xff) + " transmitted...");
|
||||
logger.debug("802.15.4: " + (val & 0xff) + " transmitted...");
|
||||
|
||||
if (len == 6) {
|
||||
//System.out.println("## CC2420 Packet of length: " + val + " expected...");
|
||||
expLen = val + 6;
|
||||
}
|
||||
|
||||
|
@ -120,10 +114,8 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
setChanged();
|
||||
notifyObservers();
|
||||
|
||||
// System.out.println("## CC2420 Transmission finished...");
|
||||
|
||||
lastEventTime = mote.getSimulation().getSimulationTime();
|
||||
/*logger.debug("----- SKY TRANSMISSION FINISHED -----");*/
|
||||
logger.debug("----- 802.15.4 TRANSMISSION FINISHED -----");
|
||||
lastEvent = RadioEvent.TRANSMISSION_FINISHED;
|
||||
setChanged();
|
||||
notifyObservers();
|
||||
|
@ -132,26 +124,32 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
}
|
||||
|
||||
/* Packet radio support */
|
||||
@Override
|
||||
public RadioPacket getLastPacketTransmitted() {
|
||||
return lastOutgoingPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public RadioPacket getLastPacketReceived() {
|
||||
return lastIncomingPacket;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setReceivedPacket(RadioPacket packet) {
|
||||
}
|
||||
|
||||
/* Custom data radio support */
|
||||
@Override
|
||||
public Object getLastCustomDataTransmitted() {
|
||||
return lastOutgoingByte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getLastCustomDataReceived() {
|
||||
return lastIncomingByte;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void receiveCustomData(Object data) {
|
||||
if (data instanceof RadioByte) {
|
||||
lastIncomingByte = (RadioByte) data;
|
||||
|
@ -160,14 +158,17 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
}
|
||||
|
||||
/* General radio support */
|
||||
@Override
|
||||
public boolean isTransmitting() {
|
||||
return isTransmitting;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isReceiving() {
|
||||
return isReceiving;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isInterfered() {
|
||||
return isInterfered;
|
||||
}
|
||||
|
@ -176,23 +177,31 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
|
||||
protected abstract void handleEndOfReception();
|
||||
|
||||
@Override
|
||||
public abstract int getChannel();
|
||||
|
||||
public abstract int getFrequency();
|
||||
|
||||
@Override
|
||||
public abstract boolean isRadioOn();
|
||||
|
||||
@Override
|
||||
public abstract double getCurrentOutputPower();
|
||||
|
||||
@Override
|
||||
public abstract int getCurrentOutputPowerIndicator();
|
||||
|
||||
@Override
|
||||
public abstract int getOutputPowerIndicatorMax();
|
||||
|
||||
@Override
|
||||
public abstract double getCurrentSignalStrength();
|
||||
|
||||
@Override
|
||||
public abstract void setCurrentSignalStrength(double signalStrength);
|
||||
|
||||
/* need to add a few more methods later??? */
|
||||
@Override
|
||||
public void signalReceptionStart() {
|
||||
isReceiving = true;
|
||||
|
||||
|
@ -207,6 +216,7 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
notifyObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void signalReceptionEnd() {
|
||||
/* Deliver packet data */
|
||||
isReceiving = false;
|
||||
|
@ -226,10 +236,12 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
notifyObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public RadioEvent getLastEvent() {
|
||||
return lastEvent;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void interfereAnyReception() {
|
||||
isInterfered = true;
|
||||
isReceiving = false;
|
||||
|
@ -249,18 +261,22 @@ public abstract class Radio802154 extends Radio implements CustomDataRadio {
|
|||
notifyObservers();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Mote getMote() {
|
||||
return mote;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Position getPosition() {
|
||||
return mote.getInterfaces().getPosition();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Collection<Element> getConfigXML() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setConfigXML(Collection<Element> configXML, boolean visAvailable) {
|
||||
}
|
||||
}
|
||||
|
|
|
@ -166,7 +166,6 @@ public class MemoryLayout {
|
|||
int nextsize = nextType.getSize();
|
||||
/* limit padding to word size */
|
||||
nextsize = nextsize > WORD_SIZE ? WORD_SIZE : nextsize;
|
||||
System.out.println("Nextsize: " + nextsize);
|
||||
/* calc padding */
|
||||
int pad = nextsize - currType.getSize();
|
||||
return pad;
|
||||
|
|
|
@ -2,11 +2,14 @@ package org.contikios.cooja.plugins.analyzers;
|
|||
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
import org.contikios.cooja.util.StringUtils;
|
||||
|
||||
public class IEEE802154Analyzer extends PacketAnalyzer {
|
||||
|
||||
private static final Logger logger = Logger.getLogger(IEEE802154Analyzer.class);
|
||||
|
||||
// Addressing modes
|
||||
public static final int NO_ADDRESS = 0;
|
||||
public static final int RSV_ADDRESS = 1;
|
||||
|
@ -33,7 +36,7 @@ public class IEEE802154Analyzer extends PacketAnalyzer {
|
|||
try {
|
||||
pcapExporter = new PcapExporter();
|
||||
} catch (IOException e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,8 +46,7 @@ public class IEEE802154Analyzer extends PacketAnalyzer {
|
|||
try {
|
||||
pcapExporter.openPcap(pcapFile);
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not open pcap file");
|
||||
e.printStackTrace();
|
||||
logger.error("Could not open pcap file", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -69,8 +71,7 @@ public class IEEE802154Analyzer extends PacketAnalyzer {
|
|||
try {
|
||||
pcapExporter.exportPacketData(packet.getPayload());
|
||||
} catch (IOException e) {
|
||||
System.err.println("Could not export PCap data");
|
||||
e.printStackTrace();
|
||||
logger.error("Could not export PCap data", e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package org.contikios.cooja.plugins.analyzers;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.io.File;
|
||||
import org.apache.log4j.Logger;
|
||||
|
||||
public class PcapExporter {
|
||||
private static final Logger logger = Logger.getLogger(PcapExporter.class);
|
||||
|
||||
DataOutputStream out;
|
||||
|
||||
|
@ -33,7 +33,7 @@ public class PcapExporter {
|
|||
out.writeInt(195); /* 195 for LINKTYPE_IEEE802_15_4 */
|
||||
|
||||
out.flush();
|
||||
System.out.println("Opened pcap file " + pcapFile);
|
||||
logger.info("Opened pcap file " + pcapFile);
|
||||
}
|
||||
|
||||
public void closePcap() throws IOException {
|
||||
|
@ -56,7 +56,7 @@ public class PcapExporter {
|
|||
out.write(data);
|
||||
out.flush();
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
logger.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue