[cooja/serialsocket] Added @Override annotations

This commit is contained in:
Enrico Joerns 2014-04-12 01:04:18 +02:00
parent af7f9ced81
commit 404fd82399
2 changed files with 16 additions and 0 deletions

View File

@ -128,6 +128,7 @@ public class SerialSocketClient extends VisPlugin implements MotePlugin {
/* Observe serial port for outgoing data */ /* Observe serial port for outgoing data */
serialPort.addSerialDataObserver(serialDataObserver = new Observer() { serialPort.addSerialDataObserver(serialDataObserver = new Observer() {
@Override
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
try { try {
if (out == null) { if (out == null) {
@ -149,6 +150,7 @@ public class SerialSocketClient extends VisPlugin implements MotePlugin {
private void startSocketReadThread(final DataInputStream in) { private void startSocketReadThread(final DataInputStream in) {
/* Forward data: virtual port -> mote */ /* Forward data: virtual port -> mote */
Thread incomingDataThread = new Thread(new Runnable() { Thread incomingDataThread = new Thread(new Runnable() {
@Override
public void run() { public void run() {
int numRead = 0; int numRead = 0;
byte[] data = new byte[1024]; byte[] data = new byte[1024];
@ -193,10 +195,12 @@ public class SerialSocketClient extends VisPlugin implements MotePlugin {
return label; return label;
} }
@Override
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) { public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
return true; return true;
} }
@Override
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
return null; return null;
} }
@ -227,6 +231,7 @@ public class SerialSocketClient extends VisPlugin implements MotePlugin {
} }
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
SerialSocketClient.this.setTitle(SerialSocketClient.this.getTitle() + " *DISCONNECTED*"); SerialSocketClient.this.setTitle(SerialSocketClient.this.getTitle() + " *DISCONNECTED*");
statusLabel.setText("Disconnected from server"); statusLabel.setText("Disconnected from server");
@ -234,10 +239,12 @@ public class SerialSocketClient extends VisPlugin implements MotePlugin {
}); });
} }
@Override
public void closePlugin() { public void closePlugin() {
cleanup(); cleanup();
} }
@Override
public Mote getMote() { public Mote getMote() {
return mote; return mote;
} }

View File

@ -129,6 +129,7 @@ public class SerialSocketServer extends VisPlugin implements MotePlugin {
} }
server = new ServerSocket(LISTEN_PORT); server = new ServerSocket(LISTEN_PORT);
new Thread() { new Thread() {
@Override
public void run() { public void run() {
while (server != null) { while (server != null) {
try { try {
@ -157,6 +158,7 @@ public class SerialSocketServer extends VisPlugin implements MotePlugin {
/* Observe serial port for outgoing data */ /* Observe serial port for outgoing data */
serialPort.addSerialDataObserver(serialDataObserver = new Observer() { serialPort.addSerialDataObserver(serialDataObserver = new Observer() {
@Override
public void update(Observable obs, Object obj) { public void update(Observable obs, Object obj) {
try { try {
if (out == null) { if (out == null) {
@ -178,6 +180,7 @@ public class SerialSocketServer extends VisPlugin implements MotePlugin {
private void startSocketReadThread(final DataInputStream in) { private void startSocketReadThread(final DataInputStream in) {
/* Forward data: virtual port -> mote */ /* Forward data: virtual port -> mote */
Thread incomingDataThread = new Thread(new Runnable() { Thread incomingDataThread = new Thread(new Runnable() {
@Override
public void run() { public void run() {
int numRead = 0; int numRead = 0;
byte[] data = new byte[1024]; byte[] data = new byte[1024];
@ -218,10 +221,12 @@ public class SerialSocketServer extends VisPlugin implements MotePlugin {
return label; return label;
} }
@Override
public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) { public boolean setConfigXML(Collection<Element> configXML, boolean visAvailable) {
return true; return true;
} }
@Override
public Collection<Element> getConfigXML() { public Collection<Element> getConfigXML() {
return null; return null;
} }
@ -251,6 +256,7 @@ public class SerialSocketServer extends VisPlugin implements MotePlugin {
if (Cooja.isVisualized()) { if (Cooja.isVisualized()) {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
statusLabel.setText("Listening on port: " + LISTEN_PORT); statusLabel.setText("Listening on port: " + LISTEN_PORT);
} }
@ -259,6 +265,7 @@ public class SerialSocketServer extends VisPlugin implements MotePlugin {
} }
private boolean closed = false; private boolean closed = false;
@Override
public void closePlugin() { public void closePlugin() {
closed = true; closed = true;
cleanupClient(); cleanupClient();
@ -269,12 +276,14 @@ public class SerialSocketServer extends VisPlugin implements MotePlugin {
} }
} }
@Override
public Mote getMote() { public Mote getMote() {
return mote; return mote;
} }
private static final int UPDATE_INTERVAL = 150; private static final int UPDATE_INTERVAL = 150;
private Timer updateTimer = new Timer(UPDATE_INTERVAL, new ActionListener() { private Timer updateTimer = new Timer(UPDATE_INTERVAL, new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) { public void actionPerformed(ActionEvent e) {
if (closed) { if (closed) {
updateTimer.stop(); updateTimer.stop();