Move to ReflectiveListen

This commit is contained in:
2016-07-03 16:16:04 +01:00
parent 46b377bf9a
commit 381befaa41
5 changed files with 50 additions and 44 deletions

View File

@@ -1,6 +1,5 @@
apply plugin: 'java' apply plugin: 'java'
apply plugin: 'eclipse' apply plugin: 'eclipse'
apply plugin: 'protobuf'
task wrapper(type: Wrapper) { task wrapper(type: Wrapper) {
gradleVersion = '2.2' gradleVersion = '2.2'
@@ -24,6 +23,8 @@ repositories {
} }
dependencies { dependencies {
compile 'org.slf4j:slf4j-log4j12:1.7.7'
compile 'org.picocontainer:picocontainer:2.15'
compile 'org.msgpack:msgpack:0.6.11' compile 'org.msgpack:msgpack:0.6.11'
compile 'com.sparetimelabs:purejavacomm:0.0.22' compile 'com.sparetimelabs:purejavacomm:0.0.22'
} }

View File

@@ -6,9 +6,10 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import base.work.Listen; import base.work.Listen;
import base.work.ReflectiveListen;
import base.worker.Worker; import base.worker.Worker;
public abstract class AbstractArduino extends Listen<Object> implements Arduino { public abstract class AbstractArduino extends ReflectiveListen implements Arduino {
public static final int BUFFER_SIZE = 1024; public static final int BUFFER_SIZE = 1024;
protected Logger logger = LoggerFactory.getLogger(getClass()); protected Logger logger = LoggerFactory.getLogger(getClass());
protected ArrayList<Listen<Object>> listenList; protected ArrayList<Listen<Object>> listenList;
@@ -18,11 +19,11 @@ public abstract class AbstractArduino extends Listen<Object> implements Arduino
listenList = new ArrayList<Listen<Object>>(); listenList = new ArrayList<Listen<Object>>();
} }
public void register(Listen<Object> listen) { public void register(ReflectiveListen listen) {
listenList.add(listen); listenList.add(listen);
} }
public void remove(Listen<Object> listen) { public void remove(ReflectiveListen listen) {
listenList.remove(listen); listenList.remove(listen);
} }
@@ -33,4 +34,8 @@ public abstract class AbstractArduino extends Listen<Object> implements Arduino
public void exit() { public void exit() {
stop(); stop();
} }
public void input(byte[] buffer) {
logger.error("Input was not parsed in port!");
}
} }

View File

@@ -1,13 +1,13 @@
package com.github.boukefalos.arduino; package com.github.boukefalos.arduino;
import base.Control; import base.Control;
import base.work.Listen; import base.work.ReflectiveListen;
import com.github.boukefalos.arduino.exception.ArduinoException; import com.github.boukefalos.arduino.exception.ArduinoException;
public interface Arduino extends Control { public interface Arduino extends Control {
public void register(Listen<Object> listen); public void register(ReflectiveListen listen);
public void remove(Listen<Object> listen); public void remove(ReflectiveListen listen);
public void send(byte[] buffer) throws ArduinoException; public void send(byte[] buffer) throws ArduinoException;
} }

View File

@@ -7,11 +7,11 @@ import base.Duplex;
import base.Receiver; import base.Receiver;
import base.exception.worker.ActivateException; import base.exception.worker.ActivateException;
import base.exception.worker.DeactivateException; import base.exception.worker.DeactivateException;
import base.work.Listen; import base.work.ReflectiveListen;
import com.github.boukefalos.arduino.exception.ArduinoException; import com.github.boukefalos.arduino.exception.ArduinoException;
public class Server extends Listen<Object> implements Control, Receiver { public class Server extends ReflectiveListen implements Control, Receiver {
protected static final boolean DIRECT = false; protected static final boolean DIRECT = false;
protected Arduino arduino; protected Arduino arduino;

View File

@@ -28,7 +28,7 @@ public class Port implements SerialPortEventListener {
"usbdev", // Linux "usbdev", // Linux
"tty", // Linux "tty", // Linux
"serial", // Linux "serial", // Linux
"COM3", // Windows "COM", // Windows
}; };
protected static Logger logger = LoggerFactory.getLogger(Port.class); protected static Logger logger = LoggerFactory.getLogger(Port.class);